Skip to content

Group leaf-dev's commands by subject and use, and merge the evidence galleries' duplicated code - #5965

Merged
max-sixty merged 11 commits into
mainfrom
thread-placement-anchor
Nov 15, 2026
Merged

max-sixty merged 11 commits into
mainfrom
thread-placement-anchor

Conversation

@max-sixty

@max-sixty max-sixty commented Nov 14, 2026 •

Copy link
Copy Markdown
Owner

leaf-dev had 28 commands at one level, so a command's name had to say its subject, and several didn't: placements showed only thread cards, pins only comment pins, and the site's six commands were spread across the list. This groups the commands by subject and by use, cuts every caller over, and merges the evidence galleries' duplicated code.

leaf-dev
  bench  preview  probe  setup  stills  trace-server
  placement  pins  cards                         (cards was placements)
  journey    run  chart  session  snapshots      (journey, journey-chart, claude-code-session, thread-snapshots)
  logs       response-times  timeline
  suite      flake  bugback  profile             (profile was suite-profile)
  eval       run  report                         (eval, eval-report)
  site       build  verify  distribution  previews  demo  media
  generate   corpus  record-types

The grouping. A group gathers the commands a developer reaches for together about one subject. The commands sessions run most, and across subjects, stay at the top: over the last two weeks probe ran in 90 of 146 sessions, and preview and stills in 37 each. compare is now preview --base [REF] (with --authored), the flag every other command that runs two versions takes. dev/AGENTS.md states the rule.

The mechanism. A package in leaf_dev/commands/ is a group of the commands its modules are, found by name as modules always were.

  • A module whose name starts with _ is the group's own helper rather than a command.
  • Help lists the top-level commands and the groups in separate sections, and each group's line names its commands.
  • A command module defines the Click command of its command's name, so a moved module keeps its function names and names its command in the decorator.

Every import, module path, file path and invocation follows: CI, the wt and pre-commit hooks, the Worker's bundle test, the skills and the docs. Scratch paths follow too, for example .tmp/cards and .tmp/preview-base.

The merged code. leaf_dev/gallery.py writes the pages that show Leaf's drawing case by case, used by placement pins, placement cards, stills, journey snapshots and eval report:

  • media writes a capture into a page under its content name, which pins and cards each did.
  • frame cuts a crop box around a case's regions, the same box on every arm. stills, snapshots and pins each did this.
  • marked outlines and tints what a case is about, which stills, pins and cards each did.
  • shot builds an lf-shot pair, or a linked image where only one arm ran, which pins, cards and eval report each did.
  • page builds the page shell, which pins, cards and eval report each did.

browser.QUOTE_RANGE replaces five JavaScript copies of finding quoted words in a page.

Testing:

  • Every command and group loads, and its --help runs.
  • These pass: the dev model tier, the product model tests that import moved modules, test_evals, the pins catalogue test, and the send-placement and margin tests.
  • Two dev tests fail on main too: test_preview_file_subscription_follows_atomic_replacements and test_a_composed_part_refuses_an_authored_copy.
  • stills --base draws the four states whose JavaScript changed as before.
  • Both galleries run end to end.

Left for a follow-up: moving the journey and eval library modules under their groups, moving pins onto visits, and the other duplicated mechanisms a sweep of leaf-dev found (bin/leaf runners, arm Python, media naming).

Open PRs that edit a moved module will need to follow the move: #5953 edits flake.py, now suite/flake.py, and #5197 edits suite_profile.py, now suite/profile.py.

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

…nstead of 28

leaf-dev listed 28 commands at one level, so a command's name had to say its
subject, and several didn't: `placements` showed only thread cards, `pins`
only comment pins, and `site`, `verify-site`, `refresh-previews`,
`record-demo` and `publish-media` were one family spread across the list.

