Skip to content

fix(update): bound private SQLite snapshot amplification during candidate validation on a live install - #167451

Merged
steipete merged 2 commits into
mainfrom
upd/upd-snapshot-amplification
Oct 8, 2026
Merged

steipete merged 2 commits into
mainfrom
upd/upd-snapshot-amplification

Conversation

@steipete

@steipete steipete commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Read-only candidate checks can copy the updater's already-prepared SQLite image again for each reader. Five overlapping inspections of a synthetic database with 1 GiB of payload retained six database copies until their scope closed. This amplifies temporary storage even though cleanup eventually succeeds.

Refs #160483, Refs #155902. Thanks @iFadi for the live-install capacity evidence; related cleanup report: #157712.

User Impact

Candidate read-only inspections reuse the prepared database. Snapshot capacity errors include estimated bytes needed, available bytes, and observed live WAL sidecars. Candidate snapshot ENOSPC/EDQUOT failures recommend freeing snapshot space and retrying the update, without recommending schema repair on the serving installation.

Why This Change Was Made

SQLite's consistent online backup already exists in v2026.9.9. Current main also removes duplicate rehearsal publication copies and handles an inactive WAL becoming active. The remaining reuse fix belongs to the read-only openers: recognize the complete isolation contract shipped by the 2026.9.4 updater, check physical containment of the main file and every sidecar, and retain read-only scope cleanup and write guards. External paths and escaping symlinks keep artifact-preserving copies. Explicit independently mutable snapshots keep their existing ownership.

The trusted wrapper's extraction manifest also includes the newly imported rehearsal boundary helper. No schema, dependency, configuration, CLI, or environment options change. The raw-copy cleanup-refusal case is separately owned by #167027.

Evidence

  • Synthetic 1 GiB payload with an independent checkpointing WAL writer: the original reader owner retained six images / 6,455,149,505 logical staged bytes for five overlapping readers; the candidate retained one / 1,075,590,656 bytes. Elapsed: 8.55 s versus 4.07 s. Integrity passed, readers closed, and staging was empty afterward. These are logical file sizes on macOS/APFS, not physical ext4 allocation measurements or a complete Debian update reproduction.
  • Raw artifact-preserving stress reproduced ten attempts and refusal under WAL checkpoint churn; peak was one staged database (1,075,585,536 bytes), with no residue. Online backup succeeded in one attempt while the writer continued. Rehearsal source snapshots are sequential; Gateway agent schema inspection has a concurrency limit of two.
  • Reuse and capacity diagnostics failed on the original code. Three touched-suite runs each passed 31 tests, with one existing Linux-only skip. Combined wall times: 39.48 s, 18.81 s, 18.98 s; per-file test time stayed below 5.2 s.
  • node scripts/check-changed.mjs passed for the core/docs, wrapper manifest, and QA changes, including extension production/test typechecks and native extension lint. The final capacity-before-cleanup ordering change also passed focused lint, core typecheck, both affected test typecheck graphs, and the three final test runs.
  • The direct candidate worker online-backup suite passed both cases (snapshot and discovery) while the independent writer advanced; wrapper wall time was 11.50 s.
  • All 546 selected direct/one-barrel importer files are accounted for: 8,137 passed tests and 17 existing conditional skips, including repaired failures. The sweep caught a missing trusted-wrapper dependency; the manifest repair passed its 20 extraction and bootstrap tests.
  • The same sweep exposed a QA fixture holding its reserved port during packaged auth bootstrap. Release now precedes bootstrap, with a shared free-port assertion. The strengthened fixture failed six cases before the repair; three repaired Gateway-child runs each passed 72 tests (one existing skip), in 72.20 s, 80.06 s, and 86.62 s. Both real-Gateway media browser scenarios passed. PowerPoint completed in 85.1 s instead of failing bootstrap at 5.8 s.
  • Pre-existing slow suites were retained: the worker-artifact file reported about 159 s of test time, and paired-node lifecycle reported 323.199 s (one case 242.516 s). Browser setup also emitted a report-only startup JavaScript budget warning (373,710 B versus 373,454 B); no budget or baseline was changed. Hosted CI time is not yet available.
  • Diff: production +68/−22, tests/support +210/−10, tooling manifest +1/−0, docs +9/−0. All proof ran locally with isolated state.
  • P1 autoreview was attempted; the diagnostic retry confirmed HTTP 401 Unauthorized. No review verdict was produced. Maintainer review of the PR head remains pending.

Keep candidate read-only inspections on the existing rehearsal image while retaining write guards and physical path containment. Report snapshot capacity before cleanup and avoid serving-schema repair advice for candidate-only capacity failures.

Refs #160483, Refs #155902. Thanks @iFadi for the live-install capacity evidence.
Let packaged bootstrap commands verify the configured port is offline before a source rebuild. Check port availability for mock auth as well as plugin repair, preserving the runtime publication guard.
@clawsweeper

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

@steipete
steipete marked this pull request as ready for review October 8, 2026 20:54
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation scripts Repository scripts extensions: qa-lab size: M labels Oct 8, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 8, 2026
@clawsweeper

clawsweeper Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

The branch reuses prepared SQLite databases during isolated update validation, adds snapshot-capacity diagnostics, and releases the QA Gateway port before packaged authentication bootstrap.

Example: Five inspections overlap while validating a candidate with a 1 GiB database

  • Before: The reported baseline retains six database images totaling 6,455,149,505 logical staged bytes.
  • After: The reported candidate retains one image totaling 1,075,590,656 logical staged bytes.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Useful, focused owner-level code with meaningful runtime observations, but incomplete proof at the required published update boundary.
Proof confidence 🦐 gold shrimp (3/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Partial
User problem: Update validation can consume several additional database-sized temporary copies even after the updater has prepared an isolated image.
Reason: The repair removes a measured storage cost using existing owners and an established isolation contract. Its references appropriately avoid claiming complete resolution of the broader live-update and residual-copy reports.

Merge readiness

✅ Ready for maintainer review

This PR contains useful work that current main does not provide. No definite introduced code defect was found, and the related cleanup PR addresses a different failure.

Priority: P2
Reviewed head: f2a118d6ac9a164568ed946f4408a53140be764f

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: Show a published 2026.9.4 updater driving this candidate's prepared-database validation, with bounded staging, serving-state preservation, and completed reader cleanup; no such differential run is recorded.
Agent review details

How this fits together

The updater prepares private copies of installed databases so candidate migrations and startup checks can run without changing the serving installation. Read-only database openers select the inspection source and retain responsibility for closing their readers.

flowchart TD
  A[Installed databases] --> B[Updater prepares private copies]
  B --> C[Candidate validation]
  C --> D{Complete isolation markers and contained database family?}
  D -->|Yes| E[Read prepared database]
  D -->|No| F[Create artifact-preserving snapshot]
  E --> G[Close inspection readers]
  F --> G
  F --> H[Report capacity and recovery guidance]
Loading

Technical review

Best possible solution:

Keep reuse in the existing read-only owners, preserve external-source artifact protection, and retain separate tracking for live-update failures and cleanup leaks beyond this repair.

Do we have a high-confidence way to reproduce the issue?

Yes for redundant copies: current main unconditionally snapshots each artifact-preserving agent opener, and the supplied overlapping-reader experiment reports the resulting amplification. The complete Debian update failure was not reproduced.

Is this the best way to solve the issue?

Yes for the bounded copy-amplification problem: recognizing the existing private rehearsal contract at the read-only owners avoids another snapshot implementation and preserves explicit snapshot ownership.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 0f56d2e3d9b8.

Provenance checked

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

  • Current main still makes the additional copy: At fetched main, the artifact-preserving agent opener unconditionally calls prepareSqliteReadOnlyLocationSync. The introduced branch makes that copy conditional on the existing rehearsal isolation contract. (src/infra/sqlite-snapshot-source.ts:57, 0f56d2e3d9b8)
  • Reuse retains the inspection boundary: The agent opener forces readOnly:true and retains scope-owned closure. Shared-state inspection avoids cached writer reuse, while the eligibility helper checks the database and WAL, SHM, and journal paths. (src/infra/sqlite-snapshot-source.ts:60, f2a118d6ac9a)
  • Existing isolation design: fix(update): keep the rehearsal Doctor from retiring workspace files outside the rehearsal root #145606 established recognition of the isolation environment already shipped by older update drivers and preservation of external workspace paths. The branch consumes that existing contract. (src/infra/update-rehearsal-paths.ts:35, fde94351cacb)
  • Published driver markers checked: The released v2026.9.4 rehearsal producer sets the private HOME, state, cache, workspace, skipped-service, and external-repair environment values recognized by the candidate helper. This establishes source compatibility, not execution of the published-driver boundary. (src/infra/update-candidate-rehearsal.ts, 0f56d2e3d9b8)
  • Recorded after-fix observations: The supplied complete PR body reports a real independent checkpointing WAL writer, six-to-one image reduction, integrity success, reader closure, and empty staging afterward. It also explicitly limits the result to logical macOS/APFS sizes rather than the Debian update reproduction. Captured body source identity: da40d4c65ad449109046936646c07b1e9a546a2b9b011322e654d19fd24809c2. (f2a118d6ac9a)
  • Required update proof: Root policy requires a published-driver × candidate cell for update changes. The supplied proof covers production reader stress, candidate workers, tests, and QA browser scenarios, but does not record that cell for this change. (AGENTS.md, f2a118d6ac9a)

Likely related people:

  • Peter Steinberger: Raw commit fde9435 adds src/infra/update-rehearsal-paths.ts:35 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: fde94351cacb; files: src/infra/update-rehearsal-paths.ts)

