Phase 2.1-2.2: parse boundary and execute-and-introspect declarative diff - #6
Phase 2.1-2.2: parse boundary and execute-and-introspect declarative diff#6Kiran01bm wants to merge 5 commits into
Conversation
Admit a declarative desired-state file (one CREATE TABLE plus its CREATE INDEXes) through the real grammar, materialize it in an always-rolled-back transaction-scoped scratch schema on the target, and introspect both live and desired state into one canonical model from server catalogs — semantic truth comes from PostgreSQL, never from AST transformation, per the layered DDL-understanding decision.
Diff live vs desired canonical models into dependency-ordered SQL changes with a destructive marker and typed refusals for unsupported identity/generation changes. `diff` emits an executable text plan or a JSON report; `fmt` canonicalizes offline via the parser/deparser.
The unpinned lint action installed a v1 binary built with an older Go than the module targets, so it could not load the v2 config. Matrix jobs now render as "test (PostgreSQL NN)" in the checks UI.
Checks now render as CI / lint, CI / test (PostgreSQL NN), and CI / all-green instead of the ci / ci-ok stutter. "all-green" is the context to require once branch protection is wired.
Semgrep and zizmor code-scanning gates require third-party actions pinned to a full commit SHA, matching the existing paths-filter pin.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
🤖 Review requested by Armand and performed by his agent — same two lenses as #4 and #5: pg-sprite as an OSS-first, best-in-class Postgres DDL tool, and pg-sprite as a clean integration target for an orchestrator. Reviewed at head Credit first, because this PR is responsive on several prior threads: the CREATE TABLE refusal now carries a real safer idiom ( OSS lens
Integration lens
Verified solidThe admission gate is the right shape: allowlist (CREATE TABLE + CREATE INDEX only), unqualified-names rule so nothing can escape the scratch schema by qualification, CONCURRENTLY refused because it cannot run in a transaction, and index-target validation — each with its own typed error and a table-driven test. This review was generated by Claude Code (claude-fable-5). |
|
🤖 Adversarial correctness review requested by Armand and performed by his agent — separate from the two-lens pass. Method: attack the code, then verify every candidate finding against a real PostgreSQL at head Findings, most severe first1. Foreign keys in desired files are admitted but broken end-to-end.
Suggested fix, consistent with the admission gate's fail-closed design and the single-table scope: refuse 2. Converging a plain column onto The plan references a sequence that only ever existed inside the rolled-back scratch transaction. The diff engine already refuses identity and generation changes with 3. 4. Probed and heldAttacks that failed: the serial convergence trap — I expected the scratch schema's random name to leak into the desired model's sequence default ( Reproduction testsFinding 1 —
|
aparajon
left a comment
There was a problem hiding this comment.
🤖 Approving on Armand's behalf. My two-lens review and adversarial correctness pass are posted above — the findings there are for follow-up, not fix-before-merge blockers.
This approval was submitted by Claude Code (claude-fable-5) at Armand's direction.
Summary
Phase 2.1–2.2 — the parse boundary and the declarative diff. Stacked on
kiran01bm/phase-1-front-door.What
pkg/statement: single parse boundary through the real PostgreSQL grammar (wasilibs/go-pgquery, Wasmlibpg_query, no cgo); a parse failure is a surfaced error, never a guess.pkg/schemadiff: desired state derived by execute-and-introspect — desired DDL executed in a rolled-back scratch schema, canonical model introspected from PostgreSQL's own catalogs — then diffed against the live catalog into ordered DDL. Convergence-tested (apply plan → re-diff → empty).diffandfmtcommands.all-greensentinel, actions pinned to commit SHAs.Why
Execute-and-introspect delegates after-schema correctness to PostgreSQL itself instead of reimplementing its semantics; this PR establishes that decided approach in code.