Skip to content

refactor(workboard): centralize dispatch owner selection - #130333

Merged
steipete merged 1 commit into
mainfrom
codex/loc-sweep-workboard-runtime-20260826
Aug 26, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/loc-sweep-workboard-runtime-20260826

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Related: #115119

What Problem This Solves

Workboard used separate owner-selection logic when choosing ready tasks and when counting occupied worker slots. Its private store also retained an unused KV constructor after runtime registration moved to SQLite.

Why This Change Was Made

Use one private owner selector for dispatch and occupied-slot checks. Ready tasks ignore expired claims; occupied tasks retain their claim owner through the existing heartbeat-reclaim grace period. Delete the unused private KV factory and its unused attachment-entry cap. Doctor's legacy KV migration and the canonical SQLite runtime remain unchanged.

Production LOC: +14/-55 (net -41). Tests: +70/-33 (net +37). The assertion baseline shrinks from 5 to 1 only because four assertions were deleted with the dead constructor. No schema, migration, config, or public API change.

User Impact

No intended SQLite behavior change. Worker selection and occupied-slot accounting now share one policy while preserving claim expiry and reclaim behavior. The blank-assignment regression covers the in-memory store boundary; SQLite already normalizes empty assignment values, so this is not presented as a new reachable SQLite bug.

Evidence

  • Candidate 099bd5a64aee6f0e41a358a9085cdb392f78f2aa.
  • 288 owner, dispatch, race, real SQLite, lifecycle, restart, cleanup, and doctor-migration tests passed using an install matching the candidate's dependency manifests.
  • Complete changed-file gate and typed lint passed without skipped guards or checks.
  • Independent reviewer inspected the final source and public exports and reran all 30 ownership tests. Fresh structured Codex P1 review passed.
  • Model/subagent acceptance is fixture controlled; this is actual SQLite/lifecycle proof, not authenticated provider or live Gateway proof.
  • Maintainer-requested, AI-assisted refactor. CI on the published candidate remains required before landing.

Use one slot-owner policy for ready candidates and occupied workers while preserving heartbeat-reclaim grace. Remove the unused private KV store factory; doctor remains the legacy migration owner.
@clawsweeper

clawsweeper Bot commented Aug 26, 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 26, 2026 19:56
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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 26, 2026
@clawsweeper

clawsweeper Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 26, 2026, 4:02 PM ET / 20:02 UTC.

ClawSweeper review

What this changes

This PR centralizes Workboard dispatch and occupied-slot owner selection, removes an unused private KV-store factory, and updates ownership regression coverage.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open. Current main still has separate ready-card and occupied-slot owner selection, so this refactor is not obsolete; source review found no actionable patch defect. This is a protected maintainer PR and exact-head CI was still running.

Priority: P3
Reviewed head: 099bd5a64aee6f0e41a358a9085cdb392f78f2aa

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A net-negative, focused refactor with a credible owner-boundary regression test and no source-level blocking defect found.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored internal refactor is exempt from the external contributor proof gate; its PR body nevertheless records focused SQLite, lifecycle, and ownership test evidence.
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 internal refactor is exempt from the external contributor proof gate; its PR body nevertheless records focused SQLite, lifecycle, and ownership test evidence.
Evidence reviewed 6 items Current-main comparison: Current main still derives occupied-slot owners without a dispatch-time expiry argument, while its dispatcher retains a separate ready-card resolver; the PR’s central refactor is therefore not already implemented.
Canonical policy at the owner boundary: The PR routes ready candidates through the shared helper with dispatch time while occupied slots retain claim ownership through reclaim grace when no time is passed.
SQLite capacity sibling: SQLite claim admission uses the same slot-owner helper after the shared occupied-slot predicate, preserving the heartbeat-reclaim owner boundary rather than introducing a second policy.
Findings None None.
Security None None.

Live Verification

Command: pnpm test extensions/workboard/src/dispatcher-ownership.test.ts

Result: FAIL (partial) — step 2 expect_output Workboard dispatcher ownership: expected terminal output was not visible within 30 seconds: "Workboard dispatcher ownership"

$ node --import tsx scripts/test-projects.mts extensions/workboard/src/dispatcher-ownership.test.ts
[test] starting test/vitest/vitest.extensions.config.ts

 RUN  v4.1.11 /tmp/clawsweeper-live-proof-130333-1L38B3/target

 ✓  extensions  extensions/workboard/src/dispatcher-ownership.test.ts (30 tests) 116ms

 Test Files  1 passed (1)
      Tests  30 passed (30)
   Start at  20:03:30
   Duration  25.83s (transform 21.24s, setup 1.01s, import 24.32s, tests 116ms, environment 0ms)

[test] passed 1 Vitest shard in 32.51s
$ node --import tsx scripts/test-projects.mts extensions/workboard/src/dispatcher-ownership.test.ts
[test] starting test/vitest/vitest.extensions.config.ts

 RUN  v4.1.11 /tmp/clawsweeper-live-proof-130333-1L38B3/target

 ✓  extensions  extensions/workboard/src/dispatcher-ownership.test.ts (30 tests) 98ms

 Test Files  1 passed (1)
      Tests  30 passed (30)
   Start at  20:04:03
   Duration  10.94s (transform 6.65s, setup 463ms, import 10.14s, tests 98ms, environment 0ms)

[test] passed 1 Vitest shard in 17.56s

Assertions:

  • FAIL expect_output: Workboard dispatcher ownership

How this fits together

Workboard persists task cards in SQLite and dispatches ready cards to subagent workers. Owner selection feeds both the capacity check for existing work and the claim used before a new worker starts.

flowchart LR
  Cards[Persisted Workboard cards] --> Claims[Claims and expiry]
  Claims --> Owner[Owner selection]
  Cards --> Owner
  Owner --> Capacity[Occupied-slot check]
  Owner --> Dispatch[Ready-card dispatch]
  Capacity --> Dispatch
  Dispatch --> Runs[Subagent runs]
Loading

Before merge

  • Resolve merge risk (P1) - Exact-head CI was still in progress in the review context; do not land until required checks complete successfully.
  • Complete next step (P2) - No repair lane is warranted: this active protected maintainer PR has no discrete source-level defect; complete normal exact-head CI and maintainer review.
Agent review details

Security

None.

PR surface

Source -41, Tests +37, Other 0. Total -4 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 3 14 55 -41
Tests 1 70 33 +37
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 1 0
Total 5 85 89 -4

Review metrics

Metric Value Why it matters
Production versus test LOC production +14/-55 (net -41); tests +70/-33 (net +37); test support +1/-1 Production is net-negative through removal of the unused keyed-store factory; the added test coverage exercises the preserved owner-capacity boundary.
Persistence surface 0 schema, migration, or config changes The PR keeps the canonical SQLite runtime and existing doctor migration path unchanged while removing only unused in-process construction.

Stored data model

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

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Land one canonical owner-selection helper after exact-head CI confirms the refactor, keeping dispatch-time expiry distinct from occupied-slot reclaim grace and retaining SQLite as the sole runtime store.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Land one canonical owner-selection helper after exact-head CI confirms the refactor, keeping dispatch-time expiry distinct from occupied-slot reclaim grace and retaining SQLite as the sole runtime store.

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

Not applicable as a standalone report: this is a behavior-preserving refactor, although the added in-memory boundary test credibly demonstrates the blank-assignment capacity regression it guards.

Is this the best way to solve the issue?

Yes. Moving ready-card selection into the existing slot-owner policy removes duplicate ownership logic while preserving the intentionally different expiry treatment for dispatch and reclaim grace.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 8585e7e04eef.

Labels

Label changes:

  • add P3: This is a small maintainer-requested internal Workboard refactor with no intended user-facing feature or configuration change.
  • 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: This maintainer-authored internal refactor is exempt from the external contributor proof gate; its PR body nevertheless records focused SQLite, lifecycle, and ownership test evidence.

Label justifications:

  • P3: This is a small maintainer-requested internal Workboard refactor with no intended user-facing feature or configuration change.
  • 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 internal refactor is exempt from the external contributor proof gate; its PR body nevertheless records focused SQLite, lifecycle, and ownership test evidence.

Evidence

What I checked:

Likely related people:

  • steipete: Authored the current refactor and multiple merged dispatch, launch-recovery, and concurrency repairs in the central owner-selection path. (role: recent Workboard feature owner; confidence: high; commits: 099bd5a64aee, 549e6349f857, a9303f27e982; files: extensions/workboard/src/dispatcher.ts, extensions/workboard/src/store-constants.ts, extensions/workboard/src/store.ts)
  • Jason (Json): Recent merged lifecycle synchronization work is adjacent to the claim-grace and worker-state invariant this refactor preserves. (role: adjacent lifecycle contributor; confidence: medium; commits: 57c27b114b55; files: extensions/workboard/src/dispatcher.ts, extensions/workboard/src/store-workflow.ts)

Rank-up moves

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

  • Let exact-head CI complete successfully before landing.

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.

@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready verification for 099bd5a64aee6f0e41a358a9085cdb392f78f2aa: one private owner selector now serves ready dispatch and occupied-slot accounting, with their intentionally different claim-expiry/reclaim-grace inputs preserved. The unused private KV factory is removed; SQLite runtime registration and doctor's legacy migration remain unchanged. Production -41 lines, tests +37; assertion ratchet shrinks only for four deleted casts.

OPENCLAW_VITEST_MAX_WORKERS=2 node scripts/run-vitest.mjs extensions/workboard/src/dispatcher-ownership.test.ts extensions/workboard/src/dispatcher.test.ts extensions/workboard/src/dispatcher.races.test.ts extensions/workboard/src/dispatcher-compensation.test.ts extensions/workboard/src/store.test.ts extensions/workboard/src/sqlite-store-policy.test.ts extensions/workboard/src/lifecycle-sync.test.ts extensions/workboard/src/lifecycle-sync.restart.test.ts extensions/workboard/src/lifecycle-sync.cleanup-recovery.test.ts extensions/workboard/doctor-contract-api.test.ts
node scripts/check-changed.mjs -- config/assertion-safety-baseline.txt extensions/workboard/src/dispatcher-ownership.test.ts extensions/workboard/src/dispatcher.ts extensions/workboard/src/store-constants.ts extensions/workboard/src/store.ts

All 288 tests and the complete changed gate passed with matching dependencies, including real SQLite, lifecycle, restart, race, cleanup and migration behavior. A separate reviewer reran30 owner cases and inspected the exact committed boundary; fresh structured Codex P1 review is clean. Model/subagent acceptance is fixture controlled, not authenticated provider proof. The in-memory blank-assignment regression fails before and passes after, but SQLite already normalizes empty assignment values: this is not a new SQLite operator-bug claim.

Exact-head CI is green: https://github.com/openclaw/openclaw/actions/runs/33007779554 . Current-main owner files remain unchanged relative to the reviewed base. There is no completed ClawSweeper review/rank-up list at this checkpoint; a queued publisher is not being treated as approval or as a blocker. Independent review and the native exact-head gates remain the landing authority under the maintainer's explicit autonomous direction.

@steipete
steipete merged commit 1fd3c07 into main Aug 26, 2026
203 checks passed
@steipete
steipete deleted the codex/loc-sweep-workboard-runtime-20260826 branch August 26, 2026 20:34
@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 27, 2026
…0333)

Use one slot-owner policy for ready candidates and occupied workers while preserving heartbeat-reclaim grace. Remove the unused private KV store factory; doctor remains the legacy migration owner.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. plugin: workboard rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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