PR surface

Source +46, Tests +200, Docs +9, Other +1. Total +256 across 13 files. Added test files: 2.

View PR surface stats
Area Files Added Removed Net
Source 7 68 22 +46
Tests 4 210 10 +200
Docs 1 9 0 +9
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 0 +1
Total 13 288 32 +256

Labels

Label changes:

  • add P2: The measured extra-copy cost warrants a bounded update-validation repair, while attribution of the broader released update blocker remains incomplete.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: The measured extra-copy cost warrants a bounded update-validation repair, while attribution of the broader released update blocker remains incomplete.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only; repair and merge need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

Reviewed October 8, 2026, 5:02 PM ET / 21:02 UTC.

@steipete
steipete merged commit 0ac773b into main Oct 8, 2026
231 of 235 checks passed
@steipete
steipete deleted the upd/upd-snapshot-amplification branch October 8, 2026 21:15
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 9, 2026
RomneyDa pushed a commit that referenced this pull request Oct 14, 2026
…date validation on a live install (#167451)

Refs #160483
Refs #155902

Reported by @iFadi.
(cherry picked from commit 0ac773b)
Backport adaptation: the release line has no agent-scoped artifact-preserving reads (openSqliteReadOnlyDatabase) or inspection write guard, so only the shared-state rehearsal snapshot reuse, capacity diagnostics, and admission guidance were ported; the rehearsal test and docs cover shared state only.
RomneyDa added a commit that referenced this pull request Oct 29, 2026
* fix(update): backport safe validation and recovery reports to 2026.9.x

Adapt #167451 and #170130 to the September shared-state reader architecture.
Reuse isolated rehearsal images, capture authored config without reopening
migrated state, preserve candidate-owned verification, and retain actionable
snapshot-capacity diagnostics. Keep saved outcomes and rollback restrictions.

Require distinct known versions before reconciling runtime recovery advice;
version-only health cannot identify a changed Git commit at the same version.

Adapted from Peter Steinberger authored main commits:
- 0ac773b
- d128f0d
Using older-line adaptation 47538fa from #170736 / #170753.

* test(release): consolidate September survivor and lifecycle fixtures

Keep the shell survivor roster canonical, preserve bounded/redacted Doctor
lint and redirected failure evidence, and reset stale attempt logs. Share the
September Chokidar fixture and await real cleanup recovery config settlement.
Do not import October-only observer/startup-maintenance features.

Adapted from Dallin Romney authored source proposals:
f13af59
cd3346e
6dd10c2
5f40bd0

Consolidates relevant subsets of #166817, #166828, #166855, #166882, #166892.

* test(ui): isolate September font fixtures before each case

Backport only the font fixture reset from 9ef8502
as carried by #166813 and #166890. Preserve the September theme inventory.

* fix: compose 2026.9.36 release validation security candidate

Preserve the prepared release validation composition; adopt pinned ClawHub materialization and compatibility-tested tool and runtime dependency security repairs. Remaining audit and review limitations are recorded in the external release audit evidence.

Co-authored-by: RomneyDa <[email protected]>

* fix: complete release security dependency and workflow repairs

Repair embedded Mermaid/KaTeX assets, migrate the coherent Vitest security cohort, and retain trusted workflow data boundaries.

Co-authored-by: RomneyDa <[email protected]>

* fix(release): restore original bounded scope of #186177

Preserve all original and security history while reducing this PR to the conflict-free merge of original head 32665a0 and release base e93b50a. Removed work remains in ancestor commits and local split evidence. Scope reduction does not certify full composition or waive unresolved review gates.

Co-authored-by: RomneyDa <[email protected]>

* fix(update): preserve unsafe Doctor recovery guidance

Co-authored-by: RomneyDa <[email protected]>

* test(update): adapt Doctor custody regression harness

Co-authored-by: RomneyDa <[email protected]>

---------

Co-authored-by: Peter Steinberger <[email protected]>
Co-authored-by: roboclaw-bot <[email protected]>
Co-authored-by: RomneyDa <[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 extensions: qa-lab P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts 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