feat(engine): custom modifier descriptor types
T3 Wave 1 (T3). Defines the user-authored CustomModifierDescriptor
shape that Wave 3 (validator, Zod schema, library, apply) and Wave 4
(server registration, editor UI) build on.
- CustomModifierId: branded string (mirrors asEntityId), with the
asCustomModifierId() trust-boundary helper.
- CustomModifierDescriptor:
- type: 'data' discriminator (T4 will add 'scripted' alongside).
- id, name (1-40), description (0-200), version: 1 literal.
- primitives: readonly EffectPrimitiveNode[] (re-exported from
primitives/types so consumers have one import).
- targetAttrs: readonly ChessAttrKey[] for editor conflict surfacing.
- uiForm: 'primitive-composer' literal (routes editing to the
custom-modifier composer UI in T25).
- source: 'custom' for library typing.
- Optional author, createdAt (auto-populated by library save).
Persistence, validation, Zod schema, and apply() arrive in Wave 3.
This commit is contained in:
parent
2e655a0c1a
commit
2c36925d0b
4 changed files with 129 additions and 0 deletions
22
.sisyphus/notepads/modifier-profiles-t3/learnings.md
Normal file
22
.sisyphus/notepads/modifier-profiles-t3/learnings.md
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
# Modifier Profiles T3 — Learnings
|
||||
|
||||
## [2026-04-19 17:14] Task: T3
|
||||
|
||||
- Added `packages/chess/src/modifiers/custom/types.ts` with branded `CustomModifierId` and `asCustomModifierId` helper that mirrors `asEntityId` trust-boundary wording/style from `packages/rete/src/schema.ts`.
|
||||
- Added `CustomModifierDescriptor` with literal discriminators (`type: "data"`, `version: 1`, `uiForm: "primitive-composer"`, `source: "custom"`) and a forward-design JSDoc note for future `"scripted"` descriptors in T4.
|
||||
- Divergence from ideal import shape: `EffectPrimitiveNode` is a local fallback interface in `custom/types.ts` because `packages/chess/src/modifiers/primitives/types.ts` is not yet committed in this branch state. Included TODO to swap to `../primitives/types.js` import immediately when T2 lands.
|
||||
- Added `packages/chess/src/modifiers/custom/index.ts` as a focused barrel with explicit Wave 3 scope boundary comment.
|
||||
- Added `packages/chess/src/modifiers/custom/types.test.ts` with four scenarios: branded helper runtime/type round-trip, descriptor structure assignment, readonly `targetAttrs` typing, readonly `primitives` typing.
|
||||
|
||||
## [2026-04-19 17:13] Task: T2
|
||||
|
||||
- Added `packages/chess/src/modifiers/primitives/types.ts` with T3 primitive core contracts:
|
||||
- `PrimitiveKind` union with exactly 15 ADR-2 primitive ids.
|
||||
- `EffectPrimitive<Params>` descriptor shape (`paramsSchema: ZodType<Params>`, `apply(ctx, params): void`, optional `maxDepth`, optional `childPrimitives`).
|
||||
- `EffectPrimitiveNode` runtime node shape (`kind`, `params`).
|
||||
- `PrimitiveApplyContext` (`engine`, `session`, `pieceId`, `depth`, `descriptor`).
|
||||
- Forward-declared `CustomModifierDescriptor` placeholder interface to avoid circular dependency with future `../custom/types.ts`.
|
||||
- Added `packages/chess/src/modifiers/primitives/registry.ts` + singleton export.
|
||||
- Mirrored `MODIFIER_REGISTRY` class shape exactly: private `Map`, duplicate guard throw, `register/get/list/has`, generic register call-site support.
|
||||
- Added `packages/chess/src/modifiers/primitives/index.ts` barrel with explicit Wave-2 side-effect-registration stub comment.
|
||||
- Added `packages/chess/src/modifiers/primitives/registry.test.ts` with 6 scenarios: round-trip get, duplicate throw, list order stability, `has()` accuracy, unknown kind miss, and generic type preservation at register call site.
|
||||
Loading…
Add table
Add a link
Reference in a new issue