Skip to content

Module visibility dropped to Private during Salsa sync in db.rs #320

Closed

Description

@bpowers

Description

In src/simlin-engine/src/db.rs, the Module variant in reconstruct_variable always receives Compat::default() during Salsa sync (around lines 2399-2404 and 2515-2519). This means the Module's visibility field -- now carried inside the Compat struct -- is silently reset to Private during incremental compilation round-trips.

While can_be_module_input is preserved because it is tracked as a separate Salsa field, visibility for Modules has no corresponding tracked field and gets lost.

Pre-existing behavior

This is not a regression. Before PR #319 (which moved compat fields into a Compat struct), visibility was always hardcoded to Private for Modules in reconstruct_variable. The refactor into Compat makes this data loss more visible: the Module now carries a full Compat struct, but its visibility component is silently zeroed out.

Why it matters

  • Correctness: If Module visibility is ever set to something other than Private (e.g., Public), that information is silently discarded after Salsa round-trips. This could cause incorrect behavior in any future use of Module visibility.
  • Maintainability: The Compat struct creates an expectation that all its fields are preserved consistently. Having one field silently dropped is a subtle trap for future development.

Component(s) affected

  • src/simlin-engine/src/db.rs -- reconstruct_variable function, Module variant handling

Possible approaches

  1. Add a tracked Salsa field for Module visibility (similar to can_be_module_input) and populate it during sync_variables.
  2. If Module visibility is intentionally always Private, add a code comment explaining why and consider whether the Compat struct should even carry visibility for Modules.

Context

Identified during PR #319 review (move non_negative, can_be_module_input, visibility into Compat struct).

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions