Skip to content

fix: avoid duplicate SQLite copies during update rehearsal - #162403

Merged
fuller-stack-dev merged 12 commits into
mainfrom
fix/update-single-generation
Oct 1, 2026
Merged

fuller-stack-dev merged 12 commits into
mainfrom
fix/update-single-generation

Conversation

@fuller-stack-dev

@fuller-stack-dev fuller-stack-dev commented Oct 1, 2026 •

Copy link
Copy Markdown
Member

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 snapshotUpdateCandidateState observed 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 9c5a3906982184d8bfd4e647b42bcd582da5136a integrates canonical d0642be5bee9d2a812a85d0bf93527161ff54dda, 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 bc46e4f47f5167c714d57452d905f9413bba7e8e passed 137 focused snapshot/repository/backup/restore tests in 103.00 s, with three existing Windows-only skips on Darwin. Independent API proof on 35811f7 and bc46e4f covered 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 077 head. Fixtures and child processes settled, and consumed generated output was removed.

  • Exact-head native typed build passed in 704.60 s; native --skip-build packaging then passed all package integrity and bundled workspace dependency checks in 72.15 s. The 101,928,960-byte tarball SHA-256 was b97c583fb1e724087d392c3bd899ff555a3e94bcfc4f7a4bfc63bd4de0055c80.

  • Required published-updater compatibility passed in 472.96 s: [email protected] → exact 9c5a3906982184d8bfd4e647b42bcd582da5136a, native scripts/e2e/upgrade-survivor-docker.sh, base scenario, 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

  • Initial CI exposed repository race hooks intercepting private transfer instead of final publication. All three hooks now select the canonical repository entry and retain their error, foreign-byte and cleanup assertions.
  • Windows CI exposed three cleanup hooks faulting a consumed payload. All three reproduced on unchanged bfd9f33 in 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.
  • ff91 lint failure reproduced three diagnostics from missing generated Kysely declarations. Canonical repairs 54522d16, 98421de8 and 4f34af88 are integrated; current cold lint passes. Historical downstream failures and cancellations remain recorded.
  • 077 progress failure omitted Phase: verifying despite successful completion and a complete final report. Canonical 82fe5e962f72a54bc80c43cb9b2a116228bafb3b fixes 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 firstHopPostCore evidence was unavailable and was not replaced with a later recovery observation. Readiness returned HTTP 200 with ready=true and no failing checks, alongside a startup event-loop degradation advisory; no steady-state performance conclusion is drawn from that sample.

Fresh canonical movement through 91e1bed6cdc6ba9ce3c019e0d03af1b99f7f5cd2 is 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.

@clawsweeper

clawsweeper Bot commented Oct 1, 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.

@fuller-stack-dev
fuller-stack-dev marked this pull request as ready for review October 1, 2026 04:45
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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 Oct 1, 2026
@clawsweeper

clawsweeper Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed October 1, 2026, 5:26 AM ET / 09:26 UTC (Revision 7).

ClawSweeper review

What this changes

The 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
Reviewed head: 9c5a3906982184d8bfd4e647b42bcd582da5136a

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The focused implementation and snapshot evidence are strong, with one material updater compatibility requirement still outstanding.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): Recorded production API proof exercises snapshotUpdateCandidateState on a real SQLite fixture and shows reduced checkpoint allocation, preserved sparse row IDs, and unchanged source bytes; prior API evidence also covers independence and failures. The stronger repository-required published-updater handoff remains outstanding in risks. No stored schema or serialized-format contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): Recorded production API proof exercises snapshotUpdateCandidateState on a real SQLite fixture and shows reduced checkpoint allocation, preserved sparse row IDs, and unchanged source bytes; prior API evidence also covers independence and failures. The stronger repository-required published-updater handoff remains outstanding in risks. No stored schema or serialized-format contract changes.
Evidence reviewed 8 items Pinned introduced changes: Reviewed the merge-base-to-head delta. Private transfer is enabled only inside snapshot creation; the exported publisher retains independent-copy behavior.
Current main still needs the change: Fetched main still copies the prepared image through copyFileExclusive, and its rehearsal caller omits preserveRowIds. The provided merged prerequisites address worker selection and verified receipts, rather than implementing this optimization.
Re-review continuity: All seven introduced source/test files are unchanged from the preceding reviewed head; only the updating guide differs. Repository race hooks now select final repository entries, and the guide accurately describes row-ID preservation.
Findings None None.
Security None None.

How this fits together

Update 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]
Loading

Before merge

  • Resolve merge risk (P1) - The published-updater-to-exact-candidate flow using existing operator state has not been demonstrated; snapshot API proof does not establish that rehearsal, activation, migration, and recovery remain compatible.
  • Complete next step (P2) - Record the repository-required published-updater-to-exact-candidate compatibility result using existing operator state before merge.
Agent review details

Security

None.

PR surface

Source +53, Tests +343, Docs 0. Total +396 across 8 files.

View PR surface stats
Area Files Added Removed Net
Source 2 80 27 +53
Tests 5 353 10 +343
Docs 1 2 2 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 8 435 39 +396

Review metrics

Metric Value Why it matters
Production and regression growth production +53 net lines; tests +343 net lines Production growth implements private transfer and ownership checks; regression growth covers isolation, fallback, cleanup, and rehearsal row IDs.
Observed allocation checkpoint 33,611,776 → 16,809,984 allocated bytes The recorded same-fixture result supports reduced duplicate allocation, without claiming a whole-update peak reduction.

Merge-risk options

Maintainer options:

  1. Complete the updater compatibility cell (recommended)
    Record a published updater running against this exact candidate with existing operator state and verify successful completion and state preservation.

Technical review

Best 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.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a bounded updater storage and rehearsal-correctness repair without evidence of an urgent introduced outage.
  • merge-risk: 🚨 compatibility: The changed snapshot lifecycle participates in installed updates, whose published-driver handoff remains unverified for this candidate.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): Recorded production API proof exercises snapshotUpdateCandidateState on a real SQLite fixture and shows reduced checkpoint allocation, preserved sparse row IDs, and unchanged source bytes; prior API evidence also covers independence and failures. The stronger repository-required published-updater handoff remains outstanding in risks. No stored schema or serialized-format contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. Recorded production API proof exercises snapshotUpdateCandidateState on a real SQLite fixture and shows reduced checkpoint allocation, preserved sparse row IDs, and unchanged source bytes; prior API evidence also covers independence and failures. The stronger repository-required published-updater handoff remains outstanding in risks. No stored schema or serialized-format contract changes.

Evidence

What I checked:

  • Pinned introduced changes: Reviewed the merge-base-to-head delta. Private transfer is enabled only inside snapshot creation; the exported publisher retains independent-copy behavior. (src/infra/sqlite-snapshot.ts:344, 9c5a39069821)
  • Current main still needs the change: Fetched main still copies the prepared image through copyFileExclusive, and its rehearsal caller omits preserveRowIds. The provided merged prerequisites address worker selection and verified receipts, rather than implementing this optimization. (src/infra/sqlite-snapshot.ts:374, 3862ade452e3)
  • Re-review continuity: All seven introduced source/test files are unchanged from the preceding reviewed head; only the updating guide differs. Repository race hooks now select final repository entries, and the guide accurately describes row-ID preservation. Public docs: docs/install/updating.md. (docs/install/updating.md:394, 9c5a39069821)
  • Recorded production-boundary proof: The captured PR body records a 16 MiB fixture exercised through snapshotUpdateCandidateState: allocated bytes at the observed checkpoint fell from 33,611,776 to 16,809,984, source bytes stayed unchanged, and rowid 71 remained 71. Earlier API proof retains its original commit identities; current-head focused validation reports 49 passing tests. These observations do not establish whole-update peak allocation or an installed-updater handoff. (src/infra/update-candidate-state.ts:669, 9c5a39069821)
  • Required upgrade evidence remains outstanding: The full root policy requires a published-driver × candidate cell for update changes. The captured body explicitly says this cell has not run. Compatibility proof for fix(update): bind rollback backups to verified snapshot bytes #162383 exercised a different candidate and cannot satisfy this PR's handoff requirement. The body also correctly states that published older drivers retain their original first-hop snapshot workers. (AGENTS.md, 9c5a39069821)
  • Publication dependency contract inspected: The introduced transfer calls publishFileExclusive through OpenClaw's directory-durability adapter, establishing a direct dependency signal. npm metadata verifies openclaw/fs-safe ownership; the published 0.21.3 implementation was read in memory. It pins source and parent identities, publishes exclusively, permits copy fallback, verifies copied content, and returns a durability receipt. No dependency code was executed or installed.

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Add the published-updater-to-exact-candidate result using existing operator state.

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 (6 earlier review cycles)
  • reviewed 2026-10-01T05:00:51.047Z sha 35811f7 :: needs changes before merge. :: [P2] Restrict repository race hooks to final entry publication
  • reviewed 2026-10-01T05:10:15.489Z sha bfd9f33 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-01T05:23:05.325Z sha af8c565 :: needs changes before merge. :: [P3] Update the rehearsal guide to remove the compaction claim
  • reviewed 2026-10-01T05:34:56.932Z sha ff91f52 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-01T05:47:45.770Z sha ff91f52 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-01T08:05:28.908Z sha 077342a :: blocked before merge. :: none

@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Fixed the P2 race-hook finding in 830027a6c, included in published head bfd9f33a42d7cd60b9a0c0b21ee4e9a6905dd949. All three affected hooks now require the canonical repository-entry grandparent, including the previously passing post-link inspection case. Original error assertions, foreign sentinel bytes and cleanup assertions are unchanged.

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.

@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 Oct 1, 2026
@openclaw-barnacle openclaw-barnacle Bot added the docs Improvements or additions to documentation label Oct 1, 2026
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

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

@clawsweeper

clawsweeper Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@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 Oct 1, 2026
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Published reviewed integration 077342a9329da98ea23a82f1df7e599b57664708. The landed Kysely prerequisites now pass the original cold three-file lint command in 10.89 s, and affected cleanup/transfer/row-ID suites pass 35/35 in 50.56 s. No production or fixture correction was added in this conflict-free canonical integration. The body preserves prior proof and diagnosed failures. New CI reports the separately owned progress lifetime defect from #162464; required CI is still failed and no merge is requested here.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. labels Oct 1, 2026
@fuller-stack-dev
fuller-stack-dev merged commit c77a055 into main Oct 1, 2026
142 checks passed
@fuller-stack-dev
fuller-stack-dev deleted the fix/update-single-generation branch October 1, 2026 10:39
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Merged via squash.

steipete added a commit that referenced this pull request Oct 2, 2026
…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.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 2, 2026
…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
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 2, 2026
…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.
RomneyDa added a commit that referenced this pull request Oct 2, 2026
* 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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