Skip to content

Add pkg/lint: offline typed findings replacing the CLI lint stub - #9

Open
Kiran01bm wants to merge 1 commit into
kiran01bm/p2-5-plan-contractfrom
kiran01bm/p2-5-linter
Open

Add pkg/lint: offline typed findings replacing the CLI lint stub#9
Kiran01bm wants to merge 1 commit into
kiran01bm/p2-5-plan-contractfrom
kiran01bm/p2-5-linter

Conversation

@Kiran01bm

Copy link
Copy Markdown
Collaborator

Summary

Replaces the CLI lint stub with a real offline linter: pkg/lint runs the same parse-and-classify pipeline as the front doors but with zero live facts, so it needs no database and is strictly conservative. Findings carry typed codes automation branches on — never prose. Second slice of the P2.5 dry-run/advisory surface, stacked on the plan-contract PR.

What

  • New pkg/lint: Check(script) returns a versioned Report (format_version: 1) of typed findings. Codes map from the classifier:
    • unsupported-operation — the engine would refuse it (error; the only severity that flips the exit code)
    • blocking-idiom — a safer native form exists; the finding carries it as suggestion (warning)
    • table-rewrite — needs the copy-and-swap path, with the planner's typed reason (warning)
    • destructive — column/constraint drops, same definition as the declarative differ (warning)
  • New statement.Split: grammar-backed script splitter returning canonical per-statement SQL — no hand-parsing; the coming suggest surface reuses it.
  • CLI lint [file] (or stdin), --json, offline — no DB flags. A clean script prints nothing and exits 0; error findings exit non-zero via a typed sentinel.
  • An unsupported operation is a finding, not a lint failure — one bad statement never hides the rest of the report. A parse failure is an error, surfaced.
  • Docs swept: README status → Phases 1–2.5; SAFETY.md, architecture package map, and low-level design stub markers flipped; testing matrix rows added.

Why

The linter is the policy gate the tracker's E1 slice needs before execution: refuse what the engine cannot run safely, and surface what it would rewrite or gate, in CI, without touching a database. Deriving findings entirely from the classifier keeps one source of truth for safety judgment — the linter adds severity and presentation, never a second opinion.

Before / after

Before:
  pg-sprite lint ──> "lint: not implemented yet (Phase 0 stub)"

After:
  pg-sprite lint change.sql
    ├─ parse (statement.Split, real grammar)
    ├─ classify per statement (planner, zero facts — conservative)
    └─ typed findings: errors → exit non-zero, warnings advise
  pg-sprite lint --json ──> lint.Report  format_version: 1

References

  • PLAT-38440 (P2.5: dry-run plan + advisory suggest surface + linter)
  • Stacked on the plan-contract PR (kiran01bm/p2-5-plan-contract)

lint runs the same parse-and-classify pipeline as the front doors but
with zero live facts, so it needs no database and is strictly
conservative. Findings carry typed codes (unsupported-operation,
blocking-idiom, table-rewrite, destructive) with error/warning
severities; only errors flip the exit code. statement.Split is the new
grammar-backed script splitter both lint and the coming suggest surface
use. Second slice of PLAT-38440.
@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