Skip to content

feat(cmd/crucible): machine-readable lint/diff output + diff exit-code gate#182

Merged
joshua-temple merged 1 commit into
mainfrom
feat/cli-machine-readable-output
Jun 17, 2026
Merged

feat(cmd/crucible): machine-readable lint/diff output + diff exit-code gate#182
joshua-temple merged 1 commit into
mainfrom
feat/cli-machine-readable-output

Conversation

@joshua-temple

Copy link
Copy Markdown
Collaborator

Closes #172.

What

Makes crucible lint and diff consumable by CI gates and code-scanning — they previously emitted human text only.

  • lint -format text|json|sarif (default text). SARIF is 2.1.0 (uploadable to GitHub code-scanning); each finding becomes a result with ruleId=kind, mapped level, a logical location for the state/transition, and the IR path as a physical location (omitted for stdin -).
  • diff -format text|json (default text).
  • diff -exit-code (opt-in): exits non-zero when the recommended bump is major (≥1 breaking change), so a diff can gate CI. Default behavior (always exit 0) is unchanged.

Design notes

  • JSON is built from CLI-local DTOs; state/analysis and state/evolution types are untouched.
  • lint still exits non-zero on findings in every format (SARIF-upload-then-gate flows should ignore the exit code).
  • Flags are accepted in any position relative to the IR paths (both subcommands route through reorderArgs).
  • The JSON shape is documented but pre-1.0 (cmd/crucible is v0.1.0).

Verification

  • go build / go vet / go test (71 pass, 18 new) / golangci-lint (0 issues) — all green in cmd/crucible.
  • End-to-end against the binary: valid JSON/SARIF output, correct exit codes for lint findings and diff -exit-code (major→1, minor→0, no-flag→0), stdin SARIF carries no physical location, unknown/unsupported format → usage exit.
  • Text output is unchanged.

…ode gate

lint gains -format text|json|sarif; diff gains -format text|json and an opt-in
-exit-code that exits non-zero when the recommended bump is major (at least one
breaking change), so lint and diff results can drive CI gates and code-scanning.

- JSON is built from CLI-local DTOs; the state/analysis and state/evolution
  types are unchanged. SARIF is 2.1.0 (lint only) and anchors the IR path as a
  physical location except for stdin input.
- Exit codes preserved: lint still exits non-zero on findings in every format.
- Flags are accepted in any position; both subcommands route through reorderArgs.

Closes #172.
@joshua-temple joshua-temple merged commit fa42b23 into main Jun 17, 2026
120 checks passed
@joshua-temple joshua-temple deleted the feat/cli-machine-readable-output branch June 17, 2026 14:34
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.

CLI: machine-readable --format json / SARIF output for lint and diff

1 participant