Skip to content

Wait for the anchor tests' comments to reach the log before reading it - #812

Merged
max-sixty merged 3 commits into
mainfrom
fix/ci-35389883602
Sep 19, 2026
Merged

max-sixty merged 3 commits into
mainfrom
fix/ci-35389883602

Conversation

@leaf-agent

@leaf-agent leaf-agent commented Sep 18, 2026 •

Copy link
Copy Markdown
Collaborator

nightly on main failed in run 35389883602 with StopIteration from test_a_removed_subject_keeps_its_conversation_open_and_detached: the test read the event log for the comment it had just sent, and the log held only the page's opening note. Ten comment submits in tests/test_render_anchors.py read past a gesture whose own send nothing waited for — five behind the passage mark, four behind a bare round_trip(page), and one behind the thread card the page paints optimistically. None is evidence that the comment reached the log. The file now states one rule: a browser-sent comment whose result later work reads waits for the server's answer before that read.

Why none of the three waits proves the comment landed

page.wait_for_function("() => (CSS.highlights.get('lf-mark')?.size ?? 0) > 0") is satisfied by the runtime's own unresolved ledger, so it returns while the POST is still in the wire. CLAUDE.md's cross-runtime invariants state it directly — "Every forward gesture whose semantic result the page can draw is on screen in the turn that sends it, before the log answers" — and sending's comment in tests/render_harness.py already names this failure shape: a log read behind an unenclosed gesture "answers with whatever stood last — the page's opening note, or the gesture before this one … and it holds it only on a machine slow enough to lose the race". CI's nightly under -n 2 was that machine.

round_trip(page) fails for the reason stated above the helper: the press reaches the runtime inside the driver's call and posts behind it, so a post the gesture has not issued yet is not pending and the trip is over before it begins.

The thread card is the same invariant in its conversation form. conversationForAttempt in skills/leaf/assets/runtime/pending/model.js renders an unresolved comment as a thread under a pending: identity, so .lf-thread counts one the turn the comment is sent — on the path where the server refuses it as well as the path where it accepts.

What changed

Nine sites are enclosed in sending, the helper the file already uses for exactly this. Of the five behind the passage mark, one reads the log immediately — that is the failing test, and the read that raised StopIteration. The other four order a revision stamp against the same in-flight POST, and one of those goes on to read the log behind the stamp. The four behind a bare round_trip(page) are the same defect in the diff and whole-page cases: two of them read sent_events(serve.page_dir) and assert on the anchors it holds, which loses the race as an equality failure on an empty list rather than as a timeout.

The tenth, test_the_captured_quote_is_prose_a_file_can_hold, takes the rule without the helper. Its stated subject is the durable fact — the server accepting the 400-character quote and writing it to a UTF-8 file — and the failure it guards against is a request failure the outbox retries rather than settles, so round_trip inside sending would sit out its whole deadline instead of reporting what the reader was told. It waits instead on the identity the server gave the card (.lf-thread:not([data-id^="pending:"]), the idiom tests/test_render_drafts.py already uses) or the offline notice, and then reads the quote back out of events.jsonl through Python's UTF-8 decoder — the reader a half character has no bytes for. That read is new: the test never touched the file before, which is how the one site whose subject is the durable fact was also the one with no durable read.

A scan of the file for comment submits — ControlOrMeta+Enter, .lf-compose-submit, and the threads' Send — finds each one either enclosed in sending or followed by that settled-card wait. The scan also cleared the neighbouring files: the mark waits in test_render_navigation.py and test_render_pages.py follow comments written by post_event or the CLI, which are durable before the browser opens, and tests/test_render_drafts.py already calls round_trip(page) before its stamp for this reason.

Verification

With the event POST held three seconds behind a page.route handler, the failing test's body raises the same StopIteration as it stood, and passes enclosed. Holding the capped-quote test's POST open behind the held_events fixture, the wait as it stood returns on the pending card and the log read comes back empty; the settled-card wait does not return while the request is held. tests/test_render_anchors.py passes whole under --run-nightly.

The everyday suite runs 1137 passed / 5 failed in the agent sandbox; all five reproduce unchanged on this branch's merge base and are the sandbox's own conditions rather than the suite's — three OSError: [Errno 30] Read-only file system under /tmp in test_interact_session.py, the umask mode check in test_interact_layer.py, and test_live_shell_artifact.py, which needs the website dependencies. None is in the changed file; CI runs the everyday gate for real.

Deterministic reproductions

A scratch parametrisation of the failing test's body, holding the POST behind the paint:

def _slow_events(page, seconds):
    def later(route):
        time.sleep(seconds)
        route.continue_()
    page.route("**/api/event", later)

[False] (the body as it stood) fails at next(...) with StopIteration; [True] (the submit enclosed in sending) passes. A second scratch check confirmed the premise from the other side: with the POST held open by the held_events fixture, the mark wait returns while events_model.read_events(page_dir) holds ['note'] — no comment at all, which is exactly the shape CI reported.

The capped-quote site needs held_events rather than a sleeping route, because the sync driver runs a route handler on the thread the page is driven from: a time.sleep there freezes the paint the race depends on, and both arms pass. Held open, and parametrised over the old and new waits:

FAILED test_cap[False] - AssertionError: assert [] == ['Capped. Cap...ed. Capped.😀']
FAILED test_cap[True]  - TimeoutError: Page.wait_for_function: Timeout 4000ms exceeded.

[False] is the defect: the wait returned, .lf-thread counted one, and the log held no comment. [True] is the repair: the wait does not return while the server has not answered.

Five tests in tests/test_render_anchors.py used the passage mark as their
evidence that a browser-sent comment had reached the event log. The mark is the
optimistic paint, drawn in the turn the gesture is sent, before the log answers,
so the durable read behind it could answer with the page's opening note. Enclose
each submit in sending(), which waits for that gesture's own send to enter the
wire and complete its trip.

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tests/test_render_anchors.py still has four comment submits that read past an unenclosed gesture, so the rule this PR states for the file — a browser-sent comment that later work depends on is enclosed in sending — does not yet hold across it. Each is a page.keyboard.press("ControlOrMeta+Enter") followed by a bare round_trip(page):

  • test_a_manifest_diff_can_comment_on_one_unloaded_file, and the second submit in test_a_data_bound_diff_aims_and_selects_one_source_line, then read sent_events(serve.page_dir) and assert on the anchors it holds. That is a one-shot read of events.jsonl behind the press — the shape that raised StopIteration in the nightly this PR fixes. Lose the race and comments is [], which fails the equality assertion rather than the wait.
  • test_a_selection_of_the_whole_page_still_finds_its_passage asserts the quote is not detached on "the pass that runs after the send", which its own comment names as the pass that would have thrown. If the trip is over before the post exists, that pass has not run and the assertion reads the optimistic paint, which is never detached — green without the behaviour the test names.
  • The first submit in the same data-bound diff test reads only rendered state, but carries the same shape.

tests/CLAUDE.md states the rule under A state the page passes through is not a state to poll for: "Read the event log only after round_trip, and read the event a gesture just made through sending; the runtime posts behind the press the driver has already returned from, so a trip waited on without sending can be over before the gesture's own post exists."

All four are the same one-line change as the five in the diff, so I am enclosing them on this branch rather than leaving the file half-stated.

The bare press(); round_trip(page) pairing also appears three times in tests/test_render_aim.py. Same shape, outside this PR's file, so left alone.

Four submits in `tests/test_render_anchors.py` pressed
ControlOrMeta+Enter and then waited on a bare `round_trip(page)`.
`tests/CLAUDE.md` names that as the wait that proves nothing: the
runtime posts behind the press the driver has already returned from,
so the trip can be over before the gesture's own post exists.

Two of them read `events.jsonl` through `sent_events` immediately
behind it and assert on the anchors it holds — the same one-shot log
read that raised `StopIteration` in the nightly, failing on an empty
list instead of on the wait. A third asserts a quote is not detached
on the pass that runs after the send; with the post not yet made, that
pass has not run and the assertion reads the optimistic paint, which
is never detached.

`sending` already covers all four, so the file now holds one rule
rather than two.
@max-sixty

Copy link
Copy Markdown
Owner

@leaf-agent The race analysis holds — tests/render_harness.py:706 and tests/CLAUDE.md both state that a press posts behind the driver's call, and the mark wait is the optimistic paint — but the scan is incomplete. test_the_captured_quote_is_prose_a_file_can_hold still presses ControlOrMeta+Enter outside sending (line 1164 at head), and the wait behind it, .lf-thread count 1 or a shown .lf-notice, is satisfied by the optimistic pending paint: conversationForAttempt in skills/leaf/assets/runtime/pending/model.js renders an unresolved comment as a thread with pending: true, so the card exists before the server answers. That test's stated subject is the durable fact — the server accepting the quote and writing it to a UTF-8 file — so it is the same defect at the site where reading the paint instead of the answer matters most.

That makes the body's claim "A scan of the file finds no submit left outside it" false, and this repo squash-merges with the PR body as the commit message, so the claim lands on main verbatim.

Either cover that site or narrow the claim. Note that sending would sit out its full deadline on the refusal path the test's docstring describes, since the outbox keeps retrying rather than settling, so a durable read may suit it better than the helper.

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

`test_the_captured_quote_is_prose_a_file_can_hold` waited on `.lf-thread`
counting one, which the optimistic paint answers: `conversationForAttempt`
renders an unresolved comment as a thread under a `pending:` identity, so the
card stands on the refusal path the test's docstring describes as well as on
the path where the server accepts. The test's subject is the durable fact — the
server writing the 400-character quote to a UTF-8 file — so it now waits for
the identity the response replaced that one with, or the offline notice, and
reads the quote back out of `events.jsonl`. That read is new; the test never
touched the file before.

`sending` is not the helper here: the failure it guards against is a request
failure the outbox retries rather than settles, so `round_trip` would sit out
its whole deadline instead of reporting what the reader was told.

`tests/CLAUDE.md` states the general rule beside the one it already carries for
a container the runtime keeps whether or not it holds anything.
@leaf-agent

Copy link
Copy Markdown
Collaborator Author

Covered, and you were right about the helper as well.

test_the_captured_quote_is_prose_a_file_can_hold now waits on the identity the server gave the card — .lf-thread:not([data-id^="pending:"]), the idiom tests/test_render_drafts.py already uses — or the offline notice, and then reads the quote back out of events.jsonl through Python's UTF-8 decoder. That read is new: the test never touched the file before, which is how the one site whose subject is the durable fact was also the one with no durable read. sending stays out of it for the reason you gave, recorded in a comment at the site.

The claim in the body was false, so I rewrote the body rather than narrowing it: the rule the file now states is that a browser-sent comment whose result later work reads waits for the server's answer before that read — nine sites through sending, this one through the settled card. The scan behind the new sentence is over the three submit gestures the file uses (ControlOrMeta+Enter, .lf-compose-submit, and the threads' Send), and each hit is now enclosed or followed by that wait.

I also put the general rule in tests/CLAUDE.md, beside the one it already carries for a container the runtime keeps whether or not it holds anything — the pending card is the same trap, and nothing named it.

Bug-back

A sleeping page.route handler cannot show this one: the sync driver runs the handler on the thread the page is driven from, so the time.sleep freezes the paint the race depends on and both arms pass. Holding the POST open with the held_events fixture instead, parametrised over the old and new waits:

FAILED test_cap[False] - AssertionError: assert [] == ['Capped. Cap...ed. Capped.😀']
FAILED test_cap[True]  - TimeoutError: Page.wait_for_function: Timeout 4000ms exceeded.

[False] is the defect you described: the wait returned, .lf-thread counted one, and the log held no comment. [True] is the repair — it does not return while the server has not answered.

tests/test_render_anchors.py passes whole under --run-nightly, 93 tests.

@max-sixty
max-sixty merged commit 654a4ba into main Sep 19, 2026
4 checks passed
@max-sixty
max-sixty deleted the fix/ci-35389883602 branch September 19, 2026 01:56
max-sixty added a commit that referenced this pull request Oct 27, 2026
The panel's status and the All pages list show an agent's working line
(the `--text` of `leaf task start` or of an ephemeral reply), and the
user reads it at a glance. Of 1,413 such lines on the maintainer's pages
over the last two weeks (rough regex counts), 29% ran past 80
characters, about 7% carried commit hashes or CI mechanics ("Waiting for
current-head CI and review on #17 ddc2cc5c"), and about 5% were to-do
titles in the imperative ("Delete the width eval case"), which read as
asking the user to do it.

`skills/leaf/references/conversation-loop.md`, "When to write", now says
who reads the line and where, and asks for a few of the user's words:
not a to-do's title, and no commit hashes, ids or CI mechanics. Both
references also drop "under your name", since the panel no longer puts
the agent's name in front of its line (#4325).

## Score

`evals/work-names-its-item` gains a to-do with an imperative title, a CI
wait on a named commit and run, and a `line-reads-at-a-glance` metric.

| | before | after |
|---|---|---|
| `line-reads-at-a-glance`, Claude Code | 0/3 | 3/3 |
| `line-reads-at-a-glance`, Codex | 0/3 | 3/3 |
| `judgment` (existing), both harnesses | 6/6 | 6/6 |

Before the rule, every run named the CI run number or the commit hash
while waiting ("Waiting on CI run 18233 for PR #812 (head 9c41d2ab)"),
and Codex's lines ran to about 80 characters. After it, they read
"waiting for the rollout fix to pass its checks". Neither arm copied the
to-do's imperative title, so the eval doesn't measure that clause; the
evidence for it is the page survey.

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

Co-authored-by: Claude Opus 5.5 <[email protected]>
max-sixty added a commit that referenced this pull request Nov 17, 2026
… choice the user presses (#6220)

A ready pull request now reaches the user as a choice they press ("Merge
#812" / "Hold off for now") rather than a message telling them to run
`/merge-pr` and reply. The turn-end check's reference named "a merge
waiting on the user's approval" as a step asked in words, and an agent's
"Merging is yours: run `/merge-pr`" read to the fork as a command for
the user. On 44 real pages since 2026-11-01, none of 88 merge or landing
asks was a choice (72 by the fork, 16 by agents), and 17 of the 21 the
user answered in words said "yes" or the merge command.

The rule now lives once, in a new paragraph of `conversation-loop.md`
("The On lists") that the fork reads through `clerk.GUIDANCE`: an action
the agent takes once the user agrees is a permission, asked as options,
even where the user could start it with a command they'd type to the
agent; an action only the user can take is a step, asked in words.
`turn-end-check.md` drops its copy of the step rule and adds that the
fork marks an option recommended only where the agent advised it, since
early runs marked "Merge" recommended unprompted.

**Evidence** (Claude Code fork, 3 runs per arm): the new
`ask-permission` case, Max's closeout cut down, is asked as a choice 0/3
on main, 0/3 with only the merge example deleted, and 6/6 here.
`ask-step`, a command only the user can run, stays in words 3/3.
`ask-follow-up` passes 6/9 here against 7/9 on main, failing on both
arms on the #6079 wording faults. `closeout-asks-take-their-route` now
requires landings as options; both arms pass 3/3. Runs cost about $10.

**To weigh:** a step whose report has listable answers ("Works" / "Still
broken") still asks for a reply in words; that is a separate call this
PR leaves alone.

Asked for by Max in a comment on a Leaf page. Tests:
`tests/model/test_clerk.py`, `dev/tests/test_evals.py`,
`test_product_page.py`, `test_interact_layer.py`.

> _This was written by Claude Code on behalf of max-sixty_
max-sixty added a commit that referenced this pull request Nov 20, 2026
The sentence in authoring-on-me.md's "Make each question self-contained" told
the agent to name work by what it does "rather than by its number". Max wants
the number kept, since it is how the user finds the pull request, with words
beside it that say what the work is. The sentence now asks for that, with
"Merging #431, the retry for dropped uploads" as its title example, and moves
to the end of the paragraph, after what a question mainly holds, since he still
found it prefatory where it stood.

The naming rubrics now let an option cite a number its ask's title describes,
as "Merge #812" under "Merging #812, the LRU result cache", since the card
gives the number its context.

Evals (Claude Code, this tree, 3 runs a case): fork asks name the work 6/6,
items-right 27/27, guardrails 9/9. The agent's merge ask after a compaction
titles every thread with both, as "Merging #1211, the badge on notes waiting to
sync", but in each run still mentions #1204 in passing without saying what it
is, so names scores 0/3. The page-sections case names 1/3. A version whose
example was a passing mention ("#431, the retry for dropped uploads", not a
bare "#431") raised sections to 2/3 but titled merge asks "Merging #1211"
in 3/3, so the title example stays. About $14 of runs.
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