Skip to content

fix: session archive completes after forced stop - #125614

Merged
steipete merged 1 commit into
mainfrom
steipete/workboard-automation-session-review-8bc6c6
Aug 18, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/workboard-automation-session-review-8bc6c6

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Closes #125555

What Problem This Solves

Fixes an issue where operators stopping a workspace-backed session could be unable to archive it when the embedded run required forced terminalization. The session appeared killed and had no remaining process, but its durable local turn claim remained active, so every archive attempt returned “did not finish stopping; retry the archive.”

Why This Change Was Made

Forced terminalization now invokes the exact claim-settlement closure captured by the local turn owner and bound to the authoritative embedded-run handle. Normal completion and forced recovery share that idempotent, replacement-fenced cleanup path; archive remains a consumer of authoritative lifecycle state and does not gain a stale-claim bypass.

The regression composes the real SQLite placement store, a deliberately unresolved local run, forced killed-state persistence, archive drain, replacement claim acquisition, and late completion of the old run.

AI-assisted implementation; maintainer reviewed the complete diff and behavior.

User Impact

Stopped sessions no longer remain permanently unarchivable after a forced stop. Transcripts and worktrees keep their existing preservation behavior, while stale local execution authority is released at its owning lifecycle boundary.

Evidence

Before (live managed Gateway, redacted):

  • chat.abort succeeded.
  • sessions.patch failed twice with Timed out waiting for session <id> turn claim release and the user-visible retry error.
  • The lane exceeded its abort grace and the session persisted as killed.
  • Later inspection showed no process in the worktree and a clean tree, but the original local placement claim was still durable.

Regression proof:

  • The new composed regression failed on pre-fix main for the intended reason: Timed out waiting for session session-worker-turn turn claim release.
  • node scripts/run-vitest.mjs across 11 lifecycle/worker-turn files: 108 tests passed.
  • Focused source-blind behavior validation ran the composed scenario twice: both runs passed.
  • node scripts/check-changed.mjs -- <six changed paths> passed core and core-test lanes, including typecheck, lint, import cycles, and database guards.
  • pnpm build passed; no ineffective dynamic-import warning was introduced.
  • Fresh Codex autoreview at P0/P1: no accepted/actionable findings.
  • git diff --check passed.

Proof boundary:

  • The original failure was observed live. Post-fix live Gateway reproduction was not repeated because deterministically triggering it requires intentionally wedging an internal run beyond abort grace; the after-proof uses the real SQLite placement/archive owner boundary rather than a mocked claim.

LOC classification:

  • Production: +62/-13 (net +49), required for the closure-bound exact-authority seam across the local-turn and embedded-run owners.
  • Tests/test support: +134/-1 (net +133).

@clawsweeper

clawsweeper Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@steipete
steipete marked this pull request as ready for review August 18, 2026 05:01
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime agents Agent runtime and tooling size: M maintainer Maintainer-authored PR labels Aug 18, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. 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 Aug 18, 2026
@clawsweeper

clawsweeper Bot commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 18, 2026, 1:42 AM ET / 05:42 UTC.

ClawSweeper review

What this changes

This PR makes forced embedded-run terminalization settle the matching local worker-turn claim so a stopped workspace session can complete archive draining.

Regression provenance

