Skip to content

Move the code other modules import from leaf-dev commands into helper modules - #6380

Merged
max-sixty merged 4 commits into
mainfrom
leaf-dev-commands-not-libraries
Nov 18, 2026
Merged

max-sixty merged 4 commits into
mainfrom
leaf-dev-commands-not-libraries

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

Follow-up to #6014, which left other code importing from leaf-dev command modules. Now a command module is imported only by the CLI and by the tests of that command: the code other modules borrowed lives in helper modules, and dev/AGENTS.md states the rule.

  • dev/leaf_dev/website.py reaches leaf.page or the local build from a browser: page loads, state reads, activation, user sessions, the local adapter and the local Worker, and the built site's paths (SITE, asset_site, install_tree, site_lock). It came out of site verify, from which journey run imported a dozen names, and site build. Its browser script (website.js, formerly verify_browser.js) and wrangler_server.mjs moved beside it, and startup_profile and startup_line joined startup.py.
  • dev/leaf_dev/corpus.py is the corpus generator, which named_source, page_fixtures and states call on demand.
  • server_paths.py folded into commands/bench.py, its only user, which ends their import cycle. Its names that collided with bench's took a server prefix (measure_server, SERVER_FITTED, …).
  • arms.py holds preview_lease and the terminated stop handler, which the Codex journey and website_eval imported from preview.
  • Group helpers: placement/_pin_cases.py, the catalogue tests/browser/margin/test_pins.py asserts, and site/_build.py and site/_distribution.py, the pipeline site previews and the product tests use. pins.py, build.py and distribution.py keep their commands.

The code moved unchanged apart from those renames and two paths: website.py reads the build's manifest through leaf_website.SITE_MANIFEST and its lock through site_lock, where site verify had spelled both out a second time.

To weigh: site previews now ends with the build site build runs (_build.build_site), which also takes the site's lock and bundles the published runtime, so the .tmp/site it leaves is one site verify website-worker can read; before, it rebuilt .tmp/site unlocked and unbundled. git records _build.py, _distribution.py and _pin_cases.py as new files, so their history before this change is on build.py, distribution.py and pins.py.

Checks: every touched command's --help; generate corpus, bench events --read server, placement pins, site distribution and site build end to end; the dev tests over the moved code, where only the ten tests #6374 fixes fail, as on main; the product tests that import it; and pre-commit on every changed file. site verify website-worker times out at its first activation through the local Worker on this machine, on main as well, so that pass is unverified here. Each moved definition matches its original by AST apart from the changes above.

Max asked for this as the follow-up #6014's description named.

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

@max-sixty
max-sixty merged commit 69c4c65 into main Nov 18, 2026
5 checks passed
@max-sixty
max-sixty deleted the leaf-dev-commands-not-libraries branch November 18, 2026 18:11
max-sixty added a commit that referenced this pull request Nov 18, 2026
…ts a leaf-dev command module (#6407)

Makes `dev/AGENTS.md`'s rule that only the CLI and tests import a
`leaf-dev` command module a ruff check. `banned-api` (TID251) bans
`leaf_dev.commands` everywhere except `cli.py`, the commands themselves
and the two test trees, so pre-commit, CI and `wt merge` refuse a helper
module that imports a command, with a message saying where the code
goes.

Five commits between 19 October and 3 November added such imports, and
#6014 and #6380 then took two PRs to move them out; this check would
have refused each one at commit time. It doesn't see one group's command
importing another group's command. Nothing on main does that: every
import inside `commands/` is of the importer's own group's `_name.py`.

Max asked whether to add this as the follow-up to #6380.

Checks: `pre-commit run ruff-check --all-files` passes on main, and a
used `from leaf_dev.commands.site.verify import PAGES` added to
`dev/leaf_dev/website_eval.py` fails with the message.

> _This was written by Claude Code on behalf of max-sixty_
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