Repository navigation
Conversation
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.
Summary
Fence background-runner shutdown to the exact claim it originally acquired. A stale runner must not interrupt a replacement run merely because both runs belong to the same task ID.
Background
If a task is paused and explicitly retried while the original executor is still settling, another runner can acquire a new lease. The old
Runner.stop()looked up the current database task and passed that new lease intoStore.interrupt(). The store's ownership check consequently succeeded for the replacement run, changing it tointerruptedand preventing its result from being committed.This was found by source inspection on
main(d4214aff). I searched issues and all-state PRs for runner/lease/shutdown/claim, including the earlier interruption work in #47. I found no matching fix; the open headless-continuity PR #176 changes a different path. No new issue was required by CONTRIBUTING.md.Changes
Claimalongside itsAbortController.Store.interrupt()on shutdown, reusing its existing lease fence rather than reconstructing ownership from the latest task row.Testing
Windows, Node 24.22.1; locked dependencies installed with lifecycle scripts disabled.
vitest run tests/runner.test.ts— 1 failed / 8 passed. The new test expected the replacement lease to remainrunning; it becameinterruptedwith a null lease.vitest run --maxWorkers=2— 352 passed across 56 files, with unchanged timeouts.npm run check-format,npm run lint,npm run typecheck,npm run build— passed.npm run knipandnpm run knip:production— executed, exit 1 with unused dependency/export findings outside the changed files. These checks are report-only in current CI. I did not change those findings or independently rerun Knip on an untouched main checkout.git diff --check— passed.Additional Notes
AI-assisted implementation and verification. The reproduction exercises real local SQLite ownership transitions with synthetic executor results, not live Intelligence/model/computer services or a production incident. It establishes the stale-worker fencing invariant; it does not claim distributed deployment acceptance or end-to-end recovery of external side effects.
The existing normal-shutdown test still verifies that a runner interrupts work it actually owns and leaves it awaiting explicit review/retry.