Skip to content

Let the browser alone place the words an agent's comment quotes - #7353

Merged
max-sixty merged 7 commits into
mainfrom
quote-browser-only-trial
Nov 27, 2026
Merged

max-sixty merged 7 commits into
mainfrom
quote-browser-only-trial

Conversation

@max-sixty

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

Copy link
Copy Markdown
Owner

The browser alone places the words an agent's comment quotes. leaf thread create --quote no longer refuses a quote for its words, and Python no longer keeps a copy of the browser's passage reading that has to match it exactly. Python checks only the --section. It reads the page's files as evidence: where it finds the words once, it supplies the neighbours that tell that copy from another, and where it finds them zero or several times, it adds a note.

The maintainer picked this direction on the quote-finding review page (option "Let the browser alone place the words"). That approval covered the protocol bump, the removal of about 360 lines that existed only to keep the two readings in step, and the root AGENTS.md rule change.

What changes for an agent and a user

  • A quote is never refused for its words. Where the file reading finds the words zero or several times, thread create and thread reply post the thread with an unplaced-quote note saying where it stands. For example: "Leaf's reading of the page's files finds 'ship it' 2 times in § rollout, so unless the page as drawn shows it once, the thread stands on § rollout as a whole, with the quote above its messages". The note doesn't tell the agent to quote again: an earlier wording that did led 1 eval run in 4 to post a second thread on the same question.

  • Where the file reading finds the words once, the anchor stores that copy's neighbours, as a selection does. Where the agent named no section, it also stores the element around that copy. Two cases this fixes:

    • an identifier quoted in prose stays on the prose when the same section's code block shows it too;
    • a thread stays on its copy when a later version adds another.

    The approved option said "no context"; this keeps the neighbours as a hint instead. The browser reads them only to tell copies apart, and a sole copy wins whatever they say. So a hint that disagrees with the drawn page costs at most the exact place. The maintainer may reverse this call.

  • A thread whose words the page doesn't show once stands on its section instead of detaching. That covers words a script replaced, a misquote, and repeated words no context tells apart. With no section, it stands in Threads. Its quote reads "Changed" where the page doesn't show the words at all, and has no status word where the page shows them more than once.

  • A revision moves a thread to its section where the file reading finds its words in the version before and nowhere in the new one, and tells the agent (relocated-anchor). That keeps a thread off a copy of its old words the file reading doesn't hold, such as one in a code block, after the prose is renamed. Costs:

    • a version that only splits a word across two inline elements in a <div> moves its threads, since the file reading then puts a space inside the word;
    • a quote the file reading never found gets no move.
  • A section that a decision hides no longer detaches its threads at the next revision. An accepted suggestion hides the words it replaces this way. Undoing the decision shows the section and its threads again.

  • A named section the page doesn't hold places a quote nowhere, rather than letting the search run over the whole page.

  • An absent prefix/suffix means "context unknown". Browser selections always write both sides, an empty one at a fence. A logged value gains a new meaning, so the page protocol moves to 62 (main was at 61).

  • A sample fixture's own context stands. Where a fixture's anchor gives a side, the anchor keeps only the sides the fixture gave, with no note.

  • page check --render no longer checks verbatim widgets' words against the file reading. verbatim still decides whether the browser fences a widget, whether Python withholds its data body, and what a version comparison reads.

  • Python's reading matches quotes exactly on its collapsed text. A quote across two inline elements with no space between them, such as <strong>Status</strong><span>Ready</span> quoted as "Status Ready", now gets a note, though the browser still places it.

What was removed and what was kept

Removed:

  • the drawn-quote path (drawn_anchor's quote half, render-checks/quote.js, Unsaid, the CLI retry), resolve_quote, and the clerk's retry with no passage;
  • the verbatim render check (readings._verbatim_findings and its helpers, shownVerbatim, the owner and boundary identity maps in passages.js, widget-loader.js and check-api.js);
  • Python's tolerant matching across inline-element edges (Passages.edges, .soft, _letters);
  • the generated-word half of the browser's fileModelsPassage, now holdsEditedValue.

Kept, because something still needs them:

  • the browser's opaque-widget and generated-word passage cells, which keep a repeated quote's context inside the cell a module moves or rewrites;
  • Python's fences, without which a quote across a diagram's parts would post with no note;
  • Python's spacing rule in passages._write, which sets the words leaf page state, deliveries and the turn-end fork show the agent.

Instructions

threads.md, turn-end-check.md, packages.md, root AGENTS.md ("Validate once and share readings") and browser/AGENTS.md now state the new contract. Scores, on Claude Code:

  • evals/quote-names-one-copy, a new case. Asked about one of two copies of the same words, the agent quoted words the page shows once in 4/4 runs on head and 4/4 on base. Shown the new note beside a posted thread, it kept one thread in 8/8. The old note text, which advised quoting more of the passage, led 1/4 to post a second thread; that run never opened threads.md.
  • Root guidance (pnpm run eval:root-guidance --repeat 3): a first wording, "the browser alone finds a comment's quoted words", led the agent on an unrelated situation (filter-hooks-simply) to also move Python's gate into TypeScript, so it made the narrow fix in 7/18 runs to base's 18/18. The landed wording drops that clause, makes the call in 7/9 runs, and fails 18 samples across the 52 situations, as base does. Two later fact corrections in the same paragraph were not rescored.

Tests

These pass:

  • 741 model tests: anchors, threads, the clerk, deliveries, documents, obligations and authored markup;
  • the runtime's 1,165 tests;
  • pnpm run check;
  • the browser and journey tests the branch changes or that read thread status words, run by node id.

The exception is test_a_changed_datum_keeps_its_old_words_open_when_its_label_changes, which fails the same way with main's browser runtime.

test_revising_quotes_reparents_every_open_thread_without_answering_it no longer asserts that a moved reaction stays out of page state's threads. Since #7304 a reaction is a message the agent answers, and the assertion fails on main too.

Size

66 files. Code is +467/−848 (net −381, comment rewrites included), tests +477/−967 (net −490), and prose, registry text and the eval case +190/−88.

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

A measurement trial, not a change to land. It builds the redesign where
`leaf thread create --quote` stops holding a Python mirror of the browser's
passage reading to exact parity.

- Browser: a quote anchor whose words `findQuote` doesn't place once stands
  on its section as a fallback (`status: "fallback"`, `exact: false`), or
  nowhere without one. The thread card shows such a thread as "Changed",
  defined by the words landing on an element rather than as a passage.
- An absent `prefix`/`suffix` now means "context unknown": it constrains
  nothing, so only a sole copy answers an agent's quote. A selection always
  writes both sides, an empty one at a fence. Because that gives a logged
  value a new meaning, the page protocol goes from 58 to 59.
- Python: `capture_anchor` checks only the `--section` structure and stores
  `{section, quote}`, with the section taken from the file reading where it
  finds the quote once. It never refuses for the words. Where the file
  reading finds them zero or several times, it returns an `unplaced-quote`
  note, which reaches `thread create`, `thread reply`, the turn-end clerk's
  line to the agent, and `page check` for sample fixtures.
- Deleted: the drawn-quote path (`drawn_anchor()`, `render-checks/quote.js`,
  `Unsaid`, `UnsaidQuote`, `Drawn.anchor`, the CLI retry), `resolve_quote`,
  `_context`, and the clerk's retry with no passage.
- Kept: the revision reanchor. It now moves a quote to its section where the
  file reading finds the quote in the predecessor and not in the candidate
  (`copies`), with no context matching. That keeps `rewritten_from`, the
  `relocated-anchor` advice, and a durable fallback, so a later copy of the
  words doesn't capture the thread.

Behaviour the tests now hold differently:
- A quote the files hold zero or several times posts with a note instead of
  being refused.
- A thread on words a decision retired, or that generated status replaced,
  stands on its section marked "Changed" instead of detached.
- A pending or saved draft whose words vanish stands on its section.
- Browser-captured anchors carry `prefix: ""`/`suffix: ""`.
- Parity-only tests are deleted: the file/browser capture comparisons, the
  file-side `quote_cases` runner, the context-storage tests, and
  `resolve_quote` used as an oracle in browser tests.
# Conflicts:
#	browser/runtime/kernel-registry.json
#	build/browser/protocol-baseline.json
…e readings

The browser alone places a quote's words, so nothing needs Python's reading of
the page's files to match the browser's exactly. This removes what held the two
in step and keeps what other consumers still need.

Removed:
- The render gate's `verbatim` check (`readings._verbatim_findings`,
  `_expected_verbatim`, the `shownVerbatim` probe and the `verbatim` finding),
  the owner and boundary identity the browser recorded for it
  (`verbatimOwnerIdentity`, `verbatimBoundaryIdentity`, `reindexPassageOwners`),
  and the compositional owner readings and `source` provenance in
  `passages.py`. The `verbatim` key stays: it still decides whether the browser
  fences a widget, whether Python withholds its data body, and what a version
  comparison compares.
- The edge tolerance in Python's quote search (`Passages.edges`, `.soft`,
  `anchor_capture._letters`). `occurrences` is an exact search of the collapsed
  text, with fences still excepted.
- The generated-word half of `fileModelsPassage`, now `holdsEditedValue`:
  automatic control capture may quote words a module wrote on a control's face,
  and still never a native editing value.

Kept, with the consumer that needs it:
- Python's spacing where two elements' words meet (prose, CLOSING/OPENING):
  `leaf page state`, deliveries and the turn-end fork read those words, so a
  sentence reads as its author punctuated it.
- The browser's opaque-widget and generated-word cells: they keep a selection's
  context and quote off words a module rewrites or rearranges, such as a
  board's counts or a pick mark, so comments beside them stay on their words.
- Python's fences on opaque widgets and editing values: they keep the
  unplaced-quote note on a quote that runs across a widget's drawing, which the
  browser won't place.

Behaviour that changes:
- `page check --render` no longer reports a `verbatim` widget whose module
  changed its authored words.
- `leaf thread create` finds a quote only as Python's reading spells it, so a
  quote written with a space where two elements' words meet with none, or
  without one where the reading has one, gets an unplaced-quote note, though
  the browser still places it.
- Automatic control capture quotes a control's generated face words where they
  resolve once.

Tests: the parity-only tests are deleted (the compositional verbatim reading,
the projected verbatim expectations, the stateful-verbatim journey and the
verbatim provenance assertions).
`test_only_a_final_settling_failure_keeps_projection_findings` now uses
`undeclared-attr` as the finding read after replay, and the declarations
journey keeps its author-card and DevTools assertions under a new name.
…ting one of two copies

The first wording said the browser alone finds quoted words. On the root-guidance
eval it moved an unrelated call: asked to fix a hook notice, the agent also moved
Python's gate into TypeScript as its one owner in 7 of 12 runs, where main's text
led to the narrow fix in 18 of 18. Without that clause, 7 of 9, and 18 failed
samples on each text across the 52 situations.

evals/quote-names-one-copy scores the threads.md wording: one copy quoted 4/4 on
head and base; kept one thread after the note 8/8, where the old note's advice
(quote more of the passage) led 1 of 4 to post a second thread.

Two thread tests now assert the note says where the thread stands.
…er copy

Where Python's reading of the page's files finds an agent's quote once, the
anchor now stores that copy's neighbours as a hint, and the element around it
where the agent named no section. The browser reads the hint only to tell
copies apart, and a sole copy wins whatever it says. This keeps an identifier
quoted in prose off the copy a code block shows, and keeps a thread on its
copy when a later version adds another. The approved option said "no
context"; the maintainer may reverse this.

The trial's move after a new version stays. Removing it in review let a
thread whose prose a version renamed jump onto the old name in a code block,
with no notice to the agent. Its known cost: a version that only splits a word
across two inline elements in a <div> moves the thread.

A section a decision hides, such as the words an accepted suggestion
replaces, no longer counts as removed, so the next revision no longer
detaches its threads for good; undoing the decision shows them again.

Also:
- resolveAnchor places a quote nowhere when its named section is gone,
  rather than searching the whole page.
- The thread card gives no status word to a quote the page shows more than
  once (`quoteRepeats`).
- A sample fixture's own sides replace the capture's.
- Prose follows: events.md, validation.md, threads.md, turn-end-check.md,
  the thread create help, root AGENTS.md's passage sentence, the site's
  revision outcomes.

Tests: the twin test names the section both copies share, so only the
neighbours tell them apart. Two browser tests no longer expect a reanchor
for a repeated passage whose words the count still finds. The reparent
journey no longer asserts that a moved reaction stays out of page state's
threads: since #7304 a reaction is a message, and that assertion fails on main
too.
@max-sixty
max-sixty merged commit 37e0cb2 into main Nov 27, 2026
6 checks passed
@max-sixty
max-sixty deleted the quote-browser-only-trial branch November 27, 2026 05:53
leaf-agent added a commit that referenced this pull request Nov 27, 2026
… page holds (#7372)

`test_a_thread_walk_starts_one_page_trip_and_reveals_its_nested_passage`
has been failing on `main` since #7353. That change made a quote whose
named section the page doesn't hold place nowhere, where before the
search ran over the whole page. The test's fixture anchors its thread
with `("far", "Far-side passage")`, but the page has no `id="far"`. So
the thread had no passage, the walk had nothing to reveal, and the press
left every scroller at 0 (`{'page': 0, 'rail': 0, 'local': 0}`). The
fixture now names `local`, the scroller that holds the passage. That
restores what the test exercises without changing its assertions or
#7353's rule.

Verification, run locally by node id with `--run-main`:
- the test fails on `37e0cb217` (#7353) and on current `main`, and
passes on `37e0cb217^`;
- with this change it passes three times in a row on `main`.

The failure appeared in [run
45948475842](https://github.com/max-sixty/leaf/actions/runs/45948475842),
the only failure in that run's `test` job (1 failed, 8320 passed).

Closes #7370 — automated triage

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