Skip to content

fix(update): reuse engine classification from backup generations - #184559

Merged
vincentkoc merged 4 commits into
mainfrom
fix/update-backup-engine-observation-20261026
Oct 26, 2026
Merged

vincentkoc merged 4 commits into
mainfrom
fix/update-backup-engine-observation-20261026

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Oct 26, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Automatic update backups acquire a private database image to identify its storage engine, then acquire another image for the before-capture generation check. That generation image already contains the authoritative engine classification. Reacquiring a large SQLite family adds avoidable copying and verification work.

User Impact

Healthy automatic SQLite capture removes one engine-only private image per database. Before/after generation checks, full snapshot integrity, WAL handling, inventory checks, and rollback admission remain intact. Stopped and manual original SQLite captures do not gain generation work.

The backup executor must contain this change. Upgrading to it does not replace an older installed driver's own capture implementation; no elapsed-time or physical-I/O saving is claimed.

Why This Change Was Made

The physical generation owner now returns its captured engine fact separately from the fallible local generation result. Backup reuses that classification, while PostgreSQL fingerprinting remains after whole-inventory custody admission. Invalid engine metadata stays fatal; unavailable generations retain the existing manual-recovery warning. A failed acquisition without an engine fact still uses the existing classification-only reader once. Generic missing-database generations remain null and retained recovery sidecars still refuse.

The added production code carries an existing producer fact and separates PostgreSQL completion from local observation; it adds no cache, schema, runtime option, or rollback capability.

Evidence

  • Extended the real retained-WAL backup regression to count source acquisitions and preserve committed rows, family bytes, and generation attribution. Stopped/manual cases verify no added generation acquisition.
  • Added focused cases for acquisition/settlement failure, strict classification plus cleanup errors, missing databases and retained sidecars, and both refused and admitted mixed SQLite/PostgreSQL inventories. PostgreSQL transport is mocked; SQLite images and integrity checks are real.
  • Independent owner-boundary review and scoped AutoReview found no actionable P0–P2 issue. Pinned repository formatting, privacy scan, and git diff --check passed.
  • CI exposed two fixture assumptions: the removed automatic image had supplied the debug message, and a low-level image counter also included the required final inventory image. The fixtures now use manual original capture for strict debug-output proof and count generation observations at their canonical owner. Strict zero/two generation expectations, engine-only acquisition counts, real WAL/row/identity assertions and JSON checks remain. A final shadowed callback binding was renamed; these corrections add no production behavior.
  • Exact-head CI at 764b029cd3df67d4fc446577d59c2fccc1b2fa7d passed all 168 tests across the eight owning/sibling files: backup-engine 9, backup 35, generations 26, restore 19, Git candidate 51, worker imports 1, loader runtime 10, and worker budget 17. The previously failing lint job is green. The complete CI run and published required openclaw/ci-gate subsequently passed at this exact head.
  • Exact-head ClawSweeper review has no findings or remaining Before merge/Rank-up items.
  • Local dependency-backed tests and red-on-base execution were not run. The code-only checkout has no qualified local dependencies; Testbox bootstrap refused stale tooling before allocation. Hosted exact-head execution supplies the scoped runtime/lint proof. No local runtime pass or baseline-red pass is claimed.
  • This PR's required published-driver compatibility cell has not been dispatched. The separate scheduling PR's cell, using baseline [email protected] / release 157d8c2bc3ea2fa183afdc11088e69690bf8e64e and candidate 89c02954831c80cfbb78bd79db40930a260955d5, failed on unresolved cron partition selection after candidate Doctor passed. That run is evidence of a shared compatibility blocker, not an executed result for this PR.

Inherited Compatibility Failure / Follow-up

Preserve the pre-relocation cron selector through the updater/candidate snapshot owner, with explicit compatibility for older published drivers. Source inspection shows that the published snapshot transport omits the original state/config selectors before the candidate migrates a relocated copy. Physical source paths cannot safely substitute for that fact in config-only overrides. Actual partition counts and absent-versus-invalid binding status in the failed cell remain UNKNOWN because its diagnostics were redacted/truncated. Do not infer a path binding or single-partition choice, change cron selection policy, write live state, or bump the schema. This separate contract repair is not included here. The frozen-base compatibility cell, using candidate 881caa4fd1945dc1d642165eceaed282b5922123 with the same published baseline/scenario/harness, reproduced the identical candidate-doctor-lint / heartbeat-retirement-inspection failure. The engine-observation change does not touch cron transport or migration. Maintainer landing assessment records this inherited failure alongside green exact-head required CI and 168 passing tests. This PR's own upgrade cell remains unrun; no successful upgrade, deployment, elapsed-time improvement, or physical-I/O saving is claimed.

Related scheduling fix: #184527

Classify automatic backup databases from the private generation image instead of capturing another engine-only image. Keep generation failures manual, engine failures fatal, and PostgreSQL fingerprinting behind whole-inventory custody admission. Stopped and manual original SQLite captures do not gain generation work.

Validation: independent source review and scoped autoreview P0-P2 clean; pinned formatting, privacy and diff checks pass. Normal hook refused its stale formatter donor; scoped bypass follows separate formatting proof. Focused runtime, types and lint require exact-head hosted CI. Real WAL operation-count and mixed-engine custody regressions are included; no elapsed-time or physical-I/O claim.
@vincentkoc vincentkoc self-assigned this Oct 26, 2026
@clawsweeper

clawsweeper Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review in progress

ClawSweeper is reviewing this revision. This supersedes any previous blocked status.

View the workflow run.

@vincentkoc
vincentkoc marked this pull request as ready for review October 26, 2026 11:21
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 26, 2026
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 26, 2026
@clawsweeper

clawsweeper Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR reuses engine classification from the database-generation image instead of acquiring a separate classification image during automatic update backups.

Example: Automatically back up state/openclaw.sqlite with committed rows retained in its WAL.

  • Before: Engine classification acquires an additional private image before the generation and backup captures.
  • After: Classification uses the first generation image while retaining snapshot integrity and before/after generation checks.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The implementation is focused and source review is clean, but execution evidence is still thin; persisted schemas, backup formats, and generation encoding are unchanged.
Proof confidence 🦪 silver shellfish (2/6) This maintainer-authored PR is outside the ordinary contributor-proof gate; its body supplies test scenarios but no completed changed-path execution result, and update compatibility validation remains pending.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Performance · Worth it: Yes · Fix scope: Complete
User problem: Automatic update backups perform an avoidable private-image acquisition for each database, adding work while handling potentially large stores.
Reason: The maintainer-authored direction removes demonstrably duplicated work while retaining the existing recovery safeguards and configuration.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR removes redundant backup work that remains on main, and source review found no actionable code defect.

Priority: P2
Reviewed head: 764b029cd3df67d4fc446577d59c2fccc1b2fa7d

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The published-driver × candidate update run preserving settings and database rows, plus red-on-base and green-on-head execution of the acquisition-count regression, remain unreported.
Agent review details

How this fits together

The update backup worker receives the discovered database inventory, captures verified recovery images, and returns snapshot metadata and generation fingerprints used by rollback admission.

flowchart TD
  A[Update driver] --> B[Backup worker]
  B --> C[Physical generation observation]
  C --> D[Engine classification and generation]
  D --> E[Inventory custody admission]
  E --> F[Verified recovery capture]
  F --> G[Snapshot metadata and rollback attribution]
Loading

Technical review

Best possible solution:

Carry the existing generation image's classification through backup capture while preserving strict engine validation, custody admission, and rollback attribution.

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

Source establishes the redundant acquisition: main classifies each database through readBackupEngine and then acquires a generation image that independently classifies it; no target code was executed during this read-only review.

Is this the best way to solve the issue?

The change follows the existing owners and removes the redundant acquisition without a cache or competing classification policy; each additional branch preserves a distinct failure or custody contract.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 9302c1147252.

Provenance checked

Testing

Proof path: none.

Security

None.

Evidence

What I checked:

  • Verified introduced change: The pinned introduction diff carries classification and generation results through the existing physical-generation owner; stopped and manual-original SQLite captures retain their classification-only path. (src/infra/update-database-backup.ts:310, 764b029cd3df)
  • Current main still performs redundant acquisition: Current main separately calls readBackupEngine for every present database and subsequently reads its before-capture generation; the affected production files have no base movement since the merge base. (src/infra/update-database-backup.ts:296, 9302c1147252)
  • Failure and custody contracts preserved: Classification failures remain fatal, unavailable generations retain manual-recovery warnings, and PostgreSQL fingerprinting remains after whole-inventory custody admission. (src/infra/update-physical-database-generations.ts:6, 764b029cd3df)
  • Distinct earlier optimization: The merged fix(update): avoid redundant database inspection copies #177524 removed unused parent-process classification; this PR removes a separate worker-side acquisition, while fix(update): defer database diagnostics until gateway readiness #184527 changes diagnostic scheduling. (src/infra/update-database-backup.ts:500, 954a610f5d0f)
  • Exact-head validation remains pending: Live check reads found no failed check, but runtime and contract checks remained unfinished and openclaw/ci-gate was pending; the full PR body explicitly reports runtime, red-on-base, and published-driver compatibility validation as pending. (764b029cd3df)
  • History and policy limits: Root policy was read and applied; neither src nor src/infra has an ancestor AGENTS.md, and .agents/maintainer-notes is absent. Follow-history encountered an unavailable historical blob; ordinary path history, the physical-generation creation diff, and current-main blame independently established the relevant ownership and intent. (AGENTS.md, 764b029cd3df)

Likely related people:

  • Peter Steinberger: Raw commit d0ea7ea adds src/infra/update-database-backup.ts:315 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: d0ea7eae7ead; files: src/infra/update-database-backup.ts)
  • Vincent Koc: Raw commit 954a610 adds src/infra/update-database-backup.ts:510 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 954a610f5d0f; files: src/infra/update-database-backup.ts)

PR surface

Source +72, Tests +299. Total +371 across 5 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 2 88 16 +72
Tests 3 299 0 +299
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 387 16 +371

Review metrics

Metric Value Why it matters
Production versus test LOC Production +88/−16; tests +299/−0 Production growth separates reusable classification from fallible generation settlement and deferred PostgreSQL fingerprinting; tests cover acquisition failure, cleanup, custody refusal, and retained recovery data.

Labels

Label changes:

  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🦪 silver shellfish, so this older rating label is no longer current.

Label justifications:

  • P2: Avoidable database-image acquisition increases update backup work, with limited scope and no demonstrated urgent availability regression.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish 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 execution lanes are retired.

History

Review history (2 earlier review cycles)
  • reviewed 2026-10-26T11:41:13.012Z sha 16bca19 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-26T11:55:58.855Z sha fef65d1 :: needs maintainer review before merge. :: none

Reviewed October 26, 2026, 8:12 AM ET / 12:12 UTC (Revision 3).

@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 26, 2026
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 26, 2026
@vincentkoc
vincentkoc merged commit c73495d into main Oct 26, 2026
155 checks passed
@vincentkoc
vincentkoc deleted the fix/update-backup-engine-observation-20261026 branch October 26, 2026 14:01
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 27, 2026
…nclaw#184559)

* fix(update): reuse backup engine observations

Classify automatic backup databases from the private generation image instead of capturing another engine-only image. Keep generation failures manual, engine failures fatal, and PostgreSQL fingerprinting behind whole-inventory custody admission. Stopped and manual original SQLite captures do not gain generation work.

Validation: independent source review and scoped autoreview P0-P2 clean; pinned formatting, privacy and diff checks pass. Normal hook refused its stale formatter donor; scoped bypass follows separate formatting proof. Focused runtime, types and lint require exact-head hosted CI. Real WAL operation-count and mixed-engine custody regressions are included; no elapsed-time or physical-I/O claim.

* test(update): preserve real worker logging coverage

* test(update): count generation observations at their owner

* test(update): avoid shadowed generation path binding
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. 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