Repository navigation
Conversation
Hold the exact active preaccept reservation until cancellation publication releases it. Keep stale-session rejection and existing cleanup settlement, and migrate the internal hold API together with its callers. Broader spawn fixture failures and timing variance are documented in the PR evidence.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Superseded by canonical main commit d65bc76, which fixes the same queued collector cancellation race through the existing retirement owner. That owner captures the exact run before cancellation, holds failed-launch cleanup until cancellation publication finishes, and releases publication before waiting for scheduler cleanup. The collector registration still rechecks generation, session, and live ownership at cleanup. Source comparison confirms the landed path covers the native-preaccept failure addressed here. Keeping this PR's broader scheduler barrier would give the same ordering responsibility two owners. The canonical commit includes deterministic publication-order regression coverage and records original-failure/fixed-pass proof plus the related cleanup cases. I verified its source and main ancestry; I did not independently rerun those canonical tests. This PR's exact-head CI passed 128 jobs with 19 skipped, but its previously documented local 18/21 result and substantial slowdown remain unexplained. Closing this superseded implementation does not classify those failures as fixed or unrelated. |
Related: #157584
What Problem This Solves
Fixes: Stop can cancel a queued collector's native admission and then report
INVALID_REQUEST: Queued collector session changed before cancellation publication; retry Stop.when the resulting launch cleanup deletes its provisional session first.User Impact
Stop can publish the cancellation result before its own cleanup removes the session. A session deleted or replaced by work already underway still fails the existing identity checks. Broader sibling validation has unresolved failures and material timing variance; this draft needs exact-head hosted validation.
Why This Change Was Made
The scheduler marks a launch active before Gateway admission completes, so the former queued-only hold missed this interval. The change retains the exact reservation through cancellation publication and defers new failed-launch cleanup until its holds release. The internal API and callers move together to
holdSwarmRunReservation; session-generation and caller-authority checks remain intact, with no new lifecycle lock hierarchy.Evidence
pnpm test src/gateway/session-utils.queued-collector-admission.test.ts --maxWorkers=1: 63.04s command wall, 58.63s Vitest wall; cases 4.886s, 2.454s, and 2.670s. This retains real Gateway admission and committed deletion; preparation/transforms dominate wall time.Unresolved sibling validation. The first broader run timed out in the production-boundary fixture's completed-parent case after 96.094s: the child was accepted but had not entered embedded execution, and fixture cleanup retained work. That run was stopped after the failure; it was not a passing suite.
One controlled full-file comparison preserved case order, runtime, installation, assertions, and limits, adding only identical bounded warning classification. Baseline
949ad303b1387515658ddd6b188017015ac78511passed 21/21 in 255.60s. The frozen candidate passed 18/21 in 1,971.71s, with these failures insubagent-spawn.production-boundary.test.ts:worker-currentSQLite session reclamation commit checkpoint expiredworker-reassignedafterEachexceeded its existing 180,000ms limitworker-reassigned-during-deleteafterEachtimeoutThe original completed-parent case passed in both controlled runs (4.038s baseline / 3.844s candidate). Other candidate cases slowed substantially; for example, replaced-session cleanup took 200.120s versus 1.308s on baseline. These results do not establish that the original timeout or final failures are fixed or unrelated, and the performance comparison is not clean.
Source inspection found the named slow queued-cleanup branches do not execute the new active-hold wait. A private native sample showed filesystem-stat/promise continuation and string-processing activity, but did not identify its JavaScript owner. The checkpoint failure reflects an existing five-second commit-authorization wait expiring; no timeout or guard was changed. Causality and the timing variance remain unresolved. All owned processes settled; all failing results remain part of this validation record.