Skip to content

fix(storage): defer WAL timers during owned offline maintenance - #167048

Open
roboclaw-bot wants to merge 21 commits into
mainfrom
openclaw/repair-10-wal-maintenance
Open

roboclaw-bot wants to merge 21 commits into
mainfrom
openclaw/repair-10-wal-maintenance

Conversation

@roboclaw-bot

@roboclaw-bot roboclaw-bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #166413, #170022

What Problem This Solves

Fixes repeated lock-refusal warnings when background SQLite maintenance runs during the same process's offline work.

User Impact

Maintenance waits for offline work or cancellation. Reader/busy warnings stay compact; real errors remain visible. Explicit checkpoint authority is unchanged. No WAL-related migration or schema, format, permission, retention or durability change. Installed-update acceptance is pending.

Why This Change Was Made

Timers defer to their verified local maintenance owner. Release resumes the existing cadence without polling; cancellation and ownership loss stay distinct. Detailed WAL health remains separate from compact logs.

Upstream owns creation locking, schema facts, Darwin inspection and the benchmark catalog; superseded local migration code is removed. Canonical 7df fixed Bifrost parity. Its HTTP fixture scopes/restores both NO_PROXY spellings; production proxy/auth policy is unchanged.

Evidence

  • Published canonical checkpoint: 1c208c54e10a39fc90cdb6d4b62e27ad8811607b, tree 2cd47891d48793fc465325c0e9c799c207267a08, parent 016dcab. Published 780fe85315e3429586297696aabd0c07286fdb17 is its same-tree marker child; request ecebd66a-2130-48b3-af60-be5f4e8343ae. Exact @steipete canonical 94e1 fixture, blob 8e849e2a1e666994631ada36603e7b274165fad5. Only this test changed; hooks passed, checkout clean, no main/scheduler/dependency change.
  • Fresh canonical proof: all 41 cases passed in original order on own source and actual CI merge 3847198a with canonical 8e849: 41 distinct cases / 82 passing executions. Command walls 82.035s/81.676s; file 80.37s/79.94–79.95s; target 5.444s/5.196s. Local Node 26.8.2 differs from CI 24.19.0; pinned Bun 1.4.4/20261019 policy matches. Hosted repair cost unmeasured.
  • Fresh gates/review: format, 4 root-test type graphs, typed lint (0 warnings/errors), whitespace and hooks passed. One complete independent P0–P3 review: 0 findings. Each child retains config/environment/worker/memory checks; child identity selects its actual job and owner policy. Native claims/output joined.
  • Conflict resolved: canonical convergence cleared the 016dcab/94e1 fixture collision without main integration. At 11:28 REST reports MERGEABLE/CLEAN; later GraphQL UNKNOWN is not a new conflict. Mergeability is separate from product acceptance.
  • Prior assertion proof is historical: actual base ac71093 reproduced 40 passed/1 failed at the worker-limit oracle (79.278s). Previous d0eaa passed 41/41 on merge 3847198 and own 778525 (82.040s/86.487s). Those results and 0c8c7db remain historical, not canonical 8e849 proof.
  • Unchanged production evidence: 8 admission/WAL cases passed (78 filtered; seven commands 181.034s). Bifrost retained 20 passing executions/10 distinct cases, 78 filtered and four original proxy-diverted loopback failures. Corrected HTTP walls: 51.678s Bun / 64.009s Node; failed Bun 57.297s; all five commands 297.725s. Prior 715abae retained 71 distinct cases/ 82 executions,174 filtered, six review cohorts and 11/14 static passes. Darwin inspection was on Linux, not physical Darwin. DELETE/WAL crash-reopen preserved the 16,384-row hash. These suites were not replayed for this test-only convergence.
  • Exact package/fresh install PASS: full canonical build/package on 780fe85: declarations, AI, UI, plugins, inventory/content/import checks. Tar SHA256 67c878f2069a6cfa3bbc688af51cc63c4761123572a84d59ba9abd87e69b984e; 120,037,759 bytes/20,409 entries. Build ID 2026.10.5-780fe85315e3-2026-10-21T11-11-51.054Z. Public install.sh/npm 12.2.0 installed these exact bytes in isolated home/prefix/cache; native binding, version/help and 17,926 content hashes passed. Installed 46,346 entries/543.5MiB, below 47,500/900MiB budgets. Package 535.957s (build 191.4s), install 16.547s. Six roots/42 native claims joined; source/index/dependencies and temporary package edits restored.
  • Current-head CI PASS: 39589670225/1 succeeded on 780fe85 at 11:27:38UTC. Full pagination: 131 jobs, 108 passed/23 skipped; 187 checks, 128 passed/58 skipped/1 neutral, 0 pending/failed. All 3 PostgreSQL conformance jobs passed. CI-gate, dependency and security-sensitive statuses succeeded. No current-head GitHub review; dispatcher success is not approval.
  • Historical hosted CI remains RED: run 39572324917, attempt 1, failed on 778525: 133 jobs, 108 passed, 23 skipped, one assertion leaf plus gate. Checkout was merge 3847198 / base ac71093, not event base 7df11be. Native classification remains NEW: main signatures differed and scope was not compared. Local base reproduction does not rewrite or waive it. No broad CI run was observed for conflicting 016dcab; security/metadata success is not full CI. Earlier run 39494839215 failed on 715abae from Bifrost parity, separately addressed by canonical 7df11be.
  • Pending: current-head review reconciliation and isolated published-driver update cell. Fresh installation is not upgrade, Gateway or physical Darwin acceptance; hosted PG conformance is not that product proof. No RFR. Separate shared-state-reader/Doctor drainage remains unresolved.
Retained failures and historical evidence

Local validation retains tests.result: fail and investigated failures. On frozen 7df, changed-test roots were agents-tools 721/720, gateway-root 724/720, infra 727/720 and plugins-platform 728/720; all 212 configurations/counters/membership matched upstream. The 29 fallback compiler passes did not qualify the boundary or consumer narrowing.
At cbfaa0d, 11/14 static commands passed. Failed root counts 721/723/727 exceeded 720 with 207 matching configurations. Incoming max-lines suppressions in ui/src/pages/chat/components/chat-message.test.tsx, ui/src/pages/config/config-page-state.ts and ui/src/pages/sessions/sessions-page-state.ts were missing from the baseline. The standalone environment guard reported 459/452; its nested check had short-circuited. Eight changed production files and remaining inputs were incoming-exact. Older 453/452 is another composition. No cap, baseline, suppression, severity override or waiver was used; old guards were not rerun or declared fixed.
The first local proof attempt added eight discovery failures because synthetic non-Git fixtures were beneath a Git checkout. Normal external temporary ownership removed them while preserving the target RED. The attempt remains recorded; assertions were not weakened.
Prior CI 38900010210 failed on aeb5a23 through e9b84bd1 / base 5ce763a: 92 passed, 14 underlying failures plus gate, 23 skipped. Integrity-proof/inventory repairs converged onto upstream owners; later secondary-ownership success still has no proven cause. Other failures are not blanket-fixed.
The older concurrent-claim failure and red/green evidence remain historical. Run 38796748726 passed on 42ef154, not this candidate. The last fully read ClawSweeper comment reviews 16cf632: no findings, historical conflict hold and installed-entry-point gap. No current-head formal review or merge/auto-merge request.

Requested and co-authored by @RomneyDa.

Work sessions


View the OpenClaw team session

Pause periodic admission on the local maintenance owner, retain cancellation joins, and summarize reader contention without hiding storage failures.

Co-authored-by: RomneyDa <[email protected]>
@clawsweeper

clawsweeper Bot commented Oct 8, 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 size: M labels Oct 8, 2026
@roboclaw-bot
roboclaw-bot marked this pull request as ready for review October 8, 2026 07:55
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 8, 2026
@clawsweeper

clawsweeper Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

This PR pauses shared-state WAL timers behind locally owned offline maintenance and condenses repeated checkpoint diagnostics.

Example: A 10-second shared-state checkpoint tick fires while the same process owns offline maintenance.

  • Before: The timer attempts maintenance and records an expected authority refusal as a checkpoint error.
  • After: The timer records offline-maintenance deferral, waits for release, and resumes its cadence unless canceled.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Useful, focused repair with meaningful native-owner regression coverage and no identified introduced defect; evidence remains below shipped-entry-point acceptance.
Proof confidence 🦐 gold shrimp (3/6) This collaborator-authored bot PR is outside the ordinary contributor proof gate; supplied evidence exercises native SQLite and scheduler owners, including cancellation and owner loss, but expressly claims no installed CLI/Gateway acceptance.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Offline maintenance can repeatedly produce misleading shared-state checkpoint warnings from its own background timer.
Reason: This collaborator-authored repair has approved direction and addresses a demonstrated admission defect without adding user configuration or weakening storage safeguards.

Merge readiness

⛔ Needs changes before merge - 1 item remains

Keep this PR: it addresses a concrete scheduling defect still present on main, and review found no introduced correctness bug.

Priority: P2
Reviewed head: 16cf632c8bb374ab548cb57b210199d0b7485202

Before merge

  • Complete next step - Resolve GitHub's reported merge conflict while preserving main's checkpoint changes and this PR's deferral contracts, then validate the affected resolution.

Findings

None.

Tests

  • Missing end-to-end proof: The supplied native-owner tests do not demonstrate timer deferral through an installed CLI or Gateway.
Agent review details

How this fits together

Shared-state database handles use the WAL scheduler to request checkpoints and reclamation; state ownership controls admission, and checkpoint observations feed logs, status, and Doctor.

flowchart TD
  A[WAL timer] --> B[Maintenance scheduler]
  B --> C[Local state owner]
  C --> D[Wait for release or cancellation]
  B --> E[Worker admission]
  E --> F[SQLite maintenance]
  F --> G[Checkpoint health]
  G --> H[Logs and status]
Loading

Technical review

Best possible solution:

Retain the existing WAL and state owners while deferring optional local timer work until maintenance releases custody.

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

Current-main source permits periodic work to encounter its own offline-maintenance refusal, and the supplied regression evidence reports error/warning results before the change; this read-only review ran no target code.

Is this the best way to solve the issue?

The change fixes admission at the existing scheduling owner, preserves explicit checkpoint authority, and correctly keeps cross-thread Doctor resource drainage outside its scope.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 48588a652222.

Provenance checked

  • Periodic WAL admission and retirement keeps the original intent (18401b6: Periodic maintenance must serialize through its writer and retain settlement custody; later retirement work joins accepted maintenance before native close.)
  • Expected maintenance refusal reporting changes intended behavior with a stated reason (8108a5e: Checkpoint diagnostics expose genuine errors and incomplete progress; the PR explains why verified local scheduling refusal should instead be deferred while preserving earlier real warnings.)
  • Physical state projection keeps the original intent (5b3fd54: Retain the same physical compatibility sidecar through relocation and accepted schema work; extraction preserves reference counting and read-proof invalidation.)
  • Explicit maintenance exclusion keeps the original intent (000af98: Caller-owned maintenance checks guard native storage effects; the new deferral is restricted to optional periodic admission.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

  • Reviewed introduced change: Reviewed the pinned base-to-head hunks, affected production owners, changed tests, and relevant callers; the projection extraction retains the existing reference-counted lock lifecycle. (16cf632c8bb3)
  • Verified local-owner deferral: Deferral requires a registered sqlite-maintenance owner with current physical ownership; release and ownership loss settle its notification. (src/infra/gateway-state-owner.ts:661, 16cf632c8bb3)
  • Cancellation and authority remain owned: The suspended scheduler waits on owner settlement or scheduler cancellation; explicit checkpoints retain runMaintenance authority checks, and worker admission rechecks the local fence before granting work. (src/infra/sqlite-wal.ts:412, 16cf632c8bb3)
  • Native regression coverage: The changed tests exercise actual SQLite handles and scheduler owners for resume, cancellation, owner loss, preservation of committed rows and prior errors, and refusal of explicit checkpoints outside maintenance authority; the PR reports corresponding red/green runs. (src/state/openclaw-state-db-open.test.ts:311, 16cf632c8bb3)
  • Current main still needs the change: The fetched main retains the original timer admission and state-owner behavior without local maintenance deferral. (src/infra/sqlite-wal.ts, 48588a652222)
  • Related Doctor repair is distinct: fix(doctor): avoid inherited state maintenance during repair #166413 drains inherited shared-state maintenance before Doctor repair; its runtime evidence does not establish this PR's timer-deferral behavior or supersede its local scheduling fix.

Likely related people:

  • Peter Steinberger: Raw commit 8108a5e adds src/infra/sqlite-wal-checkpoint.ts:58 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 8108a5eae7e6; files: src/infra/sqlite-wal-checkpoint.ts)

PR surface

Source +127, Tests +114, Docs +14, Other +1. Total +256 across 13 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 8 184 57 +127
Tests 3 163 49 +114
Docs 1 14 0 +14
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 0 +1
Total 13 362 106 +256

Labels

Label changes:

  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.
  • remove status: 👀 ready for maintainer look: Current PR status label is status: ⏳ waiting on author.

Label justifications:

  • P2: Expected local maintenance refusal produces repeated misleading storage errors; the demonstrated scope is background scheduling rather than data loss or a broken first-run flow.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only; repair and merge need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

History

Review history (3 earlier review cycles)
  • reviewed 2026-10-08T08:03:37.097Z sha 74948c8 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-08T08:16:53.953Z sha e049271 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-08T08:42:46.358Z sha e049271 :: needs maintainer review before merge. :: none

Reviewed October 10, 2026, 5:25 PM ET / 21:25 UTC (Revision 4).

Restore the wrapper runtime closure after the maintenance-owner extraction.

Co-authored-by: RomneyDa <[email protected]>
@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Oct 8, 2026
Resolve the checkpoint test import conflict while retaining main cadence and native schema-admission changes. Preserve both source-owned test contracts.

