Repository navigation
Write the RFC 0015 INCOMPLETE marker before --export-json verification - #5062
feliperodri merged 2 commits into
Conversation
RFC 0015 says an earlier --export-json file is replaced by an INCOMPLETE marker when verification begins, so a killed run cannot leave an older COMPLETE document that looks current. Kani now builds the run context once after harness selection, writes the marker atomically, and then replaces it with the terminal document from the same context. A failed marker write stops the run before any harness is verified. The new json-handler/incomplete-marker test blocks a fake cbmc, then kills the driver (the marker stays) or releases it (the terminal document keeps the marker's fields), and checks a bad export path and a rejected harness filter.
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
2 open issues
What changed in this PR
Implements RFC 0015 behavior where --export-json is atomically replaced with an INCOMPLETE marker before verification, preventing stale COMPLETE exports from appearing current after a killed run.
Changes:
- Add
begin_export_json()to write anINCOMPLETEmarker and reuse a single run context for the terminal export. - Update driver flow to write the marker after harness selection and before verification, and adjust
wall_time_ssemantics accordingly. - Add integration + unit tests and update RFC/docs to describe the new marker behavior.
| File | Description |
|---|---|
| tests/json-handler/incomplete-marker/test.sh | Adds a test entrypoint that runs the integration script with resolved kani/cbmc paths. |
| tests/json-handler/incomplete-marker/test.rs | Adds a minimal proof harness for the integration test project. |
| tests/json-handler/incomplete-marker/run.py | Adds an end-to-end harness that verifies marker persistence on kill and replacement on completion. |
| tests/json-handler/incomplete-marker/fake_cbmc.py | Adds a fake CBMC wrapper that blocks until released to simulate in-verification interruption. |
| tests/json-handler/incomplete-marker/config.yml | Registers the new JSON-handler test. |
| rfc/src/rfcs/0015-export-json.md | Updates RFC 0015 text for marker behavior and revised wall_time_s definition. |
| kani-driver/src/main.rs | Writes the marker context after harness selection and uses it for the terminal export. |
| kani-driver/src/frontend/schema_utils.rs | Introduces RunContext reuse, marker serialization, and updates export API/signatures + tests. |
| docs/src/verification-results.md | Updates user docs to describe marker behavior and how to interpret incomplete exports. |
Review effort: Lite
feliperodri
left a comment
There was a problem hiding this comment.
The design is right: the marker is written once, before verification, through the same atomic write, and the final document reuses its context. Killing the run leaves an honest INCOMPLETE.
Before merge:
write_export_jsonsilently returnsOkwhenctxisNoneand--export-jsonis set. That hides a missedbegin_export_json. Please make it an error or an assert.run.pydiscards stdout and stderr. Please keep the output and print it on failure.- This is an RFC feature, so please add
[C] Feature / Enhancementand a milestone. - Please link this to #5059 (kani-mcp), which must treat a non-
COMPLETErun_stateas incomplete.
`write_export_json` returned `Ok` without writing when `--export-json` was set but no run context was passed, so a missed `begin_export_json` call went unnoticed. `begin_export_json` now returns a `PendingExport` that holds the output path and the run context, and `write_export_json` takes one by value. The only way to reach the terminal write is through the marker. The incomplete-marker test now keeps the output of each Kani run: the background runs write to log files, which are printed when an assertion fails, and a run that times out reports its captured output.
|
Thanks for the review. Fixed in 03bd1ea:
|
feliperodri
left a comment
There was a problem hiding this comment.
Thanks, PendingExport is a better fix than an assert: the final write can't happen without the marker. run.py keeps each run's output, and the PR body links #5059. I added [C] Feature / Enhancement, and I'm leaving the milestone off since none of the current ones fits machine-readable output.
e08fef2
Part of model-checking#942 (RFC 0015, model-checking#4727). Follows model-checking#5062 (the INCOMPLETE marker). This PR changes only tests and the test helper `scripts/validate_json_export.py`. ## Description Adds end-to-end tests for `--export-json` and fixture-based tests for two reading-rule helpers. The unit tests in `kani-driver` build their inputs by hand; each suite below runs `kani` or `cargo kani` and covers a path those unit tests do not reach. The end-to-end tests run `kani` or `cargo kani` and check the exported documents or the rejected requests. Only `structured-warnings` substitutes a CBMC wrapper, which injects warnings or simulates non-completed outcomes. The gate-rejection and no-harness cases do not reach verification. New suites in `tests/json-handler/`: - `additive-output`: checks that `--export-json` preserves exit status and SARIF output for one passing and one failing harness, and preserves stdout and per-harness `--output-into-files` output after masking runtime and verification-time lines. The expected exit status and the exported verdict are checked. `--export-json -` writes a file named `-`. Covers the real stdout, SARIF and per-harness file writers running next to the export. - `autoharness-export`: `kani autoharness --bounded-arguments` exports `is_automatically_generated` and `is_bounded` for each harness. Covers the harness metadata that the autoharness pipeline passes to the export. - `gate-rejections`: argument errors (a missing `-Z export-json`, `--output-format=old`, `--only-codegen`, `--no-codegen`, `-Z lean`, a directory as the target) are reported before compilation. A rejected argument and a compilation error both leave an existing file or directory at the target untouched. Covers the argument checks of the real command line and their order relative to compilation. - `jobs-ordering-stable`: checks that `harnesses[]` is sorted by `(crate_name, file, line, name)` and matches between `--jobs 4` and `--jobs 1` after excluding `resources.verification_time_s`. Covers the order of real parallel and sequential runs. - `live-configuration`: the precedence of unwind and solver settings, `cbmc_args` kept verbatim, a bare `--smt2`, `--coverage` and the check-flag toggles. For each solver case, the exported `resolved_solver` is compared with the solver line that CBMC prints. Covers the configuration of real runs, and the solver that CBMC actually runs. - `multi-crate-export`: `cargo kani --workspace` writes one document, and harnesses with the same name in two crates stay apart by `crate_name`. Covers a real Cargo workspace. - `no-harnesses-selected`: `run_state` is `NO_HARNESSES_SELECTED`, with zero counts. Covers a real project without proof harnesses. - `structured-warnings`: the caps and the exact text of `warnings[]` records, the ERROR classification of an ignored quantifier, and the CRASHED, TIMEOUT and OUT_OF_MEMORY shapes and elapsed times, against a fake `cbmc`. Covers the handling of a real child process: its output stream, a timeout kill, a crash exit and a kill signal. - `vacuity-check`: the `vacuous_pass` and `vacuity_suspect` predicates on live exports, including a partly vacuous harness, with and without reach checks. Covers the reach checks that CBMC reports for real harnesses. Existing tests changed: - `fail-fast`: also checks `harness_selection.matched_count`, and that the run is `PARTIAL` when a selected harness was skipped and `COMPLETE` when the abort lands on the last selected harness. - `multiple-harnesses`: also checks `matched_count` and `run_state`. - `schema-validation`: also tests the two new reading-rule helpers (below) directly, on a new fixture, `fixture-completed-success.json`. `scripts/validate_json_export.py` gains two helpers that implement the vacuity reading rules of the RFC: `vacuous_pass` and `vacuity_suspect`. `vacuity-check` imports them, and `schema-validation`'s `check_fixtures.py` tests them on fixtures. The branch merges `main` instead of rebasing, so its commit list includes an earlier version of the model-checking#5062 commit. The diff against `main` contains only the changes above. ## Testing - `./scripts/kani-regression.sh` passed on Linux with CBMC 6.11.0, including the 17 `tests/json-handler` tests, and the two `cargo clippy` commands of the clippy CI job passed. - Each assertion added after review was checked to fail when the behaviour it covers is broken (a changed expectation, a changed fixture, or an edited export document). - Not run on macOS. A record of which RFC 0015 clauses these tests assert, with the mutations observed to turn a test red, is kept outside this PR: https://github.com/ivmat/kani/tree/export-json-rfc0015-acceptance-2026-11/acceptance/rfc0015 By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.


Resolves #4983. Part of #942 (RFC 0015, #4727). Follows #4941.
Description
RFC 0015 says an earlier
--export-jsonfile is replaced by anINCOMPLETEmarker when verificationbegins. Without it, a run that is killed during verification leaves the earlier
COMPLETEdocument inplace, and that document looks current (see the
#4941 review).
marker with the same atomic write as the final document. After verification, the final document
from the same context replaces it, so
started_atand the other shared fields are equal in both.run_state: "INCOMPLETE", and nooutcome,wall_time_s,summaryorharnesses.harness selection (a filter that matches nothing) leaves an earlier file in place.
wall_time_snow also covers the tool version probes and the marker write. The build is still notincluded.
This implements the marker that the RFC proposes. The RFC's open question "marker or delete-up-front"
is unchanged; the flag stays unstable. The docs and the RFC text are updated to match.
Readers of the export should treat a
run_stateother thanCOMPLETEas incomplete evidence. For example,kani-mcp in #5059 deletes any earlier export before a run and reports a timeout only when no export exists.
With this change, a run that stops after the marker write leaves an
INCOMPLETEexport, so the existence ofthe file alone does not show that verification finished.
Testing
document from one context have equal shared fields.
tests/json-handler/incomplete-markerruns the real driver with a fakecbmcthat waits for arelease file. Killing the driver leaves the marker; releasing it gives a final document with the
marker's
started_at; a bad export path and a rejected--harnessfilter stop the run beforeCBMC verification starts.
written before harness selection, a marker write error ignored,
summary: nullin the marker, anda recomputed
started_at.cargo clippyandcargo fmt --checkpass at 1b6fefa.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.