refactor(engine): drop pointless FactValue double-cast in PresetState.set

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).
This commit is contained in:
Joey Yakimowich-Payne 2026-04-19 16:43:41 -06:00
commit 00533167b4
No known key found for this signature in database

View file

@ -259,13 +259,14 @@ class PresetStateImpl<T extends Record<string, unknown>>
}
set<K extends keyof T>(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,
);
}