Co-authored-by: RomneyDa <[email protected]>
roboclaw-bot and others added 6 commits October 15, 2026 02:06
Preserve worker suspension, parked checkpoint ticks, engine-neutral admission, and current ownership checks while retaining local typed deferral and compact contention diagnostics. Keep retired WAL probes and projection timestamps removed.

Co-authored-by: RomneyDa <[email protected]>
Merge pinned main 2f22858 to include the scheduled-message auth correction and current storage/runtime inputs. Preserve the reviewed WAL deferral and bounded diagnostics delta.

Co-authored-by: RomneyDa <[email protected]>
Record the observed 452 production environment names without changing the source inventory or relaxing the growth guard.

Co-authored-by: RomneyDa <[email protected]>
Replace the dense deferral description with three plain sentences and distinguish detailed WAL health from compact warning logs. Preserve surrounding documentation and runtime behavior.

Co-authored-by: RomneyDa <[email protected]>
Recheck unowned database state under the native writer lock, preserve foreign-key policy around settlement, and publish creation facts only after commit.

Co-authored-by: RomneyDa <[email protected]>
Preserve offline deferral and compact diagnostics alongside current scheduler, native identity, cleanup custody, and admission snapshot owners.

Co-authored-by: RomneyDa <[email protected]>
roboclaw-bot and others added 5 commits October 16, 2026 12:14
Preserve cold-claim transaction and WAL deferral behavior while adopting the pinned schema-refresh and PostgreSQL owner split. Keep the complete runtime wrapper inventory.

Co-authored-by: RomneyDa <[email protected]>
Worked on by:
- @RomneyDa

Co-authored-by: RomneyDa <[email protected]>
OpenClaw-Publication: d6b7ee66-87c6-4a26-a6b1-64bca28d97f2
Refresh schema facts under the cold-claim writer lock without revoking physical integrity proof. Keep ownership, version, foreign-key and commit-authority checks intact.

Register the extracted native storage migration with its existing Kysely owner group and extend the existing close/reopen regression to retain integrity evidence.

Co-authored-by: RomneyDa <[email protected]>
Merge pinned tested base 5ce763a without rewriting WAL-maintenance history.

Align the Darwin/Bun census, pristine SQLite catalog, and package fixture closure with the incoming contracts. Preserve real census exports in the synthetic mock, the cold-claim integrity repair, and the recorded inherited gate failures.

Co-authored-by: RomneyDa <[email protected]>
Merge the frozen upstream composition while retaining optional WAL deferral,
physical ownership checks, cancellation, and real storage-error reporting.
Keep current schema admission and the shared process-inspection owners.

Co-authored-by: RomneyDa <[email protected]>
Worked on by:
- @RomneyDa

Co-authored-by: RomneyDa <[email protected]>
OpenClaw-Publication: bb69ec95-c654-42d7-9e2d-5e6f4882f08f
roboclaw-bot and others added 2 commits October 21, 2026 08:29
Merge canonical upstream 7df11be to resolve the inherited Bifrost auth
parity failure while preserving WAL maintenance ownership changes.
Keep loopback HTTP fixtures independent of ambient proxy configuration.

Focused composition checks and fixture format/types/lint pass. Retain
investigated inherited test-root budget failures; package and product
proof remain pending.

Co-authored-by: RomneyDa <[email protected]>
Worked on by:
- @RomneyDa

Co-authored-by: RomneyDa <[email protected]>
OpenClaw-Publication: 3249356c-68c5-4cd9-88c6-438e04dbdb5f
roboclaw-bot and others added 4 commits October 21, 2026 10:28
Compare command children with canonical selected-owner metadata before
changed-row coalescing. Preserve exact coverage and execution policies,
including child environment, fallback-worker and memory limits.

The original actual CI base reproduces the assertion failure; the repaired
tested merge and current worktree each pass the full 41-case file.

Co-authored-by: RomneyDa <[email protected]>
Worked on by:
- @RomneyDa

Co-authored-by: RomneyDa <[email protected]>
OpenClaw-Publication: 3cc2b5c0-03cf-4004-b0f2-186937fbda46
Adopt the exact fixture from @steipete canonical commit
94e1fbf instead of retaining the
independent local equivalent. Preserve every selected child and its
config, worker and memory limits while comparing selected-owner policy.

The canonical file passes all 41 cases on this worktree and the actual
CI composition. No scheduler policy or dependency change is included.

Co-authored-by: RomneyDa <[email protected]>
Worked on by:
- @RomneyDa

Co-authored-by: RomneyDa <[email protected]>
OpenClaw-Publication: ecebd66a-2130-48b3-af60-be5f4e8343ae

This branch has not been deployed

No deployments
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 extensions: bifrost P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: L 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