Honor --compact-trace in JSON trace output - #9135
Open
tautschnig wants to merge 1 commit into
Open
Conversation
The --compact-trace option was silently ignored with --json-ui: the JSON trace converter received the trace options but only consulted them for the extended-LHS format, so JSON consumers always got the full trace including hidden steps and actual-parameter assignments. Apply the same filtering as show_compact_goto_trace when the option is set: skip hidden steps and actual-parameter assignments, and keep only assignments, declarations, function calls/returns and violated assertions. On instrumentation-heavy programs this shrinks the JSON trace by orders of magnitude because the values of internal instrumentation steps dominate the output; on a Kani-generated verification harness for Rust's write_bytes intrinsic, the trace output shrinks from 427 MB to 3 MB while retaining all counterexample-relevant assignments. Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes a user-visible inconsistency in CBMC’s JSON trace output: --compact-trace was previously ignored when using --json-ui. It adds compact-trace filtering to the JSON trace converter so JSON consumers can request a reduced counterexample trace similar to the console compact trace.
Changes:
- Apply
--compact-tracefiltering injson_goto_trace.hto skip hidden steps and drop most non-essential step kinds (notably internal instrumentation-dominated steps). - Add regression coverage that compares JSON trace output with and without
--compact-trace, checking that actual-parameter assignments are removed in compact mode. - Introduce a small C program that reliably generates actual-parameter trace steps for the regression.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/goto-programs/json_goto_trace.h | Adds compact-trace filtering logic before converting trace steps to JSON. |
| regression/cbmc/trace_options_json_compact/test.c | Test program designed to produce parameter-passing steps in the full trace. |
| regression/cbmc/trace_options_json_compact/non-compact.desc | Baseline test asserting the full JSON trace contains actual-parameter assignments. |
| regression/cbmc/trace_options_json_compact/compact.desc | Test asserting compact JSON trace excludes actual-parameter assignments and hidden steps. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+123
to
+141
| // With --compact-trace, apply the same filtering as | ||
| // show_compact_goto_trace: skip hidden steps, actual-parameter | ||
| // assignments, and everything but assignments, declarations, function | ||
| // calls/returns and violated assertions. This in particular drops the | ||
| // values of internal instrumentation steps, which can shrink the trace | ||
| // by orders of magnitude on instrumentation-heavy programs. | ||
| if(trace_options.compact_trace) | ||
| { | ||
| if(step.hidden) | ||
| continue; | ||
|
|
||
| switch(step.type) | ||
| { | ||
| case goto_trace_stept::typet::ASSERT: | ||
| case goto_trace_stept::typet::DECL: | ||
| case goto_trace_stept::typet::FUNCTION_CALL: | ||
| case goto_trace_stept::typet::FUNCTION_RETURN: | ||
| break; | ||
|
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #9135 +/- ##
===========================================
- Coverage 80.83% 80.83% -0.01%
===========================================
Files 1715 1715
Lines 189948 189958 +10
Branches 73 73
===========================================
+ Hits 153540 153547 +7
- Misses 36408 36411 +3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
feliperodri
pushed a commit
to AlexanderPortland/kani
that referenced
this pull request
Jul 29, 2026
Concrete playback disables --slice-formula (traces from sliced formulas contain arbitrary values, model-checking#1288) and requests a full trace. On contract-heavy harnesses the resulting JSON trace is dominated by the values of hidden instrumentation steps: for the write_bytes harness from model-checking/verify-rust-std the trace weighs 427 MB, of which Kani consumes only the kani::any_raw_* return-value assignments (57 KB) - everything else is built, serialized and parsed for nothing, accounting for more than half of the end-to-end playback time. Pass --compact-trace in playback mode: CBMC's compact trace drops hidden steps and actual-parameter assignments while retaining regular assignments - a strict superset of what the playback parser reads. With a CBMC that honors the option in JSON mode, the trace shrinks to 3 MB and end-to-end playback time halves (46s to 23s), producing an identical generated unit test. The CBMC-side change is diffblue/cbmc#9135; CBMC versions that do not honor --compact-trace with --json-ui accept and ignore the option, so this change is compatible with the currently pinned CBMC and becomes effective once the CBMC pin reaches a release containing that fix. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses. Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The --compact-trace option was silently ignored with --json-ui: the JSON trace converter received the trace options but only consulted them for the extended-LHS format, so JSON consumers always got the full trace including hidden steps and actual-parameter assignments.
Apply the same filtering as show_compact_goto_trace when the option is set: skip hidden steps and actual-parameter assignments, and keep only assignments, declarations, function calls/returns and violated assertions. On instrumentation-heavy programs this shrinks the JSON trace by orders of magnitude because the values of internal instrumentation steps dominate the output; on a Kani-generated verification harness for Rust's write_bytes intrinsic, the trace output shrinks from 427 MB to 3 MB while retaining all counterexample-relevant assignments.