Repository navigation
fix(backup): apply --exclude-secrets to PostgreSQL Git exports - #174698
Conversation
Share the SQLite redaction policy with portable PostgreSQL exports without changing their format. Remove credential rows, generated catalog keys and headers, and credential-derived hashes before publication.
|
🦞👀 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 SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5d43b6eb7c
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| for (const table of redaction.excludedTables) { | ||
| database.prepare(`DELETE FROM ${quote(table)}`).run(); |
There was a problem hiding this comment.
Cascade dependent rows when clearing secret tables
When a state database contains a web_push_approval_deliveries row, deleting every row from the excluded web_push_subscriptions table leaves that retained row referencing a missing subscription because this snapshot connection does not enable foreign-key cascades. The subsequent publication validation runs PRAGMA foreign_key_check, so backup git create --exclude-secrets aborts for installations with pending web-push approval deliveries; clear dependent rows or perform these deletions with cascade enforcement.
Useful? React with 👍 / 👎.
|
Codex review: needs maintainer review before merge. What this changesApplies the existing Git backup secret-exclusion policy to PostgreSQL exports before credentials enter the portable image. Example: A PostgreSQL agent store contains the synthetic credential synthetic-secret-must-not-appear-in-export.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR: it fixes a current credential-export defect, resolves both prior findings, and introduces no remaining actionable defect found in this review; required CI is still pending. Priority: P1 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe Git backup codec sends PostgreSQL stores through an offline backup worker, which copies admitted database rows into a verified portable image and publishes its manifests. flowchart TD
A[Git backup command] --> B[Git backup codec]
B --> C[Offline PostgreSQL backup worker]
C --> D[Shared secret exclusion policy]
D --> E[Portable image materialization]
E --> F[Verified image and manifests]
F --> G[Fresh namespace restore]
Technical reviewBest possible solution: Land the shared pre-materialization redaction fix once the existing required CI gates pass. Do we have a high-confidence way to reproduce the issue? Current-main source conclusively bypasses secret exclusion for PostgreSQL capture, and the maintainer reports matching PostgreSQL 17 baseline failures; no reproduction was executed during this read-only review. Is this the best way to solve the issue? Sharing the existing policy and filtering before insertion fixes the owning export boundary without introducing a second credential policy or changing backup formats. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against a1506c240aba. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +110, Tests +282, Docs +3. Total +395 across 9 files. Added test files: 1. View PR surface stats
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 HistoryReview history (1 earlier review cycle)
Reviewed October 16, 2026, 6:16 PM ET / 22:16 UTC (Revision 2). |
|
|
@clawsweeper re-review The follow-up at The populated subscription/delivery fixture reproduced the reported foreign-key failure before that policy correction. All four state/agent and standard/generic parity cases now pass on PostgreSQL 17. The standard-scope cases also restore redacted and default format-2 exports into fresh namespaces and check retained data and credential omission. The follow-up isolated review found no actionable P0–P2 findings. Exact-head CI is running. |
|
🦞👀 Re-review progress:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 47d66e37fe
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (params.gitIdentity) { | ||
| // Publish hashes of redacted rows, never fingerprints of omitted credentials. | ||
| verification.tables = ( | ||
| await inspectDatabasePort({ engine: "sqlite", db }, descriptor) |
There was a problem hiding this comment.
Avoid repeating the SQLite integrity scan during hash refresh
For every PostgreSQL Git backup using --exclude-secrets, this calls inspectDatabasePort merely to recompute table hashes, but SQLite admission inside that helper runs a full assertSqliteIntegrity; createVerifiedSqliteSnapshot then performs another full integrity check when publishing the same staged database. On large installations this adds a redundant whole-database scan to each redacted backup. Refresh the hashes through a scan that trusts the already-owned staging database and leave integrity validation to the publication boundary.
AGENTS.md reference: AGENTS.md:L69-L69
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
This path already supplies an admitted descriptor. capturePostgresBackupInWorker calls admitDatabasePortDescriptor on the PostgreSQL source before passing descriptor to exportPostgresBackup. That descriptor carries activeFragments (including an empty array when appropriate).
inspectDatabasePort forwards that descriptor to admitDatabasePortDescriptor, whose descriptor.activeFragments ? descriptor : ... branch returns it directly. It does not call inspectSqlitePortSchema or its assertSqliteIntegrity here. The subsequent table scan refreshes the hashes after transient-state sanitation; output integrity remains at the snapshot publication boundary. I am keeping the existing path because the reported additional integrity scan is not executed.
…law#174698) Apply the existing SQLite secret policy to PostgreSQL Git exports without changing format 2. Redact credential rows, secret config scopes, and generated model catalog credentials before materializing portable images; preserve provider-required schemas and consistent verification hashes. Four cross-engine regression cases cover state/agent families and generic identities, raw artifact secret omission, default exports, and restores. Exact-head CI run 38973598798 passed, including PostgreSQL conformance (24m38s).
Apply the existing SQLite secret policy to PostgreSQL Git exports without changing format 2. Redact credential rows, secret config scopes, and generated model catalog credentials before materializing portable images; preserve provider-required schemas and consistent verification hashes. Four cross-engine regression cases cover state/agent families and generic identities, raw artifact secret omission, default exports, and restores. Exact-head CI run 38973598798 passed, including PostgreSQL conformance (24m38s). (cherry picked from commit b0ab440) Co-authored-by: RomneyDa <[email protected]>
What Problem This Solves
PostgreSQL Git backup capture returned before applying
--exclude-secrets, so an explicitly redacted backup still contained credentials.User Impact
SQLite and PostgreSQL Git backups now omit the same credential rows, config scopes, and generated model catalog keys and headers. Existing format-2 PostgreSQL exports remain readable; no format or schema migration is required.
Why This Change Was Made
Both export paths use the existing SQLite secret policy. PostgreSQL applies that policy while copying rows into its portable image, retaining provider-required table definitions. Credential bytes never enter the image, and verification compares the redacted rows and hashes. The shared policy also omits web-push delivery receipts whose subscription parents are excluded, preserving foreign-key validity. The actual database family selects the policy even when a retained store uses a generic Git scope.
Related: #174642.
Evidence
Four PostgreSQL 17 regressions compare state and agent exports with SQLite, including generic scopes, raw artifact bytes, omitted-table metadata, config prefixes, generated catalogs, populated web-push deliveries, and ordinary retained rows. Redacted and default format-2 exports are restored into fresh PostgreSQL namespaces and checked for retained data and credential omission. The same tests fail on main because PostgreSQL reports no omissions. Focused SQLite backup/restore tests and an isolated Codex review are included in validation; final CI status is tracked on this PR.
The final Homebrew PostgreSQL 17 redaction/restore suite passed all four cases in 115 seconds of test time (467 seconds wall time including worker preparation). This crosses both storage engines, checks raw artifact bytes, and restores both export profiles through the provider. Core types, SQL architecture/dialect guards, and the isolated review passed. Final exact-head CI is tracked on this PR.
Final CI passed on
47d66e37febbd3e5952569634071cb8b80efdc9b: run 38973598798. PostgreSQL conformance actually ran and passed in 1,478 seconds; all four new parity cases ran, totaling 22.7 seconds of test time. Hosted re-review reports no actionable findings.