fix(recovery): reset command lane when abort leaves pre-existing task blocked#92303
fix(recovery): reset command lane when abort leaves pre-existing task blocked#92303hanZeng-08 wants to merge 1 commit into
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed June 22, 2026, 6:58 PM ET / 22:58 UTC. Summary PR surface: Source +14, Tests +34. Total +48 across 2 files. Reproducibility: yes. at source level. Current main can reach active-abort recovery with queueDepth=0, abort/drain can report true after the embedded-run registry clears, and the existing release gate ignores a still-active command-lane task unless another reset arm is true; I did not run a live gateway reproduction in this read-only review. Review metrics: none identified. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land the narrow active-count recovery mitigation only after real behavior proof is added or a maintainer explicitly overrides that proof gate; keep ghost-target binding, ineffective-recovery logging, and empty-queue observability as separate follow-ups if they still reproduce. Do we have a high-confidence way to reproduce the issue? Yes, at source level. Current main can reach active-abort recovery with queueDepth=0, abort/drain can report true after the embedded-run registry clears, and the existing release gate ignores a still-active command-lane task unless another reset arm is true; I did not run a live gateway reproduction in this read-only review. Is this the best way to solve the issue? Yes for the primary release defect: this is an acceptable narrow mitigation because it reuses the existing command-lane generation reset contract and preserves the fresh-task guard. It is not the full solution for stale target binding, ineffective-recovery logging, or all abort-aware tool/compaction cleanup. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 89de454f822c. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +14, Tests +34. Total +48 across 2 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
fix #92270
PR Comment for Issue #92270
1. Solution Overview
This fix addresses Issue #92270 where stuck-session recovery reports
status=abortedwithreleased=0while the wedge persists for hours.Root Cause
recoverStuckDiagnosticSessiondecided whether to callresetCommandLanesolely based onqueuedCountandqueueDepthafter a successfulabort+drain, ignoring the possibility that the command lane still has an underlying active task (e.g., a run stuck inwaitForCompactionRetryor in-flight tool execution). This leftactiveCount > 0unhandled, blocking queued work forever.Fix Strategy
After the abort completes, additionally check
postAbortLaneSnapshot.activeCount. If the lane has not started a new fresh task butactiveCount > 0, forceresetCommandLaneto unblock the lane so queued work can drain.2. Changes Detail
src/logging/diagnostic-stuck-session-recovery.runtime.tspostAbortLaneSnapshotafter abort (previously onlyqueuedCountwas read).2. Introduce
laneStillBlockedByPreExistingTask: when!laneStartedFreshTask && postAbortLaneSnapshot.activeCount > 0, includeresetCommandLanein the release logic.3. Ensure mutual exclusion with existing
laneStartedFreshTaskto avoid killing healthy fresh tasks.src/logging/diagnostic-stuck-session-recovery.runtime.test.tsabort+drainsucceeds withqueueDepth=0but laneactiveCount=1. VerifyresetCommandLaneis called and outcome hasreleased=1.3. Test Coverage
New Test
"releases the session lane when abort+drain succeeds but the lane task is still executing"allowActiveAbort=true,abortEmbeddedAgentRunreturns true,waitForEmbeddedAgentRunEndreturns true (simulating successful abort+drain).getCommandLaneActiveTaskIdsalways returns[101](no fresh task);getCommandLaneSnapshotreturnsactiveCount=1, queuedCount=0.resetCommandLaneis called once; outcome is{ status: "aborted", released: 1 }.Regression Tests
All 22 existing tests pass, ensuring no breakage for:
laneStartedFreshTask === true(lane already pumped fresh work during abort) — lane is preserved.queuedCount > 0orhasQueuedSessionWork— lane reset works as before.forceClearandnooppaths remain unchanged.Verification Command
node scripts/run-vitest.mjs src/logging/diagnostic-stuck-session-recovery.runtime.test.ts # Result: 23 passed (22 existing + 1 new)4. Next Steps
laneStillBlockedByPreExistingTaskandlaneStartedFreshTaskto ensure we never reset a healthy fresh task.waitForCompactionRetryand similar paths do not respect abort signals should still be investigated (see related Issues Embedded run never exits after abort: waitForCompactionRetry() not tied to abort signal, session stays active and locked #12085, [Bug]: Embedded run timeout fails to clean up session/lane state when compaction is in-flight (waitForCompactionRetry not abort-aware) #13341, [Bug]: Embedded run timeout fails to clean up session/lane state when tool execution is in-flight #14228, Session lane stays stuck after embedded compaction run timeout #16331) so thatdrained=trueafter abort truly means the task ended.sessionId=unknowncombined with aborting the wrong session still occurs, consider adding explicit mismatch detection and lane-level escalation in theactiveSessionIdresolution logic insiderecoverStuckDiagnosticSession.Comment generated for PR targeting Issue #92270.