Skip to content

fix(sessions): release lifecycle locks after queued admission cancellation - #165898

Merged
steipete merged 1 commit into
mainfrom
steipete/perf-micro-retained-owner-after-abort-grace-20260919
Oct 6, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/perf-micro-retained-owner-after-abort-grace-20260919

Conversation

@steipete

@steipete steipete commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes cancelled session admission retaining lifecycle locks while queued behind a store writer. Later reset, recovery, or cleanup work for the same session can remain blocked even after the cancelled admission disappears from active admission counts.

User Impact

Cancelled work releases its unstarted writer barrier so session lifecycle work can proceed. Already-running writes still finish under their existing owner. No configuration, schema, or stored-format change is required.

Why This Change Was Made

The session admission owner already receives cancellation, and the shared store-writer queue already removes cancelled waiting tasks without interrupting admitted writes. The session-store adapter did not carry that signal, leaving the rejected admission's callback queued while it held lifecycle locks. This change completes that existing cancellation path.

Production LOC: +2 net lines. The added option and forwarding are needed to carry the existing cancellation contract through the session-store adapter; no new queue, timer, cache, or cleanup owner is introduced.

Evidence

The extended existing regression holds the original writer open, cancels a queued admission, and requires a same-session lifecycle mutation to complete before that writer is released.

  • Before: unchanged production code cannot complete the lifecycle mutation and hits the 120-second test deadline (202.12 seconds command wall time, including cold worker compilation).
  • After: the regression passes in 29 ms (57.01 seconds command wall time, including worker compilation).
  • Command on an isolated Linux rig: node scripts/run-vitest.mjs src/sessions/session-lifecycle-admission.test.ts -t "releases lifecycle locks".
  • Independent review: no actionable P0–P2 findings.
  • blacksmith-testbox / openclaw-check, lease tbx_01m47dq1j56pjh6axx93qwwbtb: 47 tests passed using node scripts/run-vitest.mjs src/sessions/session-lifecycle-admission.test.ts src/shared/store-writer-queue.test.ts src/config/sessions/store-writer.test.ts --maxWorkers=1. Exact source hashes verified before execution. Tests: 31.35 seconds wall time; full command: 53.903 seconds. The changed file's 31 tests completed in a 23.26-second runner invocation, including compilation/import; the new regression took 2 ms.
  • The initial Testbox lease tbx_01m47bmxcmw7vmjf1wb7ae3mke remained queued beyond 20 minutes and was stopped when the committed head changed. The authorized isolated Linux rig fallback completed node scripts/check-changed.mjs --staged with exit 0 (01:21–02:25 UTC). All 27 core test type graphs passed, lint reported zero warnings/errors, dead-export scans reported zero entries, and runtime import-cycle checks reported zero cycles. The remaining native guards passed.

Separate diagnostic scenarios using real registry persistence and agents_wait settle three timeout results, both with a waiting parent and after parent-wait cancellation. An initialized registry also expires suspended delivery and retires an exhausted requester wake. All end with zero blockers in that fixture, which does not create the full Gateway chat/reply owner graph.

This is a bounded admission-lock fix found while investigating terminal child timeout retention. It does not by itself prove that every retained parent/child registration in that incident settles, and it does not force-release unfinished writes.

CI currently has an inherited production-audit failure: [email protected] matches GHSA-68fv-2mgg-jv7q. A Testbox audit of the exact base 381b1e05d7f0 lockfile reproduced the same finding (3.879 seconds, exit 1), and cmp verified that the base and PR lockfiles are identical. No dependency change is included. Failed job: https://github.com/openclaw/openclaw/actions/runs/37400070914/job/112065353711. The private-key scan passed. CI fail-fast cancelled 37 jobs; aggregate gates are red from this inherited failure. No rerun or merge has been requested.

…ation

Forward the session admission signal through the store writer adapter so cancellation removes an unstarted barrier instead of retaining lifecycle locks. Started writes keep their existing settlement and FIFO contract.
@clawsweeper

clawsweeper Bot commented Oct 6, 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.

@steipete
steipete enabled auto-merge (squash) October 6, 2026 01:40
@clawsweeper

clawsweeper Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 5, 2026, 9:51 PM ET / October 6, 2026, 01:51 UTC (Revision 2).

ClawSweeper review

What this changes

The PR forwards session admission cancellation to the existing store writer queue and extends regression coverage so cancelled waiting work releases lifecycle locks.

Merge readiness

✅ Ready for maintainer review

The fix remains necessary on fetched main, and the pinned patch has no actionable correctness findings. The inherited CI failure does not establish a defect in this change.

Priority: P2
Reviewed head: 7b98a3dcf8972d0bd4223dc9e01d7f4cd4a2fc63

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair reuses the established cancellation owner and adds a meaningful ordering regression with reported before/after validation.
Proof confidence 🌊 off-meta tidepool Not applicable: The author has verified repository admin permission, so ordinary external-contributor proof is exempt. Reported production-owner regression tests exercise queued cancellation and lock release, but do not demonstrate a full Gateway run; no material authority change or stored-data contract change requires an additional proof gate.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The author has verified repository admin permission, so ordinary external-contributor proof is exempt. Reported production-owner regression tests exercise queued cancellation and lock release, but do not demonstrate a full Gateway run; no material authority change or stored-data contract change requires an additional proof gate.
Evidence reviewed 10 items Pinned introduced change: The merge-base-to-head delta adds optional signal forwarding in the session store adapter, passes the admission signal, and extends the existing cancellation regression. Endpoint drift was not treated as PR-owned work.
Existing cancellation owner: The shared queue removes and rejects only tasks still pending. Its callback detaches cancellation when execution begins, preserving active settlement, caller context, and writer ownership. The patch reuses this contract rather than introducing another cancellation owner.
Admission cleanup and revalidation: Admission awaits the writer barrier inside lifecycle lock ownership. Forwarding cancellation rejects that wait and unwinds the locks; the existing writer-start check and final revalidation remain intact. The reply admission caller already supplies its upstream cancellation signal.
Findings None None.
Security None None.

How this fits together

Session admission coordinates new agent work with session reset, recovery, and cleanup. It holds lifecycle locks while validating against the store writer queue, then returns an admission lease or releases the reservation.

flowchart TD
  A[New session work] --> B[Acquire lifecycle locks]
  B --> C[Validate session]
  C --> D[Store writer queue]
  E[Cancellation signal] --> D
  D --> F{Writer started?}
  F -->|No, cancelled| G[Reject and release locks]
  F -->|Yes| H[Finish validation and settle]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +2, Tests +14. Total +16 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 2 3 1 +2
Tests 1 22 8 +14
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 25 9 +16

Review metrics

Metric Value Why it matters
Regression execution cost Reported regression: 2 ms; affected-file runner invocation: 23.26 s The ordering assertion adds negligible test execution cost; the reported invocation includes compilation and imports.

Technical review

Best possible solution:

Keep cancellation owned by the existing writer queue so unstarted admissions unwind their lifecycle locks while started writes settle normally.

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

Yes, source establishes a focused path: hold a store writer, cancel a waiting admission, then attempt a same-session lifecycle mutation before releasing the writer. I did not execute tests during this read-only review.

Is this the best way to solve the issue?

Yes, forwarding the existing signal through the adapter is the narrow repair; it preserves queue ownership, final validation, and started-write settlement.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 50f38c6ceb80.

Labels

Label changes:

  • add P2: This repairs a bounded session lifecycle stall after cancellation, without evidence of a widespread urgent regression.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The author has verified repository admin permission, so ordinary external-contributor proof is exempt. Reported production-owner regression tests exercise queued cancellation and lock release, but do not demonstrate a full Gateway run; no material authority change or stored-data contract change requires an additional proof gate.

Label justifications:

  • P2: This repairs a bounded session lifecycle stall after cancellation, without evidence of a widespread urgent regression.
  • 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: The author has verified repository admin permission, so ordinary external-contributor proof is exempt. Reported production-owner regression tests exercise queued cancellation and lock release, but do not demonstrate a full Gateway run; no material authority change or stored-data contract change requires an additional proof gate.

Evidence

What I checked:

  • Pinned introduced change: The merge-base-to-head delta adds optional signal forwarding in the session store adapter, passes the admission signal, and extends the existing cancellation regression. Endpoint drift was not treated as PR-owned work. (src/config/sessions/store-writer.ts:22, 7b98a3dcf897)
  • Existing cancellation owner: The shared queue removes and rejects only tasks still pending. Its callback detaches cancellation when execution begins, preserving active settlement, caller context, and writer ownership. The patch reuses this contract rather than introducing another cancellation owner. (src/shared/store-writer-queue.ts:276, 7b98a3dcf897)
  • Admission cleanup and revalidation: Admission awaits the writer barrier inside lifecycle lock ownership. Forwarding cancellation rejects that wait and unwinds the locks; the existing writer-start check and final revalidation remain intact. The reply admission caller already supplies its upstream cancellation signal. (src/sessions/session-lifecycle-admission.ts:654, 7b98a3dcf897)
  • Meaningful regression boundary: The changed regression aborts a queued admission and awaits a same-session lifecycle mutation before releasing the original writer. It extends the existing test, uses production admission and queue owners, and adds no production testing seam or wall-clock race. (src/sessions/session-lifecycle-admission.test.ts:704, 7b98a3dcf897)
  • Still missing on main and latest release: Fetched main still lacks the adapter signal option and admission forwarding. The latest supplied release, v2026.9.8, also lacks adapter forwarding. No merged fixing PR was established. (src/config/sessions/store-writer.ts:5, 50f38c6ceb80)
  • Release comparison: The released adapter has reentrant and identity options but no cancellation signal. (src/config/sessions/store-writer.ts:5, fc23bc864e45)

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 (1 earlier review cycle)
  • reviewed 2026-10-06T01:40:41.340Z sha 7b98a3d :: needs maintainer review before merge. :: none

@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 6, 2026
@steipete
steipete merged commit 9627e8a into main Oct 6, 2026
110 of 150 checks passed
@steipete
steipete deleted the steipete/perf-micro-retained-owner-after-abort-grace-20260919 branch October 6, 2026 02:32
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 6, 2026
…ation (openclaw#165898)

Forward the session admission signal through the store writer adapter so cancellation removes an unstarted barrier instead of retaining lifecycle locks. Started writes keep their existing settlement and FIFO contract.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS 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