Skip to content

Let page check --render pass a page with an unread agent message - #3299

Merged
max-sixty merged 4 commits into
mainfrom
agent-a30159730c167d587
Oct 20, 2026
Merged

max-sixty merged 4 commits into
mainfrom
agent-a30159730c167d587

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

leaf page check --render failed every page that shows an agent message whole, such as the shipped ship-review example. The runtime posts a read event on its own once it has shown an agent message. The gate's read-only preview server refused it with a 403, and Chrome reported the failed fetch as a console error, which the gate counts against the page in both color schemes.

The gate's answer_reports already answers the error reports a page sends during a reading, so they reach no log and draw no refusal. It now answers bookkeeping events (read, and any kind $events declares bookkeeping) too, as a final refusal under a 200, so the page doesn't send one again and nothing reaches the console. Every other event still reaches the server and its 403, so a page that writes without a gesture still fails the gate.

The corpus sweep (test_page_fixture_renders) now runs the gate through preview_server, the read-only capture page check --render serves, rather than through a writable server. That's why the sweep never saw this. Its ship-review case fails before this change and passes after.

Other servings: an exported page's event door throws before any fetch, so it can't hit this. A live sample is a writable child page. On leaf.page, a passive visitor's read isn't refused: the Worker forwards it to a private container, which starts one for a visitor who has only read.

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

max-sixty and others added 4 commits October 20, 2026 02:18
`leaf page check --render` failed every page that shows an agent message
whole, such as the shipped ship-review example. The runtime posts a `read`
event on its own once it has shown an agent message, the gate's read-only
preview server refused it with a 403, and Chrome reported the failed fetch
as a console error the gate counts against the page.

A read-only server now answers a bookkeeping event (`read`, and any kind
`$events` declares bookkeeping) as a final refusal under a 200: it records
nothing, the page doesn't send it again, and nothing reaches the console.
This extends the rule `/api/user-view` already follows on a capture: a
capture serves an instrument, not the user's reading. A gesture is still
refused with a 403, so the gate still catches a page that writes without
one.

The corpus sweep (`test_page_fixture_renders`) now runs the gate through
`preview_server`, the read-only capture `page check --render` serves,
rather than through a writable server, which is why it never saw this.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The read-only preview server goes back to refusing every event with a
403. The render gate's `answer_reports`, which already answers the
error reports a page sends during a reading so they reach no log and
draw no refusal, now answers bookkeeping events too: each is refused as
final under a 200, so the page doesn't send it again and Chrome logs no
console error. Every other event still reaches the server and its 403,
so a page that writes without a gesture still fails the gate.

This keeps the event door to one refusal shape and handles the posts a
page sends unprompted during a reading in the one place built for them.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@max-sixty
max-sixty merged commit 6d3ed15 into main Oct 20, 2026
2 of 3 checks passed
@max-sixty
max-sixty deleted the agent-a30159730c167d587 branch October 20, 2026 09:54
max-sixty added a commit that referenced this pull request Oct 21, 2026
On leaf.page, a visitor who has only read a page no longer starts a
private container by being shown an agent message. The runtime used to
post a `read` event on its own once a message had been fully on screen,
and the Worker forwarded it to a new private container. Now the runtime
sends no read until the visitor's session is active, as it already sends
no viewport report (`user-view.js`), and the Worker answers any read
that arrives from a passive session itself without recording it. Once
the visitor acts on the page, reads are recorded as before, including
for a message already in view. This implements Max's decision #19 on the
overnight report.

Until the visitor acts, their read messages keep their unread marks and
Next unread keeps stopping on them. Before this change, each published
example with an agent reply in it (ship-review, review-a-plan,
log-retention) started Python and Codex App Server in a container for
every visitor who opened that reply, and the container then idled for
ten minutes.

## How

- `thread/read.js` counts a message's exposure only while
`sessionIsActive()`, and scans again on `lf-session-active`. When the
visitor's first gesture activates the session, a reply in view is marked
read in the same visit. On a locally served page and in a live sample
the session is always active, so nothing changes there. The kernel is
rebuilt.
- The Worker answers a passive session's `read` itself, beside the
viewport report it already drops ("disposable observation, not a gesture
that opens private state"). It reads the event's `kind` in the same
bounded parse that recognizes a page fault (`passiveEvent`). The answer
is a final refusal under a 200, `{ok: false, final: true, findings: [],
attempt}`, as `page check --render` has answered since #3299, and not
the viewport report's empty 204. The runtime treats an empty answer as
unreached and would send the read again on every later pass, and those
passes run on each scroll. This answer only reaches a tab whose runtime
predates the gate above.

## Checks

- A Worker test beside the viewport one posts a read with no cookie,
with a session cookie, with this page's active marker from another
release, and with another page's marker. Each gets the final refusal and
no container. With this page's active marker, the read goes to the
container. Disabling the new branch fails the test.
- Through the local Worker (`leaf-dev verify-site`'s `local_worker`),
with `ship-review` built from this branch, a fresh visitor opened both
threads with `t`. No `/api/event` was posted and no container started.
The session was then turned active over its session channel, the way
another tab's activation reaches it. The same tab then posted reads for
both replies, `91f7c2a8` and `64df0b27`. A control tab whose state
answers said `active` from the start posted the same two reads.
- `pnpm run check` passes.
- `uv run leaf-dev site` then `uv run leaf-dev verify-site
website-worker` passes. Two earlier runs on a host at load 20–25 timed
out on the container's first activation read, and the same timeout hit
main's Worker on that host.

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