Skip to content

fix(swarm): reduce cancellation stalls during session writes - #163485

Merged
steipete merged 1 commit into
mainfrom
codex/swarm-proof-composition-20261002
Oct 2, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/swarm-proof-composition-20261002

Conversation

@steipete

@steipete steipete commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Related: #130741

What Problem This Solves

Fixes: stopping a Swarm child can stall during session preparation behind a write for an unrelated session.

User Impact

Cancellation can reuse a session that is already ready, while retaining current identity checks and the existing ordering for its final publication. No configuration or migration is required.

Why This Change Was Made

A prepared native generation now records readiness only after initialization and registration publication have settled. Cancellation reuses that exact live generation instead of submitting an empty writer operation. Unready generations still use normal preparation, and stale authority still fails.

Evidence

A deterministic regression failed with cancellation preparation queued behind an unrelated writer and passes with this change. The final focused run passed 32 cases covering warm preparation, generation readiness, metadata publication, and replacement publication. Changed type, lint, and storage checks passed, the normal build passed with all declarations enabled, and fresh Codex review completed without actionable findings through P2.

Single-worker command wall times were 164.56 s for warm preparation (2 cases), 84.55 s for readiness (2), 122.67 s for metadata publication (6), and 106.83 s for replacement publication (22). These include test startup and transformation. CI job timings are available in the run below.

CI attempt 37002820229/1 completed with 87 successful jobs, 20 skipped jobs, two failing test shards and their aggregate, and no cancellations. The failures are pre-existing fixtures in server.chat.orphaned-recovery.test.ts and server-plugin-in-process-dispatch.session-reads.test.ts: main's roster migration in #162612 rejects their retired default marker and agents.list before the modified Swarm paths execute. The fixtures and their configuration-loading paths are unchanged between the tested main baseline and PR merge. This is source-based attribution; no separate baseline replay is claimed. CI remains failed, with explicit maintainer authorization to use the native pre-existing-failure admin exception.

Main subsequently corrected both fixtures in #148951. ClawSweeper completed review of the exact published head without actionable introduced findings. This component proof does not establish the combined live 500 ms responsiveness target.

@clawsweeper

clawsweeper Bot commented Oct 2, 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 docs Improvements or additions to documentation gateway Gateway runtime agents Agent runtime and tooling size: L labels Oct 2, 2026
@steipete
steipete marked this pull request as ready for review October 2, 2026 11:46
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 2, 2026
@clawsweeper

clawsweeper Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 2, 2026, 8:29 AM ET / 12:29 UTC (Revision 3).

ClawSweeper review

What this changes

The PR lets Swarm child cancellation reuse an initialized database worker while awaiting the selected session’s pending publication and preserving final write ordering.

Merge readiness

✅ Ready for maintainer review

This PR remains useful: current main still queues cancellation preparation behind unrelated session writes. No actionable introduced correctness or security defect was found.

Priority: P2
Reviewed head: 5ccc63bdab3995e6996a00b6eed434898bdb25ca

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, maintainable repair with meaningful concurrency regressions and no actionable introduced findings.
Proof confidence 🌊 off-meta tidepool Not applicable: Verified repository-admin authorship exempts ordinary contributor proof. The inspected regressions exercise real session preparation and SQLite publication with delayed delivery, and the body reports passing component results; broader live responsiveness is expressly unproven. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Verified repository-admin authorship exempts ordinary contributor proof. The inspected regressions exercise real session preparation and SQLite publication with delayed delivery, and the body reports passing component results; broader live responsiveness is expressly unproven. No stored-data contract changes.
Evidence reviewed 9 items Pinned introduction and merge ownership: Reviewed the complete introduced delta from f859694 to the exact head. Raw test-merge records confirm parents e939bef followed by that head; its cancellation delta matches the introduced change.
Current main still needs the repair: Fetched main retains unconditional withSessionEntryWorker preparation with an empty runExisting operation. The merged related metadata-authority PR does not implement this warm-generation shortcut.
Prepared generation retains live ownership: Readiness becomes available after native initialization and registration publication settle. Capture rejects pending opening, native closing, or failed cleanup; the retained claim checks borrower liveness, physical identity, exact generation, and native availability.
Findings None None.
Security None None.

How this fits together

Swarm coordinates child-agent runs and their cancellation. Session preparation reads the child’s SQLite state and retains its live generation before cancellation and terminal-state publication proceed.

flowchart TD
  A[Stop child request] --> B[Select child session]
  B --> C{Database worker ready?}
  C -->|Yes| D[Retain live generation]
  C -->|No| E[Normal writer preparation]
  E --> D
  D --> F[Await selected session publication]
  F --> G[Validate and cancel child]
  G --> H[Publish through writer queue]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +81, Tests +487, Docs +8. Total +576 across 31 files.

View PR surface stats
Area Files Added Removed Net
Source 17 170 89 +81
Tests 13 549 62 +487
Docs 1 8 0 +8
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 31 727 151 +576

Review metrics

Metric Value Why it matters
Production versus regression coverage production +170/-89, tests/support +549/-62 Production growth supplies readiness and publication settlement within existing owners; most added code exercises their concurrency contracts.

Technical review

Best possible solution:

Keep preparation independent of unrelated writes while the existing session and cancellation owners enforce lifecycle validity and ordered terminal publication.

Do we have a high-confidence way to reproduce the issue?

Yes, source establishes the path: hold an unrelated session writer, then prepare cancellation for an already initialized child. Main submits the empty preparation operation to that same queue; this review did not execute the scenario.

Is this the best way to solve the issue?

Yes. Reusing the existing live generation removes unnecessary writer admission while preserving cold preparation, selected-session settlement, and final publication ordering.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 71b1c049f4c0.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a bounded cancellation-responsiveness repair without evidence of a new emergency or broader runtime outage.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Verified repository-admin authorship exempts ordinary contributor proof. The inspected regressions exercise real session preparation and SQLite publication with delayed delivery, and the body reports passing component results; broader live responsiveness is expressly unproven. No stored-data contract changes.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (2 earlier review cycles)
  • reviewed 2026-10-02T11:52:02.241Z sha 5ccc63b :: needs maintainer review before merge. :: none
  • reviewed 2026-10-02T12:10:52.430Z sha 5ccc63b :: needs maintainer review before merge. :: none

@steipete
steipete merged commit 50b3415 into main Oct 2, 2026
254 of 261 checks passed
@steipete
steipete deleted the codex/swarm-proof-composition-20261002 branch October 2, 2026 12:32
@steipete

steipete commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

Merged via explicitly authorized admin squash with attributed pre-existing CI failures.

steipete added a commit that referenced this pull request Oct 2, 2026
Merge main to incorporate the execution lifecycle changes in #163485.
Import the maintenance executor type from its contract owner, restoring
declaration generation and downstream production/test types and lint.

The focused patch, maintenance, recap retry, generation-readiness and
replacement-publication selection passes 147 tests. Core types, scoped lint
and the full-candidate review through P2 pass.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant