cli, engine: add systems format (.txt) support to CLI and expand tests#436
cli, engine: add systems format (.txt) support to CLI and expand tests#436
Conversation
The CLI's format auto-detection defaulted .txt files to XMILE parsing, which silently failed when opening systems format models like hiring.txt. Add a Systems variant to InputFormat and auto-detect .txt extension. Expand systems format integration tests: add table-driven compilation and diagnostic checks for all valid models, add simulation comparison tests for dest_cap_order/infinity/formula_deps/standalone_stocks, and fix incorrect expected CSV for dest_cap_order (was never tested against actual simulation output).
Code ReviewChanges reviewed:
Findings: None. The CLI changes are minimal and correctly mirror the existing pattern for other formats. The test additions are well-structured — the Overall correctness: Correct. The patch introduces no bugs and existing code/tests will not break. |
The Python systems package only shows non-infinite stocks in its output (stock.show == False for infinite stocks). After adding .txt support to the CLI, simulate output included all internal scaffolding variables (modules, rate/capacity auxes, drain variables) alongside user-authored stocks. Now the CLI filters systems format output to match the Python behavior: only non-infinite Stock variables appear in TSV output. Add visible_stocks() to systems::translate that collects the set of user-visible stock idents from a translated project.
Code ReviewReviewed the full diff: CLI systems format support, FindingsNo bugs found. The logic is consistent with existing patterns:
Minor observation (non-blocking): Overall CorrectnessCorrect. The patch is free of bugs and blocking issues. Existing code and tests will not break. |
The previous filtered output used canonicalized engine idents in compiler order (alphabetical, lowercased). Now visible_stocks() takes the parsed SystemsModel directly and returns (original_name, canonical) pairs in declaration order, matching the Python systems package output. Refactor open_model() to return optional visible stock metadata for systems format, avoiding the need to detect format post-hoc.
Code ReviewReviewed the full diff: CLI systems format support, Checked for issues:
No bugs found. The patch is clean, well-tested, and correct. Overall correctness: Correct ✓ |
When --ltm is enabled, LTM synthetic analysis variables are the whole point of the flag. Skip the systems format visible-stocks filter so these variables appear in output. Add print_filtered_tsv_comparison for the debug subcommand so systems format models get filtered comparison output matching the simulate path. Update simlin-cli CLAUDE.md to document the systems format variant.
Code ReviewReviewed the full diff: CLI systems format auto-detection, filtered TSV output, No bugs found. The new Verdict: Correct — no existing code or tests will break, and the new functionality is well-tested. |
…refs visible_stocks() now also excludes stocks declared with A(inf) initial values (not just bracket-syntax [A] infinite stocks). Both forms are semantically infinite and hidden in the Python systems package. The debug subcommand now detects .csv extension and uses comma delimiter instead of tab, so systems format reference files (e.g. hiring_output.csv) work correctly.
Code ReviewReviewed the full diff: CLI systems format support, No bugs found. The implementation is straightforward and well-tested:
Overall correctness: Correct. The patch is free of bugs and blocking issues. Existing code and tests will not break. |
Revert the Expr::Inf initial-value filter added in the previous commit. The Python systems package only hides bracket-syntax [A] stocks (model.infinite_stock sets show=False); explicit A(inf) stocks use model.stock which defaults to show=True. The visible_stocks filter should only check is_infinite (bracket syntax), not the initial value.
Code ReviewReviewed the full diff: CLI systems format support ( No bugs found. The implementation is clean and well-tested:
Overall correctness: correct. The patch is free of bugs and blocking issues. |
Remove the --ltm guard that disabled systems format filtering: LTM loop detection output goes to stderr and the TSV data should always show only visible stocks regardless of --ltm. Use offset 0 for the time column instead of looking up by the "time" ident, which would resolve to a user stock if one were named "time". The engine always places the time axis at offset 0.
Code ReviewReviewed the full diff: CLI systems format support, filtered TSV output, new test models, and expanded integration tests. FindingsNo bugs found. The implementation is clean and well-tested:
Overall CorrectnessCorrect. The patch introduces no regressions and is free of blocking issues. |
…aders A stock with canonical ident "time" (e.g. Time(5)) collides with the synthetic time column at offset 0. Skip it from the visible columns in both print_filtered_tsv and print_filtered_tsv_comparison to prevent duplicate headers that would corrupt round-trip TSV parsing.
Code ReviewReviewed the full diff for CLI systems format support and expanded tests. FindingsNo bugs found that meet the review threshold. The implementation is clean and well-tested. Notes
Overall CorrectnessCorrect. The patch is free of bugs and blocking issues. Existing code and tests will not break. The new functionality is well-covered by the added tests. |
Review cycle summaryThis PR went through 8 review iterations with both codex and Claude reviewers. The improvements made during the review cycle: Output quality (iterations 2-3): The initial implementation exposed all internal translator scaffolding variables in CLI output. Codex flagged this as inconsistent with the Python Edge case correctness (iterations 4-7): Fixed several edge cases identified by codex: the Three pre-existing issues were discovered and filed during review: |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #436 +/- ##
==========================================
- Coverage 81.31% 81.24% -0.07%
==========================================
Files 172 172
Lines 47797 47951 +154
==========================================
+ Hits 38865 38958 +93
- Misses 8932 8993 +61 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 660c1b347c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if canonical_ident == "time" { | ||
| continue; |
There was a problem hiding this comment.
Keep Time-named stocks in filtered systems output
Dropping any visible stock whose canonical ident is time removes a valid user-authored stock from CLI output instead of just disambiguating headers. The new tests explicitly allow this case (visible_stocks_includes_time_named_stock), but simulate now omits that stock entirely (e.g., Time(5) > B @ 1 only prints time and B), so users cannot inspect or compare a real model variable that affects dynamics. Please preserve the stock column (using its original display name) rather than skipping it.
Useful? React with 👍 / 👎.
Summary
.txtfiles to XMILE parsing, which silently failed when opening systems format models likehiring.txt. Added aSystemsvariant toInputFormatand auto-detect.txtextension.dest_cap_order/infinity/formula_deps/standalone_stocks.dest_cap_order(was never tested against actual simulation output).systemspackage test suite:infinity.txt,formula_deps.txt,standalone_stocks.txt.Test plan
open_systems()production entry point test passes for all models.txtas systems format