Skip to content

Read no space before a closing mark or after an opening one where an element's words end, at page protocol 47 - #6216

Merged
max-sixty merged 4 commits into
mainfrom
grind/words
Nov 16, 2026
Merged

max-sixty merged 4 commits into
mainfrom
grind/words

Conversation

@max-sixty

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

Copy link
Copy Markdown
Owner

A thread's name, On Me's Done row and leaf page state read an option such as <lf-option><strong>Leave it</strong>; the send keeps…</lf-option> as "Leave it ; the send keeps…", and (<code>beta</code>) as "( beta )". They now read "Leave it; the send keeps…" and "(beta)". The page protocol moves from 46 to 47.

Found in review of #6198.

Cause

Outside a text block, the words a reading shows put a space where two elements' words meet with nothing between them, since a page most often draws them apart: a chip beside its title, or an lf-option's title above its description. The same rule put a space where an inline element's words meet punctuation. The rule lives in shownApart (passages.js) and in _write's soft space (passages.py). #6198 moved thread names and Done rows onto says, which reads it.

Change

Both readings now leave that space out before a closing mark and after an opening one. The two lists are new kernel facts, $passages.closing (. , ; : ! ? … ) ] } ' ’ ” ») and $passages.opening (( [ { " ‘ “ «), which both runtimes read; why-closing-and-opening beside them says why. A straight ' only closes, as a possessive after code does (<code>Foo</code>'s). A straight " only opens, so a chip before a title that opens with a quote (<small class="tag">recommended</small><strong>"Update" …) still reads apart.

Quote matching treats an edge as a place a word may end, with or without a space, so a quote still finds the same passage. A captured anchor also logs the words on either side of its quote as the reading shows them, and those change; see "Protocol".

The structural rule the report suggested, no space where an inline element meets its own parent's text, would also have joined the 42 such edges in the corpus below with a letter or digit on both sides. Most are an lf-option title written flush against its description (<strong>Apply</strong>Implement the change described above.), which the theme sets on its own line; that rule would read "ApplyImplement the change…".

Protocol

Resolution compares an anchor's stored context, the words logged on either side of its quote, exactly. A Leaf on either side of this change misreads a context the other captured wherever it crosses a changed edge, as the bump rule in layer-registry.md ("Page protocol") describes. In an independent review, anchors captured with the merge base's browser capture (anchorForRange) on four ordinary shapes were resolved on this branch, and three detached in both runtimes. For example, in <div><strong>Keep</strong>; MARK…</div><div><strong>Drop</strong>; MARK…</div> the base stores the prefix "Keep ;" and this branch reads "Keep;". So $events.protocol moves to 47 (kernel-registry.json, with build/browser/protocol-baseline.json regenerated), and the $passages description names closing and opening among the lists whose change bumps it. The 418 quote anchors already in the surveyed logs resolve to the same words at base and head (27 resolve on neither), so the misread shows up in fresh captures, not in the logs surveyed here.

A possible follow-up would take shown spacing out of the protocol: compare a stored context the way quote matching compares a quote, treating an edge space as optional.

Evidence

The corpus is the shipped examples, every index.html with a log beside it under ~/.local/state/leaf/pages and, recursively, under ~/.tmp (792 pages), and the agent messages holding HTML in local logs. Each reading ran at base and head:

Reading Spaces dropped Documents changed
file (page_passages) 460 144 of 830
runtime (quoteFrom(pageText().segments) under happy-dom) 460 144 of 827

The two runtimes drop the same number of spaces in every document, and no other character changes. The dropped spaces stood before , (169), . (149), ) (37), ; (32), ' (21, all possessives after code, as semantic-state.js's) and : (13), and after ( (35) and " (1). Among them, 459 sit where an inline element meets its parent's text, and every one of those is a fix. One is not. It sits between two sibling elements, a label and its value, in a how-it-works page: <span>…with a more specific selector</span><code>:scope.featured { padding: 8px }</code> now reads "selector:scope.featured". The other 1,994 spaces between sibling elements stand. Six shipped examples change, for instance rust-sort.html: "Short slices ( len <= max_insertion ) take" → "Short slices (len <= max_insertion) take". None of the agent messages found locally holds the pattern, so the 5-of-51 count from #6198's review isn't reproduced here.

leaf page state PAGE send-choice, after the user chooses an option written <strong>Leave it</strong>; the send keeps its place (<code>held</code>)., gives the choice's words as "Leave it ; the send keeps its place ( held )." on main and "Leave it; the send keeps its place (held)." here.

Tests

  • tests/quote_cases.json gets a case where only the new spacing tells two copies of a quote apart by their prefix. On main it resolves to nothing in both runtimes.
  • tests/runtime/passage-boundaries.test.mjs (says) and tests/model/test_interact_anchors.py (page_passages) read the same markup as Leave it; the send keeps Foo's place (beta). recommended Apply Ship it. recommended "Update" for mixed input. On main both read "Leave it ; the send keeps Foo 's place ( beta ). …". The chip still reads apart from a plain title and from one that opens with a quote.
  • pnpm run test:runtime (997 pass), pnpm run check:browser, node --test build/registry.test.mjs, and 1,158 model tests in the modules that read passages or the protocol (interact_contract/, test_claims, test_forks, test_interact_document, test_interact_layer, test_interact_anchors, test_obligations, test_clerk, test_delivery, test_provenance, test_stop_guard, test_thread_reading, test_workflows, test_page_inspection).

Browser tests weren't run. A grep of tests/browser and tests/journeys finds no expectation of a space before punctuation that follows an element.

…element's words end

Outside a text block, the words a reading shows put a space where two
elements' words meet with nothing between them, since a page most often
draws them apart: a chip beside its title, or an lf-option's title above
its description. The same rule put a space where an inline element's
words meet punctuation, so `<strong>Leave it</strong>; the send keeps`
read "Leave it ; the send keeps" and `(<code>beta</code>)` read
"( beta )". Thread names and On Me's Done rows read these words (`says`)
since #6198, as `leaf page state` and a captured anchor's context did.

Both readings now leave that space out before a closing mark and after
an opening one. The two lists are new kernel facts, `$passages.closing`
and `$passages.opening`, which `shownApart` (passages.js) and `_write`
(passages.py) both read. An edge stays a place a quote matches with or
without a space, so only the words a reading shows change.

A structural rule, no space where an inline element meets its own
parent's text, would have joined 42 such edges in real pages that the
page draws apart, mostly an lf-option title written flush against its
description (`<strong>Apply</strong>Implement the change…`).

Over the shipped examples and 613 real pages, both runtimes drop the
same 404 spaces in 117 documents, every one beside punctuation after or
before an inline element; none sits between a chip and its title. The
383 quote anchors in those pages' logs resolve to the same words before
and after.

@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 point on the contract prose; the two runtimes' new checks agree, including where whitespace sits beside the mark.

Comment thread browser/runtime/kernel-registry.json Resolved
…quote close or open only

A capture logs the words beside an anchor's quote as the reading shows
them, and resolution compares them exactly. A context captured with the
old spacing, such as the prefix "Keep ;" before a quote in
`<strong>Keep</strong>; MARK`, no longer matches the new reading
"Keep;", so a repeated quote detaches. That is a misread the page
protocol names, so `$events.protocol` moves to 47, and the `$passages`
description now names `closing` and `opening` among the lists whose
change bumps it.

A straight `"` in `closing` joined a chip to a title that opens with a
quote: `<small class="tag">recommended</small><strong>"Update" …` read
`recommended"Update" …`. A straight `'` now only closes, as a
possessive after code does, and a straight `"` only opens. Both new
tests carry the quoted title and a possessive.
@max-sixty max-sixty changed the title Read no space before a closing mark or after an opening one where an element's words end Read no space before a closing mark or after an opening one where an element's words end, at page protocol 47 Nov 16, 2026
@max-sixty
max-sixty marked this pull request as ready for review November 16, 2026 23:09

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

#6218 also moves $events.protocol from 46 to 47, in kernel-registry.json and protocol-baseline.json. The two edits are identical, so whichever PR merges second merges without a conflict and stays at 47. That breaks the rule in root AGENTS.md ("Pages across Leaf updates"): main between the two merges is a Leaf at 47 that misreads what the second change writes. Whichever lands second should move to 48.

@max-sixty
max-sixty merged commit 36c650e into main Nov 16, 2026
6 checks passed
@max-sixty
max-sixty deleted the grind/words branch November 16, 2026 23:17
max-sixty added a commit that referenced this pull request Nov 16, 2026
max-sixty added a commit that referenced this pull request Nov 17, 2026
…otices (#6215)

The page protocol marks which Leafs can serve and write a page, so it
moves only when a Leaf at the current number would misread an event or
record another Leaf at that number wrote. Root `AGENTS.md`, "Pages
across Leaf updates", now states that once, with what keeps the number:
anything the serving Leaf supplies, including how it parses and draws
what the page keeps, even where a logged message or a comment's quote
then draws or resolves differently. `layer-registry.md`, "Page
protocol", keeps only how the number is enforced and how records carry
it (834 → 393 words).

Gone: #6208's notice that a message Markdown dialect change bumps the
protocol, the same notices on the kernel registry's `$passages`
(including the `closing`/`opening` lists #6216 just added) and `$names`
(the latter about vendored registries pages no longer keep),
`$events.description`'s claim that the protocol covers the served state,
and the layer-registry paragraphs that copied `session_runtime.py`'s
header or described superseded behavior.

**To weigh:** the policy accepts that a passage-reading change can move
an old comment onto another occurrence of its quote, and a dialect
change can drop a logged widget's action from its thread's history.
Codex found both cases; a bump prevents neither, since renewing a page
keeps its log for the new Leaf to read by its own rules.

Max asked for this after #6208. Reviewed by Codex, whose two findings
are fixed. On eight bump questions, six Sonnet runs of the new text
answered all 48 as intended, keeping bumps for a renamed field, a
non-skippable kind and a changed token meaning. #6023 (draft) rewrites
the same `AGENTS.md` section, so whichever lands second resolves a
conflict. `pre-commit`, the registry and protocol build tests, and the
`AGENTS.md` tests pass.

> _This was written by Claude Code on behalf of max-sixty_
max-sixty added a commit that referenced this pull request Nov 17, 2026
Main moved `$events.protocol` to 47 (#6216), and #6238 made the build refuse
any schema change at one number, so this branch's `held` pickup phase and
`agent-turns` role take the protocol to 48: the kernel registry,
`agent-turns`' `since`, and the baseline rebuilt from main's at 47.
Conflicts: the protocol line, the pickup row of `events.md`'s table, and a
test's stand-in for `thread.checked_text`, which now passes main's new
options through.
max-sixty added a commit that referenced this pull request Nov 17, 2026
…#6218)

Every message an agent posts now reads as Markdown with HTML, whichever
way it reaches the page, so the log drops the `html` field #6208 added.
Before, only text the agent wrote with a `leaf thread` command, and the
turn-end check's asks, drew its HTML, and the field marked those
messages; a Codex turn's final message, progress lines and failure
receipts kept their tags as words. Readers that need to know whether a
message holds HTML now derive it from the text
(`thread_context.logged_fragment`, cached), and the server adds it to
each served thread message, so the browser runtime is unchanged. A
user's message still shows tags as words.

Max asked why the field existed at all. It existed so Leaf could post
agent text without reading its HTML. Reading every agent message the
same way keeps one rule, and each path that posts agent text now meets a
refusal the way the agent's own command does:

- **A Codex final message** with a stray tag, such as `Vec<String>`
outside backticks, is refused (`unclosed tags: <string>`), and the
existing correction delivery asks the agent to fix it and answer again.
In exchange, a final message can hold HTML: a `<details>` quote, a table
or a choice draws. The turn writer's delivery clause drops "Reply
explicitly too for other HTML, which your final message shows as text",
which is no longer true.
- **Progress lines** (a Codex opening, a fork's working line,
`--ephemeral`) may now carry formatting HTML such as `<em>`; they still
refuse a widget, since the answer replaces the line. Before,
`--ephemeral` refused any HTML.
- **The turn-end check's asks** (#6202): where Leaf refused an ask's
HTML, it posted the ask again with the HTML shown as raw text. That
fallback needed the field. Now any ask Leaf refuses, for HTML or for a
picture the page hasn't got, is not posted, and the agent gets the
message and the refusal as a line it owes, which wakes it to ask the
user itself; the fork's other asks are still posted. Before, a missing
picture in one ask dropped the whole answer without telling the agent.
- **Edits**: the rules that a message drawing HTML keeps its words and
that an edit adds no HTML move from `leaf thread edit` into the append
door, so an edit a sample's fixture carries meets them too.
- **Protocol 48** (#6216 took 47): a Leaf at 47 would draw a new log's
HTML messages as text and miss their widgets. Delivery records are
unchanged.

The `html` parameter that ran through `open_thread`, `post_reply`,
`post_response`, `_compose_and_append`, `ask_again` and the clerk is
gone with the field.

Reviewed by Codex; its three findings (progress lines refusing
formatting, edits bypassing the rule through fixtures, clerk refusals
not reaching the agent) are fixed here. Ran `uv run pytest tests/model
tests/process`, `pnpm run test:runtime`, `pnpm run check`, and nine
browser and journey tests covering a choice in a thread, an export, a
reply's widget and the shipped logs.

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