@orkestrel/qualifier
v0.0.16
Published
A typed eligibility engine: ordered quantitative and logical passes qualify a subject into program-level and scoped eligibility with evidence-rich findings. Part of the @orkestrel line.
Maintainers
Readme
@orkestrel/qualifier
A synchronous, deterministic eligibility engine that runs a pure, JSON-serializable
QualificationDefinition's orderedpassesagainst one subject through one@orkestrel/reasonengine and returns a freshQualificationResultcarrying global and scoped eligibility, evidence-richfindings, and quantitativederivations.
Author the passes — quantitative derivations and logical rule gates — hand a subject
(a plain data record) to qualify, and read what comes back. The caller supplies the
definition; Qualifier only evaluates what it is given. Inject a
@orkestrel/reason ReasonInterface where
qualification shares an engine with the rest of your reasoning, and call destroy()
when the qualifier's work is done. Environment-agnostic — no I/O, no browser or
server assumptions. Part of the @orkestrel line.
Install
npm install @orkestrel/qualifierRequirements
- Node.js >= 22.12.0
- ESM (
import) and CommonJS (require) through theexportsfield
Usage
import { createQualificationDefinition, createQualifier, createRuling } from '@orkestrel/qualifier'
import { createAtom, createLogicalDefinition, createRule } from '@orkestrel/reason'
const gates = createLogicalDefinition('gates', 'Eligibility gates', [
createRule(
'licensed',
[createAtom('licensed', 'equals', false)],
createAtom('blocked', 'equals', true),
),
])
const definition = createQualificationDefinition('standard', 'Standard eligibility', [gates], {
rulings: [
createRuling('license', 'gates', 'licensed', 'restriction', {
message: 'A license is required',
}),
],
})
const qualifier = createQualifier()
const result = qualifier.qualify({ id: 'risk-1', licensed: false }, definition)
result.eligibility // 'ineligible'
result.findings[0]?.message // 'A license is required'
result.derivations // [] — no quantitative pass ran
qualifier.destroy()qualify accepts exactly one subject per call — there is no batch-of-subjects
overload. Every qualify call fires once through qualifier.emitter (qualify).
Guide
For the full surface — Qualifier, QualificationResult, finding types, validators,
factories, errors, and options — see
guides/qualifier.md.
Package
Published as a single typed entry point per the exports field in
package.json.
