Conversation
Treat provider interruption as a terminal run event, preserve interrupted outcomes, ignore superseded root completions, and wake already-queued follow-ups. Add regression coverage and update the generated lifecycle diagram. Validated: 9 targeted regression cases; domain and database suites; server suite with sandbox watcher failures passing on an unrestricted rerun; server build and domain/server typechecks. Independent review approved after both minor findings were resolved. Session: thr_9jj5v4cn7v
…ted-thread-lifecycle
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Human comments
What was wrong
A provider can finish a root turn with
status: "interrupted"without a user first requesting Stop. The server translated that completion tostop.settled, which is legal only fromstopping. Fromactiveorstarting, the lifecycle rejected the event and left the thread busy after its provider turn had ended. This was observed with Grok Build child threads after a rejected shell command: a parent could receivechild-interruptedwhile a wait for the same child's idle status never returned. The captured server diagnostic wasno transition for stop.settled from status active. The incompatible mapping and transition table are also present in the upstream base of this patch.What changed
run.interruptedas a terminal transition fromstarting,active, andstoppingtoidle, preserving the interrupted outcome and the separate manual-stop path.No server/daemon wire field, protocol version, database migration, public API, or CLI change. This does not backfill already-stale records or change permission decisions.
Related: #3189 identified the queue-wake portion and was closed by the contributor approval gate. This patch also fixes the illegal lifecycle transition that prevents unsolicited provider interruptions from reaching idle, and guards against superseded root completions.
How you verified
c1a64f4b): ran the new regression file against the unchanged production files: 7 failed / 2 passed. Restored the patch and reran it: 9 passed / exit 0. The failing-before cases include unsolicited interruptions from active and starting, old-turn settlement, queued follow-up, and child settlement.8e33492cinto the branch without conflicts. The 7-file fix is unchanged. Rechecked the subsequent upstream text-utility change at3275f6c6; it does not change the affected lifecycle/event handling.pnpm exec turbo run test --filter=@bb/domain --filter=@bb/db --filter=@bb/server --concurrency=1 --env-mode=loose -- --maxWorkers=2: domain 213 passed, database 590 passed, server 3062 passed / 1 skipped; 11 successful tasks / exit 0. Ran outside the sandbox with a temporary npm cache so plugin source-watch tests could execute normally. All 9 new regression cases are included in the server run.pnpm exec turbo run build typecheck lint --filter=@bb/server --filter=@bb/domain --concurrency=2: 7 successful build/typecheck tasks, 7 total / exit 0. These selected packages do not define separate lint tasks.git diff --checkpass. A separate read-only review approved the patch after 2 minor fixes; a fresh review of compatibility with upstream's failed-queue retry policy also approved it with 0 findings.The installed BB app was not patched, and no live provider turn was started or stopped to manufacture a reproduction. The regression tests use the real server event route and database-backed test harness.