Skip to content

Let the pick reach the log before the stamp reads it - #71

Closed
leaf-agent wants to merge 3 commits into
mainfrom
fix/ci-33038969372
Closed

leaf-agent wants to merge 3 commits into
mainfrom
fix/ci-33038969372

Conversation

@leaf-agent

@leaf-agent leaf-agent commented Aug 27, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

ci on main is red at tests/test_render_options.py::test_a_pick_offered_can_be_pointed_at_too, and it reproduces on the first try at -n0 — a real ordering fault, not contention or a re-run's bad luck.

E  AssertionError: refusing to stamp index.html: <lf-options id='transport'> (line 14): its state
   changed under the user's decision — the markup shows ['opt-bearer'] where their choose (on r1)
   left ['opt-strict']. ...

The test presses four picks in the group, ending on opt-bearer, then stamps a revision that carries that pick and rewords opt-strict. lf-options paints the pick straight from the outbox and sends it after (this.#pick(next) precedes sendAction in lf-options.js), so expect(#opt-bearer[chosen]) is satisfied while the choose is still in flight. The stamp is a file-side read of that same log, and it reads a press or two behind — the pick on opt-strict, or the cleared pick before it. Against either of those the revision's markup stands somewhere the reader never chose, and the gate refuses it, correctly, for a version the test never meant to write.

Nothing here was racy before fe4e8ea — the test wrote v2.html and appended a note, which read no log at all. That commit routed the same fixtures through the real version stamp boundary, which turned every one of these sites into an event-log reader.

Solution

round_trip(page) between the last press and the stamp. tests/CLAUDE.md already states the rule this site is missing — "Read the event log only after round_trip" — and round_trip is the fact-based wait for it: every attempt the page sent has a definitive outcome, rather than a sleep or a poll on the file.

I checked the other 40 stamp_page / stamp_version_file sites for the same shape. The ones that gesture first either send no event (a panel press, a local draft edit), send a comment the stamp's verdict does not turn on, or already establish the ordering by another fact — test_a_moved_card_wears_its_pending_mark opens a second tab that reads the move back out of replay before it stamps. Adding a trip to those would be a wait in front of a reading whose subject never moves, which tests/CLAUDE.md warns against, so this is the one site that gets one.

Testing

Rebased onto 8db3827 (Honor the active choice in revision fixture), which changed the same site — the fixture now carries the reader's live pick, and the failure survived it, because the gate's disagreement is with the log's read position rather than with what the fixture claims.

Bug-back on that base: with the round_trip line removed the test fails in ~4s at -n0, every time, with the message above; with it, it passes. tests/test_render_options.py --run-nightly is green (51 passed).


Automated fix for failed run

@leaf-agent

Copy link
Copy Markdown
Collaborator Author

Same failure on the next push to main — run 33039281326 at f154596, which carries only the scrollbar-gutter change, so the fault is independent of what landed. That run hit the other losing order this PR's body names: it refused at <lf-option id='opt-strict'> rather than at the group.

I reproduced it on f154596's tree at -n0, first try, in about four seconds, and saw both orders across runs. Dumping comments.jsonl immediately before the stamp showed two of the four choose events on disk while the DOM already wore the fourth; stamping that same index.html once all four are on disk exits 0. So the verdict is the gate reading a log two presses behind, exactly as diagnosed here — this branch's one-line round_trip(page) is the fix, and I'm not opening anything alongside it.

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

One wording point on the new comment — the fix itself reads right. I traced the gate: action_rests_on returns [widget, *detail ids inside it], so {"options": []} collapses to #transport alone and action_subjects falls back to subjects or [widget], which is exactly why the cleared pick puts the whole group's words under a standing decision. round_trip is the wait tests/CLAUDE.md names for this ("Read the event log only after round_trip"), and it is the right one here rather than told, since the subject is what the page sent, not what it was later given.

I also re-ran the sibling-site survey independently — every stamp_page / stamp_version_file call in tests/ whose preceding gesture had no intervening settle turned out to be a comment send, a local draft edit, or a panel press, none of which puts a standing action on a leaf the stamp rewords. So this really is the one site.

ci / test is still in flight at the time of writing; I have not seen it terminal.

Comment thread tests/test_render_options.py Resolved
@leaf-agent

Copy link
Copy Markdown
Collaborator Author

Third red run on main, same refusal at the group: run 33039958729 at 8b77b5a, whose only file is CLAUDE.md — so the fault now has a commit that touches no code at all behind it, and 1 failed, 1354 passed is the whole verdict. Nothing to add to the diagnosis above; main stays red until this merges.

@leaf-agent

Copy link
Copy Markdown
Collaborator Author

Rebased onto 8db3827 (Honor the active choice in revision fixture) and refreshed the comment's last clause to match what the gate now refuses. That commit reaches the same site — the v2 fixture now carries the reader's live pick instead of the authored one — and run 33041758897 is main red on it, so the fixture change did not close this. It wouldn't: the gate's disagreement is with where the log read stopped, not with what the fixture claims. On 8db3827 the refusal reads the markup shows ['opt-bearer'] where their choose (on r1) left ['opt-strict'] — the in-flight choose from the Enter press, one press behind.

Verified on the rebased head: tests/test_render_options.py --run-nightly green at -n0 (51 passed), and with the round_trip line removed the named test fails in ~4s on that same base. The earlier green here was against a base predating the failure, so it proved less than it looked.

Reproduction on 8db3827
$ uv run pytest tests/test_render_options.py -q -n0 --run-nightly \
    -k test_a_pick_offered_can_be_pointed_at_too
E  AssertionError: refusing to stamp index.html: <lf-options id='transport'> (line 14): its state
   changed under the user's decision — the markup shows ['opt-bearer'] where their choose (on r1)
   left ['opt-strict']. ...; <lf-option id='opt-strict'> (line 17): its words changed, and the user
   has already acted on it (choose on r1). ...
1 failed, 50 deselected in 4.61s

The second clause follows from the first: the stale read puts the pick on opt-strict, so the reword of that card lands under a standing decision. With the trip, the pick rests on opt-bearer and opt-strict is a card nobody picked, which is what the test's comment says it is arranging.

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

This branch is now superseded — the identical fix landed on main while it was in review, and the conflict is exactly the collision.

#63 (merged as fb28c76) rewrote this same block and added round_trip(page) at the same site, one line after the press, with its own comment:

    page.locator("#opt-bearer .lf-pick").focus()
    page.keyboard.press(" ")
    expect(page.locator("#opt-bearer[chosen]")).to_have_count(1)
    # The browser paints its queued choice immediately. Wait until the authoritative
    # log holds it before authoring the revision that honors it.
    round_trip(page)

So mergeStateStatus is DIRTY and git merge-tree origin/main pr71 conflicts on tests/test_render_options.py alone: both sides insert a round_trip call between the expect(...) and the d = serve.page_dir block. The diagnosis in the description is right and the wait is the right one — it just arrived twice. Worth noting for whoever resolves the conflict: #63 also changed the press from Enter to " " because the pick mark's role moved from button to checkbox, so taking this branch's hunk wholesale would quietly revert that.

The one thing this branch has that main doesn't is the comment. Its five lines name both losing orders — the pick on opt-strict, and the cleared pick that rests on the group rather than on any option — where main's two lines name the mechanism but not either refusal. That reasoning came out of three reproductions on this thread and nothing else on main records it, so if this closes it's worth porting the comment over the shorter one rather than dropping it.

My read is: close this, and if the longer comment is wanted, land it as its own one-hunk change on top of main. I haven't verified ci is green on fb28c76 — the run was still in progress when I looked, so I can't yet say the red this branch was opened against is actually cleared, only that main now carries the same wait.

How I checked
$ git merge-base origin/main pr71
8db38276948f83e57a440c33342a627cfa01b45b
$ git merge-tree --write-tree origin/main pr71
CONFLICT (content): Merge conflict in tests/test_render_options.py
$ git diff 8db3827..fb28c76 -- tests/test_render_options.py
+    # The browser paints its queued choice immediately. Wait until the authoritative
+    # log holds it before authoring the revision that honors it.
+    round_trip(page)

The merge base is 8db3827 (Honor the active choice in revision fixture), which is what the last rebase targeted; fb28c76 landed on main after it.

@leaf-agent

Copy link
Copy Markdown
Collaborator Author

Superseded — the fix is on main. fb28c76 (#63, Make Ask text entry one keypress away) added round_trip(page) at this exact site, between the last press and the stamp, carrying its own comment. git log -S "round_trip(page)" -- tests/test_render_options.py names that commit, and on fb28c76 the test passes at -n0 in 4.6s where on 8db3827 it failed deterministically in 5.0s with the markup shows ['opt-bearer'] where their choose (on r1) left []. Same diagnosis, arrived by another route.

So this branch now has nothing left to land: rebased onto fb28c76 its one line conflicts with the identical line already there, and the only difference is which comment sits above it. Closing rather than re-pushing a wording-only diff. Leaving the branch in place.

One mechanism worth recording, since it will recur on any bot PR that falls behind main. The force-push to f7f70e8 never got a ci run — 8 minutes after the push, /commits/f7f70e8/check-suites shows the github-actions suite already completed: success with tend-review as its only run. That is not a queue delay, it is the conflict: ci triggers on pull_request and checks out refs/pull/71/merge, which GitHub cannot build once mergeable goes CONFLICTING, while tend-review is pull_request_target and needs no merge ref, so it fired normally. The visible effect is a PR that looks gated while the only ci in flight (run 33041706837) is pinned to the orphaned pre-force-push d9cbae5. A session polling the PR's checks would read a stale commit's verdict as the head's.

Run evidence

Four red ci runs on main, all the same refusal at test_a_pick_offered_can_be_pointed_at_too:

run commit refusal named
33039281326 f154596 <lf-option id='opt-strict'>
33039958729 8b77b5a <lf-options id='transport'>
33041215842 9bc3540 <lf-options id='transport'>
33041758897 8db3827 both, after the fixture began carrying the pick

The last one is the useful one: 8db3827 made the v2 fixture declare the reader's live pick, so the stale read stopped being a words-only disagreement and started naming the state too — ['opt-bearer'] in the markup against ['opt-strict'] in the log. That is the same missing press, seen from the other side, and it is what fb28c76 closes.

ci for fb28c76 is run 33043627516, still in progress at the time of writing. Run directly on that tree here: tests/test_render_options.py --run-nightly green (53 passed), and uv run pytest tests green (629 passed, 6 skipped).

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.

1 participant