Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
6fd7a2e
engine: switch except and longeqns tests from interpreter-only to bot…
bpowers Mar 30, 2026
4e0e6eb
engine: remove redundant simulates_sum_interpreter_only and ignored e…
bpowers Mar 30, 2026
01a35aa
engine: remove stale comments about VM lacking SUM/ALLOCATE support
bpowers Mar 30, 2026
ad1d817
engine: add assert_compile_error_vm and assert_unit_error_vm test hel…
bpowers Mar 30, 2026
f838661
engine: add assert_vm_scalar_result test helper
bpowers Mar 30, 2026
b80199a
engine: remove 7 pure cross-validation tests from vm.rs
bpowers Mar 30, 2026
0450590
engine: migrate vm.rs interpreter tests to VM-only
bpowers Mar 30, 2026
4d66cd6
engine: migrate db_tests.rs and model.rs interpreter tests to VM-only
bpowers Mar 30, 2026
ec8c68b
engine: migrate unit_checking_test.rs from interpreter to VM helpers
bpowers Mar 30, 2026
f64f8e4
engine: migrate builtins_visitor.rs tests from interpreter to VM helpers
bpowers Mar 30, 2026
5f0ade0
engine: migrate dimensions.rs and db_fragment_cache_tests.rs from int…
bpowers Mar 30, 2026
31fe72b
engine: bulk-migrate array_tests.rs from interpreter to VM helpers
bpowers Mar 30, 2026
990d313
engine: migrate remaining gated helper callers to VM equivalents
bpowers Mar 30, 2026
bc963b5
engine: migrate simple LTM loop detection tests to salsa path
bpowers Mar 30, 2026
b972328
engine: migrate per-link polarity LTM tests to salsa path
bpowers Mar 30, 2026
253d098
engine: migrate complex model and cycle partition LTM tests to salsa …
bpowers Mar 30, 2026
0a43470
engine: migrate module loop LTM tests to salsa path
bpowers Mar 30, 2026
56dfab5
engine: remove interpreter leg from simulate_path_with
bpowers Mar 30, 2026
37529ae
engine: remove interpreter leg from simulate_mdl_path and simulate_md…
bpowers Mar 30, 2026
e693775
engine: delete simulate_path_interpreter_only and simulate_mdl_path_i…
bpowers Mar 30, 2026
04443ad
engine: remove interpreter from simulate_systems.rs
bpowers Mar 30, 2026
860309e
engine: remove interpreter from standalone tests in simulate.rs
bpowers Mar 30, 2026
d666985
engine: migrate simulate_ltm.rs from Project::from to salsa path
bpowers Mar 30, 2026
2804973
engine: ungate get_var_loc methods (called from production db.rs)
bpowers Mar 30, 2026
259f893
engine: delete interpreter.rs and remove from lib.rs
bpowers Mar 30, 2026
0550df1
engine: remove monolithic compilation path from project.rs and model.rs
bpowers Mar 30, 2026
14857eb
engine: remove all cfg(any(test, feature = "testing")) gated code
bpowers Mar 31, 2026
694358c
engine: remove testing Cargo feature
bpowers Mar 31, 2026
f4b011b
engine: clean up dead code and stale comments after interpreter removal
bpowers Mar 31, 2026
8cb5e05
doc: update engine CLAUDE.md after interpreter removal
bpowers Mar 31, 2026
73e0f48
doc: remove stale interpreter references from architecture and array …
bpowers Mar 31, 2026
a1f4baa
engine: remove stale interpreter references from test code
bpowers Mar 31, 2026
25b3a97
engine: gate test-only Module helpers with #[cfg(test)] instead of #[…
bpowers Mar 31, 2026
14d55f8
engine: tighten from_datamodel visibility to pub(crate)
bpowers Mar 31, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ Core simulation engine. Compiles, type-checks, unit-checks, and simulates SD mod
- Primary compilation path is `db::compile_project_incremental()` using salsa tracked functions for fine-grained incrementality (`db.rs`, `db_analysis.rs`, `db_ltm.rs`)
- Equation text is parsed via recursive descent parser (`parser/mod.rs`)
- Simulations run on a stack-based bytecode VM (`vm.rs`) with `PREVIOUS`/`INIT` intrinsic opcodes
- AST-walking `interpreter.rs` is deprecated for production; retained as a reference spec for VM correctness
- `builtins.rs` defines builtin functions (including `PREVIOUS`, `INIT`); stateful module functions (TREND, SMOOTH3) are model definitions in `stdlib/*.stmx`, generated into `stdlib.gen.rs`
- Native Vensim MDL parser in `mdl/` (replaces C++ xmutil); see [docs/design/mdl-parser.md](/docs/design/mdl-parser.md)

Expand Down
2 changes: 1 addition & 1 deletion docs/array-design.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ Indexed dimensions (e.g., numeric dimensions like `Periods(5)`) can use position
- Broadcasting: `BeginBroadcastIter`, `LoadBroadcastElement`, `StoreBroadcastElement`
- Sparse iteration support via pre-computed flat offsets

#### Array Builtins (in both interpreter and VM)
#### Array Builtins
- `SUM(array)` - Sum all elements
- `MEAN(array)` - Arithmetic mean
- `STDDEV(array)` - Standard deviation
Expand Down
10 changes: 4 additions & 6 deletions src/simlin-engine/CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,16 @@ Equation text flows through these stages in order:
- `pretty.rs` - Debug pretty-printing
6. **`src/bytecode.rs`** - Instruction set definition, opcodes, type aliases (`LiteralId`, `ModuleId`, `DimId`, `TempId`, etc.). Includes `LoadPrev`/`LoadInitial` opcodes for `PREVIOUS()`/`INIT()` intrinsics and vector operation opcodes (`VectorSelect`, `VectorElmMap`, `VectorSortOrder`, `Rank`, `AllocateAvailable`, `AllocateByPriority`) that operate on view-stack arrays and write results to temp storage.
7. **`src/vm.rs`** - Stack-based bytecode VM. Hot loop uses proven-safe unchecked array access validated at compile time by `ByteCodeBuilder`. Maintains `prev_values` and `initial_values` snapshot buffers for `LoadPrev`/`LoadInitial` opcodes. Implements vector operation dispatch (VectorSelect, VectorElmMap, VectorSortOrder, Rank, AllocateAvailable, AllocateByPriority). Array reducers (ArrayMax, ArrayMin, ArrayMean, ArrayStddev) return NaN for empty views; ArraySum returns 0.0 (additive identity).
8. **`src/interpreter.rs`** - AST-walking interpreter. Retained as a reference spec for VM correctness verification via `Simulation::new()` + `run_to_end()`. Production compilation uses `db::compile_project_incremental`.
9. **`src/alloc.rs`** - Allocation helpers shared by interpreter and VM: `allocate_available()` (bisection-based priority allocation), `alloc_curve()` (per-requester allocation curves for 6 profile types), `normal_cdf()`/`erfc_approx()`.
8. **`src/alloc.rs`** - Allocation helpers for VM priority allocation: `allocate_available()` (bisection-based priority allocation), `alloc_curve()` (per-requester allocation curves for 6 profile types), `normal_cdf()`/`erfc_approx()`.

## Data model and project structure

- **`src/common.rs`** - Error types (`ErrorCode` with 100+ variants), `Result`, identifier types (`RawIdent`, `Ident<Canonical>`, dimension/element name types), canonicalization
- **`src/datamodel.rs`** - Core structures: `Project`, `Model`, `Variable`, `Equation` (including `Arrayed` variant with `default_equation` for EXCEPT semantics and `has_except_default` bool flag), `Dimension` (with `mappings: Vec<DimensionMapping>` replacing the old `maps_to` field, and `parent: Option<String>` for indexed subdimension relationships), `DimensionMapping`, `DataSource`/`DataSourceKind`, `UnitMap`. View element types (`Aux`, `Stock`, `Flow`, `Alias`, `Cloud`) carry an optional `ViewElementCompat` with original Vensim sketch dimensions/bits for MDL roundtrip fidelity. `StockFlow` has an optional `font` string for the Vensim default font spec.
- **`src/variable.rs`** - Variable variants (`Stock`, `Flow`, `Aux`, `Module`), `ModuleInput`, `Table` (graphical functions). `classify_dependencies()` is the primary API for extracting dependency categories from an AST in a single walk, returning a `DepClassification` with five sets: `all` (every referenced ident), `init_referenced`, `previous_referenced`, `previous_only` (idents only inside PREVIOUS), and `init_only` (idents only inside INIT/PREVIOUS). The older single-purpose functions (`identifier_set`, `init_referenced_idents`, etc.) remain as thin wrappers. `parse_var_with_module_context` accepts a `module_idents` set so `PREVIOUS(module_var)` rewrites through a scalar helper aux instead of `LoadPrev`.
- **`src/variable.rs`** - Variable variants (`Stock`, `Flow`, `Aux`, `Module`), `ModuleInput`, `Table` (graphical functions). `classify_dependencies()` is the primary API for extracting dependency categories from an AST in a single walk, returning a `DepClassification` with five sets: `all` (every referenced ident), `init_referenced`, `previous_referenced`, `previous_only` (idents only inside PREVIOUS), and `init_only` (idents only inside INIT/PREVIOUS). `parse_var_with_module_context` accepts a `module_idents` set so `PREVIOUS(module_var)` rewrites through a scalar helper aux instead of `LoadPrev`.
- **`src/dimensions.rs`** - `DimensionsContext` for dimension matching, subdimension detection, and element-level mappings. Supports indexed subdimensions via `parent` field (child maps to first N elements of parent). `has_mapping_to()` checks for element-level dimension mappings between two dimensions. `SubdimensionRelation` caches parent-child offset mappings for both named (element containment) and indexed (declared parent) dimensions
- **`src/model.rs`** - Model compilation stages (`ModelStage0` -> `ModelStage1` -> `ModuleStage2`), dependency resolution, topological sort. `collect_module_idents` pre-scans datamodel variables to identify which names will expand to modules (preventing incorrect `LoadPrev` compilation). `init_referenced_vars` extends the Initials runlist to include variables referenced by `INIT()` calls, ensuring their values are captured in the `initial_values` snapshot. `check_units` is gated behind `cfg(any(test, feature = "testing"))` (production unit checking uses salsa tracked functions).
- **`src/project.rs`** - `Project` struct aggregating models. `from_salsa(datamodel, db, source_project, cb)` builds a Project from a pre-synced salsa database (all variable parsing comes from salsa-cached results). `from_datamodel(datamodel)` is a convenience wrapper that creates a local DB and syncs. `From<datamodel::Project>` and `from_datamodel` are gated behind `cfg(any(test, feature = "testing"))` (retained only for tests and the AST interpreter cross-validation path); production code uses `db::compile_project_incremental` with `ltm_enabled`/`ltm_discovery_mode` on `SourceProject`.
- **`src/model.rs`** - Model compilation stages (`ModelStage0` -> `ModelStage1` -> `ModuleStage2`), dependency resolution, topological sort. `collect_module_idents` pre-scans datamodel variables to identify which names will expand to modules (preventing incorrect `LoadPrev` compilation). `init_referenced_vars` extends the Initials runlist to include variables referenced by `INIT()` calls, ensuring their values are captured in the `initial_values` snapshot. Unit checking uses salsa tracked functions in `db.rs`.
- **`src/project.rs`** - `Project` struct aggregating models. `from_salsa(datamodel, db, source_project, cb)` builds a Project from a pre-synced salsa database (all variable parsing comes from salsa-cached results). `from_datamodel(datamodel)` is a convenience wrapper that creates a local DB and syncs. Production code uses `db::compile_project_incremental` with `ltm_enabled`/`ltm_discovery_mode` on `SourceProject`.
- **`src/results.rs`** - `Results` (variable offsets + timeseries data), `Specs` (time/integration config)
- **`src/patch.rs`** - `ModelPatch`/`ProjectPatch` (both `Clone`) for representing and applying model changes. `ModelPatch` is consumed by `incremental_layout()` to determine what variables were added/removed/renamed

Expand Down Expand Up @@ -86,7 +85,6 @@ The primary compilation path uses salsa tracked functions for fine-grained incre

## Cargo features

- **`testing`** - Exposes the monolithic `Project::from` construction path and associated test helpers (`check_units`, etc.). Required by `simulate`, `simulate_ltm`, and `compiler_vector` integration tests. Production code uses `compile_project_incremental` instead.
- **`file_io`** - Filesystem-based data providers (CSV/Excel). Required by `simulate` and `simulate_ltm` tests.
- **`schema`** - JSON Schema derivation via `schemars`.
- **`ai_info`** - AI metadata signing.
Expand Down
13 changes: 4 additions & 9 deletions src/simlin-engine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ default = ["schema", "ai_info", "debug-derive"]
# are used with .unwrap(), or appear in assert_eq!() keep unconditional Debug.
# New types should use: #[cfg_attr(feature = "debug-derive", derive(Debug))]
debug-derive = []
# Exposes the monolithic Project::from construction path and associated
# test helpers (compile, build_sim, run_interpreter, etc.) for integration
# tests. Production code uses compile_project_incremental instead.
testing = []
schema = ["dep:schemars"]
ai_info = ["dep:ed25519", "dep:base64"]
file_io = ["dep:csv"]
Expand Down Expand Up @@ -66,19 +62,19 @@ tempfile = "3"

[[test]]
name = "simulate"
required-features = ["file_io", "testing"]
required-features = ["file_io"]

[[test]]
name = "simulate_ltm"
required-features = ["file_io", "testing"]
required-features = ["file_io"]

[[test]]
name = "simulate_systems"
required-features = ["file_io", "testing"]
required-features = ["file_io"]

[[test]]
name = "systems_roundtrip"
required-features = ["file_io", "testing"]
required-features = ["file_io"]

[[test]]
name = "roundtrip"
Expand All @@ -91,7 +87,6 @@ name = "json_roundtrip"

[[test]]
name = "compiler_vector"
required-features = ["testing"]

[[bench]]
name = "array_ops"
Expand Down
Loading
Loading