refactor: hoist scenario-template registry out of materializer orchestrator#334
Merged
Conversation
…trator Closes #333. Before: `materializer/src/index.ts` open-coded one `emitTemplateSuites()` block per template (EdgeLifecycle, EntityLifecycle, UpdatedFieldVisibleOnReadBack, StateTransitionVisibleAfterAction) and `buildCoverage()` received a duplicate hardcoded `templateOutputDirs` map. Adding a template was three edits across two files — every site had to agree on name + output dir or coverage would silently skip a template the orchestrator emitted (or vice versa). After: a single `materializer/src/templateRegistry.ts` declares `TEMPLATE_REGISTRY: readonly TemplateBinding[]`. The orchestrator loops over it for both wipe-and-emit and the `buildCoverage()` call. `buildCoverage` now takes `templates: readonly TemplateBinding[]` directly instead of a name→dir Record. Adding a template is now one entry in one file (plus the planner-side TBox + ABox edits). A new L3-style guard in `tests/codegen/template-registry.test.ts` asserts symmetric equality between the active config's scenario-templates ABox and `TEMPLATE_REGISTRY` so an ABox row without a registry entry (or vice versa) fails red — the next class of drift this refactor opens up. The existing coverage tests (`tests/codegen/coverage.test.ts`, added in #332) are updated to the new signature. Behaviour-preserving: pipeline output is unchanged (testsuite:generate still reports `+26 lifecycle suites, -73 suppressed by scenario-template coverage` against the same pinned spec). All 633 tests pass.
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors the materializer orchestrator to remove hardcoded scenario-template wiring by introducing a single template registry used for both template suite emission and coverage-based suppression.
Changes:
- Added
TEMPLATE_REGISTRY(template name + outputDir) as a single source of truth for scenario-template wiring. - Updated the orchestrator to iterate the registry for wipe-and-emit, and passed it directly to
buildCoverage(). - Updated coverage extraction API and tests to use the new registry-based
templatesinput.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/codegen/template-registry.test.ts | Adds a guard test to enforce symmetry between the active config’s scenario-templates ABox and TEMPLATE_REGISTRY. |
| tests/codegen/coverage.test.ts | Updates buildCoverage unit tests to pass templates instead of templateOutputDirs. |
| materializer/src/templateRegistry.ts | Introduces the centralized registry of scenario templates (name + outputDir). |
| materializer/src/index.ts | Replaces per-template emission and hardcoded coverage wiring with a loop over TEMPLATE_REGISTRY. |
| materializer/src/coverage.ts | Changes buildCoverage to accept templates: readonly TemplateBinding[] and derives the name→outputDir lookup internally. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Closed
5 tasks
- templateRegistry.ts: TBox is name-agnostic; only ABox + registry edits are mandatory when adding a new template (TBox/emitter changes only when shape changes). - coverage.ts: clarify that suppression extends when included in the templates option (TEMPLATE_REGISTRY in production). - coverage.test.ts: rename test to reference the templates option, since buildCoverage has no knowledge of TEMPLATE_REGISTRY.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #333. Follow-up to #332.
Problem
materializer/src/index.tsopen-coded oneemitTemplateSuites()block per scenario template (EdgeLifecycle, EntityLifecycle, UpdatedFieldVisibleOnReadBack, StateTransitionVisibleAfterAction) andbuildCoverage()received a duplicate hardcodedtemplateOutputDirsmap. Adding a template was three edits across two files — every site had to agree on name + output dir or coverage would silently skip a template the orchestrator emitted (or vice versa).This was the coupling smell flagged during #332 review: the materializer claims to be config-agnostic, but its orchestrator hardcoded the template list.
Change
materializer/src/templateRegistry.tsdeclaresTEMPLATE_REGISTRY: readonly TemplateBinding[]— one entry per template,{ name, outputDir }. Single source of truth.materializer/src/index.tsnow loops over the registry for wipe-and-emit and passes it straight intobuildCoverage().materializer/src/coverage.tsacceptstemplates: readonly TemplateBinding[]instead oftemplateOutputDirs: Record<string, string>— same semantics, one fewer place where the map can drift.emitTemplateSuitesrenderer, so noemitterfield is needed onTemplateBinding. Step 2 of refactor(materializer): decouple template emission + coverage from hardcoded template registry #333 (deriving the registry from the ABox) is deferred until a future template needs a different renderer.Tests
tests/codegen/template-registry.test.tsasserts symmetric equality between the active config'sscenario-templates.jsonABox andTEMPLATE_REGISTRY, plus that registryoutputDirs are distinct. Catches the next class of drift the refactor opens up: ABox row without a registry entry (or vice versa) fails red.tests/codegen/coverage.test.ts(added in feat: suppress feature specs covered by scenario-template ontology #332) updated to the new signature.Behaviour preservation
testsuite:generateagainst the pinned spec still reports:All 633 tests pass; pipeline output for
camunda-ocais unchanged.Pre-push gate
tsc --noEmit× 6 workspace tsconfigstestsuite:generate+generate:request-validation(regen)npm test(633 passed, 4 skipped)