Skip to content

Rewrite your app in Rust, piece by piece, checked against the original at every step. Works with TypeScript, JavaScript, Python, Go, Ruby, Java, C, PHP, C#, Kotlin, PowerShell and Swift.

fix(cli): advertise all 16 JSON schemas (#1386)

Rishi sharmacebb9968f9bd
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2a4615e9..6ee0f3ae 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -17,6 +17,8 @@
the error JSON on stdout with code `usage` and clap's first line as the message, like every other
failure. Before, clap exited before `run()` and stdout stayed empty. `--help`, `--version` and
runs without `--json` print what they did before (#1351 by @zichen0116).
+- `--version --json` lists the schemas for `analyze`, `profile`, `obligations`, and the
+ evidence, standing and fallbacks reports (#1350 by @stack-rishi).
- Picking at random from a collection counts as randomness: Swift `.shuffled()` and
`.randomElement()` (the entries never matched, since a name after `.` is skipped), Ruby `.shuffle`
and `.sample`, and Java and Kotlin `.shuffled()`, `.random()` and `Collections.shuffle(`. Before,
diff --git a/docs/STATUS.md b/docs/STATUS.md
index b3b5b432..8f18d6c5 100644
--- a/docs/STATUS.md
+++ b/docs/STATUS.md
@@ -67,7 +67,7 @@ Details of every run: [real-world.md](real-world.md) (TS/JS) and
| `gate`'s `size` decisions (`[[size]]` in `rust/obligations-decisions.toml`) | Tested (unit tests only; no real port has used one) | `src/gate.rs`: a Python port at 12x fails without a decision, passes on one that allows 15x with the ADR and reason in the detail and a note naming the ADR, fails on one that allows 5.5x, and fails with the fault when the file is invalid; `src/obligations/standing/decisions.rs`: the last entry for a unit counts, and a missing unit, a `max` of 3 or less, or an ADR that does not name the unit is a fault |
| `selftest`: planted wrong ports and recording tampering against `diff` and `gate` | Tested (TS/JS, Python) | `tests/selftest.rs`, 2026-11-29, Linux x86_64 (4 cores): 28 rows across TS/JS and Python; after the recording, error-class, known-differences and `runtime` checks came in, 2026-11-29, macOS arm64 (Apple M4): 34 rows, 26 caught by the check meant to refuse them (`diff`, the wrong error type included; `gate`'s `literals` for a hard-coded table, marked or not, and for a port that includes `cases.jsonl`; `gate`'s `recording` for deleted cases, deleted `recorded-from.json` and a raised float tolerance; `gate`'s `accepted diffs` for added `known-diffs.jsonl` entries; `gate`'s `runtime` and `spawns` for a port that runs the original, marked or not), 6 documented gaps, both correct ports pass; with `gate`'s `held-out` check (fixed seed in `selftest`) running for Python PyO3 as well, 30 caught and 2 gaps, since it refuses the port that differs only outside the recording and the wrong port behind a legacy-marked recording in both languages; `--strict`, `--only`, an unknown id, a language without an original and a missing toolchain are tested too. The two recording rows and the shell-out row failed on the first run and are fixed in `gate`. Open gaps, named in `docs/how-it-works.md`: a port that prints passes `diff` and `gate`; a recording marked `"legacy_recording": true` is used unverified, with a note, though `gate`'s `held-out` still refuses a port that differs only outside it. Other languages have no built-in original and are listed as not run. Not run on Windows (CI runs it on Ubuntu and macOS, not on the Windows job) |
| Audit log (rust/audit.jsonl), `log` | Tested | `tests/audit.rs`: `enable` (`--force`, `--only`) and `disable` append one entry each and keep earlier lines byte for byte, a torn line is skipped and the next entry starts on its own line, `log` on a repository without a log writes nothing, `map` shows the last switch, the MCP `log` tool reads the same entries; gate entries (pass, then fail with the failed checks and case counts) in `tests/fuzz.rs`; `app wire` and `app lift` entries (refused lifts left out) in `tests/app.rs`'s lift runs. Not yet kept on a real port |
-| JSON for tools: `schema`, `at`, `port` on every output; saved last gate and diff; `report.json`; `map` on/off; errors as JSON; `--version --json`; `gate --json-events` | Tested | `tests/json_output.rs`: `--version --json` lists every schema, `map` reports `enabled` before and after `enable --force` and `disable`, a new `port` after `port.rs` changes, and `gate`/`diff` failures under `--json` print the error JSON on stdout with code `not_bridged` while plain runs keep stdout empty; `tests/fuzz.rs`: the saved `last-gate.json` of a failing gate (failed checks, behavior numbers, the port version now, no absolute repository path); `tests/card.rs`: `report.json` with `language_id` and the port version; unit tests for the port version and macOS `/private` paths. `--json-events` and the saved `last-diff.json` checked by hand on a three-unit sample |
+| JSON for tools: `schema` on `map`, `gate`, `diff`, `report`, `enable`, `disable`, `selftest`, errors, `spec check`, `spec approve`, `analyze`, `profile`, and `obligations` (including `--evidence`, `--check` and `fallbacks`); `at` and `port` where applicable; saved last gate and diff; `report.json`; `--version --json`; `gate --json-events` | Tested | `tests/json_output.rs`: `--version --json` lists the advertised schemas and matches the schema from `analyze --json`, `map` reports `enabled` before and after `enable --force` and `disable`, a new `port` after `port.rs` changes, and `gate`/`diff` failures under `--json` print the error JSON on stdout with code `not_bridged` while plain runs keep stdout empty; `tests/fuzz.rs`: the saved `last-gate.json` of a failing gate (failed checks, behavior numbers, the port version now, no absolute repository path); `tests/card.rs`: `report.json` with `language_id` and the port version; unit tests for the port version and macOS `/private` paths. `--json-events` and the saved `last-diff.json` checked by hand on a three-unit sample |
| `new`, `spec approve`, `spec check` (new CLI apps) | Tested | `tests/spec.rs`: a new app fails until its case is approved and the app is written, then passes; an edited approved case (or the input folder its `fs.base` names, in `src/spec.rs`), a deleted one, an unapproved case that passes and an open question in SPEC.md each keep it from done; `new` refuses a folder with files and a name cargo would refuse; `rules` writes `spec/RULES.md`. Not yet run with an agent, and only CLIs |
| `rules` (rust/RULES.md) | Tested | `tests/rules.rs` (add, duplicates skipped, a crate folder resolves to its repository, `go`'s TASK.md carries the rules) and the MCP prompts in `src/mcp_prompts.rs`; not yet measured with an agent |
| `app record`, `app replay` | Verified (Node servers and CLIs), Tested (the other languages, on this repository's fixtures) | json-server: 514 HTTP cases with `--fresh`, `--arg`, `--pace`; Prettier: 17,224 CLI cases with `--inputs`, 63 of them with config files around the input; CLIs in `tests/app.rs`, CLI `--fresh` in `tests/app_fresh.rs` |
diff --git a/src/state.rs b/src/state.rs
index b25a6053..883757fb 100644
--- a/src/state.rs
+++ b/src/state.rs
@@ -16,11 +16,20 @@ use sha2::{Digest, Sha256};
/// The version of the JSON each command prints, `rust-anything/<command>@1` as `report` already
/// says. It goes up only when a field is removed or changes meaning; new fields keep it.
pub fn schema(command: &str) -> String {
- format!("rust-anything/{command}@1")
+ match command {
+ "analyze" => crate::analyze::SCHEMA,
+ "profile" => crate::profile::SCHEMA,
+ "obligations" => crate::obligations::SCHEMA,
+ "evidence" => crate::obligations::evidence::EVIDENCE_SCHEMA,
+ "standing" => crate::obligations::standing::STANDING_SCHEMA,
+ "fallbacks" => crate::obligations::standing::FALLBACKS_SCHEMA,
+ _ => return format!("rust-anything/{command}@1"),
+ }
+ .to_string()
}
/// The commands whose JSON carries a `schema`, for `--version --json`.
-pub const SCHEMAS: [&str; 10] = [
+pub const SCHEMAS: [&str; 16] = [
"map",
"gate",
"diff",
@@ -31,6 +40,12 @@ pub const SCHEMAS: [&str; 10] = [
"error",
"spec-check",
"spec-approved",
+ "analyze",
+ "profile",
+ "obligations",
+ "evidence",
+ "standing",
+ "fallbacks",
];
pub const LAST_GATE: &str = ".rust-anything/last-gate.json";
diff --git a/tests/json_output.rs b/tests/json_output.rs
index b66911ca..a1b06eca 100644
--- a/tests/json_output.rs
+++ b/tests/json_output.rs
@@ -1,6 +1,6 @@
-//! What tools read from `--json`: every output names its schema, results carry the time and the
-//! port version they ran on, `map` says which units are on, a failure under `--json` is JSON on
-//! stdout, and `--version --json` lists the schemas. The gate's saved result, its events and
+//! What tools read from `--json`: results carry the time and the port version where applicable,
+//! `map` says which units are on, a failure under `--json` is JSON on stdout, and
+//! `--version --json` lists the schemas. The gate's saved result, its events and
//! `report.json` need a recorded port; they are checked where one is built, in `tests/fuzz.rs`
//! and `tests/report.rs`.
@@ -9,8 +9,8 @@ mod common;
use std::path::{Path, PathBuf};
use std::process::Output;
-use rust_anything::bridge;
use rust_anything::walk::Canonical;
+use rust_anything::{bridge, state};
use serde_json::Value;
fn copy_tree(from: &Path, to: &Path) {
@@ -95,11 +95,23 @@ fn version_json_lists_the_schema_of_every_output() {
let v = json(&out);
assert_eq!(v["name"], "rust-anything");
assert_eq!(v["version"], env!("CARGO_PKG_VERSION"));
- for command in [
- "map", "gate", "diff", "report", "enable", "disable", "selftest", "error",
- ] {
- assert_eq!(v["schemas"][command], format!("rust-anything/{command}@1"));
+ let schemas = v["schemas"].as_object().expect("schema map");
+ for command in state::SCHEMAS {
+ assert_eq!(schemas[command], state::schema(command), "{command}");
}
+
+ let fixture = Path::new(env!("CARGO_MANIFEST_DIR")).join("tests/fixtures/mini");
+ let analysis = run(&["analyze", "--json"], Some(&fixture));
+ assert!(
+ analysis.status.success(),
+ "{}",
+ String::from_utf8_lossy(&analysis.stderr)
+ );
+ let analysis = json(&analysis);
+ let analysis_schema = analysis["schema"].as_str().expect("analyze schema");
+ assert_eq!(schemas["analyze"], analysis_schema);
+ assert_eq!(schemas.len(), state::SCHEMAS.len());
+
let plain = run(&["--version"], None);
assert_eq!(
String::from_utf8_lossy(&plain.stdout).trim(),