@orkestrel/qualifier 0.0.24 → 0.0.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,6 @@
1
1
  import type { AuditFault } from '@orkestrel/contract';
2
- import type { Check } from '@orkestrel/reason';
3
2
  import type { CheckResult } from '@orkestrel/reason';
4
3
  import type { CheckState } from '@orkestrel/reason';
5
- import type { Comparison } from '@orkestrel/reason';
6
4
  import type { ContractInterface } from '@orkestrel/contract';
7
5
  import type { ContractShape } from '@orkestrel/contract';
8
6
  import type { EmitterErrorHandler } from '@orkestrel/emitter';
@@ -16,10 +14,10 @@ import type { LogicalResult } from '@orkestrel/reason';
16
14
  import type { QuantitativeDefinition } from '@orkestrel/reason';
17
15
  import type { QuantitativeResult } from '@orkestrel/reason';
18
16
  import type { ReasonInterface } from '@orkestrel/reason';
17
+ import type { ReasonRefusal } from '@orkestrel/reason';
19
18
  import type { ReasonResult } from '@orkestrel/reason';
20
19
  import type { ReasonValidationResult } from '@orkestrel/reason';
21
20
  import type { Rule } from '@orkestrel/reason';
22
- import type { RuleResult } from '@orkestrel/reason';
23
21
  import type { ShapeScan } from '@orkestrel/reason';
24
22
  import type { Subject } from '@orkestrel/reason';
25
23
 
@@ -40,25 +38,133 @@ import type { Subject } from '@orkestrel/reason';
40
38
  export declare function assertSubject(value: unknown): asserts value is Subject;
41
39
 
42
40
  /**
43
- * Builds a {@link Premise} from an authored {@link Check} and its evaluated
44
- * `CheckResult`.
41
+ * Copies a list, reading its length and each entry once.
45
42
  *
46
- * @param check - The authored check
47
- * @param result - The evaluated check result carrying the resolved `actual` and `state`
48
- * @param labels - Optional field-to-label overrides, keyed by dot-joined field
49
- * @returns A fresh premise
43
+ * @param value - The value to copy
44
+ * @param clone - Copies one entry. Default: carries it as it is
45
+ * @returns A fresh list, or the value itself when it is no list
50
46
  *
51
47
  * @example
52
48
  * ```ts
53
- * import { checkToPremise } from '@orkestrel/qualifier'
54
- * import { createCheck } from '@orkestrel/reason'
49
+ * import { cloneList } from '@orkestrel/qualifier'
55
50
  *
56
- * const authored = createCheck('age', 'above', 18)
57
- * checkToPremise(authored, { field: 'age', actual: 25, state: 'met' })
58
- * // { field: 'age', comparison: 'above', expected: 18, actual: 25, state: 'met' }
51
+ * cloneList(['a', 'b']) // ['a', 'b']
52
+ * cloneList('a') // 'a'
59
53
  * ```
60
54
  */
61
- export declare function checkToPremise(check: Check, result: CheckResult, labels?: Readonly<Record<string, string>>): Premise;
55
+ export declare function cloneList(value: unknown, clone?: (entry: unknown) => unknown): unknown;
56
+
57
+ /**
58
+ * Copies the named members a value has into a plain record, reading each once.
59
+ *
60
+ * @remarks
61
+ * An inherited member and an accessor count, so a class instance keeps what it gives. A member the
62
+ * names leave out is dropped, and one the value lacks stays absent.
63
+ *
64
+ * @param value - The value to copy
65
+ * @param names - The members to read
66
+ * @param clones - Copies a member of that name; any other is carried as it is. Default: none
67
+ * @returns A fresh record, or the value itself when it is a list or no object
68
+ *
69
+ * @example
70
+ * ```ts
71
+ * import { cloneMembers } from '@orkestrel/qualifier'
72
+ *
73
+ * cloneMembers({ a: 1, b: 2 }, ['a']) // { a: 1 }
74
+ * ```
75
+ */
76
+ export declare function cloneMembers(value: unknown, names: readonly PropertyKey[], clones?: Readonly<Record<string, (member: unknown) => unknown>>): unknown;
77
+
78
+ /**
79
+ * Copies an untrusted engine's answer, reading each member a verdict rests on once, and admits the
80
+ * copy alone.
81
+ *
82
+ * @remarks
83
+ * Reading the answer again could give another verdict, so everything is derived from the copy. A
84
+ * check's and a refusal's `actual` and a check's expected value are carried by identity, and so are
85
+ * the members that hold no verdict, such as a quantitative result's `groups`. A member its contract
86
+ * does not name is dropped. It never throws.
87
+ *
88
+ * @param value - The answer
89
+ * @returns The copy, or `undefined` when it is no reason result or throws on being read
90
+ *
91
+ * @example
92
+ * ```ts
93
+ * import { cloneReasonResult } from '@orkestrel/qualifier'
94
+ * import { createLogicalDefinition, createLogicalReasoner } from '@orkestrel/reason'
95
+ *
96
+ * const result = createLogicalReasoner().reason({}, createLogicalDefinition('d', 'd', []))
97
+ * cloneReasonResult(result)?.success // true
98
+ * cloneReasonResult({ success: true }) // undefined
99
+ * ```
100
+ */
101
+ export declare function cloneReasonResult(value: unknown): ReasonResult | undefined;
102
+
103
+ /**
104
+ * Collects why an answer refused: the engine's own refusals, and what the answer leaves out or
105
+ * contradicts by itself.
106
+ *
107
+ * @remarks
108
+ * A failure naming no refusal and no fault is `silent`. A success is `malformed` beside a refusal
109
+ * or a fault, and at a value that is not finite, held in `actual`. Whatever verdict it claims, an
110
+ * answer is `malformed` for each rule it lists more than once, named in `rule`.
111
+ *
112
+ * @param result - The engine's answer
113
+ * @returns The refusals, with no path of this package's
114
+ *
115
+ * @example
116
+ * ```ts
117
+ * import { collectAnswerRefusals } from '@orkestrel/qualifier'
118
+ *
119
+ * collectAnswerRefusals({
120
+ * reasoning: 'quantitative',
121
+ * value: Number.NaN,
122
+ * groups: [],
123
+ * count: 0,
124
+ * success: true,
125
+ * trace: [],
126
+ * refusals: [],
127
+ * faults: [],
128
+ * repairs: [],
129
+ * defaulted: [],
130
+ * }) // [{ cause: 'malformed', actual: NaN }]
131
+ * ```
132
+ */
133
+ export declare function collectAnswerRefusals(result: ReasonResult): readonly ReasonRefusal[];
134
+
135
+ /**
136
+ * Collects why a pass refused: the engine's own refusals under the pass id, and what its answer
137
+ * leaves out or contradicts.
138
+ *
139
+ * @remarks
140
+ * An injected engine answers through an interface, so its verdict is checked against the rest of
141
+ * its answer, as `collectAnswerRefusals` does, and against its pass. An answer of another
142
+ * reasoning is `malformed`, and so is a success for each rule it does not answer, named in `rule`.
143
+ *
144
+ * @param pass - The pass the engine ran
145
+ * @param result - The engine's answer
146
+ * @returns The refusals, each with the pass id at the head of its `path`
147
+ *
148
+ * @example
149
+ * ```ts
150
+ * import { collectPassRefusals } from '@orkestrel/qualifier'
151
+ * import { createQuantitativeDefinition } from '@orkestrel/reason'
152
+ *
153
+ * collectPassRefusals(createQuantitativeDefinition('cap', 'Cap', []), {
154
+ * reasoning: 'quantitative',
155
+ * value: 0,
156
+ * groups: [],
157
+ * count: 0,
158
+ * success: false,
159
+ * trace: [],
160
+ * refusals: [],
161
+ * faults: [],
162
+ * repairs: [],
163
+ * defaulted: [],
164
+ * }) // [{ cause: 'silent', path: ['cap'] }]
165
+ * ```
166
+ */
167
+ export declare function collectPassRefusals(pass: QualificationPass, result: ReasonResult): readonly ReasonRefusal[];
62
168
 
63
169
  /**
64
170
  * Returns the most severe {@link Eligibility} in a list.
@@ -141,11 +247,9 @@ import type { Subject } from '@orkestrel/reason';
141
247
  * A standalone qualifier creates and owns one shared quantitative-plus-logical
142
248
  * reason engine, destroying it on `destroy()`. An injected `options.engine`
143
249
  * remains caller-owned and is never destroyed. `validate` runs semantic
144
- * validation before every qualification. Default: `true`. `labels` overrides the
145
- * display name of a premise field, keyed by the dot-joined field path
146
- * `formatField` produces, and takes precedence over a premise's own `label`.
250
+ * validation before every qualification. Default: `true`.
147
251
  *
148
- * @param options - Optional injected engine, validation, labels, and emitter hooks
252
+ * @param options - Optional injected engine, validation, and emitter hooks
149
253
  * @returns A {@link QualifierInterface}
150
254
  *
151
255
  * @example Create a qualifier
@@ -209,13 +313,22 @@ import type { Subject } from '@orkestrel/reason';
209
313
  */
210
314
  export declare const DEFAULT_QUALIFIER_VALIDATE = true;
211
315
 
212
- /** Represents one quantitative pass's audit result. */
316
+ /**
317
+ * Represents one quantitative pass's audit result.
318
+ *
319
+ * @remarks
320
+ * `success` is false exactly when `refusals` or `faults` holds an entry. `refusals` are the
321
+ * engine's own, and one for each way its answer contradicts itself or fails and names nothing;
322
+ * they carry no path of this package's, because `id` names the pass. `faults` are the engine's
323
+ * own, a read of an unread pass's projection as it was read. `value` and `trace` are the engine's.
324
+ */
213
325
  export declare interface Derivation {
214
326
  readonly id: string;
215
327
  readonly value: number;
216
328
  readonly success: boolean;
217
329
  readonly trace: readonly string[];
218
- readonly errors: readonly string[];
330
+ readonly refusals: readonly ReasonRefusal[];
331
+ readonly faults: readonly AuditFault[];
219
332
  }
220
333
 
221
334
  /** Describes a `Derivation` in its JSON projection, where a non-finite number is `null`. */
@@ -238,7 +351,7 @@ import type { Subject } from '@orkestrel/reason';
238
351
  * ```ts
239
352
  * import { deriveFindingEligibility } from '@orkestrel/qualifier'
240
353
  *
241
- * const finding = { id: 'license', pass: 'gates', rule: 'licensed', effect: 'restriction' as const, state: 'met' as const, premises: [] }
354
+ * const finding = { id: 'license', pass: 'gates', rule: 'licensed', effect: 'restriction' as const, state: 'met' as const, checks: [] }
242
355
  * deriveFindingEligibility([finding]) // 'ineligible'
243
356
  * ```
244
357
  */
@@ -249,8 +362,8 @@ import type { Subject } from '@orkestrel/reason';
249
362
  *
250
363
  * @remarks
251
364
  * Only scoped findings that are `met` contribute. Each named scope combines its own
252
- * findings' impacts by severity. An unmentioned scope is absent (eligible by
253
- * default at the program layer).
365
+ * findings' impacts by severity. A scope no finding is met for is absent, which is eligible only
366
+ * where the run succeeded, because a finding left unread leaves its scope absent too.
254
367
  *
255
368
  * @param findings - The resolved findings
256
369
  * @returns A fresh record of scope to its combined eligibility
@@ -259,7 +372,7 @@ import type { Subject } from '@orkestrel/reason';
259
372
  * ```ts
260
373
  * import { deriveScopeEligibilities } from '@orkestrel/qualifier'
261
374
  *
262
- * const finding = { id: 'coastal', pass: 'wind', rule: 'coastal', effect: 'restriction' as const, scope: 'wind', state: 'met' as const, premises: [] }
375
+ * const finding = { id: 'coastal', pass: 'wind', rule: 'coastal', effect: 'restriction' as const, scope: 'wind', state: 'met' as const, checks: [] }
263
376
  * deriveScopeEligibilities([finding]) // { wind: 'ineligible' }
264
377
  * ```
265
378
  */
@@ -429,7 +542,9 @@ import type { Subject } from '@orkestrel/reason';
429
542
  *
430
543
  * @remarks
431
544
  * `state` is the state of the ruling's rule, so only `met` applies the ruling's effect. A rule
432
- * left `unread` is no answer either way, and the pass it sits in reads `referral`.
545
+ * left `unread` is no answer either way, and the pass it sits in reads `referral`. `message` is
546
+ * the ruling's authored text split at its tokens, with no empty part, whatever the state.
547
+ * `checks` is what the rule read, and is empty for a rule that never ran.
433
548
  */
434
549
  export declare interface Finding {
435
550
  readonly id: string;
@@ -438,8 +553,8 @@ import type { Subject } from '@orkestrel/reason';
438
553
  readonly effect: QualificationEffect;
439
554
  readonly scope?: string;
440
555
  readonly state: CheckState;
441
- readonly message?: string;
442
- readonly premises: readonly Premise[];
556
+ readonly message?: ReadonlyArray<string | MessageSlot>;
557
+ readonly checks: readonly CheckResult[];
443
558
  }
444
559
 
445
560
  /** Describes a `Finding` in its JSON projection. */
@@ -448,8 +563,12 @@ import type { Subject } from '@orkestrel/reason';
448
563
  /**
449
564
  * Finds the `{{dotted.path}}` tokens a message template reads.
450
565
  *
566
+ * @remarks
567
+ * White space around a path is trimmed, and the white space inside it stays. A token of white
568
+ * space alone names one key, its last character, and `{{}}` is text.
569
+ *
451
570
  * @param template - The message template
452
- * @returns Each token's dotted path, trimmed, in order, repeats included
571
+ * @returns Each token's dotted path, in order, repeats included
453
572
  *
454
573
  * @example
455
574
  * ```ts
@@ -482,70 +601,51 @@ import type { Subject } from '@orkestrel/reason';
482
601
  export declare function findRule(definition: LogicalDefinition, id: string): Rule | undefined;
483
602
 
484
603
  /**
485
- * Determines whether a subject already owns the reserved {@link QUALIFICATION_KEY}.
486
- *
487
- * @param subject - The subject to check
488
- * @returns True if the subject owns the reserved key; false otherwise
489
- *
490
- * @example
491
- * ```ts
492
- * import { hasReservedKey } from '@orkestrel/qualifier'
493
- *
494
- * hasReservedKey({ id: 's1', qualification: {} }) // true
495
- * ```
496
- */
497
- export declare function hasReservedKey(subject: Subject): boolean;
498
-
499
- /**
500
- * Determines whether a logical result holds a rule left unread.
604
+ * Finds each rule a logical result does not answer: one it left unread, and an enabled one it
605
+ * omits.
501
606
  *
502
- * @param result - The result of a pass
503
- * @returns True when a logical result holds such a rule; false otherwise
607
+ * @param definition - The logical pass
608
+ * @param result - The result of the pass
609
+ * @returns The rule ids, each once, the unread ones first
504
610
  *
505
611
  * @example
506
612
  * ```ts
507
- * import { hasUnreadRule } from '@orkestrel/qualifier'
613
+ * import { findUnansweredRules } from '@orkestrel/qualifier'
614
+ * import { createAtom, createLogicalDefinition, createRule } from '@orkestrel/reason'
508
615
  *
509
- * const rule = { id: 'r', state: 'unread' as const, premises: [], checks: [] }
510
- * hasUnreadRule({
616
+ * const gates = createLogicalDefinition('gates', 'Gates', [
617
+ * createRule('licensed', [createAtom('licensed', 'equals', false)], createAtom('blocked', 'equals', true)),
618
+ * ])
619
+ * findUnansweredRules(gates, {
511
620
  * reasoning: 'logical',
512
- * conclusion: 'unread',
513
- * rules: [rule],
621
+ * conclusion: 'unmet',
622
+ * rules: [],
514
623
  * count: 0,
515
- * success: false,
624
+ * success: true,
516
625
  * trace: [],
517
- * errors: [],
626
+ * refusals: [],
518
627
  * faults: [],
519
628
  * repairs: [],
520
629
  * defaulted: [],
521
- * }) // true
630
+ * }) // ['licensed']
522
631
  * ```
523
632
  */
524
- export declare function hasUnreadRule(result: ReasonResult): boolean;
633
+ export declare function findUnansweredRules(definition: LogicalDefinition, result: LogicalResult): readonly string[];
525
634
 
526
635
  /**
527
- * Interpolates `{{dotted.path}}` tokens in a message template against a subject.
528
- *
529
- * @remarks
530
- * Each token is split on `.` into a `FieldPath` array and resolved with
531
- * `resolveField` (a plain string field is one key, never dot-split — the split
532
- * here is the token-to-path bridge). A finite number renders with `en-US`
533
- * thousand grouping (`5010` → `5,010`); any other resolved value String-coerces.
534
- * An unresolved path renders as the empty string.
636
+ * Determines whether a subject already owns the reserved {@link QUALIFICATION_KEY}.
535
637
  *
536
- * @param template - The message template carrying `{{dotted.path}}` tokens
537
- * @param subject - The record tokens resolve against
538
- * @returns The template with every token replaced
638
+ * @param subject - The subject to check
639
+ * @returns True if the subject owns the reserved key; false otherwise
539
640
  *
540
641
  * @example
541
642
  * ```ts
542
- * import { interpolateMessage } from '@orkestrel/qualifier'
643
+ * import { hasReservedKey } from '@orkestrel/qualifier'
543
644
  *
544
- * interpolateMessage('Limit is {{limit}}', { limit: 5010 }) // 'Limit is 5,010'
545
- * interpolateMessage('Missing {{gone}}', {}) // 'Missing '
645
+ * hasReservedKey({ id: 's1', qualification: {} }) // true
546
646
  * ```
547
647
  */
548
- export declare function interpolateMessage(template: string, subject: Readonly<Record<string, unknown>>): string;
648
+ export declare function hasReservedKey(subject: Subject): boolean;
549
649
 
550
650
  /**
551
651
  * Determines whether a value is a definition's `metadata`: a record of JSON values.
@@ -568,9 +668,8 @@ import type { Subject } from '@orkestrel/reason';
568
668
  *
569
669
  * @remarks
570
670
  * Every published member is checked: `value` follows the published `number` type, including
571
- * `NaN` and the infinities, and `trace` and `errors` hold strings. Unknown members are
572
- * admitted, because a foreign result implementation may add them without changing the
573
- * published contract.
671
+ * `NaN` and the infinities. Unknown members are admitted, because a foreign result
672
+ * implementation may add them without changing the published contract.
574
673
  *
575
674
  * @param value - The value to test
576
675
  * @returns True if every published derivation member is valid; false otherwise
@@ -607,10 +706,10 @@ import type { Subject } from '@orkestrel/reason';
607
706
  * Determines whether a value is an open result-side {@link Finding}.
608
707
  *
609
708
  * @remarks
610
- * Every published member is checked, including each nested {@link Premise}. Optional `scope`
611
- * and `message` members may be absent or `undefined`; a present defined value must be a
612
- * string. Unknown members are admitted, because a foreign result implementation may add them
613
- * without changing the published contract.
709
+ * Every published member is checked, including each nested {@link MessageSlot} and check result.
710
+ * Optional `scope` and `message` members may be absent or `undefined`; a present defined value is
711
+ * checked in full. Unknown members are admitted, because a foreign result implementation may add
712
+ * them without changing the published contract.
614
713
  *
615
714
  * @param value - The value to test
616
715
  * @returns True if every published finding member is valid; false otherwise
@@ -618,19 +717,25 @@ import type { Subject } from '@orkestrel/reason';
618
717
  export declare function isFinding(value: unknown): value is Finding;
619
718
 
620
719
  /**
621
- * Determines whether a value is an open result-side {@link Premise}.
720
+ * Determines whether a value is an open result-side {@link MessageSlot}.
622
721
  *
623
722
  * @remarks
624
- * The optional `field`, `label`, `description`, `comparison`, and `met` members are checked
625
- * when they are defined. `expected` is unchecked and may be absent or contain any value
626
- * because its published type is `unknown`. `actual` is unchecked and may be absent or contain
627
- * any value for the same reason. Unknown members are admitted, because an open result admits
723
+ * `field` is checked. `actual` must be present and may hold anything, and is never read, because
724
+ * its published type is `unknown`. Unknown members are admitted, because an open result admits
628
725
  * what the published contract does not name.
629
726
  *
630
727
  * @param value - The value to test
631
- * @returns True if every checked premise member follows its published type; false otherwise
728
+ * @returns True if the slot names a field and carries a value; false otherwise
729
+ *
730
+ * @example
731
+ * ```ts
732
+ * import { isMessageSlot } from '@orkestrel/qualifier'
733
+ *
734
+ * isMessageSlot({ field: ['age'], actual: undefined }) // true
735
+ * isMessageSlot({ field: ['age'] }) // false
736
+ * ```
632
737
  */
633
- export declare function isPremise(value: unknown): value is Premise;
738
+ export declare function isMessageSlot(value: unknown): value is MessageSlot;
634
739
 
635
740
  /**
636
741
  * Determines whether a value is an exact {@link QualificationDefinition} record.
@@ -750,38 +855,37 @@ import type { Subject } from '@orkestrel/reason';
750
855
  /** Matches each `{{dotted.path}}` token of a message template, with the path as its one group. */
751
856
  export declare const MESSAGE_TOKEN: RegExp;
752
857
 
858
+ /** Represents one slot of an authored message: the field its token names and the value read there. */
859
+ export declare interface MessageSlot {
860
+ readonly field: FieldPath;
861
+ readonly actual: unknown;
862
+ }
863
+
864
+ /** Describes a `MessageSlot` in its JSON projection. */
865
+ export declare const messageSlotShape: ContractShape;
866
+
753
867
  /**
754
- * Represents display-neutral evidence for one condition, authored as a checked or a
755
- * described premise.
868
+ * Projects a slot's `actual` to JSON on its own budget, as `undefined` when it has no JSON form.
756
869
  *
757
- * @remarks
758
- * A checked premise carries `field` and `comparison`; a described premise
759
- * carries neither and renders from `description` instead. The checked form
760
- * renders only when `field` and `comparison` are both present, and
761
- * `description` then goes unused; a premise missing either half of the
762
- * checked pair renders as described instead. `state` is what the rule read: `met`,
763
- * `unmet`, or `unread`. It is absent when the rule never ran, because it was disabled or
764
- * the premise is only described, and both `unread` and absent render as unknown.
870
+ * @param slot - The slot
871
+ * @returns The slot, its `actual` JSON or `undefined`
872
+ *
873
+ * @example
874
+ * ```ts
875
+ * import { projectMessageSlot } from '@orkestrel/qualifier'
876
+ *
877
+ * projectMessageSlot({ field: ['limit'], actual: Number.NaN }) // { field: ['limit'], actual: null }
878
+ * ```
765
879
  */
766
- export declare interface Premise {
767
- readonly field?: FieldPath;
768
- readonly label?: string;
769
- readonly description?: string;
770
- readonly comparison?: Comparison;
771
- readonly expected?: unknown;
772
- readonly actual?: unknown;
773
- readonly state?: CheckState;
774
- }
775
-
776
- /** Describes a `Premise` in its JSON projection. */
777
- export declare const premiseShape: ContractShape;
880
+ export declare function projectMessageSlot(slot: MessageSlot): MessageSlot;
778
881
 
779
882
  /**
780
883
  * Projects a result to the JSON its contract reads.
781
884
  *
782
885
  * @remarks
783
- * A premise's `actual` holds whatever the subject held and a derivation's `value` may be `NaN`,
784
- * so a result crosses a boundary as this projection, each `actual` on its own budget.
886
+ * A check's, a slot's, and a refusal's `actual` holds whatever the run read, and a derivation's
887
+ * `value` may be `NaN`, so a result crosses a boundary as this projection, each `actual` on its
888
+ * own budget.
785
889
  *
786
890
  * @param result - The qualification result
787
891
  * @returns Its JSON projection, which `qualificationResultContract` admits
@@ -848,11 +952,11 @@ import type { Subject } from '@orkestrel/reason';
848
952
  * Represents one subject's complete qualification outcome.
849
953
  *
850
954
  * @remarks
851
- * `success` is false exactly when `errors` holds an entry, and then `eligibility` carries at
852
- * least a `referral`. `faults` names each input the run could not read, with a read of an
853
- * unread pass's projection replaced by what that pass could not read, and `errors` holds one
854
- * string per fault plus what no fault can say. `repairs` and `defaulted` report what the door
855
- * changed.
955
+ * `success` is false exactly when `refusals` or `faults` holds an entry, and then `eligibility`
956
+ * carries at least a `referral`. `faults` names each input the run could not read, with a read of
957
+ * an unread pass's projection replaced by what that pass could not read. `refusals` says why else
958
+ * the run refused: a pass's carry the pass id at the head of their `path`, and the door's carry no
959
+ * path. `repairs` and `defaulted` report what the door changed.
856
960
  */
857
961
  export declare interface QualificationResult {
858
962
  readonly id: string;
@@ -863,7 +967,7 @@ import type { Subject } from '@orkestrel/reason';
863
967
  readonly derivations: readonly Derivation[];
864
968
  readonly success: boolean;
865
969
  readonly trace: readonly string[];
866
- readonly errors: readonly string[];
970
+ readonly refusals: readonly ReasonRefusal[];
867
971
  readonly faults: readonly AuditFault[];
868
972
  readonly repairs: readonly AuditFault[];
869
973
  readonly defaulted: readonly FieldPath[];
@@ -929,7 +1033,8 @@ import type { Subject } from '@orkestrel/reason';
929
1033
  * `shape` on the definition admits the subject through a door first. An unscoped
930
1034
  * restriction stops the remaining passes because no later finding can be more severe.
931
1035
  * A pass left unread projects nothing and reads `referral`, and the run goes on, so a later
932
- * restriction can still outrank it. An error no fault can say stops the run.
1036
+ * restriction can still outrank it. A refusal stops the run, and so does an answer that
1037
+ * contradicts itself or its pass, which is refused as `malformed`.
933
1038
  *
934
1039
  * @param subject - The record to qualify
935
1040
  * @param definition - The authored qualification definition
@@ -1144,15 +1249,12 @@ import type { Subject } from '@orkestrel/reason';
1144
1249
  * @remarks
1145
1250
  * `engine` injects a reason engine that stays caller-owned and is never destroyed; an
1146
1251
  * absent `engine` makes the qualifier create and own one. `validate` runs semantic
1147
- * validation before every qualification. Default: `true`. `labels` overrides the display
1148
- * name of a premise field, keyed by the dot-joined field path `formatField` produces, and
1149
- * takes precedence over a premise's own `label`. `on` carries the initial emitter hooks,
1150
- * and `error` handles a listener throw.
1252
+ * validation before every qualification. Default: `true`. `on` carries the initial emitter
1253
+ * hooks, and `error` handles a listener throw.
1151
1254
  */
1152
1255
  export declare interface QualifierOptions {
1153
1256
  readonly engine?: ReasonInterface;
1154
1257
  readonly validate?: boolean;
1155
- readonly labels?: Readonly<Record<string, string>>;
1156
1258
  readonly on?: EmitterHooks<QualifierEventMap>;
1157
1259
  readonly error?: EmitterErrorHandler;
1158
1260
  }
@@ -1160,6 +1262,10 @@ import type { Subject } from '@orkestrel/reason';
1160
1262
  /**
1161
1263
  * Projects a quantitative result into a {@link Derivation} audit record.
1162
1264
  *
1265
+ * @remarks
1266
+ * `refusals` are what `collectAnswerRefusals` collects, and `success` is false exactly when they or
1267
+ * the faults hold an entry, whatever verdict the result claims.
1268
+ *
1163
1269
  * @param id - The pass id
1164
1270
  * @param result - The evaluated quantitative result
1165
1271
  * @returns A fresh derivation
@@ -1168,9 +1274,9 @@ import type { Subject } from '@orkestrel/reason';
1168
1274
  * ```ts
1169
1275
  * import { quantitativeResultToDerivation } from '@orkestrel/qualifier'
1170
1276
  *
1171
- * const result = { reasoning: 'quantitative' as const, value: 500_000, groups: [], count: 1, success: true, trace: ['cap: 500000'], errors: [] }
1277
+ * const result = { reasoning: 'quantitative' as const, value: 500_000, groups: [], count: 1, success: true, trace: ['cap: 500000'], refusals: [], faults: [], repairs: [], defaulted: [] }
1172
1278
  * quantitativeResultToDerivation('cap', result)
1173
- * // { id: 'cap', value: 500000, success: true, trace: ['cap: 500000'], errors: [] }
1279
+ * // { id: 'cap', value: 500000, success: true, trace: ['cap: 500000'], refusals: [], faults: [] }
1174
1280
  * ```
1175
1281
  */
1176
1282
  export declare function quantitativeResultToDerivation(id: string, result: QuantitativeResult): Derivation;
@@ -1221,109 +1327,16 @@ import type { Subject } from '@orkestrel/reason';
1221
1327
  * count: 1,
1222
1328
  * success: true,
1223
1329
  * trace: [],
1224
- * errors: [],
1330
+ * refusals: [],
1331
+ * faults: [],
1332
+ * repairs: [],
1333
+ * defaulted: [],
1225
1334
  * }
