footprintjs 14.2.0 → 14.3.0

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.
@@ -0,0 +1,182 @@
1
+ "use strict";
2
+ /**
3
+ * filter/firstMatch -- the ONE first-match law over a `decide()` rule table, the ONE row assembler, and one rule's
4
+ * evaluation without a scope.
5
+ *
6
+ * `firstMatch(rules, evaluate, defaultBranch)` asks `evaluate` for each rule in order until one matches, and builds the
7
+ * `DecisionEvidence`: the rows evaluated so far, the branch chosen, the default and its label, in that key order.
8
+ * Three doors call it, each with its own way of evaluating one rule:
9
+ *
10
+ * | Door | One rule is evaluated over |
11
+ * |---|---|
12
+ * | `decide()` (decide/decide.ts) | the stage's scope: its recorders, its run's redaction rule |
13
+ * | `decideAttempt` (attempt/decision.ts) | an attempt's inputs, every value kept (`ruleOver(read)`) |
14
+ * | `decideFromFacts` (decide/fromFacts.ts) | a plain record of facts, no value kept (`ruleOver(read, KEEP_NO_VALUE)`) |
15
+ *
16
+ * `functionRow` and `filterRow` build every row, for these three and for `select()`. A function rule's `matched` is
17
+ * whether its return was truthy, which is what routes the decision, and never the return itself: a rule over `any`
18
+ * facts can return a value (`(f) => f.token`), and the row must not carry it.
19
+ *
20
+ * `ruleOver(read, keeping?)` is one rule as `decide()` evaluates it, minus the scope: a filter rule's rows come from
21
+ * `evaluateFilter`, a function rule reads through a view that records each read and closes when the rule returns.
22
+ * `keeping` is what a row keeps of a value it read: every value (`KEEP_EVERY_VALUE`, the default), or none
23
+ * (`KEEP_NO_VALUE`: names and operators only, the placeholder for every value and threshold and for a thrown rule's
24
+ * text).
25
+ *
26
+ * A leaf beside `evaluator.ts`, not in decide/: attempt/ calls it, and decide/decide.ts imports the scope runtime, so an
27
+ * attempt → decide edge would close the attempt ⇄ decide ⇄ scope module cycle that moved the evaluator here (P2).
28
+ */
29
+ Object.defineProperty(exports, "__esModule", { value: true });
30
+ exports.ruleOver = exports.KEEP_NO_VALUE = exports.KEEP_EVERY_VALUE = exports.filterRow = exports.functionRow = exports.firstMatch = exports.normalizeDefaultBranch = void 0;
31
+ const summarize_js_1 = require("../capture/summarize.js");
32
+ const redactionValues_js_1 = require("../memory/redactionValues.js");
33
+ const evaluator_js_1 = require("./evaluator.js");
34
+ /** `decide()`'s summary length for an evidence value (filter/evaluator.ts, decide/evidence.ts). */
35
+ const MAX_VALUE_LEN = 80;
36
+ /**
37
+ * Collapses both {@link DefaultBranch} forms to one shape, once. A bare string yields `label: undefined`, which the
38
+ * evidence then omits — so the string call site produces exactly the evidence it produced before the parameter was
39
+ * widened.
40
+ *
41
+ * ONLY the object form is unwrapped; every other value passes through as the branch, untouched. That is deliberate:
42
+ * JavaScript callers reach `decide()` with the third argument MISSING (a rule set that covers every case never consults
43
+ * a default), and before the parameter widened that `undefined` simply landed on `evidence.default`. It still does — a
44
+ * normalization that only understood strings would turn those call sites into a TypeError.
45
+ */
46
+ function normalizeDefaultBranch(defaultBranch) {
47
+ return typeof defaultBranch === 'object' && defaultBranch !== null
48
+ ? defaultBranch
49
+ : { branch: defaultBranch };
50
+ }
51
+ exports.normalizeDefaultBranch = normalizeDefaultBranch;
52
+ /**
53
+ * Evaluates `rules` in order — first match wins — and builds the evidence. A rule whose `then` equals the default is
54
+ * still a rule's choice: what chose a branch is read from the rows, never from the branch.
55
+ */
56
+ function firstMatch(rules, evaluate, defaultBranch) {
57
+ const { branch: defaultId, label: defaultLabel } = defaultBranch;
58
+ // Declared once, spread into BOTH exits below — deliberately. A default's meaning is a property of the DECIDER, not
59
+ // of the run: it must be in the evidence of the run where a rule won just as much as in the run that fell through.
60
+ // Emit it only on the fallthrough and any consumer harvesting branch meanings would watch them appear and disappear
61
+ // with the data.
62
+ const defaultMeaning = defaultLabel !== undefined ? { defaultLabel } : undefined;
63
+ const evaluated = [];
64
+ for (const [index, rule] of rules.entries()) {
65
+ const row = evaluate(rule, index);
66
+ evaluated.push(row);
67
+ if (row.matched) {
68
+ const evidence = { rules: evaluated, chosen: rule.then, default: defaultId, ...defaultMeaning };
69
+ return { branch: rule.then, label: rule.label, evidence };
70
+ }
71
+ }
72
+ const evidence = { rules: evaluated, chosen: defaultId, default: defaultId, ...defaultMeaning };
73
+ return { branch: defaultId, label: defaultLabel, evidence };
74
+ }
75
+ exports.firstMatch = firstMatch;
76
+ /**
77
+ * A function rule's row. `matched` is `!!returned`: whether the rule's return was truthy, which is all that routes a
78
+ * decision. The return itself is never stored, so a rule that returns a value (`(f) => f.token`) leaves no value here.
79
+ */
80
+ function functionRow(rule, index, returned, inputs, matchError) {
81
+ return {
82
+ type: 'function',
83
+ ruleIndex: index,
84
+ branch: rule.then,
85
+ matched: !!returned,
86
+ label: rule.label,
87
+ inputs,
88
+ ...(matchError !== undefined && { matchError }),
89
+ };
90
+ }
91
+ exports.functionRow = functionRow;
92
+ /** A filter rule's row. */
93
+ function filterRow(rule, index, matched, conditions, matchError) {
94
+ return {
95
+ type: 'filter',
96
+ ruleIndex: index,
97
+ branch: rule.then,
98
+ matched,
99
+ label: rule.label,
100
+ conditions,
101
+ ...(matchError !== undefined && { matchError }),
102
+ };
103
+ }
104
+ exports.filterRow = filterRow;
105
+ /** No mask: every value, threshold and thrown text as it is. What `decideAttempt` keeps. */
106
+ exports.KEEP_EVERY_VALUE = {
107
+ masked: () => false,
108
+ matchError: (error) => (error instanceof Error ? error.message : String(error)),
109
+ };
110
+ /**
111
+ * No value: names and operators only. Every value and threshold is the placeholder (`evaluateFilter`'s own hole for a
112
+ * masked key), and a thrown rule's text is the placeholder: the thrown value is never turned into text, so none of its
113
+ * code runs. What `decideFromFacts` keeps.
114
+ */
115
+ exports.KEEP_NO_VALUE = { masked: () => true, matchError: () => redactionValues_js_1.SCOPE_PLACEHOLDER };
116
+ /**
117
+ * One rule's evaluation over `read`, without a scope: `read(key)` returns one value and is called only for the keys
118
+ * the rule touches, in the order it touches them. `keeping` is what each row keeps of a value (default: every value).
119
+ *
120
+ * As in `decide()`: a rule that throws does not match, and its row says why (`matchError`); a filter rule that throws
121
+ * records no conditions; a function rule that throws keeps the reads it made before the throw. A function rule's view
122
+ * closes when the rule returns or throws: a view it kept reads nothing afterwards and adds nothing to its row.
123
+ */
124
+ function ruleOver(read, keeping = exports.KEEP_EVERY_VALUE) {
125
+ return (rule, index) => evaluateRule(rule, index, read, keeping);
126
+ }
127
+ exports.ruleOver = ruleOver;
128
+ function evaluateRule(rule, index, read, keeping) {
129
+ if (typeof rule.when === 'function') {
130
+ const inputs = [];
131
+ const view = readingView(read, inputs, keeping.masked);
132
+ let returned;
133
+ let matchError;
134
+ try {
135
+ returned = rule.when(view.facts);
136
+ }
137
+ catch (error) {
138
+ returned = false;
139
+ matchError = keeping.matchError(error);
140
+ }
141
+ finally {
142
+ view.close();
143
+ }
144
+ return functionRow(rule, index, returned, inputs, matchError);
145
+ }
146
+ let matched = false;
147
+ let conditions = [];
148
+ let matchError;
149
+ try {
150
+ ({ matched, conditions } = (0, evaluator_js_1.evaluateFilter)(read, keeping.masked, rule.when));
151
+ }
152
+ catch (error) {
153
+ matchError = keeping.matchError(error);
154
+ }
155
+ return filterRow(rule, index, matched, conditions, matchError);
156
+ }
157
+ /**
158
+ * The values as a function rule sees them: each string-keyed read is recorded the way `decide()`'s evidence collector
159
+ * records a scope read — its key, its summary or the placeholder when `masked` says so, and the flag. A symbol-keyed
160
+ * read answers `undefined` and is not recorded. Once closed, the view answers `undefined` and records nothing.
161
+ */
162
+ function readingView(read, inputs, masked) {
163
+ let open = true;
164
+ const facts = new Proxy({}, {
165
+ get(_target, key) {
166
+ if (!open || typeof key !== 'string')
167
+ return undefined;
168
+ const value = read(key);
169
+ const redacted = masked(key);
170
+ // A masked value is never summarised: a summary shows the value, or an object's first keys.
171
+ inputs.push({ key, valueSummary: redacted ? redactionValues_js_1.SCOPE_PLACEHOLDER : (0, summarize_js_1.summarizeValue)(value, MAX_VALUE_LEN), redacted });
172
+ return value;
173
+ },
174
+ });
175
+ return {
176
+ facts,
177
+ close: () => {
178
+ open = false;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gIGNvbnN0IHZhbHVlID0gcmVhZChrZXkpO1xuICAgICAgY29uc3QgcmVkYWN0ZWQgPSBtYXNrZWQoa2V5KTtcbiAgICAgIC8vIEEgbWFza2VkIHZhbHVlIGlzIG5ldmVyIHN1bW1hcmlzZWQ6IGEgc3VtbWFyeSBzaG93cyB0aGUgdmFsdWUsIG9yIGFuIG9iamVjdCdzIGZpcnN0IGtleXMuXG4gICAgICBpbnB1dHMucHVzaCh7IGtleSwgdmFsdWVTdW1tYXJ5OiByZWRhY3RlZCA/IFNDT1BFX1BMQUNFSE9MREVSIDogc3VtbWFyaXplVmFsdWUodmFsdWUsIE1BWF9WQUxVRV9MRU4pLCByZWRhY3RlZCB9KTtcbiAgICAgIHJldHVybiB2YWx1ZTtcbiAgICB9LFxuICB9KTtcbiAgcmV0dXJuIHtcbiAgICBmYWN0cyxcbiAgICBjbG9zZTogKCkgPT4ge1xuICAgICAgb3BlbiA9IGZhbHNlO1xuICAgIH0sXG4gIH07XG59XG4iXX0=
@@ -49,6 +49,16 @@ export { narrative } from './recorders.js';
49
49
  export type { DecideRule, DecisionEvidence, DecisionResult, DefaultBranch, FilterOps, RuleEvidence, SelectionEvidence, SelectionResult, WhenClause, WhereFilter, } from './lib/decide/index.js';
50
50
  /** @category Decision Branching */
51
51
  export { decide, select } from './lib/decide/index.js';
52
+ /**
53
+ * `decideFromFacts` — `decide()`'s evaluation over a plain record of named facts, with no scope; its evidence keeps
54
+ * names and operators only, never a value. `decisionRecord` projects any `DecisionEvidence` to
55
+ * `{ strategy, by, rule?, label?, reads }`; `fixedRecord` records a choice no table made (`by: 'fixed'`).
56
+ *
57
+ * @category Decision Branching
58
+ */
59
+ export type { DecisionFromFacts, DecisionRecord, DecisionVoucher } from './lib/decide/index.js';
60
+ /** @category Decision Branching */
61
+ export { decideFromFacts, decisionRecord, fixedRecord } from './lib/decide/index.js';
52
62
  /** @category Errors */
53
63
  export { RunInFlightError } from './lib/errors/RunInFlightError.js';
54
64
  export type { TerminalFailureContext } from './lib/errors/terminalFailure.js';
@@ -17,10 +17,10 @@
17
17
  * share.
18
18
  *
19
19
  * `decideAttempt` evaluates that table WITHOUT a scope (the runner has none — `decide()` needs a registered
20
- * one) and builds the evidence `decide()` would build: the filter rows come from `decide()`'s own evaluator
21
- * (`filter/evaluator.ts · evaluateFilter`), the function rows and the first-match loop mirror
22
- * `decide/decide.ts` field for field and key for key. A property test pins that both paths give equal evidence
23
- * for equal inputs (test/lib/attempt/property).
20
+ * one) on the first-match core `decide()` and `decideFromFacts` share (`filter/firstMatch.ts`): the filter rows come
21
+ * from `decide()`'s own evaluator (`filter/evaluator.ts · evaluateFilter`), the function rows from the core's reading
22
+ * view, with no mask — every input is a number, a name or a flag. A property test pins that the three doors give
23
+ * equal evidence for equal inputs (test/lib/attempt/property).
24
24
  *
25
25
  * Inputs are READ, one key at a time, only when a rule reaches them — so the user's `retryOn` and `backoffMs`
26
26
  * run exactly when a retry needs them, as they did before the record existed.
@@ -0,0 +1,75 @@
1
+ /**
2
+ * decide/fromFacts -- `decide()`'s evaluation without a scope: a rule table over a plain record of named facts.
3
+ *
4
+ * One law, two doors. `decide()` evaluates a table over a stage's scope; `decideFromFacts` evaluates the same table
5
+ * over a record a caller built, on the same first-match core and the same row assembler (`filter/firstMatch.ts`), and
6
+ * returns the same `DecisionEvidence` shape. A property test pins that its evidence equals what `decide()` records in a
7
+ * run whose redaction policy selects every key, apart from a thrown rule's text, which this door never quotes
8
+ * (test/lib/decide/property/decide-from-facts.property.test.ts).
9
+ *
10
+ * A scope brings its run's redaction rule; a record brings none. So this door keeps no value, ever: names and operators
11
+ * only. There is no option that keeps values here. A caller inside a run that wants the run's own evidence calls
12
+ * `decide()` with its scope.
13
+ */
14
+ import type { DecideRule, DecisionEvidence, DefaultBranch } from './types.js';
15
+ /**
16
+ * What {@link decideFromFacts} returns. Not a decider's return value: inside a decider stage, use `decide()`.
17
+ *
18
+ * @category Decision Branching
19
+ */
20
+ export interface DecisionFromFacts {
21
+ /** The branch chosen: the first matching rule's `then`, or the default. */
22
+ readonly branch: string;
23
+ /** The `DecisionEvidence` of the decision, names and operators only. {@link decisionRecord} projects it to a record. */
24
+ readonly evidence: DecisionEvidence;
25
+ }
26
+ /**
27
+ * Evaluates `rules` in order over `facts` — first match wins — exactly as `decide()` evaluates them over a scope,
28
+ * and returns the branch and its `DecisionEvidence`. For a "which strategy, and why" chosen outside a stage.
29
+ *
30
+ * - `rules` take `decide()`'s shapes: a filter (`{ express: { eq: true } }`, every key ANDed) or a function
31
+ * (`(f) => f.weightKg > 30`). A rule's `label` is its reason. A filter with no evaluable condition never matches: the
32
+ * catch-all is `defaultBranch`.
33
+ * - `facts` is a plain record of FLAT names. A rule key is a name, never a path. Every own string-keyed DATA property
34
+ * is read once, up front, before any rule runs; class instances, frozen and null-prototype objects and arrays work.
35
+ * Inherited and symbol-keyed properties are not facts: a rule reads them as missing. A `Proxy` as facts is asked
36
+ * `ownKeys` once and `getOwnPropertyDescriptor` once per string key, and nothing else.
37
+ * - `defaultBranch` is `decide()`'s: `'rejected'`, or `{ branch: 'rejected', label: 'No rule fired' }`.
38
+ *
39
+ * **The evidence keeps names and operators only.** Every `actualSummary`, `valueSummary` and `threshold` is the
40
+ * placeholder `'[REDACTED]'` with `redacted: true` (a threshold also says `thresholdRedacted: true`), a function rule's
41
+ * `matched` is `true` or `false` whatever the rule returned, and a rule that threw says `matchError: '[REDACTED]'`: the
42
+ * thrown value is never turned into text. The rules still decide on the real values. One limit no door can close: a
43
+ * NAME is recorded as written, so a value a rule uses as a property key (`(f) => f[f.token]`), or a key that is itself
44
+ * the secret, is recorded as a fact name.
45
+ *
46
+ * A function rule reads facts by property access (`f.weightKg`); each string-keyed read is recorded by name. Its view
47
+ * closes when the rule returns: a view the rule kept reads nothing afterwards.
48
+ *
49
+ * A rule that throws does not match and does not throw out: its row says `matched: false` and carries `matchError`, as
50
+ * in `decide()`. Unlike `decide()`, and like the retry table's own evaluation, this door prints no dev-mode warning for
51
+ * a rule that threw: the row is the report.
52
+ *
53
+ * **Refused, up front, with a `TypeError` whose message names no value** (a fact that cannot be read as data would
54
+ * otherwise read as missing, and decide a different branch than `decide()` would):
55
+ * - facts that are not an object;
56
+ * - an own ACCESSOR property: the message names its key; its getter never runs;
57
+ * - a registered stage scope: inside a stage, use `decide(scope, …)`;
58
+ * - a `Map` or a `Set` (told by its own brand, so a `Proxy` around one is not).
59
+ *
60
+ * `rules` that are not an array of rules fail with the language's own `TypeError`.
61
+ *
62
+ * @example
63
+ * ```ts
64
+ * const { branch, evidence } = decideFromFacts(
65
+ * [{ when: { express: { eq: true } }, then: 'courier', label: 'Express delivery was asked for' }],
66
+ * { express: true },
67
+ * { branch: 'post', label: 'No rule fired' },
68
+ * );
69
+ * // branch === 'courier'; decisionRecord(evidence) →
70
+ * // { strategy: 'courier', by: 'rule', rule: 0, label: 'Express delivery was asked for', reads: ['express'] }
71
+ * ```
72
+ *
73
+ * @category Decision Branching
74
+ */
75
+ export declare function decideFromFacts<F extends object>(rules: readonly DecideRule<F>[], facts: F, defaultBranch: DefaultBranch): DecisionFromFacts;
@@ -1,12 +1,17 @@
1
1
  /**
2
2
  * decide/ -- Decision reasoning capture for footprintjs.
3
3
  *
4
- * decide() and select() auto-capture evidence from decider/selector functions:
4
+ * decide() and select() auto-capture evidence from decider/selector functions; decideFromFacts() evaluates the
5
+ * same rules over a plain record, and decisionRecord() / fixedRecord() give the record of a decision:
5
6
  * - Function when: (s) => s.creditScore > 700 (auto-captures reads)
6
7
  * - Filter when: { creditScore: { gt: 700 } } (captures reads + operators + thresholds)
7
8
  */
8
9
  export type { DecideRule, DecisionEvidence, DecisionResult, DefaultBranch, FilterCondition, FilterOps, FilterRuleEvidence, FunctionRuleEvidence, ReadInput, RuleEvidence, SelectionEvidence, SelectionResult, WhenClause, WhereFilter, } from './types.js';
9
10
  export { DECISION_RESULT } from './types.js';
10
11
  export { decide, select } from './decide.js';
12
+ export type { DecisionFromFacts } from './fromFacts.js';
13
+ export { decideFromFacts } from './fromFacts.js';
14
+ export type { DecisionRecord, DecisionVoucher } from './record.js';
15
+ export { decisionRecord, fixedRecord } from './record.js';
11
16
  export { evaluateFilter } from '../filter/evaluator.js';
12
17
  export { EvidenceCollector } from './evidence.js';
@@ -0,0 +1,81 @@
1
+ /**
2
+ * decide/record -- the decision record: which strategy was picked, by what, for what reason, from which facts.
3
+ *
4
+ * A projection, not a second structure: `decisionRecord(evidence)` derives the record from a `DecisionEvidence`
5
+ * (`decide()`'s or `decideFromFacts`'s), so nothing is stored twice. `fixedRecord` makes the one record no evidence
6
+ * can give: a choice no table made, because someone stated it.
7
+ */
8
+ import type { DecisionEvidence } from './types.js';
9
+ /**
10
+ * Who stated a fixed choice: the application (its configuration), or a provider (an adapter's own setting).
11
+ *
12
+ * @category Decision Branching
13
+ */
14
+ export type DecisionVoucher = 'app' | 'provider';
15
+ /**
16
+ * One "which strategy, and why". A user may add its own fields beside these; it does not rename them or change what
17
+ * they mean. `strategy`, `by` and `reads` are always present; `rule` only for `by: 'rule'`, `label` only when the table
18
+ * or the caller gave a reason, `voucher` only on a fixed choice whose caller said who stated it.
19
+ *
20
+ * @category Decision Branching
21
+ */
22
+ export interface DecisionRecord {
23
+ /** The branch chosen. */
24
+ readonly strategy: string;
25
+ /**
26
+ * What chose it: `'rule'`, a rule of the table; `'default'`, the table's default, because no rule matched;
27
+ * `'fixed'`, no table — someone stated the choice ({@link fixedRecord}).
28
+ */
29
+ readonly by: 'rule' | 'default' | 'fixed';
30
+ /** The winning rule's index in its table (`ruleIndex`, counted from 0). Present only when `by` is `'rule'`. */
31
+ readonly rule?: number;
32
+ /** The reason, in the table author's words: the winning rule's `label`, or the default's. Absent when none was given. */
33
+ readonly label?: string;
34
+ /**
35
+ * The names of the facts that decided it, de-duplicated in first-read order: names, never values. A name is recorded
36
+ * as written, so a value a rule used as a property key (`(f) => f[f.token]`) is recorded as a name.
37
+ */
38
+ readonly reads: readonly string[];
39
+ /** Who stated a fixed choice, when the caller says. Only on `by: 'fixed'`. */
40
+ readonly voucher?: DecisionVoucher;
41
+ }
42
+ /**
43
+ * The decision record of `evidence`, derived from the evidence alone.
44
+ *
45
+ * - **The winner.** The winning rule is the last entry of `evidence.rules` when its `matched` is true (first match
46
+ * wins, so evaluation stopped there): `by: 'rule'`, `rule` its `ruleIndex`, `label` its label. `by` is never
47
+ * inferred from `chosen === default`: a rule whose `then` equals the default branch is still `by: 'rule'`.
48
+ * - **The default.** Otherwise `by: 'default'` and `label` is `evidence.defaultLabel`.
49
+ * - **`reads`.** For a rule, the names its row read: a filter's condition keys, a function's input keys. For the
50
+ * default, the de-duplicated union, in first-read order, of every row's condition and input keys: what was looked
51
+ * at, since no rule won.
52
+ *
53
+ * A name the rows do not hold cannot be in the record, and the record says nothing more about it. The rows lose a name
54
+ * that was read, or meant to be read, in these cases:
55
+ * - a filter rule that THREW (for example an `in` list over 1000 entries) records no conditions, so none of its names;
56
+ * - a key the filter refuses (the prototype denylist: `__proto__`, `constructor`, `toString`, …) records no condition;
57
+ * - a key whose operators are an empty object (`{ a: {} }`) is read but records no condition, and a key whose operators
58
+ * are not an object (`{ a: 5 }`) is not read at all;
59
+ * - a function rule's symbol-keyed reads are not recorded, and in `decide()` neither is a read with no key (the whole
60
+ * state at once);
61
+ * - a read a function rule makes after it returned (`decideFromFacts`, the retry table) is not recorded.
62
+ *
63
+ * A function rule that threw keeps the names it read before the throw.
64
+ *
65
+ * @category Decision Branching
66
+ */
67
+ export declare function decisionRecord(evidence: DecisionEvidence): DecisionRecord;
68
+ /**
69
+ * The record of a choice no table made: `by: 'fixed'`, no rule, no reads. A bare string in a configuration
70
+ * (`delivery: 'courier'`) is `fixedRecord('courier', undefined, 'app')`. It is not a rule: an empty filter never
71
+ * matches, so no table can express "always".
72
+ *
73
+ * @param strategy - the branch someone stated.
74
+ * @param label - the reason, when there is one.
75
+ * @param voucher - who stated it, `'app'` or `'provider'`, when the caller knows.
76
+ * @throws TypeError when `strategy` is not a string, `label` is given and not a string, or `voucher` is given and is
77
+ * not one of the two.
78
+ *
79
+ * @category Decision Branching
80
+ */
81
+ export declare function fixedRecord(strategy: string, label?: string, voucher?: DecisionVoucher): DecisionRecord;
@@ -0,0 +1,98 @@
1
+ /**
2
+ * filter/firstMatch -- the ONE first-match law over a `decide()` rule table, the ONE row assembler, and one rule's
3
+ * evaluation without a scope.
4
+ *
5
+ * `firstMatch(rules, evaluate, defaultBranch)` asks `evaluate` for each rule in order until one matches, and builds the
6
+ * `DecisionEvidence`: the rows evaluated so far, the branch chosen, the default and its label, in that key order.
7
+ * Three doors call it, each with its own way of evaluating one rule:
8
+ *
9
+ * | Door | One rule is evaluated over |
10
+ * |---|---|
11
+ * | `decide()` (decide/decide.ts) | the stage's scope: its recorders, its run's redaction rule |
12
+ * | `decideAttempt` (attempt/decision.ts) | an attempt's inputs, every value kept (`ruleOver(read)`) |
13
+ * | `decideFromFacts` (decide/fromFacts.ts) | a plain record of facts, no value kept (`ruleOver(read, KEEP_NO_VALUE)`) |
14
+ *
15
+ * `functionRow` and `filterRow` build every row, for these three and for `select()`. A function rule's `matched` is
16
+ * whether its return was truthy, which is what routes the decision, and never the return itself: a rule over `any`
17
+ * facts can return a value (`(f) => f.token`), and the row must not carry it.
18
+ *
19
+ * `ruleOver(read, keeping?)` is one rule as `decide()` evaluates it, minus the scope: a filter rule's rows come from
20
+ * `evaluateFilter`, a function rule reads through a view that records each read and closes when the rule returns.
21
+ * `keeping` is what a row keeps of a value it read: every value (`KEEP_EVERY_VALUE`, the default), or none
22
+ * (`KEEP_NO_VALUE`: names and operators only, the placeholder for every value and threshold and for a thrown rule's
23
+ * text).
24
+ *
25
+ * A leaf beside `evaluator.ts`, not in decide/: attempt/ calls it, and decide/decide.ts imports the scope runtime, so an
26
+ * attempt → decide edge would close the attempt ⇄ decide ⇄ scope module cycle that moved the evaluator here (P2).
27
+ */
28
+ import type { DecideRule, DecisionEvidence, DefaultBranch, FilterCondition, FilterRuleEvidence, FunctionRuleEvidence, ReadInput, RuleEvidence } from '../decide/types.js';
29
+ /** One rule's evaluation, as the first-match loop asks for it. */
30
+ export type RuleEvaluator<R> = (rule: R, index: number) => RuleEvidence;
31
+ /** A first-match pass: the branch, the label of what chose it (the rule's, or the default's), and the evidence. */
32
+ export interface FirstMatch {
33
+ readonly branch: string;
34
+ readonly label: string | undefined;
35
+ readonly evidence: DecisionEvidence;
36
+ }
37
+ /**
38
+ * Collapses both {@link DefaultBranch} forms to one shape, once. A bare string yields `label: undefined`, which the
39
+ * evidence then omits — so the string call site produces exactly the evidence it produced before the parameter was
40
+ * widened.
41
+ *
42
+ * ONLY the object form is unwrapped; every other value passes through as the branch, untouched. That is deliberate:
43
+ * JavaScript callers reach `decide()` with the third argument MISSING (a rule set that covers every case never consults
44
+ * a default), and before the parameter widened that `undefined` simply landed on `evidence.default`. It still does — a
45
+ * normalization that only understood strings would turn those call sites into a TypeError.
46
+ */
47
+ export declare function normalizeDefaultBranch(defaultBranch: DefaultBranch): {
48
+ branch: string;
49
+ label?: string;
50
+ };
51
+ /**
52
+ * Evaluates `rules` in order — first match wins — and builds the evidence. A rule whose `then` equals the default is
53
+ * still a rule's choice: what chose a branch is read from the rows, never from the branch.
54
+ */
55
+ export declare function firstMatch<R extends {
56
+ readonly then: string;
57
+ readonly label?: string;
58
+ }>(rules: readonly R[], evaluate: RuleEvaluator<R>, defaultBranch: {
59
+ readonly branch: string;
60
+ readonly label?: string;
61
+ }): FirstMatch;
62
+ /** What a rule's row needs of the rule: its branch and its label. */
63
+ interface RuleHead {
64
+ readonly then: string;
65
+ readonly label?: string;
66
+ }
67
+ /**
68
+ * A function rule's row. `matched` is `!!returned`: whether the rule's return was truthy, which is all that routes a
69
+ * decision. The return itself is never stored, so a rule that returns a value (`(f) => f.token`) leaves no value here.
70
+ */
71
+ export declare function functionRow(rule: RuleHead, index: number, returned: unknown, inputs: ReadInput[], matchError: string | undefined): FunctionRuleEvidence;
72
+ /** A filter rule's row. */
73
+ export declare function filterRow(rule: RuleHead, index: number, matched: boolean, conditions: FilterCondition[], matchError: string | undefined): FilterRuleEvidence;
74
+ /** What a row keeps of the values a rule read. */
75
+ export interface ValueKeeping {
76
+ /** Is the value under `key` masked? What `redacted` says on a row. */
77
+ readonly masked: (key: string) => boolean;
78
+ /** A thrown rule's text, as the row keeps it. */
79
+ readonly matchError: (error: unknown) => string;
80
+ }
81
+ /** No mask: every value, threshold and thrown text as it is. What `decideAttempt` keeps. */
82
+ export declare const KEEP_EVERY_VALUE: ValueKeeping;
83
+ /**
84
+ * No value: names and operators only. Every value and threshold is the placeholder (`evaluateFilter`'s own hole for a
85
+ * masked key), and a thrown rule's text is the placeholder: the thrown value is never turned into text, so none of its
86
+ * code runs. What `decideFromFacts` keeps.
87
+ */
88
+ export declare const KEEP_NO_VALUE: ValueKeeping;
89
+ /**
90
+ * One rule's evaluation over `read`, without a scope: `read(key)` returns one value and is called only for the keys
91
+ * the rule touches, in the order it touches them. `keeping` is what each row keeps of a value (default: every value).
92
+ *
93
+ * As in `decide()`: a rule that throws does not match, and its row says why (`matchError`); a filter rule that throws
94
+ * records no conditions; a function rule that throws keeps the reads it made before the throw. A function rule's view
95
+ * closes when the rule returns or throws: a view it kept reads nothing afterwards and adds nothing to its row.
96
+ */
97
+ export declare function ruleOver<S extends object>(read: (key: string) => unknown, keeping?: ValueKeeping): RuleEvaluator<DecideRule<S>>;
98
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "footprintjs",
3
- "version": "14.2.0",
3
+ "version": "14.3.0",
4
4
  "description": "TypeScript workflow engine that records each run's stages, state changes and decision evidence, so AI agents and people can explain and debug what happened.",
5
5
  "license": "MIT",
6
6
  "author": "Sanjay Krishna Anbalagan",