Skip to content

Conversation

@N1ark
Copy link
Contributor

@N1ark N1ark commented Dec 22, 2025

Fixes #154

A lot more changes than what the issue required but I want the user-facing part of Soteria (i.e. Terminal) to be really nice and clean and shareable so the user experience is nice and homogeneous! So I added a bunch of utility that could be shared so we have only one way of output things across the tool.

  • Removed --dump-stats from Soteria-C and --stats from Soteria-Rust; instead added a Config module to stats to configure stats outputting, with a flag --output-stats (alias --dump-stats, --stats) to either dump the stats to the given file if specified, or to the terminal if the specified string is stdout.

  • Added Terminal.Printers with some utility printers: pp_time, pp_plural, pp_percent, and pp_unstable. pp_unstable wraps a printer for "unstable" values, i.e. values that change frequently. If the flag --hide-unstable (alias --diffable) is passed, pp_unstable prints a placeholder value instead (e.g. <time>).

    For instance, pp_time is wrapped in pp_unstable, and in Soteria-Rust I also wrapped code ranges in it, to avoid test diffs when I upgrade Rust versions and the call-traces move around.

  • Added Soteria.Terminal.Config.in_test_environment : unit -> bool, that returns whether we are currently in a test environment (dune test). This is used to automatically enable some flags (--hide-unstable and --clean in Soteria-Rust), avoiding the need to have them everywhere in the test files.

@N1ark N1ark requested a review from giltho as a code owner December 22, 2025 10:24
@N1ark N1ark added soteria-core Issues related to the Soteria core library cleanliness Quality of life improvements, to keep the codebase clean and healthy labels Dec 22, 2025
@giltho
Copy link
Contributor

giltho commented Jan 9, 2026

Am I correct to understand that the last bullet point is now gone in favour of some dune magic?

@N1ark
Copy link
Contributor Author

N1ark commented Jan 9, 2026

Am I correct to understand that the last bullet point is now gone in favour of some dune magic?

yes correct :) changed that the other day because it was hacky and i realised i could just set env vars in the cram config which i wasnt aware of

@giltho
Copy link
Contributor

giltho commented Jan 9, 2026

Yeah looking at the commit, it's much prettier and very clever, hadn't thought of it either :)

Copy link
Contributor

@giltho giltho left a comment

Choose a reason for hiding this comment

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

👌

let functions_to_analyse = as_nonempty_list functions_to_analyse in
let@ () = initialise ~log_config ~term_config ~solver_config config in
let@ () =
initialise ~log_config ~term_config ~solver_config ~stats_config config
Copy link
Contributor

Choose a reason for hiding this comment

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

We're starting to need a single ~soteria-config term

(* | "requires" { REQUIRES } *)
(* | "ensures" { ENSURES } *)
(* | "RW" { RW } *)
(* | "Freed" { FREED } *)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm cleaning up some of linear in the logic PR so I'm a bit worried about this creating conflicts, but at the same time I think it's minor enough that it doesn't have to move.

Comment on lines 7 to 8
(** Pretty-prints a time quantity in seconds, displaying it in either seconds or
milli-seconds for smaller values (< 0.05s). Wrapped in [pp_unstable]. *)
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't spend time doing this but fyi you can reference {!pp_unstable} to have a link in the doc

@@ -1,9 +1,9 @@
(executables
(names run_twice deep_give_up if_sure)
(names run_twice deep_give_up if_sure print_stats)
Copy link
Contributor

Choose a reason for hiding this comment

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

Urgh my other PR removes cram tests for symex, it's going to be a mess :(

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nooooo

Copy link
Contributor Author

Choose a reason for hiding this comment

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

your price to pay for taking 3 weeks to review 👿

@giltho
Copy link
Contributor

giltho commented Jan 11, 2026

Clarification: most comments are things I thought about in the moment, the only thing I'd like changed before merging if you can is the parameter to pp_unstable, otherwise feel free to merge

@N1ark N1ark added this pull request to the merge queue Jan 11, 2026
Merged via the queue into main with commit f2f9883 Jan 11, 2026
1 of 2 checks passed
@N1ark N1ark deleted the shared-flags branch January 11, 2026 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cleanliness Quality of life improvements, to keep the codebase clean and healthy soteria-core Issues related to the Soteria core library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make a shared flag for logging/dumping stats

3 participants