Skip to content

Conversation

@yimingyinqwqq
Copy link

Add opt-in JSON export (--export-json ) to emit structured verification results (metadata, per-harness outcomes, CBMC stats).
Improves Kani by enabling reliable machine-readable output for external tools and applications.

Context: Current output is human-readable only, which blocks robust automation and integrations.

Manual tests:
• Run cargo kani --export-json out.json
• With multiple harnesses: counts in summary match executed harnesses.

Resolves #2572
Resolves #2636
Resolves #2574
Resolves #2562
Resolves #1194
Resolves #1219
Resolves #1045
Resolves #598
Resolves #3357

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.

ConnorJKY and others added 30 commits September 10, 2025 20:09
…n-handler

# Conflicts:
#	kani-driver/src/main.rs
…schedule the schema for harness metadada util func.
@yimingyinqwqq
Copy link
Author

Thank you for your suggestion! We discussed with Rajath about this and user can opt in using the flag so hopefully nothing will be broken.

@github-actions github-actions bot added the Z-CompilerBenchCI Tag a PR to run benchmark CI label Nov 20, 2025
@zhassan-aws
Copy link
Contributor

Thanks for adding this feature. This has been longstanding!

I would recommend putting this feature under an unstable flag (see https://model-checking.github.io/kani/rfc/rfcs/0006-unstable-api.html) for some time until we ensure the json schema won't change.

@zhassan-aws
Copy link
Contributor

Would it make sense to use a standard JSON schema format such as https://json-schema.org/ along with a standard validator, e.g. https://python-jsonschema.readthedocs.io/en/stable/validate/?


Several edge cases need consideration:

**CBMC output parsing**: We extract CBMC statistics using regex patterns. If CBMC's output format changes in future versions, parsing may fail. To handle this gracefully, we can omit CBMC statistics in the json schema.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's likely more robust to use CBMC's --json-ui option (https://diffblue.github.io/cbmc/man/cbmc.html).

@yimingyinqwqq
Copy link
Author

Thanks for adding this feature. This has been longstanding!

I would recommend putting this feature under an unstable flag (see https://model-checking.github.io/kani/rfc/rfcs/0006-unstable-api.html) for some time until we ensure the json schema won't change.

Thank you for reviewing this and for the suggestion.
We will move this feature under an unstable flag and update the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Z-CompilerBenchCI Tag a PR to run benchmark CI Z-EndToEndBenchCI Tag a PR to run benchmark CI

Projects

None yet

6 participants