From 00533167b4232cf7badb404388b5f728d2518bd1 Mon Sep 17 00:00:00 2001 From: Joey Yakimowich-Payne Date: Sun, 19 Apr 2026 16:43:41 -0600 Subject: [PATCH] refactor(engine): drop pointless FactValue double-cast in PresetState.set MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit FactValue is `unknown` in @paratype/rete, so `value as unknown as FactValue` was `unknown` → `unknown` → `unknown` — zero type narrowing, just noise. The stale comment also claimed FactValue was `string | number | boolean | null` (it isn't, and hasn't been for a while). Pass value directly; update the comment to reflect actual serialization responsibility (caller ensures JSON-round-trippable for event-log replay). --- packages/chess/src/engine.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/chess/src/engine.ts b/packages/chess/src/engine.ts index 0f2ef45..fc7e8be 100644 --- a/packages/chess/src/engine.ts +++ b/packages/chess/src/engine.ts @@ -259,13 +259,14 @@ class PresetStateImpl> } set(key: K, value: T[K]): void { - // The rete session validates that `value` is a legal FactValue - // (string | number | boolean | null). Passing objects here will - // throw — a deliberate constraint to keep facts serialization-safe. + // `FactValue` is `unknown` in the rete package, so any `T[K]` + // assigns directly. Runtime serialization guarantees (the value + // round-trips through JSON in event-log replay) are the caller's + // responsibility. this.#session.insert( PRESET_STATE_ENTITY, this.#attrOf(key as string), - value as unknown as import("@paratype/rete").FactValue, + value, ); }