Repository navigation
fix(acp,cursor): a turn's cached provider thread is settled, so late updates cannot mark it busy - #909
Conversation
List only (step 1 of "Adding a seam line"). Fixes the race behind the flaky Kiro turn_interrupt replay test (#846): at a turn's end the ACP and Cursor adapters cache the provider thread as active, and usage or shell updates that arrive after the turn re-send that snapshot session-scoped, which the server writes without a run guard. When that write lands after the run's final idle write, the ended thread stays active. The fix adds one override line (and a comment) after upstream's status line in each adapter, so the cached snapshot is idle like the server's final write, and one check in each adapter's existing test. No upstream line changes, so no lost-line count is needed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…updates cannot mark it busy Fixes #846. At a turn's end the ACP adapter (Kiro, Kimi, Grok, fx and the ACP registry agents) and the Cursor adapter cache the provider thread as active. Usage or session info that Kiro sends after the cancelled prompt (and Cursor's background-shell updates) re-send that cached snapshot as a session-scoped update, which the server writes without a run guard. When that write lands after the run's final idle write, the ended thread stays active for good; the turn_interrupt Kiro replay test caught it now and then. The cached snapshot is now settled (idle, or error for a broken thread) like the server's final write. One override line after upstream's status line in each adapter, announced in .github/fork-seams.json. Co-Authored-By: Claude Opus 5.5 <[email protected]>
a0cd901 to
6e58254
Compare
11d0ddd to
6b4c249
Compare
|
lens: code · reviewer: claude-opus-5-5 · read at: 6b4c249 blocker: none Cause analysis: correct.
Fix:
Paths that should mark a thread active:
Other adapters:
Tests:
State question:
|
# Conflicts: # .github/fork-seams.json
…updates cannot mark it busy (#909) * fork seams: announce the settled provider thread lines (#846, step 1) List only (step 1 of "Adding a seam line"). Fixes the race behind the flaky Kiro turn_interrupt replay test (#846): at a turn's end the ACP and Cursor adapters cache the provider thread as active, and usage or shell updates that arrive after the turn re-send that snapshot session-scoped, which the server writes without a run guard. When that write lands after the run's final idle write, the ended thread stays active. The fix adds one override line (and a comment) after upstream's status line in each adapter, so the cached snapshot is idle like the server's final write, and one check in each adapter's existing test. No upstream line changes, so no lost-line count is needed. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(acp,cursor): a turn's cached provider thread is settled, so late updates cannot mark it busy Fixes #846. At a turn's end the ACP adapter (Kiro, Kimi, Grok, fx and the ACP registry agents) and the Cursor adapter cache the provider thread as active. Usage or session info that Kiro sends after the cancelled prompt (and Cursor's background-shell updates) re-send that cached snapshot as a session-scoped update, which the server writes without a run guard. When that write lands after the run's final idle write, the ended thread stays active for good; the turn_interrupt Kiro replay test caught it now and then. The cached snapshot is now settled (idle, or error for a broken thread) like the server's final write. One override line after upstream's status line in each adapter, announced in .github/fork-seams.json. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
…updates cannot mark it busy (#909) * fork seams: announce the settled provider thread lines (#846, step 1) List only (step 1 of "Adding a seam line"). Fixes the race behind the flaky Kiro turn_interrupt replay test (#846): at a turn's end the ACP and Cursor adapters cache the provider thread as active, and usage or shell updates that arrive after the turn re-send that snapshot session-scoped, which the server writes without a run guard. When that write lands after the run's final idle write, the ended thread stays active. The fix adds one override line (and a comment) after upstream's status line in each adapter, so the cached snapshot is idle like the server's final write, and one check in each adapter's existing test. No upstream line changes, so no lost-line count is needed. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(acp,cursor): a turn's cached provider thread is settled, so late updates cannot mark it busy Fixes #846. At a turn's end the ACP adapter (Kiro, Kimi, Grok, fx and the ACP registry agents) and the Cursor adapter cache the provider thread as active. Usage or session info that Kiro sends after the cancelled prompt (and Cursor's background-shell updates) re-send that cached snapshot as a session-scoped update, which the server writes without a run guard. When that write lands after the run's final idle write, the ended thread stays active for good; the turn_interrupt Kiro replay test caught it now and then. The cached snapshot is now settled (idle, or error for a broken thread) like the server's final write. One override line after upstream's status line in each adapter, announced in .github/fork-seams.json. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
… file (#1187) * fork-ci: enforce review findings, rounds and critical gate files (#740) * fork-ci: enforce review findings, rounds and critical gate files The head check now enforces the owner's review rules from the base's `review` block: - findings (#99): in enforce, a lens's newest report with a `blocker:` or `major:` line fails the head until a later report of that lens has none, or a person's override comment for the head is newer. - rounds (#100): the round is the number of different full shas the lens comments read (or the highest rN marker). From rounds.approach_at the approach lens is required; past rounds.max it stops with "a person decides" until an override covers every lens. - critical files (#82): the fork's own queue config makes workflow, queue and lens files critical with two lenses. It fails closed: rounds and findings that cannot be judged fail the head in either mode. Adds the fork's own config with a review block in enforce mode and four general lens prompts, and documents how a project opts in through its own config. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fork ci: read lens findings both ways, count fix rounds, person-only overrides (#740 fix) Findings (#99): headings, bold, tables, dash and emoji labels count, after NFKC, zero-width removal and o/0/M look-alikes; clean lines (none found, none!, none (only minors)) and fenced code do not. A report on the head with no findings section fails that lens instead of passing as clean. NOT SAFE on the title or a verdict line is a blocker. Rounds (#100): a round is a different change of the pull request's own diff (from its merge base), so a queue update that only merges the base in adds none. Edited, hidden and short-sha reads still count; a round marker in a lens name is a floor. Past the cap the message says a person's override alone is enough, also for a missing approach lens. Overrides (#78): review.override_authors lists the people whose override counts; empty or left out means none is accepted. The fork config stays in shadow and leaves the list out, and the lens prompts use the exact header and findings section the gate reads. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fork ci: a findings section needs both labels, read finding: lines, key rounds on content (#740 final fix) - A report has a findings section only with a blocker label and a major label (or findings: none, or finding: lines): blocker: none plus a major in a form not read (F1 (major): x, Severity: major, One major: x ...) now fails closed instead of passing as clean. - finding: <blocker|major|minor> lines are read: a minor-only report passes, a finding: major line fails whatever none lines are there. - Clean: major: none — two minors below, Major: (none), none plus an emoji. A labelled recap (Major 1: fixed) stays an open finding; the lens prompts say to write recaps without a label. - HTML entities, backslash escapes and the ratio sign are folded. - Linear time on long runs of spaces (squeezed in _plain; the table rule pattern matched on the stripped line): a 200k-character line under 2 s. - Round key: index lines and the whole hunk header dropped, --binary kept, so a base edit to another line of a file the PR changes is no new round. - A listed override login whose comment has another author association is warned about in the check output; a read-commit fetch has a timeout. - Tests for the hunk-header strip, the fence that ends a table and the override_authors cap. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]> * fork seams: announce the model policy lines on t3_thread_launch and t3_thread_configure (#731) (#746) * fork seams: announce the model policy lines on t3_thread_launch and t3_thread_configure (#731) Part of #731. List only (step 1 of "Adding a seam line"): the #731 code change adds two upstream lines to each of two MCP handler files, and changes the fork's own model policy contract file, which the list must name as a fork file. - project/handlers.ts: an agent's t3_thread_launch is checked against the model policy once its model is known, before the slot gate. - thread/handlers.ts: an agent's t3_thread_configure that changes a thread's model is checked before it is dispatched. - forkFiles: packages/contracts/src/modelPolicy* (added by #268, a fork file upstream does not have; like mcpProfile*, playtest* and reviewRules*). Co-Authored-By: Claude Opus 5.5 <[email protected]> * fork seams: announce the model policy lines for a settings file that fails to load (#731) A settings.json that does not parse makes upstream run on its defaults, whose model policy is off. The fork reads the policy from the file on its own and fails closed, which needs two lines in apps/server/src/serverSettings.ts: the import of fork/modelPolicyFile.ts and the modelPolicy value in the fallback settings. Announced here so #747 may add them. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]> * Scheduled tasks: webhook wait counts unreadable retries, logs the skip's cause (#763) (#765) - A waiting webhook delivery whose task stays unreadable is skipped after 60 failed retries in a row (5 minutes), not 5 minutes of wall-clock time, so a host that sleeps between two retries cannot end it early. One good read still resets the count. - The skip logs a warning with the cause of the last failed read. - savedSince's SELECT and row mapping are built from one column map, typed against RunCopy's fields, so a field cannot be compared but not read. - A row found deleted by the compare's read ends the delivery at once as deleted, not as "could not be read". The reason text takes its retry count and minutes from the constants; the long doc comment is wrapped. Co-authored-by: Claude Opus 5.5 <[email protected]> * heavy: minors from the #760 reviews (#761) (#764) - The fallback note folder (~/.local/state/heavy) is used only in a home the effective user owns ($HOME, else the passwd home). As root with a user's HOME (sudo -E) it never makes a root-owned folder there. With no usable home it refuses instead of writing into the working dir. - stop_scope waits the grace time only after a step that sent a signal. - The leftover sweep removes old empty docker-label notes of scopes that are gone (not listed when it began, minAgeSeconds old). A live run's note stays. - Tests: the hygiene check finds every untimed read form; the real tests wait for the guard's rename and use a temp HOME. README/docstring wording fixed. Co-authored-by: Claude Opus 5.5 <[email protected]> * Model policy: check agents' model picks on the server, mark picks outside it in Settings (#731) (#747) * fork seams: announce the model policy lines on t3_thread_launch and t3_thread_configure (#731) Part of #731. List only (step 1 of "Adding a seam line"): the #731 code change adds two upstream lines to each of two MCP handler files, and changes the fork's own model policy contract file, which the list must name as a fork file. - project/handlers.ts: an agent's t3_thread_launch is checked against the model policy once its model is known, before the slot gate. - thread/handl
Fixes #846
Cause (a product race, not a test race)
When a turn ends, the ACP adapter caches the provider thread snapshot with status
active(packages/provider-acp/src/server/adapter.ts:8654, infinalizeTurn) and clears the active turn. Kiro sends twosession_info_updatenotifications after the cancelledsession/promptresponse (entries 26 and 27 offixtures/turn_interrupt/kiro_transcript.ndjson). The usage/session-info handler re-sends the cached snapshot, stillactive, and marks itsessionScopedbecause no turn is running (adapter.ts:5813). The server writes a session-scoped update straight to the projection, with no run guard (apps/server/src/orchestration-v2/ProviderSessionManager.ts:3026).The run's own final write sets the thread to
idle(apps/server/src/orchestration-v2/RunExecutionService.ts:378,finalProviderThreadStatus). Which of the two writes lands last depends on fiber timing. When the lateactivewrite lands last, the ended thread staysactivefor good, and the test'sstatus === "idle"check (fixtures/turn_interrupt/codex_output.ts:47) fails now and then.The Cursor adapter has the same pattern. It caches
activeat a turn's end (packages/provider-cursor/src/server/adapter.ts:2614), and background-shell updates after the turn re-send that snapshot session-scoped.Fix
The cached snapshot is settled at the turn's end, like the server's final write:
idle, while a broken thread keepserrorin ACP. The fix is one override line, plus a comment, after upstream's status line in each adapter. No upstream line changes. The other adapters (Claude, Codex, OpenCode, Pi, Muse) setactiveonly when a turn starts, so they do not have this pattern. The ACP adapter also serves Kimi, Grok, fx and the ACP registry agents, so they get the fix too. The test was right; it is unchanged.Each adapter's existing test now also checks the status of the snapshot that is sent again:
AcpAdapterV2.test.ts, the Kimi lateusage_updatetestprovider-cursor adapter.test.ts, the background-shell testThe four files are upstream files, so the lines are seams. They are announced in #907 (step 1) and moved to
addedhere (step 2).Verification
Forced race (proof of the cause). The race is rare on its own, so I forced the order seen in CI, as a local experiment that is not committed: a 100 ms delay on Kiro's
session_info_updateso it arrives after the turn has closed, and a 200 ms pause before the scenario reads its final projections. With a trace on both writes:expected 'active' to equal 'idle', the same error as CI. The trace shows the run's finalidlewrite, then the late session-scopedactivewrite about 90 ms later.idle.Without the forced delay, Kiro's late update arrives while the turn is still open, so it goes through the run and lands before the final
idle. That is why the test passes almost always.Unit tests (deterministic). Without the two adapter lines, the new checks fail every time with
expected 'active' to equal 'idle': the AcpAdapterV2 late-usage test and the Cursor background-shell test. With them:provider-cursoradapter.test.ts: 33/33AcpAdapterV2.test.ts: 152/152provider-acp,provider-cursorandapps/server.Loops (the Kiro replay file, 30 completed runs each, on a loaded machine).
active)The natural rate is too low to show in 30 runs: 0/30 before, 0/30 after. CI hit it rarely. The forced-race runs above are the before/after evidence: 4/4 failures before and 0/4 after.
CI. Every test job passes. The only red check is the seam check (
Fork lines in upstream files), and the two aggregate checks that follow from it. CI judges seams by main's list (--config-refis main), and main does not list these lines until #907 merges. Locally, the seam check passes against #907's list.Merge order
This is stacked on #907 (base
fork-seams/846-announce) so its seam check is judged by the list that announces these lines. Merge #907 first, then retarget this PR tomainbefore the base branch is deleted. If #907 is squash-merged, updating this branch from main conflicts in.github/fork-seams.json: keep this branch's side, with the lines underaddedand noannounced.General vs project
🤖 Generated with Claude Code