Repository navigation
fix: catch incompatible ownership before porting to SQLite - #202101
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesReject PostgreSQL-to-SQLite ports with installation ownership before copying stores or creating recovery artifacts. Example: Run openclaw database port --to sqlite with database.engine="postgres" and database.postgres.ownership="installation".
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored PR fixes a concrete late-validation failure with a focused preflight check; no introduced correctness or security defects were found. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe database port CLI passes destination and family selections to the existing port owner, which admits the operation before capturing stores, publishing engine changes, or managing recovery. flowchart TD
A[Database port CLI] --> B[Port selection admission]
B --> C[Ownership guidance]
B --> D[Offline state owner]
D --> E[Capture and verify stores]
E --> F[Publish stores and config]
D --> G[Resume or rollback]
Technical reviewBest possible solution: Keep the ownership prerequisite in the existing port admission owner while preserving operator choice and interrupted-port rollback. Do we have a high-confidence way to reproduce the issue? Current-main admission permits the incompatible destination, while switchConfig retains installation ownership and reaches the schema rejection after staging; the supplied CLI evidence reports that exact failure. Is this the best way to solve the issue? This is the smallest complete fix: enforce the existing destination invariant in assertPortSelection, retain the established recovery owner, and cover ordinary and scoped dry-run admission without new machinery. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against f91bc9900e81. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +5, Tests +15, Docs +6. Total +26 across 3 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes:
Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 19, 2026, 5:52 PM ET / 22:52 UTC. |
|
Merged via squash.
|
…202101) Co-authored-by: VACInc <[email protected]>
…law#194384) * docs: clarify PostgreSQL conformance coverage * fix(cron): keep one-shot finalization working on PostgreSQL 16 * test(database): reuse cron conformance for JSON conversion regression * test(postgres): accept fractional explain row counts (cherry picked from commit 7ab0143) Release adaptation: Only engine-owned jsonValue and retained cron enabled JSON replacement; preserve native boolean type with PG16 explicit ::json and SQLite json(). Omit unrelated PG docs/EXPLAIN test edits; retained one-shot enabled-transition caller present on baseline. Follow-up dispositions: e029e18 docs: document isolated PostgreSQL restore drills (openclaw#202704); 49f0740 fix(database): report disabled memory after a port (openclaw#202630); a80b564 fix: keep database workers healthy after silent connection loss (openclaw#201856); 3d91af2 fix(config): reject reserved PostgreSQL schema prefixes (openclaw#202097); 835d722 fix: catch incompatible ownership before porting to SQLite (openclaw#202101); 67796a6 fix: keep scheduled Git backups current on PostgreSQL (openclaw#201870); cc849dd fix: recover lease heartbeats after a PostgreSQL connection loss (openclaw#201858); 6594caf fix: prepare macOS runtime pins without the PostgreSQL secret (openclaw#202102); 6ca56cd docs: clarify PostgreSQL storage and backup coverage (openclaw#202086); a079190 fix(postgres): chat history slows under concurrent reads (openclaw#190129); 2ff4256 feat(database): keep PostgreSQL rollback captures in PostgreSQL (openclaw#196236); 96c685b feat(backup): restore PostgreSQL stores into a staging database for restore drills (openclaw#194808); fb83d65 fix: reduce transcript allocation when preparing native context seeds; 71ec4d2 fix(config): keep Workboard PostgreSQL upgrades readable (openclaw#194648); b6ed907 perf(sessions): persist active transcript facts for hydration (openclaw#193682) Validation: Baseline cron generated json(bound text) on PostgreSQL where json(text) is unavailable; helper and focused boolean regression retained. Exact PostgreSQL16 server proof unavailable; focused SQLite/helper tests queued. diff check passed. Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit 38fdd9b52704d588d9ca24ef8e391d644961c985) (cherry picked from commit fb935e6912388314851b05cb698ef038b83bbd07)
Summary
High Level TLDR
A move from PostgreSQL to SQLite could copy and verify the database before telling the operator that installation ownership makes the destination config invalid. The command and dry run now report the incompatible setting before copying. The operator chooses when to turn off installation ownership.
What Problem This Solves
The late failure leaves an active recovery manifest, so the Gateway requires rollback before it can start again. The early refusal applies to both whole-installation and family ports.
Root Cause
The config schema requires every configurable family to use PostgreSQL when
database.postgres.ownershipisinstallation. The port changes the selected engine and leaves the ownership setting as configured. Previously, strict config validation caught the conflict at publication, after the staged SQLite store had been verified. The command now checks the destination in its existing engine selection preflight and the operator guide explains the prerequisite.Real behavior proof
Ran the production database port CLI registration against a disposable PostgreSQL 18.7 server over a Unix socket. Seeded a shared-state store with a seven-byte blob and configured installation ownership.
openclaw database port --to sqlite --dry-runreportedDatabase port: preflight (postgres → sqlite); 1 database stores.The real command exited 1 atswitch configwithCONFIG_VALIDATION_FAILED. The active manifest waspreparingwith a verified target. The source config and PostgreSQL anchor remained active.openclaw database port --to sqliteandopenclaw database port --family state --to sqliteeach exited 1 with the ownership guidance. Both dry runs did the same. The config and anchor still selected PostgreSQL and the recovery directory was absent.openclaw database port --rollback <manifest>completed for the interrupted baseline operation and archived its active manifest. The original PostgreSQL config and installation ownership remained intact.state-directoryin the fresh fixture and reranopenclaw database port --to sqlite. The command reportedDatabase port: complete (sqlite); 1 database stores.The SQLite row matched the original blob and the operation archived its manifest.Three timed dry runs after one warmup per build on the same host and workload took 35.33–45.61 s on main (median 44.65 s) and 11.64–19.38 s with the fix (median 14.56 s). These are source CLI invocations under shared host load. The before run inventories the source, while the after run refuses at config admission.
What was not tested
No live Gateway, paid model calls, or production-size port. The disposable fixture covered one shared-state store. The interrupted-port proof covered rollback. No resume, cross-host lock failover, or older-release upgrade was verified.
Verification
pnpm test src/commands/doctor-database-port.test.ts --maxWorkers=1. Two new cases failed on main. All 9 passed on the candidate (60.04 s wall time).git diff --checkpassed.1fbcec108f4e4ed21c698d82e31e7ce23498b342at P0–P2 and returned no actionable findings. The change adds one admission branch and two command cases. It uses the existing config and recovery contracts.79452f476694028c0fe338156a7bf39a94d379ba, including PostgreSQL conformance. https://github.com/openclaw/openclaw/actions/runs/44630101353