Skip to content

fix(workboard): recover interrupted worker launches - #126170

Merged
steipete merged 2 commits into
mainfrom
steipete/elegant-ptolemy-6a97ea
Aug 19, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/elegant-ptolemy-6a97ea

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Related: #125951

What Problem This Solves

Fixes an issue where Workboard cards could remain permanently running when the dispatcher or Gateway restarted after a worker launch was prepared but before worker acceptance was durably recorded.

Why This Change Was Made

The Workboard store now owns a typed, durable launch lifecycle—prepared, accepted, or failed—inside the existing automation_json payload. The dispatcher persists preparation before calling the worker runtime, records acceptance through a fenced store transition, and lets post-restart lifecycle reconciliation either adopt a session that proves acceptance or fail a missing prepared launch. Delayed failures and stale lifecycle observations are matched against the exact prepared identity so they cannot overwrite a newer retry.

This replaces the prior process-local launchIntentPersisted flag and generic execution-association enrichment with canonical store-owned transitions and a trusted launch-state normalizer. The existing SQLite schema, persisted envelope version, and Gateway protocol are unchanged.

Provenance: clear — the prelaunch persistence window was introduced in #125951 on 2026-08-18 by PR author @steipete and squash-merged by @steipete as 549e6349f8579cbbaa29147dc193b3c6b76f6b99; it persisted a running association before subagent.run without a durable prepared/accepted phase that restart reconciliation could distinguish.

Production LOC: +495/-184 (net +311) | Tests: +483/-1 (net +482). The positive production delta is the durable typed launch-state ownership boundary, store transitions, restart reconciliation, and trusted normalizer; it does not add a parallel persistence path.

User Impact

Workboard no longer leaves cards permanently running when the dispatcher or Gateway restarts between launch preparation and worker acceptance. Accepted workers are recovered under their canonical session, genuinely missing launches become visibly blocked, and later retries are protected from delayed failures belonging to an older launch.

Evidence

  • Blacksmith Testbox tbx_01m0bjvjbz4rmqssnx4yevjcwb: https://github.com/openclaw/openclaw/actions/runs/32196803631
  • Focused Testbox command passed 4 files / 222 tests: dispatcher-ownership.test.ts, lifecycle-sync.test.ts, lifecycle-sync.restart.test.ts, and store.test.ts.
  • Targeted oxfmt, oxlint, core tsgo, extensions tsgo, extension-test tsgo, and git diff --check passed.
  • Restart coverage uses a shared backing store with the original prepare → process-loss → replacement-store ordering. It proves absent complete snapshots fail prepared launches, incomplete snapshots defer judgment, active/terminal sessions establish acceptance, and delayed dispatcher failures cannot overwrite recovery.
  • Store coverage proves untrusted metadata cannot mint launch state and stale failures/lifecycle observations cannot replace a newer retry.
  • Final Codex autoreview on the exact uncommitted bundle: clean, no accepted/actionable findings; overall correctness 0.97.
  • Proof gap: the coarse check-changed aggregate was not used as final proof because it stopped on unrelated assertion-safety baseline drift in extensions/copilot/src/tool-bridge.ts and src/agents/embedded-agent-runner/run/attempt-prompt-support.ts. The exact selected formatting, lint, typecheck, and focused test lanes all passed.
  • No SQLite DDL or schema-version change, no persisted-envelope version change, and no Gateway protocol change.

AI-assisted: implementation and review used Codex; the final diff and evidence were inspected and coordinated by the maintainer.

@clawsweeper

clawsweeper Bot commented Aug 19, 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 19, 2026 03:49
@steipete steipete closed this Aug 19, 2026
@steipete steipete reopened this Aug 19, 2026
@clawsweeper

clawsweeper Bot commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed August 19, 2026, 12:21 AM ET / 04:21 UTC.

ClawSweeper review

What this changes

The PR adds durable prepared, accepted, and failed launch phases to Workboard cards so restart reconciliation can recover accepted workers or visibly block launches that never reached Gateway acceptance.

Regression provenance

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

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep open: current main retains the missing-session no-op this PR addresses, but the prior P1 remains—an optional terminal timestamp is replaced with the reconciliation clock and can falsely adopt a never-accepted retry. Likely related people: steipete — recent Workboard launch-lifecycle owner (high confidence).

Priority: P1
Reviewed head: d3355eac098ac8d5d305963e5bd72f69e0cf207b

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch has a coherent durable-state direction, but a confirmed P1 restart transition remains unresolved.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its supplied focused Testbox evidence is supplemental.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its supplied focused Testbox evidence is supplemental.
Evidence reviewed 7 items Current-main behavior: Current main still treats an absent linked session as a missing observation during reconciliation, the legacy path this PR replaces.
Incorrect acceptance inference: The PR treats a terminal session with no timestamp as accepted at now, despite that time not being evidence that the prepared launch was accepted.
Gateway row contract: Gateway session rows make updatedAt optional, so the fallback is reachable through the supported local protocol contract.
Findings 1 actionable finding [P1] Require durable terminal acceptance evidence
Security None None.

Live Verification

Command: node scripts/run-vitest.mjs extensions/workboard/src/lifecycle-sync.restart.test.ts --reporter=verbose

Result: PASS (completed)

node scripts/run-vitest.mjs extensions/workboard/src/lifecycle-sync.restart.test.ts --reporter=verbose
runner@runnervmzvulz:/tmp/clawsweeper-live-proof-126170-P5LR10/target$ node scripts/run-vitest.mjs extensions/workboard/src/lifecycle-sync.restart.test.ts --rep
orter=verbose
node scripts/run-vitest.mjs extensions/workboard/src/lifecycle-sync.restart.test.ts --reporter=verbose
[test] starting test/vitest/vitest.extensions.config.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-126170-P5LR10/target

 ✓  extensions  extensions/workboard/src/lifecycle-sync.restart.test.ts › Workboard prepared launch restart recovery › fails a prepared launch absent from the f
irst complete post-restart snapshot 82ms
 ✓  extensions  extensions/workboard/src/lifecycle-sync.restart.test.ts › Workboard prepared launch restart recovery › fails a prepared launch when its persiste
d session has no active run 55ms
 ✓  extensions  extensions/workboard/src/lifecycle-sync.restart.test.ts › Workboard prepared launch restart recovery › accepts a prepared launch found under its
 canonical post-restart session 55ms
 ✓  extensions  extensions/workboard/src/lifecycle-sync.restart.test.ts › Workboard prepared launch restart recovery › accepts a prepared launch from an explici
t terminal session snapshot 52ms
 ✓  extensions  extensions/workboard/src/lifecycle-sync.restart.test.ts › Workboard prepared launch restart recovery › keeps a prepared launch running when the
post-restart snapshot is incomplete 55ms

 Test Files  1 passed (1)
      Tests  5 passed (5)
   Start at  04:22:07
   Duration  27.62s (transform 22.44s, setup 1.10s, import 25.84s, tests 302ms, environment 0ms)

[test] passed 1 Vitest shard in 33.65s
runner@runnervmzvulz:/tmp/clawsweeper-live-proof-126170-P5LR10/target$ node scripts/run-vitest.mjs extensions/workboard/src/lifecycle-sync.restart.test.ts --rep
orter=verbose
























Assertions:

  • PASS expect_output: Workboard prepared launch restart recovery

How this fits together

The Workboard plugin persists card state before dispatching a subagent through the Gateway. On restart, lifecycle reconciliation reads Gateway session rows and turns that evidence into the card’s visible running, review, or blocked state.

flowchart LR
  A[Ready Workboard card] --> B[Dispatcher prepares durable launch]
  B --> C[Gateway subagent launch]
  C --> D[Gateway session row]
  D --> E[Restart reconciliation]
  E --> F[Store-owned launch transition]
  F --> G[Visible card status]
Loading

Before merge

  • Require durable terminal acceptance evidence (P1) - updatedAt is optional on Gateway session rows, but this fallback turns its absence into now. Because retries reuse the card’s deterministic session key, an older terminal row can be adopted as this prepared launch and move the card to review or blocked although the new worker was never accepted. Leave that terminal row unproven and add the absent-timestamp regression case.
  • Resolve merge risk (P1) - Merging can turn a newly prepared but never-accepted retry into a terminal Workboard result when a same-key terminal Gateway session omits updatedAt.
  • Resolve merge risk (P1) - Production code grows by 311 net lines for the durable lifecycle; that owner-boundary growth is not ready to accept while an acceptance transition still relies on inferred time.

Findings

  • [P1] Require durable terminal acceptance evidence — extensions/workboard/src/lifecycle-sync.ts:305
Agent review details

Security

None.

PR surface

Source +311, Tests +482. Total +793 across 10 files.

View PR surface stats
Area Files Added Removed Net
Source 7 495 184 +311
Tests 3 483 1 +482
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 10 978 185 +793

Review metrics

Metric Value Why it matters
Production versus test LOC production +495/-184 (net +311); tests +483/-1 (net +482) The bug fix adds a durable store-owned lifecycle and extensive restart coverage; the remaining invalid transition must be corrected before that production growth is justified.

Stored data model

Persistent data-model change detected: vector/embedding metadata: extensions/workboard/src/dispatcher-ownership.test.ts, vector/embedding metadata: extensions/workboard/src/store-workflow.ts, vector/embedding metadata: extensions/workboard/src/store.test.ts, vector/embedding metadata: extensions/workboard/src/store.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Fence terminal adoption on durable evidence (recommended)
    Remove the updatedAt ?? now terminal fallback and cover the absent-timestamp stale-terminal restart case before merging.

Technical review

Best possible solution:

Keep the store-owned launch lifecycle, but treat a terminal session without a timestamp newer than preparation as unproven, then add the shared-store restart regression before merge.

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

Yes, from source: reconcile a prepared card against a complete terminal session snapshot with the same deterministic key and no updatedAt; the current fallback converts it to accepted at the current clock time.

Is this the best way to solve the issue?

No; durable launch state is the right owner boundary, but terminal acceptance must remain unproven when its optional timestamp is absent rather than being synthesized from reconciliation time.

Full review comments:

  • [P1] Require durable terminal acceptance evidence — extensions/workboard/src/lifecycle-sync.ts:305
    updatedAt is optional on Gateway session rows, but this fallback turns its absence into now. Because retries reuse the card’s deterministic session key, an older terminal row can be adopted as this prepared launch and move the card to review or blocked although the new worker was never accepted. Leave that terminal row unproven and add the absent-timestamp regression case.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.99

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 8c3b3c6ea8d3.

Labels

Label changes:

  • add P1: A Gateway restart can incorrectly move a Workboard card to a terminal state even though its new worker launch was never accepted.
  • add merge-risk: 🚨 session-state: The patch changes durable launch and execution-state reconciliation, and its timestamp fallback can associate stale terminal state with a newer retry.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its supplied focused Testbox evidence is supplemental.

Label justifications:

  • P1: A Gateway restart can incorrectly move a Workboard card to a terminal state even though its new worker launch was never accepted.
  • merge-risk: 🚨 session-state: The patch changes durable launch and execution-state reconciliation, and its timestamp fallback can associate stale terminal state with a newer retry.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its supplied focused Testbox evidence is supplemental.

Evidence

What I checked:

Likely related people:

  • steipete: Authored the related merged Workboard launch work and the current recovery implementation; current-line blame also attributes the reconciliation change to this area. (role: recent area contributor; confidence: high; commits: 549e6349f857, d3355eac098a; files: extensions/workboard/src/lifecycle-sync.ts, extensions/workboard/src/store-normalizers.ts, extensions/workboard/src/dispatcher.ts)

Rank-up moves

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

  • Remove the terminal-session timestamp fallback and add the absent-updatedAt shared-store restart regression.
  • Re-run the focused Workboard restart suite on the repaired exact head and retain its redacted output in the PR evidence.

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-19T03:57:51.635Z sha d4227ae4414354624dead2569c585330db2cf308 :: found issues before merge. :: [P1] Require terminal evidence newer than the prepared launch

@steipete
steipete force-pushed the steipete/elegant-ptolemy-6a97ea branch from d4227ae to 4ed1057 Compare August 19, 2026 04:08
Persist prepared, accepted, and failed launch phases so Gateway restart reconciliation cannot leave cards permanently running between launch preparation and worker acceptance.
@steipete
steipete force-pushed the steipete/elegant-ptolemy-6a97ea branch from 4ed1057 to d3355ea Compare August 19, 2026 04:13
@clawsweeper clawsweeper Bot added merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 19, 2026
Do not synthesize terminal-session acceptance timing during restart reconciliation; stale same-key terminal rows without updatedAt now fail the prepared launch instead of being adopted.
@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready evidence for #126170 at exact head 682b515837bb8a24a643ecc29620d0eeef471316.

ClawSweeper disposition: the P1 terminal-evidence finding was applied. Terminal sessions no longer synthesize acceptance time when updatedAt is absent; the new shared-store regression proves an unversioned same-key terminal row cannot be adopted as a retry. Both rank-up moves were completed. No re-review was requested because the current review is under 12 hours old and the follow-up push only addresses its finding.

Exact proof:

  • Blacksmith Testbox tbx_01m0bjvjbz4rmqssnx4yevjcwb, run 32196803631: node scripts/run-vitest.mjs extensions/workboard/src/dispatcher-ownership.test.ts extensions/workboard/src/lifecycle-sync.test.ts extensions/workboard/src/lifecycle-sync.restart.test.ts extensions/workboard/src/store.test.ts passed 4 files / 222 tests. Targeted oxfmt, oxlint, pnpm tsgo:core, pnpm tsgo:extensions, pnpm tsgo:extensions:test, and git diff --check passed on that verified bundle.
  • After integrating current main's Workboard compensation repair, the same four-file command passed 4 files / 230 tests.
  • After the ClawSweeper repair, node scripts/run-vitest.mjs extensions/workboard/src/lifecycle-sync.restart.test.ts --reporter=verbose passed 1 file / 6 tests, including does not accept a terminal session without durable timing evidence.
  • Final owner proof: the four-file command above passed 4 files / 231 tests.
  • node_modules/.bin/oxfmt --check extensions/workboard/src/lifecycle-sync.ts extensions/workboard/src/lifecycle-sync.restart.test.ts, node scripts/run-oxlint.mjs extensions/workboard/src/lifecycle-sync.ts extensions/workboard/src/lifecycle-sync.restart.test.ts, and git diff --check passed after the review fix.
  • Final Codex autoreview of the finding fix: clean, no accepted/actionable findings; correctness 0.99.
  • Exact-head required CI is green: run 32216845168.

CI history: the first two attempts (32213491604 and 32214072115) reused a stale merge ref and failed only on two unrelated docs/contract assertions already repaired on main. Rebasing onto current main produced a clean exact-head run before review, and the final finding-fix head is green above.

Production LOC: +495/-184 (net +311) | Tests: +511/-1 (net +510). The production growth is the durable typed launch-state owner, trusted normalizer, fenced store transitions, and restart reconciliation; it adds no parallel persistence path.

Known proof gap: restart behavior is proven through deterministic shared-backing-store preparation → process-loss → replacement-store ordering, not an authenticated live multi-process Gateway restart.

No SQLite DDL/schema-version change, no persisted-envelope version change, and no Gateway protocol change.

@steipete
steipete merged commit dcdfd73 into main Aug 19, 2026
159 checks passed
@steipete
steipete deleted the steipete/elegant-ptolemy-6a97ea branch August 19, 2026 05:01
@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
* fix(workboard): recover interrupted worker launches

Persist prepared, accepted, and failed launch phases so Gateway restart reconciliation cannot leave cards permanently running between launch preparation and worker acceptance.

* fix(workboard): require durable terminal evidence

Do not synthesize terminal-session acceptance timing during restart reconciliation; stale same-key terminal rows without updatedAt now fail the prepared launch instead of being adopted.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. plugin: workboard rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XL status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant