Skip to content

fix(test): isolate PostgreSQL upgrade schema ownership checks - #206391

Merged
vincentkoc merged 1 commit into
mainfrom
fix/postgres-upgrade-role-isolation-20261127
Nov 27, 2026
Merged

vincentkoc merged 1 commit into
mainfrom
fix/postgres-upgrade-role-isolation-20261127

Conversation

@vincentkoc

Copy link
Copy Markdown
Member

What Problem This Solves

The PostgreSQL upgrade conformance test counted every schema in its shared test database. A concurrent Talk test created two schemas between snapshots, making a correct missing-permission refusal fail. Failed conformance shard

User Impact

Contributors can run upgrade and Talk coverage together and still detect leaked upgrade schemas. The change only affects the test.

Why This Change Was Made

Each run creates a unique restricted role that owns the original schema. PostgreSQL also assigns any backup created through that connection to that role. Assert that its complete inventory after rejection consists of the original schema. This catches additional schemas regardless of their names and preserves the exact database and role in the expected grant hint.

Evidence

  • On PostgreSQL 16.15, a second connection committed an unrelated schema while the observing transaction remained open. The old whole-database query gained one row. The new owner-scoped query still returned the original schema.
  • A positive control created a second schema owned by the fixture role. The same query returned both, then returned only the original after removal. The restricted role lacked database CREATE throughout.
  • The signed change passed the pinned formatter and local ClawSweeper found no source issue. PR conformance CI exercises the existing real upgrade preflight and its exact error.

@vincentkoc vincentkoc self-assigned this Nov 27, 2026
@clawsweeper

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

@vincentkoc
vincentkoc marked this pull request as ready for review November 27, 2026 04:53
@clawsweeper clawsweeper Bot added the P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. label Nov 27, 2026
@vincentkoc
vincentkoc enabled auto-merge (squash) November 27, 2026 05:01
@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. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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 Nov 27, 2026
@clawsweeper

clawsweeper Bot commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Codex review: passed.

What this changes

This PR scopes the PostgreSQL upgrade test’s schema inventory to its unique fixture role.

Example: Another test creates an unrelated schema during PostgreSQL 16.15 upgrade preflight coverage.

  • Before: The whole-database inventory changes and incorrectly fails the upgrade test.
  • After: The unrelated schema is ignored, while an additional schema owned by the upgrade fixture still fails the assertion.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch is focused and correct by inspection; validation consists of reported database experiments and partially completed conformance CI.
Proof confidence 🦐 gold shrimp (3/6) There is no changed shipped behavior requiring product-entry-point proof; the body reports real PostgreSQL query controls, and head conformance CI supplies supporting validation.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Test only · Worth it: Yes · Fix scope: Complete
User problem: Contributors can receive a false PostgreSQL conformance failure when another test creates schemas concurrently.
Reason: This narrowly repairs test isolation while retaining the original permission diagnostic and schema-leak invariant; maintainer authorship establishes direction.

Merge readiness

✅ Ready for maintainer review

Keep open: this PR makes a focused correction to a source-verifiable conformance-test isolation bug, with no actionable defects found.

Reviewed head: a57a9818ffa7ac94b6751b4bb66fcf5bb2e44182

Before merge

None.

Findings

None.

Agent review details

How this fits together

The conformance test invokes the production PostgreSQL upgrade preflight with a restricted connection, then checks its grant diagnostic and absence of leaked schemas.

flowchart LR
  A[Unique fixture role] --> B[Restricted connection]
  B --> C[Production upgrade preflight]
  C --> D[Missing CREATE diagnostic]
  A --> E[Owned schema inventory]
  E --> F[Original schema assertion]
Loading

Technical review

Best possible solution:

Use the fixture role’s complete schema inventory to preserve leak detection without observing unrelated tests.

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

The original query observes unrelated concurrent schema creation; the body reports this PostgreSQL 16.15 experiment and a fixture-owned positive control, but I did not execute a reproduction.

Is this the best way to solve the issue?

The existing unique role supplies the correct isolation boundary, and exact equality still detects any extra owned schema without relying on naming conventions.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Upgrade preflight schema-allocation assertion keeps the original intent (c7b132a: Verify that missing database CREATE permission produces the exact administrator remedy before allocating a protected upgrade namespace.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Ayaan Zaidi: Raw commit c7b132a adds src/snapshot/database-backup.postgres.test.ts:90 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: c7b132acd632; files: src/snapshot/database-backup.postgres.test.ts)

PR surface

Tests +1. Total +1 across 1 file. Added test files: 0.

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

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.

Labels

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp 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:

  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp 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 November 27, 2026, 12:08 AM ET / 05:08 UTC.

@vincentkoc
vincentkoc merged commit 535f39d into main Nov 27, 2026
196 checks passed
@vincentkoc
vincentkoc deleted the fix/postgres-upgrade-role-isolation-20261127 branch November 27, 2026 05:13
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash auto-merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant