Skip to content

Add pkg/suggest: advisory safer-form rewrites with typed caveats - #14

Open
Kiran01bm wants to merge 1 commit into
kiran01bm/safer-form-wordingfrom
kiran01bm/p2-5-suggest
Open

Add pkg/suggest: advisory safer-form rewrites with typed caveats#14
Kiran01bm wants to merge 1 commit into
kiran01bm/safer-form-wordingfrom
kiran01bm/p2-5-suggest

Conversation

@Kiran01bm

Copy link
Copy Markdown
Collaborator

Summary

Adds the advisory suggest surface — the last piece of P2.5
(PLAT-38440): map DDL that is risky as
written to the safer native form the engine would run instead, offline, never executing.

What

  • pkg/suggest: versioned report (format_version: 1) with one Suggestion per
    constructed rewrite — original, operation, typed reason, recommended sequence,
    and typed caveats (non-transactional, separate-transactions,
    invalid-index-on-failure, detach-finalize-on-failure, validation-scan).
  • pg-sprite suggest [file] CLI (stdin when omitted, --json): advisory only — always
    exits zero on a valid script; lint remains the gate.
  • Caveats derive from the parsed operation kind; a rewrite with no caveat mapping fails
    closed instead of emitting caveat-less advice, so a new planner rewrite cannot ship
    un-annotated.

Why

The classifier already constructs safer sequences (planner.Decision.SaferSQL), but they
were only visible inside diff/migrate --dry-run output. The SchemaBot adapter's plan
verb and the standalone CLI front door both need the advisory contract as a standalone,
machine-readable surface: what would run instead, why, and under which caveats — because a
safer form is not a semantic equivalent (different transactionality, locking, and failure
modes).

                 ┌───────────────────────┐
 DDL script ────▶│ statement.Split       │
                 │ planner.Classify      │  zero live facts,
                 │ (per statement)       │  nothing executes
                 └──────────┬────────────┘
                            │ safer-idiom decisions with a
                            │ constructed rewrite only
                            ▼
                 ┌───────────────────────┐
                 │ suggest.Report         │
                 │  original → recommended│──▶ text / --json
                 │  reason + caveats      │
                 └───────────────────────┘

References

Completes the P2.5 advisory surface (PLAT-38440): original -> recommended
with typed reason and caveat metadata, offline and never executing.
Refusals and rewrites stay lint findings; suggest reports only
constructed rewrites, and an unmapped rewrite fails closed rather than
shipping caveat-less advice.
@Kiran01bm
Kiran01bm marked this pull request as ready for review August 6, 2026 10:25
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant