You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
engine: stock/flow unit check uses 'time' instead of the time unit #455
Stock/flow unit checks compare a flow's units against stock units / time, using the literal unit name time instead of the model's time unit.
A model whose time unit is year then reports every correctly annotated flow as a mismatch.
Example
simlin simulate --no-output test/metasd/WRLD3-03/wrld3-03.mdl (time unit year, read from TIME STEP) printed 20+ lines like:
units error in model 'main' variable 'resource_usage_rate': unit_mismatch -- expected units 'resource_units/year' to match the units expected by the attached stock nonrenewable_resources (resource_units/time)
units error in model 'main' variable 'land_life_multiplier_from_land_yield': unit_mismatch -- expected left and right argument units to match, but 'time' and 'year' don't
Why it matters
The stock/flow check is the most useful unit check in SD, and this made it noise on any model whose time unit is not literally time.
Seen on World3.
Fix
The cause on World3 was upstream of the check: the units context failed to build (World3's footer repeats each 22: equivalence line, which was rejected as a duplicate), and the engine fell back to an empty context.
An empty context has neither the model's time unit nor its unit aliases, so time stood in for year.
The time unit should always come from the model's settings, resolved through unit aliases, even when some unit declarations are bad.
Confirm on World3 that no time vs year mismatch remains.
Pointers
src/simlin-engine/src/units_check.rs (model_time_units, the stock/flow check in check)
changed the title [-]engine: unit checker cannot unify 'year' with the implicit 'time' unit of stocks[/-][+]engine: stock/flow unit check uses 'time' instead of the time unit[/+]on Oct 12, 2026
The empty-context fallback is gone: Context::new cannot fail and always carries sim_specs.time_units (src/simlin-engine/src/units.rs:405-409; db/query.rs:69-83). The stock/flow check and inference both take the time unit from model_time_units/resolve_name, through aliases (units_check.rs:488-495, 582; units_infer.rs:969-979), pinned by aliased_time_unit_does_not_cause_inference_mismatch and context_construction_keeps_valid_units_despite_a_conflict (units.rs:902).
Activity
[-]engine: unit checker cannot unify 'year' with the implicit 'time' unit of stocks[/-][+]engine: stock/flow unit check uses 'time' instead of the time unit[/+]bpowers commentedon Oct 12, 2026
Closing: already fixed on main.
The empty-context fallback is gone:
Context::newcannot fail and always carriessim_specs.time_units(src/simlin-engine/src/units.rs:405-409; db/query.rs:69-83). The stock/flow check and inference both take the time unit frommodel_time_units/resolve_name, through aliases (units_check.rs:488-495, 582; units_infer.rs:969-979), pinned byaliased_time_unit_does_not_cause_inference_mismatchandcontext_construction_keeps_valid_units_despite_a_conflict(units.rs:902).