Repository navigation
engine: fix incremental dependency data loss - #322
Conversation
This hardens several silent correctness failures in incremental compilation and salsa sync. Module-to-module causal edges now normalize module output refs, implicit fragment compilation now resolves composite module dependencies and collects lookup tables from dependency variables, and module compat visibility is preserved during both initial and incremental sync. It also removes a silent narrowing cast in symbolic module declaration symbolization by rejecting offsets that do not fit in u32. New regression tests cover each bug path so these failures cannot silently regress again.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0df6d09b6d
ℹ️ 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".
| for mr in source_var.module_refs(db).iter() { | ||
| let canonical_src = canonicalize(&mr.src).into_owned(); | ||
| edges.entry(canonical_src).or_default().insert(name.clone()); | ||
| let normalized = normalize_module_ref_str(&canonical_src); |
There was a problem hiding this comment.
Keep parent-scope module sources when normalizing edges
Avoid passing every module reference source through normalize_module_ref_str here: XMILE parent-scope connectors like from=".area" canonicalize to ·area, and normalize_module_ref_str truncates at the first middot, producing an empty key (""). That drops the real dependency source in model_causal_edges (and similarly in the implicit-module branch), so causal graphs/loop analysis for models using parent-scope module references become incorrect.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Addressed in commits a5eba4f and 3fe542a: normalize_module_ref_str now strips the leading middot before truncating, and both module-ref loops filter out internal/output refs (where src starts with the module's own prefix) before calling normalization. Regression tests cover both the leading-middot case and the self-loop prevention.
Code ReviewChanges Reviewed
FindingsNo bugs found. The changes are logically correct and well-tested. Key correctness observations:
VerdictCorrect. The patch addresses all five described bugs with appropriate tests. Existing code and tests should not break. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #322 +/- ##
==========================================
- Coverage 79.35% 79.33% -0.02%
==========================================
Files 132 132
Lines 31487 31574 +87
==========================================
+ Hits 24986 25050 +64
- Misses 6501 6524 +23 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…ication normalize_module_ref_str failed to strip leading middots (XMILE parent-scope refs like .area canonicalize to middot-area), producing empty-string keys in the causal graph. Align with model_dependency_graph's normalize_dep by stripping the leading middot before truncating at the module qualifier. Extract build_module_inputs helper to deduplicate the module reference filtering/mapping logic that appeared in compile_var_fragment and twice in compile_implicit_var_fragment. Change extra_submodels from Vec to HashMap to naturally deduplicate when multiple deps reference the same module.
Code Review: PR #322 — engine: fix incremental dependency data lossI reviewed the full diff across SummaryThis PR addresses five correctness bugs with well-structured fixes and thorough regression tests. Each fix is narrowly scoped and consistent with the patterns already established in the codebase. FindingsNo blocking bugs found. Detailed Notes
Module
Test coverage — All five fix paths have targeted regression tests that validate both the happy path and the specific failure mode. The module-output smooth test and lookup-dep-tables test both run full simulations to verify end-to-end correctness. VerdictCorrect. The patch is free of bugs and blocking issues. Existing code and tests will not break. |
Module references in Stella-imported models can include output refs where src starts with the module's own prefix (e.g. src="a.output" for module "a"). After normalization these collapse to the module name, creating false self-loops (a -> a) in the causal graph and downstream loop analysis. Filter these internal refs before normalizing, matching the existing filtering in build_module_inputs.
Code ReviewReviewed the three changed files: Analysis
Compat preservation: Straightforward fix —
Lookup table collection: The new loop at lines 4314-4332 matches the existing pattern in FindingsNo bugs found. Verdict: CorrectThe patch correctly addresses all five reported issues with consistent normalization, proper compat propagation, and complete module dependency handling in the implicit compilation path. All changes are covered by regression tests. Existing code and tests should not break. |
Review cycle summaryThis PR went through 3 review iterations with both Codex and Claude reviewing each round. Iteration 1 identified two classes of issues:
Both were addressed by extracting a Iteration 2 caught that the new normalization in Iteration 3 both reviewers confirmed no remaining actionable issues. |
Summary
This PR fixes five high-priority compiler/sync correctness bugs in batch 1:
model_causal_edgescompile_implicit_var_fragmentCompat.visibilitythrough initial + incremental salsa syncWhat changed
symbolic.rsdecl.off as u32with checked conversion (u32::try_from) insymbolize_module_decl.usizeoffsets to ensure symbolization rejects narrowing.db.rsmodel_causal_edges: normalize module-ref sources in both explicit and implicit module edge insertion paths.source_variable_from_datamodelandupdate_source_variable: preserveModule.compatinstead of resetting toCompat::default().compile_implicit_var_fragment:module·outputdependency handlingcompile_var_fragmentbehavior)db_tests.rsSMTH1(module.output, ...)SMTH1(LOOKUP(table_var, ...), ...))Verification
Ran targeted regressions and nearby sanity tests:
compiler::symbolic::tests::test_module_decl_offset_overflow_is_rejecteddb::db_tests::test_model_causal_edges_normalizes_inter_module_output_refsdb::db_tests::test_sync_preserves_module_visibility_from_datamodeldb::db_tests::test_incremental_sync_updates_module_visibilitydb::db_tests::test_incremental_compile_smooth_over_module_outputdb::db_tests::test_incremental_compile_implicit_lookup_dep_tablesdb::db_tests::test_implicit_module_offsets_in_flattened_mapdb::db_tests::test_sparse_per_element_gfs_preserve_table_indicesdb::db_tests::test_incremental_vs_monolithic_outputcargo fmt --checkAll pre-commit checks passed during commit.
Fixes #291
Fixes #293
Fixes #301
Fixes #304
Fixes #320