Skip to content

Consolidate six duplicated helpers in dev/, tests/ and worker/ - #6733

Merged
leaf-agent merged 1 commit into
mainfrom
dup-sweep-dev-build-tests-worker
Nov 22, 2026
Merged

leaf-agent merged 1 commit into
mainfrom
dup-sweep-dev-build-tests-worker

Conversation

@leaf-agent

Copy link
Copy Markdown
Collaborator

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.

Sets found and left alone
  • Sets an open PR is changing. Nothing in this diff overlaps another open PR's hunks. Move 45 over-budget tests to daily journeys, and stop five waiting out an unanswered title completion #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.

Weekly duplicate sweep of dev/, build/, tests/ and worker/. Each set moves
onto one home and every caller follows; behavior is unchanged.

- The core's and bundled packages' stylesheets less what they vendor:
  interact_support.shipped_sheets, replacing two sheets() functions and five
  inline loops in the model tests.
- Running tests/js_facts.mjs: dev/tests/test_js_facts.py now calls
  interact_support.js_facts.
- Lowercase hex of bytes in the Worker: routing.hex (formerly newSessionId),
  with storage's two SHA-256 digests through one sha256Hex.
- Whether a pid is alive: leaf.machine.pid_alive, replacing two os.kill(pid, 0)
  copies in tests.
- Reading an example's seeded log: read_event_lines(seed_log(source)), replacing
  three inline parsers, one of which split on splitlines().
- The bundled registries and which keys are elements, in leaf_dev: docs and
  logs usage read leaf.schema's paths and is_element_name rather than their own
  paths, "lf-" prefix test and regex; stills and test_product_page take
  leaf.schema.DEFAULT_PACKAGE.
@leaf-agent

Copy link
Copy Markdown
Collaborator Author

The one red test, tests/journeys/test_render_pages.py::test_a_shipped_log_replays_its_example_state (KeyError: 'id'), comes from main, not from this PR. examples/developer/diff-thread-gallery.jsonl, added in #6682, seeds two replies without an id, and the test fails the same way when run by node id on main at 850e0bf. It ran here only because this PR edits the test file. #6737 gives the two replies ids, and with it the test passes.

The red pytest step also skipped the Worker dry-run deploy. On this head the Worker still bundles. The dry run stopped only at the container image build, which needs Docker the sandbox lacks, and this PR touches no container files. pnpm run test:worker passes, 99 tests.

@leaf-agent
leaf-agent merged commit 4c4438d into main Nov 22, 2026
7 of 8 checks passed
@leaf-agent
leaf-agent deleted the dup-sweep-dev-build-tests-worker branch November 22, 2026 10:07
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.

1 participant