Repository navigation
Run bench-check's tracer as a script, not through PYTHONPATH - #1373
Merged
Merged
Conversation
bench-check traced `leaf page check --render` by putting a directory holding sitecustomize.py first on the child's PYTHONPATH, so Python imported it at startup. That is an import-path edit the repository no longer makes. The child now runs the command bin/leaf runs, `uv run -q --no-dev --project ARM python`, with tracer/traced_leaf.py in place of `-m leaf`. The script installs the same sys.monitoring hooks, takes the trace path and function table as arguments rather than environment variables, and runs leaf through runpy as `-m leaf` would, so argv, prog name and exit status match. The spans and phase rows are unchanged; the wall leaves out only the /bin/sh that bin/leaf execs uv from. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
approved these changes
Sep 27, 2026
max-sixty
added a commit
that referenced
this pull request
Sep 28, 2026
…1384) `scripts/` held what the suite could import only through pytest's `pythonpath = ["scripts"]`. Each script becomes a `leaf-dev` command in the module that owns it, the directory is gone, and nothing in the tree reaches code through `sys.path`, `PYTHONPATH`, `pythonpath` or a file path any more. | Was | Now | |---|---| | `scripts/preview.py` | `leaf-dev preview` | | `scripts/corpus.py` | `leaf-dev corpus` | | `scripts/keydocs.py` | `leaf-dev keydocs` | | `scripts/verify_site.py` (+ `verify-site-browser.js`) | `leaf-dev verify-site` | | `scripts/verify_codex_task.py` | `leaf-dev verify-codex-task` | | `scripts/deploy-site-dev.sh` | `worker/deploy-dev.sh` (`npm run deploy:dev`) | - **Preview's worker.** `leaf-dev preview` execs its worker into the selected checkout's `--no-dev` environment, overlaid with this checkout's `leaf_dev` and `watchfiles`. The worker runs `python -m leaf_dev.preview` rather than the command group, because the group's other commands import `leaf_website`, which that environment lacks. The argparse options become click options with the same names, and the hidden `--_worker` flag becomes `--worker`. Usage errors still exit 2, and a failed `leaf` call still exits with that call's own status. - **Callers.** CI, `publish-site` (its run lines and path filters), the eslint override, the Worker's npm script, and the tests all use the new names. The suite imports `from leaf_dev import preview, verify_site, corpus, keydocs`, and runs the preview as `python -m leaf_dev preview`. - **Guidance.** `scripts/AGENTS.md` folds into `dev/AGENTS.md`, which now states the rule against import-path edits. The `AGENTS.md` repository map, `/developing-leaf` and the other docs name the commands. - **Tests that faked a stale install.** Two tests put an older `leaf` first on `PYTHONPATH` to stand in for a stale plugin install: the `--version`/`--root` test and the re-vendor restart test. Each now installs the payload (`install_payload`) and runs that install's own `bin/leaf`, as a host does. Their assertions are unchanged. - **Regenerated files.** `examples/corpus.html` and `docs/registry.html` each change one line, the generator name in their header comment. `TODO.md`'s "Repository tooling" item is done, so it is removed. `leaf-dev bench-check` already stopped using `PYTHONPATH` in #1373. **Checks:** - `leaf-dev --help` lists the five new commands. - `leaf-dev preview triage-board --export` writes the page. `leaf-dev corpus` reproduces the committed corpus. - pytest passed 153 of 153 on `test_interact_preview`, `test_interact_product`, `test_website_server`, and the two rewritten tests. - pre-commit passes on every changed file. - The nightly `test_render_export` tests that wait for a watched edit fail locally. They fail on this machine regardless of the change: plain `watchfiles.watch` on a fresh temp directory reports no edit at all right now, at a load average above 40. Four of them, run alone on the merge base (2553559), fail the same way. CI's run is the reading for those tests. > _This was written by Claude Code on behalf of max-sixty_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 (1M context) <[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 bench-checkloaded its tracer by putting a directory holdingsitecustomize.pyfirst on the child'sPYTHONPATH, so Python imported it at startup. The repository no longer edits an import path, so this was one of the items left inTODO.md. This PR removes it and deletes that TODO line.The traced child now runs the command
bin/leafruns,uv run -q --no-dev --project <arm> python, withdev/leaf_dev/tracer/traced_leaf.pyin place of-m leaf. The script installs the samesys.monitoringhooks, then runsleafthroughrunpy.run_module("leaf", run_name="__main__", alter_sys=True). argv, theleafprog name and the exit status therefore matchpython -m leaf. The trace path and the function table are now arguments to the script; before, they were environment variables. The script sits alone intracer/: Python puts a script's own directory first onsys.path, so there it shadows nothing, where-mwould put the working directory. Only the/bin/shthatbin/leafexecs uv from drops out of the measured wall; the spans and the phase rows are unchanged.Verified:
uv run leaf-dev bench-checkran end to end with the script tracer. Its tables have the same 80 rows as a run with the oldsitecustomize.pytracer on this machine, with identical labels in the same order and no-cells, and no check failed.--rootexits 0 and writes a trace. An unknownleaf pagesubcommand exits 2 withleaf's own usage line, and the trace records theclispan.🤖 Generated with Claude Code