Skip to content

Add leaf-dev logs usage: what the pages on this machine used - #5970

Merged
max-sixty merged 10 commits into
mainfrom
fable-crust
Nov 22, 2026
Merged

max-sixty merged 10 commits into
mainfrom
fable-crust

Conversation

@max-sixty

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

Copy link
Copy Markdown
Owner

Adds leaf-dev logs usage, which reads the page directories under the state home and prints what they used: the pages holding each registered widget, the packages their layer records select, each command a person ran with its sessions and pages, and each leaf command with the runs agents made against a page. "Regular maintenance" in the root AGENTS.md asks who would notice a mechanism gone; until now the only evidence was whether an example or a test named it, and the record of real use in every page directory went unread. It sits in the logs group with the other commands that read real pages' logs, and reads --since as they do, refusing a time without its offset.

/developing-leaf's references/removals.md, which a session opens before proposing a removal, names the command and says what its count is evidence for: a feature nothing here used is a candidate to test, and the count alone decides no removal. The root AGENTS.md is unchanged.

On 2026-11-21 it read 462 page directories and 506 sessions. No page held lf-file-editor, lf-file-tree, lf-deck, lf-visual-review, lf-dial or lf-call-diff.

To weigh: it counts one machine's use. Max kept the three features whose removal first cited it (#5972, #5974, #5976, all closed), on the ground that his own use is not specific enough, and the examples built since for three of those widgets are the test he asked for instead. Two shortcuts are deliberate: a session counts as a person unless its browser calls itself headless, and command ids minted per element (option.choose-<id>) fold into one row where ten or more share a stem. It has no tests, and dev/tests now runs daily, so a later change to the logs' shape would break it unnoticed.

Requested as part of the "crust and big simplifications" run. Checked with pre-commit on the changed files and by running it against the state home, with and without a valid --since.

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

Regular maintenance asks who would notice a mechanism gone, and until now the
only evidence was the tree: whether an example or a test names the thing. The
record of real use sits in every page directory. `leaf-dev usage` reads it and
prints, for the pages under the state home, the pages holding each registered
widget, the packages their layer records select, each command a person ran with
its sessions and pages, and each `leaf` command with the runs agents made
against a page. Headless sessions, which are checks and probes driving a page,
are left out of the commands.

On 2026-11-14 it reads 400 page directories and 593 sessions in 44 s. No page
holds `lf-file-editor`, `lf-visual-review`, `lf-deck`, `lf-file-tree`, `lf-dial`
or `lf-call-diff`; `leaf file bind`, `codex launch`, `page picture` and
`page report` have no run.

The developing-leaf skill's "Regular maintenance" names the command where it
asks who would notice.

@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 page that a newer Leaf initialized stops the whole survey. layer_record raises IncompatibleLayer for a record at a later shape (its docstring says it does this on purpose, so page init won't mistake the record for none), and survey doesn't catch it. With one page dir in a scratch state home holding {"format":"leaf-layer/999999"}, leaf-dev usage exits with "was initialized by a Leaf newer than this one… Use a newer Leaf." and prints no tables. Every worktree on the machine shares that state home, so a page touched from a branch that bumps the layer shape or the protocol is enough to trigger it. The header already says packages count only "for the pages whose record this Leaf reads", so the code should skip those pages and leave the other tables intact. See the inline suggestions.

Comment thread dev/leaf_dev/commands/usage.py Resolved
Comment thread dev/leaf_dev/commands/usage.py Resolved
The skill is 30,189 characters on main since #5820, over the 30,000 cap
`test_every_skill_file_reads_in_one_command` holds, so the sentence naming
`leaf-dev usage` under "Regular maintenance" can't land until the file has
room. The command's own header and `leaf-dev --help` describe it meanwhile.

@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.

babcb1b drops the skill sentence, but the description still says "One sentence in that section names the command." Merging squashes with the PR body as main's commit message, so that claim would land false. It should either go, or say the sentence waits until the skill has room under the 30,000-character cap.

`layer_record` refuses a record at a later shape, so that `page init` won't take
it for none and replace the page's selection. The survey has no such stake, and
every worktree shares the state home, so one page a newer branch initialized
stopped the whole survey with that refusal. It now reads the record with
`LAYER.read`, which answers none for a shape this Leaf doesn't read, and the
packages count covers the pages it does read, as its header says.
…tice

"Regular maintenance" asks who would notice a mechanism gone, and the command
answers from the pages on this machine. The sentence waited for #5967, which
split the skill and brought it back under its 30,000-character cap.
# Conflicts:
#	.claude/skills/developing-leaf/SKILL.md
…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 max-sixty changed the title Add leaf-dev usage: what the pages on this machine used Add leaf-dev logs usage: what the pages on this machine used Nov 15, 2026
max-sixty added a commit that referenced this pull request Nov 20, 2026
Rewrites the root `AGENTS.md` so a reader who has only the file can
parse each sentence on the first read. Below "Repository map" no rule
changes: pronouns give way to their nouns, a rule is split from its
mechanism and its reason, and Tend and the server's "reading" are
defined where they first appear. "Keep the layer open" now defines a
content widget, says what core code may not do, and limits the rule
against naming widgets to Leaf's own instructions (`SKILL.md`, its
references, and the entries in `browser/registry.json` and the kernel
registry), leaving a package's guidance free to name any widget, as the
maintainer decided. The defects a review reports in instruction text
become a list, with a new item for a sentence its reader can parse only
on a second read, and Tend's review threshold names that list instead of
the label "public surface traps". In the maintainer's sections above
"Repository map", only the three readings the maintainer picked change:
when Leaf adds code to prevent a failure ("Leaf's role"), that contract
prose may be edited for clarity ("Stage"), and that the code making a
change records it ("Responsiveness").

**To weigh:** Fresh readers given only the file flagged 60 and 72 of
about 250 sentences as needing a second read on `main`; on this branch
two readers of the draft flagged 31 each and a reader of the final text
28, none unsettled. Below "Repository map" that is 41 and 53 down to 13,
13 and 8. Most of what remains sits in the maintainer's sections, whose
proposed rewrite (9 flags in one read) waits on the maintainer. Asked
ten questions about rules the rewrite touched, fresh agents given only
the old file said it left the question open in 6 of 30 answers, and
given the new file in none; every new-file answer matched the code.
Codex compared old and new for changed rules and false claims, and its
eight findings on the first draft are fixed. The file grows from 5,538
to about 6,270 words, since a sentence that names its noun and splits
off its reason is longer. A full-file rewrite conflicts with the open
drafts that edit this file (#6023, #6024, #5979, #5970); it leaves the
`hooks/` line that #6574 edits alone.

Asked by max-sixty, who picked the three readings on the survey page; he
hasn't read this diff. Prose only; pre-commit passes.

> _This was written by Claude Code on behalf of max-sixty_
main rewrote the root AGENTS.md's "Regular maintenance" and moved how to measure a
removal into /developing-leaf's references/removals.md. The sentence naming
`leaf-dev logs usage` moves there with it, and the root file takes main's text
unchanged. It now also says what the count is evidence for: a feature nothing here
used is a candidate to test, and the count alone decides no removal.

@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.

The description still says "One sentence in that section names the command", and the section it means is "Regular maintenance" in the root AGENTS.md. The diff doesn't touch AGENTS.md: the sentence went into .claude/skills/developing-leaf/references/removals.md ("Measure a removal"). The squash merge makes the description main's commit message, so as it stands the message points readers at the wrong file. Naming removals.md there fixes it.

@max-sixty

Copy link
Copy Markdown
Owner Author

Fixed in the description, which I rewrote a few minutes after this head was pushed: it now says /developing-leaf's references/removals.md names the command and that the root AGENTS.md is unchanged.

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

@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.

Confirmed: the description now places the sentence in removals.md and says the root AGENTS.md is unchanged, which matches the diff. That was the last open finding.

@max-sixty
max-sixty marked this pull request as ready for review November 22, 2026 02:09
@max-sixty
max-sixty merged commit 203d4ab into main Nov 22, 2026
8 checks passed
@max-sixty
max-sixty deleted the fable-crust branch November 22, 2026 02:10
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]>
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