Skip to content

Codegen: engine setup seam + consistent _block_key#313

Merged
milanofthe merged 1 commit into
mainfrom
refactor/engine-codegen-seam
Jun 2, 2026
Merged

Codegen: engine setup seam + consistent _block_key#313
milanofthe merged 1 commit into
mainfrom
refactor/engine-codegen-seam

Conversation

@milanofthe
Copy link
Copy Markdown
Member

Two related codegen cleanups, no behaviour change for the default (pathsim) build.

1. Engine codegen seam. New engineCodegen.ts exports generateEngineSetup(importGroups), returning null by default (no extra code). pathsimRunner.ts calls it right after the imports in both the runtime and the export generators; when non-null it emits a # <header> section (banner on export) with the engine's setup lines. This is the codegen counterpart to the worker-side engineInstall seam: an alternate engine can inject setup (e.g. class-level port() wraps for toolbox blocks) without forking the shared codegen.

2. Consistent block identity. The generated _node_id_map keyed on raw id(var), while _apply_mutations (dynamic add/remove) and the scope/spectrum extraction already key on _block_key(...). _block_key returns a stable block_id when the engine exposes one and falls back to id() otherwise — so for pathsim this is identical, but it removes the static/dynamic inconsistency (a latent bug for any engine where id() isn't stable across wrappers).

svelte-check: 0 errors/0 warnings.

@milanofthe milanofthe merged commit 7b8512a into main Jun 2, 2026
4 checks passed
@milanofthe milanofthe deleted the refactor/engine-codegen-seam branch June 2, 2026 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant