playtest atlas: attribute an entry to the lenses whose requests just ended, and keep a persona's split memories whole
The Zyphos runs named four to seven lenses per entry; the ten-second window spanned a whole sweep. Lenses now come from request-end times read once a second, and a persona memory that a semicolon split is rejoined instead of printed as unread. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
ff89da5db0
commit
d4d6421693
1 changed files with 33 additions and 30 deletions
|
|
@ -40,10 +40,10 @@ use tokio::sync::Semaphore;
|
|||
/// The snapshot id the live server's re-import of the Zyphos vault at Zyphos
|
||||
/// main 49207ef produced. A run that imports another reports it.
|
||||
const EXPECTED_ZYPHOS_SNAPSHOT: &str = "62b087811a62a1cbeb641743f4cf0a13254dbda1244399273db9ae9cd5f58094";
|
||||
/// An entry that appears this soon after a lens's inference counts as that
|
||||
/// lens's: sessions commit at the end of their last round.
|
||||
const LENS_WINDOW: Duration = Duration::from_secs(10);
|
||||
const POLL_EVERY: Duration = Duration::from_secs(4);
|
||||
/// An entry counts as the work of the lenses whose requests ended within this
|
||||
/// long before the last read: sessions commit as their last round returns.
|
||||
const LENS_WINDOW: Duration = Duration::from_millis(2500);
|
||||
const POLL_EVERY: Duration = Duration::from_secs(1);
|
||||
/// Sweeps in a row that commit nothing before the run stops: what is left is
|
||||
/// refused or unanswerable, not undone.
|
||||
const STALL_SWEEPS: u32 = 3;
|
||||
|
|
@ -112,30 +112,26 @@ impl AtlasOptions {
|
|||
|
||||
// ------------------------------------------------------------ the two taps
|
||||
|
||||
/// Which lenses have inference in flight or just finished.
|
||||
/// When each lens's inferences ended. A session commits as its last request
|
||||
/// returns, so what appears in the world was written by a lens whose request
|
||||
/// ended just before it.
|
||||
#[derive(Default)]
|
||||
struct Activity(StdMutex<BTreeMap<Lens, (usize, Option<Instant>)>>);
|
||||
struct Activity(StdMutex<Vec<(Lens, Instant)>>);
|
||||
|
||||
impl Activity {
|
||||
fn begin(&self, lens: Lens) {
|
||||
self.0.lock().unwrap().entry(lens).or_default().0 += 1;
|
||||
}
|
||||
|
||||
fn end(&self, lens: Lens) {
|
||||
let mut table = self.0.lock().unwrap();
|
||||
let slot = table.entry(lens).or_default();
|
||||
slot.0 = slot.0.saturating_sub(1);
|
||||
slot.1 = Some(Instant::now());
|
||||
self.0.lock().unwrap().push((lens, Instant::now()));
|
||||
}
|
||||
|
||||
fn recent(&self) -> Vec<Lens> {
|
||||
self.0
|
||||
.lock()
|
||||
.unwrap()
|
||||
.iter()
|
||||
.filter(|(_, (inflight, last))| *inflight > 0 || last.is_some_and(|at| at.elapsed() < LENS_WINDOW))
|
||||
.map(|(lens, _)| *lens)
|
||||
.collect()
|
||||
/// The lenses whose requests ended after `since`, in the order they first ended.
|
||||
fn ended_since(&self, since: Instant) -> Vec<Lens> {
|
||||
let mut lenses = Vec::new();
|
||||
for (lens, at) in self.0.lock().unwrap().iter() {
|
||||
if *at >= since && !lenses.contains(lens) {
|
||||
lenses.push(*lens);
|
||||
}
|
||||
}
|
||||
lenses
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -160,9 +156,6 @@ impl InferencePort for LensTap {
|
|||
|
||||
async fn infer(&self, request: PreparedInference) -> Result<InferenceOutput, InferenceFault> {
|
||||
let lens = lens_of(&request);
|
||||
if let Some(lens) = lens {
|
||||
self.activity.begin(lens);
|
||||
}
|
||||
let output = self.inner.infer(request).await;
|
||||
if let Some(lens) = lens {
|
||||
self.activity.end(lens);
|
||||
|
|
@ -579,6 +572,14 @@ fn parse_world(view: &str) -> World {
|
|||
} else if let Some((_, id, rest)) = bracketed(&piece) {
|
||||
let voice = rest.trim_start_matches(": voice ").trim().trim_matches('"').to_owned();
|
||||
world.materials.push(Material { id, voice, ..Material::default() });
|
||||
} else if let Some(last) = world.materials.last_mut() {
|
||||
// A `;` inside a memory or read splits it; the piece continues the
|
||||
// last field the material carries.
|
||||
let field = [&mut last.reads, &mut last.memories, &mut last.values, &mut last.voice].into_iter().find(|field| !field.is_empty());
|
||||
if let Some(field) = field {
|
||||
field.push_str("; ");
|
||||
field.push_str(&piece);
|
||||
}
|
||||
} else {
|
||||
world.unread.push(format!("persona material: {piece}"));
|
||||
}
|
||||
|
|
@ -720,6 +721,7 @@ struct Watch<'a> {
|
|||
host: &'a crate::timelines::TimelineHost,
|
||||
activity: &'a Activity,
|
||||
seen: BTreeMap<String, Seen>,
|
||||
last_poll: Instant,
|
||||
}
|
||||
|
||||
impl Watch<'_> {
|
||||
|
|
@ -729,7 +731,8 @@ impl Watch<'_> {
|
|||
let snapshot = self.host.world.snapshot().await.ok()?;
|
||||
let world = parse_world(&table_view(&snapshot));
|
||||
// Begin's seed and its run-ahead are not a sweep of this run; no lens is read for them.
|
||||
let lenses = if sweep == 0 { Vec::new() } else { self.activity.recent() };
|
||||
let lenses = if sweep == 0 { Vec::new() } else { self.activity.ended_since(self.last_poll.checked_sub(LENS_WINDOW).unwrap_or(self.last_poll)) };
|
||||
self.last_poll = Instant::now();
|
||||
for (key, (section, label)) in world.keyed() {
|
||||
self.seen.entry(key).or_insert_with(|| Seen { sweep, lenses: lenses.clone(), section, label });
|
||||
}
|
||||
|
|
@ -824,7 +827,7 @@ pub(super) async fn run(options: AtlasOptions) -> anyhow::Result<PathBuf> {
|
|||
let recorder = Arc::new(Recorder { inner: evidence, sweep: AtomicUsize::new(0), log: StdMutex::new(Vec::new()) });
|
||||
let runner = host.controllers.elaborator(recorder.clone());
|
||||
|
||||
let mut watch = Watch { host: &host, activity: &activity, seen: BTreeMap::new() };
|
||||
let mut watch = Watch { host: &host, activity: &activity, seen: BTreeMap::new(), last_poll: Instant::now() };
|
||||
watch.poll(0).await.context("the seeded world could not be read")?;
|
||||
let opening = host.world.snapshot().await?;
|
||||
log(format!(
|
||||
|
|
@ -1059,9 +1062,9 @@ fn render_atlas(header: &Header, world: &World, seen: &BTreeMap<String, Seen>, r
|
|||
out.push_str(
|
||||
"How to read this. Every entry below was admitted by the kernel from an elaborator's patch; nothing here was written by hand. \
|
||||
The kernel keeps no separate kinds for customs, laws, debts or traits: they appear as facts (with standing), routine and obligation \
|
||||
commitments, offices and authority grants, forums, and the causes behind each regard. \"Added in\" names the sweep and the lens whose \
|
||||
inference was running or had just finished when the entry first appeared, so within a sweep of concurrent sessions it can name a \
|
||||
neighbour lens. \"Drew on\" lists vault notes retrieved in that sweep by a query that named the entry or its place; the journal's own \
|
||||
commitments, offices and authority grants, forums, and the causes behind each regard. \"Added in\" names the sweep and the lenses whose \
|
||||
inference ended in the seconds before the entry first appeared, so with two sessions running at once it can name the other \
|
||||
session's lens as well. \"Drew on\" lists vault notes retrieved in that sweep by a query that named the entry or its place; the journal's own \
|
||||
per-patch evidence references are not readable outside the kernel, so an entry no query named says so.\n\n",
|
||||
);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue