// The try covers setup as well as the displayed example. try { // Page reference context: the first fact nearly fills native text storage. // The next addFact fits the fact capacity but must raise PAYLOAD_TOO_LARGE // because its strings exceed the remaining text capacity. The example checks it. const engine = keepEngine(await Engine.create({ profile: 'small' })) engine.registerDomain('documents', [ Predicate.edb('user', 1), Predicate.edb('owns', 2), Predicate.edb('blocked', 1), Predicate.idbQuery('allow', 2), ], []) const ruleset = engine.loadInlineRuleset('documents', 'reference-context', 'allow(User, Doc) :- owns(User, Doc), not(blocked(User)).') const input = ruleset.edb({ factCapacity: 2, textCapacity: 12 }) input.addFact('user', ['alice']) // Reuse the copied engine diagnostic when adding operation context. /* API_REFERENCE_EXAMPLE */ } finally { // Engine.close cascades to every ruleset, input, session and result it owns. closeEngines() }