footprintjs 14.2.0 → 14.4.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.
- package/AGENTS.md +2 -1
- package/dist/esm/index.d.ts +10 -0
- package/dist/esm/index.js +3 -1
- package/dist/esm/lib/attempt/decision.d.ts +4 -4
- package/dist/esm/lib/attempt/decision.js +8 -86
- package/dist/esm/lib/attempt/runner.js +5 -5
- package/dist/esm/lib/capture/explainCoverage.d.ts +2 -0
- package/dist/esm/lib/capture/explainCoverage.js +1 -1
- package/dist/esm/lib/capture/explainWitness.js +5 -3
- package/dist/esm/lib/decide/decide.js +12 -73
- package/dist/esm/lib/decide/fromFacts.d.ts +75 -0
- package/dist/esm/lib/decide/fromFacts.js +114 -0
- package/dist/esm/lib/decide/index.d.ts +6 -1
- package/dist/esm/lib/decide/index.js +5 -2
- package/dist/esm/lib/decide/record.d.ts +81 -0
- package/dist/esm/lib/decide/record.js +83 -0
- package/dist/esm/lib/engine/graph/detachTopology.d.ts +12 -0
- package/dist/esm/lib/engine/graph/detachTopology.js +93 -0
- package/dist/esm/lib/engine/graph/skippedProjection.d.ts +46 -0
- package/dist/esm/lib/engine/graph/skippedProjection.js +336 -0
- package/dist/esm/lib/engine/handlers/ContinuationResolver.js +5 -1
- package/dist/esm/lib/engine/handlers/DeciderHandler.js +16 -20
- package/dist/esm/lib/engine/handlers/SelectorHandler.js +27 -27
- package/dist/esm/lib/engine/traversal/FlowchartTraverser.js +5 -3
- package/dist/esm/lib/filter/firstMatch.d.ts +95 -0
- package/dist/esm/lib/filter/firstMatch.js +218 -0
- package/dist/esm/lib/memory/StageContext.js +8 -2
- package/dist/esm/lib/memory/storedControlEvidence.d.ts +23 -0
- package/dist/esm/lib/memory/storedControlEvidence.js +110 -0
- package/dist/esm/lib/memory/storedControlLifecycle.d.ts +30 -0
- package/dist/esm/lib/memory/storedControlLifecycle.js +8 -0
- package/dist/esm/lib/runner/ExecutionRuntime.d.ts +2 -1
- package/dist/esm/lib/runner/ExecutionRuntime.js +2 -1
- package/dist/esm/lib/runner/FlowChartExecutor.d.ts +1 -0
- package/dist/esm/lib/runner/FlowChartExecutor.js +31 -14
- package/dist/esm/lib/runner/options.d.ts +12 -1
- package/dist/esm/lib/runner/options.js +1 -1
- package/dist/esm/lib/runner/recordSink.d.ts +3 -2
- package/dist/esm/lib/runner/recordSink.js +5 -2
- package/dist/esm/skipped-writer-capture.d.ts +4 -0
- package/dist/esm/skipped-writer-capture.js +171 -0
- package/dist/esm/skipped-writer-state.d.ts +35 -0
- package/dist/esm/skipped-writer-state.js +7 -0
- package/dist/esm/skipped-writers.d.ts +18 -0
- package/dist/esm/skipped-writers.js +60 -0
- package/dist/index.js +68 -63
- package/dist/lib/attempt/decision.js +8 -86
- package/dist/lib/attempt/runner.js +5 -5
- package/dist/lib/capture/explainCoverage.js +1 -1
- package/dist/lib/capture/explainWitness.js +5 -3
- package/dist/lib/decide/decide.js +12 -73
- package/dist/lib/decide/fromFacts.js +118 -0
- package/dist/lib/decide/index.js +9 -3
- package/dist/lib/decide/record.js +88 -0
- package/dist/lib/engine/graph/detachTopology.js +97 -0
- package/dist/lib/engine/graph/skippedProjection.js +340 -0
- package/dist/lib/engine/handlers/ContinuationResolver.js +5 -1
- package/dist/lib/engine/handlers/DeciderHandler.js +16 -20
- package/dist/lib/engine/handlers/SelectorHandler.js +27 -27
- package/dist/lib/engine/traversal/FlowchartTraverser.js +5 -3
- package/dist/lib/filter/firstMatch.js +226 -0
- package/dist/lib/memory/StageContext.js +8 -2
- package/dist/lib/memory/storedControlEvidence.js +121 -0
- package/dist/lib/memory/storedControlLifecycle.js +13 -0
- package/dist/lib/runner/ExecutionRuntime.js +2 -1
- package/dist/lib/runner/FlowChartExecutor.js +31 -14
- package/dist/lib/runner/options.js +1 -1
- package/dist/lib/runner/recordSink.js +5 -2
- package/dist/skipped-writer-capture.js +175 -0
- package/dist/skipped-writer-state.js +11 -0
- package/dist/skipped-writers.js +88 -0
- package/dist/types/index.d.ts +10 -0
- package/dist/types/lib/attempt/decision.d.ts +4 -4
- package/dist/types/lib/capture/explainCoverage.d.ts +2 -0
- package/dist/types/lib/decide/fromFacts.d.ts +75 -0
- package/dist/types/lib/decide/index.d.ts +6 -1
- package/dist/types/lib/decide/record.d.ts +81 -0
- package/dist/types/lib/engine/graph/detachTopology.d.ts +12 -0
- package/dist/types/lib/engine/graph/skippedProjection.d.ts +46 -0
- package/dist/types/lib/filter/firstMatch.d.ts +95 -0
- package/dist/types/lib/memory/storedControlEvidence.d.ts +23 -0
- package/dist/types/lib/memory/storedControlLifecycle.d.ts +30 -0
- package/dist/types/lib/runner/ExecutionRuntime.d.ts +2 -1
- package/dist/types/lib/runner/FlowChartExecutor.d.ts +1 -0
- package/dist/types/lib/runner/options.d.ts +12 -1
- package/dist/types/lib/runner/recordSink.d.ts +3 -2
- package/dist/types/skipped-writer-capture.d.ts +4 -0
- package/dist/types/skipped-writer-state.d.ts +35 -0
- package/dist/types/skipped-writers.d.ts +18 -0
- package/package.json +15 -2
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.skippedWriterCaptureOptions = exports.declareSkippedWriterPaths = exports.readSkippedWriters = void 0;
|
|
27
|
+
/**
|
|
28
|
+
* Skipped writers. Query evidence on an exact live FootPrint capture.
|
|
29
|
+
*
|
|
30
|
+
* @module footprintjs/skipped-writers
|
|
31
|
+
*/
|
|
32
|
+
const explainWitness_js_1 = require("./lib/capture/explainWitness.js");
|
|
33
|
+
const skipped_writer_state_js_1 = require("./skipped-writer-state.js");
|
|
34
|
+
let optionalEvaluator;
|
|
35
|
+
function evaluator() {
|
|
36
|
+
return (optionalEvaluator ??= Promise.resolve().then(() => __importStar(require('foottrace/cause'))).then((reader) => {
|
|
37
|
+
const capability = reader;
|
|
38
|
+
const { evaluateSkippedPaths, savedChartDigest } = capability;
|
|
39
|
+
if (typeof evaluateSkippedPaths !== 'function')
|
|
40
|
+
return undefined;
|
|
41
|
+
return {
|
|
42
|
+
evaluateSkippedPaths,
|
|
43
|
+
savedChartDigest: typeof savedChartDigest === 'function' ? savedChartDigest : undefined,
|
|
44
|
+
};
|
|
45
|
+
})
|
|
46
|
+
.catch(() => undefined));
|
|
47
|
+
}
|
|
48
|
+
const declarations = new WeakMap();
|
|
49
|
+
function unavailable(gap) {
|
|
50
|
+
return { candidates: [], gaps: [gap] };
|
|
51
|
+
}
|
|
52
|
+
/** Only an exact served snapshot can supply the native chart and retained writer entries. */
|
|
53
|
+
async function readSkippedWriters(snapshot, key, beforeIdx) {
|
|
54
|
+
const capability = await evaluator();
|
|
55
|
+
if (!capability)
|
|
56
|
+
return unavailable('not-collected');
|
|
57
|
+
const capture = skipped_writer_state_js_1.liveCaptures.get(snapshot);
|
|
58
|
+
if (!capture) {
|
|
59
|
+
const witness = (0, explainWitness_js_1.captureWitnessOf)(snapshot);
|
|
60
|
+
return unavailable(witness?.boundary === 'completed' && witness.commits.from > 0 ? 'not-collected' : 'chart-binding');
|
|
61
|
+
}
|
|
62
|
+
if (capture.gap)
|
|
63
|
+
return unavailable(capture.gap);
|
|
64
|
+
const result = capability.evaluateSkippedPaths(capture.rows.map((row) => JSON.parse(row)), key, beforeIdx, capture.evidence);
|
|
65
|
+
return {
|
|
66
|
+
candidates: result.candidates.map((candidate) => ({ ...candidate, binding: 'native' })),
|
|
67
|
+
gaps: result.gaps,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
exports.readSkippedWriters = readSkippedWriters;
|
|
71
|
+
/** Declare the exhaustive write paths for an exact authored stage placement. */
|
|
72
|
+
function declareSkippedWriterPaths(placement, paths) {
|
|
73
|
+
declarations.set(placement, Object.freeze([...paths]));
|
|
74
|
+
}
|
|
75
|
+
exports.declareSkippedWriterPaths = declareSkippedWriterPaths;
|
|
76
|
+
/**
|
|
77
|
+
* Enable bounded skipped-writer capture when the installed Foottrace supplies the evaluator.
|
|
78
|
+
* Use the returned options with a same-instance executor configured with a record sink.
|
|
79
|
+
*/
|
|
80
|
+
async function skippedWriterCaptureOptions(options = {}) {
|
|
81
|
+
const capability = await evaluator();
|
|
82
|
+
if (!capability)
|
|
83
|
+
return options;
|
|
84
|
+
const { configureSkippedWriterCapture } = await Promise.resolve().then(() => __importStar(require('./skipped-writer-capture.js')));
|
|
85
|
+
return configureSkippedWriterCapture(options, capability, (placement) => declarations.get(placement), (snapshot, capture) => skipped_writer_state_js_1.liveCaptures.set(snapshot, capture));
|
|
86
|
+
}
|
|
87
|
+
exports.skippedWriterCaptureOptions = skippedWriterCaptureOptions;
|
|
88
|
+
//# sourceMappingURL=data:application/json;base64,ey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yZXMuc2V0KHNuYXBzaG90LCBjYXB0dXJlKSxcbiAgKTtcbn1cbiJdfQ==
|
package/dist/types/index.d.ts
CHANGED
|
@@ -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)
|
|
21
|
-
* (`filter/evaluator.ts · evaluateFilter`), the function rows
|
|
22
|
-
*
|
|
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.
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { LogAddress } from 'foottrace';
|
|
2
|
+
import type { ExplainCaptureWitness } from './explainWitness.js';
|
|
2
3
|
import type { CaptureChannelStatus, NativeCaptureNote } from './nativeCoverage.js';
|
|
3
4
|
import type { EngineReadSources } from './readSources.js';
|
|
4
5
|
import type { FanoutCollections } from './subflowHandoff.js';
|
|
@@ -40,6 +41,7 @@ export declare function createExplainCapture(switches: Switches): ExplainCapture
|
|
|
40
41
|
/** @internal Bounded fixed-vocabulary facts, accumulated at the native owners of this log. */
|
|
41
42
|
export declare class ExplainCapture {
|
|
42
43
|
private readonly switches;
|
|
44
|
+
onWitness?: (record: object, witness: ExplainCaptureWitness) => void;
|
|
43
45
|
private readonly observations;
|
|
44
46
|
private readonly observedHandoffs;
|
|
45
47
|
private untrackedNestedRead;
|
|
@@ -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,12 @@
|
|
|
1
|
+
import type { StageNode } from './StageNode.js';
|
|
2
|
+
export interface DetachedStageTopology<TOut, TScope> {
|
|
3
|
+
readonly root: StageNode<TOut, TScope>;
|
|
4
|
+
detachedOf(authored: object): StageNode<TOut, TScope> | undefined;
|
|
5
|
+
authoredOf(detached: object): StageNode<TOut, TScope> | undefined;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* A private immutable topology for a captured leg. Shared placements remain shared.
|
|
9
|
+
* Functions and operational configuration keep their references. Author-owned
|
|
10
|
+
* declarations can be read through the original placement while building the projection.
|
|
11
|
+
*/
|
|
12
|
+
export declare function detachStageTopology<TOut, TScope>(root: StageNode<TOut, TScope>, work?: number): DetachedStageTopology<TOut, TScope> | undefined;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { StageNode } from './StageNode.js';
|
|
2
|
+
type Role = 'stage' | 'mount' | 'loop-reference' | 'join';
|
|
3
|
+
type ControlKind = 'decider' | 'selector';
|
|
4
|
+
type ProjectionGap = 'graph-ambiguous' | 'truncated';
|
|
5
|
+
interface Choice {
|
|
6
|
+
readonly entry: string;
|
|
7
|
+
readonly name: string;
|
|
8
|
+
readonly fallback?: true;
|
|
9
|
+
readonly loopBack?: {
|
|
10
|
+
readonly body: string;
|
|
11
|
+
readonly exit: string;
|
|
12
|
+
readonly owner: string;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
/** The version-1 Foottrace chart description. No stage function is carried. */
|
|
16
|
+
export interface SkippedChartProjection {
|
|
17
|
+
readonly stages: readonly {
|
|
18
|
+
readonly id: string;
|
|
19
|
+
readonly stageId: string;
|
|
20
|
+
readonly role: Role;
|
|
21
|
+
readonly edges: readonly string[];
|
|
22
|
+
readonly writes?: readonly string[];
|
|
23
|
+
}[];
|
|
24
|
+
readonly controls: readonly {
|
|
25
|
+
readonly placementId: string;
|
|
26
|
+
readonly kind: ControlKind;
|
|
27
|
+
readonly choices: readonly Choice[];
|
|
28
|
+
readonly continuation: string | null;
|
|
29
|
+
}[];
|
|
30
|
+
}
|
|
31
|
+
export interface SkippedProjectionOptions {
|
|
32
|
+
/** Exhaustive paths for this exact placement, with undefined indicating no declaration. */
|
|
33
|
+
readonly writesOf?: (placement: StageNode) => readonly string[] | undefined;
|
|
34
|
+
/** Resolve a stage's function from the same stage map as the traverser, without invoking it. */
|
|
35
|
+
readonly hasStageFunction?: (placement: StageNode) => boolean;
|
|
36
|
+
readonly work?: number;
|
|
37
|
+
}
|
|
38
|
+
/** Project only the static scope. A producer must separately verify it against the traversed run. */
|
|
39
|
+
export declare function projectSkippedChart(root: StageNode, options?: SkippedProjectionOptions): {
|
|
40
|
+
readonly status: 'ready';
|
|
41
|
+
readonly graph: SkippedChartProjection;
|
|
42
|
+
} | {
|
|
43
|
+
readonly status: 'unknown';
|
|
44
|
+
readonly reason: ProjectionGap;
|
|
45
|
+
};
|
|
46
|
+
export {};
|
|
@@ -0,0 +1,95 @@
|
|
|
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
|
+
/** A function rule's row. Only synchronous return truthiness routes a decision. */
|
|
68
|
+
export declare function functionRow(rule: RuleHead, index: number, returned: unknown, inputs: ReadInput[], matchError: string | undefined): FunctionRuleEvidence;
|
|
69
|
+
/** A filter rule's row. */
|
|
70
|
+
export declare function filterRow(rule: RuleHead, index: number, matched: boolean, conditions: FilterCondition[], matchError: string | undefined): FilterRuleEvidence;
|
|
71
|
+
/** What a row keeps of the values a rule read. */
|
|
72
|
+
export interface ValueKeeping {
|
|
73
|
+
/** Is the value under `key` masked? What `redacted` says on a row. */
|
|
74
|
+
readonly masked: (key: string) => boolean;
|
|
75
|
+
/** A thrown rule's text, as the row keeps it. */
|
|
76
|
+
readonly matchError: (error: unknown) => string;
|
|
77
|
+
}
|
|
78
|
+
/** No mask: every value, threshold and thrown text as it is. What `decideAttempt` keeps. */
|
|
79
|
+
export declare const KEEP_EVERY_VALUE: ValueKeeping;
|
|
80
|
+
/**
|
|
81
|
+
* No value: names and operators only. Every value and threshold is the placeholder (`evaluateFilter`'s own hole for a
|
|
82
|
+
* masked key), and a thrown rule's text is the placeholder: the thrown value is never turned into text, so none of its
|
|
83
|
+
* code runs. What `decideFromFacts` keeps.
|
|
84
|
+
*/
|
|
85
|
+
export declare const KEEP_NO_VALUE: ValueKeeping;
|
|
86
|
+
/**
|
|
87
|
+
* One rule's evaluation over `read`, without a scope: `read(key)` returns one value and is called only for the keys
|
|
88
|
+
* the rule touches, in the order it touches them. `keeping` is what each row keeps of a value (default: every value).
|
|
89
|
+
*
|
|
90
|
+
* As in `decide()`: a rule that throws does not match, and its row says why (`matchError`); a filter rule that throws
|
|
91
|
+
* records no conditions; a function rule that throws keeps the reads it made before the throw. A function rule's view
|
|
92
|
+
* closes when the rule returns or throws: a view it kept reads nothing afterwards and adds nothing to its row.
|
|
93
|
+
*/
|
|
94
|
+
export declare function ruleOver<S extends object>(read: (key: string) => unknown, keeping?: ValueKeeping): RuleEvaluator<DecideRule<S>>;
|
|
95
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { CommitAbout, EventLog, RunDecisionNote } from 'foottrace/write';
|
|
2
|
+
import { type StoredControlLifecycle } from './storedControlLifecycle.js';
|
|
3
|
+
interface ControlExecution {
|
|
4
|
+
readonly id: string;
|
|
5
|
+
readonly parent?: string;
|
|
6
|
+
readonly resumes?: string;
|
|
7
|
+
}
|
|
8
|
+
/** Private producer state. An unresolved dispatch cannot certify a served recording's chart. */
|
|
9
|
+
export declare function canBindStoredControl(log: EventLog): boolean;
|
|
10
|
+
/** Install once on the opted-in native log. An ordinary writer stays on its existing path. */
|
|
11
|
+
export declare function installStoredControl(log: EventLog, seal?: StoredControlLifecycle['seal']): void;
|
|
12
|
+
/** Bind the native identity at entry. An ordinary log creates no frame evidence. */
|
|
13
|
+
export declare function beginStoredControl(frame: object, log: EventLog, execution: ControlExecution): void;
|
|
14
|
+
/** The first substantive bundle owns ancestry, including an explicit empty root stamp. */
|
|
15
|
+
export declare function storedControlAbout(frame: object): CommitAbout | undefined;
|
|
16
|
+
export declare function storedControlLanded(frame: object): void;
|
|
17
|
+
/** A native entry without an owning bundle can supply its edge, but no settled choice. */
|
|
18
|
+
export declare function noteStoredControlStage(frame: object): void;
|
|
19
|
+
/** Only an admitted, actually dispatched choice follows the owning commit. */
|
|
20
|
+
export declare function noteStoredControlDecision(frame: object, decision: Omit<RunDecisionNote, 'id'>): void;
|
|
21
|
+
/** The exact resolved static target is known before the next execution begins. */
|
|
22
|
+
export declare function noteStoredControlLoop(frame: object, target: string): void;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Meta } from 'foottrace';
|
|
2
|
+
import type { CommitAbout, EventLog } from 'foottrace/write';
|
|
3
|
+
import type { StageContext } from './StageContext.js';
|
|
4
|
+
/** The stage lifecycle seam. The optional producer owns all evidence storage and validation. */
|
|
5
|
+
export interface StoredControlLifecycle {
|
|
6
|
+
begin(frame: {
|
|
7
|
+
readonly parent?: {
|
|
8
|
+
readonly runtimeStageId: string;
|
|
9
|
+
};
|
|
10
|
+
}, id: string, parentLog?: EventLog): void;
|
|
11
|
+
about(frame: object): CommitAbout | undefined;
|
|
12
|
+
landed(frame: object): void;
|
|
13
|
+
dynamic(): void;
|
|
14
|
+
seal?(runId: string): Promise<{
|
|
15
|
+
readonly skippedChart: Meta;
|
|
16
|
+
} | undefined>;
|
|
17
|
+
decision(frame: StageContext, children: readonly {
|
|
18
|
+
readonly name: string;
|
|
19
|
+
}[], chosen: string, fellBack: boolean, fromRules: boolean): void;
|
|
20
|
+
selection(frame: StageContext, children: readonly {
|
|
21
|
+
readonly name: string;
|
|
22
|
+
}[], chosen: readonly string[]): void;
|
|
23
|
+
loop(frame: StageContext, source: {
|
|
24
|
+
readonly next?: {
|
|
25
|
+
readonly isLoopRef?: boolean;
|
|
26
|
+
};
|
|
27
|
+
}, reference: object | string, target: string): void;
|
|
28
|
+
}
|
|
29
|
+
export declare function registerStoredControl(owner: object, lifecycle: StoredControlLifecycle): void;
|
|
30
|
+
export declare function storedControlFor(owner: object | undefined): StoredControlLifecycle | undefined;
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* After execution, consumers query it for the full execution state.
|
|
11
11
|
*/
|
|
12
12
|
import type { CommitBundle, CommitValuesMode, LogAddress, LogOutcome, Meta } from 'foottrace';
|
|
13
|
-
import type { RecordSink, WriteProvenanceMode } from 'foottrace/write';
|
|
13
|
+
import type { LogCollects, RecordSink, WriteProvenanceMode } from 'foottrace/write';
|
|
14
14
|
import { EventLog, SharedMemory } from 'foottrace/write';
|
|
15
15
|
import type { RunCorrelation } from '../attempt/types.js';
|
|
16
16
|
import type { ExplainCapture, ExplainCaptureFactory, ExplainCaptureNote } from '../capture/explainCoverage.js';
|
|
@@ -167,6 +167,7 @@ export interface RuntimeRecord {
|
|
|
167
167
|
readonly sink: RecordSink;
|
|
168
168
|
readonly address: LogAddress;
|
|
169
169
|
readonly meta?: Meta;
|
|
170
|
+
readonly collects?: Pick<LogCollects, 'reads'>;
|
|
170
171
|
}
|
|
171
172
|
export declare class ExecutionRuntime {
|
|
172
173
|
/** Installed only for explicit handoff capture. It is not the app's persistence sink. */
|
|
@@ -54,6 +54,7 @@ export declare class FlowChartExecutor<TOut = any, TScope = any> {
|
|
|
54
54
|
/** The run's ONE redaction rule (`memory/redaction.ts`), built fresh per leg. */
|
|
55
55
|
private redactionRule;
|
|
56
56
|
private lastCheckpoint;
|
|
57
|
+
private storedControl?;
|
|
57
58
|
/**
|
|
58
59
|
* `true` once run() (or a resume) executed here. `resume()` branches on it:
|
|
59
60
|
* true → reuse the runtime (execution tree, recorders, narrative accumulate);
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* bare `ScopeFactory`) into the `ExecutorArgs` the executor keeps for every leg.
|
|
7
7
|
*/
|
|
8
8
|
import type { Meta } from 'foottrace';
|
|
9
|
+
import type { RecordEntry } from 'foottrace/write';
|
|
9
10
|
import type { RunCorrelation } from '../attempt/types.js';
|
|
10
11
|
import type { FlowChart } from '../builder/types.js';
|
|
11
12
|
import type { ExplainCaptureFactory } from '../capture/explainCoverage.js';
|
|
@@ -102,10 +103,19 @@ export interface ExecutorArgs<TOut, TScope> {
|
|
|
102
103
|
/** The record sink, resolved and checked at construction (10.1, P6). */
|
|
103
104
|
sink?: ResolvedRecordSink;
|
|
104
105
|
captureCoverage?: boolean;
|
|
105
|
-
explainCapture?: ExplainCaptureFactory
|
|
106
|
+
explainCapture?: ExplainCaptureFactory & {
|
|
107
|
+
prepareStoredControl?(chart: FlowChart<TOut, TScope>): PreparedStoredControl<TOut, TScope> | undefined;
|
|
108
|
+
};
|
|
106
109
|
captureExtent?: boolean;
|
|
107
110
|
captureClosure?: boolean;
|
|
108
111
|
}
|
|
112
|
+
/** Private result prepared by the optional producer before host callbacks. */
|
|
113
|
+
export interface PreparedStoredControl<TOut, TScope> {
|
|
114
|
+
readonly root: FlowChart<TOut, TScope>['root'];
|
|
115
|
+
readonly stageMap: FlowChart<TOut, TScope>['stageMap'];
|
|
116
|
+
retain(entry: RecordEntry): void;
|
|
117
|
+
attach(runtime: ExecutionRuntime): void;
|
|
118
|
+
}
|
|
109
119
|
/**
|
|
110
120
|
* Resolve either constructor form. The 2-param form is the options form with
|
|
111
121
|
* only `scopeFactory`; the scope factory falls back to the chart's, then to a
|
|
@@ -114,6 +124,7 @@ export interface ExecutorArgs<TOut, TScope> {
|
|
|
114
124
|
export declare function resolveExecutorArgs<TOut, TScope>(flowChart: FlowChart<TOut, TScope>, factoryOrOptions: ScopeFactory<TScope> | FlowChartExecutorOptions<TScope> | undefined): ExecutorArgs<TOut, TScope>;
|
|
115
125
|
/** @internal Construction-only overrides for a native traversal leg; never an application option. */
|
|
116
126
|
export interface TraverserOverrides<TOut = any, TScope = any> {
|
|
127
|
+
storedControl?: PreparedStoredControl<TOut, TScope>;
|
|
117
128
|
initialContext?: unknown;
|
|
118
129
|
preserveRecorders?: boolean;
|
|
119
130
|
existingRuntime?: InstanceType<typeof ExecutionRuntime>;
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
* log's to count (`EventLog · sinkFailures`), never the run's — so nothing here throws to the engine.
|
|
23
23
|
*/
|
|
24
24
|
import type { Meta } from 'foottrace';
|
|
25
|
-
import type { RecordSink } from 'foottrace/write';
|
|
25
|
+
import type { RecordEntry, RecordSink } from 'foottrace/write';
|
|
26
26
|
import type { CaptureHistoryOptions, CaptureHistoryStatus } from '../capture/historyTypes.js';
|
|
27
27
|
import type { RedactionRule } from '../memory/redaction.js';
|
|
28
28
|
import type { RecordSinkStats } from './ExecutionRuntime.js';
|
|
@@ -86,6 +86,7 @@ export declare function resolveRecordSink(option: unknown): ResolvedRecordSink |
|
|
|
86
86
|
*/
|
|
87
87
|
export declare class RunRecord {
|
|
88
88
|
private readonly resolved;
|
|
89
|
+
private readonly retain?;
|
|
89
90
|
/** Hand this to every `EventLog` of the run. */
|
|
90
91
|
readonly sink: RecordSink;
|
|
91
92
|
private entries;
|
|
@@ -100,7 +101,7 @@ export declare class RunRecord {
|
|
|
100
101
|
private captureStatus?;
|
|
101
102
|
/** Opaque error identities only: no raw entry or adapter error is enumerable on the transport error. */
|
|
102
103
|
private readonly invocationFailures;
|
|
103
|
-
constructor(resolved: ResolvedRecordSink);
|
|
104
|
+
constructor(resolved: ResolvedRecordSink, retain?: ((entry: RecordEntry) => void) | undefined);
|
|
104
105
|
/** Capture the served entry now; an asynchronous failure keeps this leg's rule, not a later resume's rule. */
|
|
105
106
|
private invoke;
|
|
106
107
|
/** A sink error is the diagnostic errors.recordSinkError; raw causes belong only to the caller's exception. */
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { StageNode } from './lib/engine/graph/StageNode.js';
|
|
2
|
+
import type { FlowChartExecutorOptions } from './lib/runner/options.js';
|
|
3
|
+
import type { Evaluator, LiveCapture } from './skipped-writer-state.js';
|
|
4
|
+
export declare function configureSkippedWriterCapture<TScope>(options: FlowChartExecutorOptions<TScope>, capability: Evaluator, writesOf: (placement: StageNode) => readonly string[] | undefined, bind: (snapshot: object, capture: LiveCapture) => void): FlowChartExecutorOptions<TScope>;
|