Skip to content

feat(config): offload async health and audit persistence - #147256

Merged
steipete merged 7 commits into
mainfrom
codex/config-health-composed-20260913
Sep 14, 2026
Merged

steipete merged 7 commits into
mainfrom
codex/config-health-composed-20260913

Conversation

@steipete

@steipete steipete commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Related: #144592

Async config observation, recovery health updates, and audit appends now run their SQLite work through the shared database worker. Health and audit writes acquire the common actor's retained native handle; final actor close releases it. Read-only Health operations remain noncreating. Audit fields, redaction, retention and existing synchronous APIs are unchanged. The audit-store edit extracts existing queries into a connection-bound kernel; table definitions and migrations are unchanged.

Bounded observation scopes stop superseded work before side effects. Health updates compare the persisted facts from their original read inside the write transaction and merge only changed fields, preserving sibling paths and newer synchronous observations. Prepared recovery replans through its existing owner. All three file-writing paths use the same post-commit metadata policy: ordinary metadata retirement cannot turn a committed file operation into failure, while ownership and maintenance refusals still propagate. Promotion preserves an existing 0750 parent and creates a 0600 last-good file; ordinary recovery retains its 0700 directory policy.

The review finding in .bak recovery is fixed at its actual post-commit call. The new snapshot regression failed on the previous production code after confirming the backup bytes were restored and canonical database closure completed. With the fix, it and the adjacent ordinary recovery case pass, including valid exact-byte reread, audit persistence, warning behavior and durable reopen. Fresh scoped P2 review, core/config-CLI types and typed lint passed. Earlier Health/Doctor/actor proof and fixture fixes remain covered; the final exact-head CI is green.

The unchanged published 2026.9.4 updater passed a fresh maintained Testbox qualification against exact candidate 9f0a1453cea81f4d413f18e5b4fd0de57a607b82 (run). Its 70,093,456-byte package has SHA-256 cb1519c246a5ae035013d52b7600ab5b9d44e51d5a4af465ccb4fd11870199eb. Every one of the 9,499 installed dist files matched that package in six Health phases. All 47 phases passed, including actual worker read/patch/Doctor-audit calls, durable reopen, sibling-row preservation, retained task/flow equality after update and both Gateway starts, and three original backup rows plus two active backup files. The lease was stopped and verified completed.

The local regression directly exercises the corrected .bak path. The unchanged live recipe explicitly exercises last-good recovery and final-artifact update/Health/Doctor continuity; it does not inject admission retirement. Gateway startup took 14 seconds. Readiness returned HTTP 200 with ready: true, while reporting an 8,376 ms event-loop delay and an 8,717 ms sampling interval. This is persistence and upgrade proof, not whole-Gateway nonblocking performance evidence.

@clawsweeper

clawsweeper Bot commented Sep 13, 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 commands Command implementations size: XL maintainer Maintainer-authored PR labels Sep 13, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. 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 Sep 13, 2026
@clawsweeper

clawsweeper Bot commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 13, 2026, 9:29 PM ET / September 14, 2026, 01:29 UTC (Revision 9).

ClawSweeper review

What this changes

Moves asynchronous config health tracking and audit persistence onto the shared SQLite worker, preserves recovery outcomes, and updates lifecycle regression coverage.

Warning

SQLite table change

This PR modifies persisted SQLite tables in src/infra/sqlite-audit-record-store.ts. Prefer a design that avoids changing persisted SQLite tables. If the change is necessary, verify migration and upgrade compatibility against an existing database before merge.

Merge readiness

⛔ Blocked before merge - 1 item remains

The PR remains useful and has no remaining actionable correctness findings. The supplied final-candidate updater qualification addresses the previous review’s outstanding follow-up; current main still lacks this conversion.

Priority: P2
Reviewed head: 9f0a1453cea81f4d413f18e5b4fd0de57a607b82

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A coherent persistence conversion with meaningful concurrency coverage and final-candidate upgrade evidence; the previous follow-up is addressed.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (linked_artifact): The captured final-candidate Testbox qualification records real installed-worker health/audit operations, Doctor last-good recovery, durable reopening, and published-updater state continuity. The backup-admission-retirement correction has supplemental regression coverage. Raw linked logs were blocked by the review host, so their detailed results are attributed to the supplied PR record.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (linked_artifact): The captured final-candidate Testbox qualification records real installed-worker health/audit operations, Doctor last-good recovery, durable reopening, and published-updater state continuity. The backup-admission-retirement correction has supplemental regression coverage. Raw linked logs were blocked by the review host, so their detailed results are attributed to the supplied PR record.
Evidence reviewed 9 items Prior recovery finding is addressed: The backup-restoration path now calls updateAfterFileCommit at line 504. That shared policy absorbs ordinary metadata failures while preserving ownership and maintenance refusals. The snapshot regression verifies restored bytes, successful rereading, persisted audit output, warning behavior, and durable reopening after canonical database closure.
Freshness and storage invariants: Health updates compare the exact originally read database fields inside the write transaction, preserve omitted fields and sibling paths, and refuse writes based on failed reads. Scope tests cover supersession, nested rollback, admission retirement, and continued access to the captured database.
Final-candidate upgrade qualification: The captured PR body records published updater 2026.9.4 qualifying candidate 9f0a145: 47 passing phases, 9,499 matching installed dist files in six Health phases, actual worker health/audit calls, sibling preservation, durable reopen, retained task/flow state, and preserved backups. It links https://github.com/openclaw/openclaw/actions/runs/34793476152 and identifies package SHA-256 cb1519c246a5ae035013d52b7600ab5b9d44e51d5a4af465ccb4fd11870199eb. GitHub reports the Testbox run cancelled, consistent with the body's reported lease shutdown, but does not independently establish its phase results. Raw job-log retrieval was blocked by the review host's storage-domain allowlist; the detailed results remain contributor-recorded evidence. The body explicitly distinguishes last-good live recovery from the supplemental backup-retirement regression and makes no whole-Gateway nonblocking claim.
Findings None None.
Security None None.

How this fits together

Config observation and Doctor recovery record health fingerprints and audit events used to diagnose and recover configuration files. The shared database worker now performs their asynchronous persistence while the existing config owner controls file recovery.

flowchart TD
  A[Config snapshots and Doctor] --> B[Observation and recovery owner]
  B --> C[Current observation check]
  C --> D[Shared SQLite worker]
  D --> E[Conditional health updates]
  D --> F[Bounded audit records]
  C --> G[Guarded config file recovery]
  G --> E
Loading

Before merge

  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Source +568, Tests +1465, Docs +24, Other -2. Total +2055 across 36 files.

View PR surface stats
Area Files Added Removed Net
Source 16 1250 682 +568
Tests 18 1545 80 +1465
Docs 1 24 0 +24
Config 0 0 0 0
Generated 0 0 0 0
Other 1 0 2 -2
Total 36 2819 764 +2055

Review metrics

Metric Value Why it matters
Production versus test growth Net production +568 lines; tests and fixtures +1,465 lines Production growth implements worker dispatch and freshness ownership, with most net growth devoted to regression and lifecycle coverage.

Stored data model

Persistent data-model change detected: database schema: src/infra/sqlite-audit-record-store.ts, serialized state: src/infra/sqlite-audit-record-store.ts, unknown-data-model-change: src/infra/sqlite-audit-record-store.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: partial_overlap
Canonical: #144592
Summary: This PR implements one bounded portion of the broader asynchronous-storage program.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Use the shared worker for complete health and audit operations while retaining guarded recovery, existing persisted formats, and synchronous caller contracts.

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

Not applicable to the internal conversion itself. The previous backup-retirement defect has a focused snapshot regression and a source-visible correction; this review did not execute tests.

Is this the best way to solve the issue?

Yes: the patch extends the existing shared worker and extracts connection-bound kernels while preserving the current schema, audit policy, and recovery owner.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 4846bf9e7d3e.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The captured final-candidate Testbox qualification records real installed-worker health/audit operations, Doctor last-good recovery, durable reopening, and published-updater state continuity. The backup-admission-retirement correction has supplemental regression coverage. Raw linked logs were blocked by the review host, so their detailed results are attributed to the supplied PR record.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove merge-risk: 🚨 compatibility: Current PR review selected no merge-risk labels.

Label justifications:

  • P2: This is a bounded persistence improvement within the coordinated asynchronous-storage effort, without evidence of an urgent user-facing regression.
  • 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 (linked_artifact): The captured final-candidate Testbox qualification records real installed-worker health/audit operations, Doctor last-good recovery, durable reopening, and published-updater state continuity. The backup-admission-retirement correction has supplemental regression coverage. Raw linked logs were blocked by the review host, so their detailed results are attributed to the supplied PR record.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured final-candidate Testbox qualification records real installed-worker health/audit operations, Doctor last-good recovery, durable reopening, and published-updater state continuity. The backup-admission-retirement correction has supplemental regression coverage. Raw linked logs were blocked by the review host, so their detailed results are attributed to the supplied PR record.

Evidence

What I checked:

  • Prior recovery finding is addressed: The backup-restoration path now calls updateAfterFileCommit at line 504. That shared policy absorbs ordinary metadata failures while preserving ownership and maintenance refusals. The snapshot regression verifies restored bytes, successful rereading, persisted audit output, warning behavior, and durable reopening after canonical database closure. (src/config/io.observe-recovery.ts:504, 9f0a1453cea8)
  • Freshness and storage invariants: Health updates compare the exact originally read database fields inside the write transaction, preserve omitted fields and sibling paths, and refuse writes based on failed reads. Scope tests cover supersession, nested rollback, admission retirement, and continued access to the captured database. (src/config/io.health-state.kernel.ts:106, 9f0a1453cea8)
  • Final-candidate upgrade qualification: The captured PR body records published updater 2026.9.4 qualifying candidate 9f0a145: 47 passing phases, 9,499 matching installed dist files in six Health phases, actual worker health/audit calls, sibling preservation, durable reopen, retained task/flow state, and preserved backups. It links https://github.com/openclaw/openclaw/actions/runs/34793476152 and identifies package SHA-256 cb1519c246a5ae035013d52b7600ab5b9d44e51d5a4af465ccb4fd11870199eb. GitHub reports the Testbox run cancelled, consistent with the body's reported lease shutdown, but does not independently establish its phase results. Raw job-log retrieval was blocked by the review host's storage-domain allowlist; the detailed results remain contributor-recorded evidence. The body explicitly distinguishes last-good live recovery from the supplemental backup-retirement regression and makes no whole-Gateway nonblocking claim. (9f0a1453cea8)
  • Current main still needs the conversion: Fetched main's async health reader still delegates ordinary reads to the synchronous reader, and appendConfigAuditRecord still invokes synchronous registration. No merged replacement was established. A release health-source lookup could not retrieve its missing Git object, so no release inclusion claim is made. (src/config/io.health-state.ts:137, 4846bf9e7d3e)
  • Existing coordinated work: Complete asynchronous runtime storage boundaries while retaining SQLite #144592 remains open and explicitly requests complete asynchronous storage-owner boundaries while retaining SQLite and existing persistence policy. This PR addresses its config-health and audit portion, not the entire program.
  • Feature-history routing: Current-main history identifies prior recovery work at d640aef and config revision work at cb25f00. GitHub commit metadata maps their authors to steipete and obviyus. Exact source-line blame could not complete because a required historical object download failed; these are routing candidates, not introduction attribution. (src/config/io.observe-recovery.ts, d640aef875e8)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • obviyus: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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 (8 earlier review cycles)
  • reviewed 2026-09-13T18:18:16.138Z sha 4998b48 :: blocked before merge. :: [P2] Preserve committed backup recovery through metadata retirement
  • reviewed 2026-09-13T19:20:52.468Z sha 4998b48 :: blocked before merge. :: [P2] Preserve committed backup recovery through metadata retirement
  • reviewed 2026-09-13T20:16:22.770Z sha f6267d3 :: blocked before merge. :: [P2] Preserve committed backup recovery through metadata retirement
  • reviewed 2026-09-13T21:30:44.435Z sha 9848454 :: blocked before merge. :: [P2] Preserve committed backup recovery through metadata retirement
  • reviewed 2026-09-13T22:56:26.969Z sha f002b7a :: blocked before merge. :: [P2] Preserve committed backup recovery through metadata retirement
  • reviewed 2026-09-13T23:26:50.138Z sha 3df4653 :: blocked before merge. :: [P2] Preserve committed backup recovery through metadata retirement
  • reviewed 2026-09-13T23:55:51.513Z sha 2097431 :: blocked before merge. :: [P2] Preserve committed backup recovery through metadata retirement
  • reviewed 2026-09-14T00:45:14.743Z sha 9f0a145 :: blocked before merge. :: none

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. and removed merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Sep 13, 2026
@steipete
steipete force-pushed the codex/config-health-composed-20260913 branch from 4998b48 to f6267d3 Compare September 13, 2026 20:04
@steipete
steipete marked this pull request as ready for review September 13, 2026 20:05
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. labels Sep 13, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Sep 13, 2026
@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Sep 14, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Sep 14, 2026
@steipete
steipete merged commit dbde270 into main Sep 14, 2026
208 of 209 checks passed
@steipete
steipete deleted the codex/config-health-composed-20260913 branch September 14, 2026 01:33
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 14, 2026
…7256)

* refactor(config): move health observations and audit writes to the shared worker

* test(config): drain async owners before auth fixture cleanup

* test(config): drain shared workers between write fixtures

* test(gateway): await config settlement in lifecycle probes

* test(gateway): settle startup config before channel reload

* test(gateway): preserve registered probe reply shape

* fix(config): preserve committed backup recovery after metadata retirement
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR 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. size: XL 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