Skip to content

Admit example seed logs through the append door - #3881

Merged
max-sixty merged 4 commits into
mainfrom
grind/f-seed-admission
Oct 27, 2026
Merged

max-sixty merged 4 commits into
mainfrom
grind/f-seed-admission

Conversation

@max-sixty

@max-sixty max-sixty commented Oct 25, 2026 •

Copy link
Copy Markdown
Owner

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. Admission runs with the fixture's own runtime (ADMIT_SEED, one uv 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 raises RuntimeError carrying 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_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 (RuntimeError naming attention), 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.

This was written by Claude Code on behalf of max-sixty

max-sixty and others added 3 commits October 24, 2026 21:10
`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
max-sixty marked this pull request as ready for review October 27, 2026 05:42
@max-sixty
max-sixty merged commit d8ffa04 into main Oct 27, 2026
4 of 5 checks passed
@max-sixty
max-sixty deleted the grind/f-seed-admission branch October 27, 2026 06:23
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_
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants