@orkestrel/rater 0.0.25 → 0.0.27

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,9 +1,6 @@
1
1
  import type { Aggregation } from '@orkestrel/reason';
2
2
  import type { AuditFault } from '@orkestrel/contract';
3
- import type { Check } from '@orkestrel/reason';
4
3
  import type { CheckResult } from '@orkestrel/reason';
5
- import type { CheckState } from '@orkestrel/reason';
6
- import type { Comparison } from '@orkestrel/reason';
7
4
  import type { ContractInterface } from '@orkestrel/contract';
8
5
  import type { ContractShape } from '@orkestrel/contract';
9
6
  import type { EmitterErrorHandler } from '@orkestrel/emitter';
@@ -18,48 +15,9 @@ import type { JSONValue } from '@orkestrel/contract';
18
15
  import type { QuantitativeDefinition } from '@orkestrel/reason';
19
16
  import type { QuantitativeResult } from '@orkestrel/reason';
20
17
  import type { ReasonInterface } from '@orkestrel/reason';
18
+ import type { ReasonRefusal } from '@orkestrel/reason';
21
19
  import type { Subject } from '@orkestrel/reason';
22
20
 
23
- /**
24
- * Builds an {@link Evidence} row from an evaluated {@link Check}.
25
- *
26
- * @param check - The authored check
27
- * @param actual - The resolved subject value
28
- * @param state - The check's state; absent when the check was not evaluated
29
- * @param labels - Optional field-to-label overrides, keyed by dot-joined field
30
- * @returns A fresh evidence row
31
- *
32
- * @example
33
- * ```ts
34
- * import { createCheck } from '@orkestrel/reason'
35
- * import { buildEvidence } from '@orkestrel/rater'
36
- *
37
- * const entry = createCheck('age', 'above', 18)
38
- * buildEvidence(entry, 25, 'met') // { field: 'age', comparison: 'above', expected: 18, actual: 25, state: 'met' }
39
- * ```
40
- */
41
- export declare function buildEvidence(check: Check, actual: unknown, state: CheckState | undefined, labels?: Readonly<Record<string, string>>): Evidence;
42
-
43
- /**
44
- * Builds one evidence row per authored check of a quantitative factor, joined
45
- * to that check's evaluated result.
46
- *
47
- * @param checks - The factor's authored checks
48
- * @param results - The corresponding {@link CheckResult}s, in the same order
49
- * @param labels - Optional field-to-label overrides, keyed by dot-joined field
50
- * @returns A fresh list of evidence rows, one per authored check
51
- *
52
- * @example
53
- * ```ts
54
- * import { createCheck } from '@orkestrel/reason'
55
- * import { buildEvidenceRows } from '@orkestrel/rater'
56
- *
57
- * const checks = [createCheck('age', 'above', 18)]
58
- * buildEvidenceRows(checks, [{ field: 'age', state: 'met', actual: 25 }])
59
- * ```
60
- */
61
- export declare function buildEvidenceRows(checks: readonly Check[] | undefined, results: readonly CheckResult[] | undefined, labels?: Readonly<Record<string, string>>): readonly Evidence[];
62
-
63
21
  /**
64
22
  * Builds a fresh {@link LineDefinition} from a line id, a display name, and the
65
23
  * line's quantitative rating definition, with `overrides` merged over those
@@ -87,7 +45,6 @@ export declare function buildLineDefinition(id: string, name: string, rate: Quan
87
45
  *
88
46
  * @param definition - The authored line definition
89
47
  * @param result - The evaluated quantitative result
90
- * @param labels - Optional field-to-label overrides, keyed by dot-joined field
91
48
  * @returns A fresh line result
92
49
  *
93
50
  * @example
@@ -100,7 +57,21 @@ export declare function buildLineDefinition(id: string, name: string, rate: Quan
100
57
  * if (result.reasoning === 'quantitative') buildLineResult(line, result) // amount present only on a successful worksheet
101
58
  * ```
102
59
  */
103
- export declare function buildLineResult(definition: LineDefinition, result: QuantitativeResult, labels?: Readonly<Record<string, string>>): LineResult;
60
+ export declare function buildLineResult(definition: LineDefinition, result: QuantitativeResult): LineResult;
61
+
62
+ /**
63
+ * Builds the failed {@link QuantitativeResult} for an engine answer that is no quantitative result.
64
+ *
65
+ * @returns A fresh failed result carrying one `malformed` refusal
66
+ *
67
+ * @example
68
+ * ```ts
69
+ * import { buildMalformedResult } from '@orkestrel/rater'
70
+ *
71
+ * buildMalformedResult().refusals // [{ cause: 'malformed' }]
72
+ * ```
73
+ */
74
+ export declare function buildMalformedResult(): QuantitativeResult;
104
75
 
105
76
  /**
106
77
  * Builds a fresh {@link RatingDefinition} from a rating id, a display name, and
@@ -130,7 +101,6 @@ export declare function buildRatingDefinition(id: string, name: string, lines: r
130
101
  *
131
102
  * @param definition - The authored quantitative definition
132
103
  * @param result - The evaluated quantitative result
133
- * @param labels - Optional field-to-label overrides, keyed by dot-joined field
134
104
  * @returns A fresh worksheet
135
105
  *
136
106
  * @example
@@ -143,15 +113,14 @@ export declare function buildRatingDefinition(id: string, name: string, lines: r
143
113
  * if (result.reasoning === 'quantitative') buildWorksheet(definition, result) // the full audit trail
144
114
  * ```
145
115
  */
146
- export declare function buildWorksheet(definition: QuantitativeDefinition, result: QuantitativeResult, labels?: Readonly<Record<string, string>>): Worksheet;
116
+ export declare function buildWorksheet(definition: QuantitativeDefinition, result: QuantitativeResult): Worksheet;
147
117
 
148
118
  /**
149
119
  * Joins one authored quantitative factor to its evaluated {@link FactorResult}.
150
120
  *
151
121
  * @param definition - The authored factor
152
122
  * @param results - The group's factor results
153
- * @param labels - Optional field-to-label overrides, keyed by dot-joined field
154
- * @returns A fresh worksheet factor
123
+ * @returns A fresh worksheet factor, its `checks` empty for a factor that never ran
155
124
  *
156
125
  * @example
157
126
  * ```ts
@@ -159,17 +128,16 @@ export declare function buildWorksheet(definition: QuantitativeDefinition, resul
159
128
  * import { buildWorksheetFactor } from '@orkestrel/rater'
160
129
  *
161
130
  * const factor = createFieldFactor('seats', 'seats')
162
- * buildWorksheetFactor(factor, [{ id: 'seats', applied: true, value: 10 }])
131
+ * buildWorksheetFactor(factor, [{ id: 'seats', applied: true, value: 10, fallback: false }])
163
132
  * ```
164
133
  */
165
- export declare function buildWorksheetFactor(definition: Factor, results: readonly FactorResult[], labels?: Readonly<Record<string, string>>): WorksheetFactor;
134
+ export declare function buildWorksheetFactor(definition: Factor, results: readonly FactorResult[]): WorksheetFactor;
166
135
 
167
136
  /**
168
137
  * Joins one authored quantitative group to its evaluated {@link GroupResult}.
169
138
  *
170
139
  * @param definition - The authored group
171
140
  * @param results - The definition's group results
172
- * @param labels - Optional field-to-label overrides, keyed by dot-joined field
173
141
  * @returns A fresh worksheet group
174
142
  *
175
143
  * @example
@@ -181,7 +149,7 @@ export declare function buildWorksheetFactor(definition: Factor, results: readon
181
149
  * buildWorksheetGroup(group, [{ id: 'charge', applied: true, value: 100, factors: [] }])
182
150
  * ```
183
151
  */
184
- export declare function buildWorksheetGroup(definition: QuantitativeDefinition['groups'][number], results: readonly GroupResult[], labels?: Readonly<Record<string, string>>): WorksheetGroup;
152
+ export declare function buildWorksheetGroup(definition: QuantitativeDefinition['groups'][number], results: readonly GroupResult[]): WorksheetGroup;
185
153
 
186
154
  /**
187
155
  * Builds one display-neutral {@link Step} row.
@@ -190,18 +158,17 @@ export declare function buildWorksheetGroup(definition: QuantitativeDefinition['
190
158
  * @param id - The stage's authored id, when it has one
191
159
  * @param name - The stage's authored name, when it has one
192
160
  * @param value - The stage's resolved value
193
- * @param expression - A display-neutral expression string
194
161
  * @returns A fresh step
195
162
  *
196
163
  * @example
197
164
  * ```ts
198
165
  * import { buildWorksheetStep } from '@orkestrel/rater'
199
166
  *
200
- * buildWorksheetStep('total', 'quote', 'Quote', 110, 'sum = 110')
201
- * // { stage: 'total', id: 'quote', name: 'Quote', value: 110, expression: 'sum = 110' }
167
+ * buildWorksheetStep('total', 'quote', 'Quote', 110)
168
+ * // { stage: 'total', id: 'quote', name: 'Quote', value: 110 }
202
169
  * ```
203
170
  */
204
- export declare function buildWorksheetStep(stage: WorksheetStage, id: string | undefined, name: string | undefined, value: number, expression: string): Step;
171
+ export declare function buildWorksheetStep(stage: WorksheetStage, id: string | undefined, name: string | undefined, value: number): Step;
205
172
 
206
173
  /**
207
174
  * Builds the ordered {@link Step} rows for a resolved {@link Worksheet}.
@@ -225,11 +192,44 @@ export declare function buildWorksheetStep(stage: WorksheetStage, id: string | u
225
192
  */
226
193
  export declare function buildWorksheetSteps(definition: QuantitativeDefinition, result: QuantitativeResult, groups: readonly WorksheetGroup[]): readonly Step[];
227
194
 
195
+ /**
196
+ * Copies a quantitative result into plain objects and arrays this package owns, reading each
197
+ * member of it once.
198
+ *
199
+ * @remarks
200
+ * The copy reaches the result's groups, their factors, and each factor's checks. A check's own
201
+ * `check` and `actual`, and the entries of `refusals`, `faults`, and `repairs`, are carried as
202
+ * they were read.
203
+ *
204
+ * @param result - The quantitative result to copy
205
+ * @returns A fresh result that holds each member as it read
206
+ *
207
+ * @example
208
+ * ```ts
209
+ * import { copyResult } from '@orkestrel/rater'
210
+ *
211
+ * const answer = {
212
+ * reasoning: 'quantitative',
213
+ * value: 5,
214
+ * groups: [],
215
+ * count: 0,
216
+ * success: true,
217
+ * trace: [],
218
+ * refusals: [],
219
+ * faults: [],
220
+ * repairs: [],
221
+ * defaulted: [],
222
+ * } as const
223
+ * copyResult(answer) === answer // false
224
+ * ```
225
+ */
226
+ export declare function copyResult(result: QuantitativeResult): QuantitativeResult;
227
+
228
228
  /**
229
229
  * Creates a rating orchestrator over the shared quantitative engine, seeded
230
230
  * from {@link RaterOptions} and returning a {@link RaterInterface}.
231
231
  *
232
- * @param options - Optional total handler, labels, injected engine, and emitter hooks
232
+ * @param options - Optional total handler, injected engine, and emitter hooks
233
233
  * @returns A {@link RaterInterface}
234
234
  *
235
235
  * @example Create a rater
@@ -242,42 +242,91 @@ export declare function buildWorksheetSteps(definition: QuantitativeDefinition,
242
242
  */
243
243
  export declare function createRater(options?: RaterOptions): RaterInterface;
244
244
 
245
- /** Represents a checked-evidence row rendered into a display-neutral sentence. */
246
- export declare interface Evidence {
247
- readonly field?: FieldPath;
248
- readonly label?: string;
249
- readonly comparison?: Comparison;
250
- readonly expected?: unknown;
251
- readonly actual?: unknown;
252
- readonly state?: CheckState;
253
- }
245
+ /**
246
+ * Finds each line whose id an earlier line of the list holds.
247
+ *
248
+ * @param lines - The lines of one rating, in order
249
+ * @returns One `definition` refusal for each such line, its `path` the id and its `index` the line's place
250
+ *
251
+ * @example
252
+ * ```ts
253
+ * import { createQuantitativeDefinition } from '@orkestrel/reason'
254
+ * import { buildLineDefinition, findRepeatedLines } from '@orkestrel/rater'
255
+ *
256
+ * const rate = createQuantitativeDefinition('base', 'Base', [])
257
+ * const line = buildLineDefinition('base', 'Base', rate)
258
+ * findRepeatedLines([line, line]) // [{ cause: 'definition', path: ['base'], index: 1 }]
259
+ * ```
260
+ */
261
+ export declare function findRepeatedLines(lines: readonly LineDefinition[]): readonly ReasonRefusal[];
254
262
 
255
- /** Describes an `Evidence` row in its JSON projection. */
256
- export declare const evidenceShape: ContractShape;
263
+ /**
264
+ * Finds each group id a result lists more than once, and each factor id one of its groups lists
265
+ * more than once.
266
+ *
267
+ * @remarks
268
+ * An entry that repeats an id is refused whatever it holds, because a worksheet reads the first
269
+ * entry and a completeness check reads the last. Each repeated id is named once, however many
270
+ * entries repeat it.
271
+ *
272
+ * @param result - The result the engine answered with
273
+ * @returns The `group`, and the `factor` where a factor repeats, of each repeated id
274
+ *
275
+ * @example
276
+ * ```ts
277
+ * import { findRepeatedParts } from '@orkestrel/rater'
278
+ *
279
+ * const group = { id: 'charge', applied: true, value: 100, factors: [] }
280
+ * findRepeatedParts({
281
+ * reasoning: 'quantitative',
282
+ * value: 100,
283
+ * groups: [group, group],
284
+ * count: 1,
285
+ * success: true,
286
+ * trace: [],
287
+ * refusals: [],
288
+ * faults: [],
289
+ * repairs: [],
290
+ * defaulted: [],
291
+ * }) // [{ group: 'charge' }]
292
+ * ```
293
+ */
294
+ export declare function findRepeatedParts(result: QuantitativeResult): ReadonlyArray<Pick<ReasonRefusal, 'group' | 'factor'>>;
257
295
 
258
296
  /**
259
- * Determines whether a value is an open result-side {@link Evidence} object.
297
+ * Finds each enabled group of a definition that a result omits, and each enabled factor an
298
+ * answered group omits.
260
299
  *
261
300
  * @remarks
262
- * Optional `field` is checked as a `FieldPath`, `label` as a string,
263
- * `comparison` as a `Comparison`, and `state` as a `CheckState`, each when defined.
264
- * Unknown members, prototypes, and class instances are admitted. Arrays are
265
- * refused. `expected` and `actual` are `unknown`, so this guard does not read or
266
- * check them and a borrowed result is never narrowed on them; either member may
267
- * also be absent because `objectOf` reads declared members rather than
268
- * requiring or enumerating own keys.
301
+ * An omitted group is named alone, because its factors have no group to answer in.
269
302
  *
270
- * @param value - The value to test
271
- * @returns True if every checked `Evidence` member conforms; false otherwise
303
+ * @param definition - The authored quantitative definition
304
+ * @param result - The result the engine answered with
305
+ * @returns The `group`, and the `factor` where one is omitted, of each omission, in definition order
272
306
  *
273
307
  * @example
274
308
  * ```ts
275
- * import { isEvidence } from '@orkestrel/rater'
309
+ * import { createFactorGroup, createQuantitativeDefinition, createStaticFactor } from '@orkestrel/reason'
310
+ * import { findUnansweredParts } from '@orkestrel/rater'
276
311
  *
277
- * isEvidence({ field: 'age', comparison: 'above', expected: 18, actual: 25, state: 'met' }) // true
312
+ * const definition = createQuantitativeDefinition('quote', 'Quote', [
313
+ * createFactorGroup('charge', 'sum', [createStaticFactor('base', 100)]),
314
+ * ])
315
+ * findUnansweredParts(definition, {
316
+ * reasoning: 'quantitative',
317
+ * value: 0,
318
+ * groups: [],
319
+ * count: 0,
320
+ * success: true,
321
+ * trace: [],
322
+ * refusals: [],
323
+ * faults: [],
324
+ * repairs: [],
325
+ * defaulted: [],
326
+ * }) // [{ group: 'charge' }]
278
327
  * ```
279
328
  */
280
- export declare function isEvidence(value: unknown): value is Evidence;
329
+ export declare function findUnansweredParts(definition: QuantitativeDefinition, result: QuantitativeResult): ReadonlyArray<Pick<ReasonRefusal, 'group' | 'factor'>>;
281
330
 
282
331
  /**
283
332
  * Determines whether a value is an exact {@link LineDefinition} record.
@@ -322,7 +371,7 @@ export declare function isLineDefinition(value: unknown): value is LineDefinitio
322
371
  * ```ts
323
372
  * import { isLineResult } from '@orkestrel/rater'
324
373
  *
325
- * isLineResult({ id: 'base', name: 'Base', worksheet: { id: 'base', name: 'Base', aggregation: 'sum', value: 0, groups: [], steps: [], trace: [], errors: [], success: false } }) // true
374
+ * isLineResult({ id: 'base', name: 'Base', worksheet: { id: 'base', name: 'Base', aggregation: 'sum', value: 0, groups: [], steps: [], trace: [], refusals: [], success: false } }) // true
326
375
  * ```
327
376
  */
328
377
  export declare function isLineResult(value: unknown): value is LineResult;
@@ -387,7 +436,7 @@ export declare function isRatingDefinition(value: unknown): value is RatingDefin
387
436
  * ```ts
388
437
  * import { isRatingResult } from '@orkestrel/rater'
389
438
  *
390
- * isRatingResult({ lines: [], success: true, errors: [], faults: [], repairs: [], defaulted: [] }) // true
439
+ * isRatingResult({ lines: [], success: true, refusals: [], faults: [], repairs: [], defaulted: [] }) // true
391
440
  * ```
392
441
  */
393
442
  export declare function isRatingResult(value: unknown): value is RatingResult;
@@ -396,7 +445,7 @@ export declare function isRatingResult(value: unknown): value is RatingResult;
396
445
  * Determines whether a value is an open {@link Step} result object.
397
446
  *
398
447
  * @remarks
399
- * `stage` is checked through `isWorksheetStage`, `id`, `name`, and `expression` when
448
+ * `stage` is checked through `isWorksheetStage`, `id` and `name` when
400
449
  * defined, and `value` as a plain number. Unknown members, prototypes, and
401
450
  * class instances are admitted and left unchecked, because a borrowed result
402
451
  * implementation may add them. Arrays are refused. Optional members may be
@@ -420,7 +469,7 @@ export declare function isStep(value: unknown): value is Step;
420
469
  * @remarks
421
470
  * Identity, `aggregation` through reason's `isAggregation`, an optional
422
471
  * plain-number `precision`, a plain-number `value`, the nested groups and steps,
423
- * `trace`, `errors`, and `success` are checked. Unknown members, prototypes, and
472
+ * `trace`, `refusals` through reason's `isReasonRefusal`, and `success` are checked. Unknown members, prototypes, and
424
473
  * class instances are admitted and left unchecked, because a borrowed result
425
474
  * implementation may add them. Arrays are refused. Optional members may be
426
475
  * absent or read as `undefined`.
@@ -432,7 +481,7 @@ export declare function isStep(value: unknown): value is Step;
432
481
  * ```ts
433
482
  * import { isWorksheet } from '@orkestrel/rater'
434
483
  *
435
- * isWorksheet({ id: 'quote', name: 'Quote', aggregation: 'sum', value: 0, groups: [], steps: [], trace: [], errors: [], success: true, faults: [], repairs: [], defaulted: [] }) // true
484
+ * isWorksheet({ id: 'quote', name: 'Quote', aggregation: 'sum', value: 0, groups: [], steps: [], trace: [], refusals: [], success: true, faults: [], repairs: [], defaulted: [] }) // true
436
485
  * ```
437
486
  */
438
487
  export declare function isWorksheet(value: unknown): value is Worksheet;
@@ -441,11 +490,11 @@ export declare function isWorksheet(value: unknown): value is Worksheet;
441
490
  * Determines whether a value is an open {@link WorksheetFactor} result object.
442
491
  *
443
492
  * @remarks
444
- * `id`, the optional authored text, `applied`, an optional plain-number
445
- * `value`, and each `Evidence` entry are checked. Unknown members, prototypes,
446
- * and class instances are admitted and left unchecked, because a borrowed
447
- * result implementation may add them. Arrays are refused. Optional members may
448
- * be absent or read as `undefined`.
493
+ * `id`, the optional authored text, `applied`, `fallback`, the optional plain-number
494
+ * `value` and `raw`, and each `CheckResult` entry are checked. `actual` is `unknown`, so
495
+ * this guard does not read it. Unknown members, prototypes, and class instances are
496
+ * admitted and left unchecked, because a borrowed result implementation may add them. Arrays
497
+ * are refused. Optional members may be absent or read as `undefined`.
449
498
  *
450
499
  * @param value - The value to test
451
500
  * @returns True if every published worksheet-factor member conforms; false otherwise
@@ -454,7 +503,7 @@ export declare function isWorksheet(value: unknown): value is Worksheet;
454
503
  * ```ts
455
504
  * import { isWorksheetFactor } from '@orkestrel/rater'
456
505
  *
457
- * isWorksheetFactor({ id: 'base', applied: true, value: 100, evidence: [] }) // true
506
+ * isWorksheetFactor({ id: 'base', applied: true, value: 100, fallback: false, checks: [] }) // true
458
507
  * ```
459
508
  */
460
509
  export declare function isWorksheetFactor(value: unknown): value is WorksheetFactor;
@@ -463,7 +512,7 @@ export declare function isWorksheetFactor(value: unknown): value is WorksheetFac
463
512
  * Determines whether a value is an open {@link WorksheetGroup} result object.
464
513
  *
465
514
  * @remarks
466
- * `id`, the optional authored text, `applied`, a plain-number `value`, and each
515
+ * `id`, the optional authored text, `applied`, an optional plain-number `value`, and each
467
516
  * `WorksheetFactor` entry are checked. Unknown members, prototypes, and class
468
517
  * instances are admitted and left unchecked, because a borrowed result
469
518
  * implementation may add them. Arrays are refused. Optional members may be
@@ -542,8 +591,9 @@ export declare const lineResultShape: ContractShape;
542
591
  * Projects a result to the JSON its contract reads.
543
592
  *
544
593
  * @remarks
545
- * An evidence row's `actual` holds whatever the subject held and a worksheet's numbers may be
546
- * `NaN`, so a result crosses a boundary as this projection, each `actual` on its own budget.
594
+ * A factor's `actual`, a check's `actual`, and a refusal's `actual` hold whatever the subject held
595
+ * and a worksheet's numbers may be `NaN`, so a result crosses a boundary as this projection, each
596
+ * `actual` on its own budget.
547
597
  *
548
598
  * @param result - The rating result
549
599
  * @returns Its JSON projection, which `ratingResultContract` admits
@@ -657,15 +707,13 @@ export declare interface RaterInterface {
657
707
  * `engine` — an injected {@link ReasonInterface}; when omitted, `Rater` builds
658
708
  * and owns its own quantitative-only engine (`bail: false`), destroying it on
659
709
  * `destroy()`. `total` — a {@link TotalHandler} overriding the default
660
- * {@link sumAmounts} projection. `labels` — field-to-label display overrides
661
- * threaded into every resolved {@link Evidence}.
710
+ * {@link sumAmounts} projection.
662
711
  */
663
712
  export declare interface RaterOptions {
664
713
  readonly on?: EmitterHooks<RaterEventMap>;
665
714
  readonly error?: EmitterErrorHandler;
666
715
  readonly engine?: ReasonInterface;
667
716
  readonly total?: TotalHandler;
668
- readonly labels?: Readonly<Record<string, string>>;
669
717
  }
670
718
 
671
719
  /**
@@ -701,13 +749,15 @@ export declare const ratingDefinitionShape: ContractShape;
701
749
  * @remarks
702
750
  * `total` is derived by the {@link TotalHandler} (default {@link sumAmounts})
703
751
  * over `lines` — only successfully rated lines carry an `amount`. `success`
704
- * is `true` only when every line's `worksheet.success` is `true`.
752
+ * is `false` exactly when `refusals` or `faults` holds an entry. Each refusal a line
753
+ * gave opens its `path` with that line's id, and a total that is not a finite number is
754
+ * a `value` refusal with no `path`.
705
755
  */
706
756
  export declare interface RatingResult {
707
757
  readonly lines: readonly LineResult[];
708
758
  readonly total?: number;
709
759
  readonly success: boolean;
710
- readonly errors: readonly string[];
760
+ readonly refusals: readonly ReasonRefusal[];
711
761
  readonly faults: readonly AuditFault[];
712
762
  readonly repairs: readonly AuditFault[];
713
763
  readonly defaulted: readonly FieldPath[];
@@ -719,13 +769,51 @@ export declare const ratingResultContract: ContractInterface<unknown>;
719
769
  /** Describes a `RatingResult` in its JSON projection. */
720
770
  export declare const ratingResultShape: ContractShape;
721
771
 
772
+ /**
773
+ * Holds an engine's answer to what its own members and the definition support.
774
+ *
775
+ * @remarks
776
+ * The answer is read once, through {@link copyResult}, and every verdict follows from that copy.
777
+ * An answer that is no quantitative result is `malformed` alone. A success beside a refusal or a
778
+ * fault, beside each enabled group or factor the answer omits, beside each group or factor id it
779
+ * lists more than once, and beside a value that is not a finite number, fails closed with one
780
+ * `malformed` refusal for each, the part in `group` and `factor` and the value in `actual`. A failure that names no refusal and no fault is
781
+ * `silent`. Any other answer returns as its copy.
782
+ *
783
+ * @param answer - What the engine answered
784
+ * @param definition - The authored quantitative definition the engine ran
785
+ * @returns A fresh result the package owns
786
+ *
787
+ * @example
788
+ * ```ts
789
+ * import { createQuantitativeDefinition } from '@orkestrel/reason'
790
+ * import { settleResult } from '@orkestrel/rater'
791
+ *
792
+ * settleResult(
793
+ * {
794
+ * reasoning: 'quantitative',
795
+ * value: 5,
796
+ * groups: [],
797
+ * count: 0,
798
+ * success: false,
799
+ * trace: [],
800
+ * refusals: [],
801
+ * faults: [],
802
+ * repairs: [],
803
+ * defaulted: [],
804
+ * },
805
+ * createQuantitativeDefinition('base', 'Base', []),
806
+ * ).refusals // [{ cause: 'silent' }]
807
+ * ```
808
+ */
809
+ export declare function settleResult(answer: unknown, definition: QuantitativeDefinition): QuantitativeResult;
810
+
722
811
  /** Represents a display-neutral worksheet derivation step. */
723
812
  export declare interface Step {
724
813
  readonly stage: WorksheetStage;
725
814
  readonly id?: string;
726
815
  readonly name?: string;
727
816
  readonly value: number;
728
- readonly expression?: string;
729
817
  }
730
818
 
731
819
  /**
@@ -750,7 +838,12 @@ export declare function sumAmounts(lines: readonly LineResult[]): number | undef
750
838
  /** Represents a pure total port over resolved lines. */
751
839
  export declare type TotalHandler = (lines: readonly LineResult[]) => number | undefined;
752
840
 
753
- /** Represents a quantitative definition joined to its result — the rating audit trail. */
841
+ /**
842
+ * Represents a quantitative definition joined to its result — the rating audit trail.
843
+ *
844
+ * @remarks
845
+ * `refusals` are the engine's own, with no `path` of this package's.
846
+ */
754
847
  export declare interface Worksheet {
755
848
  readonly id: string;
756
849
  readonly name: string;
@@ -760,7 +853,7 @@ export declare interface Worksheet {
760
853
  readonly groups: readonly WorksheetGroup[];
761
854
  readonly steps: readonly Step[];
762
855
  readonly trace: readonly string[];
763
- readonly errors: readonly string[];
856
+ readonly refusals: readonly ReasonRefusal[];
764
857
  readonly success: boolean;
765
858
  readonly faults: readonly AuditFault[];
766
859
  readonly repairs: readonly AuditFault[];
@@ -770,26 +863,42 @@ export declare interface Worksheet {
770
863
  /** Lists the stages a worksheet derivation step can belong to. */
771
864
  export declare const WORKSHEET_STAGES: readonly ['factor', 'group', 'total'];
772
865
 
773
- /** Represents a resolved quantitative factor, joined to its authored metadata. */
866
+ /**
867
+ * Represents a resolved quantitative factor, joined to its authored metadata.
868
+ *
869
+ * @remarks
870
+ * `raw` is the source value before transforms and bounds, `actual` is what the source read at
871
+ * its field, and `fallback` is true when the factor's fallback supplied `raw`. `checks` holds each
872
+ * check beside what it read, and is empty for a factor that never ran.
873
+ */
774
874
  export declare interface WorksheetFactor {
775
875
  readonly id: string;
776
876
  readonly name?: string;
777
877
  readonly description?: string;
778
878
  readonly applied: boolean;
779
879
  readonly value?: number;
780
- readonly evidence: readonly Evidence[];
880
+ readonly raw?: number;
881
+ readonly actual?: unknown;
882
+ readonly fallback: boolean;
883
+ readonly checks: readonly CheckResult[];
781
884
  }
782
885
 
783
886
  /** Describes a `WorksheetFactor` in its JSON projection. */
784
887
  export declare const worksheetFactorShape: ContractShape;
785
888
 
786
- /** Represents a resolved quantitative group, joined to its authored metadata. */
889
+ /**
890
+ * Represents a resolved quantitative group, joined to its authored metadata.
891
+ *
892
+ * @remarks
893
+ * `value` is absent for a group the result holds no answer for: a disabled group, or one a
894
+ * failed run never reached.
895
+ */
787
896
  export declare interface WorksheetGroup {
788
897
  readonly id: string;
789
898
  readonly name?: string;
790
899
  readonly description?: string;
791
900
  readonly applied: boolean;
792
- readonly value: number;
901
+ readonly value?: number;
793
902
  readonly factors: readonly WorksheetFactor[];
794
903
  }
795
904