Repository navigation
Description
Problem
simlin-cli prints Warning-severity diagnostics with an "error" prefix, so advisory warnings read as hard failures.
Reproduce:
cargo run -p simlin-cli -- simulate --ltm test/conveyors/covid19_severity.stmx
Output includes lines like:
error in model 'main': ModelError{conveyor_ltm_degraded: ...}
conveyor_ltm_degraded is a DiagnosticSeverity::Warning. It tells the user that LTM link/loop scores through the conveyor are approximate. Printed with an error in model ... prefix, it reads as a compilation failure -- but the simulation ran and produced results.
This surfaced after commit 2d574720 ("cli: enable ltm before harvesting diagnostics"), which made the CLI actually harvest the diagnostics it had previously been dropping. The formatting bug is older; that commit just made it reachable.
Mechanism
Two places drop the severity:
-
simlin_engine::errors::format_diagnostic(src/simlin-engine/src/errors.rs:275) hardcodes the word "error" into the rendered message:message: Some(format!("error in model '{}': {}", diag.model, err)),
and again for the
Equationarm (error in model '{}' variable '{}': {}). The resultingFormattedErrorstruct (errors.rs:35) has noseverityfield at all, so the severity present ondb::Diagnosticis discarded at the format boundary. -
report_formatted_errors/print_formatted_errorinsrc/simlin-cli/src/main.rs:413-429justeprintln!the pre-renderedmessage. They have no severity to switch on even if they wanted to.
Why it matters
- User-facing and actively misleading. A user running
--ltmon a conveyor model is told "error" for something that is advisory. The natural reaction is to assume the run is invalid and stop trusting the output, or to go hunting for a model bug that does not exist. - It also hides real errors. With warnings and errors rendered identically, there is nothing to grep or scan for.
simlin-cli's exit code andhas_model_errors/has_variable_errorsflags are severity-blind too, so a "warning" contributes tohas_model_errors. - The information is already there:
db::DiagnosticcarriesDiagnosticSeverity. Only the printer ignores it.
Components affected
src/simlin-cli/src/main.rs(report_formatted_errors,print_formatted_error, and thehas_model_errors/has_variable_errorsgating)src/simlin-engine/src/errors.rs(FormattedError,format_diagnostic,format_diagnostic_with_datamodel,collect_formatted_errors)
Note the second is a shared type consumed by libsimlin / the GUI, so a fix should consider whether those consumers want the severity too (they almost certainly do -- the same advisory-rendered-as-error problem exists wherever FormattedError.message is displayed verbatim).
Possible approaches
- Add a
severity: DiagnosticSeverityfield toFormattedErrorand populate it informat_diagnostic/format_unit_error/format_equation_error. Stop baking the literal word "error" intomessage; either render the severity word from the field at print time, or have the formatter emitwarning in model '...'when appropriate. - Have
print_formatted_errorroute warnings and errors distinctly (prefix, and possibly stream), and makehas_model_errors/has_variable_errorscount onlyError-severity diagnostics so warnings do not affect exit status or thehandle_simulation_errorpath. - Audit the other
FormattedError.messageconsumers for the same conflation before changing the string, since the "error in model" prefix is likely load-bearing in test assertions.
Discovery
Found while fixing the conveyor-engine branch: --ltm on a conveyor model prints its conveyor_ltm_degraded advisory as an error.
Activity
engine: lower the full conveyor pass to wasm and gate it on corpus pa…
engine: lower the full conveyor pass to wasm and gate it on corpus pa…