houserules/.sisyphus/notepads/modifier-profiles-t3/learnings.md

2.4 KiB

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.

[2026-04-19 17:28] Wave 2 batch B

  • Added absorb-damage-with-attribute primitive + tests.