export the declarative diff→plan pipeline as pkg/diffplan - #20
Conversation
Orchestrators embedding pg-sprite as a Go library need the desired-schema → routed plan.Report flow without shelling out to the CLI. The CLI diff command now delegates to the same exported pipeline, so both callers share one implementation and stored reports mean the same thing regardless of caller.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
🤖 Adversarial correctness review, requested by Armand and performed by his agent. Reviewed at head Verdict: correct and safe to land — nothing blocks. The extraction is a faithful move rather than a rewrite: I diffed the new Findings1. 2. 3. (nit) Action items
Verified (tried to break, couldn't)The delegation is behavior-preserving — the extracted body is identical to the CLI's, including the This review was generated by Claude Code (claude-opus-5). |
|
🤖 Second review pass, requested by Armand and performed by his agent — two lenses on the same head Lens 1 — OSS adoption easeWhat's right. The shape is the one a Go library should have: a single exported function, no package-level state, no hidden initialization, and the callee does not close the pool it is handed — so an embedder can own connection lifecycle, retries, and timeouts without fighting the library. Pushing parse and connect out to the caller is the right call too: it keeps the refusal taxonomy visible at the boundary where the adopter can render it, instead of collapsing "your schema file is inadmissible" and "the database is unreachable" into one error from one function. The signature will be hard to change later. The first question an adopter asks is not answered where they will look. "What do I need in order to call this?" — the answer is a read-write connection with schema-creation privilege, because the desired state is realized by executing the file's DDL in a scratch schema that is rolled back. That is in the package doc, but not in Two smaller things that shape the pkg.go.dev landing page. There is no runnable Versioning posture is right and should be louder. "No Go API compatibility promise before v1; the JSON Lens 2 — SchemaBot integrationThe mapping is close, and the gaps are all in the report's engine-specific fields. SchemaBot's The disposition mapping is the safety-critical one. SchemaBot's The write-capable connection is the item to socialize early. SchemaBot's plan path is generally understood as read-only against the target, and this front door needs schema-creation privilege on the target database and executes the desired file's DDL there (rolled back). That is a credential-posture question for every deployment that would use it, and it is far cheaper to raise while the adapter is still a design than to discover during a least-privilege review. It is also worth deciding explicitly whether the scratch execute-and-introspect should run against the production target at all, or against a throwaway database, since the plan is meant to be a safe read. Fan-out shape. The fingerprint is a better fit than it looks. SchemaBot re-plans when a PR head moves and has to decide whether the new plan is materially different from the one an operator already approved. This review was generated by Claude Code (claude-opus-5). |
aparajon
left a comment
There was a problem hiding this comment.
🤖 Approving on Armand's behalf after the adversarial correctness review and the two-lens pass above (no blocking findings).
This stamp was left by Claude Code (claude-opus-5).
Make DesiredSchema opaque so only ParseDesired can produce a valid one, name Plan's inputs with diffplan.Request, move live-facts extraction to planner.FactsFrom so dry-run no longer depends on the declarative front door, document that planning never writes the live table but is not read-only (rolled-back scratch DDL needs CREATE on the target database), add a pkg.go.dev Example for the embed flow, and record the adapter design notes (disposition mapping, credential posture, per-table fan-out, report storage) in docs/schemabot-integration.md.
|
Review response from Kiran's (@Kiran01bm) AI code review assessment agent (Amp, Claude Opus 4.5) Summary: all findings from both review lenses are addressed in this PR — API seam tightened, docs corrected, pkg.go.dev example added, and the adapter design notes recorded where the reviewer asked.
|
…ignment * origin/main: Tighten the diffplan library seam per PR #20 API review Export the declarative diff→plan pipeline as pkg/diffplan Address plan-contract review: converge both front doors Add pkg/plan: one versioned dry-run report for both front doors # Conflicts: # docs/schemabot-integration.md
* origin/main: ci: run the test matrix against one long-lived database Tighten the diffplan library seam per PR #20 API review Export the declarative diff→plan pipeline as pkg/diffplan # Conflicts: # SAFETY.md # docs/low-level-design.md
…dalone-cli * origin/main: ci: make docs-only detection honor its exclusion patterns docs: reword README from research notes to decided outcomes ci: run the test matrix against one long-lived database Tighten the diffplan library seam per PR #20 API review Export the declarative diff→plan pipeline as pkg/diffplan lint: locate findings in source, derive destructive from the classifier 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 # Conflicts: # docs/vision.md
…urora * origin/main: vision: claim only what standalone use enforces today ci: make docs-only detection honor its exclusion patterns docs: reword README from research notes to decided outcomes ci: run the test matrix against one long-lived database Tighten the diffplan library seam per PR #20 API review Export the declarative diff→plan pipeline as pkg/diffplan lint: locate findings in source, derive destructive from the classifier 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 vision: standalone CLI use is a supported front door 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: # docs/testing.md
* origin/main: testutil: gate Ministack harness behind build tag, demote CI job to signal vision: claim only what standalone use enforces today ci: make docs-only detection honor its exclusion patterns docs: reword README from research notes to decided outcomes ci: run the test matrix against one long-lived database Tighten the diffplan library seam per PR #20 API review Export the declarative diff→plan pipeline as pkg/diffplan Add pkg/executor native CREATE INDEX CONCURRENTLY with fail-closed recovery Add pkg/suggest: advisory safer-form rewrites with typed caveats Clarify safer rewrites are safer forms, not semantic equivalents testutil: control-plane error contract and rotation-seam tests testutil: AWS-boundary test tier via Ministack RDS/Aurora vision: standalone CLI use is a supported front door
Summary
Exports the declarative desired-schema → routed
plan.Reportpipeline as a public Go package,pkg/diffplan, so orchestrators embedding pg-sprite as a library get the same plan the CLIdiffcommand prints — without shelling out. The CLI now delegates to the exported pipeline, so there is exactly one implementation and a stored report means the same thing regardless of which caller produced it.What
pkg/diffplan:Plan(ctx, pool, schema, ds)runs introspect → diff (or full qualified desired schema when the table doesn't exist) → classify with live facts → route → fingerprint, and stamps the server version. Fail-closed input guards; never executes against the live table.LiveFactsis exported so both front doors (declarative diff and imperative dry-run) extract classifier facts identically.serverVersionmoves todbconn.ServerVersion— both front doors stamp reports with it.internal/clidiffbecomes a thin delegate: read file → parse → pool →diffplan.Plan→ render. Rendering stays in the CLI.statement.ParseDesired, connect viadbconn.NewPool.pkg/diffplanrow; testing coverage map updated; schemabot-integration.md'sPlanverb row now points at the exported entry point.Why
An orchestrator integrating pg-sprite needs the plan flow as a Go API (per docs/schemabot-integration.md, the adapter's
Planverb is parse → diff → classify → route), andinternal/is unimportable by construction. Exporting the existing pipeline — rather than having the adapter re-composeschemadiff/planner/routeritself — keeps classification, canonicalization, and fingerprinting decisions in one place so the CLI and library can never drift.The Go API carries no compatibility promise before a v1 tag (docs/architecture.md); the JSON
plan.Reportremains the stability boundary. No tag is cut here.Testing / validation
New unit tests (input guards, fact extraction) and integration tests for the library front door: ordered routed plan with live-fact-driven classification, copy-and-swap refusal disposition, never-writes, no-op diff, missing-table full-schema plan, deterministic fingerprint.
dbconn.ServerVersiongets an integration subtest.make lint0 issues;make test-unitand the integration suite green; existing CLI integration tests pass unchanged through the delegation.