Skip to content

fix: Stop fails after cancelling queued collector admission - #157927

Closed
steipete wants to merge 1 commit into
mainfrom
codex/mcp-cancel-publication-20260925
Closed

steipete wants to merge 1 commit into
mainfrom
codex/mcp-cancel-publication-20260925

Conversation

@steipete

Copy link
Copy Markdown
Contributor

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

  • Reproduced the reported CI error on unchanged production by allowing real provisional deletion to finish before publication preparation; both full-session and exact Stop failed. The new scheduler regression also failed before the repair.
  • Native admission regression: 3/3 passed, including late-cleanup refusal. 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.
  • Scheduler: 24/24 passed, 3.42s Vitest wall; three new overlapping-hold cases took 2–3ms each. Its wrapper invocation also included the earlier two-case native fixture and took 72.40s total. Nine additional cancellation, publication, retirement, authority, and spawn-fixture files passed 208 cases.
  • Selected changed-file checks passed, including core production types, all 25 consuming test graphs, lint, dead exports, storage guards, and runtime value-cycle checks. Node 24.21.0 / pnpm 12.4.2 on macOS; frozen dependencies unchanged. Managed P0–P2 review was refreshed with the final failure evidence and found no accepted/actionable finding; the failures below remain unresolved.

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 949ad303b1387515658ddd6b188017015ac78511 passed 21/21 in 255.60s. The frozen candidate passed 18/21 in 1,971.71s, with these failures in subagent-spawn.production-boundary.test.ts:

Case Candidate time Failure
worker-current 173.354s SQLite session reclamation commit checkpoint expired
worker-reassigned 322.970s afterEach exceeded its existing 180,000ms limit
worker-reassigned-during-delete 389.092s Same afterEach timeout

The 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.

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.
@clawsweeper

clawsweeper Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime agents Agent runtime and tooling size: M labels Sep 25, 2026
@steipete
steipete marked this pull request as ready for review September 25, 2026 05:30
@steipete

Copy link
Copy Markdown
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling gateway Gateway runtime size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant