No description
Combines T3 (consumer registrations for the 7 new hook attrs) and T4 (pre-move state snapshots) since both modify apply.ts and gate the incoming wave of trigger primitives. T3 — Consumer registrations: Adds registerAttrConsumer() calls for the 7 trigger hook attrs added to ChessAttrMap (OnMoveHooks, OnTurnEndHooks, OnPromotionHooks, OnCheckReceivedHooks, OnCheckDeliveredHooks, OnMovedOntoSquareHooks, OnCapturedHooks). Without these, the load-time assertSeedConsumerIntegrity() check would fail loudly when the upcoming Wave 2 primitives start writing the attrs. T4 — Pre-move snapshots: Two new per-engine WeakMaps mirror the existing PRE_MOVE_HP_SNAPSHOTS lifecycle: - PRE_MOVE_CHECK_STATE_SNAPSHOTS: per-color royal IDs + their attacker IDs at onBeforeMove time, used by the upcoming on-check-received (edge-triggered transition into check) and on-check-delivered (revealed-attacker discovered check) evaluators. - PRE_MOVE_PROMOTION_PAWNS: pawn IDs eligible to promote this move (white pawns on rank 6, black pawns on rank 1) — feeds the upcoming on-promotion evaluator without re-walking the board post-move. Snapshots populate in onBeforeMove, expose read-only getters (getPreMoveCheckState, getPreMovePromotionPawns), and clear in onAfterMove inside try/finally to prevent leaks even if a trigger evaluator throws. Reuses the engine's existing attackProbe helper (via PIECE_TYPE_REGISTRY) and getActiveRoyalEntityIds for preset-aware royal resolution rather than computing check lines from scratch. Adds 4 new tests in apply.test.ts: snapshot capture, promotion-pawn flagging, post-move cleanup, and no-leak across 3 sequential moves. |
||
|---|---|---|
| .github/workflows | ||
| .sisyphus | ||
| docs | ||
| packages | ||
| scripts | ||
| .gitignore | ||
| eslint.config.js | ||
| lefthook.yml | ||
| LICENSE | ||
| package.json | ||
| playwright.config.ts | ||
| README.md | ||
| tsconfig.base.json | ||
| tsconfig.json | ||
| vitest.workspace.ts | ||
@paratype
A Doorenbos-style Rete II rules engine for TypeScript games, with an authoritative WebSocket chess demo.
Packages
packages/rete— Rete II engine corepackages/chess— Browser chess demo (React + Vite)packages/server— Authoritative Bun WebSocket server
Docs
- SPEC.md — Engine specification
- PHASES.md — Development phases & perf budgets
- RULES.md — Chess rule presets
- PROTOCOL.md — WebSocket message protocol
Getting Started
bun install && bun run check