TypeScript / JavaScript
Solving
Evaluate one input snapshot and manage the live result.After registering a domain and loading source, solving evaluates the current EDB snapshot. The wrapper retains one result for queries until it is released. This is the solve lifecycle in the JavaScript API.
Solving and lifetime
solve() publishes at most one live result. Release it with freeResult()
before changing input, solving again or replacing the policy. close() releases
the result, session, policy and input storage; subsequent operations reject
with INVALID_STATE.
pg.freeResult().clearFacts()
pg.addFacts([{ predicate: 'safe', terms: ['bob'] }]).solve()With one session, a new solve does not preserve an old result across failure. Results returned to JavaScript by enumeration and error diagnostics are copies; they remain valid after releasing native storage.
Keep close() in a finally block. A JavaScript object becoming unreachable
does not release the native handles owned by the wrapper.
Derived fact count
derivedFactCount() returns the total IDB count, including auxiliary
relations. It is not the number of query-visible answers or the number of
input facts.
Fingerprints
fingerprints() returns policy, session and execution fingerprints. The
execution fingerprint excludes EDB input. None proves that an execution is
correct.
The returned strings identify compiled policy/session/execution state. Do not use an execution fingerprint as a substitute for recording a request's facts or for checking the answer to a query.