Repository navigation
Admit example seed logs through the append door - #3881
Merged
Merged
Conversation
`prepare_page` used to append an example's `<stem>.jsonl` to `events.jsonl` as raw text, after the first stamp. Every page `leaf-dev preview`, `leaf-dev site` and the suite's `serve` build from an example skipped `event_contracts.append_admitted`, so its log could hold events no writer could send, in a shape real pages never have.
Now `_seed_log` admits each seed event through `append_admitted` once the page has stamped the revision the event names. An event a later version answers lands after that version's stamp, in the order a real page records it. A refusal raises `EventRefused`, with a note naming the seed file and event id, from the build that lays the seed in.
## What admission found
I routed every seed (5 examples, 3 regression fixtures, 104 events) through `append_admitted` in a scratch copy before changing anything (`.tmp/measure_seed.py`, not committed):
- **Derived fields copied in by hand.** 9 actions carried a hand-written `meaning` and 2 comment/reply lines in `feature-gallery` carried `attention`. Admission writes both fields itself and refuses them in a command. Each stale `meaning` differed from what admission now derives: it was missing `minLength: 1` on option values, and for the board move, `minLength` on `value`/`unit` and the rank `pattern`. The seeds now leave both fields out.
- **Unvoiced thread titles.** 8 `thread_title` lines in the two developer galleries had no `session`, which the record contract requires. Each now carries the session of its thread's agent replies where they have one (`01a0bfe4-…`), else `gallery-agent`, the session the feature gallery's pickup already names. Nothing reads a title's session, so nothing on screen changes.
- **Revisions not yet stamped.** 3 `review-a-plan` events and the last reply in `feature-gallery` name revision 2 or 3 but were written right after the first stamp. Admission refused them there ("reply revision must be one of [1]"), so seeds now wait for their revision.
- With those fixed, admission keeps every seed's ids, order and fields. It adds `attention` to every event and the current `meaning` to actions, as on every real page.
Thread ids and their order are unchanged, so the gallery's `t` walks and pinned ids still hold.
I diffed each fixture's served state (`full_state`) between the old raw append and the new path, ignoring timestamps and note ids. The only differences are the added `attention` flags, the refreshed `meaning` schemas, the thread-title sessions, and the later seq of the events that now follow their revision's stamp (which also makes the page's latest agent voice Codex instead of the preparing session on `review-a-plan`). Queues, obligations and thread state are identical.
## The corpus
`leaf-dev corpus` ran `sample_events` over the raw seed files, which only worked because the seeds were in stored form: closures read each action's `meaning`. `build_events` now builds the source's page in a temporary directory, takes the closures from its admitted log, and writes them without the derived fields, so the corpus's own seed goes through the door as commands too. Today the only source this builds is the feature gallery. It adds about 2 s to each `corpus.generate` (0.33 s before, 2.4 s after for `build_events`, measured in-process), which corpus previews pay on each source edit. Max may prefer another trade-off here.
## Tests
- New `test_a_seed_no_writer_could_send_stops_the_page_it_seeds`: a seed carrying a derived `attention` is refused by `prepare_page`, and the same comment without it is admitted with `attention` written. It fails on the old `page_fixtures.py` (`DID NOT RAISE EventRefused`).
- `test_page_fixtures_pass_check` for every seeded fixture and the corpus (9 passed). These now admit every seed, so a bad seed fails here.
- `tests/model/test_interact_product.py`, `tests/model/test_product_page.py`, `tests/model/interact_contract/test_layer_contract.py`, `test_revendoring.py`, `dev/tests/model/test_interact_preview.py`, `dev/tests/model/test_interact_product.py` (162 passed).
- Browser: `test_a_shipped_log_replays_its_example_state`, `test_the_layer_traps_no_margin_in_the_panel_it_draws`, `tests/browser/test_render_sample_delivery.py`, `tests/browser/threads/test_rewrites.py`, the feature gallery's core journeys, the thread-panel gallery, the chrome-key axe check, the gallery's stamped embed, the corpus whole-page rules, and the nested primary reader (46 passed).
Not run: the `test_site.py` builds, `leaf-dev pins` (whose generated seed is plain comments), and the nightly files outside that selection.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Main's #3958 runs a fixture's seed receipt with the fixture's own runtime, since another Leaf refuses a page vendored at a different protocol. Seed admission now runs there too: ADMIT_SEED admits each batch of seed events and, after the last stamp, writes the receipt, in one subprocess of the fixture's runtime; a refusal raises RuntimeError carrying the door's finding. The seed logs are main's, rewritten by the same rules this branch applied by hand (drop the derived meaning and attention, give a thread title its thread's agent session). Main moved the seeded-fragment test to the journeys tier (#3926); its docstring takes this branch's edit there, and the new seed test stays in the model tier. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
max-sixty
marked this pull request as ready for review
October 27, 2026 05:42
Co-Authored-By: Claude Opus 5.5 <[email protected]>
leaf-agent
approved these changes
Oct 27, 2026
max-sixty
added a commit
that referenced
this pull request
Oct 27, 2026
`leaf-dev probe --log` and the page fixture's seed now admit events through one helper, `page_fixtures.admit_events`, and `arms.admit_log` is deleted. ## Why #3881 left two subprocess runners for a runtime's `append_admitted`: `ADMIT_SEED` in `page_fixtures.py` for an example's companion log, and `_ADMIT`/`admit_log` in `arms.py` for `probe --log`. They had already drifted: - `admit_log` split lines with `splitlines()`, which breaks a message holding U+2028 into two invalid lines. The fixture path splits on `"\n"` for that reason. - One ran `python -I`, the other didn't. - One raised `click.ClickException`, the other `RuntimeError`. ## Change - `read_event_lines(path)` reads a log file the fixture's way (split on `"\n"`). Both callers use it. - `admit_events(runtime, page, events, *, log, env, stamped=False, acknowledge=False)` runs one script (`ADMIT`) under the page's own runtime with `python -I`, and returns how many events it admitted. `stamped` holds back events naming a revision that hasn't been stamped yet. The fixture passes it between stamps, which keeps the per-stamp interleaving its `each_version` callback reads. `acknowledge` writes the receipt after the last stamp. `probe --log` passes neither, so its events stay unacknowledged, as before. - A refusal raises `click.ClickException` naming the log file and the event id. `probe` already reports a `ClickException` per arm, so a refused seed now prints as that arm's build failure instead of a traceback. Preview converts both exception types to the same message. ## Tests `tests/model/test_interact_product.py::test_a_seed_no_writer_could_send_stops_the_page_it_seeds` now writes its seed with a raw U+2028 inside the message and asserts that the admitted text keeps it. It expects `click.ClickException` for the refused seed. With `splitlines()` in the shared reader, this test fails. Also ran: - `dev/tests/model/test_interact_preview.py -k acknowledges_its_seed`. - A build of every versioned, seeded example (`log-retention`, `review-a-plan`) with `each_version`. Each version's events landed after its stamp, and the receipt came last. - `leaf-dev probe review-a-plan --base --log` with a U+2028 message. The served state holds the message whole on both arms. - `probe --log` with a refused event, which printed `build: admitting …: event 'q' refused: …` for the arm. - pre-commit and `pnpm run check`. > _This was written by Claude Code on behalf of max-sixty_
This was referenced Oct 28, 2026
leaf-agent
added a commit
that referenced
this pull request
Oct 28, 2026
The example-opening test folded `ship-review.jsonl` as stored events, but #3881 changed companion logs to writer commands admitted when building each page. Actions in that input correctly omit `meaning`, so the test raised `KeyError` while computing expected thread counts even after the browser had opened the example. Read the served page's admitted log instead, preserving the checks for open and resolved threads, attached passage paint, and the reply widget. This keeps #3881's admission boundary and changes no product behavior. Validation: the focused example-opening browser test fails with `KeyError: 'meaning'` before this correction and passes after it. Pre-commit passes, including Ruff and Vulture. Closes #4453 — automated triage Co-authored-by: leaf-agent <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
prepare_pageused to append an example's<stem>.jsonltoevents.jsonlas raw text, after the first stamp. Every pageleaf-dev preview,leaf-dev siteand the suite'sservebuild from an example skippedevent_contracts.append_admitted, so its log could hold events no writer could send, in a shape real pages never have.Now
_seed_logadmits each seed event throughappend_admittedonce the page has stamped the revision the event names. An event a later version answers lands after that version's stamp, in the order a real page records it. Admission runs with the fixture's own runtime (ADMIT_SEED, oneuv run --project <runtime>per stamp that has events to admit), as the seed's receipt already did since #3958, because another Leaf refuses a page vendored at a different protocol; the same subprocess writes the receipt after the last stamp. A refusal raisesRuntimeErrorcarrying the door's finding and the seed event's id, from the build that lays the seed in.What admission found
The seed logs are main's as of the merge, rewritten by the rules below; applying the same rewrite to the logs this branch started from reproduces its hand edits byte for byte.
I routed every seed (5 examples, 3 regression fixtures, 104 events) through
append_admittedin a scratch copy before changing anything (.tmp/measure_seed.py, not committed):meaningand 2 comment/reply lines infeature-gallerycarriedattention. Admission writes both fields itself and refuses them in a command. Each stalemeaningdiffered from what admission now derives: it was missingminLength: 1on option values, and for the board move,minLengthonvalue/unitand the rankpattern. The seeds now leave both fields out.thread_titlelines in the two developer galleries had nosession, which the record contract requires. Each now carries the session of its thread's agent replies where they have one (01a0bfe4-…), elsegallery-agent, the session the feature gallery's pickup already names. Nothing reads a title's session, so nothing on screen changes.review-a-planevents and the last reply infeature-galleryname revision 2 or 3 but were written right after the first stamp. Admission refused them there ("reply revision must be one of [1]"), so seeds now wait for their revision.attentionto every event and the currentmeaningto actions, as on every real page.Thread ids and their order are unchanged, so the gallery's
twalks and pinned ids still hold.I diffed each fixture's served state (
full_state) between the old raw append and the new path, ignoring timestamps and note ids. The only differences are the addedattentionflags, the refreshedmeaningschemas, the thread-title sessions, and the later seq of the events that now follow their revision's stamp (which also makes the page's latest agent voice Codex instead of the preparing session onreview-a-plan). Queues, obligations and thread state are identical.The corpus
leaf-dev corpusransample_eventsover the raw seed files, which only worked because the seeds were in stored form: closures read each action'smeaning.build_eventsnow builds the source's page in a temporary directory, takes the closures from its admitted log, and writes them without the derived fields, so the corpus's own seed goes through the door as commands too. Today the only source this builds is the feature gallery. It adds about 2 s to eachcorpus.generate(0.33 s before, 2.4 s after forbuild_events, measured in-process), which corpus previews pay on each source edit. Max may prefer another trade-off here.Tests
test_a_seed_no_writer_could_send_stops_the_page_it_seeds: a seed carrying a derivedattentionis refused byprepare_page(RuntimeErrornamingattention), and the same comment without it is admitted withattentionwritten. It fails on the oldpage_fixtures.py(DID NOT RAISE EventRefused).test_page_fixtures_pass_checkfor every seeded fixture and the corpus (9 passed). These now admit every seed, so a bad seed fails here.tests/model/test_interact_product.py,tests/model/test_product_page.py,tests/model/interact_contract/test_layer_contract.py,test_revendoring.py,dev/tests/model/test_interact_preview.py,dev/tests/model/test_interact_product.py(162 passed).test_a_shipped_log_replays_its_example_state,test_the_layer_traps_no_margin_in_the_panel_it_draws,tests/browser/test_render_sample_delivery.py,tests/browser/threads/test_rewrites.py, the feature gallery's core journeys, the thread-panel gallery, the chrome-key axe check, the gallery's stamped embed, the corpus whole-page rules, and the nested primary reader (46 passed).Not run: the
test_site.pybuilds,leaf-dev pins(whose generated seed is plain comments), and the nightly files outside that selection.