A package in leaf_dev/commands/ is now a group of the commands its modules
are, found by name as modules always were, and described in help by its
docstring with its commands listed. The groups gather the commands a developer
reaches for together about one subject; the commands sessions run most and
across subjects stay at the top (probe, preview and stills, in 90, 37 and 37
of the last two weeks' 146 sessions).

  placement  pins, cards (was placements)
  journey    run, chart, session, snapshots
  logs       response-times, timeline
  suite      flake, bugback, profile
  eval       run, report
  site       build, verify, distribution, previews, demo, media
  generate   corpus, record-types
  bench  preview  probe  setup  stills  trace-server

`compare` is now `preview --base [REF]`, with `--authored`, the flag every
other command that runs two versions takes. A command module defines the
Click command of its command's name, so a moved module keeps its function
names and names its command in the decorator.

Every import, module path, file path and invocation in the tree follows,
including CI, the wt and pre-commit hooks, the Worker's bundle test and the
skills. dev/AGENTS.md states the grouping rule.
…rough one gallery module

pins and cards each wrote a capture into a page's media under its content
name, drew the boxes a case is about over the capture, built the lf-shot pair
or lone image for a case and wrapped the page in its own document shell, and
eval report built the same lf-shot pair. leaf_dev/gallery.py now does each
once: media, marked, shot and page. Both galleries now mark their cases with
the same rounded outline and tinted fill, in their own colors, and a lone
capture is a linked image in both. cards' own section builder is
window_sections, so the module name stays free.
placement pins, placement cards, two stills states and site demo each walked
a page's text nodes for a run of words in their own JavaScript. QUOTE_RANGE is
pins' version, which finds words across text nodes as a passage may run, and
the others embed it. The four stills states it touches draw as before.
long_source_selected keeps its own walk: it finds its second words only after
its first, which a search from the start wouldn't.
…ups hold private helpers, and finish the cut-over

Crop boxes: stills, journey snapshots and placement pins each worked out the
padded box around a capture's regions, kept inside the capture, so every
arm's crop lines up. gallery.frame does it once, and gallery.edges reads a
browser's {x, y, width, height} rectangle. stills' diff outlines and pins'
target outlines come from gallery.marked, as cards' already did. eval report
and cards' fixture page take gallery.page, which now names its Layout.

Discovery: a module in a group whose name starts with _ is the group's own
helper rather than a command, so a group can hold its library code. Help
lists the top-level commands and the groups in separate sections.

The cut-over's leftovers, found in review:
- the record-types pre-commit hook watched the generator's old path, so an
  edit to it skipped its check;
- worker/README.md, publish-site.yaml and startup.js still named
  verify-site and journey;
- scratch paths and keys still used commands that no longer exist:
  .tmp/compare is now .tmp/preview-base, .tmp/placements is .tmp/cards,
  .tmp/verify-site is .tmp/site-verify, and claude-code-session is
  journey-session.

preview's summary names --base, so a developer looking for compare finds it.
…oss text nodes

verify-website.yaml still uploaded .tmp/verify-site/run-*, so a failed verify
uploaded nothing without a warning. word_lines' and placement cards'
docstrings said a quote lies in one text node, which QUOTE_RANGE no longer
needs.

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One regression in placement cards. When no arm captured a case, the gallery now shows the text "None" in that case's figure. Inline suggestion below.

The regrouping and the gallery helpers look right otherwise. Every command and group loads and its --help runs. The focused dev tests pass apart from the two the description names, and both also fail on current main. A placement pins run draws its outlines clear of the pins.

leaf-agent
leaf-agent previously approved these changes Nov 14, 2026
max-sixty added a commit that referenced this pull request Nov 14, 2026
…ch for a mechanism before writing one (#5967)

Sessions keep re-implementing leaf-dev mechanisms that already exist;
`leaf-dev placements` (#5846) rewrote `leaf-dev pins`' report page. Two
causes are fixed here. First, Claude Code re-attaches only the first
20,000 characters of a loaded skill after a compaction, and
developing-leaf (29,913 bytes) lost its tail, including "Weigh what a
change adds" with its "What it repeats" search, in 66 of the 78
compacted sessions that loaded it since 1 November. The skill now moves
the procedures one occasion needs into `references/` behind stub
headings, which keep every citation working, and drops to 17,095 bytes.
A pre-commit hook holds it, and the shipped leaf skill, under 19,500
bytes; the skill has grown about 1,500 characters a week, so the hook
fires again within a couple of weeks, asking for the next move. Second,
`dev/AGENTS.md` sent an author to three module headers, while the code
they needed lived inside other commands. It now asks for a search by the
calls a mechanism makes.

Replaying the placements session from the user's request: on the old
guidance, both runs wrote their own media writer, page shell and outline
without opening `pins.py`. On this branch, both grepped for `ImageDraw`
and `media_name`, read pins' report code, and moved its media writer
into `page_fixtures.py` for both commands to import. Neither shared the
page shell or the `lf-shot` pair; #5965 consolidates those.

Moved text is byte-identical to the sections it came from. Pre-commit
passes; no suite run, since nothing here is code.

Asked for by Max. Codex reviewed the diff; its one finding (the search
stopped at `dev/`) is folded in.

> _This was written by Claude Code on behalf of max-sixty_
# Conflicts:
#	.claude/skills/developing-leaf/SKILL.md
#	.pre-commit-config.yaml
#	dev/AGENTS.md
#	src/leaf/forks.py
leaf-agent
leaf-agent previously approved these changes Nov 14, 2026
# Conflicts:
#	.claude/skills/developing-leaf/references/agent-journey.md
#	dev/leaf_dev/journey_claude_code.py
#	evals/fork-reply/case.yaml
#	notes/fork-replies.md
#	src/leaf/forks.py
leaf-agent
leaf-agent previously approved these changes Nov 15, 2026
@max-sixty
max-sixty merged commit 8106a4d into main Nov 15, 2026
7 checks passed
@max-sixty
max-sixty deleted the thread-placement-anchor branch November 15, 2026 01:32
max-sixty added a commit that referenced this pull request Nov 15, 2026
…ings do

main grouped leaf-dev's commands by subject (#5965), and `logs` holds the
commands that read real pages' logs, which is what this one does. It is now
`leaf-dev logs usage`, and the sentence that names it moved with "Regular
maintenance" from the developing-leaf skill to the root AGENTS.md (#6003).

`--since` took a naive ISO time and then failed with a traceback comparing it
to the log's timezone-aware stamps. It now reads the time through
`interaction_time`, as `logs timeline` and `logs response-times` do, and
refuses one without an offset by name.
max-sixty added a commit that referenced this pull request Nov 18, 2026
Follow-up to #5965, which grouped `leaf-dev`'s commands: this merges the
developer tooling's internal duplicates, so each mechanism has one home.
52 files, +2541 / −2581; most of the ± is code moving between modules.

### Group helpers instead of command modules used as libraries

- The shared journey machinery (`Isolation`, `Terminal`, `User`, …)
moved out of the command `commands/journey/run.py` into
`commands/journey/_journey.py`, and the harness journeys into
`commands/journey/_claude_code.py`, `_codex.py` and `_pi.py`. `run.py`
keeps the command.
- `logs response-times`' reader moved to `leaf_dev/page_timings.py`,
since the journey, `logs timeline` and `delivery_eval` imported it from
the command; `suite.py` moved to `commands/suite/_runs.py`.
- `dev/AGENTS.md` says where a helper only one group uses goes
(`_name.py`, which `cli.py` lists as no command).
- No eval module moved: none of the moves would remove a cross-group
import, and eval cases name executors by module path.

Command modules other code still imports as libraries remain: `site
verify`'s page and session helpers (the journey imports 12 names, and
this PR adds `load_presented`), `generate corpus`, `preview`'s lease,
`bench` (with `server_paths`, a cycle), `journey snapshots` and `site
build`/`distribution`. Moving them needs about 600 lines out of
`verify`; that's a separate decision.

### `placement pins` on `leaf_dev.visits`

`placement pins` now visits its arms through the loop `placement cards`,
`stills` and `probe` share. Its report and all 52 full screenshots are
byte- and pixel-identical to the old loop's, with and without `--base`.

### Merged duplicates

- `arms.run_leaf(arm | None, state | None, env=, error=)` runs Leaf for
the site build and the fork eval too, from the repository root, against
which a page's layer resolves a relative package such as the docs'
`./docs/package`; `arms.arm_python` builds the command for code run in
an arm's interpreter (five callers).
- `leaf.media.write_media` writes developer media, with
`require_media_type` for the refusal `site media` had copied.
- `site verify` opens each page through one `load_presented`; its
saved-state pass now checks the durable source after presentation rather
than before, which changes only which failure is reported first.
- A process's state home points at scratch through `patch.dict`; visits'
console readings through `collect_page_errors(warnings=)`; a mark's
colour through `panel_paint.ink_box` with a per-channel window, which
reproduces `marked_tops` on 300 blurred frames and runs 9x faster.
- The UI review's `provider.mjs` asks Python for the Claude login home
and environment (`arms.claude_home`, `arms.environment`) instead of
copying them.
- `hook_transport.inline_delivery` reads a hook's inline delivery for
the Claude Code journey, `logs timeline` and the harness;
`arms.phase_traces` splits a stream trace at its `eval_phase` marks
(equivalent on 2,000 random traces).
- The usability eval captures its comment anchors with `anchor_capture`.
Anchors now carry Leaf's captured context and refuse a quote their
element holds twice, as Leaf does, where the hand-built one took the
first match; every anchor the cases and fixtures name still captures.
- `suite flake`, `suite bugback` and eval runs allocate their
directories with `run_directory`, now named `run-YYYYMMDD-HHMMSS-…`;
CI's `run-*` globs still match, and no code parses the name.
- Seven Python copies resolve the host's Claude and Codex config
directories through `leaf.harness`, and five hand-written one-liners
call the library or `leaf_dev` helper they repeated.

Left as copies, because their behaviour differs in ways one parameter
can't carry: `preview`'s own runner (streams stderr, keeps the session
environment, exits with Leaf's status), `eval report`'s Leaf (builds the
developer's own page with their configuration), `control-legibility`'s
provider, Node's `CODEX_HOME` lookup, archiving a sample's pages, and
the judge inputs `regrade.py` and `authoring_assertion.mjs` build, which
name the pages differently, so merging them changes what judges read.

### Checks

- `uv run leaf-dev --help` and every touched command's `--help`;
`placement pins` (with and without `--base`), `placement cards --case
words-long`, `probe` with the `panel_paint` journey, `bench --read
server`, `preview`, `journey chart` and `logs timeline` end to end; the
site build's `page init` from outside the repository root.
- `dev/tests` covering the touched modules, the `tests/` model, process
and browser tests that import them, and pre-commit (ruff, vulture, ty,
knip, prettier, eslint, typos) on every changed file.
- Ten dev tests fail identically on main (`1289a479d5`), so none is this
branch's: `test_preview_file_subscription_follows_atomic_replacements`,
`test_desktop_start_requires_its_validated_native_chat` (3 cases) and
`test_serving_connects_codex_feedback_before_handing_over_its_url` (4
cases) in `test_interact_preview.py`, one case of
`test_product_page.py::test_a_composed_part_refuses_an_authored_copy`,
and
`test_the_page_a_turn_has_just_written_waits_for_its_revision_after_presentation`,
which has failed since #5228 (its fake page returns a list for the new
`innerText` read).
- After merging main (291 commits), main's edits to code this branch
moved out of `journey/run.py` were carried into `_journey.py` (the
seven-character release hash, `open_news`'s selector, `send_comment`
without `passage`); on the merged head, pre-commit, the dev tests, the
product tests over the resolved conflicts (panel paint, pins, frame
marks, website routes, media), `placement pins` (with and without
`--base`), `placement cards --case words-long`, the `panel_paint` probe,
`bench --read server`, `preview`, `journey chart` and `logs timeline`
were rerun.
- An independent review read the branch and reran these; the one
regression it found, the site build failing outside the repository root,
is fixed here.

> _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