Repository navigation
Bound OpenCode history reads and repeated worker failures - #25292
Conversation
Reuse the scan-owned lifetime proposed in #10708 by @AmethystLiang with the existing shared worker queue.
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review. 📝 WalkthroughWalkthroughThe changes add a 45-second active-work budget to OpenCode SQLite scans and route worker-client and WSL requests through that scope. The scope excludes Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to This change adds a 45-second work budget for OpenCode scans and per-owner worker failure limits. No merge-blocking issue was found in the supplied review context. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The change improves containment of slow or repeatedly failing history reads. No new access or privilege expansion was identified in the reviewed paths. Partial results, cancellation, and recovery remain the main risks, and coverage is limited. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
ℹ️ No critical issues — the mechanism holds up under the tests I ran; two minor consistency nits below.
Reviewed changes
- Per-scan OpenCode work budget (
session-scanner-opencode-sqlite-scan-scope.ts): anAsyncLocalStorage-scoped owner gives eachscanAiVaultSessionscall a 45s clock that is spent only while OpenCode SQLite work is outstanding (paused between legs, and counting queue wait and WSL preparation), aborting the scan's OpenCode signal when exceeded. - Per-owner worker failure budget (
worker-thread-request-queue.ts): worker deaths are now tracked perWorkerThreadRequestOwner, so a crash loop drains and refuses only the failing scan's queued calls while unrelated readers and later scans keep working. - Call-site wiring (
session-scanner.ts,...-worker-client.ts,...-worker-spawn.ts): the scope is entered at the top of the scan; OpenCode list/parse/capture register with it, whilezcode/native-chatreads are explicitly left unscoped. - Tests: five files cover budget pausing/resume, owner isolation, WSL preparation, deadline-incomplete capture, and cancellation.
ℹ️ Nitpicks
session-scanner-opencode-sqlite-worker-client.ts:30-34— theMAX_CONSECUTIVE_DEATHScomment still describes the pre-change reset rules ("after draining", "when a fresh scan burst starts from idle"). With per-owner budgets an owner's cap is enforced by its own counter and a crash loop now setsrefusedinstead of resetting; the "per-scan, not process-wide" intent still holds, but the mechanism it names is stale.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Derived the OpenCode deadline message from its budget (
session-scanner-opencode-sqlite-scan-scope.ts): the deadline error now builds`${OPENCODE_SQLITE_SCAN_BUDGET_MS / 1000}s`instead of a hardcoded45s, so the message cannot drift from the budget constant. The emitted text is unchanged (the constant is still 45 000), and the existingstringContaining('45s work budget')assertions still pass.
This addresses the inline nit from the prior review, whose thread is now resolved. The delta since 5d3e7c9 is this single message change; the rest of the PR is unchanged and was covered by the prior review.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

ELI5
A busy or repeatedly crashing OpenCode history reader can delay an AI Vault scan. Each scan now gets 45 seconds for its outstanding OpenCode work and stops replacing failed workers after three failures.
What Changed
Reuse the existing cancellation flow and shared worker queue. The allowance includes queue waiting and WSL preparation, and pauses between completed OpenCode operations. Reaching it records an OpenCode issue while retaining sessions already read and allowing other agents to finish.
Only failures of work that actually started count against that scan. Its own success resets its count; unrelated readers and later healthy scans keep working. Caller cancellation and worker retirement retain their existing behavior.
Why
The limit belongs to the scan requesting the work. A global timer or failure counter would also interrupt unrelated readers.
Linked Issue
Continues #10708 and credits @AmethystLiang for the original contribution. Its broader unavailable-reader, cooldown, WSL, and complete-history concerns remain open.
Visual Proof
N/A — background history-reader behavior. Verification retains installed-CLI responses, scan results, worker events, and cleanup evidence.
Testing
a5b8b7e2passes all three required typechecks. All 200 scanner source inputs, nine dependencies, and two controlled harness inputs match the runtime-verified compilation closure.Queued and active cancellation still propagate. The two unrelated readers returned four candidates each after the AFTER scan deadline. Earlier outside-reader fixtures used invalid filenames; their zero-candidate results are retained separately.
The 25-second holds, 28 added sessions, and forced exits are test amplification on real installed-session data. The final suite passed once with zero retries; all seven child processes and eight worker threads closed, and the private listener was confirmed closed. This is macOS evidence, with no live Windows, WSL, SSH, natural-crash, or whole-Vault wallclock claim.
Review
Five production files and five tests change. The installed verification remains pinned to source
db6ca590; integration5d3e7c99preserves all ten files and all unrelated main changes. Source and evidence were independently reviewed. Follow-up8be861f5derives the deadline message from the existing budget; the emitted 45-second message is unchanged, and all six scope tests, lint, and format pass.Agent skill upstream boundary
Notes
Original #10708 stays open for its remaining scope. Earlier harness failures are preserved separately.
Checklist