Skip to content

fix(update): capture and seal original state on PostgreSQL families - #187217

Merged
steipete merged 2 commits into
mainfrom
upd/upd-l1956
Oct 29, 2026
Merged

steipete merged 2 commits into
mainfrom
upd/upd-l1956

Conversation

@steipete

@steipete steipete commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes #187155: PostgreSQL updates can report original-state capture unavailable, classify their own database writes as an unknown writer, and leave recovery status unable to recognize a successful update.

User Impact

PostgreSQL originals are captured and sealed through the existing exact backup provider, updater writes are attributed, and status reads the configured engine to recognize successful captures as stale. The installed updater must contain this repair. No schema, configuration option, CLI option, or dependency changes.

Why This Change Was Made

Original capture supplied no maintenance custody; parent generation observation skipped PostgreSQL; status read its SQLite anchor instead of the PostgreSQL ledger. This reuses the existing custody and engine-selection owners. Unparseable configuration keeps recovery files visible with unreadable outcomes, and all status inspection remains bounded by its existing deadline. Foreign-write refusal and uncertain-child custody remain intact.

Thanks @etzelm for the same-build SQLite/PostgreSQL comparison.

Evidence

  • Capture and attribution regressions fail on pinned base 44ffd0a845b32480ffaf46ff6cfbcaa2267491c1. Public stale-success status fails with the pre-fix status reader after the capture repair. The final five-family PostgreSQL conformance cases pass, including public status with valid and malformed configuration.
  • All 24 affected/proof files were exercised: 292 cases pass; two SQLite WAL-reader cases fail identically on base and patch. A read-only SQLite 3.54.0 open changes WAL ctime while its bytes and mtime stay unchanged, triggering the existing stopped-capture fingerprint. PostgreSQL conformance qualification uses vector and the documented 512-lock budget. Doctor's rename proof passes on tmpfs (overlayfs is explicitly unsupported).
  • Fixed the deadline unit fixture's fake-clock hang: engine initialization now stays outside that timer-only fixture, preserving real exports, all assertions and all three cases. Before: pending beyond 120 s; after: 3/3 pass, 1.56 s test time (23.12 s wrapper). No timeout/retry/assertion weakening.
  • Core, infra-test and CLI-update typechecks; touched-file oxlint/oxfmt; Madge (zero cycles); diff and max-lines/test-lines/mock-export ratchets pass. Final Codex review is clean through P2. Production +113/-28 lines (net +85); tests +116/-116 (net zero); docs +6.
  • Live same-build A/B passes: task-owned PostgreSQL 17.11 state/agent/workboard stores versus SQLite, isolated HOME/state, no Gateway or other writer. Native generated metadata was untouched; all five production files match the reviewed source byte-for-byte. New PostgreSQL run/capture 7f3f4f2b-af1f-49c5-9e1b-758d34d9da9e succeeds (20.735 s), seals four exact capsules, and public status reports stale: its update already succeeded (2.170 s). SQLite run/capture 5fc7c4e6-67fc-4f04-a686-fdad23604d31 does the same (11.764 s / 3.649 s). Captured and live Workboard sentinels, both agents, and configured ports are retained. No capture-unavailable or unknown-writer warning.
  • Proof limits: these are fresh same-build/channel-convergence updates. Separate next-commit activation attempts fail identically on both engines at the existing native guard: Cannot bridge inspect-Duxclsbo.js export findSystemGatewayServices (PG 272.070 s; SQLite 282.390 s). A supported clean package rebuild does not remove that failure. Candidate output contains the export but lacks source-origin region comments required by scripts/lib/update-compat-chunks.mts; CI environment causation is unproven. No compatibility guard/generated metadata was changed, and candidate activation is not claimed. Repeated already-current runs retain existing skipped/ambiguous semantics.
  • Existing slow boundary cases remain: final capture/status 39.978 s, exact rollback 41.327 s, parent-bookkeeping cases 41–53 s, rollback consumer file 184 s test time. Full check:changed / SQLite inventory was skipped under the campaign's local gate budget. PR CI supplies broad proof.
Live commands and local regression commands

Inside the task-owned container, separately for ENGINE=postgres and ENGINE=sqlite:

export HOME="/work/.artifacts/l1956/live-reviewed-$ENGINE/home"
export OPENCLAW_STATE_DIR="/work/.artifacts/l1956/live-reviewed-$ENGINE/state"
export OPENCLAW_CONFIG_PATH="$OPENCLAW_STATE_DIR/openclaw.json"
openclaw workboard create 'Update recovery sentinel' --notes 'Synthetic update reliability proof' --json
openclaw update --yes --no-restart --channel dev
openclaw update status
openclaw workboard list --json
openclaw agents list --json
openclaw config get gateway.port

PostgreSQL exact capsules retain 97 state tables, 39 tables for each agent, and 18 Workboard tables. Both captures retain six SQLite image/anchor entries.

Focused proof used repository wrappers with isolated HOME/state and distinct compiler caches:

node scripts/test-database-conformance.mjs --engine postgres --connection "$TASK_PG_DSN" -- src/infra/database-engine/update-preflight.conformance.test.ts --maxWorkers=1
node scripts/run-vitest.mjs src/cli/update-cli/status.deadline.test.ts --maxWorkers=1
node scripts/run-vitest.mjs src/flows/doctor-health.fleet-preflight.test.ts --maxWorkers=1

@clawsweeper

clawsweeper Bot commented Oct 29, 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 docs Improvements or additions to documentation cli CLI command changes size: S labels Oct 29, 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. 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 29, 2026
@clawsweeper

clawsweeper Bot commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR acquires existing maintenance custody for PostgreSQL original-state capture and includes updater-owned writes in Doctor’s generation handoff.

Example: An isolated PostgreSQL 17.11 installation runs openclaw update --yes --no-restart --channel dev.

  • Before: Original capture lacks exclusive custody, and updater history writes can be classified as unknown writes.
  • After: The patched path acquires maintenance custody and observes the updater’s state generation before Doctor admission.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The source repair is focused and has meaningful boundary regressions, but the explicitly required live update result remains pending; the existing manifest, schema, and configuration formats are unchanged.
Proof confidence 🧂 unranked krab (1/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: Complete
User problem: PostgreSQL updates finish with misleading recovery warnings and an unsealed original capture despite no competing writer.
Reason: The reported behavior violates the existing PostgreSQL capture contract, and the maintainer-authored repair uses the established ownership and receipt mechanisms.

Merge readiness

✅ Ready for maintainer review

Keep this maintainer-authored PR open: it addresses two source-confirmed PostgreSQL recovery defects still present on current main, and no actionable introduced defect was found.

Priority: P2
Reviewed head: e0dcd3e655a3cf26ba8e1d23b36d2963d8d1613b

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: Record the pending PostgreSQL/SQLite CLI update comparison through activation, capture sealing, Doctor attribution, and retained settings/data, including the applicable latest-stable upgrade cell.
Agent review details

How this fits together

The installed updater captures recovery originals before activation and passes database generations to candidate Doctor; existing backup providers produce snapshots, while receipts determine whether automatic restoration remains admissible.

flowchart TD
  A[Installed updater] --> B[Original recovery capture]
  B --> C[Existing maintenance owner]
  C --> D[Exact database backup providers]
  D --> E[Sealed recovery manifest]
  A --> F[Parent write observation]
  F --> G[Doctor generation receipt]
Loading

Technical review

Best possible solution:

Use the existing maintenance owner and generation receipt lifecycle to complete PostgreSQL capture and attribution without weakening custody or untouched-database checks.

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

Source confirms missing capture custody and the PostgreSQL observation skip, supported by the reporter’s concrete A/B trace; this read-only review did not execute the updater.

Is this the best way to solve the issue?

The patch repairs both gaps at their existing owners, preserves the custody refusal and sticky restoration checks, and adds no parallel capture implementation.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Original-state acquisition changes intended behavior with a stated reason (0b08491: Maintenance-owner acquisition let standalone Doctor reuse its existing custody, while direct updater capture retained isolated steps.)
  • PostgreSQL parent-write observation changes intended behavior with a stated reason (db37496: The earlier bookkeeping repair explicitly scoped its observation and native-close handling to SQLite, leaving PostgreSQL unchanged.)
  • PostgreSQL exclusive capture boundary keeps the original intent (d0ea7ea: Exact PostgreSQL capture and restoration use the engine-aware backup owner and require exclusive offline custody.)
  • Existing conformance fixture and recovery coverage keeps the original intent (457b8e9: The suite verifies PostgreSQL-aware inventory, exact capture, and recovery; later fixture changes preserve cleanup and shared-owner settlement.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit db37496 adds src/cli/update-cli/update-command-database-receipts.ts:41 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: db37496952a4; files: src/cli/update-cli/update-command-database-receipts.ts)
  • Vincent Koc: Raw commit c73495d adds src/infra/update-database-backup.ts:313 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: c73495de40bc; files: src/infra/update-database-backup.ts)

PR surface

Source +51, Tests 0, Docs +5. Total +56 across 4 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 55 4 +51
Tests 1 47 47 0
Docs 1 5 0 +5
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 107 51 +56

Review metrics

Metric Value Why it matters
Production versus test growth Production +55/-4, net +51; tests +47/-47, net 0. Production growth implements acquisition, liveness checks, and cleanup through the existing owner; the regressions extend existing capture and rollback cases.

Labels

Label changes:

  • add P2: Updates complete, but PostgreSQL recovery captures and write attribution are unreliable; the report establishes neither an outage nor actual data loss.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab 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: Updates complete, but PostgreSQL recovery captures and write attribution are unreliable; the report establishes neither an outage nor actual data loss.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab 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.

Reviewed October 28, 2026, 11:31 PM ET / October 29, 2026, 03:31 UTC.

@steipete
steipete marked this pull request as ready for review October 29, 2026 03:53
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-29T03:56:22.739028Z c933bb2 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@steipete
steipete merged commit 945f6dd into main Oct 29, 2026
205 of 209 checks passed
@steipete
steipete deleted the upd/upd-l1956 branch October 29, 2026 04:18
steipete added a commit that referenced this pull request Oct 29, 2026
…ed (#187367)

945f6dd (#187217) routed update engine selection through dry-run previews, so openclaw update --dry-run --json with an unparseable config exited 1 with 'configuration is invalid' instead of returning its best-effort preview. Malformed-config previews now reach the existing would-refuse notes without choosing a database backend or inspecting writable state; real updates and Doctor still refuse unsafe admission. Fixes #187333. Thanks @shakkernerd.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 30, 2026
…penclaw#187217)

On PostgreSQL families a successful update warned that the original-state capture was unavailable, refused automatic restoration because the database writer was unknown, and left the capture unsealed, while the same update on SQLite sealed it. The PostgreSQL capture now takes custody through the existing backup provider, the updater's own writes are attributed, and update status reads the PostgreSQL stores, so the capture seals and reports stale-success like SQLite. Fixes openclaw#187155. Thanks @etzelm.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 30, 2026
…ed (openclaw#187367)

fe72331 (openclaw#187217) routed update engine selection through dry-run previews, so openclaw update --dry-run --json with an unparseable config exited 1 with 'configuration is invalid' instead of returning its best-effort preview. Malformed-config previews now reach the existing would-refuse notes without choosing a database backend or inspecting writable state; real updates and Doctor still refuse unsafe admission. Fixes openclaw#187333. Thanks @shakkernerd.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

1 participant