Repository navigation
List the parts a thread can name in each visual in leaf page state - #7109
Merged
Merged
Conversation
`leaf page state` now gives each visual on the page the parts a thread can name in it, with their ids and labels, as `parts` on the visual's entry in `elements`. Agents copy a part's id from there for `thread create --part` rather than working it out from a widget's prose. The list comes from the render reading of the version the page shows, whether the agent's `page check --render` or the page's server after a handover took it, and is absent until a reading of that version exists. The render check reads each visual's parts as the page's picker and `thread create --part` admit them (`visualParts`), so a diagram without `parts` lists none, and keeps their ids and labels (`drawnParts` in `render-checks/widgets.js`) in the render-reading record, whose shape moves to `since` 56. The record moves from `render_gate.handover_pass` to `render_reading`, below `agent_state` in the import order, so page state can read it. An agent's `page check --render` now leaves its reading only where no file the version is built from has changed since the check read the source (`source_readings`, as `page stamp` compares them), so a check that a save or a data update overtook no longer replaces a later version's reading. The list is for finding a part and refuses nothing: a visual that finds a part only when asked, such as a chart's point, or draws one only while a view of it is open, lists fewer parts than it can show, and a check that failing page code ended lists none. `threads.md` and `--part`'s help point agents at the list. The render gate journey test reads the diagrams' parts from the gate's reading rather than from a second page load, and checks that a diagram admitting no part lists none.
leaf-agent
previously approved these changes
Nov 25, 2026
…rded A render reading now records the version of the page's data its check rendered with (`data.data_version`, from the check's frozen snapshot), and `page state` lists its parts only while the page shows that version and holds that data. A data update changes no version but can change what a visual draws: clearing a Playwright trace's recording removed its rows while `page state` still listed them, and `thread create` accepted the stale id. An agent's `page check --render` writes its reading without a guard again. The guard compared the page's file stamps before the write, so it also dropped a correct reading whenever another file moved, such as an image pasted into an unsent comment. The server's own reading never had it, so a data update during the server's check still stored the old parts. With the data version in the reading, a check that a save overtook can leave the page with no list, which the agent's next check restores, but never with parts the page no longer draws. `threads.md` says to run the check after a save or a data update when a visual lists no parts.
A server's reading that `_tell` weighs under the page's transaction could otherwise replace, with the data version it read, a reading the agent's check wrote between its look and its write, leaving `page state` with no parts list until another check.
leaf-agent
previously approved these changes
Nov 25, 2026
Composing the page's layer for its execution identity took 0.8 s in a cold process on a real page, against 0.2 s for the whole of `page state`, to catch a Leaf update that changes a widget's part ids while the version stands.
leaf-agent
previously approved these changes
Nov 25, 2026
max-sixty
added a commit
that referenced
this pull request
Nov 25, 2026
… validation (#7116) Splits `src/leaf/validation` so the checks lower modules call stand below them, and only `page check` stays with the page commands. This is one step of moving `src/leaf`'s children into layer subpackages: 15 of the 95 import-linter allowances were imports reaching up into `validation`. - `markup_checks/`: `markup.py` and `instances.py`, the rules a document's markup meets, checked from the document and registry given. Event admission imports it downward now. - `authored_checks/`: `admission.py`, `source.py`, `source_history.py` and `declarations.py` (formerly `composition.py`), the checks of a page's saved source, an agent's messages and a layer's declarations. It stands just below every module that calls it. - `validation/command.py` stays in place and now stands above the render gate it runs. - `unanswered_media` moves into `revision_artifact`, which `validation.md` makes the owner of a `/media/` file the page won't answer; `text_media_errors` into `authored_checks.admission`, beside `checked_text`, which runs it; `incoming_registry` into `registry.validation`. - In the order, `anchor_capture` moves below `authored_checks`, and `revisioning` above it, since activation runs the source check. Allowances go from 95 to 77. **What to check**: the two allowances that still name these modules, in `.config/importlinter.ini`. Both are new lines, and each replaces a crossing the other way on an existing cycle: - `authored_checks.source -> sample_content`: a sample's history and the message gate check each other recursively. `sample_content` admits fixture events, so it stays above event admission (formerly `sample_content -> validation.admission` and `-> validation.markup`). - `render_gate.handover_pass -> validation.command`: replaces the three `validation.command -> render_gate.*` allowances. Moving `check_page` into `render_gate` would remove it, after #7109 lands. #7109 will hit a one-line import-block conflict in `tests/model/test_handover_pass.py`; `validation/command.py` itself auto-merges. Tests: 1,162 model tests covering validation, admission, revisioning, layers, delivery and the clerk, two process tests for `page check` and `check_source`, `lint-imports`, and `pre-commit` on the changed files all pass. > _This was written by Claude Code on behalf of max-sixty_
# Conflicts: # tests/model/test_handover_pass.py
leaf-agent
approved these changes
Nov 25, 2026
This was referenced Nov 25, 2026
max-sixty
added a commit
that referenced
this pull request
Nov 25, 2026
`leaf thread create --section <visual> --part <id>` admitted any id its visual's declaration admits by prefix, so a thread on `node:nope` in a diagram was posted and drew no marker, against root `AGENTS.md`'s rule that Python never accepts an anchor the rendered page can't resolve. The command now checks the id against what the page drew of that visual: - a part the visual drew is taken; - one it didn't, on a visual that puts such a thread on the whole visual (a timeline, a trace: `drawsAbsentParts`), is taken with a note saying so; - one it didn't, on a visual that would show the thread nowhere (a diagram), is refused. The refusal lists the parts it drew and says that leaving out `--part` puts the thread on the whole visual, so the agent can always post. What the page drew comes from the render reading `page state` already lists parts from (#7109), now keeping `{parts, whole}` per visual. Where no reading holds the live version, as right after a save, the command draws the page once outside the lease, as `--quote` does since #7140. Where no browser can draw it, the id passes with a note that it went unchecked. To weigh: READING's shape changed, so the page protocol moves 56 → 57. A visual that lists no parts and doesn't draw absent ones is refused, which goes one step past the rule Max chose. `thread reply --part` still takes any declared id. Max chose this design on the issue ([comment](#7039 (comment))). Tests: `drawn_part` per branch and the CLI against a stored reading and with no browser (model tier), the drawing path on a real diagram and timeline (browser tier), and the help regtest. Closes #7039 > _This was written by Claude Code on behalf of max-sixty_
max-sixty
pushed a commit
that referenced
this pull request
Nov 25, 2026
…page state (#7181) Since #7109, `leaf page state` opened the active revision's document twice: it got the render reading's digest from `read_artifact`, which builds a bundle descriptor and reads the document again even though the state read had already read it. The held revision reading carries the same digest (`RevisionReading.digest`, computed from the manifest, documented as `RevisionArtifact.digest`), so `page_state`, the thread part check in `thread.py` and the handover pass's `_live` in `handover_pass.py`, which made the same digest-only call, now take it from `read_revision`. Nothing changes in what any of them reports. `tests/journeys/test_interact_document.py::test_a_state_read_never_materializes_a_revision_bundle` fails on `main` (`assert 2 == 1` at line 781) and passes with this change; `tests/model/test_interact_anchors.py` and `tests/model/test_handover_pass.py` pass too. Closes #7176 — automated triage --------- Co-authored-by: leaf-agent <[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.
An agent that names one box of a diagram in a thread (
leaf thread create --section <visual-id> --part <part-id>) has had to work out the part's id from the widget's prose, such asnode:and a percent-encoded source id. Of the 313 threads agents opened on this machine's pages, none named a part.leaf page statenow lists, on each visual's entry inelements, the parts a thread can name in it, each with itsidandlabel, so the agent copies one:{"id": "design-diagram", "parts": [{"id": "node:proposed", "label": "Proposed"}, {"id": "node:today", "label": "Today: every command"}, …]}The list comes from the render reading of the version the page shows: the agent's
page check --render, or the reading the page's server takes after each handover. Neither starts a browser for it. Until a reading of that version exists, the visual's entry has noparts.thread create --partaccepts (visualParts), so a diagram without apartsattribute lists none. The render check already read each visual's inventory to validate it;drawnParts(src/leaf/render-checks/widgets.js) keeps the ids and labels in the render-reading record, which moves tosrc/leaf/render_reading.pysoagent_statecan import it.thread create --partstill decides what it accepts;threads.mdand--part's help point agents at the list.data.data_version, from the check's frozen snapshot), andpage statelists its parts only while the page shows that version and holds that data. A data update changes no version but can change what a visual draws, as clearing a Playwright trace's recording removes its rows, so after one the list is absent until the next check. A check of an older version that finishes after a newer one's still replaces its reading, as before this change; the page then lists no parts until a check reads it again, and never lists parts it doesn't draw. Guarding that write would compare the page's file stamps, which an image pasted into an unsent comment also moves; it only takes the page's transaction, so a server's reading can't replace it unseen. A Leaf update that changes a widget's part ids while the version stands still lists the old ids until the next check:thread createrefuses one whose prefix the widget no longer declares, and keying the list by the execution identity too would add about 0.8 s to everypage state. A check that failing page code ends draws no visuals, so its reading lists no parts; keeping an earlier reading's parts for that version would need a merge rule of its own for a page whose code fails only sometimes.dataandpartsfields, so itssincemoves from 43 to the current protocol, 56 (layer-registry.md, "Page protocol"); the protocol baseline changes only that entry.uv run pytest tests/model/test_handover_pass.py tests/model/test_interact_layer.pypasses, with tests that a reading's parts reachpage stateonly for the version and the data it read, and list again once a check reads the page after a data update.tests/journeys/test_render_gate.py::test_the_gate_passes_what_the_renderer_drawsreads the diagrams' parts from the gate's reading, including a namespace drawn only in hierarchical mode and a quoted ER name, and checks that a diagram admitting no part lists none.pnpm run test:runtimeandpnpm run check:browserpass.