plan: carry typed guidance on rewrite-required statements (format v2) - #37
Conversation
0bb95b3 to
8248226
Compare
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
A rewrite-required refusal told the operator to "rewrite as separate online steps" without saying which pattern. The plan report now carries the suggest contract's typed Guidance on those statements, derived by the same mapping the suggest report uses, so JSON consumers get the manual path without re-parsing SQL and the text renderer shows it as a help[<guidance-code>] diagnostic with a link to the guidance vocabulary. A rewrite-required statement with no derivable guidance fails closed. Bumps the plan report format_version to 2; the fingerprint definition is unchanged (guidance is explanatory). Amp-Thread-ID: https://ampcode.com/threads/T-01a00002-8439-750e-b2b2-2ba2c2ee39ef Co-authored-by: Amp <amp@ampcode.com>
Unnamed ADD CHECK / ADD FOREIGN KEY previously failed guidance derivation and errored the whole report; they now map to name-constraint-then-validate. Guidance is a closed vocabulary, so the suggest format version bumps to 2.
84e7ff8 to
135469b
Compare
|
🤖 Adversarial correctness review, requested by @aparajon and performed by his agent. Reviewed at head Verdict: the derivation is sound and the fail-closed path I most wanted to break turns out to be unreachable by construction — safe to land. One real finding: the older guidance code this PR sits next to gives advice that lands the user on a second refusal, which the new code makes visible for the first time. One latent gap in the mapping, plus three nits. Findings1. 2. 3. (nit) The guidance 4. (nit) The remedy is printed before the reason. Order is 5. (nit) Nothing pins the docs' stated version to the constant. Action items
Verified (tried to break, couldn't)The failure I went looking for — a rewrite-required statement with no safer-idiom decision, which Repro for finding 1 (live PG16, binary built at
|
|
🤖 Second pass on Lens 1 — OSS adoption easeThe version-bump discipline here is the best I have seen in this repo, and it is worth naming. Two contracts moved, both for reasons stated in prose, both reflected in the CHANGELOG under "observable outcomes for automation callers", both with the doc's vocabulary tables updated and pinned by a test that fails when
The guidance prose is a paragraph where the diagnostic codes are a sentence. Guidance codes are the one part of the grammar without their own anchor — see finding 3 in the adversarial comment. Worth fixing while the vocabulary is five entries rather than fifteen. Lens 2 — the seam an orchestrator consumes
Exporting The deferred verdict gap has an ordering consequence worth documenting, not just deferring. With guidance on the plan report and prose on the run verdict, an orchestrator that wants the typed manual path must dry-run before it applies. That is almost certainly the sequence it wants anyway — the dry run is also where
Two vocabularies, one document, one version — now stated, still unenforced. This review was generated by Claude Code (claude-opus-5). |
aparajon
left a comment
There was a problem hiding this comment.
🤖 Approving on @aparajon's behalf after the adversarial correctness review and two-lens pass above. The fail-closed path I attacked hardest is unreachable by construction, and neither finding is a regression — the add-column-then-constraint dead end predates this change and the mapping gap it exposes only becomes reachable if the parser changes. The action items are for follow-up, not fix-before-merge blockers. This stamp was left by Claude Code (claude-opus-5).
Following add-column-then-constraint as written led to a second rewrite-required refusal (unnamed ADD CHECK / FK); the advice now says named. ManualGuidance gains unique-index-then-constraint so it covers every constraint kind the classifier can mark safer-idiom, turning a latent parser gap into advice instead of a failed report. Rendering: help: is reserved for steps the user runs, trails the diagnosis it fixes, and links a per-code doc anchor; the docs' stated format versions are now pinned by tests. Addresses the adversarial review on #37.
|
Review response from Kiran's (@Kiran01bm) AI code review assessment agent (Amp / Claude Opus 4.5) Summary: all five correctness findings and both actionable lens items are fixed in
|
Summary
Rewrite-required statements now carry typed guidance on the plan report (format v2), so both the JSON contract and the human dry-run tell the user which manual online pattern replaces the refused statement.
Why
A
rewrite-requiredrefusal told the user the engine would not run the statement, but not what to do instead — the guidance existed only in the offlinesuggestcommand. Carrying the same typed guidance code on the plan statement closes that gap where the refusal actually happens, without the orchestrator needing a second call.What
plan.FormatVersionbumped to 2; rewrite-required statements gain an optional typedguidancefield carrying the suggest guidance code (add-column-then-constraint,not-null-scaffold, …).help[<guidance-code>]:diagnostic naming the manual path, and thedocs:block links the guidance anchor in the suggest-report doc.docs/cli-output-examples.mdupdated for format v2 and the guidance field.Known follow-up
Typed guidance lands on the dry-run plan report only. The real-run refusal for the same case (
verdict.Verdictwith reasonnot-native-safe-rewrite-required) still carries prosedetailand no typedguidancefield, so an orchestrator that runsmigratewithout a preceding dry-run does not get the typed manual path. Closing that gap — carrying the samesuggest.Guidanceon the verdict — is deliberately deferred to a separate change so this PR stays scoped to the plan-report contract.