1226
1335
  * reasonResultToProjection(cap, result) // 500000
1227
1336
  * ```
1228
1337
  */
1229
1338
  export declare function reasonResultToProjection(definition: QualificationPass, result: ReasonResult): QualificationProjection;
1230
1339
 
1231
- /**
1232
- * Renders a {@link Premise} comparison as a display-neutral verb phrase.
1233
- *
1234
- * @param comparison - The comparison to describe
1235
- * @returns A display-neutral phrase
1236
- *
1237
- * @example
1238
- * ```ts
1239
- * import { renderComparison } from '@orkestrel/qualifier'
1240
- *
1241
- * renderComparison('above') // 'is more than'
1242
- * ```
1243
- */
1244
- export declare function renderComparison(comparison: NonNullable<Premise['comparison']>): string;
1245
-
1246
- /**
1247
- * Renders one {@link Premise} into a display-neutral sentence.
1248
- *
1249
- * @remarks
1250
- * The checked form renders only when `field` and `comparison` are both
1251
- * present, and `description` then goes unused; a premise missing either half
1252
- * of the checked pair renders as described instead.
1253
- *
1254
- * @param entry - The premise to render
1255
- * @param labels - Optional field-to-label overrides, keyed by dot-joined field
1256
- * @returns A display-neutral sentence
1257
- *
1258
- * @example
1259
- * ```ts
1260
- * import { renderPremise } from '@orkestrel/qualifier'
1261
- *
1262
- * renderPremise({ field: 'age', comparison: 'above', expected: 18, actual: 25, state: 'met' })
1263
- * // 'age is more than 18 → met'
1264
- *
1265
- * renderPremise({ description: 'Applicant is enrolled', state: 'met' })
1266
- * // 'Applicant is enrolled → met'
1267
- * ```
1268
- */
1269
- export declare function renderPremise(entry: Premise, labels?: Readonly<Record<string, string>>): string;
1270
-
1271
- /**
1272
- * Renders a structured or scalar expected value display-neutrally.
1273
- *
1274
- * @remarks
1275
- * An array renders as its elements, each `String`-coerced, joined with `', '`.
1276
- * A reason `Bounds`-shaped record (the `between` / `outside` expected value)
1277
- * renders its present sides joined with the word `and`; an absent side is
1278
- * omitted. A finite number and everything else fall back to plain `String()` —
1279
- * a finite number is not grouped here (grouping is {@link interpolateMessage}'s
1280
- * message-token-only behavior).
1281
- *
1282
- * @param value - The value to render
1283
- * @returns A display-neutral rendering
1284
- *
1285
- * @example
1286
- * ```ts
1287
- * import { renderValue } from '@orkestrel/qualifier'
1288
- *
1289
- * renderValue([18, 25, 40]) // '18, 25, 40'
1290
- * renderValue({ minimum: 18, maximum: 65 }) // '18 and 65'
1291
- * renderValue(42) // '42'
1292
- * ```
1293
- */
1294
- export declare function renderValue(value: unknown): string;
1295
-
1296
- /**
1297
- * Builds rich premises for one fired {@link Rule} by walking its premise atoms
1298
- * and reading each from what the rule read.
1299
- *
1300
- * @remarks
1301
- * Each authored premise expression is flattened to its atom leaves through `extractAtoms`,
1302
- * which lines up with the `checks` the rule result carries, so a premise cannot disagree with
1303
- * the pass. A rule with no result never ran, so its premises carry no `state` or `actual`.
1304
- *
1305
- * @param rule - The authored rule
1306
- * @param resolved - The rule's result, absent when it never ran
1307
- * @param labels - Optional field-to-label overrides, keyed by dot-joined field
1308
- * @returns A fresh, ordered list of rich premises
1309
- *
1310
- * @example
1311
- * ```ts
1312
- * import { ruleToPremises } from '@orkestrel/qualifier'
1313
- * import { createAtom, createRule } from '@orkestrel/reason'
1314
- *
1315
- * const rule = createRule('licensed', [createAtom('licensed', 'equals', false)], createAtom('blocked', 'equals', true))
1316
- * const resolved = {
1317
- * id: 'licensed',
1318
- * state: 'met' as const,
1319
- * premises: ['met' as const],
1320
- * checks: [{ field: 'licensed', state: 'met' as const, actual: false }],
1321
- * }
1322
- * ruleToPremises(rule, resolved)[0]?.state // 'met'
1323
- * ```
1324
- */
1325
- export declare function ruleToPremises(rule: Rule, resolved: RuleResult | undefined, labels?: Readonly<Record<string, string>>): readonly Premise[];
1326
-
1327
1340
  /** Represents an authored consequence for one rule in one logical pass. */
1328
1341
  export declare interface Ruling {
1329
1342
  readonly id: string;
@@ -1350,13 +1363,14 @@ import type { Subject } from '@orkestrel/reason';
1350
1363
  * @remarks
1351
1364
  * `state` is the state of the ruling's rule. A rule the result omits reads `unmet` when it is
1352
1365
  * disabled, which is authored, and `unread` otherwise, because a refused pass evaluated no rule.
1353
- * Premises come from what the rule read. The message interpolates against the subject.
1366
+ * `checks` are the rule result's own, empty for a rule the result omits. A rule the result lists
1367
+ * more than once reads `unread` with no checks, because no entry answers for it. The message is
1368
+ * split against the subject.
1354
1369
  *
1355
1370
  * @param ruling - The authored ruling
1356
1371
  * @param pass - The pass the ruling's rule lives in
1357
1372
  * @param result - The pass's evaluated logical result
1358
1373
  * @param subject - The pre-projection subject snapshot the pass evaluated
1359
- * @param labels - Optional field-to-label overrides, keyed by dot-joined field
1360
1374
  * @returns A fresh finding
1361
1375
  *
1362
1376
  * @example
@@ -1375,7 +1389,7 @@ import type { Subject } from '@orkestrel/reason';
1375
1389
  * count: 1,
1376
1390
  * success: true,
1377
1391
  * trace: [],
1378
- * errors: [],
1392
+ * refusals: [],
1379
1393
  * faults: [],
1380
1394
  * repairs: [],
1381
1395
  * defaulted: [],
@@ -1383,7 +1397,7 @@ import type { Subject } from '@orkestrel/reason';
1383
1397
  * rulingToFinding(ruling, gates, result, { licensed: false }).state // 'met'
1384
1398
  * ```
1385
1399
  */
1386
- export declare function rulingToFinding(ruling: Ruling, pass: QualificationPass, result: LogicalResult, subject: Subject, labels?: Readonly<Record<string, string>>): Finding;
1400
+ export declare function rulingToFinding(ruling: Ruling, pass: QualificationPass, result: LogicalResult, subject: Subject): Finding;
1387
1401
 
1388
1402
  /**
1389
1403
  * Describes what the definition's shape cannot stand for: a read of a field it does not declare,
@@ -1413,4 +1427,27 @@ import type { Subject } from '@orkestrel/reason';
1413
1427
  */
1414
1428
  export declare function scanDefinitionShape(definition: QualificationDefinition, projections?: readonly string[]): ShapeScan;
1415
1429
 
1430
+ /**
1431
+ * Splits a message template at its `{{dotted.path}}` tokens, reading each from a subject.
1432
+ *
1433
+ * @remarks
1434
+ * The text between tokens stays as authored, and an empty text is left out. Each token becomes a
1435
+ * {@link MessageSlot} whose `field` is the token's path as an array of keys and whose `actual` is
1436
+ * the raw value there, `undefined` for an absent one. Nothing is formatted. The tokens are those
1437
+ * {@link findMessageTokens} finds.
1438
+ *
1439
+ * @param template - The message template carrying `{{dotted.path}}` tokens
1440
+ * @param subject - The record tokens resolve against
1441
+ * @returns The authored texts and the slots, in order
1442
+ *
1443
+ * @example
1444
+ * ```ts
1445
+ * import { splitMessage } from '@orkestrel/qualifier'
1446
+ *
1447
+ * splitMessage('Limit is {{limit}}', { limit: 5010 })
1448
+ * // ['Limit is ', { field: ['limit'], actual: 5010 }]
1449
+ * ```
1450
+ */
1451
+ export declare function splitMessage(template: string, subject: Readonly<Record<string, unknown>>): ReadonlyArray<string | MessageSlot>;
1452
+
1416
1453
  export { }