Repository navigation
fix: admit fixture seeds and probe logs through one helper - #4484
Merged
Merged
Conversation
`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`.
leaf-agent
approved these changes
Oct 27, 2026
leaf-agent
added a commit
that referenced
this pull request
Nov 22, 2026
This week's duplicate sweep of `dev/`, `build/`, `tests/` and `worker/` (week 47) moves six duplicated helpers onto one home each and moves every caller. Behavior stays the same. The touched model tests, the dev js_facts tests and the Worker's routing, storage and index tests pass. A script compared the old and new outputs of the consolidated `leaf_dev` functions and the seeded-log reads across the corpus, and they match. | Question | Home | Copies removed (introducing PR) | |---|---|---| | Which stylesheets do the core and the bundled packages ship, leaving out vendored files? | new `interact_support.shipped_sheets` | `sheets()` in `test_interface_fonts.py` (#4804) and `test_theme_tokens.py` (#6025). Five inline loops in `test_interact_layer.py` (#3138, #3886) | | Run `tests/js_facts.mjs` | `interact_support.js_facts` (#2666) | its own subprocess call in `dev/tests/test_js_facts.py` (#5118) | | Lowercase hex of bytes in the Worker | `routing.hex`, which is `newSessionId` (#313) renamed, plus a `sha256Hex` in `storage.ts` | the publication-identity and chunk-digest copies in `storage.ts` (#2652) | | Is this pid alive? | `leaf.machine.pid_alive` | `_alive` in `tests/process/test_codex_tool.py` (#3331). `running()` in `test_interact_layer.py` (#1774) | | Read an example's seeded log | `read_event_lines(seed_log(source))` (#4484) | inline parsers in `test_render_pages.py`, `test_interact_product.py` (#924) and `test_render_gate.py` (#509). The last one split lines with `splitlines()`, which also breaks at U+2028 | | Paths of the bundled registries and packages; which registry keys name elements | `leaf.schema.ASSETS` / `BUNDLED_PACKAGES` / `DEFAULT_PACKAGE`, `leaf.registry.contract.is_element_name`, `docs.registries()` | `docs.py`'s own `ASSETS`/`PACKAGES` (#3593) and its `startswith("lf-")` checks (#2660). `logs usage`'s hand-written regex and registry list (#5970). `ROOT / "packages" / "default"` in `stills.py` (#3927) and `test_product_page.py` (#3593) | `is_element_name` and the two checks it replaces give the same answer for every key in the bundled registries today. A selector key such as `lf-options.selected` would have passed the `lf-` prefix test. <details><summary>Sets found and left alone</summary> - **Sets an open PR is changing.** Nothing in this diff overlaps another open PR's hunks. #6732 moves tests out of `test_render_gate.py`, `test_render_pages.py` and `test_interact_layer.py`, but none of the tests changed here. - **Changes to browser tests with nothing run to check them.** The WCAG contrast computation exists as about 11 copies across browser, journey and model tests. Other copies: about 9 `EDITOR_ROOTS` shadow-root keepers, the `/api/interaction` batch predicates, CDP `touch()` closures, one-line patch templates, reply-holding route handlers, and the `data-lf-entry` runtime-module import snippet in `dev/leaf_dev/states.py` and in tests. Each would mean editing browser tests that this sweep can't run on a shared host. They suit a sweep that can run those tests. - **Vendor bundling.** `build/browser/build.mjs` builds signals-core and Lit with esbuild calls that repeat `build/vendor.mjs`'s `bundle()`. Merging them changes build options and needs a full `check:browser` byte comparison, so it was left for a change that runs that. - **Copies that are near but not the same.** `_build.py`'s `check_links` repeats `leaf_website.released_path`, but it also needs the matched page's root and kind. The list of API-key variables an eval drops is repeated across Python and the Promptfoo configs, as subsets and supersets of one another. The Codex token-expiry check has different thresholds, 1 h and 60 s. - **Too small to be worth it.** Picking a free loopback port (`eval_user.py`, `interact_support.available_loopback_port`). The XDG state root in `leaf_dev.state_home` and `leaf.state.state_home`. The `settled` helper in two `tests/runtime` files. </details> 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.
leaf-dev probe --logand the page fixture's seed now admit events through one helper,page_fixtures.admit_events, andarms.admit_logis deleted.Why
#3881 left two subprocess runners for a runtime's
append_admitted:ADMIT_SEEDinpage_fixtures.pyfor an example's companion log, and_ADMIT/admit_loginarms.pyforprobe --log. They had already drifted:admit_logsplit lines withsplitlines(), which breaks a message holding U+2028 into two invalid lines. The fixture path splits on"\n"for that reason.python -I, the other didn't.click.ClickException, the otherRuntimeError.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 withpython -I, and returns how many events it admitted.stampedholds back events naming a revision that hasn't been stamped yet. The fixture passes it between stamps, which keeps the per-stamp interleaving itseach_versioncallback reads.acknowledgewrites the receipt after the last stamp.probe --logpasses neither, so its events stay unacknowledged, as before.click.ClickExceptionnaming the log file and the event id.probealready reports aClickExceptionper 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_seedsnow writes its seed with a raw U+2028 inside the message and asserts that the admitted text keeps it. It expectsclick.ClickExceptionfor the refused seed. Withsplitlines()in the shared reader, this test fails.Also ran:
dev/tests/model/test_interact_preview.py -k acknowledges_its_seed.log-retention,review-a-plan) witheach_version. Each version's events landed after its stamp, and the receipt came last.leaf-dev probe review-a-plan --base --logwith a U+2028 message. The served state holds the message whole on both arms.probe --logwith a refused event, which printedbuild: admitting …: event 'q' refused: …for the arm.pnpm run check.