Skip to content

feat(cli): add --format-version for JSON schema migration#191

Merged
rocketman-code merged 4 commits intomainfrom
feat/format-version
Apr 23, 2026
Merged

feat(cli): add --format-version for JSON schema migration#191
rocketman-code merged 4 commits intomainfrom
feat/format-version

Conversation

@rocketman-code
Copy link
Copy Markdown
Owner

--format-version N flag on all subcommands with --json. Consumers pin the schema version they expect (cargo metadata pattern).

  • Format-version 1: pre-0.5.0 shape (ChainReport.chains as flat string arrays, no edge_kinds/classification on PackageEntry)
  • Format-version 2: current shape (annotated chain objects, full edge-kind data)
  • All JSON output includes a format_version field regardless of version
  • stderr warning when --json is used without --format-version

Test plan:

  • cargo xtask check (fmt + clippy + tests)
  • V1: chainsaw trace --chain zod --json --format-version 1 returns flat string arrays
  • V2: chainsaw trace --chain zod --json --format-version 2 returns annotated objects
  • No flag: stderr warning, defaults to V2

…types

FormatVersion::V1 emits the pre-0.5.0 JSON shape: ChainReport.chains
as flat string arrays, TraceReport.PackageEntry without edge_kinds or
classification. V2 is the current shape. All reports include a
format_version field in JSON output. Existing to_json() delegates to
to_json_versioned(V2) for backward compat with REPL callers.
Consumers pass --format-version 1 or 2 to pin the JSON schema.
When --json is used without --format-version, stderr warns and
defaults to 2. Threaded through all emit call sites in main.rs.
@rocketman-code rocketman-code merged commit 4b64d60 into main Apr 23, 2026
8 checks passed
@rocketman-code rocketman-code deleted the feat/format-version branch April 23, 2026 15:30
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