Skip to content

Interface: ForwardChainRequest

@kortexya/reasoninglayer


@kortexya/reasoninglayer / ForwardChainRequest

Defined in: src/types/inference.ts:725

Request for forward chaining inference.

Serialization format: Uses untagged TermInputDto / FeatureInputValueDto.

optional emitProvenance?: boolean

Defined in: src/types/inference.ts:790

Emit W3C PROV-O lineage for this run (default: false).

When true, the run’s derivation provenance (which rule and which antecedents produced each derived fact) is reified into prov:wasDerivedFrom / prov:wasAttributedTo Ψ-terms and persisted, so lineage becomes ordinary facts the engine can query (OSFQL / backward chaining) and serialise (RDF export) — not an opaque side index. Forces real derivation, bypassing the derivation cache.

Distinct from enableProvenanceTags, which attaches confidence scores to the response rather than persisting queryable lineage.


optional enableProvenanceTags?: boolean

Defined in: src/types/inference.ts:748

Whether to include provenance tags (confidence scores) in the response.


optional initialFacts?: TermInputDto[]

Defined in: src/types/inference.ts:727

Initial facts (optional — uses existing facts if not provided).


optional keepDerived?: boolean

Defined in: src/types/inference.ts:746

KEEP the run’s derivations resident in the tenant’s store instead of rolling them back, so a later MATCH reads them.

Default false, and “ephemeral” means ROLLED BACK rather than merely unwritten: the engine removes every wrapper and inner copy the run created before it answers. So a default run reports a derivedCount and leaves the store exactly as it found it — forward chaining is not a repair door. To re-materialise a tenant use OSFQL CHAIN; or AdminClient.rebuildDerivedFacts.

Not durable, and never was: the engine’s old write stored only the meta.clause wrapper of each conclusion and never the inner ground copy a reader returns, so nothing survived a restart. That write is gone, and the flag now says what it always did. Named persistDerived until the engine renamed the wire field to keep_derived.


optional maxIterations?: number

Defined in: src/types/inference.ts:750

Maximum number of derivation iterations.


optional planRuleOrder?: boolean

Defined in: src/types/inference.ts:804

Plan the rule order with the engine’s native MCTS over its installed policy/value scorer (default: false).

The planner runs 50 simulations to depth 20, with up to 10 planning children. Execution still checks every premise and keeps every rule.

The engine answers 503 with code mcts_scorer_unavailable when no scorer is installed, and 422 with code mcts_tagged_inference_unsupported when enableProvenanceTags is also set.


optional timeoutMs?: number | null

Defined in: src/types/inference.ts:776

A server-side deadline for this derivation, in milliseconds.

The chainer checks it cooperatively — at every fixpoint-iteration boundary, at every rule application, and inside each rule’s own candidate loop — and the route answers 504 when it passes. Clamped by the deployment’s forward-chaining time limit.

Omitted means that backstop (300 s by default), which is deliberately longer than the safe-method one: a full materialisation over a large tenant legitimately takes longer than a GET handler. 0 is the explicit opt-out.

A deadline does not change what the run keeps — keepDerived stays the single switch. A truncated keepDerived: true run keeps the partial derivation it reached, records provenance for every conclusion it stored and announces it, so a re-run continues from it. A truncated default run (keepDerived: false, answered 200 or 504) is rolled back and leaves nothing stored. The 504 body says which happened.

A run also stops when its caller goes away: closing the connection (an aborted signal, a client-side timeout) cancels the derivation at its next fixpoint-iteration boundary, with or without this deadline, under the same keepDerived rule as a truncated run. 0 opts out of the deadline, not out of cancellation.