Skip to content

SD-AI relationships may be incomplete for models with pre-existing equation errors #433

@bpowers

Description

@bpowers

Description

When using EditModel on an SD-AI JSON file that has pre-existing equation errors (errors NOT introduced by the current edit), the error gate at edit_model.rs:296 passes (it only checks for new errors), and the write-back regenerates relationships from the current equation state. Since compute_link_polarities() cannot derive dependencies for unparseable equations, the generated relationships array omits entries for broken variables.

This is by design (generate_relationships replaces the old re-parse-and-filter approach, per PR #432), and the current behavior is arguably more correct: we should not emit relationships for equations we cannot parse. However, if an AI consumer relies on the relationships array being complete during incremental repair of a broken model, the partial output could be unexpected.

Why it matters

  • Developer/AI experience: An AI agent iteratively repairing a broken model may assume the relationships array is complete and miss dependency information for variables with pre-existing errors.
  • Correctness: The omission is technically accurate (we cannot determine relationships for unparseable equations), but the implicit contract -- that relationships reflect the full model -- is violated.

Components affected

  • src/simlin-engine -- edit_model.rs (error gate logic), generate_relationships / compute_link_polarities

Possible approaches

  • Merge generated relationships with original file relationships for models that have pre-existing errors, preserving original entries for variables not covered by the generated set.
  • Document the behavior so AI consumers know to expect partial relationships when the model has parse errors.
  • Add a metadata field (e.g., relationships_complete: bool) to signal whether the array covers all variables.

Discovery context

Identified during analysis of the SD-AI relationships array generation design (branch sdai-relationships).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions