Repository navigation
fix: avoid duplicate SQLite copies during update rehearsal - #162403
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: blocked before merge. Reviewed October 1, 2026, 5:26 AM ET / 09:26 UTC (Revision 7). ClawSweeper reviewWhat this changesThe PR avoids copying privately owned SQLite images again during snapshot publication, preserves row IDs in update rehearsals, and adjusts regression coverage and updating documentation. Merge readiness⛔ Blocked before merge - 2 items remain The PR remains useful and has no identified blocking code defect. Earlier findings are resolved, but the repository-required published-updater compatibility check remains explicitly unperformed. Priority: P2 Review scores
Verification
How this fits togetherUpdate rehearsals prepare private copies of operator databases before candidate migrations and validation. The SQLite snapshot owner verifies and publishes those copies while preserving the live source databases. flowchart TD
A[Operator databases] --> B[Private consistent copy]
B --> C[Snapshot verification]
C --> D{Privately owned image?}
D -->|Yes| E[Transfer with copy fallback]
D -->|No| F[Independent publication copy]
E --> G[Verified snapshot]
F --> G
G --> H[Candidate migration rehearsal]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +53, Tests +343, Docs 0. Total +396 across 8 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep private-image transfer within the existing snapshot owner, preserve public-copy isolation and fallback, and establish compatibility through the published updater before landing. Do we have a high-confidence way to reproduce the issue? Yes, source provides a high-confidence path: current main recopies the private image and leaves rehearsal compaction enabled, which can renumber sparse implicit row IDs. This read-only review did not execute that path. Is this the best way to solve the issue? Yes, the patch extends the existing publication owner and reuses its supported fallback while preserving the public publisher contract. Full updater compatibility remains a separate validation requirement. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 3862ade452e3. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (6 earlier review cycles)
|
…eration # Conflicts: # src/infra/sqlite-snapshot.ts
|
Fixed the P2 race-hook finding in The requested local-repository and snapshot suites passed, along with the backup/restore consumers after integrating #162383: 137 tests passed, three existing Windows-only skips, 103.004 seconds. Scoped lint, formatting, whitespace checks and independent correction/integration reviews passed. The PR body records exact tested commits, subsequent main impact and the original CI failure; current-head hosted checks remain pending. |
|
Fixed the rehearsal-guide P3 in ed26f80, published in ff91f52. The guide now states that the worker verifies and publishes the private copy while preserving row IDs, matching preserveRowIds: true and the absence of rehearsal VACUUM. Formatting and whitespace checks passed. Runtime code is unchanged by this correction; the previous snapshot/cleanup proof remains applicable. The Windows cleanup job on af8c565 also passed: https://github.com/openclaw/openclaw/actions/runs/36819007638/job/110230545544 @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
…te-single-generation
|
Published reviewed integration @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
…te-single-generation
|
Merged via squash.
|
…teway tests fail on loaded hosts when fixture children outlast polling deadlines (#162945) agent-exec (plugin e2e and construction), update candidate-state budget/cleanup, managed-service handoff boundary/process support, plugin install-record commit, the local TUI PTY e2e, and the QA Lab Gateway heartbeat-routing and package-for-Docker tests polled readiness/PID files or raced process exit against fixed timers, so a fixture child or preparation step that outlasted the bound on a loaded host failed the test. Waits now await existing owner callbacks (such as the command onOutputChunk readiness), retained child close promises, fixture receipts with a durable-record fallback where the product owns the child, and same-process fixture events registered before the Gateway starts. The rebase keeps #162694's managed-service triage receipts byte-for-byte, #162403's cleanup directory-retirement fault, and #162496's Bun preload settings, and layers this lane's receipts and joins on top. Thirteen sites stay unchanged where independent runner clocks, post-abort cleanup joins, a synchronously blocked host, out-of-scope producers, or killed helpers without a close handle leave no owned signal. The budget and agent-exec plugin tests keep their whole fixture lifetime until teardown joins it, so a timed-out body can no longer lose its release file or stop markers to afterEach (forced-abort probes reproduce the four defects before the fix). No product source, test timeout, product timeout, or assertion meaning changed. Follow-up to #162696 in the polling audit from #162274. Proof on Blacksmith Testbox: delay probes fail the original bytes and pass these bytes, forced-abort probes reach cleanup, 480 standalone runs, 120/120 on the rebased head, Gateway E2E shards 2/4 and 3/4 3/3 each (2/4 re-proven 3/3 on the final teardown-fix head), type-aware lint, deadcode, base-aware timeout-race ratchet; Codex autoreview clean.
…162403) * fix: avoid duplicating SQLite snapshots during update rehearsal * test: target final snapshot publication in race hooks * test: exercise staging cleanup after snapshot transfer * docs: describe row-preserving update rehearsals
…teway tests fail on loaded hosts when fixture children outlast polling deadlines (openclaw#162945) agent-exec (plugin e2e and construction), update candidate-state budget/cleanup, managed-service handoff boundary/process support, plugin install-record commit, the local TUI PTY e2e, and the QA Lab Gateway heartbeat-routing and package-for-Docker tests polled readiness/PID files or raced process exit against fixed timers, so a fixture child or preparation step that outlasted the bound on a loaded host failed the test. Waits now await existing owner callbacks (such as the command onOutputChunk readiness), retained child close promises, fixture receipts with a durable-record fallback where the product owns the child, and same-process fixture events registered before the Gateway starts. The rebase keeps openclaw#162694's managed-service triage receipts byte-for-byte, openclaw#162403's cleanup directory-retirement fault, and openclaw#162496's Bun preload settings, and layers this lane's receipts and joins on top. Thirteen sites stay unchanged where independent runner clocks, post-abort cleanup joins, a synchronously blocked host, out-of-scope producers, or killed helpers without a close handle leave no owned signal. The budget and agent-exec plugin tests keep their whole fixture lifetime until teardown joins it, so a timed-out body can no longer lose its release file or stop markers to afterEach (forced-abort probes reproduce the four defects before the fix). No product source, test timeout, product timeout, or assertion meaning changed. Follow-up to openclaw#162696 in the polling audit from openclaw#162274. Proof on Blacksmith Testbox: delay probes fail the original bytes and pass these bytes, forced-abort probes reach cleanup, 480 standalone runs, 120/120 on the rebased head, Gateway E2E shards 2/4 and 3/4 3/3 each (2/4 re-proven 3/3 on the final teardown-fix head), type-aware lint, deadcode, base-aware timeout-race ratchet; Codex autoreview clean.
* fix(state): state read worker loads the whole Gateway graph (+486 MB RSS) (#161003) * fix(state): keep the state read worker out of the update write graph Move reconciliation inspection and candidate selection into a read-only module shared by the state reader and reconciliation writer. The standalone reader disables code splitting, so its former write-side import also bundled dynamic failure-fact/Doctor imports and the Gateway runtime. At release tip 56fb887, the built worker was 52,186,708 bytes with 9,768 esbuild inputs. After this split it is 3,491,598 bytes with 1,025 inputs, measured with packages external for both input graphs. Keep the read queries, eligibility checks, and transactional reconciliation bodies unchanged. The full build and 95 focused tests pass. * test(state): keep standalone workers out of the Gateway server graph Bundle each standalone entry with esbuild and reject transitive Gateway server, flow, wizard, in-process dispatch, and update-write inputs. Restoring the release-tip reader import and writer exports fails only the state reader with 682 forbidden inputs; the fixed graph passes all nine entries. Validation: pnpm test test/scripts/runtime-process-build-graph.test.ts --maxWorkers=1 (3.67s wall, 0.678s Vitest); negative control 3.732s wall. oxfmt, oxlint, and independent review pass. (cherry picked from commit f2715ed) * fix: retain SQLite workers through package replacement (#162076) Resolve read-only worker launches through the running updater's retained generation. Keep session reuse generation-aware and join child work before retiring its runtime files. This protects future self-updates; an already loaded 2026.9.6 driver retains its first-hop limitation. Refs #161865 (cherry picked from commit f59e979) * fix(update): retry the Windows backup rename on transient locks (#162231) On Windows the managed update swap renamed the live package tree to its backup location once; a transient EPERM/EBUSY/EACCES from an antivirus, indexer, or Scheduled Task handle failed the swap and rolled the update back. The filesystem owner of the swap now retries those codes with bounded backoff (16 attempts), records each retry, re-checks package identity and update authority between attempts, and reports a named failure after the bound. POSIX behavior is unchanged. Refs #162027 (cherry picked from commit b5555b0) * fix: avoid duplicate SQLite copies during update rehearsal (#162403) * fix: avoid duplicating SQLite snapshots during update rehearsal * test: target final snapshot publication in race hooks * test: exercise staging cleanup after snapshot transfer * docs: describe row-preserving update rehearsals (cherry picked from commit c77a055) * perf(update): allow native Git runtime directory copies (#162387) Co-authored-by: Peter Steinberger <[email protected]> (cherry picked from commit 1129326) * fix: prevent slow Gateway shutdown during memory sync (#162616) * fix(state): retain publication leases while Gateway drains * perf(state): preserve normal publication close scheduling (cherry picked from commit defb7cf) * perf(gateway): reduce session publication allocations and repeated redaction scans (#162810) Reduce repeated session-publication allocations and redaction prefilter scans at their lifecycle owners, preserving live recipient authority and byte-identical redaction. Validated with Node 24 and fork Bun tests, authority negative controls, fixture differential checks, pinned AWS kernel and three-round load benchmarks, a clean post-rebase spot quartet, and green exact-head CI. (cherry picked from commit 4e4e315) * fix(agents): bound the shell snapshot cache (#162967) snapshotCache in src/agents/shell-snapshot.ts was a process-wide Map that retained one entry per distinct cwd/environment key for the Gateway's lifetime, so long-running Gateways with many sessions grew without bound. The owner now reuses the existing LRU cache with a documented 128-entry limit; the active key stays cached and a miss recomputes. At 201k synthetic keys RSS fell from 265 MiB to 232 MiB and live heap from 74 MiB to 6 MiB. Closes #162582 (cherry picked from commit 24baf01) * improve: deliver sessions_send replies once (cherry picked from commit 84c6eb8) * fix: prevent delegated work from stopping silently (cherry picked from commit 4f0541e) * fix(update): canonicalize package activation paths * test(update): fix the Windows backup-rename regression on native Windows Inject the platform only into the backup-rename policy. Leave native filesystem staging, verification, and cleanup on the host platform so the Linux policy case reaches its injected EPERM on Windows. Preserve all existing failure, retry, rollback, and content assertions. Refs #162027. * fix(sessions): keep announce skip token private * test(sessions): avoid awaiting detached reply flow * test(ci): include infra in shared Windows partitions (#162310) * test(release): align backport companion expectations * test(sqlite): verify snapshot content receipts * test(subagents): align retired reply token expectations * test(release): align completion cutover integrations * test(release): recognize direct peer replies * test(release): align requester yield guidance * test(release): align direct session reply fixtures * fix(release): preserve session continuation authority * fix(codex): avoid startup app-server bursts for idle agents (#163129) Closes #163026 ## What Problem This Solves Fixes a burst of Codex app-server processes when a Gateway starts with many configured agents and explicit Codex homes. Thanks to @609NFT for reporting the remaining startup pressure after #162912. ## User Impact Idle agents no longer start catalog-only app-servers at Gateway activation. Explicit homes hydrate when an authorized catalog request first needs them, using the existing progressive loading behavior. Native turns remain available without prior catalog hydration. ## Why This Change Was Made A concurrency limit on initialization alone would still accumulate retained shared clients. Removing eager fleet hydration avoids both startup fanout and catalog-only retention without changing shared-client pooling, active-turn ownership, stored data, or cache schemas. The service still captures its background execution scope; on-demand catalog hydration and refresh keep their existing owner. No overlap with Pash/Sarah changes: their history on the touched documentation concerns output projection, scheduled app authority, Computer Use, and managed binary selection, not catalog activation. ## Evidence Real Gateway and packaged native Codex app-servers in an isolated Linux arm64/Node 24.21 container, with 739 synthetic agents and seven additional explicit homes: | Startup measurement | Main baseline | Candidate | | --- | --- | --- | | App-server processes spawned / peak live | 16 / 16 (8 wrapper/native pairs) | 0 / 0 | | Peak aggregate process RSS, 180-second window | 3,315,548 KiB | 1,744,276 KiB; repeat 2,247,344 KiB | | Gateway readiness | 77.84 seconds (earlier sample 78.42) | 78.78 seconds; repeat 80.97 | Readiness remains approximately 80 seconds; this does not claim a latency improvement. The synthetic profile demonstrates elimination of activation-driven native processes, not reproduction of the reporter's host OOM or blocked-egress timeout count. - On-demand catalog RPCs returned the exact three seeded session IDs for agents `agent000`, `agent001`, and `agent738`, including the normal cold `catalog_pending` transition. - Exact-head live gate: zero app-server processes before the request, then agent `agent738` completed a real `openai/gpt-5.4-mini` turn through the **codex** harness in 4.65 seconds with the expected reply. Utility-model jobs, heartbeat, cron, and model discovery were disabled; one inference turn. - Regression fails on the baseline because activation starts resident work; passes on the candidate and verifies that subsequent demand initializes the home. The stop, request-lifetime, homes, backoff, and listing-cache files pass: **41 tests**, 34.39 seconds wall total; the changed stop file's three tests took 136 ms. - `git diff --check` passes. - Inspected Codex app-server lifecycle at `codex-rs/app-server/src/lib.rs:244–307`: shutdown drains admitted turns. This fix does not alter that lifecycle or retire a sibling turn's shared connection. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit 01d479d) * test(release): make session describe drain bound structural * fix(release): complete session and drain backports * test(release): cover cron send cutover * test(release): align completion prompt expectations * refactor(gateway): satisfy line caps * test(gateway): remove stale fixture import * test(gateway): isolate heartbeat lifecycle cases * test(gateway): start lazy catalog hydration * test(ui): tolerate sub-pixel sidebar roster layout (#161068) (cherry picked from commit 4d638fd) * test(ui): stabilize model refresh tooltip hover --------- Co-authored-by: Peter Steinberger <[email protected]> Co-authored-by: Jason (Json) <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
What Problem This Solves
Update rehearsals copy an already-owned private SQLite image again and use VACUUM, which can renumber implicit row IDs.
User Impact
Snapshot publication transfers its verified private image through the existing exclusive publisher where hard links are supported. Rehearsals preserve row IDs. Public callers still receive an independent snapshot, and copy fallback remains available.
Capacity guards are unchanged, and fallback can temporarily require another image. This does not resolve the full update-space requirement. Installed 9.6 and published 9.7 drivers still run their older snapshot workers. The optimization needs a driver containing #162298 and does not retrofit the first update hop.
Why This Change Was Made
The snapshot owner can transfer its private image instead of copying it again. It retires the original private name only after matching exact nonzero device/inode identity and preserves the verified hash/size receipt from #162383. Migration rehearsals need a consistent image that preserves row IDs.
Evidence
The same 16 MiB fixture through
snapshotUpdateCandidateStateobserved 33,611,776 allocated bytes before and 16,809,984 after. These are checkpoint lower bounds, not whole-update peaks. Source bytes remained unchanged; rowid 71 stayed 71 instead of becoming 1. Snapshot time was 727.91 ms before and 412.33 ms after.Published candidate
9c5a3906982184d8bfd4e647b42bcd582da5136aintegrates canonicald0642be5bee9d2a812a85d0bf93527161ff54dda, including the landed progress and typed-lint repairs. Five full affected files passed 49/49, in 80.31 s through the native wrapper and 57.42 s in Vitest. The formerly failing text progress case passed in 6.94 s.Command:
node scripts/run-vitest.mjs src/cli/update-cli.admission-ledger.test.ts src/infra/update-candidate-state.cleanup.test.ts src/infra/sqlite-snapshot.transfer.test.ts src/infra/update-candidate-state.rowids.test.ts src/infra/sqlite-worker-identity.test.ts --maxWorkers=1.The original three-file typed-lint command passed cold in 10.36 s on that exact candidate. The native wrapper regenerated absent Kysely declarations. No manual warmup, focused-config bypass or preparation skip was used.
Earlier integrated
bc46e4f47f5167c714d57452d905f9413bba7e8epassed 137 focused snapshot/repository/backup/restore tests in 103.00 s, with three existing Windows-only skips on Darwin. Independent API proof on35811f7andbc46e4fcovered varied row IDs, contents/schema, source preservation, later-write independence, empty/corrupt inputs and cleanup. That evidence retains its original provenance.All five touched test files were audited in full. No test was removed, assertion weakened, skip added, or retry/timeout inflated. Independent production, correction and integration reviews found no remaining P0–P2 defect. Current integration leaves all seven authored source/test files byte-identical to the reviewed
077head. Fixtures and child processes settled, and consumed generated output was removed.Exact-head native typed build passed in 704.60 s; native
--skip-buildpackaging then passed all package integrity and bundled workspace dependency checks in 72.15 s. The 101,928,960-byte tarball SHA-256 wasb97c583fb1e724087d392c3bd899ff555a3e94bcfc4f7a4bfc63bd4de0055c80.Required published-updater compatibility passed in 472.96 s:
[email protected]→ exact9c5a3906982184d8bfd4e647b42bcd582da5136a, nativescripts/e2e/upgrade-survivor-docker.sh,basescenario, manual restart, Linux arm64. The initial update succeeded with no separate recovery update. Candidate and installed package identities matched; seeded state, automatic migration and unavailable-plugin configuration preservation passed. Startup took 18 s; health, readiness and RPC checks passed, reporting the exact candidate build.Exact-head hosted CI and required CI, dependency and security gates passed. The exact-head ClawSweeper review found no code or security defect; its outstanding compatibility requirement is now covered by the result above.
Diagnosed failures and corrections
bfd9f33in 29.74 s. Successful snapshots now fault remaining staging-directory retirement; versions/read-error cases retain payload-removal controls. Cancellation teardown joins children after early failure. The corrected af8 Windows job passed, without claiming its entire run green.54522d16,98421de8and4f34af88are integrated; current cold lint passes. Historical downstream failures and cancellations remain recorded.Phase: verifyingdespite successful completion and a complete final report. Canonical82fe5e962f72a54bc80c43cb9b2a116228bafb3bfixes reporter disposal before terminal publication. It is integrated, and the full affected test file now passes. Original failures and cancelled siblings remain historical evidence.Compatibility limits
The published 9.7 driver retains its original snapshot-worker selection. This successful compatibility cell does not demonstrate first-hop optimization, reduced capacity guards, whole-update peak allocation, rollback, CoW or Windows behavior. Native
firstHopPostCoreevidence was unavailable and was not replaced with a later recovery observation. Readiness returned HTTP 200 withready=trueand no failing checks, alongside a startup event-loop degradation advisory; no steady-state performance conclusion is drawn from that sample.Fresh canonical movement through
91e1bed6cdc6ba9ce3c019e0d03af1b99f7f5cd2is conflict-free. The snapshot publisher and rehearsal transfer path are unchanged. Reviewed movement affects separate maintenance-owner generation capture, Bun fixture preloading and the optional backup-schedule scenario. Dependency changes are outside the snapshot contract. The existing tested candidate is retained without rebasing unrelated main changes.