Repository navigation
fix: keep scheduled Git backups current on PostgreSQL - #201870
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 changesThis PR lets PostgreSQL Git backups capture current data while the Gateway runs by reusing the existing online snapshot path. Example: A scheduled Git backup runs with SQLite shared state and PostgreSQL agent main after session_nodes.updated_at changes from 2 to 3.
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 current PostgreSQL backup failure with a focused change; no actionable correctness or security defects were found. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherScheduled backups invoke the Git backup command in a child process; selected stores pass through the shared database capture owner and become verified capsules committed to a Git repository. flowchart LR
A[Backup schedule] --> B[Git backup CLI child]
B --> C[Selected database stores]
C --> D[Existing online capture owner]
D --> E[Read only PostgreSQL snapshot]
E --> F[Verified Git capsule]
F --> G[Git commit]
Technical reviewBest possible solution: Use the existing online read-only capture owner for Git backups while retaining the current sanitization, artifact format, and offline restore boundary. Do we have a high-confidence way to reproduce the issue? Current-main source establishes the offline-custody refusal and mixed-engine degradation path, and the PR records matching baseline failures; target code was not executed during this review. Is this the best way to solve the issue? This is the smallest complete repair: Git capture opts into an established production owner, and the two regression cases protect distinct failure outcomes without adding production machinery. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against fb9e9fdfcf6c. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +8, Tests +76, Docs +7. Total +91 across 6 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, 9:16 AM ET / 14:16 UTC. |
|
Merged via squash.
|
Co-authored-by: VACInc <[email protected]>
Co-authored-by: VACInc <[email protected]> (cherry picked from commit 67796a6) Gap-sweep intake (Dallin, 2026-11-24): ledger-high/P0-P1 fix not yet on 2026.11.10. Clean apply. Later main mentions of #201870: none. Co-authored-by: RomneyDa <[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
Scheduled Git backups could not capture PostgreSQL stores because they run beside the Gateway, while Git capture required offline ownership. Use the existing online, read-only per-store backup path so these schedules can capture current data.
What Problem This Solves
With PostgreSQL shared state, every scheduled Git run failed. With SQLite shared state and PostgreSQL agents,
--allcould commit shared state while skipping agent history as degraded.User Impact
Git capture can run while the Gateway serves requests, including scheduled backups. PostgreSQL restores and generic local snapshots keep their offline custody requirement. Snapshots remain consistent per store, rather than across the entire installation at one instant.
Why This Change Was Made
Git capture now prepares its config and engine selection and passes them to the same online capture owner used by archive backups. It keeps the existing export format, sanitization, and secret-redaction path. The documentation now distinguishes online capture from offline restore.
Root Cause
captureGitPostgresBackupcalledrunOfflineDatabaseBackupwithout prepared config or the online-capture option. The scheduled CLI child therefore refused the running Gateway owner. The existing--allagent-degradation behavior converted that refusal into a skipped agent scope in mixed installations.On baseline
3587df70a233dc639b733b9169797d3abd138301, the new CLI-child regression failed withThis operation requires exclusive offline state ownershipfor PostgreSQL shared state. The mixed-engine case exited successfully but returnedAgent main degradedinstead of capturing the agent.Real behavior proof
On Linux, Node 26.13.1, and a disposable PostgreSQL 18.7 server:
cron run <id> --wait --jsonreturnedstatus: ok; run history reportedcompletionStatus: succeededwith a Git commit and no degradation warning.backup git verify --global --jsonverified the committed PostgreSQL capsule. The Gateway still answered health checks afterward.Commands used for the Gateway proof, with fixture paths omitted:
Copied result:
scheduled Git run ok; PostgreSQL global capsule committed and verified; Gateway still healthy.What was not tested
No paid model calls, external Git push, or native Windows/macOS run. The Gateway used mock-only model configuration; this backup flow does not invoke a model. There is no like-for-like successful-capture benchmark because the baseline refuses custody before capture. No latency claim is made.
Initial local attempts hit fixture setup failures: preload URL handling, private temporary-directory modes, mixed-engine fixture ownership, and missing search extensions. These were corrected in disposable fixtures before the reported proof. A first Gateway run captured PostgreSQL shared state but warned about an unprovisioned agent; the final global-only schedule completed without that warning.
Verification
OPENCLAW_VITEST_RUNTIME=node pnpm test src/infra/database-engine/git-backup.postgres.test.ts src/infra/database-engine/git-backup-secrets.postgres.test.ts src/snapshot/database-backup.online.test.ts src/snapshot/database-backup.test.ts --maxWorkers=1, with the database conformance preload: 21 tests passed across the completed runs. Secret-redaction agent cases were rerun after adding the required extensions to their fixture database: 4/4 passed.tsconfig.core.jsonfor the changed production owner, regression, and declaration inputs: passed.git diff --check: passed.pnpm build:runtime: passed in 2m 11s. It emitted advisory Control UI size-budget warnings.3587df70a233dc639b733b9169797d3abd138301, with full backup/custody context: P0–P2 scoped-clean, no findings. The reviewer did not rerun tests in its isolated sandbox. The initial wrapper launch failed before review; the installed native CLI completed the review with isolation retained.Exact-head CI completed successfully, including all four PostgreSQL conformance shards and the PostgreSQL 16 smoke lane. Hosted review reviewed
9fdf1390deb2333159128cdc4f7281a100c2ddeawith no findings and sufficient behavior proof. Maintainer review remains required before merge.