Skip to content

serve: external edits to never-opened models skip the error check #478

Done

Description

@bpowers

When a model file changes on disk, the simlin-serve file watcher is meant to reject an external edit that introduces new compile errors and keep the last good version in memory.
For a model nobody has opened yet, the check does nothing: the in-memory copy is loaded from disk on first access, and by then the disk already holds the new content, so the edit is compared against itself and always passes.
The comment in the code claims the opposite.

Example

  1. Start simlin-serve in a directory containing foo.stmx; do not open it in the browser or via MCP.
  2. In another editor, save foo.stmx with a reference to an undefined variable.
  3. The watcher broadcasts the change and the next GET returns the broken model.

If foo.stmx is opened first, step 2 is rejected as intended.

Why it matters

Found in code review, not seen in use.
For an unopened model there is no earlier version anyone has seen, and what is on disk is arguably the right thing to serve, so the practical harm is small.
The misleading comment is the bigger problem.

Fix

Make the behavior explicit: if the model was never loaded into memory, accept the disk content and log that no comparison was possible; fix the comment to match.
Alternative: load every model at startup scan so there is always a baseline; this costs parse time and memory for every file under the root.

Pointers

  • src/simlin-serve/src/watcher.rs, handle_model_change (the baseline match and its comment)
  • src/simlin-serve/src/registry.rs, get_or_init_doc (lazy load from disk)
  • src/simlin-serve/src/scan.rs, scan_into_registry

Activity

  1. added
    bug
    on Apr 26, 2026
  2. added
    backend
    on Oct 12, 2026
  3. changed the title [-]Watcher validation gate is a no-op for never-opened entries (first-touch baseline bug)[/-] [+]serve: external edits to never-opened models skip the error check[/+] on Oct 12, 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

    backendbug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions