Repository navigation
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: needs real behavior proof before merge. What this changesThis PR replaces Gateway shared-state copies with live read transactions and retires temporary SQLite payloads in bounded steps. Example: Start a Gateway with a synthetic 12 GiB shared-state database.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 7 items remain This PR addresses worthwhile large-database stalls, but its live dispatch scope removes GitHub readiness source-revocation checks and needs correction before merge. Priority: P2 Before merge
Findings
Provenance
Tests
Agent review detailsHow this fits togetherGateway startup and RPC handlers consume shared-state metadata through SQLite read owners; offline inspection retains private snapshots whose lifecycle owner controls reclamation. flowchart TD
A[Gateway startup and RPC] --> B[Live read scope]
B --> C[Shared state read owner]
C --> D[SQLite read transaction]
E[Offline inspection] --> F[Private snapshot owner]
F --> G[Bounded payload retirement]
Technical reviewBest possible solution: Keep live transactions and bounded cleanup in the existing owners, while making publication source revocation independent of artifact-copy policy. Do we have a high-confidence way to reproduce the issue? Current-main snapshot preparation and the pinned startup callers establish the copying path; the author reports a real Gateway baseline, and no target code was executed during this review. Is this the best way to solve the issue? The existing read and retirement owners are appropriate, but source-lifetime checks must survive independently of the scope that previously selected private copies. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against eca83d7d00f9. Merge-risk optionsMaintainer options:
Provenance checked
TestingProof path: in-process harness. SecurityNeeds attention: Delayed readiness responses can retain disclosure authority from an agent database whose source has been revoked or replaced. EvidenceSecurity concerns:
What I checked:
Likely related people:
PR surfaceSource +98, Tests +166, Docs +14, Other +97. Total +375 across 34 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 Reviewed November 2, 2026, 1:46 AM ET / 06:46 UTC. |
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. |
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e3d45f4373
ℹ️ 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".
| const prepared = isLiveStateRead() | ||
| ? undefined | ||
| : await prepareSqliteReadOnlyLocation(databasePath, { |
There was a problem hiding this comment.
Retain private recovery for hot rollback journals
If the shared-state database has a hot rollback journal (for example, after an interrupted writer on a restored DELETE-journal-mode database), bypassing preparation makes Gateway startup fail before writable recovery can run. inspectOwnershipThroughConnection() opens the source read-only, and SQLite cannot read a hot journal without rolling it back: a native reproduction returns SQLITE_READONLY_ROLLBACK (776), while recovery on a private copy succeeds. The previous preparation path supported this case, also covered by the existing openclaw-state-db.test.ts hot-journal recovery test. Keep live reads for ordinary WAL databases, but retain an exceptional private-recovery path for hot rollback journals.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Confirmed that this failure mode also applies to supported network filesystems, where OpenClaw selects DELETE journaling; it is not limited to externally restored databases. The existing hot-journal regression exercises offline artifact-preserving reads and still passes, but it does not prove Gateway startup under the new live-read scope.
This remains unresolved and blocks landing. A private-recovery fallback conflicts with the zero-copy startup objective; native recovery before inspecting the external-ownership row would change the authority boundary. The behavior choice is being settled before implementation. The separate observation-policy/source-revocation findings were fixed in 4616962 and the affected readiness tests and exact-head CI now pass.
Reserve private state admission for a genuinely hot rollback journal during startup, then recover the canonical database only after ownership and config guards pass. Normal startup and runtime readers keep using live SQLite. Remove Gateway legacy snapshot scanning. Drain active snapshot payloads with async bounded truncation and retain producer custody through reply delivery and parent exit. Integrate the one-shot CLI drain from #178730. Co-authored-by: Frosmans <[email protected]>
4616962 to
0e6aa3d
Compare
Permit native closed-WAL inspection under the existing Gateway live-read policy while retaining full integrity checks and offline artifact preservation. Release producer staging locks before result publication while keeping cleanup custody through delivery. Prove both regressions at their owning boundaries, repair callback fixtures, and isolate the PostgreSQL orphan-inventory test from sibling schema cleanup. The actual cleanup owner took 57.8 seconds to drain a synthetic 35 GiB clone, so avoiding the unnecessary agent copy removes that admission work.
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
…sals main's openclaw#190918 removed the periodic reclaimer whose skip warning carried the message; re-home the regression at the reconcile owner that still refuses unknown staging content.
Merge the pinned main containing e68dfaf (openclaw#190918), which isolates PostgreSQL orphan-inventory assertions from sibling schema cleanup. The incoming PR failed that exact conformance assertion in CI41446017953; this preserves the original three-file ENOTDIR product delta while integrating its existing baseline repair. No timeout changes or new unrelated repair are introduced. Co-authored-by: SunnyShu <[email protected]> Co-authored-by: steipete <[email protected]>
…aw#190918) * fix: prevent large-database Gateway startup and cleanup stalls * fix: preserve observation policy for live state reads * fix: preserve crash restart without routine state snapshots Reserve private state admission for a genuinely hot rollback journal during startup, then recover the canonical database only after ownership and config guards pass. Normal startup and runtime readers keep using live SQLite. Remove Gateway legacy snapshot scanning. Drain active snapshot payloads with async bounded truncation and retain producer custody through reply delivery and parent exit. Integrate the one-shot CLI drain from openclaw#178730. Co-authored-by: Frosmans <[email protected]> * fix: avoid agent startup copies and preserve snapshot handoff Permit native closed-WAL inspection under the existing Gateway live-read policy while retaining full integrity checks and offline artifact preservation. Release producer staging locks before result publication while keeping cleanup custody through delivery. Prove both regressions at their owning boundaries, repair callback fixtures, and isolate the PostgreSQL orphan-inventory test from sibling schema cleanup. The actual cleanup owner took 57.8 seconds to drain a synthetic 35 GiB clone, so avoiding the unnecessary agent copy removes that admission work. --------- Co-authored-by: Frosmans <[email protected]>
Let the reconciliation owner skip read transactions for empty selections while retaining the existing composite snapshot for nonempty runs and already-pinned callers. The synthetic boot/restart workload removes eight statements with unchanged warm turns. Related: openclaw#190918, openclaw#191332.
What Problem This Solves
Gateway startup and state reads can create multi-GiB database copies, while periodic cleanup frees old clones through one large unlink. Both operations can stall serving traffic on extent-heavy filesystems.
User Impact
Normal Gateway startup, its ownership checks, and serving RPC reads use live read-only SQLite transactions. Crash restart on DELETE-journal filesystems still recovers automatically: only startup may take one private copy after SQLite actually requires hot-journal recovery. The exception is logged and its copy is removed before admission continues. No schema change, configuration option, or new cache.
The Gateway legacy-cache sweep is removed. Abandoned historical copies require explicit offline maintenance; no blanket Doctor sweep is introduced because the cache spans independently owned state directories. Active private copies receive bounded cleanup. Bounded truncation does not guarantee bounded later btrfs transaction latency.
Why This Change Was Made
Offline inspection protects exact database/WAL/SHM bytes and permits private recovery before ownership checks. Runtime consistency needs a live SQLite read transaction. This change separates source selection from inspection side-effect policy, preserving ownership, cancellation, publication safeguards, and Doctor/update artifact preservation.
For a hot rollback journal, startup inspects private ownership, passes config/live-owner guards, revalidates original main/journal fingerprints under existing schema custody, and lets SQLite recover the canonical database. Generic live readers cannot opt into this exception. Closed-WAL agent inspection also follows the live policy: SQLite may create empty coordination files while full integrity, foreign-key, ownership, and schema checks remain in the isolated read transaction. Offline and partial WAL/recovery families retain their preservation policy.
Producer custody lasts through reply delivery; surviving owners drain interrupted creation. The native staging lock is released before publication so an already-informed caller can retire immediately, even while the send callback is pending. Async cleanup truncates through the same retained descriptor. Graceful CLI draining incorporates @Frosmans's work from #178730, with co-author credit.
Evidence
Reviewed head:
c18f1c86258db021831a8400d4114a977921527c, source comparison parentd9627ecb437b2a0fdaa2215137b291dbbc806137. The PR is ready; the lead accepted the exact-main inherited CI exception below. All measurement runs are complete.Five serialized A/B pairs used synthetic state of 12.919 GB, a 37.681 GB agent DB, eight agents, 10,000 sessions, and 62,000 workspace files / 1.181 GB. Every baseline published 18 files / 153,969,655,960 logical bytes, including nine state and eight agent images. Every candidate created zero files and zero copied bytes. All ten first RPCs succeeded on their first attempt; all runs stopped without forced exit.
Pair 3 was slower and remains included. First-reply ranges are 75.355–85.639 s versus 45.319–85.764 s; with n=5, nearest-rank p95 is the sample maximum, not a production tail estimate. Two earlier A/A controls showed readiness 117.436/95.651 s and CPU 65.54/64.54 s; they describe their earlier time window, not concurrent controls. Measurements used Node 26.12.1 / SQLite 3.54.1 on local APFS under shared-host load, not production btrfs/RAID. CPU excludes already-exited children; RSS covers the Gateway process only.
The original +16.3% first-reply regression was real. It exposed synchronous cleanup in the RPC window and then an awaited 35 GiB agent-copy retirement costing 57.825 s through 561 async truncations. Moving cleanup off-thread did not remove that admission delay; deleting the unnecessary closed-WAL fallback did. Old slower cohorts remain retained. The fresh profile retains a slower state-admission integrity phase: 2.588 s on the baseline parent/private source versus 23.674 s on the candidate child/live source, while separate existing schema-maintenance integrity samples are 4.504→4.864 s. These are sampled wall times. Earlier same-inode cold/warm controls explain the lost bulk-read preparation from copy/coherence comparison; full startup and first-reply medians still improve with integrity checks retained. The final CPU pair records zero sync/async truncation calls across the candidate lifecycle and agent-inspector requests 16→8. Targeted schema-child profiles exist, but three short-lived integrity-worker profiles are missing across the pair; complete process-tree CPU coverage is not claimed. Shutdown logs identify the unchanged cron-maintenance owner awaiting its task scope and scheduled sweep. The diagnostic candidate stop is mostly main-thread idle (2.120 of 2.488 s), with no clone to delete. Why that sweep remains pending more often is unresolved; the 1.166 s median increase is retained, not labeled noise. First-RPC profiles show the same module loading, plugin-worker joins, filesystem admission, and SQL work, with the old synchronous-truncation hotspot absent. Chronological heap A/B/A samples were 3,895,363,704 / 3,913,751,856 / 3,849,312,272 main-thread V8 bytes. Baseline A/A is −1.18%; candidate is +0.47% versus the first baseline and +1.67% versus the later one. These descriptive samples establish neither an allocation improvement nor equivalence; native/other-process allocations are excluded. The final local btrfs probe passed on 35 GiB logical / 2.1875 GiB allocated / 573,440 extents: whole unlink 877.322 ms; async owner 559 truncations, zero sync truncations, maximum callback 3.903 ms, final 64 MiB removal 3.756 ms. Total cleanup 878.290→938.031 ms; CPU 867.477→404.374 ms. Direct-cleanup A/A was 900.140/851.763 ms. This does not bound delayed-reference transaction commits. Task-owned probe resources were cleaned up. All measurement runs and task-owned probe cleanup completed.
Focused proof includes 328 consumer tests and 58 affected-boundary tests, followed by 27 infra cases, 13 startup-integrity cases, and the exact seven previously failing Doctor cases plus six hot-journal controls. Regression proof covers concurrent writers, external ownership, source changes, hot-journal recovery, creator exit, real delayed-send handoff, CLI drain, and bounded async deletion. The new closed-WAL case fails before the fix on attempted copy creation and still rejects a corrupted foreign key afterward.
A real isolated Gateway hot-restart smoke creates zero copies on healthy boot and exactly one logged 1,454,080-byte copy for a crash-created DELETE journal, removed by readiness; committed state is recovered. A packaged CLI burst produced four valid
sessions.abortreplies after an expected pre-listener refusal. All five observed CLI processes created zero copies on both baseline and the prior repaired source; the reported CLI-owned producer did not reproduce. Gateway state images fell 9→0, and observed processes and snapshot paths were gone after shutdown.pnpm check:changedcompleted. All other gates passed after an owned test-variable shadowing error was mechanically renamed and targeted typed lint/formatting passed. Three unused plugin-hook exports reproduce on clean source parent d962 and originated in71e516af03a11fb1e309ff4fd2a0b8dccee506da/ #190906. This is a main regression; no full-command green is claimed.CI 41441670232 on this exact head finished with 113 successful jobs, 23 skipped, and one failed Doctor process test plus its aggregate gate. Its tested main parent is
714490716002d24b939817366f277872b6ea2825. The Doctor child exceeds 30 seconds before Gateway startup. The same failure reproduces on that clean exact parent with Node 24.22.1; the unchanged matching-runtime candidate control passes. The test/deadline originated in2a1402cd3e3914352820a24961087f1de0c736d9/ #151025, but the runtime slowdown introducer is not established. The lead explicitly waived the introducing-commit requirement for this landing on the strength of exact-main reproduction. No timeout is raised or waived in code.Earlier CI found the staging-lock handoff defect and stale callback fixtures, repaired with causal red/green proof. A PostgreSQL test's global schema inventory raced sibling deletion; it now owns an isolated database and preserves the full orphan assertion with a sibling-deletion control. The old Docker root-help timeout remains unexplained historically but passed fresh exact-head CI. Earlier local fleet-preflight and Bun probe failures remain investigated uncertainties; unchanged passing replays are not claimed as fixes.
Independent Codex review covered the full PR through P2. Its native-close concern was rejected after source inspection and eight cross-process lock-survival controls: SQLite-managed connections preserved competing writer locks; deliberate raw descriptor closes broke them. The final repair received fresh scoped-clean P0–P2 review with complete lifecycle-owner context.
Runtime
src/delta is +106 LOC; tests −102 LOC; proof tooling +248 LOC separately. Guarded hot-journal recovery and producer-exit custody account for growth after deleting the serving reclaimer. Older-worker cancellation still needs retained layout/cutoff validation (#154937).Related: #178730, #188009, #190875, #191054. Their remaining transfer-policy and Doctor recovery/async-only changes are separate; no duplicate closed-WAL fix was found.
Accepted inherited-red landing
Lead accepted inherited-red admin merge; fix tracked in lane 2119
Failing checks in run 41441670232, attempt 1:
checks-node-changed-compact-large-1-1(job 125265741642) and downstreamopenclaw/ci-gate(job 125275803641). The failing case issrc/commands/doctor-config-preflight.process.test.ts→serves canonical state after Doctor repairs cron and preserves retired plugin sidecars.Reproduction ran from a clean checkout of the exact CI main parent
714490716002d24b939817366f277872b6ea2825:Actual output excerpt (the timeout argv separately identifies the Doctor child as Node 24.22.1):
The #190906 hook-export regression is separately proven inherited by the clean d962 production Knip reproduction and introducing commit
71e516af03a11fb1e309ff4fd2a0b8dccee506da; it is a local changed-check failure, not an additional failed job in this CI attempt. All these failures remain recorded, not relabeled green.CLI incident coverage limit
The successful
gateway call sessions.abortburst created zero CLI copies on both baseline and candidate. That is not causal proof that this PR eliminates the reported CLI leaks. The Gateway startup admission path is live and retained producers now have creator-exit cleanup, but the entire generic CLIgateway callbootstrap is not placed under the live-read policy. The reported unverifiable-owner/Doctor-heldsessions.abortandsessions.listproducer conditions were not reproduced. The general CLI never-clone guarantee is not completed by this PR; those incident producers need a separate targeted lane. No claim is made that ordinary successful burst coverage reproduces those failure conditions.