Skip to content

core: two TypeScript canonicalize copies that disagree on dotted names #624

Open

Description

@bpowers

The TypeScript code has two implementations of identifier canonicalization, and only one matches the Rust engine's canonicalize in src/simlin-engine/src/common.rs.
@simlin/core's canonicalize, used throughout the diagram editor, has no handling for dots or quoted parts.
@simlin/engine carries its own complete copy, canonicalizeIdent, which is tested against the Rust output.
There should be one implementation, and it should match Rust.

Example

input Rust and canonicalizeIdent @simlin/core canonicalize
model.variable model·variable model.variable
"a.b" a․b (U+2024, the literal-period marker) a.b

Why it matters

The two copies will drift, and the inputs that expose a difference (dotted or quoted names) are rare enough that drift would go unnoticed.
The diagram editor canonicalizes with the incomplete version, so a dotted or quoted name it computes may not match the engine's key for the same variable.
No failure has been observed; the difference is known from reading the code.

Fix

Move canonicalizeIdent (and its test corpus) into @simlin/core as the single canonicalize, and have @simlin/engine import it.
Before switching, audit the @simlin/core callers in src/diagram for code that relies on a dot surviving canonicalization (for example module-wiring.ts, which accepts a literal . as a module separator on read).

Pointers

  • src/core/canonicalize.ts
  • src/engine/src/internal/canonicalize.ts and src/engine/tests/canonicalize.test.ts
  • src/simlin-engine/src/common.rs: canonicalize, the reference behavior

Activity

  1. added
    engine
    hygiene
    javascript
    on May 22, 2026
  2. changed the title [-]ts: two divergent canonicalize implementations (@simlin/core incomplete vs @simlin/engine Rust-faithful)[/-] [+]core: two TypeScript canonicalize copies that disagree on dotted names[/+] on Oct 12, 2026
  3. added
    frontend
    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

    enginefrontendhygienejavascript

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions