Repository navigation
fix: keep update verification working after package replacement - #162076
Conversation
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
|
🦞👀 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 September 30, 2026, 3:31 PM ET / 19:31 UTC. ClawSweeper reviewWhat this changesThe branch launches SQLite read-only workers from the updater’s retained package files, joins their work before cleanup, adds a package-removal regression test, and documents the older-updater limit. Merge readiness⛔ Blocked before merge - 2 items remain Current main still uses the old SQLite worker launch path, so this focused repair remains useful. A broader open PR overlaps with it but has a separate blocking updater finding and is not a safe replacement. Priority: P0 Review scores
Verification
How this fits togetherThe CLI updater replaces the installed package and verifies it while managing the Gateway. Verification reads SQLite state through child workers whose code must remain available until their work finishes. flowchart LR
A[Installed updater] --> B[Retain package files]
B --> C[Replace package]
C --> D[Post-install verification]
D --> E[SQLite worker launch]
B --> E
E --> F[Read result and cleanup]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +26, Tests +83, Docs +5. Total +114 across 4 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep SQLite worker launches under the retained-generation owner, verify the upgrade boundary for this candidate, and provide installer-owned in-product recovery for users on immutable older drivers. Do we have a high-confidence way to reproduce the issue? Yes at the worker boundary: remove the loaded package after retention, then request another SQLite inspection. The exact pnpm-global, systemd first hop was observed in the linked issue but was not rerun in this read-only review. Is this the best way to solve the issue? Yes for future updater generations: the patch uses the existing retained-generation owner for launch and cleanup. Older installed drivers require a separate recovery path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 49576e21354f. LabelsLabel 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
|
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 openclaw#161865
* 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]>
Refs #161865
What Problem This Solves
Post-install verification can launch a SQLite read-only worker from the package generation that the package manager just removed, interrupting a self-update after the Gateway has stopped.
User Impact
Future updates started by a runtime containing this fix keep SQLite inspection workers available through package replacement and verification.
Known first-hop limitation: an already-installed 2026.9.6 driver continues executing its original worker-launch code. It reads recovery state before starting the candidate Doctor, so installing a corrected candidate cannot repair that already-loaded driver. This limitation is accepted for this repair, consistent with the first-hop decision in #161257. The issue remains open; a pnpm-global published-driver harness is a named follow-up.
Why This Change Was Made
SQLite launches now consume the existing retained-generation owner. Session compatibility includes generation identity, so a pre-retention session is replaced when necessary. One-shot children and session operations settle before their retained files are removed.
Production grows by 26 lines (+43/−17) to carry that identity and join child lifetimes; redirecting only the filename would leave session reuse and cleanup incomplete. The regression adds 83 test lines, with 5 documentation lines. No dependencies, schemas, public options, or package versions change.
Evidence
tbx_01m3sr7cet30rc53khc8ajspce), Node 24.19.0: the regression fails on the original source withMODULE_NOT_FOUNDafter package removal and passes with the repair. Passing regression time: 142–160 ms. The isolated pre-fix control took 24.50 s wall, dominated by shared worker preparation.node scripts/check-changed.mjspassed against the pinned baseline, including core types, all 27 test-type graphs, lint, and static guards. The final Testbox command exited 0.Separate performance follow-up:
src/commands/doctor-maintenance.requester-authority.test.ts/keeps configured-owner requester authority live through maintenance and revocationexceeded the slow-test threshold (32.056 s). Diagnostic phase timing measured 34.416 s: fixture seed 90 ms, requester capture 305 ms, migration 5.632 s, successful config write 27.113 s with 339 authority callback invocations. The repeated live-policy/snapshot work needs a separate owner performance repair; no assertions, retries, or timeouts were weakened.