Skip to content

fix(update): honor server recovery captures in supervised migrations - #198435

Closed
qingminglong wants to merge 1 commit into
openclaw:mainfrom
qingminglong:pr/update-migrate-server-captures
Closed

qingminglong wants to merge 1 commit into
openclaw:mainfrom
qingminglong:pr/update-migrate-server-captures

Conversation

@qingminglong

Copy link
Copy Markdown
Contributor

Closes #198334

What Problem This Solves

Fixes: during a supervised migration (oc update migrate path), the database backup is created without the postgresSchemaCaptures setting, so a configuration with database.postgres.recoveryCaptures: "server" produces local exports for non-state PostgreSQL stores and leaves behind an ambiguous recovery set instead of the server captures the recovery inventory expects.

User Impact

When recovery captures are configured as server, a supervised migration now backs up non-state PostgreSQL stores on the database (server captures), matching what the native update path already does and what the recovery inventory expects to find. No configuration change, migration, or user action is required; behavior is unchanged for every other recoveryCaptures setting.

Why This Change Was Made

The native update path passes postgresSchemaCaptures: source.config.database?.postgres?.recoveryCaptures === "server" to createUpdateDatabaseBackup, but the supervised migration path (updateMigrateCommand) omitted the flag entirely. The two paths therefore disagreed about where non-state PostgreSQL stores live after a backup: the migration wrote local exports while recovery tooling expected server captures, which surfaces as ambiguous recovery sets and failed Doctor finalization during update repair. The fix forwards the same flag from the same config source, restoring parity between the two update paths; no other backup options or migration steps are touched.

Evidence

  • Regression tests red→green: "honors the configured recovery captures in the migration database backup (server)" and "(portable)" in src/cli/update-cli/update-command-migrate.test.ts fail on main (expected postgresSchemaCaptures === true, received undefined) and pass with the fix. Command: node scripts/run-vitest.mjs run src/cli/update-cli/update-command-migrate.test.ts — before: 2 passed / 16 failed; after: 4 passed / 16 failed (the same 16 failures, unchanged).
  • Related targeted suites: the other 16 failures in that file are pre-existing and unrelated to this change — they fail identically before and after the fix with local-filesystem environment errors (FsSafeError path-mismatch, a linkedom entities/decode export resolution error) on this Windows contributor machine; the failing set is byte-identical across the red and green runs, which is the relevant comparison.
  • Behavior verification: the new tests assert createUpdateDatabaseBackup receives postgresSchemaCaptures: true when recoveryCaptures: "server" in both server and portable configurations; on main the option arrives as undefined, with the fix it arrives as true.
  • Scope: one production file (update-command-migrate.ts, 4 added lines forwarding the existing config flag) plus two regression test cases (31 added test lines). The native update path, backup implementation, and all other migration steps are untouched.
  • Repo checks: oc.sh check — oxlint 0 errors on changed files; tsgo -p tsconfig.core.json reports 63 errors vs the documented 64-error baseline (none in changed files); test-lines ratchet vs upstream/main passes.

@clawsweeper

clawsweeper Bot commented Nov 13, 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.

@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes size: XS labels Nov 13, 2026
@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. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. 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 Nov 13, 2026
@clawsweeper

clawsweeper Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR makes supervised migration honor the existing PostgreSQL server-recovery-capture setting.

Example: Run supervised migration with database.postgres.recoveryCaptures set to "server" and a PostgreSQL Workboard store.

  • Before: The rollback backup exports the Workboard rows to a local database.sqlite image.
  • After: The backup keeps the Workboard rows in a server-side restore_<uuid> schema.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The useful option forwarding leaves a concrete server-capture lifecycle defect, and the supplied tests do not exercise the changed database behavior.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦪 silver shellfish (2/6) 2 actionable review findings remain.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Partial
User problem: Supervised PostgreSQL updates ignore the selected server-capture policy, increasing stopped time and local disk usage.
Reason: The documented existing option establishes useful bug-fix scope, but this change does not establish resolution of the linked Doctor-finalization incident.

Merge readiness

⛔ Blocked before merge - 5 items remain

Keep open: the omitted option is a real current-main bug, but enabling server captures without retiring them leaks PostgreSQL schemas after successful supervised updates.

Priority: P2
Reviewed head: c09d6e84cdf9dda6bbb3809c495ce074e52b1ea1

Before merge

  • Add real behavior proof - The contributor supplies mocked backup-argument assertions, with no after-fix supervised CLI run demonstrating server capture creation, restoration, or retirement; redact IPs, API keys, phone numbers, and non-public endpoints from supplied evidence. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.
  • Retire server capture schemas before deleting their manifests (P2) - With recoveryCaptures set to "server" and a non-state PostgreSQL store, this option creates a full restore_<uuid> schema. After successful migration, updateFinishCommand still removes receipt.backup.directory at line 485 without calling discardPostgresSchemaCaptures. Each accepted supervised update therefore leaves its server-side database copies behind and deletes the manifests needed by the existing retirement owner. Invoke that owner before directory removal, retain the directory when dropping fails, and preserve finish retry behavior.
  • Remove the unsupported repair-incident closing claim (P2) - Merging this PR would automatically close [Bug]: Update repair fails during Doctor finalization on 2026.11.1 #198334, but that report's initiating failure remains unknown in the collaborator discussion. The patch only changes capture placement; it neither diagnoses nor repairs interrupted Doctor finalization or existing ambiguous recovery sets. Use a non-closing relationship for that incident and describe the verified capture-policy bug documented at [Bug]: update migrate ignores database.postgres.recoveryCaptures "server" and exports every PostgreSQL store locally #198401.
  • Add data-model compatibility proof - The review found that existing stored data may not work after upgrade. Show that existing data still loads and works with this change.
  • Explain or restore the original intent of Supervised finish lifecycle - 56b8dde: Supervised finish retires accepted migration backups; its local-directory cleanup predates enabling server-carried captures, and this PR gives no reason for omitting the additional retirement required by that carrier.

Findings

  • [P2] Retire server capture schemas before deleting their manifests — src/cli/update-cli/update-command-migrate.ts:223-224
  • [P2] Remove the unsupported repair-incident closing claim — PR description:1

Provenance

  • Supervised finish lifecycle changes intended behavior without addressing why it exists (56b8dde: Supervised finish retires accepted migration backups; its local-directory cleanup predates enabling server-carried captures, and this PR gives no reason for omitting the additional retirement required by that carrier.)

Tests

  • Low-value test src/cli/update-cli/update-command-migrate.test.ts: The added cases replace the backup owner with a throwing mock and assert its input fields, so they pass while finish leaks every server capture; replace these assertions with observable capture and retirement coverage.
  • Missing end-to-end proof: Provide redacted CLI output or logs showing supervised PostgreSQL migrate, restore, successful finish, and finish retry after a schema-drop failure, including an upgrade from v2026.11.3.
Agent review details

How this fits together

The supervised update CLI captures configuration and databases before candidate Doctor migration, records a recovery receipt, and later restores or retires those captures.

flowchart TD
  A[Configured recovery policy] --> B[Supervised migrate command]
  B --> C[Database backup owner]
  C --> D[Portable state capture]
  C --> E[PostgreSQL server capture]
  D --> F[Recovery receipt]
  E --> F
  F --> G[Restore or finish]
Loading

Technical review

Best possible solution:

Complete supervised capture retirement through the existing PostgreSQL cleanup owner, preserving manifests on failure and scoping the fix to the verified capture-policy bug.

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

Current main omits the option that selects server captures, and #198401 supplies matching real-run observations; no target code was executed during this review.

Is this the best way to solve the issue?

Forwarding the existing setting is appropriate, but the smallest complete fix also connects supervised finish to existing schema retirement rather than adding another cleanup mechanism.

Full review comments:

  • [P2] Retire server capture schemas before deleting their manifests — src/cli/update-cli/update-command-migrate.ts:223-224
    With recoveryCaptures set to "server" and a non-state PostgreSQL store, this option creates a full restore_<uuid> schema. After successful migration, updateFinishCommand still removes receipt.backup.directory at line 485 without calling discardPostgresSchemaCaptures. Each accepted supervised update therefore leaves its server-side database copies behind and deletes the manifests needed by the existing retirement owner. Invoke that owner before directory removal, retain the directory when dropping fails, and preserve finish retry behavior.
    Confidence: 0.99
  • [P2] Remove the unsupported repair-incident closing claim — PR description:1
    Merging this PR would automatically close [Bug]: Update repair fails during Doctor finalization on 2026.11.1 #198334, but that report's initiating failure remains unknown in the collaborator discussion. The patch only changes capture placement; it neither diagnoses nor repairs interrupted Doctor finalization or existing ambiguous recovery sets. Use a non-closing relationship for that incident and describe the verified capture-policy bug documented at [Bug]: update migrate ignores database.postgres.recoveryCaptures "server" and exports every PostgreSQL store locally #198401.
    Confidence: 0.98

Overall correctness: patch is incorrect
Overall confidence: 0.98

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: unit tests only.

Security

None.

Evidence

Acceptance criteria:

  • pnpm test src/cli/update-cli/update-command-migrate.test.ts src/cli/update-cli/update-command-database-retention.test.ts
  • node scripts/test-database-conformance.mjs --engine postgres --connection -- src/infra/database-engine/backup-schema-capture.test.ts
  • pnpm check:changed
  • Verify the retirement regression fails before the repair and passes afterward.
  • Inspect contributor-supplied supervised CLI and v2026.11.3 upgrade evidence with existing settings, rows, and portable recovery artifacts intact.

What I checked:

Likely related people:

  • Mitchell Etzel: Raw commit 2ff4256 adds src/cli/update-cli/update-command-database-backup.ts:182 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 2ff4256ae377; files: src/cli/update-cli/update-command-database-backup.ts)
  • Peter Steinberger: Raw commit 61bfde1 adds src/cli/update-cli/update-command-migrate.ts:206 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 61bfde18d87b; files: src/cli/update-cli/update-command-migrate.ts)

PR surface

Source +4, Tests +31. Total +35 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 4 0 +4
Tests 1 31 0 +31
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 35 0 +35

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #198401
Summary: The matching report concerns the omitted supervised capture option; the originally linked repair incident has no established connection.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This affects an advanced supervised-update workflow, with unnecessary export costs before the fix and server-storage accumulation in the proposed lifecycle.
  • merge-risk: 🚨 other: Successful supervised updates would leave full PostgreSQL capture schemas behind after deleting their manifests, accumulating database-server storage.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦪 silver shellfish.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

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.

Reviewed November 13, 2026, 3:22 PM ET / 20:22 UTC.

@roboclaw-bot

Copy link
Copy Markdown
Collaborator

Thanks @qingminglong — forwarding postgresSchemaCaptures is the right first half, and your parity test is kept. With server captures on, though, update finish would then delete the backup manifests without dropping the server-side restore_<uuid> schemas, so they'd be orphaned (ClawSweeper's lifecycle finding).

I've carried your commit unchanged, with your authorship, into #198469, which adds the finish-time retirement plus tests. Once that lands I'll close this one in its favor. Also, this fixes #198401; it doesn't establish a fix for #198334, so that issue stays open.

@obviyus

obviyus commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the work here. We're closing this: it doesn't show a real user-facing problem (no report from an affected user and no natural reproduction), and it follows a pattern of small, speculative or duplicate changes split across many PRs. Please open an issue with a reproduction of real harm first; a fix can follow once the problem is confirmed.

@obviyus obviyus closed this Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: XS status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Update repair fails during Doctor finalization on 2026.11.1

3 participants