Repository navigation
fix(workboard): finalize running execution on terminal status transitions - #123239
wangyan2026 wants to merge 1 commit into
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs real behavior proof before merge. What this changesThe PR finalizes running executions on terminal card transitions, clears lifecycle claims, and changes owner-slot accounting. Example: Worker agent worker-1 releases a running card with status done, then receives another ready card.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 7 items remain This PR addresses a current, shipped Workboard starvation bug, but its capacity changes admit overlapping same-owner work in two reachable cases. Priority: P1 Before merge
Findings
Provenance
Tests
Agent review detailsHow this fits togetherThe Workboard plugin persists cards, claims, executions, and attempts; dispatcher selection and transactional SQLite admission consult the same owner-capacity predicate before starting workers. flowchart TD
A[Operator or worker action] --> B[Workboard store mutations]
C[Gateway lifecycle observation] --> B
B --> D[Persisted cards and claims]
D --> E[Shared owner capacity predicate]
E --> F[Dispatcher and SQLite admission]
F --> G[Worker run]
Technical reviewBest possible solution: Finalize terminal state and release completed lifecycle claims at their existing store owners while preserving live execution occupancy and fresh review claims. Do we have a high-confidence way to reproduce the issue? Source establishes both the shipped starvation path and the introduced overlap: move a running worker to todo, let its claim expire within reclaim grace, then dispatch another ready card for that owner; no target code was executed during this read-only review. Is this the best way to solve the issue? The store-owner repair is appropriate, but the shared predicate is too broad: a dispatcher-only guard would miss SQLite admission, while deleting execution occupancy and all review-claim occupancy discards valid concurrency protection. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 81a4ac385dd6. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceAcceptance criteria:
What I checked:
Likely related people:
PR surfaceSource +36, Tests +697. Total +733 across 6 files. Added test files: 1. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (16 earlier review cycles; latest 8 shown)
Reviewed October 17, 2026, 8:35 PM ET / October 18, 2026, 00:35 UTC (Revision 17). |
5a1e152 to
5616f0b
Compare
5616f0b to
d4df27f
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
0e64830 to
aba27c7
Compare
…nsitions Finalize a still-running execution when a card transitions from running to a terminal status (done/review/blocked) without an explicit execution patch (releaseClaim/update/move/reassign), mirroring complete/block/ reclaim. Non-terminal statuses (todo/backlog/triage/scheduled/ready) preserve execution occupancy so a worker moved aside can still complete successfully. Map done->done, review->review (successful attempt, failureCount resets), and blocked as explicit failure or abandonment. Remove the dispatcher's unguarded card.execution?.status === 'running' capacity arm so legacy stale rows no longer hold the owner's slot. Release card.metadata.claim in syncLifecycle when the card transitions to a terminal-for-dispatch status (review/blocked), so the owner's slot is freed for follow-up dispatch immediately rather than after claim TTL expiry. Exclude review/blocked claims from workboardCardConsumesOwnerSlot as defense-in-depth for legacy rows. Closes openclaw#122911.
e4ab202 to
120cbb0
Compare
|
@clawsweeper re-review Isolated-Gateway after-fix trace added to PR body. The trace uses Key evidence:
The previous CLI build failure was resolved by |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Thanks for the PR. We're closing older pull requests that have gone stale against current This Workboard execution-finalization PR still needs behavior proof and has had no commits since August 27. If stale running executions still block dispatch on current main, please open a fresh PR rebased on main. |
What Problem This Solves
Workboard dispatch slots could be permanently starved by stale execution state and uncleared dispatch claims, blocking follow-up work for the same owner agent.
Two related bugs caused this:
Stale running execution on terminal transitions: When a card left
runningstatus viareleaseClaim, genericupdateCard,move, orreassign(paths that don't pass an explicit execution patch), the execution record stayedrunning. The dispatcher's capacity predicate then counted the card as occupying the owner's slot indefinitely.Dispatch claim not released on lifecycle success:
syncLifecyclemapped the card toreviewand execution toreviewon lifecycle success, but did not clearcard.metadata.claim.workboardCardConsumesOwnerSlotstill counted the active (non-expired) claim against the owner's capacity, so the next ready card for that owner was blocked until the claim's TTL expired (30 minutes by default).Closes #122911.
Why This Change Was Made
Fix 1: Finalize running execution on terminal status transitions only
updateCard(store-core.ts) is the shared owner for execution lifecycle. It already had logic to sync session keys, but lacked the symmetric finalization for execution status. The fix adds a finalization step: when a card transitions fromrunningto a terminal status (done/review/blocked) without an explicit execution patch, the execution status is closed to match the card's terminal state.done/revieware successful outcomes (attempt succeeds,failureCountresets);blockedis an explicit failure or abandonment path.Non-terminal statuses (
todo,backlog,triage,scheduled,ready) preserve execution occupancy so a worker moved aside can still complete successfully. The original broad condition (status !== "running") incorrectly finalized executions for non-terminal moves, causingcompleteDirectto retainblockedon later successful completions (ClawSweeper P1 re-review).The dispatcher's unguarded
card.execution?.status === "running"capacity arm was removed — with execution now finalized at the owner, legacy stale rows no longer need a downstream guard.Fix 2: Release terminal review claims before capacity counting (ClawSweeper P1)
syncLifecycle(store.ts) is the lifecycle owner that transitions the card to terminal-for-dispatch status (review/blocked). The claim must be released at this boundary so the owner's slot is freed immediately, not after claim TTL expiry. Without this,normalizeMetadata's fallback preserved the stale claim, andworkboardCardConsumesOwnerSlotcounted it against capacity.The fix clears
card.metadata.claiminsyncLifecyclewhen the card transitions to any non-running, non-done status.workboardCardConsumesOwnerSlot(store-constants.ts) additionally excludesreview/blockedclaims as defense-in-depth, covering legacy rows wheresyncLifecycledid not clear the claim before this fix shipped.Production LOC delta
store-core.ts: +19/-1 (execution finalization at the shared owner, terminal-only)store.ts: +15/-0 (claim release at the lifecycle owner)store-constants.ts: +7/-4 (defense-in-depth capacity exclusion)dispatcher.test.ts: +12/-4 (updated review-slot test)dispatcher-ownership.test.ts: +5/-2 (use non-terminal status for claim-expiry test)Production: +41/-5 net +36 across 3 lifecycle owners. Tests: +703/-6 net +697.
Each change lives at its architectural owner —
updateCardowns execution lifecycle,syncLifecycleowns claim lifecycle,workboardCardConsumesOwnerSlotowns capacity semantics. The terminal-only narrowing absorbs the ClawSweeper P1 finding without expanding the production surface: the broadstatus !== "running"condition andfinalizedExecutionStatusternary were replaced by a direct terminal-status check, keeping net production LOC proportional to the three owners repaired.User Impact
Workboard dispatch recovers immediately when a worker finishes or fails — no 30-minute starvation window. Follow-up cards for the same owner agent dispatch as soon as the lifecycle transition completes. Legacy cards with stale claims (from before this fix) also no longer hold slots. Moving a running card aside to a non-terminal status (e.g.,
todo) no longer corrupts the execution record — the worker can still complete successfully and the attempt is recorded assucceeded. This is a default-path fix: every operator using workboard dispatch was affected.No config, API, default, protocol, or schema change; existing operator behavior is unchanged except that stale executions are now finalized and stale slots are released.
Evidence
Linux, Node 22 (
node scripts/run-vitest.mjswrapper).Rebased onto current main. The dispatcher's unguarded
card.execution?.status === "running"capacity arm is removed at its canonical helper location instore-constants.ts, so bothdispatcher.tsandsqlite-store.tscall sites are repaired in one change.Focused proof (two files, 46 tests)
Full workboard suite — no regression
Pre-fix failure proof (12 of the new tests fail on main)
Failures (grouped by invariant):
releaseClaim(status=done)→ execution staysrunning(expecteddone)releaseClaim(status=review)→ execution staysrunning(expectedreview)generic update(status=done)→ execution staysrunning(expecteddone)move(status=done)→ execution staysrunning(expecteddone)done+ running execution → ready card NOT started (persisted, SQLite boundary)review+ running execution → ready card NOT started (persisted)review+ active claim → ready card NOT started (claim not excluded)syncLifecyclesuccess → claim NOT released, follow-up dispatch blockedblocked(expectedrunning)Matrix-style evidence — terminal transition paths
releaseClaim(status=done)runningdone+ ready card startsreleaseClaim(status=review)runningreview+ ready card startsgeneric update(status=done)runningdonemove(status=done)runningdonesyncLifecyclesuccess → reviewmove(running→todo)thencompleteblocked, attemptfailedrunning→done, attemptsucceededLegacy stale-row recovery (persisted fixture, dispatcher read-only)
done+ executionrunning(SQLite)review+ executionrunning(persisted)review+ active claim (legacy)Regression proof — sibling paths unchanged
completedone(unchanged)blockblocked(unchanged)reclaimsyncLifecycle(association)executionAssociationPatch(unchanged)syncLifecycle(non-association)todo/backlog/ready)runningpreserved (unchanged)Production-boundary dispatch trace (SQLite-backed WorkboardStore, not in-memory)
This trace exercises the real
createWorkboardSqliteStorespersistence layer,WorkboardStore(production store),dispatchAndStartWorkboardCards(production dispatcher),syncLifecycle(production lifecycle),store.move/store.complete(production mutations), andstores.cards.register/store.get(real SQLite read/write). Onlysubagent.runis mocked (cannot start a real agent in a proof script).TDD red-green verification
store-core.ts+store.ts+store-constants.ts) toorigin/main, ran regression tests → 12 failures (execution not finalized, claim not released, follow-up dispatch blocked, non-terminal move corrupts execution)Isolated-Gateway after-fix trace (real gateway + real agent run)
This trace uses
startQaLiveLaneGateway(fromextensions/qa-lab/runtime-api.js) to start a real isolated Gateway with a mock-openai provider. The agent run is a real worker — the Gateway runs the full agent loop (provider transport, model fetch, agent command, stop reason), not a mockedsubagent.run. The mock-openai provider returns canned responses, but the Gateway's dispatch, lifecycle, and agent execution are all production code paths.Gateway logs confirm the real agent run:
The trace proves:
The
pnpm installwas needed to update@earendil-works/pi-tuifrom stale 0.82.1 to the expected 0.84.2 (which exportsTuiMainScreen), resolving the pre-existingmainbuild failure mentioned in the previous review cycle.ClawSweeper review status (2026-08-27T09:09 UTC, head 120cbb0)
Static checks
PR surface against current main
Production: +41/-5 net +36 (
store-core.ts+19/-1 terminal-only finalizer,store.ts+15/-0 claim release on lifecycle,store-constants.ts+7/-4 defense-in-depth capacity exclusion).dispatcher.tsis unchanged (the arm removal is in the shared helper).Tests: +703/-6 net +697 (
dispatcher-ownership-stale-execution.test.ts+686 new focused regression file,dispatcher-ownership.test.ts+5/-2,dispatcher.test.ts+12/-4).No config, protocol, schema-version, or public API change.