Skip to content

engine: recurrence inside a module with wired inputs reports a false cycle #573

Closed as not planned

Description

@bpowers

The engine resolves element-by-element recurrences (like x[t2] = x[t1] + 1) by looking for dependency cycles in the model as if it had no module inputs.
When the model is used as a module with wired inputs, its real dependencies differ, so a recurrence inside such a module can be missed and reported as a circular dependency.

Example

Unknown; no model in the repo hits this.
All the recurrence test models (ref.mdl, interleaved.mdl, init_recurrence.mdl) are root models with no inputs.

Why it matters

The failure is a spurious circular-dependency error, never a wrong number: the final dependency check runs on the real wired-up graph and rejects anything left unresolved.
It would only affect a user who writes a per-element recurrence inside a module that takes inputs.

Fix

Pass the module's real input names into recurrence resolution instead of an empty list.
Cost: resolution is cached once per model today; with inputs it would be cached once per distinct wiring.
Alternative: leave it, since the failure is a clear error, and revisit if a real model hits it.

Pointers

  • src/simlin-engine/src/db/dep_graph.rs: resolve_recurrence_sccs (its rustdoc explains the no-input choice), no_input_var_info, model_dependency_graph_impl

Activity

  1. added
    engine
    on Jun 8, 2026
  2. added
    bug
    on Oct 12, 2026
  3. changed the title [-]engine: element-cycle dt-recurrence SCC resolution uses no-input build_var_info wiring; Phase 2 must plumb real module_input_names before consuming ResolvedScc.element_order[/-] [+]engine: recurrence inside a module with wired inputs reports a false cycle[/+] on Oct 12, 2026
  4. added
    wontfix
    on Oct 12, 2026
  5. bpowers commented on Oct 12, 2026

    @bpowers
    OwnerAuthor

    Closing as won't fix.

    The worst case is a clear error, never a wrong number: the final check runs on the wired graph. No real model hits it, and the fix costs per-wiring caching. The no-input choice is documented in the resolve_recurrence_sccs rustdoc; reopen if a user hits it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugenginewontfix

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions