TypeScript / JavaScript
Runtime EDB
Supply typed request facts as one atomic batch.The runtime EDB contains the facts for one evaluation. In this wrapper,
addFacts() collects them before solve(); it is not a policy-source loader.
See Runtime EDB for the underlying distinction.
Values
Use strings for symbols, booleans for booleans, and bigint for integers.
A number is accepted only when Number.isSafeInteger succeeds. Integer input
must fit signed int64; every integer returned by enumeration is a bigint.
"1", 1n and true are distinct values.
The shipped Fact type is { predicate: string; terms: InputValue[] }, where
InputValue is string | bigint | number | boolean.
pg.addFacts([
{ predicate: 'event', terms: [9007199254740993n, 'api', true, ''] },
{ predicate: 'ready', terms: [] },
])Arities zero through four are accepted. The domain still controls the declared arity. Embedded NUL and unpaired UTF-16 surrogates are rejected; valid strings are measured as UTF-8 bytes. There is no symbol-ID input API.
Transporting int64 does not extend policy literal or aggregate arithmetic.
min, max and sum retain their nonnegative integer domain and overflow
rejections. Two complete source facts with different event IDs both contribute
to sum, even when their numeric value matches; repeating a complete fact does
not contribute again.
Batch insertion
addFacts(facts) is one atomic batch across all its predicates. A malformed
last fact or exhausted input capacity leaves the earlier input unchanged.
Raw contributions are bounded before deduplication. The wrapper does not split
a large batch into hidden smaller commits.
Adding validates shape and input storage. Domain membership, declared arity and native solver limits are checked when solving. An accepted addition is not a promise that resolution will fit.
inputUsage() returns facts, textBytes and textCapacity.
clearFacts() resets the input when no result is alive. A failed solve keeps
the input for correction/retry and publishes no result.
pg.freeResult().clearFacts()
pg.addFacts([{ predicate: 'safe', terms: ['bob'] }])Freeing a result and clearing facts are different operations. To evaluate a new request, do both before adding that request's entire input.