TypeScript / JavaScript
Rulesets
Load policy source and replace the active prepared policy.A ruleset is the loaded policy that the wrapper prepares for solving. Here the wrapper owns one active policy/session pair; it does not expose a native ruleset pointer. See the ruleset concept for the language-independent model.
Load a policy
loadPolicy(domain, id, source) uses the public inline loader, computes the
UTF-8 source length and creates a reference session. A failed load preserves
the previous policy/session. Loading is rejected while a result is alive.
An accepted replacement clears the input buffer.
pg.loadPolicy('access', 'access.main', 'allow(X) :- safe(X).')The first argument selects a domain already registered with
registerDomain(). The second names this policy for the loader; the third is
the policy source. A source constant in that text must be declared in the
domain's atoms list. Request values supplied later with addFacts() are not
part of this source.
Replacing the active policy
Free any live result before loading another policy. A successful replacement
clears the previous request input, so add the new request's facts before
calling solve() again. If loading fails, the existing policy and session
remain available; inspect the resulting DatalogError rather than assuming
that a partial replacement took effect.
For a JSON manifest or multiple policies loaded as a set, use a binding that exposes that path: this wrapper currently offers the inline path only.