Skip to content

cli debug and print_tsv_comparison silently truncate on length mismatch #437

@bpowers

Description

@bpowers

Description

The debug subcommand in simlin-cli and the print_tsv_comparison function in simlin-engine/src/results.rs use iter().zip() to compare simulation output against reference data. Rust's zip() stops at the shorter iterator, so when the reference dataset has fewer timesteps than the simulation (or vice versa), trailing steps are silently dropped from the comparison output with no warning.

This means a user debugging a model could miss divergence that only appears in later timesteps, or fail to notice that reference data is incomplete -- the tool gives no indication that the comparison is partial.

Why it matters

  • Correctness: The comparison tool's purpose is to help users spot differences between expected and actual simulation results. Silently omitting data undermines that purpose.
  • Developer experience: A user investigating a model discrepancy could waste time because the tool hides the very steps where behavior diverges.
  • Debuggability: When reference files are generated from different tool versions or configurations, length mismatches are a meaningful signal that should be surfaced, not hidden.

Components affected

  • src/simlin-cli/src/main.rs -- the debug subcommand's result comparison logic
  • src/simlin-engine/src/results.rs -- print_tsv_comparison function

Possible approaches

  1. Warn on mismatch: Before the zip loop, compare lengths and emit a warning (e.g., via eprintln!) if they differ, stating which side is shorter and by how many steps.
  2. Use zip_longest: Switch to itertools::zip_longest (or equivalent) to iterate over all steps, printing placeholder values (e.g., N/A or ---) for the shorter side's missing entries.
  3. Error on mismatch: Treat a length mismatch as an error condition, printing the mismatch details and returning a non-zero exit code from the CLI.

Option 1 is the simplest and least disruptive. Option 2 gives the most complete output.

Context

Identified during review of PR #436 (systems format debug path). This is pre-existing behavior, not introduced by that PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions