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:
parent
396051f5c0
commit
00533167b4
1 changed files with 5 additions and 4 deletions
|
|
@ -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,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue