Repository navigation
fix(sqlite): move WAL and serving-owner checks off the Gateway main thread - #184275
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex review: needs changes before merge. What this changesThis PR makes WAL inspection asynchronous and moves serving-owner verification into the existing heartbeat worker. Example: A SQLite admission encounters filesystem calls delayed by 20 ms each.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 2 items remain This PR addresses a concrete responsiveness problem and fixes the earlier checkpoint, retirement, and scheduler findings; two additional sibling fixtures fail on the reviewed head and need focused repairs. Priority: P2 Before merge
Findings
Agent review detailsHow this fits togetherSQLite lifecycle and admission owners sit between Gateway requests and native database operations, checking custody and ordering maintenance, writes, and disposal. flowchart TD
A[Gateway request] --> B[Captured database access]
B --> C[Heartbeat worker verification]
C --> D[Live admission guard]
D --> E[SQLite worker operation]
F[Async WAL inspection] --> G[Maintenance and disposal owner]
G --> E
Technical reviewBest possible solution: Keep the existing ownership and disposal cutover, and adapt the two remaining fixture families to await the actual asynchronous boundaries. Do we have a high-confidence way to reproduce the issue? Current main synchronously enumerates procfs and checks ownership during dispatch, establishing the blocking path; current-head CI independently demonstrates the two fixture failures without running target code during this review. Is this the best way to solve the issue? Reusing the heartbeat, WAL, disposal, and admission owners is a coherent repair that preserves containment and live authority; the remaining work belongs in affected fixtures rather than production fallbacks. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 1e07f2fedbdd. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceAcceptance criteria:
What I checked:
Likely related people:
PR surfaceSource +374, Tests +510, Docs +16, Other +386. Total +1286 across 32 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (2 earlier review cycles)
Reviewed October 26, 2026, 4:54 AM ET / 08:54 UTC (Revision 3). |
a637f52 to
1e89f10
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1e89f10218
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
1e89f10 to
6a472f1
Compare
|
Fixed the checkpoint ordering finding: one owner-held inspection flag now excludes scheduled ticks, deferred admission, and explicit checkpoint/reclaim/close work while the sidecar scan is pending. Confirmed mismatch containment still runs before shutdown cleanup. The new tracked and untracked SQLite regressions both failed on a premature PASSIVE checkpoint before the fix. Node and pinned Bun now each pass 53 focused tests (five Linux-only cases skipped on macOS). Independent review of the repair is clean; CI is running on the updated head. @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
6a472f1 to
3521c79
Compare
Reuse the existing heartbeat worker for fresh per-request physical custody checks, then recheck current owner authority before native admission. Move expired timer renewal to async filesystem operations while preserving synchronous native and sleep-recovery contracts. Fault-injected owner heartbeat delay falls from 192 ms to 0.133 ms. Main-thread allocation falls about 68%, with approximately 61 microseconds more process CPU and 613 sampled bytes per admission. Focused regressions, scoped checks, and independent review passed.
Guard native close and replacement before dependent cleanup. Idle eviction keeps its handle, admission facts, and lease while inspection is pending, then retries through the existing timer. The delayed-scan idle regressions fail before this repair. The complete lease-owner file passes 22 tests on Node and Bun; WAL and Kysely consumer tests pass. Independent review is clean.
78f3f27 to
0f7f932
Compare
|
Merged reviewed head CI run 40308838028 completed with 60 successful jobs, including all three PostgreSQL conformance shards. Its only failing test was The latest PR context/evidence check passed in 40309478707; earlier failed/cancelled metadata checks were superseded. Both review threads are resolved. Independent subagent review (autoreview route unavailable) and the final 25 real-owner tests are clean. The previous head's PostgreSQL empty-result failure did not recur on this head; it is not claimed fixed by this PR. The native workspace preflight selects a separate canonical checkout outside the lane's authorized workspace. The explicitly authorized exact-head REST squash fallback was used; no CI rerun or configuration change was used to force a passing result. |
Since #184275 the Linux WAL split-brain inspection runs asynchronously on the periodic maintenance tick. Interruption tests advance the fake clock past that tick, so a synchronous close in teardown could race a pending inspection and throw. Close through the orderly async lifecycle first.
Move MCP mutations, personal GitHub credential publication, transcript exports, recovery cleanup, and borrowed cleanup identity checks through existing async owners. Preserve original custody, physical identity and birthtime, final publication guards, and accepted-write settlement. Resolve runtime owner paths and close-checkpoint diagnostics asynchronously. Follow-up to #184275. Five alternating 2,000-check owner samples reduced total process CPU by 62% and sampled allocation by 62%; injected slow filesystem heartbeat delay fell from 491 ms to 0.095 ms. Focused behavior, core typecheck, lint, closure checks, and independent review passed.
Move MCP mutations, personal GitHub credential publication, transcript exports, recovery cleanup, and borrowed cleanup identity checks through existing async owners. Preserve original custody, physical identity and birthtime, final publication guards, and accepted-write settlement. Resolve runtime owner paths and close-checkpoint diagnostics asynchronously. Follow-up to #184275. Five alternating 2,000-check owner samples reduced total process CPU by 62% and sampled allocation by 62%; injected slow filesystem heartbeat delay fell from 491 ms to 0.095 ms. Focused behavior, core typecheck, lint, closure checks, and independent review passed.
…ests (#184586) * perf(sqlite): keep runtime lease checks off the Gateway main thread Move MCP mutations, personal GitHub credential publication, transcript exports, recovery cleanup, and borrowed cleanup identity checks through existing async owners. Preserve original custody, physical identity and birthtime, final publication guards, and accepted-write settlement. Resolve runtime owner paths and close-checkpoint diagnostics asynchronously. Follow-up to #184275. Five alternating 2,000-check owner samples reduced total process CPU by 62% and sampled allocation by 62%; injected slow filesystem heartbeat delay fell from 491 ms to 0.095 ms. Focused behavior, core typecheck, lint, closure checks, and independent review passed. * test(sqlite): align lease fixtures with current ownership guards Retain the same cancellation predicate in synchronous and awaited MCP fixture checks. Expect the broker physical-identity refusal after lease cleanup moved to its existing admission owner, preserving the original database lease-row assertion. * fix(sqlite): preserve physical custody through async lease checks * fix(sqlite): scope captured identity to its admitted lifetime * fix(sqlite): publish observed heartbeat loss before returning * test(sqlite): prepare MCP authorization subprocess before its deadline
* fix(update): support direct extended-stable upgrades Normalize verified 2026.9.33/34 physical database inventories inside candidate Doctor, attribute migrations with committed generations, and return physical receipts to the older updater. Keep explicit candidate inspections current and preserve strict checks for changed data, intervening commits, and replacements. Complete agent schema preparation before ordinary readers enter, and preserve the source cron selector when a released updater snapshots a rehearsal copy. No new schema, durable state, configuration, or ordinary-reader exclusion. Supersedes the approach in #182129. * test(gateway): stop WAL maintenance before closing watcher test state Since #184275 the Linux WAL split-brain inspection runs asynchronously on the periodic maintenance tick. Interruption tests advance the fake clock past that tick, so a synchronous close in teardown could race a pending inspection and throw. Close through the orderly async lifecycle first. * test(update): match the path-qualified migration refusal message
…hread (openclaw#184275) * fix(sqlite): avoid Gateway stalls during WAL sidecar scans Await periodic sidecar identity inspection without blocking the Gateway main thread. Preserve fatal containment before shutdown cleanup, and recheck suspected mismatches after descriptor close or reuse. Includes delayed-filesystem regression proof and a reproducible responsiveness benchmark. * test(sqlite): await asynchronous WAL inspection before admission assertions * fix(sqlite): block checkpoints during WAL sidecar inspection * test(sqlite): await scheduled checkpoint recovery * fix(sqlite): verify serving ownership off the main thread Reuse the existing heartbeat worker for fresh per-request physical custody checks, then recheck current owner authority before native admission. Move expired timer renewal to async filesystem operations while preserving synchronous native and sleep-recovery contracts. Fault-injected owner heartbeat delay falls from 192 ms to 0.133 ms. Main-thread allocation falls about 68%, with approximately 61 microseconds more process CPU and 613 sampled bytes per admission. Focused regressions, scoped checks, and independent review passed. * fix(sqlite): retain native custody during WAL inspection Guard native close and replacement before dependent cleanup. Idle eviction keeps its handle, admission facts, and lease while inspection is pending, then retries through the existing timer. The delayed-scan idle regressions fail before this repair. The complete lease-owner file passes 22 tests on Node and Bun; WAL and Kysely consumer tests pass. Independent review is clean. * test(sqlite): wait for asynchronous maintenance admission * fix(sqlite): reuse worker-verified custody for retained reads * test(memory): retain PostgreSQL search failure diagnostics
…ests (openclaw#184586) * perf(sqlite): keep runtime lease checks off the Gateway main thread Move MCP mutations, personal GitHub credential publication, transcript exports, recovery cleanup, and borrowed cleanup identity checks through existing async owners. Preserve original custody, physical identity and birthtime, final publication guards, and accepted-write settlement. Resolve runtime owner paths and close-checkpoint diagnostics asynchronously. Follow-up to openclaw#184275. Five alternating 2,000-check owner samples reduced total process CPU by 62% and sampled allocation by 62%; injected slow filesystem heartbeat delay fell from 491 ms to 0.095 ms. Focused behavior, core typecheck, lint, closure checks, and independent review passed. * test(sqlite): align lease fixtures with current ownership guards Retain the same cancellation predicate in synchronous and awaited MCP fixture checks. Expect the broker physical-identity refusal after lease cleanup moved to its existing admission owner, preserving the original database lease-row assertion. * fix(sqlite): preserve physical custody through async lease checks * fix(sqlite): scope captured identity to its admitted lifetime * fix(sqlite): publish observed heartbeat loss before returning * test(sqlite): prepare MCP authorization subprocess before its deadline
) * fix(update): support direct extended-stable upgrades Normalize verified 2026.9.33/34 physical database inventories inside candidate Doctor, attribute migrations with committed generations, and return physical receipts to the older updater. Keep explicit candidate inspections current and preserve strict checks for changed data, intervening commits, and replacements. Complete agent schema preparation before ordinary readers enter, and preserve the source cron selector when a released updater snapshots a rehearsal copy. No new schema, durable state, configuration, or ordinary-reader exclusion. Supersedes the approach in openclaw#182129. * test(gateway): stop WAL maintenance before closing watcher test state Since openclaw#184275 the Linux WAL split-brain inspection runs asynchronously on the periodic maintenance tick. Interruption tests advance the fake clock past that tick, so a synchronous close in teardown could race a pending inspection and throw. Close through the orderly async lifecycle first. * test(update): match the path-qualified migration refusal message
What Problem This Solves
Fixes Gateway main-thread stalls caused by synchronous filesystem checks during WAL diagnostics and SQLite ownership admission. During slow metadata writeback, these checks could block unrelated requests even though the database work itself belonged to a worker.
User Impact
Periodic WAL inspection now awaits filesystem operations. Ordinary serving-owner SQLite dispatch requests a fresh physical ownership check from the existing heartbeat worker, then rechecks the same live authority immediately before native admission. Slow I/O delays the affected operation while other Gateway work can continue.
A confirmed WAL mismatch still terminates before cleanup. Checkpoints, native close/deserialize, and dependent cleanup cannot overtake a pending scan. Idle eviction retains its handle, lease, and admission facts and retries after inspection. Ownership replacement, unlink, release, projection changes, or verifier loss still refuse admission. Successful ownership checks are never reused across requests.
Why This Change Was Made
The existing WAL owner runs the asynchronous procfs/sidecar scan, rechecks suspected descriptor reuse, and joins inspection during shutdown. The native SQLite disposal owner supplies the guard used by close, replacement, and agent retirement; it runs before clean-close sealing or admission invalidation.
The captured database-access owner supplies asynchronous preparation and a request-specific final authority guard. The first retained read consumes the successfully verified canonical-path fact instead of repeating two synchronous ownership probes; retargeted aliases still resolve and check their new destination. Generic SQLite broker dispatch, specialized session archive/reclamation requests, and asynchronous credential operations consume that contract. Credential path resolution is asynchronous while preserving invocation order for aliases. Expired heartbeat-timer recovery also uses asynchronous I/O and settles before shutdown completes.
No schema, dependency, configuration, or public API change. Synchronous bootstrap/schema, native cleanup, immediate sleep recovery, unregistered offline admission, and separate synchronous management-effect/SDK APIs retain their existing contracts. This PR does not claim all Gateway filesystem work is eliminated. Warm admission-fact lookup and reader diagnostics already perform no filesystem operations.
Measurement
Acceptance was declared before measurement: preserve custody and containment, remove main-thread stalls under injected I/O, and disclose relocated CPU/allocation cost. Five alternating base/candidate runs per owner, 2,000 operations each, separate CPU and sampled-allocation passes. Benchmark usage lives in each script's header; the shared perf README is unchanged.
This is a responsiveness repair, not a total-CPU/allocation improvement. WAL adds approximately 26 microseconds CPU and 106 KiB sampled allocation at its existing 30-minute cadence. Ownership adds approximately 61 microseconds process CPU and 613 sampled bytes per admission; host allocation falls about 68%, total allocation rises about 9%. Ownership main-thread CPU paired signs were mixed, so that median is context rather than a throughput claim.
WAL heartbeat ranges: 820.77–1120.53 ms before, 0.208–0.812 ms after; host one-minute load 60.97–81.85. Ownership ranges: 187.374–212.289 ms before, 0.118–0.158 ms after; host load 58.43–61.45. WAL uses 128 synthetic proc descriptors and two sidecars, with the same 135 FS operations per healthy scan. Ownership uses the shared serving owner used by session/plugin dispatch. These are owner measurements, not whole-Gateway load or p99 results. The benchmark's ownership delay applies to host calls; real-worker delayed verification is separately covered by regression tests. No Team activity or production-state access.
Evidence
Real broker regressions fail on the baseline's synchronous owner reads, then pass with the fix. They delay the actual heartbeat worker, exercise changed custody, and reopen SQLite to prove rejected writes were not committed. All three expired-timer regressions fail on baseline synchronous
openSync. Focused ownership/heartbeat/broker/credential coverage passed 94 tests, specialized worker consumers 30, and final heartbeat coverage 31.WAL regressions fail on baseline synchronous proc enumeration and cover healthy scans, mismatches, closed/reused descriptors, shutdown containment, checkpoint ordering, and native retirement. The idle-eviction regressions fail before the disposal guard because the native database closes while inspection is pending. The fixed tests require the native handle, lease, and admission facts to survive until inspection resolves; a healthy result subsequently permits eviction.
Earlier WAL-only CI exposed timer assumptions in sibling checkpoint, reclamation, admission, and state-open tests. They now await the existing scheduler instead of assuming timer firing completes asynchronous I/O. Those focused files passed on Node and pinned Bun; Linux CI passed all 54 WAL tests. One earlier mocked Control UI disclosure assertion failed and did not recur; it is not claimed fixed here. Combined-head CI exposed three more synchronous fixture assumptions: close during inspection, cancel before first worker dispatch, and reclamation maintenance scheduled during COMMIT. The fixtures now await actual admission boundaries and preserve native lock, retained-lease, cancellation, and shutdown assertions. Focused Node validation passes all 225 tests across five affected files; the four SQLite files also pass all 61 tests on pinned Bun. Scoped lint and independent review are clean. All lane files remained byte-identical through rebase. The unrelated reasoning-capability assertion is fixed upstream by #184414 and included through rebase. The final head must pass its own CI. On head
78f3f27, the discarded-environment pre-bootstrap case failed identically on the branch and its unchanged base. PostgreSQL memory rebuild returned an empty result in CI but passed five isolated full-file runs on both that head and CI’s main parent; attribution remains unresolved because the changed transport is on its path. The test now preserves unavailable/error diagnostics before reducing search results to paths; this is not claimed as a PostgreSQL repair. All seven PostgreSQL product tests pass with the strengthened diagnostic assertion on the rebased candidate, using a disposable local container and one test worker.The final retained-read regression fails on
78f3f27with two synchronous ownership probes and passes with zero. All 25 real-owner tests pass, including retained maintenance, ownership loss, and an alias retargeted to a different database under maintenance. Independent review caught and fixed alias-key publication before commit.Scoped formatting/lint, the core typecheck, export collision check, and required closure checks passed. Focused local tests and PR CI provide proof under the requested fast-path protocol; no full Gateway stress campaign or Testbox lease.
Independent subagent review (autoreview route unavailable) found and fixed shutdown, checkpoint-overtake, and native-retirement ordering issues. The ownership cutover has a clean P0–P2 review. A proposed startup-inode finding was retracted after inspecting fs-safe's existing exact-byte/token contract; no stronger requirement was invented. The configured autoreview route refused before inference and operator configuration was not changed.
Final native-retirement proof: all 22 lease-owner tests pass on both Node and pinned Bun, including both delayed-scan eviction cases. The final WAL and native Kysely-cache files also pass (91 tests, five Linux-only skips on macOS). Fixture cleanup awaits the real maintenance worker, whose separate lease can legitimately outlive idle eviction of the original host handle.
Runtime production delta is +376 lines: asynchronous scan/request settlement, containment before native disposal, and async timer recovery with retained native/sleep-recovery contracts require that growth. The two standalone benchmarks add 386 lines of proof tooling; the requested non-test/non-doc total is +762 lines. There is no retained synchronous ordinary-dispatch or periodic-scan fallback. Existing heartbeat, disposal, resource-registry, and writer-queue owners remain authoritative.
Known residual: native runtime leases used by project checkout/clone, plugin/package lifecycle, and GitHub publication/OAuth still reach synchronous state ownership assertions. They need migration through the existing async lease owner and awaited effect preparation while retaining final synchronous guards. These are real runtime paths, not SDK-only exceptions; that follow-up is separate from this reviewed diagnostic/worker-dispatch cutover.