Possible regression — probable (reproduction; reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

No blocking source defect found: the patch releases the exact durable claim at its lifecycle owner and preserves replacement fencing. Keep this maintainer-owned PR open until its current merge result receives exact-head lifecycle validation.

Priority: P2
Reviewed head: 38620b631b73a2d1513cbfb3ef69ee142795e47b
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch is a focused owner-boundary repair with a meaningful composed regression; final merge-result validation is the remaining confidence reducer.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its body nevertheless describes a live pre-fix observation and composed owner-boundary after-proof.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its body nevertheless describes a live pre-fix observation and composed owner-boundary after-proof.
Evidence reviewed 6 items Admission owner boundary: The embedded-run lane enters session-placement admission before executing the run; the local launcher captures a closure over the newly created exact claim and uses it for both ordinary completion and forced settlement.
Exact-handle forced cleanup: Forced clearing reads settlement only from the expected active handle, removes it before cleanup, and awaits it in finally; late completion cannot release a replacement claim because release validates claim identity and generation.
Archive remains an authoritative consumer: Archive waits for a durable turn claim to release rather than bypassing it, so the repair stays at the local-turn lifecycle owner.
Findings None None.
Security None None.

How this fits together

Workspace-backed agent sessions register an embedded run and a durable local worker-turn claim. The archive lifecycle aborts active work and waits for both the embedded run and claim to drain before archiving the session.

flowchart LR
  A[Stopped workspace session] --> B[Embedded agent run]
  B --> C[Local worker-turn claim]
  B --> D[Forced terminalization]
  D --> E[Exact claim settlement]
  E --> F[Archive lifecycle drain]
  F --> G[Archived session]
Loading

Decision needed

Question Recommendation
After exact-head merge-result validation, should forced terminalization settle the captured local claim through this lifecycle seam? Validate then merge: Run the composed forced-stop scenario on the final merge result and merge if it releases only the old claim while archive succeeds.

Why: The patch deliberately changes when durable worker-turn authority is released, so the final merge result needs an owner decision after session-state validation.

Before merge

  • Resolve merge risk (P1) - This bug repair adds net +49 production lines across durable session lifecycle ownership; it needs exact-head merge-result validation because the local checkout could not materialize current main.
  • Resolve merge risk (P1) - The branch is behind main, and the changed claim-release timing is session-state-sensitive even though the submitted replacement-fencing scenario is sound.
Agent review details

Security

None.

PR surface

Source +51, Tests +131. Total +182 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 5 64 13 +51
Tests 1 132 1 +131
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 196 14 +182

Review metrics

Metric Value Why it matters
Production versus regression coverage production +62/-13 (net +49); tests/test support +134/-1 (net +133) The positive production growth introduces an exact-claim lifecycle seam; the larger test addition covers forced stop, archive drain, and replacement fencing.

Stored data model

Persistent data-model change detected: durable storage schema: src/gateway/worker-environments/worker-turn-launcher.test.ts, serialized state: src/agents/session-placement-admission.ts, unknown-data-model-change: src/gateway/worker-environments/worker-turn-launcher.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Validate the final merge result (recommended)
    Run the composed forced-stop, archive, replacement-claim, and late-completion scenario against the exact merge result before landing.
  2. Pause on integration uncertainty
    Hold the PR if the final merge result cannot demonstrate that a replacement claim remains fenced from the old run.

Technical review

Best possible solution:

Keep the exact-handle settlement path, then validate the composed force-stop/archive/replacement scenario on the final merge result before landing.

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

Yes, from source: leave a local embedded turn unresolved past abort grace, force-terminalize it, then archive the session and observe the durable claim drain. This read-only review did not execute the scenario.

Is this the best way to solve the issue?

Yes, subject to exact-head validation: the repair releases state at the claim owner and keeps archive as an authoritative consumer rather than adding an archive-side bypass.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 5d098cd36fca.

Labels

Label justifications:

  • P2: The defect blocks archive completion for force-stopped workspace sessions while preserving the transcript and worktree.
  • merge-risk: 🚨 session-state: Merging changes release timing for durable local turn claims and must not clear a replacement claim.
  • 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: This maintainer-authored PR is exempt from the external-contributor proof gate; its body nevertheless describes a live pre-fix observation and composed owner-boundary after-proof.

Evidence

What I checked:

Likely related people:

  • steipete: Authored the PR head and the locally materialized preceding lifecycle commit used in the provenance check. (role: recent lifecycle contributor; confidence: medium; commits: 38620b631b73, b66845607a12; files: src/agents/embedded-agent-runner/runs.ts, src/gateway/worker-environments/worker-turn-launcher.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Run the composed forced-stop/archive/replacement scenario against the exact final merge result.

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-08-18T05:10:47.388Z sha fd0d965faf6282e716771279a224d5d801c37792 :: needs maintainer review before merge. :: none

Forced embedded-run terminalization now settles the exact closure-bound local placement claim, preserving replacement fencing and allowing archive to drain.

Closes #125555
@steipete
steipete force-pushed the steipete/workboard-automation-session-review-8bc6c6 branch from fd0d965 to 38620b6 Compare August 18, 2026 05:35
@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready at exact prepared head 38620b631b73a2d1513cbfb3ef69ee142795e47b, prepared against main base 2eec0470652d6d6a559c355a9c517d45f0c066ae.

Native preparation completed with:

  • OPENCLAW_TESTBOX=1 scripts/pr prepare-run 125614
  • Hosted exact-head gate: CI run 32103508904 and Workflow Sanity run 32103508903
  • Gate mode: hosted_exact_or_recent_parent; no separate Blacksmith Testbox run ID was created because the native exact-head gate recorded the Testbox variants as not applicable for this change
  • Prepared head and remote PR head both verified as 38620b631b73a2d1513cbfb3ef69ee142795e47b

Local proof completed before preparation:

node scripts/run-vitest.mjs <11 focused lifecycle/worker-turn test files>  # 108 passed
node scripts/check-changed.mjs -- <six changed paths>                     # core/coreTests passed
pnpm build                                                               # passed
git diff --check                                                         # passed

The composed source-blind forced-stop/archive/replacement scenario passed twice, and fresh P0/P1 autoreview found no accepted/actionable findings. The pre-fix regression failed for the intended Timed out waiting for session session-worker-turn turn claim release reason.

ClawSweeper’s latest review has no findings. Its rank-up move—mechanical current-main refresh plus exact-head validation—is complete. The patch identity stayed stable, the review is under 12 hours, and the post-review change was mechanical, so no re-review was requested.

The first PR head had a compact-small-2 failure on its merge ref. After the current-main refresh, the Linux missing stop/restart cluster did not reproduce; exact-head CI is fully green.

Best-fix verdict: best. Forced terminalization now settles the exact closure-bound claim captured by the local-turn owner and authoritative embedded handle. Archive remains a consumer of authoritative state, and claim identity/generation validation keeps replacement claims fenced. Production is +62/-13 (net +49), justified by this cross-owner exact-authority seam; tests/test support are +134/-1.

Proof gap: Post-fix live Gateway proof was not repeated because deterministic triggering requires intentionally wedging an internal run beyond abort grace; the after-proof is the real SQLite placement/archive owner boundary.

@steipete
steipete merged commit fc8eb59 into main Aug 18, 2026
212 checks passed
@steipete
steipete deleted the steipete/workboard-automation-session-review-8bc6c6 branch August 18, 2026 05:54
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 20, 2026
Forced embedded-run terminalization now settles the exact closure-bound local placement claim, preserving replacement fencing and allowing archive to drain.

Closes openclaw#125555
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 maintainer Maintainer-authored PR merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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.

[Bug]: Archiving a stopped session can retain a stale local turn claim

1 participant