Skip to content

refactor: add template-backed simulation codegen#654

Merged
jayscambler merged 2 commits intorefactor/mission-lifecycle-transitionsfrom
refactor/template-backed-simulation-codegen
Apr 9, 2026
Merged

refactor: add template-backed simulation codegen#654
jayscambler merged 2 commits intorefactor/mission-lifecycle-transitionsfrom
refactor/template-backed-simulation-codegen

Conversation

@jayscambler
Copy link
Copy Markdown
Contributor

Summary

  • move simulation-family code generation onto a template-backed rendering path
  • add a shared placeholder renderer with unresolved-token protection
  • keep generated simulation behavior stable while reducing giant inline string construction in the generator

TDD / DDD / DRY framing

This is the next stacked architectural PR after #653.

Bounded extraction:

  • Simulation Codegen Rendering — isolate template rendering from simulation spec normalization/mapping

Test-first work:

  • added a template renderer test first
  • added a simulation codegen test asserting all placeholders resolve and the output remains executable
  • implemented the renderer and moved simulation code shape into a dedicated template module

Changes

New modules

  • ts/src/scenarios/codegen/template-renderer.ts
  • ts/src/scenarios/codegen/templates/simulation-template.ts

Updated module

  • ts/src/scenarios/codegen/simulation-codegen.ts
    • now builds replacements and renders the dedicated template instead of assembling one giant inline string directly

New tests

  • ts/tests/simulation-codegen-template.test.ts
    • deterministic placeholder rendering
    • simulation codegen emits fully rendered executable source

Validation

  • cd ts && npx vitest run tests/simulation-codegen-template.test.ts tests/codegen.test.ts tests/codegen-runtime.test.ts
  • cd ts && npm run lint

Why this matters

This addresses the remaining code-review recommendation to move away from large monolithic codegen strings. It also establishes a reusable rendering seam for future family-by-family migration to template-backed generation.

@jayscambler jayscambler merged commit 18430d4 into refactor/mission-lifecycle-transitions Apr 9, 2026
4 checks passed
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