docs / Miri for Agents / JSON Reference

JSON Reference

Every --format json answer follows one schema, diagnostics-schema.json. New fields may appear over time, so ignore any you do not know; schemaVersion changes only when an existing field changes meaning. Fields marked always are present in every answer.

The answer

FieldTypeMeaning
schemaVersion alwaysintegerVersion of this schema. Currently 1. A version gains optional fields and new command values as commands land, so a consumer must ignore members it does not recognise; the number changes only when an existing field changes shape or meaning.
ok alwaysbooleanWhether the command did what was asked. Semantics are per-command; see the per-command table in agent-protocol.md.
command alwaysstringThe command that produced this envelope: ‘check’, ‘build’, ‘run’, ‘test’, ‘explain’, ‘fix’, ‘determinism’, ‘view’, ‘patch’, or ‘skill’.
diagnostics alwaysarray of JsonDiagnosticArray of diagnostic messages (errors, warnings, notes).
artifactstring or nullPath to the build artifact (for build/run commands only). Absent or null if no artifact was produced.
exitCodeinteger or nullProcess exit code. Semantics vary by command: for run, this is the program’s exit status; for other commands, 0 means ok, non-zero means failed. See the per-command table in agent-protocol.md.
signalinteger or nullSignal number if the process was killed by a signal (for run/test commands on Unix only). Absent or null if the process exited normally or on non-Unix platforms.
stdoutTailstring or nullLast N bytes of the program’s stdout (for run/test commands only). Absent or null if not captured.
stderrTailstring or nullLast N bytes of the program’s stderr (for run/test commands only). Absent or null if not captured.
stdoutTruncatedboolean or nullTrue if stdoutTail was truncated; false if complete. Absent or null if stdout was not captured.
stderrTruncatedboolean or nullTrue if stderrTail was truncated; false if complete. Absent or null if stderr was not captured.
durationMsinteger or nullElapsed time in milliseconds for the command execution. Absent or null if not measured.
testsJsonTestSummaryTest summary (for test command only). Absent or null for other commands.
explanationJsonExplanationDocumentation for one diagnostic code (for explain command only). Absent or null for other commands.
viewJsonViewThe canonical source a scoped read returned (view command only). Absent or null for other commands.
patchJsonPatchPatch results: applied edits and revalidation count (patch command only). Absent or null for other commands.
skillsarray or nullSkills from the embedded catalogue (skill command only). Absent or null for other commands.
codesarray or nullDiagnostic code registry (explain list command only). Absent or null for other commands.
gpuJsonGpuTelemetryWhat the run’s GPU work cost (run command only). Absent for a program that never reached the GPU runtime, which is what distinguishes no GPU work from GPU work that cost nothing.

A diagnostic

FieldTypeMeaning
severity alwaysstringSeverity level of the diagnostic.
codestring or nullStable diagnostic code (e.g., ‘MER_TYP_010’) for documentation and tooling. Absent or null for some synthetic diagnostics.
message alwaysstringHuman-readable diagnostic message.
pathstring or nullSource file path where the issue occurred. Absent or null for diagnostics without a source location.
lineinteger or null1-indexed line number in source where the issue occurred. Absent or null if no source location.
columninteger or null1-indexed column number in source where the issue occurred. Absent or null if no source location.
lengthinteger or nullLength in bytes of the error span. Absent or null if no source location.
expectedstring or nullExpected type/value for type mismatch errors. Populated for explicitly-typed error variants (TypeMismatch, ArityMismatch, etc) and selectively for family-coded errors (e.g., MER_TYP_002). Absence does not imply types are unknown; some families do not yet carry structured type information.
actualstring or nullActual type/value for type mismatch errors. Populated for explicitly-typed error variants (TypeMismatch, ArityMismatch, etc) and selectively for family-coded errors (e.g., MER_TYP_002). Absence does not imply types are unknown; some families do not yet carry structured type information.
helpstring or nullActionable help text explaining how to resolve the issue. Absent or null if no help is available.
fixSafetystring or nullFix-safety level of this diagnostic’s repair, if the diagnostic carries a repair. One of: ‘format-only’, ‘behavior-preserving’, ‘local-edit’, ‘api-changing’, ‘target-changing’, or ‘requires-human-review’. It classifies the risk of the edit, not whether one exists — the presence of the ‘repair’ member is what says that. Absent or null if the diagnostic carries no repair.
repairJsonRepairAlways absent in schema version 1; reserved for the repair-plan surface in future versions.
related alwaysarray of JsonRelatedRelated diagnostics (notes, additional context). Empty if no related diagnostics.
preexistingboolean or nullTrue if this diagnostic existed in the pre-edited version (patch command only). False if the edit introduced it. Absent or null for commands other than patch, for a patch command’s own refusal notice (e.g., MER_BLD_011), or for a warning, which is never partitioned against the pre-edited version.

A repair

FieldTypeMeaning
id alwaysstringStable identifier for the repair shape, such as ‘let-to-var’ or ‘add-import’. miri explain --list --format json names the repairs each code can offer.
summary alwaysstringHuman-readable summary of the repair.
edits alwaysarray of JsonEditThe edits that carry out this repair, in source order. Never empty: a repair exists only when the compiler determined the edit.

An edit

FieldTypeMeaning
path alwaysstringFile path (absolute or relative) to edit.
start alwaysintegerStart byte offset (inclusive).
end alwaysintegerEnd byte offset (exclusive).
replacement alwaysstringText replacing the range. Empty to delete the range; the range may be empty to insert.

A test run

FieldTypeMeaning
total alwaysintegerTotal number of tests run (including passed, failed, ignored, etc).
passed alwaysintegerNumber of tests that passed.
failed alwaysintegerNumber of tests that failed.
ignored alwaysintegerNumber of tests that were ignored.
results alwaysarray of JsonTestResultIndividual test results.
rejectedFiles alwaysarray of JsonRejectedFileFiles that were rejected from the test run (e.g., unparseable or declaring main).
filesRead alwaysintegerNumber of .mi files discovery opened and read, whether or not they declared a test. With total 0 it separates ‘read files, none declared a test’ from ‘read no files at all’.

One test

FieldTypeMeaning
path alwaysstringPath to the test file.
name alwaysstringName of the test.
outcome alwaysstringOutcome of the test.
detailstring or nullAdditional detail about the test result (e.g., error message or timing). Absent or null if no detail.
codestring or nullDiagnostic code for assertion failures (e.g., “MER_RT_005”). Absent or null if no failure.
lineinteger or null1-indexed line number where the assertion failed. Absent or null if not applicable.
columninteger or null1-indexed column number where the assertion failed. Absent or null if not applicable.
expectedstring or nullFor assert_eq, the expected value; for assert_panics, the expected message. Absent or null if not applicable.
actualstring or nullFor assert_eq, the actual value; for assert_panics, the caught message. Absent or null if not applicable.
expressionstring or nullThe expression text for bare assert, or null/absent for other assertions.
messagestring or nullOptional user-provided message for the assertion.