Skip to content

Select page state from the served reading, and count gate coverage as served - #1235

Merged
max-sixty merged 1 commit into
mainfrom
agent-a61a3b1b4bd15b8c4
Sep 26, 2026
Merged

max-sixty merged 1 commit into
mainfrom
agent-a61a3b1b4bd15b8c4

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

leaf page state and leaf thread read now select from the reading /api/state serves instead of folding the log a second time. The render gate now reads the log coverage from that same served state instead of keeping its own count of it.

Page state is a selection. _write_page_state called full_state, which runs browser_state, and then rebuilt every reading itself: the active document's page_reading and read_document, two more build_threads folds, frozen_thread_reading, the thread request lifecycles and Asks, canonical_updates, unread_content, active_summaries, and its own grouping of workflows by thread. Now:

  • browser_state returns its wire dict together with a BrowserReading: the threads, the frozen thread reading, and each view's DocumentReading. browser_thread and browser_document already return this kind of pair. project_browser_state passes the pair through.
  • served_state.page.read_served_page returns a ServedPage holding the state, the reading, and the stored data it read. full_state stays as a thin wrapper for every caller that only wants the JSON.
  • agent_state takes the document, the threads, and the frozen thread reading from BrowserReading. It takes the thread Asks, updates, unread messages, and summaries from the served wire. It still builds its own elements, state, content, requests (every occupied seat, across revisions), and reactions.
  • FrozenThreadReading.subject_thread states which thread a thread or widget subject stands in. The browser's attention grouping and thread read's update and workflow filters all use it, replacing three inline copies.

Each served thread carries its id. The browser grouped attention by thread["root"]["id"]. When a torn log line loses a thread's opening message, the surviving reply opens the thread under the lost id (build_threads), so the root's id and the thread's id differ. Asks and workflows name that thread by the lost id, and the attention lookup missed them: a thread whose open Ask sat in the surviving reply read as nobody's turn. Each served thread now carries id, and both the attention grouping and page state key on it. test_a_thread_whose_opening_message_was_torn_away_still_reads asserts the thread reads as the user's turn, and fails with the old keying. The runtime still keys threads on root.id (scripts/browser/application.ts, thread/*), so the panel's own reading of such a thread still misses it; the wire id is now there for it to read.

Before a page's first revision, the served state has no browser reading. The document, thread, Ask, and update sections of page state then keep their empty defaults. That case has no thread or claim subject for them to report, because status --on and every thread need a document.

Output. I diffed page state and every thread read (at --after 0 and --after 3) from base and candidate on nine pages: the feature gallery, ship-review, corpus, command-hub with one pending and one receipted request, review-a-plan, log-retention, triage-board, a gallery page seeded with 347 events, and a command-hub page with two thread Asks, a thread-widget answer, a worker report, and a thread claim. Both versions ran back to back against the same page directories, and a second base run matched the first. The only difference: each summary in thread read now carries protected. That is the browser's list of covered messages that stay in view, so the agent reads the same summary the user is shown. test_thread_summary_is_admitted_as_one_ordered_thread_range now asserts that equality.

Time. In-process page state medians on the 347-event page were 24/31/33 ms before and 19/17/24 ms after (three interleaved rounds of 30 runs each); on the thread-Ask page they were 14/15/10 ms before and 11/9/7 ms after. The spoken reading, read_document, and the frozen thread projection now each run once. The CLI's roughly 0.3 s is mostly process startup.

Gate coverage. render_gate/scheme.py and render_gate/page_code.py counted {action, report} events for the logApplied wait. The runtime's data-lf-applied stamp counts the served coverage records, and those include undos. render_checks.wait_for_presentation now reads that count itself through log_coverage(state) (the length of the active view's coverage; every view lists the same records), so neither caller passes a count. The gate's "never finished replaying" message now counts records rather than actions. scripts/record-demo.py keeps its own action-only count, because another branch has unmerged work in that file.

🤖 Generated with Claude Code

… served

`leaf page state` and `leaf thread read` called `full_state` and then folded
the log again: the active document, two more thread folds, the frozen thread
reading, thread Asks and requests, updates, unread, summaries, and their own
workflow-by-thread grouping. `browser_state` now returns its wire dict with a
`BrowserReading` (threads, frozen thread reading, each view's document
reading), `read_served_page` returns a `ServedPage` (state, reading, stored
data), and agent state selects from those. `full_state` is the JSON-only
wrapper. `FrozenThreadReading.subject_thread` replaces three inline copies of
which thread a subject stands in.

Each served thread now carries its `id`, and the browser's attention grouping
keys on it rather than `root.id`, so a thread whose opening message a torn log
line lost reads its open Ask as the user's turn.

Behaviour that moved: `thread read` summaries carry `protected`, the same
summary the browser shows. `page state` output is otherwise byte-identical
on nine example pages; in-process time on a 347-event page fell from about
24-33 ms to 17-24 ms.

The render gate's `logApplied` wait counted {action, report} events; the
runtime's stamp counts the served `coverage` records, undos included.
`wait_for_presentation` now reads `log_coverage(state)` itself.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@max-sixty
max-sixty merged commit 154aacc into main Sep 26, 2026
5 checks passed
@max-sixty
max-sixty deleted the agent-a61a3b1b4bd15b8c4 branch September 26, 2026 19:18
max-sixty added a commit that referenced this pull request Sep 27, 2026
… reader (#1250)

Four Python readers waited on different subsets of the runtime's
readiness facts.
The suite's `BOTH_STAMPS` required upgrade, an applied stamp,
presentation, the
coordinator's current reading, settled rendering and deferred arrivals
(#913 and
#1145 added the last two, but only there). The render gate's
`wait_for_presentation` waited on data version, log coverage and current
presentation, with neither arrival nor rendering.
`scripts/example-previews.py`
and `record-demo.py` checked the three body stamps alone, and
`record-demo.py`'s
stills waited on upgrade and a count of `action` lines in
`events.jsonl`, with no
presentation, where the gate counts the reading's served coverage
(#1235).

`pageReadiness` in `runtime/presentation.js` now names the first fact a
page has
yet to state, in the order a page reaches them: `upgraded`, then `data`
and `log`
against an `/api/state` reading the caller holds, then `presented`,
`arrived` and
`rendering`. It returns null once the page is ready. The entry script
exposes it
as `lfReadiness`, replacing `lfCurrentPresentationReady` and
`lfPageArrived`;
`lfRenderingSettled` stays for waits after input.
`leaf.render_checks.wait_until_ready(page, state=None)`
is the one Python wait. It raises `PageNotReady` naming the stage, and
every
reader uses it: the suite (`open_page`, `navigate`, `restarting`, the
arrivals
case and each direct wait), the gate's scheme pass and page-code run,
the catalog
stills, and the demo recording. The stills now wait against the server's
reading,
so they count served coverage.

Behaviour that moved:

- `leaf version check` now also waits for deferred arrivals and settled
rendering before it reads a page, and reports either stage by name. A
failure
  at either still keeps the projection findings, as `pageSettled` did.
- The gate requires the applied stamp even when the reading covers no
records;
  before, it skipped the log stage then.
- The page-code run reads `/api/state` straight after navigation, not
after the
  upgrade stamp, since the readiness wait includes upgrade.
- The catalog stills and demo frames are shot after deferred arrivals
land and
  rendering settles, not at first presentation.
- A timed-out wait names its stage in the runtime's own words, and
reports a page
  that cannot answer within 5s as `answering`.

The render-check probes `initiallyPresented`, `currentPresented`,
`dataApplied`
and `logApplied` are gone, along with `validationPresentationReady` and
`pageArrived`. The tests that read them now assert the readiness stage,
or the
coordinator's `applicationPresented` directly. A new gate test holds a
page's
first state answer and checks that the wait fails at `log` with that
wording,
then passes once the answer lands. The scheme pass keeps its `upgraded`
probe as
a barrier before the visual-provider check, which must run before
presentation
can hang on an invalid inventory.

`scripts/verify_site.py` and the MCP app still wait on
`data-lf-presented` alone.
That is the interaction boundary a host shows the frame at, and it stays
their
fact.


> _This was written by Claude Code on behalf of max-sixty_

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
max-sixty added a commit that referenced this pull request Sep 27, 2026
The concept survey's drifted duplicates now each have one owner
(#1214–#1221, #1223, #1228, #1231, #1235, #1244, #1245, #1247, #1250,
#1251, #1254, #1260), so the survey note never lands. What it found and
nobody has taken becomes `TODO.md` entries:

- **Shared definitions** (new section under Next): re-addressing
resource references in one pass instead of `http.py`'s regex scopers and
three head composers; `tests/render_harness.py` `told()` beside
`pageReadiness`'s `data` and `log` stages (#1250), which answer the same
question; Python still naming a thread's identity a root
(`thread_roots`, `FrozenThreadReading.roots`) now that the runtime keys
threads on the served `id` (#1260).
- **Requests**: the existing "Decide whether requests earn their weight"
entry now says kept requests need one owner for seat availability, which
four runtime modules restate.
- **Implementation candidates**: the unresolved-gesture ledger as one
state machine, deferred until a change has to touch it, since nothing
there has drifted and it is the hottest race path.

The survey's small undrifted items and its list of deliberate splits are
dropped: none has drifted, and the splits are intended.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

> _This was written by Claude Code on behalf of max-sixty_

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[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