Skip to content

perf(gateway): avoid chat stalls during WAL maintenance - #158570

Merged
steipete merged 21 commits into
mainfrom
perf/l33-wal-worker-maintenance
Sep 26, 2026
Merged

steipete merged 21 commits into
mainfrom
perf/l33-wal-worker-maintenance

Conversation

@steipete

@steipete steipete commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Periodic WAL maintenance can stall every Control UI connection while one Gateway checkpoints an agent or shared-state database.

User Impact

Periodic checkpoints, bounded page reclamation, and file-size diagnostics now run through the existing SQLite workers. Linux sidecar containment retains its original synchronous timer-entry scan before identity admission or native cleanup. The 30-minute cadence, 512-page pass budget, FIFO release between units, physical identity checks, durability settings, and synchronous offline/close contracts remain unchanged. No configuration, protocol, schema, retention, or update migration changes.

Why This Change Was Made

Async admission previously invoked native maintenance on the Gateway thread. The existing timer now dispatches each unit through the canonical agent/shared-state writer and adopts its ordered checkpoint snapshot into the original host health owner. Shared-state maintenance retains its 350 ms coordinator wait, bounded polling, and blocking-owner diagnostics across worker transport. Admitted work retains native settlement custody; canceled queued agent work does not prevent a replacement connection from opening.

Existing worker-local timers retain their current paths; this adds no scheduler. The old shared-state adapter's manual coordinator ownership is removed. Agent WAL registration stays with database publication so the shared writer queue remains independent of database startup.

Evidence

The WAL workload appends 600 × 4 KiB values per pass through the actual registered timer and database owners. Source runs used Node 26.9.0 on the saturated macOS/arm64 campaign host, in before/after/before/after order for each database. Each version has 12 warm samples plus two separately reported cold samples.

Database WAL bytes Median main-thread delay, before → after Median completion, before → after Host checkpoint calls across warm samples
Agent 3,502,032 426.05 → 1.69 ms 424.51 → 238.22 ms 12 → 0
Shared state 4,309,552 574.23 → 1.77 ms 574.04 → 497.95 ms 12 → 0

Completion includes worker execution and reply delivery. Cold source-worker startup took 5.81–6.03 s for agent storage and 1.83–7.10 s for shared state; cold maximum host scheduling gaps were 67.49–180.35 ms and 7.40–22.47 ms respectively. Shared-host timing is noisy; the invariant result is zero host checkpoint calls. These are component measurements, not an end-to-end capacity guarantee.

Focused tests ran with node scripts/run-vitest.mjs <file> --maxWorkers=1 on the same Blacksmith Testbox (Node 24.19.0, Linux). Wall times include runner/compiler preparation:

Test file Result Wall time
sqlite-wal.agent-admission.test.ts 6 passed 12.62 s
sqlite-wal-checkpoint.test.ts 14 passed 6.69 s
openclaw-state-db.coordinator.test.ts 18 passed 12.10 s
openclaw-state-worker-error.test.ts 73 passed 9.28 s
sqlite-wal.test.ts 57 passed 24.50 s

The existing reclamation, broker, and lifecycle-cleanup siblings added 21 passing tests. Their grouped run took 36.35 s including the WAL suite before its four synchronous mock-abort expectations were updated; the final standalone WAL run above passed all 57. The real Linux main/worker containment cases passed in both runs. These existing process-based cases protect fatal containment and native cleanup behavior.

The new agent owner regression failed on the original production code with seven host incremental_vacuum calls (21.20 s wall); candidate production was restored and every changed file hash was rechecked afterward. Shared-state replacement remains byte-for-byte unchanged when either the pathname or physical-file fence refuses admission.

node scripts/check-changed.mjs --base 31a5754546a0854ca85abf44bf57134e182d5b20 -- <changed files> ran for 1,485.75 s. All 25 core-test typecheck graphs, core typechecking, formatting, docs, boundary, ratchet, and dead-export gates passed. The final lint stage reported a missing unknown catch annotation and an implicit async cancellation return; both are corrected in the final head. The targeted lint/core-typecheck rerun could not connect because the single Testbox had expired. That rerun remains unverified; hosted CI is authoritative. The final edits do not change runtime behavior.

Provider: blacksmith-testbox; lease: tbx_01m3dk4s6je5vamt9kz89q5f27; lease workflow. After native sync timed out and wrapper preparation stalled on the saturated host, validation used a separate checkout on this same lease, pinned to the original base with the tracked candidate patch and SHA-256 verification of every changed file. The lease expired after the long gate, and crabbox stop completed without error. Local dependency installation took 20m28s; local focused attempts were interrupted during repeated compiled-subprocess preparation. No full build or swarm run was needed for this execution-placement change. Hosted PR CI timing is not yet available.

The production growth carries explicit worker requests/results, ordered health adoption, agent operation drainage, and the existing WAL coordinator budget/diagnostics through the common broker. Removing the manual state coordinator adapter and its superseded cleanup fixture offsets part of that cost; a neutral count would require dropping those contracts or unrelated cleanup.

Independent Codex autoreview: scoped clean through P2; no accepted/actionable findings. Diff-scoped deslop and git diff --check passed.

Overlap review: #158465 adds separate agent execution commands; #158486 and #158120 add unrelated shared-state commands; #158202 fixes another worker lifecycle branch. #158450, #158559, and #157972 overlap the worker-access documentation. Their relevant diffs do not implement this WAL cutover and were reconciled as disjoint changes.

Landing repair: exact-head CI run 36212594007 exposed a runtime import cycle from the shared-state cache through its WAL adapter and worker context back to the cache. Commit 6374cdadc744ea66602451f2eb50657f0ad932d3 moves context construction behind the existing lifecycle admission callback, preserving synchronous capture and the same state owner. The existing import-cycle guard now reports zero cycles; targeted lint and independent Codex review through P2 passed. The coordinator and schema-policy suites passed all 41 tests (66.24 s Vitest duration; 191.00 s including worker compilation). An initial local attempt stopped before assertions because concurrent SDK declaration generation changed compiler inputs; the sequential retry passed after generation completed. No CI rerun was requested.

The next exact-head run 36213846476 confirmed both cycle guards passed, then exposed same-name wrapper shadowing and a deterministic MCP reconstruction fixture failure. Commit 8b7135217c8a716b88912041b866d1dd735c5507 distinguishes admission-injected helper names and removes the unnecessary session-key mock; no assertions changed. The original Gateway selector reproduced all 11 MCP failures (634 other tests passed), and the repaired focused file passed all 11 tests in 18.39 s wall / 12.78 s Vitest duration. Full pnpm check:architecture, formatting, git diff --check, and fresh independent Codex review through P2 passed. CI cancelled sibling jobs after the originating failure; no blind reruns were requested.

Run 36215210429 exposed a missing materialized-wrapper manifest entry for the extracted context module. The provisioning test reported failed private-store injection; inspecting its child stderr proved ERR_MODULE_NOT_FOUND was the underlying cause. Commit 4aba91745739dff87302d3940e404a159529eeb7 adds the single missing entry. Provisioning, wrapper lease bootstrap, and extracted dependency closure then passed (3 selected tests across 2 files, 92.08 s wall); independent Codex review passed. The matching main CI shard was green, so this was repaired as a task-related packaging defect. No CI rerun was requested.

Run 36216322050 was blocked by a new main regression from #158464: the retained-assets UI fixture still imported ControlUiRootState from its former owner. The exact UI E2E type graph reproduced TS2459 on a fresh main checkout. Main repair da8149b8ba7d88d76dbe7979986e307a4542e6f0 corrects only that erased type import; the same graph, formatting, and independent review passed. One main push raced a concurrent commit and was refreshed before successful publication. Main was merged, not rebased, into this PR as f1d411af16508db2e9052055fd2033684d34cffa, without conflicts. The integrated candidate passed 179 tests across seven focused WAL/coordinator/error/broker/cleanup files (8 existing skips; 380.49 s including compiler preparation), and a fresh review of the complete integrated PR delta was clean through P2.

Run 36218224869 reached two old reclamation fixtures that still required parent-thread vacuum calls. Both failures reproduced locally. Commit d0ee3a1cdc6fc30c07bd25bf76d52b16be41dee3 observes real worker transaction/commit admission after reclamation authorization and native settlement, requires zero host vacuum calls, and retains rejected-reclamation, freelist-budget, original-owner, and reclamation-worker shutdown checks. All 7 reclamation and 6 agent WAL admission tests passed (137.90 s wall), targeted lint and fresh independent review passed. No production change was needed. GitHub archive log downloads failed at the transport layer; the direct job-log endpoint supplied the diagnostic.

Run 36219795900 exposed a device-identity fixture whose full coordinator mock hid the real error class. A bounded census reproduced the same problem in three lease fixtures and missing worker metadata in the broker-cleanup control. Commit 00205dbf88bea0156efcedcdf1435167420babae removes four unnecessary pure-helper mocks and preserves real worker metadata while keeping worker/channel construction forbidden. All existing assertions and native-access fences remain intact. All 42 tests across these five fixtures passed in 20.92 s; targeted lint, formatting, and independent review passed.

Run 36220925835 found two publication-order fixtures still expecting host-thread vacuum after settlement. Commit 283e9f52c28b459e3a3d1074b2b6e25c0dcf3a4d changes that one expectation to zero host vacuum while preserving the real periodic tick, FIFO/publication barrier, freelist reduction and 512-page bound, and committed-row checks. Both old failures reproduced; all 20 worker-store tests passed in 50.76 s, with formatting and independent review clean. A source census found no other runtime-agent periodic assertion requiring host SQL.

Run 36222049404 was blocked by a later main change introducing a chained type assertion in progress-snapshot number coercion. Upstream fixed it in 66b812f26e725cd709e08860d2cb46ba496cd308 while a matching repair was being validated. The executable correction passed the full boundary-lint command, all 45 progress-state tests, 12 native conversion probes, and independent review. No duplicate main commit was published. Conflict-free merge a890852452a0a2f783d9c29dbf110dcd2c2f7597 incorporates that fix; full boundary lint passed again on the merged tree. The only overlapping code change relocates a type import, so prior WAL behavior proof remains valid.

ClawSweeper's Linux containment finding is addressed by 6aacde4140bb: the existing sidecar scan again runs at timer entry, before a replaced published database can fail identity admission. This deliberately retains the existing Linux /proc scan once per maintenance interval; checkpoint/vacuum and file-size work remain off the Gateway thread. It preserves synchronous close custody without adding another worker or an asynchronous preflight gap.

Real Linux proof used blacksmith-testbox lease tbx_01m3e75wcejgp57b8pc57f8kfb, workflow 36224536736. The new registered agent/shared timer cases replace the main inode and sidecars, require one fatal diagnostic and SIGKILL before a survival acknowledgment or stale cleanup, and verify replacement WAL data/integrity on reopen. Both cases failed on the original production source in 16.60 s for the intended reason. Restoring the fixed source produced 83 passing WAL/agent/shared tests in 30.03 s, with all four selected source hashes reverified. New agent/shared containment cases took 421 ms / 362 ms. The standalone local WAL command passed 49 tests with 10 platform skips in 10.21 s; Linux proof covers those platform cases directly. Lint, the infrastructure type graph, formatting, and final independent review passed. The lease was stopped successfully; a portal telemetry-sync timeout did not affect command success or proof.

The last prior-head CI run 36223360422 exposed another incomplete worker metadata mock. A bounded census reproduced the same defect in four related fixtures and a same-file OS mock. Commit d37274a45382f67318a653ff2038f85b7b9b3e1a preserves real metadata while retaining every original fake worker, forbidden constructor, and two-worker limit. All 41 existing fixture tests passed in 17.89 s; no assertions or native-access fences changed.

Run 36225001097 caught TS2345 in the subprocess fixture: Node timer optional generic arguments could not be spread into the captured generic callback in the production type graph. Commit 5f79c67ef601bc767acf236d3bef3a18ad076b96 forwards the same callback, receiver, and arguments through Reflect.apply, without casts or changed assertions. The exact core production graph reproduced the error and then passed; targeted lint, formatting, and independent review passed. ClawSweeper confirmed the Linux containment finding is addressed and identified no remaining patch defect; its remaining blocker was this now-repaired typecheck.

While run 36225683891 was active, main #158627 introduced prepared state readers and conflicted with this branch’s cycle-free context extraction. Merge 9bceadfaadfa39fc7e38416af889b1c9c53dcef4 preserves main’s prepared-reader API, live identity getter, schema admission and captured-scope checks in the extracted implementation. No rebase was used. Production types, targeted lint, zero-cycle guard, and 64 lifecycle/schema/coordinator/agent-admission tests passed (69.52 s including runner preparation), with independent integrated review clean. The superseded run also reported a nested report-owner fixture cancelled by SIGTERM during cold preparation; the source-backed cause and owning repair are documented below. Fresh exact-head CI is required for this conflict resolution.

The report-owner failure repeated in 36226673738. Its owning cause was the new WAL registration’s eager database-lifecycle imports in the lightweight writer-queue module, which common runtime cleanup always loads. Commit d88015a476d84f796206a1958a93d999c51fe3eb moves the unchanged registration body to the agent database WAL owner and restores the queue module to main’s lightweight implementation. The exact 83-case shard reproduced 82 passes / 1 deadline failure before the change (342.21 s local wall), then passed 83/83 afterward (85.20 s; real-home case 4.42 s). The focused after-case’s complete child stderr contains no compiled-worker preparation, versus a 24.075 s worker build in the failing hosted case. No deadline, concurrency, assertion, or retry changed. The 26 WAL publication/admission tests, extracted-wrapper dependency closure, production types, lint, zero-cycle guard, and independent review also passed. Exact-head CI remains required on the new head.

Run 36229740142 exposed eager ordinary-read admission during legitimate private source binding under file exclusion. Both short binding cases reproduced before the fix (18.58 s wall); the async timeout had the same premature-open cause. Publication now returns its generation-bound admission facts to the WAL owner without opening the read seal. Actual maintenance still checks the seal, generation, native owner, physical identity, and captured scope before dispatch and commit. The opening environment is passed through publication rather than recaptured from ambient process state.

All 63 focused binding, asynchronous lifecycle, alias/read-admission, coordinator, and unpublished-open tests passed (250.99 s grouped wall, including runner preparation). Existing main-thread binding cases now invoke their real registered timer and await its refused result while exclusion remains held, require zero host SQL from that tick, and preserve durable-row and private-handle closure checks. The two changed cases took 2.654 s and 2.072 s; no test count, sleeps, deadlines, retries, or production test seams were added. A first assertion was placed in the unit worker suite, where native worker maintenance is intentional; that fixture mistake was corrected by moving the assertion to the existing main-thread binding owner. Production types and independent review through P2 passed. A test variable shadowing the maintenance lease was caught by lint and renamed before publication. Exact-head hosted CI remains the landing gate.

The final standalone binding run passed all 4 cases in 87.15 s wall (21.70 s Vitest duration; changed cases 1.529 s / 1.239 s), and final targeted lint passed. Published repair: e22ce5f85d7e.

After that repair, the watcher detected a conflict with main #158655. Merge 7accc4c4ee75 preserves main's lightweight read-worker context API and environment capture in this PR's existing admission-injected context module, avoiding a renewed cache/WAL/context import cycle. All 101 reader, signal/error mapping, binding, coordinator, and schema-policy tests passed in 166.76 s wall. Production types, targeted lint, import-cycle guard, formatting, and a fresh independent review of the complete integrated delta passed. No rebase was used.

Run 36233045084 found one missed test caller of the publication result: the pending-close fixture still accessed .key rather than the returned identity. Commit 114688c6b4ab destructures that identity without changing the assertion. The exact state-logging type graph passed, both pending-close tests passed in 6.33 s wall (2.17 s Vitest), and independent review was clean. The remaining lifecycle publication callers were checked. No unchanged CI rerun was requested.

Final landing validation

Exact-head CI 36233506753 passed for 114688c6b4ab888c6938247c73ddf1f362d184b7; watch-pr-ci exited 0 with GREEN and GitHub SUCCESS. This supersedes the earlier pending or unavailable gate notes above. Native exact-head review artifacts validated with zero findings, and GitHub-gated preparation completed without changing the reviewed head. All CI retries in this history followed a diagnosed repair or required main merge; no unchanged run was retried merely to get green.

@clawsweeper

clawsweeper Bot commented Sep 26, 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: L labels Sep 26, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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 26, 2026
@clawsweeper

clawsweeper Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 26, 2026, 5:48 AM ET / 09:48 UTC (Revision 13).

ClawSweeper review

What this changes

Moves periodic agent and shared-state SQLite checkpoints and page reclamation into existing writer workers, with lifecycle tests and worker-access documentation.

Merge readiness

✅ Ready for maintainer review

Current main still performs periodic WAL maintenance on the Gateway thread. The PR remains useful, and this review found no concrete defect in the current head.

Priority: P1
Reviewed head: 114688c6b4ab888c6938247c73ddf1f362d184b7

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Strong registered-path measurements and lifecycle proof support a coherent worker cutover with no identified correctness or security defect.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The changed periodic WAL owners were exercised through registered timers, real SQLite databases, and writer workers in before/after component runs; the reported after-fix result is zero host checkpoint calls and sharply lower main-thread delay. Linux process cases also exercise containment through the registered path, and replacement tests cover refusal before database mutation. The current diff changes no stored-data contract, so migration compatibility is not applicable.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The changed periodic WAL owners were exercised through registered timers, real SQLite databases, and writer workers in before/after component runs; the reported after-fix result is zero host checkpoint calls and sharply lower main-thread delay. Linux process cases also exercise containment through the registered path, and replacement tests cover refusal before database mutation. The current diff changes no stored-data contract, so migration compatibility is not applicable.
Evidence reviewed 11 items Current main still needs the change: The fetched main scheduler still invokes periodic maintenance through an admission callback that executes the native operation on its caller thread.
Introduced worker dispatch: The pinned PR delta dispatches each periodic unit through a registered worker executor and adopts its checkpoint snapshot after the timer remains current.
Containment remains at timer entry: The Linux sidecar scan runs synchronously before worker admission; a detected split-brain condition terminates before maintenance dispatch.
Findings None None.
Security None None.

How this fits together

The Gateway maintains SQLite databases used for agent and shared state. Periodic timer results feed database health reporting while the Gateway serves chats and other requests.

flowchart LR
  A[Database timer] --> B[Linux sidecar check]
  B --> C[Owner and identity admission]
  C --> D[SQLite writer worker]
  D --> E[Checkpoint and page reclamation]
  E --> F[Database health status]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +318, Tests +162, Docs +11, Other +1. Total +492 across 51 files.

View PR surface stats
Area Files Added Removed Net
Source 26 528 210 +318
Tests 23 407 245 +162
Docs 1 11 0 +11
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 0 +1
Total 51 947 455 +492

Review metrics

Metric Value Why it matters
Production and test growth production net +318 lines; tests and support net +162 lines The production growth carries worker requests, lifecycle custody, and health adoption; the added tests exercise those boundaries.
Measured host checkpoint calls 12 → 0 for each database across warm samples The registered-timer comparison directly checks the main-thread work this PR intends to remove.

Technical review

Best possible solution:

Complete the normal exact-head merge gates and retain the registered-timer, replacement, and Linux containment regressions alongside the worker-backed maintenance path.

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

Yes. Current main retains the caller-thread maintenance path, and the PR supplies a registered-timer before/after workload. I did not execute that workload during this read-only review.

Is this the best way to solve the issue?

Yes. Dispatching through the existing SQLite writer owners preserves the timer, database identity, health, and close responsibilities without adding another scheduler.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 6be19d76682d.

Labels

Label changes:

  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.

Label justifications:

  • P1: Periodic database maintenance has measured Gateway-thread stalls that can delay active chats.
  • merge-risk: 🚨 session-state: The handoff changes maintenance custody for agent and shared-state databases, where an identity or settlement error could affect retained state.
  • merge-risk: 🚨 availability: A worker or coordinator failure in this maintenance path could delay database work, making the focused lifecycle proof relevant before merge.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The changed periodic WAL owners were exercised through registered timers, real SQLite databases, and writer workers in before/after component runs; the reported after-fix result is zero host checkpoint calls and sharply lower main-thread delay. Linux process cases also exercise containment through the registered path, and replacement tests cover refusal before database mutation. The current diff changes no stored-data contract, so migration compatibility is not applicable.
  • proof: sufficient: Contributor real behavior proof is sufficient. The changed periodic WAL owners were exercised through registered timers, real SQLite databases, and writer workers in before/after component runs; the reported after-fix result is zero host checkpoint calls and sharply lower main-thread delay. Linux process cases also exercise containment through the registered path, and replacement tests cover refusal before database mutation. The current diff changes no stored-data contract, so migration compatibility is not applicable.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Galin Iliev: 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 (12 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-26T04:43:06.169Z sha f1d411a :: blocked before merge. :: [P1] Keep Linux sidecar containment reachable after identity refusal
  • reviewed 2026-09-26T05:15:00.075Z sha d0ee3a1 :: blocked before merge. :: [P1] Restore Linux sidecar containment before identity refusal
  • reviewed 2026-09-26T06:00:23.969Z sha 283e9f5 :: blocked before merge. :: [P1] Preserve Linux sidecar containment before identity refusal
  • reviewed 2026-09-26T06:26:31.979Z sha a890852 :: blocked before merge. :: [P1] Run Linux sidecar containment before worker identity refusal
  • reviewed 2026-09-26T07:00:30.435Z sha d37274a :: blocked before merge. :: none
  • reviewed 2026-09-26T07:13:37.951Z sha 5f79c67 :: blocked before merge. :: [P1] Preserve immutable admission in the extracted state context
  • reviewed 2026-09-26T07:35:05.840Z sha 9bceadf :: needs maintainer review before merge. :: none
  • reviewed 2026-09-26T08:35:48.491Z sha d88015a :: needs maintainer review before merge. :: none

@steipete
steipete marked this pull request as ready for review September 26, 2026 02:43
Share context capture behind explicit lifecycle admission so WAL registration does not import its owning cache. Preserve synchronous schema and maintenance authority capture.

Validation: import-cycle guard, targeted lint, 41 lifecycle and schema-policy tests, and independent Codex review passed. Initial test compilation overlapped SDK declaration generation; the sequential run passed after generation settled.
Distinguish admission-injected context helpers from the canonical cache-backed facade. Remove the MCP reconstruction fixture session-key mock so shared storage cleanup can consume the real routing exports.

Validation: full architecture checks and independent Codex review passed. Original Gateway shard reproduced all 11 MCP failures; the repaired focused suite passed all 11 in 18.39 seconds.
Keep the materialized native PR wrapper complete after extracting the shared-state worker context capture module. The missing import prevented provisioner private-store injection.

Validation: reproduced the missing-module error before the fix; provisioning, extracted dependency closure and wrapper lease bootstrap passed afterward (3 tests, 92.08s wall). Independent Codex review passed.
@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Sep 26, 2026
steipete added a commit that referenced this pull request Sep 26, 2026
The Control UI file-read cutover moved ControlUiRootState to server-control-ui-root but left the retained-assets E2E fixture importing the old module. This broke the UI E2E type graph on main and PR merge refs.

Validation: reproduced TS2459, then the exact core-test-ui-e2e graph passed after correcting the erased type import. Formatting, diff checks and independent Codex review passed. Follow-up to #158464; observed while landing #158570.
Incorporate the main Control UI E2E type-import repair da8149b and current worker lifecycle context. The merge preserves the WAL cutover and resolved without conflicts.

Validation: focused WAL, state coordinator/error, broker and lifecycle cleanup suites passed; independent integrated Codex review found no actionable issues through P2.
Move settlement-order observations from the parent connection SQL spy to real worker transaction and commit admission. Retain authorization, rejected reclamation, page budget, original owner and reclamation-worker shutdown assertions; require zero parent vacuum calls.

Validation: reproduced both old fixture failures; all 13 reclamation and agent WAL admission tests passed (137.90s wall), targeted lint and independent Codex review passed.
@clawsweeper clawsweeper Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Sep 26, 2026
Remove redundant pure-helper mocks in device and lease fixtures so shared storage cleanup can use real coordinator errors. Preserve worker metadata in the broker cleanup fixture while continuing to forbid native worker and channel construction.

Validation: reproduced all missing-export failures, then 42 tests across five fixtures passed in 20.92 seconds; targeted lint, formatting and independent Codex review passed. No assertions or native-access fences were relaxed.
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Sep 26, 2026
Keep the original Linux sidecar tripwire at timer entry before physical identity admission can refuse worker dispatch. The existing synchronous scan preserves fatal no-cleanup ordering; checkpoint, vacuum and file-size work remain in workers.

Extend the existing process fixture through registered agent and shared-state owners with replaced main files and sidecars. Both cases fail on the original production path; all 83 Linux WAL/admission/coordinator tests pass after the fix with source hashes verified. Typecheck, lint and independent Codex review passed.
Preserve real worker-thread and OS metadata while retaining the existing fake workers, forbidden constructors and two-worker pool limit. This keeps shared storage teardown from failing on incomplete built-in mocks.

Validation: all 41 existing tests across five affected fixtures passed in 17.89 seconds after reproducing the missing-export failures; lint, formatting and independent Codex review passed. No assertions or native-access fences were relaxed.
@openclaw-barnacle openclaw-barnacle Bot added the agents Agent runtime and tooling label Sep 26, 2026
@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 Sep 26, 2026
Use native reflective invocation for the unchanged callback and argument list, avoiding the Node timer generic tuple mismatch without casts or relaxed checks.

Validation: reproduced TS2345 in the production core graph, then the graph, targeted lint, formatting and independent Codex review passed.
Resolve the main integration by retaining prepared read-source behavior in its existing owner and carrying the new schema admission/lifetime checks through the extracted context capture implementation. Keep the WAL lifecycle callback and cycle-free dependency boundary.

Validation: 64 focused lifecycle, schema-policy, coordinator and agent WAL admission tests passed; production core types, targeted lint, import cycles and independent integrated review passed. Merge main without rebasing contributor history.
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. label Sep 26, 2026
Place agent WAL registration with the database publisher instead of the lightweight writer queue. Preserve the registration body and shared queue owner while removing eager lifecycle and compiled-worker imports from queue-only callers.

The unchanged report-owner shard previously timed out during cold worker preparation. After the move, the focused child emits no worker-build output and all 83 tests pass under the same deadline. WAL publication/admission (26 tests), extracted wrapper closure, core types, lint, import-cycle checks and independent review passed.
@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Sep 26, 2026
@steipete
steipete merged commit cc75881 into main Sep 26, 2026
247 checks passed
@steipete
steipete deleted the perf/l33-wal-worker-maintenance branch September 26, 2026 10:16
@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 27, 2026
The Control UI file-read cutover moved ControlUiRootState to server-control-ui-root but left the retained-assets E2E fixture importing the old module. This broke the UI E2E type graph on main and PR merge refs.

Validation: reproduced TS2459, then the exact core-test-ui-e2e graph passed after correcting the erased type import. Formatting, diff checks and independent Codex review passed. Follow-up to openclaw#158464; observed while landing openclaw#158570.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 27, 2026
)

* perf(sqlite): move periodic WAL maintenance off the Gateway thread

* test(sqlite): verify WAL identity refusal and release test observers

* test(sqlite): await asynchronous periodic containment

* style(sqlite): make WAL failure types and cancellation returns explicit

* style(sqlite): align the maintenance cancellation return

* fix(sqlite): break WAL worker context import cycle

Share context capture behind explicit lifecycle admission so WAL registration does not import its owning cache. Preserve synchronous schema and maintenance authority capture.

Validation: import-cycle guard, targeted lint, 41 lifecycle and schema-policy tests, and independent Codex review passed. Initial test compilation overlapped SDK declaration generation; the sequential run passed after generation settled.

* fix(sqlite): satisfy worker context and fixture contracts

Distinguish admission-injected context helpers from the canonical cache-backed facade. Remove the MCP reconstruction fixture session-key mock so shared storage cleanup can consume the real routing exports.

Validation: full architecture checks and independent Codex review passed. Original Gateway shard reproduced all 11 MCP failures; the repaired focused suite passed all 11 in 18.39 seconds.

* fix(maintainer): include WAL context capture in wrapper

Keep the materialized native PR wrapper complete after extracting the shared-state worker context capture module. The missing import prevented provisioner private-store injection.

Validation: reproduced the missing-module error before the fix; provisioning, extracted dependency closure and wrapper lease bootstrap passed afterward (3 tests, 92.08s wall). Independent Codex review passed.

* test(sqlite): observe periodic reclamation in its worker

Move settlement-order observations from the parent connection SQL spy to real worker transaction and commit admission. Retain authorization, rejected reclamation, page budget, original owner and reclamation-worker shutdown assertions; require zero parent vacuum calls.

Validation: reproduced both old fixture failures; all 13 reclamation and agent WAL admission tests passed (137.90s wall), targeted lint and independent Codex review passed.

* test(sqlite): preserve real coordinator error exports

Remove redundant pure-helper mocks in device and lease fixtures so shared storage cleanup can use real coordinator errors. Preserve worker metadata in the broker cleanup fixture while continuing to forbid native worker and channel construction.

Validation: reproduced all missing-export failures, then 42 tests across five fixtures passed in 20.92 seconds; targeted lint, formatting and independent Codex review passed. No assertions or native-access fences were relaxed.

* test(sqlite): expect periodic vacuum in the worker

Keep the publication-order fixture aligned with periodic maintenance execution placement. Assert no parent vacuum after settlement while retaining real freelist reduction, page budget and committed-row proof.

Validation: both original failures reproduced; all 20 worker-store tests passed in 50.76 seconds. Formatting, diff checks and independent Codex review passed.

* fix(sqlite): preserve published-handle sidecar containment

Keep the original Linux sidecar tripwire at timer entry before physical identity admission can refuse worker dispatch. The existing synchronous scan preserves fatal no-cleanup ordering; checkpoint, vacuum and file-size work remain in workers.

Extend the existing process fixture through registered agent and shared-state owners with replaced main files and sidecars. Both cases fail on the original production path; all 83 Linux WAL/admission/coordinator tests pass after the fix with source hashes verified. Typecheck, lint and independent Codex review passed.

* test(sqlite): retain native metadata in worker mocks

Preserve real worker-thread and OS metadata while retaining the existing fake workers, forbidden constructors and two-worker pool limit. This keeps shared storage teardown from failing on incomplete built-in mocks.

Validation: all 41 existing tests across five affected fixtures passed in 17.89 seconds after reproducing the missing-export failures; lint, formatting and independent Codex review passed. No assertions or native-access fences were relaxed.

* test(sqlite): forward captured timer arguments safely

Use native reflective invocation for the unchanged callback and argument list, avoiding the Node timer generic tuple mismatch without casts or relaxed checks.

Validation: reproduced TS2345 in the production core graph, then the graph, targeted lint, formatting and independent Codex review passed.

* fix(sqlite): keep writer admission free of database startup

Place agent WAL registration with the database publisher instead of the lightweight writer queue. Preserve the registration body and shared queue owner while removing eager lifecycle and compiled-worker imports from queue-only callers.

The unchanged report-owner shard previously timed out during cold worker preparation. After the move, the focused child emits no worker-build output and all 83 tests pass under the same deadline. WAL publication/admission (26 tests), extracted wrapper closure, core types, lint, import-cycle checks and independent review passed.

* fix(state): preserve sealed private binding publication

* test(state): consume published identity in pending close fixture
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. scripts Repository scripts 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