Skip to content

refactor(agents): persist progress cards through the agent writer - #164458

Merged
steipete merged 4 commits into
mainfrom
dbasync/progcard
Oct 3, 2026
Merged

steipete merged 4 commits into
mainfrom
dbasync/progcard

Conversation

@steipete

@steipete steipete commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Durable progress-card updates and clears returned Promises but still executed their SQLite transaction on the Gateway thread. This moves the five surveyed put/clear SQL sites off that thread for durable sessions.

Why This Change Was Made

Bind a typed progress-card adapter to the existing canonical agent writer. Capture the physical store and input before waiting, reserve exact-store FIFO before discovery, and reread the authoritative revision inside one synchronous worker transaction. Keep live host authorization at transaction and commit, preserve the original authorization error on refusal, and broadcast only acknowledged results. Unknown outcomes never replay or fall back to host SQLite.

All durable put/clear callers use the existing Promise facade. The obsolete cross-store resolver export is removed; its remaining implementation stays private to the board store. Incognito and atomic reset retain the shared synchronous row kernel under their existing ownership; durable reads already use the history worker. The existing Gateway request-entry fence and connection-work drain settle accepted persistence before worker teardown; no additional worker service or persistence queue is introduced.

User Impact

Internal execution change only. Replace-on-write, monotonic revisions, tombstones, conditional clearing, authorization, schema, retention, durability, and update behavior remain unchanged. No new OPENCLAW_* names or Plugin SDK surface changes.

Mandatory merge gates completed: the full changed-file checker and released Plugin SDK API comparison both passed on 9cb6855b72e75ab34f02e98be2b431750d5ae4fe through Testbox. The requested PR/base comparisons are also complete; native landing uses the explicitly authorized inherited-CI admission below.

Production LOC: +266 / −35 / net +231 (301 changed lines; tests, docs, and tooling excluded). Inventory T1 1,233 → 1,233: the counted expressions remain reachable through incognito/reset, while the durable boundary now observes zero caller-thread SQL.

Existing other-owner authorization reads remain outside this storage migration: the native session-sharing fallback at src/gateway/session-sharing.ts:531 calls src/gateway/session-sharing-policy.ts:101. No new SQL was added to grant callbacks, and the boundary assertion covers the moved operations.

Evidence

  • The original facade fails the new caller-thread SQL boundary regression on card queries/transactions. The candidate passes tool → real RPC handler → real store writes and conditional clears for default and configured stores with zero caller-thread SQL.
  • Final boundary-only command: pnpm test src/gateway/progress-card-store.worker.test.ts --maxWorkers=1: 6 passed, 142.72 s wall, 18.06 s test time; most wall time was compiled fixture preparation on the shared host.
  • Worker tests also cover FIFO/input capture, target changes, transaction/commit refusal with exact authorization error identity, native decoding errors, and a simulated lost committed reply without replay.
  • Real server lifecycle close regression proves accepted put settlement, rejection of late RPCs, and durable readback after database teardown. The parent scheduler and connection-work signals are aborted during this proof.
  • pnpm test src/gateway/progress-card-store.worker.test.ts src/gateway/server-close.progress-card.test.ts --maxWorkers=1: 7 passed, 153.07 s wall on the shared host; per-file test time 11.40 s / 27.13 s. These tests require the real worker transport and real shutdown ordering.
  • Existing row-kernel, authorization, and handler coverage: 50 passed; authorization/handler test time 52.54 s / 0.04 s, kernel test time 1.45 s (2.94 s test phase).
  • Shared-registry/import proof: runtime-process build graph, eager wrapper closure, get-reply imports, state-worker imports, and worker runtime imports: 33 passed, 146.57 s wall. The compiled-wrapper dependency inventory remains closed without a new entry.
  • Madge: 0 cycles, 65.21 s wall. Database worker ratchet passed against merge base 4ab382220e2cca1deedb2c2549982f91c0fb5c64. git diff --check passed.
  • Codex autoreview against that pinned base, including the final private-helper cleanup: scoped-clean through P2.
  • Final node scripts/check-changed.mjs --base 4ab382220e2cca1deedb2c2549982f91c0fb5c64 attempt: all completed ratchets, core/test/script typechecks, and all three dead-export scans passed (zero unused exports). Core typed lint produced no diagnostic or result for more than ten minutes on the shared host. Its exact task-owned process was interrupted and joined; the checker ended with exit 130 after 2451.39 s wall, with 666.60 s spent at core lint. Later lint/guards did not run. The earlier readonly-assignment and unused-export findings were fixed and revalidated before this attempt. No full-gate retry loop was started after this tooling stall. The supported targeted core lint command for all seven changed source/test files passed in 47.16 s wall after correcting two fixture-only lint findings (redundant spread and an unbound method). Targeted tooling lint also could not start: plugin-sdk boundary dts timed out after 300000ms in artifact preparation (327.94 s wall). This local tooling limitation is superseded by the final-head Testbox pass below.
  • Released-source check: v2026.9.8 has no synchronous progress-card put/clear SDK export to retain. The frozen-commit API comparison against that release installed both revisions, then failed during API rendering with Managed command exited while its process group remained active (277.38 s wall); no report was produced. The released API comparison subsequently completed successfully on the final head; see below. No blind retry was made.

The supported Gateway qaRuntime build passed (205.02 s wall), including runtime postbuild and CLI import checks. A broader full declaration build was stopped after 659.89 s in package declaration generation; the Gateway profile is the same build used by the requested worktree setup. The final source also removes a redundant assignment to the storage helper’s already-pinned read-only environment, as required by typechecking.

CI seconds are not available before the initial push.

Related implementation precedents: #164240, #164112, #164291, #164288. Current overlap discovery found no competing store migration. #164296 is adjacent tool-authority work; tool scope is unchanged. #162433 is the previously identified umbrella design draft, not an active owner of this cutover. Discovery was bounded; its stale archive was followed by current GitHub reads.

Landing validation

The initial CI run exposed an out-of-order entry in the canonical Gateway worker-test inventory. Commit 9cb6855 restores sorted order; node scripts/run-vitest.mjs test/vitest-cli-ownership.test.ts test/scripts/ci-node-test-plan.test.ts --maxWorkers=1 passed all 547 tests in 371.78 seconds wall. P2 autoreview of the correction is scoped-clean. Production behavior is unchanged by the correction.

Released SDK reachability was checked against v2026.9.8: the Gateway put facade already returns a Promise, the synchronous row-kernel signature is retained, and the removed resolveGatewaySessionDatabase export is internal with no released src/plugin-sdk, api.runtime, or documented SDK route. The unchanged projectProgressCardChannelUpdate SDK export is independent of persistence. No compatibility shim is required. The complete released API report and full changed-file check both passed on the final head in Testbox; see the results below.

The initial doctor-health.nocow.test.ts failure is independently present on main at f79dac8 (main job). The same test and stack fail when Doctor closes agent handles outside its maintenance scope and lease release is refused. The test, Doctor maintenance owner, and agent lease/lifecycle sources are unchanged by this PR. The only touched registry dependency adds the unused progress-card entry; this failing path does not execute progress-card persistence. Final-head CI contains this inherited Doctor failure plus the independently reproduced main lease-worker count failure described below.

Final-head required gates and CI attribution

On 9cb6855b72e75ab34f02e98be2b431750d5ae4fe, Testbox run 37149741739 completed both required commands with exit 0 and a settled native wrapper receipt:

  • Released Plugin SDK comparison against v2026.9.8 (fc23bc864e4553c2d215e479eeec47b67a0bf943): 233 seconds. The report includes accumulated release-to-main differences, but no changed or removed released signature attributable to this PR. Native report digest: d16bf32e4f1a5b42c98fa77d3f3efd56cc00d981b1009030043ce817303ebce4.
  • Full node scripts/check-changed.mjs --base 4ab382220e2cca1deedb2c2549982f91c0fb5c64: 1,678 seconds, including all 27 core test-type partitions, production/script types, dead-export scans, all core/script lint, and policy guards. Existing max-lines warnings in untouched files were non-fatal; no errors.

Final-head CI run 37146455814 has 57 successful jobs, 21 skipped jobs, two failed test jobs, and their downstream aggregate. Both inventory checks pass. All six durable-worker cases pass (4.164 seconds of reported case time), and the real CLOSE-PRELUDE shutdown regression passes in 11.230 seconds in job 111271486647.

The second failure is the unchanged openclaw-state-lease-acquisition.test.ts retained-generation case: its global worker census starts at one and ends at zero. Scheduled main job 111283445990, main cd9913f1b1105f9c4e7b96fde8c1431a77e5878d, independently reproduces the exact assertion at line 122. The test and primary lease/tracking/heartbeat inputs are unchanged. The intervening cleanup only replaces the equivalent 10-second timeout helper; both failures occur during normal completion in less than a second. This establishes inherited failure attribution without claiming the identity of the exiting worker was directly instrumented.

Both remaining CI failures are independently present on main and eligible for the operator-authorized native admin exception. CI remains failed; these results are not described as green. Five local full-file lease runs passed on the PR head (18/18 tests each), which does not establish a fix. The requested Linux PR/base comparison is complete on isolated Hetzner Linux, with exact clean checkouts and separate frozen dependency installs. Every invocation used node scripts/run-vitest.mjs <file> --maxWorkers=1.

File PR head 9cb6855b72e75 Merge base 4ab382220e2c
src/state/openclaw-state-lease-acquisition.test.ts 5/5 passed, 18 cases per run; 180 seconds total wall 5/5 passed, 18 cases per run; 179 seconds total wall
src/flows/doctor-health.nocow.test.ts 5/5 failed with the named offline-maintenance cleanup error; 133 seconds total wall 5/5 failed with the identical named error; 131 seconds total wall

All ten Doctor logs match the expected case and offline-maintenance error. The isolated lease passes are not a fix claim: the independent scheduled-main CI reproduction establishes that the remaining lease census failure is inherited. No CI job was rerun.

@clawsweeper

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

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime scripts Repository scripts size: L labels Oct 3, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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 3, 2026
@clawsweeper

clawsweeper Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 3, 2026, 5:35 PM ET / 21:35 UTC (Revision 5).

ClawSweeper review

What this changes

The PR moves durable session progress-card updates and clears into the existing agent database writer while preserving revisions, authorization, and saved-card behavior.

Merge readiness

✅ Ready for maintainer review

This remains useful work: current main still performs durable progress-card writes on the Gateway thread. No actionable patch defect remains, and the latest evidence addresses the previous review’s comparison request.

Priority: P2
Reviewed head: 9cb6855b72e75ab34f02e98be2b431750d5ae4fe

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The focused implementation has strong production-boundary evidence and no remaining actionable finding; failed CI retains its separate native admission requirements.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): Inspected production-path regressions and captured final-head results exercise real RPC/storage owners and worker transport in isolated state, demonstrating durable replacements and clears, zero caller-thread SQL, rollback on transaction/commit revocation, no replay after a lost reply, and settlement before real Gateway teardown. No stored-data contract changes require migration.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): Inspected production-path regressions and captured final-head results exercise real RPC/storage owners and worker transport in isolated state, demonstrating durable replacements and clears, zero caller-thread SQL, rollback on transaction/commit revocation, no replay after a lost reply, and settlement before real Gateway teardown. No stored-data contract changes require migration.
Evidence reviewed 9 items Pinned introduction and remaining need: Reviewed the introduced merge-base-to-head patch. At fetched main 11515ce, the Promise facade still invokes the native progress-card write transaction; this worker cutover is not already implemented there.
Canonical writer and current authority: The adapter captures input and target identity, reserves existing writer admission, and supplies live caller, target-owner, and execution assertions to worker dispatch. The existing worker publication owner invokes source authority during admission; the transaction helper requests both transaction and commit grants.
Production-boundary proof: The fully supplied PR body reports six passing worker cases through the real tool, RPC handler, storage owner, and worker transport for default and configured stores. Inspected cases assert zero caller-thread SQL, FIFO revisions, captured inputs, target-change refusal, transaction/commit revocation with durable rollback, and no replay after a committed reply is lost.
Findings None None.
Security None None.

How this fits together

Progress cards store an agent’s plan and status for a conversation. Gateway requests persist replacements or clears, then notify clients to refresh the saved card.

flowchart TD
  A[Agent tool or client request] --> B[Gateway authorization]
  B --> C[Capture session and physical store]
  C --> D[Existing agent writer queue]
  D --> E[Worker transaction and live authority checks]
  E --> F[Saved progress card]
  F --> G[Acknowledged result and client notification]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +231, Tests +340, Docs +10, Other +1. Total +582 across 10 files.

View PR surface stats
Area Files Added Removed Net
Source 5 266 35 +231
Tests 3 340 0 +340
Docs 1 10 0 +10
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 0 +1
Total 10 617 35 +582

Review metrics

Metric Value Why it matters
Production and test growth production +266/-35; tests +338/-0 Production growth handles physical-store custody, worker admission, and error transport; new tests protect distinct persistence and shutdown boundaries.

Technical review

Best possible solution:

Keep one progress-card row kernel and route durable mutations through the canonical agent writer, preserving live authorization and acknowledged publication.

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

Yes, from source: current main’s Promise facade still executes the durable row transaction on the caller thread. The captured evidence reports a failing original boundary regression; this read-only review did not execute it.

Is this the best way to solve the issue?

Yes. The patch reuses the existing writer, authority, discovery, and shutdown owners while preserving the shared row kernel and existing caller contract.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 11515ce5b3da.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a bounded internal storage improvement that removes durable progress-card SQL from the Gateway thread.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): Inspected production-path regressions and captured final-head results exercise real RPC/storage owners and worker transport in isolated state, demonstrating durable replacements and clears, zero caller-thread SQL, rollback on transaction/commit revocation, no replay after a lost reply, and settlement before real Gateway teardown. No stored-data contract changes require migration.
  • proof: sufficient: Contributor real behavior proof is sufficient. Inspected production-path regressions and captured final-head results exercise real RPC/storage owners and worker transport in isolated state, demonstrating durable replacements and clears, zero caller-thread SQL, rollback on transaction/commit revocation, no replay after a lost reply, and settlement before real Gateway teardown. No stored-data contract changes require migration.

Evidence

What I checked:

  • Pinned introduction and remaining need: Reviewed the introduced merge-base-to-head patch. At fetched main 11515ce, the Promise facade still invokes the native progress-card write transaction; this worker cutover is not already implemented there. (src/gateway/progress-card-store.ts:71, 11515ce5b3da)
  • Canonical writer and current authority: The adapter captures input and target identity, reserves existing writer admission, and supplies live caller, target-owner, and execution assertions to worker dispatch. The existing worker publication owner invokes source authority during admission; the transaction helper requests both transaction and commit grants. (src/gateway/progress-card-store.ts:165, 9cb6855b72e7)
  • Production-boundary proof: The fully supplied PR body reports six passing worker cases through the real tool, RPC handler, storage owner, and worker transport for default and configured stores. Inspected cases assert zero caller-thread SQL, FIFO revisions, captured inputs, target-change refusal, transaction/commit revocation with durable rollback, and no replay after a committed reply is lost. (src/gateway/progress-card-store.worker.test.ts:23, 9cb6855b72e7)
  • Shutdown settlement: The inspected real-server regression queues an accepted progress-card RPC, enters public Gateway close, observes scheduler cancellation, rejects a late RPC, and verifies accepted persistence by reopening SQLite after teardown. The captured body reports this case passing on the final head. (src/gateway/server-close.progress-card.test.ts:19, 9cb6855b72e7)
  • Stored representation and SDK boundary: The row-kernel diff extracts preparation while retaining replacement SQL, revision increments, conditional clears, tombstones, and the synchronous kernel signature. No schema or stored-format change is introduced. The captured body records a completed comparison against v2026.9.8 with no released signature change attributable to this PR; the removed resolver remains private to the board owner. (src/session-cards/progress-card-store.ts:137, 9cb6855b72e7)
  • Re-review continuity and completed comparisons: The previous review had no remaining code findings and requested Linux PR/base comparisons. The captured body now reports five whole-file runs per revision for each named suite: lease acquisition passed on both revisions, and Doctor failed identically on both. It also records final-head changed-file and released-SDK checks completing successfully through Testbox. The Testbox allocation workflow itself is cancelled, which is not the delegated command receipt or a passing workflow claim. (9cb6855b72e7)

Likely related people:

  • Peter Steinberger: Raw commit e6ec522 adds src/session-cards/progress-card-store.ts:66 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: e6ec522a023d; files: src/session-cards/progress-card-store.ts)

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 (4 earlier review cycles)
  • reviewed 2026-10-03T18:43:38.660Z sha 2b6f04a :: needs changes before merge. :: none
  • reviewed 2026-10-03T18:50:22.541Z sha 2b6f04a :: needs changes before merge. :: [P2] [P2] Keep the worker-test registration in sorted order
  • reviewed 2026-10-03T19:09:43.125Z sha 9cb6855 :: needs changes before merge. :: none
  • reviewed 2026-10-03T20:55:58.016Z sha 9cb6855 :: needs changes before merge. :: none

@clawsweeper clawsweeper Bot added 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. and removed 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 3, 2026
Keep the progress-card worker test in the canonical sorted Gateway inventory so CLI ownership and CI planning retain identical test ordering. Focused proof: 547 tests passed; P2 autoreview found no actionable findings.
@steipete

steipete commented Oct 3, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The Gateway test inventory ordering failure is corrected in 9cb6855. Both affected suites passed (547 tests, 371.78 seconds wall), and P2 autoreview is clean. The full changed-file gate and released SDK API comparison are being completed before landing.

@clawsweeper

clawsweeper Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added 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. and removed 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 Oct 3, 2026
@steipete
steipete merged commit e0682b1 into main Oct 3, 2026
168 of 172 checks passed
@steipete
steipete deleted the dbasync/progcard branch October 3, 2026 21:45
@steipete

steipete commented Oct 3, 2026

Copy link
Copy Markdown
Contributor Author

Merged via explicitly authorized admin squash with attributed pre-existing CI failures.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 4, 2026
…enclaw#164458)

* refactor(agents): persist progress cards through the agent writer

* refactor(gateway): keep the board database resolver private

* test(gateway): simplify progress card fixtures

* fix(test): preserve sorted progress card worker inventory

Keep the progress-card worker test in the canonical sorted Gateway inventory so CLI ownership and CI planning retain identical test ordering. Focused proof: 547 tests passed; P2 autoreview found no actionable findings.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation gateway Gateway runtime P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: L 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