Skip to content

refactor: make materializer a generic transformer (#335)#336

Merged
jwulf merged 2 commits into
mainfrom
refactor/generic-materializer-335
May 21, 2026
Merged

refactor: make materializer a generic transformer (#335)#336
jwulf merged 2 commits into
mainfrom
refactor/generic-materializer-335

Conversation

@jwulf
Copy link
Copy Markdown
Member

@jwulf jwulf commented May 21, 2026

Closes #335.

The materializer no longer maintains a hand-written registry mapping template names to short on-disk directory names. The active config's scenario-templates ABox is the single source of truth: every template declared there is emitted to generated/<config>/playwright/templates/<TemplateName>/, mirroring the planner's scenarios/templates/<TemplateName>/ layout.

Adding a new template now requires only a new ABox row (plus, eventually, a renderer when one is needed).

Layout change

Before After
playwright/edges/<Name>.lifecycle.spec.ts playwright/templates/EdgeLifecycle/<Name>...
playwright/entities/<Name>.lifecycle.spec.ts playwright/templates/EntityLifecycle/<Name>...
playwright/runtime-entities/<Name>... playwright/templates/UpdatedFieldVisibleOnReadBack/<Name>...
playwright/state-transitions/<Name>... playwright/templates/StateTransitionVisibleAfterAction/<Name>...

What changed

  • materializer/src/templateRegistry.tsdeleted. index.ts now calls loadScenarioTemplatesAbox() and iterates names.
  • materializer/src/coverage.tstemplates: TemplateBinding[] replaced with templateNames: readonly string[]. New templateOutputDir(name) helper derives templates/<name>/ from the name alone. No taxonomy table.
  • materializer/src/playwright/templateEmitter.ts — support-import paths bumped from ../support/... to ../../support/... because suites are now one directory deeper.
  • L3 invariants in configs/camunda-oca/regression-invariants.test.ts retargeted to the new paths.
  • tests/codegen/template-registry.test.tsdeleted. The symmetry it guarded (registry name ↔ ABox name) is now structural; the ABox IS the source. Loader already enforces no-duplicate names.
  • tests/codegen/coverage.test.ts — updated to the new templateNames signature.
  • README, JSDoc comments updated.

Counts byte-stable

117 endpoints, +70 variant suites, +26 lifecycle suites, -73 suppressed by scenario-template coverage — unchanged. Only on-disk paths moved.

Pre-push gate

  • npm run build:analyser && npm run build:emitter-sdk
  • tsc --noEmit (extractor, planner, emitter-sdk, materializer, request-validation, tests) ✅
  • npm run lint
  • TEST_SEED=snapshot-baseline npm run testsuite:generate && npm run generate:request-validation
  • npm test → 631 passed, 4 skipped ✅

The materializer no longer maintains a hand-written registry mapping
template names to short on-disk directory names. The active config's
scenario-templates ABox is the single source of truth: every template
declared there is emitted to
`generated/<config>/playwright/templates/<TemplateName>/`, mirroring
the planner's `scenarios/templates/<TemplateName>/` layout. Adding a
new template now requires only a new ABox row (plus, eventually, a
renderer when one is needed).

Layout change (visible to anyone reading the generated tree):

  generated/<config>/playwright/edges/             -> templates/EdgeLifecycle/
  generated/<config>/playwright/entities/          -> templates/EntityLifecycle/
  generated/<config>/playwright/runtime-entities/  -> templates/UpdatedFieldVisibleOnReadBack/
  generated/<config>/playwright/state-transitions/ -> templates/StateTransitionVisibleAfterAction/

What changed:

- `materializer/src/templateRegistry.ts` deleted. The materializer
  reads the ABox via `loadScenarioTemplatesAbox()` and iterates the
  resulting names.
- `materializer/src/coverage.ts` now takes `templateNames: readonly string[]`
  and derives `emittedSpec = templates/<name>/<subject>.lifecycle.spec.ts`
  via the new `templateOutputDir(name)` helper. No taxonomy table.
- `materializer/src/playwright/templateEmitter.ts` support-import
  paths bumped to `../../support/...` to reflect the one-level-deeper
  spec location.
- L3 invariants (`configs/camunda-oca/regression-invariants.test.ts`)
  retargeted to the new paths. `+26 lifecycle suites, -73 suppressed`
  is unchanged; only the on-disk paths moved.
- `tests/codegen/template-registry.test.ts` deleted (the symmetry it
  guarded — registry name ↔ ABox name — is structural now: the ABox
  IS the source). Loader already enforces no-duplicate names.
- README, JSDoc comments updated.

Counts byte-stable: 117 endpoints, +70 variant suites,
+26 lifecycle suites, -73 suppressed.

Closes #335
Copilot AI review requested due to automatic review settings May 21, 2026 05:12
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors the materializer to treat the active config’s scenario-templates ABox as the single source of truth, eliminating the hand-maintained template registry and aligning Playwright output paths with the planner’s scenarios/templates/<TemplateName>/ structure.

Changes:

  • Removed TEMPLATE_REGISTRY and iterated template names directly from scenario-templates.json (ABox) during materialization.
  • Updated coverage extraction to accept templateNames and derive template output directories mechanically (templates/<TemplateName>/).
  • Migrated generated Playwright suite layout to generated/<config>/playwright/templates/<TemplateName>/... and retargeted invariants/docs/tests accordingly.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/codegen/template-registry.test.ts Deleted now-obsolete registry↔ABox symmetry guard test.
tests/codegen/coverage.test.ts Updated buildCoverage calls to use templateNames.
README.md Updated documented template-derived suite output path to the new layout.
path-analyser/src/types.ts Updated JSDoc path reference to the new template output layout.
materializer/src/templateRegistry.ts Deleted the manual template registry and bindings.
materializer/src/playwright/templateEmitter.ts Adjusted support import paths for the deeper templates/<TemplateName>/ suite nesting.
materializer/src/index.ts Loads template names from the scenario-templates ABox; emits suites into per-template directories derived from the name.
materializer/src/coverage.ts Replaced registry-based bindings with templateNames and introduced templateOutputDir(name).
configs/camunda-oca/regression-invariants.test.ts Retargeted invariants and spec-path checks to playwright/templates/<TemplateName>/....

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread materializer/src/playwright/templateEmitter.ts Outdated
… JSDoc

Copilot reviewer noted that the JSDoc on scenariosDir and outDir still
referenced EdgeLifecycle specifically, even though emitTemplateSuites
is now driven by templateNames and used for both EdgeLifecycle and
EntityLifecycle (and future templates). Replace the hard-coded
template name in both paths with <TemplateName> so the documentation
stays accurate as new templates are added.
@jwulf jwulf merged commit 562f49f into main May 21, 2026
1 check passed
@jwulf jwulf deleted the refactor/generic-materializer-335 branch May 21, 2026 05:50
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.

refactor: make materializer a generic transformer — derive output dir from ABox template name

2 participants