@agenticprimitives/orchestration 0.0.0-alpha.3 → 0.0.0-alpha.30
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/README.md +7 -0
- package/dist/admission.d.ts +75 -10
- package/dist/admission.d.ts.map +1 -1
- package/dist/admission.js +203 -8
- package/dist/admission.js.map +1 -1
- package/dist/answer-quality.d.ts +129 -0
- package/dist/answer-quality.d.ts.map +1 -0
- package/dist/answer-quality.js +197 -0
- package/dist/answer-quality.js.map +1 -0
- package/dist/approval.d.ts +20 -0
- package/dist/approval.d.ts.map +1 -0
- package/dist/approval.js +79 -0
- package/dist/approval.js.map +1 -0
- package/dist/artifacts.d.ts +9 -1
- package/dist/artifacts.d.ts.map +1 -1
- package/dist/artifacts.js +119 -2
- package/dist/artifacts.js.map +1 -1
- package/dist/authority.d.ts +176 -2
- package/dist/authority.d.ts.map +1 -1
- package/dist/conformance.d.ts +80 -0
- package/dist/conformance.d.ts.map +1 -0
- package/dist/conformance.js +264 -0
- package/dist/conformance.js.map +1 -0
- package/dist/derivation.d.ts +40 -0
- package/dist/derivation.d.ts.map +1 -0
- package/dist/derivation.js +158 -0
- package/dist/derivation.js.map +1 -0
- package/dist/digest.d.ts +10 -0
- package/dist/digest.d.ts.map +1 -0
- package/dist/digest.js +45 -0
- package/dist/digest.js.map +1 -0
- package/dist/evidence.d.ts +77 -0
- package/dist/evidence.d.ts.map +1 -0
- package/dist/evidence.js +101 -0
- package/dist/evidence.js.map +1 -0
- package/dist/export-port.d.ts +13 -0
- package/dist/export-port.d.ts.map +1 -0
- package/dist/export-port.js +2 -0
- package/dist/export-port.js.map +1 -0
- package/dist/index.d.ts +33 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +39 -6
- package/dist/index.js.map +1 -1
- package/dist/input.d.ts +52 -0
- package/dist/input.d.ts.map +1 -1
- package/dist/input.js +15 -0
- package/dist/input.js.map +1 -1
- package/dist/intent.d.ts +37 -0
- package/dist/intent.d.ts.map +1 -0
- package/dist/intent.js +46 -0
- package/dist/intent.js.map +1 -0
- package/dist/judgment.d.ts +131 -0
- package/dist/judgment.d.ts.map +1 -0
- package/dist/judgment.js +249 -0
- package/dist/judgment.js.map +1 -0
- package/dist/loop.d.ts +74 -9
- package/dist/loop.d.ts.map +1 -1
- package/dist/loop.js +1057 -178
- package/dist/loop.js.map +1 -1
- package/dist/metrics.js +8 -8
- package/dist/metrics.js.map +1 -1
- package/dist/outcome.d.ts +223 -0
- package/dist/outcome.d.ts.map +1 -0
- package/dist/outcome.js +326 -0
- package/dist/outcome.js.map +1 -0
- package/dist/plan-digest.d.ts +16 -0
- package/dist/plan-digest.d.ts.map +1 -0
- package/dist/plan-digest.js +45 -0
- package/dist/plan-digest.js.map +1 -0
- package/dist/planner.d.ts +43 -0
- package/dist/planner.d.ts.map +1 -1
- package/dist/planner.js +132 -0
- package/dist/planner.js.map +1 -1
- package/dist/provenance.d.ts +37 -0
- package/dist/provenance.d.ts.map +1 -0
- package/dist/provenance.js +127 -0
- package/dist/provenance.js.map +1 -0
- package/dist/reconcile.d.ts +48 -0
- package/dist/reconcile.d.ts.map +1 -0
- package/dist/reconcile.js +20 -0
- package/dist/reconcile.js.map +1 -0
- package/dist/record.d.ts +129 -22
- package/dist/record.d.ts.map +1 -1
- package/dist/record.js +53 -1
- package/dist/record.js.map +1 -1
- package/dist/regression.d.ts +130 -0
- package/dist/regression.d.ts.map +1 -0
- package/dist/regression.js +113 -0
- package/dist/regression.js.map +1 -0
- package/dist/rollup.d.ts +72 -0
- package/dist/rollup.d.ts.map +1 -0
- package/dist/rollup.js +117 -0
- package/dist/rollup.js.map +1 -0
- package/dist/selection.d.ts +334 -0
- package/dist/selection.d.ts.map +1 -0
- package/dist/selection.js +481 -0
- package/dist/selection.js.map +1 -0
- package/dist/spans.d.ts +77 -2
- package/dist/spans.d.ts.map +1 -1
- package/dist/spans.js +98 -25
- package/dist/spans.js.map +1 -1
- package/dist/step-lifecycle.d.ts +303 -0
- package/dist/step-lifecycle.d.ts.map +1 -0
- package/dist/step-lifecycle.js +304 -0
- package/dist/step-lifecycle.js.map +1 -0
- package/dist/tool-invoker.d.ts +58 -3
- package/dist/tool-invoker.d.ts.map +1 -1
- package/dist/tool-invoker.js +26 -1
- package/dist/tool-invoker.js.map +1 -1
- package/dist/trace-facts.d.ts +93 -0
- package/dist/trace-facts.d.ts.map +1 -0
- package/dist/trace-facts.js +82 -0
- package/dist/trace-facts.js.map +1 -0
- package/dist/types.d.ts +210 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +8 -0
- package/dist/types.js.map +1 -1
- package/package.json +17 -8
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
/** What a use ledger holds for one signed step identity (mandate reference × step nonce). */
|
|
2
|
+
export type SlotStateV1 = {
|
|
3
|
+
status: 'free';
|
|
4
|
+
}
|
|
5
|
+
/** An attempt began and recorded no completion. `operationId` is the key that attempt gave the downstream; `retried`
|
|
6
|
+
* says the one hand-over a reader may justify was already made. There is no timer after which it is taken over. */
|
|
7
|
+
| {
|
|
8
|
+
status: 'held';
|
|
9
|
+
attempt: string;
|
|
10
|
+
retried: boolean;
|
|
11
|
+
operationId?: string;
|
|
12
|
+
holder?: string;
|
|
13
|
+
} | {
|
|
14
|
+
status: 'done';
|
|
15
|
+
};
|
|
16
|
+
export type SlotOpV1 = {
|
|
17
|
+
op: 'begin';
|
|
18
|
+
attempt: string;
|
|
19
|
+
holder?: string;
|
|
20
|
+
operationId?: string;
|
|
21
|
+
retryOf?: string;
|
|
22
|
+
} | {
|
|
23
|
+
op: 'complete';
|
|
24
|
+
} | {
|
|
25
|
+
op: 'release';
|
|
26
|
+
attempt: string;
|
|
27
|
+
};
|
|
28
|
+
/** What the slot answers a `begin` — the only thing a runner learns about the slot. */
|
|
29
|
+
export type SlotAnswerV1 =
|
|
30
|
+
/** `slot: 'none'` — the use of this step is COUNTED ELSEWHERE (an on-chain enforcer nonce, a venue's per-request
|
|
31
|
+
* challenge): no slot was stored, so nothing here can hold, park or hand the step over. */
|
|
32
|
+
{
|
|
33
|
+
status: 'begun';
|
|
34
|
+
slot?: 'none';
|
|
35
|
+
} | {
|
|
36
|
+
status: 'held';
|
|
37
|
+
attempt: string;
|
|
38
|
+
retried: boolean;
|
|
39
|
+
operationId?: string;
|
|
40
|
+
holder?: string;
|
|
41
|
+
} | {
|
|
42
|
+
status: 'done';
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* The slot's compare-and-set. A durable ledger applies exactly this, atomically per slot.
|
|
46
|
+
* begin free ⇒ held by this attempt (`begun`). held ⇒ `held` (naming the holder) unless `retryOf` names the attempt
|
|
47
|
+
* that holds it: then the step is handed to this attempt, marked `retried` (`begun`). done ⇒ `done`.
|
|
48
|
+
* Asked again by the attempt that already holds it ⇒ `begun` again, nothing changed (a lost acknowledgement).
|
|
49
|
+
* complete ⇒ done, whoever asks: the effect exists is a fact about the step.
|
|
50
|
+
* release frees ONLY the named attempt, and only a first attempt: a retried attempt followed one that may have acted.
|
|
51
|
+
*/
|
|
52
|
+
export declare function slotTransition(slot: SlotStateV1, op: SlotOpV1): {
|
|
53
|
+
slot: SlotStateV1;
|
|
54
|
+
answer?: SlotAnswerV1;
|
|
55
|
+
};
|
|
56
|
+
/** What a reader of the effect said. `no-reader` is the answer when none is bound — it is never `absent`. */
|
|
57
|
+
export type ReaderEvidenceV1 = 'present' | 'absent' | 'unknown' | 'no-reader';
|
|
58
|
+
/** Why a step parked as effect-uncertain — one word a host can switch on; the loop renders the sentence. */
|
|
59
|
+
export type UncertainWhyV1 = 'ledger-done-no-result' | 'no-reader' | 'reader-unknown' | 'not-idempotent' | 'already-retried' | 'other-operation-id' | 'stale-read' | 'lost-handover' | 'retry-not-performed'
|
|
60
|
+
/** The ledger did not answer `begin` (it may have stored the attempt), or could not be told a first attempt performed
|
|
61
|
+
* nothing: the slot may be held by THIS attempt, which performed nothing — the run parks rather than end holding it. */
|
|
62
|
+
| 'ledger-unanswered' | 'release-failed';
|
|
63
|
+
/** The attempt this runner makes, constant for its life. */
|
|
64
|
+
export interface AttemptContextV1 {
|
|
65
|
+
/** This runner's attempt token (unique per attempt). */
|
|
66
|
+
attempt: string;
|
|
67
|
+
/** The token this runner holds the step under if it is handed over to it — ANOTHER token, also unique: every hand-over
|
|
68
|
+
* changes the name of the attempt that holds the slot, so a runner still looking at the attempt it was handed over
|
|
69
|
+
* from (this runner's own first attempt included) names an attempt that no longer holds it, and is refused. */
|
|
70
|
+
retryAttempt: string;
|
|
71
|
+
/** The key this runner would give the downstream. */
|
|
72
|
+
operationId: string;
|
|
73
|
+
/** The tool declares it dedups a repeat by operation id (`adapter.retry === 'idempotent-by-key'`). */
|
|
74
|
+
idempotentByKey: boolean;
|
|
75
|
+
/** A use ledger counts this step. `false` (a self-acting or routed step, a verifier that does not count): the attempt
|
|
76
|
+
* acts without a slot, and a throw is a plain failure — there is no signed step identity to protect. */
|
|
77
|
+
counted: boolean;
|
|
78
|
+
}
|
|
79
|
+
export type AttemptStateV1 = {
|
|
80
|
+
phase: 'idle';
|
|
81
|
+
}
|
|
82
|
+
/** This attempt holds the slot (or needs none) and the tool was invoked. `retry`: it took the step over. */
|
|
83
|
+
| {
|
|
84
|
+
phase: 'acting';
|
|
85
|
+
retry: boolean;
|
|
86
|
+
operationId: string;
|
|
87
|
+
counted: boolean;
|
|
88
|
+
}
|
|
89
|
+
/** The tool did not run; the slot is being told (`release`). */
|
|
90
|
+
| {
|
|
91
|
+
phase: 'releasing';
|
|
92
|
+
question: boolean;
|
|
93
|
+
}
|
|
94
|
+
/** The effect exists; the slot is being told (`complete`). */
|
|
95
|
+
| {
|
|
96
|
+
phase: 'completing';
|
|
97
|
+
by: 'tool' | 'reader' | 'principal';
|
|
98
|
+
}
|
|
99
|
+
/** The slot is held (by another attempt, or by this one after a throw) or done with no result here: evidence is needed. */
|
|
100
|
+
| {
|
|
101
|
+
phase: 'resolving';
|
|
102
|
+
slot: Exclude<SlotAnswerV1, {
|
|
103
|
+
status: 'begun';
|
|
104
|
+
}>;
|
|
105
|
+
/** This runner already took the step over once (and its re-invocation threw): it asks for no second hand-over. */
|
|
106
|
+
spent?: true;
|
|
107
|
+
}
|
|
108
|
+
/** A hand-over was asked of the slot (`begin` with `retryOf`); its answer is awaited. */
|
|
109
|
+
| {
|
|
110
|
+
phase: 'handing-over';
|
|
111
|
+
from: string;
|
|
112
|
+
operationId: string;
|
|
113
|
+
}
|
|
114
|
+
/** `ledgerUnwritten`: the effect exists and is recorded by this run, but the ledger could not be told — the slot stays
|
|
115
|
+
* held, and any OTHER runner of the step resolves it by a reader or the principal (never by performing it). */
|
|
116
|
+
| {
|
|
117
|
+
phase: 'recorded';
|
|
118
|
+
by: 'tool' | 'reader' | 'principal';
|
|
119
|
+
ledgerUnwritten?: true;
|
|
120
|
+
} | {
|
|
121
|
+
phase: 'released';
|
|
122
|
+
because: 'question' | 'not-performed';
|
|
123
|
+
} | {
|
|
124
|
+
phase: 'failed';
|
|
125
|
+
} | {
|
|
126
|
+
phase: 'parked';
|
|
127
|
+
ledger: 'held' | 'done';
|
|
128
|
+
why: UncertainWhyV1;
|
|
129
|
+
heldAttempt?: string;
|
|
130
|
+
};
|
|
131
|
+
export type AttemptEventV1 =
|
|
132
|
+
/** The slot answered — this attempt's first `begin`, or the `hand-over` it asked for (for an uncounted step the caller
|
|
133
|
+
* delivers `begun`). Which request it answers is part of the event: an answer to one is never read as the other's. */
|
|
134
|
+
{
|
|
135
|
+
type: 'slot-answered';
|
|
136
|
+
to: 'begin' | 'hand-over';
|
|
137
|
+
answer: SlotAnswerV1;
|
|
138
|
+
}
|
|
139
|
+
/** STORAGE ACKNOWLEDGEMENTS ARE EVENTS. The ledger did not answer (after the caller's one repeat of the same call): the
|
|
140
|
+
* write may have landed. */
|
|
141
|
+
| {
|
|
142
|
+
type: 'slot-unanswered';
|
|
143
|
+
to: 'begin' | 'hand-over';
|
|
144
|
+
} | {
|
|
145
|
+
type: 'released';
|
|
146
|
+
} | {
|
|
147
|
+
type: 'release-failed';
|
|
148
|
+
} | {
|
|
149
|
+
type: 'completed';
|
|
150
|
+
} | {
|
|
151
|
+
type: 'complete-failed';
|
|
152
|
+
}
|
|
153
|
+
/** The evidence gathered for a `resolving` step, all at once. `readAbout` is the held attempt the evidence concerns:
|
|
154
|
+
* the reader was asked AFTER the slot named it (freshness), and `uncertainty` is the digest of the prompt that slot
|
|
155
|
+
* state would raise. Evidence about another attempt (a stale read, a redelivered event) justifies nothing.
|
|
156
|
+
* `principal` is an answer the host admitted as the principal's voice — its `answers` is still compared here. */
|
|
157
|
+
| {
|
|
158
|
+
type: 'evidence';
|
|
159
|
+
reader: ReaderEvidenceV1;
|
|
160
|
+
readAbout?: string;
|
|
161
|
+
uncertainty: string;
|
|
162
|
+
principal?: {
|
|
163
|
+
effect: 'present' | 'absent';
|
|
164
|
+
answers?: string;
|
|
165
|
+
};
|
|
166
|
+
} | {
|
|
167
|
+
type: 'returned';
|
|
168
|
+
retry: boolean;
|
|
169
|
+
}
|
|
170
|
+
/** The invoker said nothing left (`NotPerformed`), or asked a question first (`InputRequired`). */
|
|
171
|
+
| {
|
|
172
|
+
type: 'not-performed';
|
|
173
|
+
retry: boolean;
|
|
174
|
+
question: boolean;
|
|
175
|
+
}
|
|
176
|
+
/** Any other throw: the effect may have happened. */
|
|
177
|
+
| {
|
|
178
|
+
type: 'threw';
|
|
179
|
+
retry: boolean;
|
|
180
|
+
};
|
|
181
|
+
export type AttemptEffectV1 = {
|
|
182
|
+
do: 'invoke';
|
|
183
|
+
operationId: string;
|
|
184
|
+
} | {
|
|
185
|
+
do: 'complete';
|
|
186
|
+
} | {
|
|
187
|
+
do: 'release';
|
|
188
|
+
}
|
|
189
|
+
/** Ask a bound reader about the held attempt, then deliver `evidence`. */
|
|
190
|
+
| {
|
|
191
|
+
do: 'gather-evidence';
|
|
192
|
+
about?: string;
|
|
193
|
+
}
|
|
194
|
+
/** `begin` again naming the held attempt; deliver its answer as `slot-answered`. */
|
|
195
|
+
| {
|
|
196
|
+
do: 'hand-over';
|
|
197
|
+
retryOf: string;
|
|
198
|
+
as: string;
|
|
199
|
+
operationId: string;
|
|
200
|
+
} | {
|
|
201
|
+
do: 'record';
|
|
202
|
+
by: 'tool' | 'reader' | 'principal';
|
|
203
|
+
ledgerUnwritten?: true;
|
|
204
|
+
} | {
|
|
205
|
+
do: 'park';
|
|
206
|
+
ledger: 'held' | 'done';
|
|
207
|
+
why: UncertainWhyV1;
|
|
208
|
+
heldAttempt?: string;
|
|
209
|
+
} | {
|
|
210
|
+
do: 'surface-question';
|
|
211
|
+
} | {
|
|
212
|
+
do: 'fail';
|
|
213
|
+
};
|
|
214
|
+
/**
|
|
215
|
+
* One runner's attempt at one step. Total: an event that does not apply to the state changes nothing and asks for nothing
|
|
216
|
+
* (a duplicated or reordered delivery is inert — in particular it never yields a second `invoke`).
|
|
217
|
+
*/
|
|
218
|
+
export declare function attemptTransition(state: AttemptStateV1, event: AttemptEventV1, ctx: AttemptContextV1): {
|
|
219
|
+
state: AttemptStateV1;
|
|
220
|
+
effects: AttemptEffectV1[];
|
|
221
|
+
};
|
|
222
|
+
/** I2 — the event that resolves each non-terminal attempt state, in words a host can show. */
|
|
223
|
+
export declare function wayForward(state: AttemptStateV1): string | null;
|
|
224
|
+
/** The fence a checkpoint carries: ONE counter that moves by exactly one with every write of the run — the claim a resume
|
|
225
|
+
* makes before it runs anything, and each park after it. A checkpoint's CONTENTS (what completed, what must still be
|
|
226
|
+
* unwound, the taint, the outstanding prompt and its binding) are whatever the write at that generation said; because
|
|
227
|
+
* every accepted write is the immediate successor of the stored one, contents never go back to an older version. */
|
|
228
|
+
export interface CheckpointFenceV1 {
|
|
229
|
+
generation?: number;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* May `incoming` be written over `stored`? (I4)
|
|
233
|
+
* • a FENCED write (one that names a generation) is refused once the run is `finished` (it has a TERMINAL record).
|
|
234
|
+
* • over nothing, a fenced write is accepted only as a run's first (generation 1).
|
|
235
|
+
* • over a stored checkpoint, only its IMMEDIATE SUCCESSOR is accepted (generation = stored + 1). A write at the stored
|
|
236
|
+
* generation or below is a duplicate, a redelivery or a turn that was overtaken — refused, whatever it contains: a
|
|
237
|
+
* redelivered claim can never put back the completed-step list the park after it replaced. Of two turns that
|
|
238
|
+
* loaded the same generation, one writes the successor and the other does not.
|
|
239
|
+
* • a write that names no generation is not a turn's (a host creating its own row): accepted as before, not fenced.
|
|
240
|
+
*/
|
|
241
|
+
export declare function checkpointWrite(stored: CheckpointFenceV1 | null | undefined, incoming: CheckpointFenceV1, finished?: boolean): 'accept' | 'superseded';
|
|
242
|
+
/** May the turn whose last write was `mine` finish the run (write its terminal record, drop its checkpoint)? Only while
|
|
243
|
+
* that write is still the stored one. A turn with no fence finished a run that never parked: no checkpoint to hold. */
|
|
244
|
+
export declare function checkpointFinish(stored: CheckpointFenceV1 | null | undefined, mine: CheckpointFenceV1 | null | undefined): 'accept' | 'superseded';
|
|
245
|
+
/** What a run record says about its run. Only a TERMINAL record is final: a `completed`, `failed` or `denied` outcome, or
|
|
246
|
+
* a cancel mark. A record of a run that is parked (`suspended`, `authority-required` — written when a park is exported)
|
|
247
|
+
* says where the run stood; the run goes on. */
|
|
248
|
+
export declare function recordKind(record: {
|
|
249
|
+
outcome?: unknown;
|
|
250
|
+
canceled?: unknown;
|
|
251
|
+
} | null | undefined): 'none' | 'parked' | 'terminal';
|
|
252
|
+
/**
|
|
253
|
+
* May `incoming` replace the stored record? A terminal record is FINAL: a parked record (a late export of an earlier
|
|
254
|
+
* park) never replaces it, and neither does a terminal record with another outcome. The same terminal record written
|
|
255
|
+
* again (with its export report, with a cancel mark) is accepted. Over a parked record, or nothing, anything is.
|
|
256
|
+
*/
|
|
257
|
+
export declare function recordWrite(stored: {
|
|
258
|
+
outcome?: unknown;
|
|
259
|
+
canceled?: unknown;
|
|
260
|
+
} | null | undefined, incoming: {
|
|
261
|
+
outcome?: unknown;
|
|
262
|
+
canceled?: unknown;
|
|
263
|
+
}): 'accept' | 'final';
|
|
264
|
+
/** What a parked run recorded about the prompt only the principal answers: its kind, its step and what it is bound to
|
|
265
|
+
* (an outbound confirmation's disclosure digest; an effect-uncertain prompt's `uncertainty`). */
|
|
266
|
+
export interface AwaitedPromptV1 {
|
|
267
|
+
kind: string;
|
|
268
|
+
stepRef: string;
|
|
269
|
+
digest?: string;
|
|
270
|
+
}
|
|
271
|
+
/** What an answer says it answers: `answers`, or — the outbound confirmation's established shape — `data.disclosure`. */
|
|
272
|
+
export declare function answerBinding(answer: {
|
|
273
|
+
answers?: unknown;
|
|
274
|
+
data?: Record<string, unknown> | undefined;
|
|
275
|
+
}): string | undefined;
|
|
276
|
+
/**
|
|
277
|
+
* Is an answer the host admitted on an earlier turn still kept? An answer that CARRIES its binding where its consumer
|
|
278
|
+
* checks it — an `effect` answer (the loop compares `answers` with the uncertainty), a confirmation with
|
|
279
|
+
* `data.disclosure` (the gate compares the disclosure) — stays the answer to that one prompt for the life of the run:
|
|
280
|
+
* a later park on ANOTHER prompt of the same step does not discard it, so a step with two confirmations converges, each
|
|
281
|
+
* answered once. A bare `confirmed` (bound only by the host, to the digest of the prompt shown) is kept only while the run
|
|
282
|
+
* still waits on that prompt.
|
|
283
|
+
*/
|
|
284
|
+
export declare function answerKeeps(awaiting: AwaitedPromptV1 | null | undefined, answer: {
|
|
285
|
+
stepRef: string;
|
|
286
|
+
confirmed?: boolean;
|
|
287
|
+
effect?: string;
|
|
288
|
+
answers?: unknown;
|
|
289
|
+
data?: Record<string, unknown> | undefined;
|
|
290
|
+
}): boolean;
|
|
291
|
+
/**
|
|
292
|
+
* Is this `confirmed` / `effect` answer the answer to the prompt the run is parked on? Only when the run waits on such a
|
|
293
|
+
* prompt, for that step, the answer names the digest that prompt was bound to, and the host verified the voice. A prompt
|
|
294
|
+
* recorded with no digest (a row written before prompts were bound) accepts nothing: the run asks again, bound.
|
|
295
|
+
*/
|
|
296
|
+
export declare function answerBinds(awaiting: AwaitedPromptV1 | null | undefined, answer: {
|
|
297
|
+
stepRef: string;
|
|
298
|
+
confirmed?: boolean;
|
|
299
|
+
effect?: string;
|
|
300
|
+
answers?: unknown;
|
|
301
|
+
data?: Record<string, unknown> | undefined;
|
|
302
|
+
}, voice: boolean): boolean;
|
|
303
|
+
//# sourceMappingURL=step-lifecycle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"step-lifecycle.d.ts","sourceRoot":"","sources":["../src/step-lifecycle.ts"],"names":[],"mappings":"AA2BA,6FAA6F;AAC7F,MAAM,MAAM,WAAW,GACnB;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE;AACpB;oHACoH;GAClH;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GAC5F;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAEvB,MAAM,MAAM,QAAQ,GAChB;IAAE,EAAE,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GACzF;IAAE,EAAE,EAAE,UAAU,CAAA;CAAE,GAClB;IAAE,EAAE,EAAE,SAAS,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAEvC,uFAAuF;AACvF,MAAM,MAAM,YAAY;AACtB;4FAC4F;AAC1F;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GAClC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAC;IAAC,WAAW,CAAC,EA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ONE state machine (design: `docs/step-lifecycle.md`).
|
|
2
|
+
//
|
|
3
|
+
// Everything that decides whether an effect may be invoked, recorded, released, handed over, parked or unwound lives
|
|
4
|
+
// here, as pure functions: (state, event) → (state, effects). The loop (forward steps and compensations), the mandate
|
|
5
|
+
// verifier's use ledger, the service host's run store and the hand-off path are INTERPRETERS of these functions — they
|
|
6
|
+
// perform the effects and feed back what happened; none of them carries a rule of its own.
|
|
7
|
+
//
|
|
8
|
+
// Three machines, one per place where state is durable:
|
|
9
|
+
//
|
|
10
|
+
// slotTransition the use ledger's slot for one signed step identity free → held(attempt) → done
|
|
11
|
+
// attemptTransition one runner's attempt to perform that step idle → acting | resolving → recorded | parked | …
|
|
12
|
+
// checkpointWrite the run's checkpoint in the host's store a fenced, strictly successive sequence of writes
|
|
13
|
+
// recordWrite the run's record a terminal record is final
|
|
14
|
+
//
|
|
15
|
+
// and one rule shared by the loop and the host: `answerBinds` — an answer is the answer to ONE prompt.
|
|
16
|
+
//
|
|
17
|
+
// The invariants these functions hold (the model test `step-lifecycle.model.test.ts` explores interleavings against them):
|
|
18
|
+
// I1 an effect is invoked at most once per signed step identity, unless the tool dedups by key AND a bound reader's
|
|
19
|
+
// fresh read says absent (once, under the SAME operation id), or the principal answered THIS uncertainty `absent`.
|
|
20
|
+
// I2 no step is held with no way forward: every non-terminal state names the event that resolves it.
|
|
21
|
+
// I3 a compensated step is never recorded completed; what must be unwound is durable run state, not a turn's.
|
|
22
|
+
// I4 a finished run is terminal: no later write reopens it.
|
|
23
|
+
// I5 a hand-off executes the parent's step under the parent's slot: parent and specialist never both perform it.
|
|
24
|
+
// I6 a confirmation or an uncertainty answer is valid only for the prompt it answers, from a verified voice, once.
|
|
25
|
+
/**
|
|
26
|
+
* The slot's compare-and-set. A durable ledger applies exactly this, atomically per slot.
|
|
27
|
+
* begin free ⇒ held by this attempt (`begun`). held ⇒ `held` (naming the holder) unless `retryOf` names the attempt
|
|
28
|
+
* that holds it: then the step is handed to this attempt, marked `retried` (`begun`). done ⇒ `done`.
|
|
29
|
+
* Asked again by the attempt that already holds it ⇒ `begun` again, nothing changed (a lost acknowledgement).
|
|
30
|
+
* complete ⇒ done, whoever asks: the effect exists is a fact about the step.
|
|
31
|
+
* release frees ONLY the named attempt, and only a first attempt: a retried attempt followed one that may have acted.
|
|
32
|
+
*/
|
|
33
|
+
export function slotTransition(slot, op) {
|
|
34
|
+
switch (op.op) {
|
|
35
|
+
case 'begin': {
|
|
36
|
+
if (slot.status === 'done')
|
|
37
|
+
return { slot, answer: { status: 'done' } };
|
|
38
|
+
const mine = (retried, operationId) => ({
|
|
39
|
+
status: 'held', attempt: op.attempt, retried,
|
|
40
|
+
...(operationId !== undefined ? { operationId } : {}), ...(op.holder !== undefined ? { holder: op.holder } : {}),
|
|
41
|
+
});
|
|
42
|
+
if (slot.status === 'free')
|
|
43
|
+
return { slot: mine(false, op.operationId), answer: { status: 'begun' } };
|
|
44
|
+
// The SAME attempt asking again (its first answer was lost on the way back): it holds the slot, and is told so.
|
|
45
|
+
// Idempotent — nothing changes, and no other attempt can name this token.
|
|
46
|
+
if (slot.attempt === op.attempt)
|
|
47
|
+
return { slot, answer: { status: 'begun' } };
|
|
48
|
+
if (op.retryOf !== undefined && op.retryOf === slot.attempt)
|
|
49
|
+
return { slot: mine(true, op.operationId ?? slot.operationId), answer: { status: 'begun' } };
|
|
50
|
+
return { slot, answer: { status: 'held', attempt: slot.attempt, retried: slot.retried, ...(slot.operationId !== undefined ? { operationId: slot.operationId } : {}), ...(slot.holder !== undefined ? { holder: slot.holder } : {}) } };
|
|
51
|
+
}
|
|
52
|
+
case 'complete':
|
|
53
|
+
return { slot: { status: 'done' } };
|
|
54
|
+
case 'release':
|
|
55
|
+
return slot.status === 'held' && !slot.retried && slot.attempt === op.attempt ? { slot: { status: 'free' } } : { slot };
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
const settled = (s) => s.phase === 'recorded' || s.phase === 'released' || s.phase === 'failed' || s.phase === 'parked';
|
|
59
|
+
/**
|
|
60
|
+
* One runner's attempt at one step. Total: an event that does not apply to the state changes nothing and asks for nothing
|
|
61
|
+
* (a duplicated or reordered delivery is inert — in particular it never yields a second `invoke`).
|
|
62
|
+
*/
|
|
63
|
+
export function attemptTransition(state, event, ctx) {
|
|
64
|
+
const stay = { state, effects: [] };
|
|
65
|
+
if (settled(state))
|
|
66
|
+
return stay;
|
|
67
|
+
/** The effect exists: tell the slot (when one holds this step), then record. */
|
|
68
|
+
const settle = (by, counted) => (counted ? { state: { phase: 'completing', by }, effects: [{ do: 'complete' }] } : { state: { phase: 'recorded', by }, effects: [{ do: 'record', by }] });
|
|
69
|
+
const park = (ledger, why, heldAttempt) => ({
|
|
70
|
+
state: { phase: 'parked', ledger, why, ...(heldAttempt !== undefined ? { heldAttempt } : {}) },
|
|
71
|
+
effects: [{ do: 'park', ledger, why, ...(heldAttempt !== undefined ? { heldAttempt } : {}) }],
|
|
72
|
+
});
|
|
73
|
+
switch (event.type) {
|
|
74
|
+
case 'slot-answered': {
|
|
75
|
+
if (state.phase === 'idle' && event.to === 'begin') {
|
|
76
|
+
if (event.answer.status === 'begun')
|
|
77
|
+
return { state: { phase: 'acting', retry: false, operationId: ctx.operationId, counted: ctx.counted && event.answer.slot !== 'none' }, effects: [{ do: 'invoke', operationId: ctx.operationId }] };
|
|
78
|
+
return { state: { phase: 'resolving', slot: event.answer }, effects: [{ do: 'gather-evidence', ...(event.answer.status === 'held' ? { about: event.answer.attempt } : {}) }] };
|
|
79
|
+
}
|
|
80
|
+
if (state.phase === 'handing-over' && event.to === 'hand-over') {
|
|
81
|
+
if (event.answer.status === 'begun')
|
|
82
|
+
return { state: { phase: 'acting', retry: true, operationId: state.operationId, counted: true }, effects: [{ do: 'invoke', operationId: state.operationId }] };
|
|
83
|
+
// Another attempt took the step between the read and the hand-over: it is theirs.
|
|
84
|
+
return park(event.answer.status === 'done' ? 'done' : 'held', 'lost-handover', event.answer.status === 'held' ? event.answer.attempt : undefined);
|
|
85
|
+
}
|
|
86
|
+
return stay;
|
|
87
|
+
}
|
|
88
|
+
case 'slot-unanswered': {
|
|
89
|
+
// The begin may have been stored under this attempt's token, and nothing was performed. Never a failure that ends
|
|
90
|
+
// the run holding the slot: a park, bound to that attempt, which the next runner's read of the slot settles.
|
|
91
|
+
if (state.phase === 'idle' && event.to === 'begin')
|
|
92
|
+
return park('held', 'ledger-unanswered', ctx.attempt);
|
|
93
|
+
if (state.phase === 'handing-over' && event.to === 'hand-over')
|
|
94
|
+
return park('held', 'lost-handover', state.from);
|
|
95
|
+
return stay;
|
|
96
|
+
}
|
|
97
|
+
case 'released':
|
|
98
|
+
case 'release-failed': {
|
|
99
|
+
if (state.phase !== 'releasing')
|
|
100
|
+
return stay;
|
|
101
|
+
if (state.question)
|
|
102
|
+
return { state: { phase: 'released', because: 'question' }, effects: [{ do: 'surface-question' }] };
|
|
103
|
+
if (event.type === 'released')
|
|
104
|
+
return { state: { phase: 'released', because: 'not-performed' }, effects: [{ do: 'fail' }] };
|
|
105
|
+
// The tool did not run, but the slot still names this attempt: the run does not end on it.
|
|
106
|
+
return park('held', 'release-failed', ctx.attempt);
|
|
107
|
+
}
|
|
108
|
+
case 'completed':
|
|
109
|
+
case 'complete-failed': {
|
|
110
|
+
if (state.phase !== 'completing')
|
|
111
|
+
return stay;
|
|
112
|
+
const unwritten = event.type === 'complete-failed' ? { ledgerUnwritten: true } : {};
|
|
113
|
+
return { state: { phase: 'recorded', by: state.by, ...unwritten }, effects: [{ do: 'record', by: state.by, ...unwritten }] };
|
|
114
|
+
}
|
|
115
|
+
case 'evidence': {
|
|
116
|
+
// A reader that finds the effect BEFORE any attempt began (the pre-act read): recorded, nothing is invoked.
|
|
117
|
+
if (state.phase === 'idle' && event.reader === 'present')
|
|
118
|
+
return settle('reader', ctx.counted);
|
|
119
|
+
if (state.phase !== 'resolving')
|
|
120
|
+
return stay;
|
|
121
|
+
const slot = state.slot;
|
|
122
|
+
// Is this evidence about the slot as this runner knows it? (A redelivered or stale event names another attempt.)
|
|
123
|
+
const current = slot.status === 'done' ? event.readAbout === undefined : event.readAbout === slot.attempt;
|
|
124
|
+
const said = current && event.principal && event.principal.answers === event.uncertainty ? event.principal.effect : undefined;
|
|
125
|
+
// The effect exists: a reader found it, or the principal answered this uncertainty. Recorded, never performed again.
|
|
126
|
+
if (event.reader === 'present')
|
|
127
|
+
return settle('reader', true);
|
|
128
|
+
if (said === 'present')
|
|
129
|
+
return settle('principal', true);
|
|
130
|
+
if (slot.status === 'done')
|
|
131
|
+
return park('done', 'ledger-done-no-result');
|
|
132
|
+
// The slot is held. Two ways past it, and only two.
|
|
133
|
+
const heldKey = slot.operationId;
|
|
134
|
+
// (A runner that already took the step over hands nothing over again: the next uncertainty is a new prompt.)
|
|
135
|
+
if (state.spent)
|
|
136
|
+
return park('held', said === 'absent' ? 'already-retried' : event.reader === 'no-reader' ? 'no-reader' : event.reader === 'unknown' ? 'reader-unknown' : 'already-retried', slot.attempt);
|
|
137
|
+
// (a) the principal said THIS uncertainty's effect does not exist: performed once more, under the held attempt's
|
|
138
|
+
// own key when the ledger knows it (so a late first attempt and this one are one operation downstream).
|
|
139
|
+
if (said === 'absent')
|
|
140
|
+
return { state: { phase: 'handing-over', from: slot.attempt, operationId: heldKey ?? ctx.operationId }, effects: [{ do: 'hand-over', retryOf: slot.attempt, as: ctx.retryAttempt, operationId: heldKey ?? ctx.operationId }] };
|
|
141
|
+
// (b) a bound reader, asked about THIS held attempt, says absent — and the tool dedups by key, the one hand-over
|
|
142
|
+
// was not used, and this runner would give the downstream the SAME key the held attempt gave it.
|
|
143
|
+
if (event.reader === 'no-reader')
|
|
144
|
+
return park('held', 'no-reader', slot.attempt);
|
|
145
|
+
if (event.reader === 'unknown')
|
|
146
|
+
return park('held', 'reader-unknown', slot.attempt);
|
|
147
|
+
if (event.readAbout !== slot.attempt)
|
|
148
|
+
return park('held', 'stale-read', slot.attempt);
|
|
149
|
+
if (!ctx.idempotentByKey)
|
|
150
|
+
return park('held', 'not-idempotent', slot.attempt);
|
|
151
|
+
if (slot.retried)
|
|
152
|
+
return park('held', 'already-retried', slot.attempt);
|
|
153
|
+
if (heldKey === undefined || heldKey !== ctx.operationId)
|
|
154
|
+
return park('held', 'other-operation-id', slot.attempt);
|
|
155
|
+
return { state: { phase: 'handing-over', from: slot.attempt, operationId: ctx.operationId }, effects: [{ do: 'hand-over', retryOf: slot.attempt, as: ctx.retryAttempt, operationId: ctx.operationId }] };
|
|
156
|
+
}
|
|
157
|
+
case 'returned': {
|
|
158
|
+
if (state.phase !== 'acting' || event.retry !== state.retry)
|
|
159
|
+
return stay;
|
|
160
|
+
return settle('tool', state.counted);
|
|
161
|
+
}
|
|
162
|
+
case 'not-performed': {
|
|
163
|
+
if (state.phase !== 'acting' || event.retry !== state.retry)
|
|
164
|
+
return stay;
|
|
165
|
+
if (!state.counted)
|
|
166
|
+
return event.question ? { state: { phase: 'released', because: 'question' }, effects: [{ do: 'surface-question' }] } : { state: { phase: 'failed' }, effects: [{ do: 'fail' }] };
|
|
167
|
+
// A first attempt that performed nothing frees the slot. A retry followed an attempt that may have acted: the slot
|
|
168
|
+
// stays held (the ledger would not free it), a question is still asked, and anything else is uncertain — never a
|
|
169
|
+
// failure that ends the run with the step held.
|
|
170
|
+
if (!state.retry)
|
|
171
|
+
return { state: { phase: 'releasing', question: event.question }, effects: [{ do: 'release' }] };
|
|
172
|
+
if (event.question)
|
|
173
|
+
return { state: { phase: 'released', because: 'question' }, effects: [{ do: 'surface-question' }] };
|
|
174
|
+
return park('held', 'retry-not-performed', ctx.retryAttempt);
|
|
175
|
+
}
|
|
176
|
+
case 'threw': {
|
|
177
|
+
if (state.phase !== 'acting' || event.retry !== state.retry)
|
|
178
|
+
return stay;
|
|
179
|
+
// A step no slot holds here (uncounted, or counted elsewhere — on chain, by the venue): a plain failure. Nothing
|
|
180
|
+
// in this machine ever re-invokes it, and no prompt is raised that an answer could turn into an invocation.
|
|
181
|
+
if (!state.counted)
|
|
182
|
+
return { state: { phase: 'failed' }, effects: [{ do: 'fail' }] };
|
|
183
|
+
// The response is lost and the effect may exist. The slot is held by THIS attempt: resolved like any held slot.
|
|
184
|
+
const holding = state.retry ? ctx.retryAttempt : ctx.attempt;
|
|
185
|
+
return { state: { phase: 'resolving', slot: { status: 'held', attempt: holding, retried: state.retry, operationId: state.operationId }, ...(state.retry ? { spent: true } : {}) }, effects: [{ do: 'gather-evidence', about: holding }] };
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
/** I2 — the event that resolves each non-terminal attempt state, in words a host can show. */
|
|
190
|
+
export function wayForward(state) {
|
|
191
|
+
switch (state.phase) {
|
|
192
|
+
case 'idle': return 'the slot answers begin';
|
|
193
|
+
case 'releasing': return 'the slot acknowledges the release, or does not';
|
|
194
|
+
case 'completing': return 'the slot acknowledges the completion, or does not';
|
|
195
|
+
case 'acting': return 'the tool returns, says it did not run, or throws';
|
|
196
|
+
case 'resolving': return 'a bound reader or the principal says whether the effect exists';
|
|
197
|
+
case 'handing-over': return 'the slot answers the hand-over';
|
|
198
|
+
case 'parked': return state.ledger === 'done' ? 'the principal answers the effect-uncertain prompt: present' : 'the principal answers the effect-uncertain prompt: present or absent';
|
|
199
|
+
case 'released': return state.because === 'question' ? 'the person answers the question; the next attempt begins' : null;
|
|
200
|
+
case 'recorded':
|
|
201
|
+
case 'failed': return null;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* May `incoming` be written over `stored`? (I4)
|
|
206
|
+
* • a FENCED write (one that names a generation) is refused once the run is `finished` (it has a TERMINAL record).
|
|
207
|
+
* • over nothing, a fenced write is accepted only as a run's first (generation 1).
|
|
208
|
+
* • over a stored checkpoint, only its IMMEDIATE SUCCESSOR is accepted (generation = stored + 1). A write at the stored
|
|
209
|
+
* generation or below is a duplicate, a redelivery or a turn that was overtaken — refused, whatever it contains: a
|
|
210
|
+
* redelivered claim can never put back the completed-step list the park after it replaced. Of two turns that
|
|
211
|
+
* loaded the same generation, one writes the successor and the other does not.
|
|
212
|
+
* • a write that names no generation is not a turn's (a host creating its own row): accepted as before, not fenced.
|
|
213
|
+
*/
|
|
214
|
+
export function checkpointWrite(stored, incoming, finished = false) {
|
|
215
|
+
if (incoming.generation === undefined)
|
|
216
|
+
return 'accept';
|
|
217
|
+
if (finished)
|
|
218
|
+
return 'superseded';
|
|
219
|
+
if (!stored)
|
|
220
|
+
return incoming.generation === 1 ? 'accept' : 'superseded';
|
|
221
|
+
return incoming.generation === (stored.generation ?? 0) + 1 ? 'accept' : 'superseded';
|
|
222
|
+
}
|
|
223
|
+
/** May the turn whose last write was `mine` finish the run (write its terminal record, drop its checkpoint)? Only while
|
|
224
|
+
* that write is still the stored one. A turn with no fence finished a run that never parked: no checkpoint to hold. */
|
|
225
|
+
export function checkpointFinish(stored, mine) {
|
|
226
|
+
if (!mine || mine.generation === undefined)
|
|
227
|
+
return 'accept';
|
|
228
|
+
if (!stored)
|
|
229
|
+
return 'superseded';
|
|
230
|
+
return (stored.generation ?? 0) === mine.generation ? 'accept' : 'superseded';
|
|
231
|
+
}
|
|
232
|
+
/** What a run record says about its run. Only a TERMINAL record is final: a `completed`, `failed` or `denied` outcome, or
|
|
233
|
+
* a cancel mark. A record of a run that is parked (`suspended`, `authority-required` — written when a park is exported)
|
|
234
|
+
* says where the run stood; the run goes on. */
|
|
235
|
+
export function recordKind(record) {
|
|
236
|
+
if (!record)
|
|
237
|
+
return 'none';
|
|
238
|
+
if (record.canceled)
|
|
239
|
+
return 'terminal';
|
|
240
|
+
return record.outcome === 'completed' || record.outcome === 'failed' || record.outcome === 'denied' ? 'terminal' : 'parked';
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* May `incoming` replace the stored record? A terminal record is FINAL: a parked record (a late export of an earlier
|
|
244
|
+
* park) never replaces it, and neither does a terminal record with another outcome. The same terminal record written
|
|
245
|
+
* again (with its export report, with a cancel mark) is accepted. Over a parked record, or nothing, anything is.
|
|
246
|
+
*/
|
|
247
|
+
export function recordWrite(stored, incoming) {
|
|
248
|
+
if (recordKind(stored) !== 'terminal')
|
|
249
|
+
return 'accept';
|
|
250
|
+
// A canceled run's record keeps its cancel mark whatever is written after (spec 398 §5.3 — the store carries the mark
|
|
251
|
+
// over); the run is finished either way.
|
|
252
|
+
if (stored.canceled)
|
|
253
|
+
return 'accept';
|
|
254
|
+
if (recordKind(incoming) !== 'terminal')
|
|
255
|
+
return 'final';
|
|
256
|
+
return stored.outcome === incoming.outcome ? 'accept' : 'final';
|
|
257
|
+
}
|
|
258
|
+
/** What an answer says it answers: `answers`, or — the outbound confirmation's established shape — `data.disclosure`. */
|
|
259
|
+
export function answerBinding(answer) {
|
|
260
|
+
const a = typeof answer.answers === 'string' && answer.answers ? answer.answers : undefined;
|
|
261
|
+
const d = typeof answer.data?.disclosure === 'string' && answer.data.disclosure ? answer.data.disclosure : undefined;
|
|
262
|
+
// ONE binding. An answer that names two different prompts names none: admission and the gate that dispatches read the
|
|
263
|
+
// same value, so they can never each validate a different disclosure.
|
|
264
|
+
if (a !== undefined && d !== undefined && a !== d)
|
|
265
|
+
return undefined;
|
|
266
|
+
return a ?? d;
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Is an answer the host admitted on an earlier turn still kept? An answer that CARRIES its binding where its consumer
|
|
270
|
+
* checks it — an `effect` answer (the loop compares `answers` with the uncertainty), a confirmation with
|
|
271
|
+
* `data.disclosure` (the gate compares the disclosure) — stays the answer to that one prompt for the life of the run:
|
|
272
|
+
* a later park on ANOTHER prompt of the same step does not discard it, so a step with two confirmations converges, each
|
|
273
|
+
* answered once. A bare `confirmed` (bound only by the host, to the digest of the prompt shown) is kept only while the run
|
|
274
|
+
* still waits on that prompt.
|
|
275
|
+
*/
|
|
276
|
+
export function answerKeeps(awaiting, answer) {
|
|
277
|
+
if (answer.confirmed === undefined && answer.effect === undefined)
|
|
278
|
+
return true;
|
|
279
|
+
const binding = answerBinding(answer);
|
|
280
|
+
if (binding === undefined)
|
|
281
|
+
return false;
|
|
282
|
+
if (answer.effect !== undefined)
|
|
283
|
+
return true;
|
|
284
|
+
if (typeof answer.data?.disclosure === 'string' && answer.data.disclosure === binding)
|
|
285
|
+
return true;
|
|
286
|
+
return answerBinds(awaiting, answer, true);
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Is this `confirmed` / `effect` answer the answer to the prompt the run is parked on? Only when the run waits on such a
|
|
290
|
+
* prompt, for that step, the answer names the digest that prompt was bound to, and the host verified the voice. A prompt
|
|
291
|
+
* recorded with no digest (a row written before prompts were bound) accepts nothing: the run asks again, bound.
|
|
292
|
+
*/
|
|
293
|
+
export function answerBinds(awaiting, answer, voice) {
|
|
294
|
+
if (!voice || !awaiting)
|
|
295
|
+
return false;
|
|
296
|
+
if (awaiting.kind !== 'confirmation' && awaiting.kind !== 'effect-uncertain')
|
|
297
|
+
return false;
|
|
298
|
+
if ((awaiting.kind === 'confirmation') !== (answer.confirmed !== undefined) || (awaiting.kind === 'effect-uncertain') !== (answer.effect !== undefined))
|
|
299
|
+
return false;
|
|
300
|
+
if (answer.stepRef !== awaiting.stepRef)
|
|
301
|
+
return false;
|
|
302
|
+
return typeof awaiting.digest === 'string' && awaiting.digest !== '' && answerBinding(answer) === awaiting.digest;
|
|
303
|
+
}
|
|
304
|
+
//# sourceMappingURL=step-lifecycle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"step-lifecycle.js","sourceRoot":"","sources":["../src/step-lifecycle.ts"],"names":[],"mappings":"AAAA,iGAAiG;AACjG,EAAE;AACF,qHAAqH;AACrH,sHAAsH;AACtH,uHAAuH;AACvH,2FAA2F;AAC3F,EAAE;AACF,wDAAwD;AACxD,EAAE;AACF,2GAA2G;AAC3G,iIAAiI;AACjI,gIAAgI;AAChI,0GAA0G;AAC1G,EAAE;AACF,uGAAuG;AACvG,EAAE;AACF,2HAA2H;AAC3H,uHAAuH;AACvH,yHAAyH;AACzH,w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