Phase 2.1-2.2: parse boundary and execute-and-introspect declarative diff - #6
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.
…to kiran01bm/phase-2-1-2-2-diff * origin/kiran01bm/phase-1-front-door: Harden the front door per PR #5 reviews Add the two project lenses to AGENTS.md and review checks docs: port reviewed SchemaBot AGENTS.md conventions ci: pin golangci-lint-action and lint binary version ci: pin golangci-lint-action and lint binary version Amp-Thread-ID: https://ampcode.com/threads/T-019fcb83-1db5-74dd-8aa5-b27a21407b7f Co-authored-by: Amp <amp@ampcode.com> # Conflicts: # SAFETY.md # internal/cli/migrate.go # pkg/statement/statement.go # pkg/statement/statement_test.go
|
For the two-lens comment (5207393457): Review response from Kiran's (@Kiran01bm) AI code review assessment agent One-line summary: all six code findings fixed in the follow-up commit; the
|
|
For the adversarial comment (5207393613): Review response from Kiran's (@Kiran01bm) AI code review assessment agent One-line summary: all four findings fixed in the follow-up commit — FK admission refusal, serial-adoption refusal, destructive index drops, and fail-closed
|
…comments Fixes from the two-lens and adversarial reviews at 14c9dee: - refuse REFERENCES at desired-file admission (typed ErrForeignKey) — the scratch transaction cannot faithfully bind an unqualified FK - refuse serial/sequence-backed default adoption (ErrUnsupportedChange) via pg_depend-backed Column.SequenceDefault — the plan would name a sequence that only existed in the rolled-back scratch transaction - classify every Change with a typed Kind; mark DROP INDEX destructive - annotate lock-hazardous statements in the text plan and point the header at migrate as the executing front door - fmt fails closed on commented input (ErrCommentLoss) instead of silently discarding comments - document column-order-by-name convergence and the two-canon boundary
…to kiran01bm/phase-2-3-2-4-classifier-router * origin/kiran01bm/phase-2-1-2-2-diff: Address PR #6 review: FK refusal, serial adoption, change kinds, fmt comments Harden the front door per PR #5 reviews Add the two project lenses to AGENTS.md and review checks docs: port reviewed SchemaBot AGENTS.md conventions ci: pin golangci-lint-action and lint binary version ci: pin golangci-lint-action and lint binary version # Conflicts: # SAFETY.md # internal/cli/cli.go # internal/cli/diff.go # internal/cli/diff_integration_test.go
…er-router' into kiran01bm/oss-standup * origin/kiran01bm/phase-2-3-2-4-classifier-router: planner, router: fail closed on unconstructed safer rewrites Address PR #6 review: FK refusal, serial adoption, change kinds, fmt comments Harden the front door per PR #5 reviews Add the two project lenses to AGENTS.md and review checks docs: port reviewed SchemaBot AGENTS.md conventions ci: pin golangci-lint-action and lint binary version ci: pin golangci-lint-action and lint binary version # Conflicts: # SAFETY.md # docs/low-level-design.md # pkg/planner/planner.go
…ontract * origin/main: vision: describe the ecosystem by capability model, not named tools Address PR #2 review: gate releases, attest artifacts, OSS positioning planner, router: fail closed on unconstructed safer rewrites Address PR #6 review: FK refusal, serial adoption, change kinds, fmt comments Harden the front door per PR #5 reviews Add the two project lenses to AGENTS.md and review checks docs: port reviewed SchemaBot AGENTS.md conventions ci: pin golangci-lint-action and lint binary version ci: pin golangci-lint-action and lint binary version ci: pin golangci-lint-action and lint binary version chore: list project leads in CODEOWNERS # Conflicts: # SAFETY.md # internal/cli/diff.go # internal/cli/dryrun.go
* origin/main: Address plan-contract review: converge both front doors vision: describe the ecosystem by capability model, not named tools Address PR #2 review: gate releases, attest artifacts, OSS positioning planner, router: fail closed on unconstructed safer rewrites Address PR #6 review: FK refusal, serial adoption, change kinds, fmt comments Harden the front door per PR #5 reviews Add the two project lenses to AGENTS.md and review checks docs: port reviewed SchemaBot AGENTS.md conventions ci: pin golangci-lint-action and lint binary version ci: pin golangci-lint-action and lint binary version ci: pin golangci-lint-action and lint binary version chore: list project leads in CODEOWNERS Amp-Thread-ID: https://ampcode.com/threads/T-019fcb83-1db5-74dd-8aa5-b27a21407b7f Co-authored-by: Amp <amp@ampcode.com> # Conflicts: # SAFETY.md
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.