Skip to content

ltm: failed implicit-helper fragment compile emits no diagnostic (model_ltm_fragment_diagnostics skips model_ltm_implicit_var_info) #741

Closed

Description

@bpowers

Summary

model_ltm_fragment_diagnostics (src/simlin-engine/src/db/ltm/compile.rs, ~line 1387) iterates only model_ltm_variables(db, model, project).vars -- the LTM synthetic variables themselves (link scores, loop scores, pathway/composite vars, synthetic aggs). It never scans the LTM implicit-helper fragments registered via model_ltm_implicit_var_info -- the helper auxes synthesized during LTM equation parsing, e.g. the $⁚$⁚ltm⁚link_score⁚...⁚0⁚arg0 PREVIOUS-capture helpers minted by builtins_visitor::make_temp_arg when an LTM equation contains PREVIOUS(<expr>).

When such a helper's fragment fails to compile, assemble_module (src/simlin-engine/src/db/assemble.rs, ~lines 1405-1419) silently drops the fragment exactly as it does for synthetic vars: the helper keeps its layout slot, no bytecode writes it, and it reads a constant 0 at runtime -- corrupting every link score that consumes it. Unlike the synthetic-var path, no Warning is emitted anywhere.

Concretely demonstrated during adversarial review: a fragment helper holding SIZE(pop[*] * 2) that fails to compile produces a link score of -500 instead of 1.0, with zero diagnostics.

Why it matters

This is the same silent-stub hazard class as the closed #546/#548 (and the open #683's absent-ident variant), but for the implicit-helper compile path rather than the synthetic-variable path. The whole point of model_ltm_fragment_diagnostics (added to close that class) is that a degraded LTM analysis must be visible instead of silently wrong; the implicit-helper leg of the same assembly path escapes it entirely.

Severity low-medium: silent wrong scores, but only reachable when a helper fragment actually fails to compile -- the currently-known generators of such failures are being fixed separately (branch ltm-core-batch).

Components affected

  • src/simlin-engine/src/db/ltm/compile.rs -- model_ltm_fragment_diagnostics (~line 1387; the pass to extend), compile_ltm_implicit_var_fragment (the compile path whose failures go unreported)
  • src/simlin-engine/src/db/ltm/mod.rs -- model_ltm_implicit_var_info (the registry of implicit helpers the pass should cover)
  • src/simlin-engine/src/db/assemble.rs -- ~lines 1405-1419, the silent fragment drop

Suggested fix

Extend model_ltm_fragment_diagnostics (or add a sibling pass driven from the same model_all_diagnostics gate) to iterate model_ltm_implicit_var_info and compile each implicit helper the way assemble_module does (compile_ltm_implicit_var_fragment), emitting the existing "failed to compile; it keeps a layout slot but no bytecode, so it evaluates to a constant 0" Warning for each failure -- mirroring the synthetic-var loop verbatim.

Discovery context

Identified during adversarial review of LTM work on branch ltm-core-batch; separate from the bug under review. Part of LTM tracking epic #488. Related: #546/#548 (closed; the synthetic-var silent-stub class this pass was built to catch), #683 (the absent-cross-module-ident case the pass also misses), #738 (a fragment failure the pass DOES catch -- the Warning fires there).

Activity

  1. added
    ltm
    on Jun 10, 2026
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

    ltm

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions