@nodetool-ai/execution-core 0.0.0-stage → 0.8.9-bootstrap.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.
Files changed (103) hide show
  1. package/README.md +5 -2
  2. package/dist/.nodetool-build-stamp +1 -0
  3. package/dist/actor.d.ts +480 -0
  4. package/dist/actor.d.ts.map +1 -0
  5. package/dist/actor.js +1912 -0
  6. package/dist/actor.js.map +1 -0
  7. package/dist/async-local-storage.d.ts +20 -0
  8. package/dist/async-local-storage.d.ts.map +1 -0
  9. package/dist/async-local-storage.js +28 -0
  10. package/dist/async-local-storage.js.map +1 -0
  11. package/dist/content-filter.d.ts +46 -0
  12. package/dist/content-filter.d.ts.map +1 -0
  13. package/dist/content-filter.js +92 -0
  14. package/dist/content-filter.js.map +1 -0
  15. package/dist/correlation-analysis.d.ts +104 -0
  16. package/dist/correlation-analysis.d.ts.map +1 -0
  17. package/dist/correlation-analysis.js +846 -0
  18. package/dist/correlation-analysis.js.map +1 -0
  19. package/dist/durable-inbox.d.ts +91 -0
  20. package/dist/durable-inbox.d.ts.map +1 -0
  21. package/dist/durable-inbox.js +211 -0
  22. package/dist/durable-inbox.js.map +1 -0
  23. package/dist/dynamic-slots.d.ts +73 -0
  24. package/dist/dynamic-slots.d.ts.map +1 -0
  25. package/dist/dynamic-slots.js +192 -0
  26. package/dist/dynamic-slots.js.map +1 -0
  27. package/dist/edge-ids.d.ts +11 -0
  28. package/dist/edge-ids.d.ts.map +1 -0
  29. package/dist/edge-ids.js +15 -0
  30. package/dist/edge-ids.js.map +1 -0
  31. package/dist/graph-utils.d.ts +72 -0
  32. package/dist/graph-utils.d.ts.map +1 -0
  33. package/dist/graph-utils.js +284 -0
  34. package/dist/graph-utils.js.map +1 -0
  35. package/dist/graph.d.ts +204 -0
  36. package/dist/graph.d.ts.map +1 -0
  37. package/dist/graph.js +868 -0
  38. package/dist/graph.js.map +1 -0
  39. package/dist/inbox.d.ts +265 -0
  40. package/dist/inbox.d.ts.map +1 -0
  41. package/dist/inbox.js +552 -0
  42. package/dist/inbox.js.map +1 -0
  43. package/dist/index.d.ts +21 -0
  44. package/dist/index.d.ts.map +1 -0
  45. package/dist/index.js +20 -0
  46. package/dist/index.js.map +1 -0
  47. package/dist/invocation-account.d.ts +43 -0
  48. package/dist/invocation-account.d.ts.map +1 -0
  49. package/dist/invocation-account.js +60 -0
  50. package/dist/invocation-account.js.map +1 -0
  51. package/dist/io.d.ts +189 -0
  52. package/dist/io.d.ts.map +1 -0
  53. package/dist/io.js +239 -0
  54. package/dist/io.js.map +1 -0
  55. package/dist/loop.d.ts +36 -0
  56. package/dist/loop.d.ts.map +1 -0
  57. package/dist/loop.js +166 -0
  58. package/dist/loop.js.map +1 -0
  59. package/dist/message-stream.d.ts +32 -0
  60. package/dist/message-stream.d.ts.map +1 -0
  61. package/dist/message-stream.js +64 -0
  62. package/dist/message-stream.js.map +1 -0
  63. package/dist/node-executor.d.ts +167 -0
  64. package/dist/node-executor.d.ts.map +1 -0
  65. package/dist/node-executor.js +6 -0
  66. package/dist/node-executor.js.map +1 -0
  67. package/dist/predicates.d.ts +8 -0
  68. package/dist/predicates.d.ts.map +1 -0
  69. package/dist/predicates.js +8 -0
  70. package/dist/predicates.js.map +1 -0
  71. package/dist/recoverable-node-error.d.ts +31 -0
  72. package/dist/recoverable-node-error.d.ts.map +1 -0
  73. package/dist/recoverable-node-error.js +37 -0
  74. package/dist/recoverable-node-error.js.map +1 -0
  75. package/dist/run-state.d.ts +65 -0
  76. package/dist/run-state.d.ts.map +1 -0
  77. package/dist/run-state.js +42 -0
  78. package/dist/run-state.js.map +1 -0
  79. package/dist/runner.d.ts +524 -0
  80. package/dist/runner.d.ts.map +1 -0
  81. package/dist/runner.js +2127 -0
  82. package/dist/runner.js.map +1 -0
  83. package/dist/runtime-contract.d.ts +28 -0
  84. package/dist/runtime-contract.d.ts.map +1 -0
  85. package/dist/runtime-contract.js +20 -0
  86. package/dist/runtime-contract.js.map +1 -0
  87. package/dist/substitute-validator.d.ts +44 -0
  88. package/dist/substitute-validator.d.ts.map +1 -0
  89. package/dist/substitute-validator.js +169 -0
  90. package/dist/substitute-validator.js.map +1 -0
  91. package/dist/supervisor.d.ts +148 -0
  92. package/dist/supervisor.d.ts.map +1 -0
  93. package/dist/supervisor.js +287 -0
  94. package/dist/supervisor.js.map +1 -0
  95. package/dist/tracing.d.ts +13 -0
  96. package/dist/tracing.d.ts.map +1 -0
  97. package/dist/tracing.js +30 -0
  98. package/dist/tracing.js.map +1 -0
  99. package/dist/trigger-wakeup.d.ts +123 -0
  100. package/dist/trigger-wakeup.d.ts.map +1 -0
  101. package/dist/trigger-wakeup.js +221 -0
  102. package/dist/trigger-wakeup.js.map +1 -0
  103. package/package.json +159 -4
package/README.md CHANGED
@@ -1,3 +1,6 @@
1
- # Temporary Holding Version
1
+ # Execution core
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The workflow graph, actor and inbox implementation with a provider-independent
4
+ execution context. Tracing uses the OpenTelemetry API and selects no exporter.
5
+
6
+ Use `@nodetool-ai/nodes-core` to compose the audited text execution host.
@@ -0,0 +1 @@
1
+ 2026-10-30T19:33:30.702Z
@@ -0,0 +1,480 @@
1
+ /**
2
+ * NodeActor – per-node asynchronous execution.
3
+ *
4
+ * Port of src/nodetool/workflows/actor.py.
5
+ *
6
+ * Execution modes:
7
+ * 1. Buffered: gather all inputs, call process() once.
8
+ * 2. Streaming input: node drains inbox via iterInput / iterAny.
9
+ * 3. Streaming output: call genProcess() which yields items.
10
+ * 4. Controlled: accept control events, cache inputs for replay.
11
+ * 5. Loop: `nodetool.control.Loop`, run by `runLoop` (loop.ts).
12
+ *
13
+ * Sync modes:
14
+ * - on_any: fire when ANY input handle has data.
15
+ * - zip_all: wait until ALL handles have data (with sticky semantics).
16
+ */
17
+ import type { CorrelationLineage, NodeDescriptor, NodeErrorDetail, MissingPackDetails } from "@nodetool-ai/protocol";
18
+ import type { ProcessingContext, NodeExecutor } from "./runtime-contract.js";
19
+ import type { Intervention } from "@nodetool-ai/protocol";
20
+ import { type SupervisorHandle } from "./supervisor.js";
21
+ import { NodeInbox } from "./inbox.js";
22
+ import type { NodeAnalysis } from "./correlation-analysis.js";
23
+ /**
24
+ * Hints from the actor about how to route an invocation's outputs.
25
+ * See runner.ts for the consumer.
26
+ */
27
+ export interface OutputRoutingHints {
28
+ /** Reject this controlled invocation while keeping the actor available for later calls. */
29
+ controlError?: MissingPackDetails;
30
+ invocationLineage?: CorrelationLineage;
31
+ perSlotLineage?: Record<string, CorrelationLineage>;
32
+ /**
33
+ * Slots in this set are being dropped (lineage_done) for the given lineage,
34
+ * not emitted with a value. §5. The runner sends `signalLineageDone` to
35
+ * downstream inboxes instead of `put`.
36
+ */
37
+ lineageDoneSlots?: Set<string>;
38
+ /**
39
+ * A supervisor `skip` verdict: this invocation produced nothing. The runner
40
+ * sends `lineage_done` on every outgoing data edge at `invocationLineage`,
41
+ * *and* `lineage_scope_closed` for every child root the invocation would have
42
+ * opened — `drop()` alone signals only the former, which leaves an aggregate
43
+ * downstream waiting forever on a scope a skipped iterator never opened.
44
+ * Design §5.2.
45
+ */
46
+ skipInvocation?: boolean;
47
+ }
48
+ export type { NodeExecutor };
49
+ /**
50
+ * Canonical lineage keys join `root=index` pairs with `,`. To compute the
51
+ * parent key for a shorter scope, take the first `prefixLength` pairs.
52
+ */
53
+ export declare function trimKey(key: string, prefixLength: number): string;
54
+ /**
55
+ * Find every pending max-scope key in `maxBuckets` whose parent (trimmed to
56
+ * `parentLength`) equals `parentKey`. Used when a strict-prefix sticky
57
+ * arrival can unblock pending child firings.
58
+ */
59
+ export declare function enumerateCandidateKeysForParent(maxBuckets: ReadonlyMap<string, ReadonlyMap<string, ReadonlyArray<unknown>>>, _dataHandles: ReadonlyArray<string>, _handleClass: ReadonlyMap<string, "max" | "prefix" | "empty">, _handleScope: ReadonlyMap<string, ReadonlyArray<string>>, _maxLength: number, parentKey: string, parentLength: number): string[];
60
+ export declare function enumerateAllPendingKeys(maxBuckets: ReadonlyMap<string, ReadonlyMap<string, ReadonlyArray<unknown>>>): string[];
61
+ export interface ActorResult {
62
+ outputs: Record<string, unknown>;
63
+ error?: string;
64
+ errorDetail?: NodeErrorDetail;
65
+ }
66
+ export declare class NodeActor {
67
+ readonly node: NodeDescriptor;
68
+ readonly inbox: NodeInbox;
69
+ private _executor;
70
+ /** Cached inputs for controlled-node replay. */
71
+ private _cachedInputs;
72
+ /** Properties from the latest control event. */
73
+ private _currentControlProperties;
74
+ /** Latest execution result. */
75
+ private _latestResult;
76
+ /** Collected non-null outputs for streaming-output nodes. */
77
+ private _streamingCollectedOutputs;
78
+ /** Handles where multiple upstream values should be collected into a list. */
79
+ private _listInputHandles;
80
+ /** Callback to route outputs downstream. */
81
+ private _sendOutputs;
82
+ /**
83
+ * Lineage of the current invocation. Set when the actor consumes input(s)
84
+ * under the correlation flag and the inheritance case is unambiguous
85
+ * (single-edge single-input handle).
86
+ */
87
+ private _currentInvocationLineage;
88
+ /**
89
+ * A node fed by a streaming handle is invoked once per chunk, so logging
90
+ * every invocation at INFO buries the run: one Preview on an agent's chunk
91
+ * output produced 1112 of 1142 lines in a run whose plan, six tasks and
92
+ * twelve steps took 30. The first invocation is the informative one.
93
+ */
94
+ private _executionsLogged;
95
+ /**
96
+ * Most recent envelope consumed per handle during the current gather.
97
+ * Reset before each invocation. Used to compute invocation lineage when
98
+ * the correlation flag is on.
99
+ */
100
+ private _lastEnvelopes;
101
+ /** Callback to emit processing messages (NodeUpdate, etc.). */
102
+ private _emitMessage;
103
+ /** Optional execution context passed into node executors. */
104
+ private _executionContext;
105
+ /** Control context for controller nodes (injected as _control_context input). */
106
+ private _controlContext;
107
+ /**
108
+ * Static correlation analysis for this node, supplied by the runner.
109
+ */
110
+ private _correlation;
111
+ /**
112
+ * Per-iteration-root, per-parent-key counter for actor-minted iteration
113
+ * tokens. §2 — counters are scoped by `(root id, exact parent lineage)`
114
+ * and never reset for repeated invocations with the same parent key.
115
+ */
116
+ private _iterationCounters;
117
+ /**
118
+ * Run-level cancellation signal (aborted by `WorkflowRunner.cancel()`),
119
+ * exposed to node code via `NodeInputs.signal`. Defaults to a
120
+ * never-aborted signal for test fixtures.
121
+ */
122
+ private _cancelSignal;
123
+ /**
124
+ * Callback wired by the runner to signal early end-of-stream for a single
125
+ * output slot (`outputs.complete(slot)`). Marks the slot's downstream edges
126
+ * done immediately, rather than waiting for the actor to finish.
127
+ */
128
+ private _signalSlotEos;
129
+ /**
130
+ * Supervisor for this run, if any. Absent means no escalation is ever
131
+ * constructed and the actor behaves exactly as it did before — a clean run
132
+ * with no supervisor costs nothing, because nothing runs.
133
+ */
134
+ private _supervisor;
135
+ /** Records every escalation/verdict pair for `RunResult.interventions`. */
136
+ private _onIntervention;
137
+ constructor(opts: {
138
+ node: NodeDescriptor;
139
+ inbox: NodeInbox;
140
+ executor: NodeExecutor;
141
+ sendOutputs: (nodeId: string, outputs: Record<string, unknown>, hints?: OutputRoutingHints) => Promise<void>;
142
+ emitMessage: (msg: unknown) => void;
143
+ executionContext?: ProcessingContext;
144
+ listInputHandles?: Set<string>;
145
+ controlContext?: Record<string, unknown> | null;
146
+ correlation?: NodeAnalysis;
147
+ cancelSignal?: AbortSignal;
148
+ signalSlotEos?: (nodeId: string, slot: string) => void;
149
+ supervisor?: SupervisorHandle;
150
+ onIntervention?: (i: Intervention) => void;
151
+ });
152
+ /**
153
+ * Run the actor to completion.
154
+ * Returns the last outputs produced.
155
+ */
156
+ run(): Promise<ActorResult>;
157
+ private _runImpl;
158
+ /**
159
+ * Run the node in whichever of the four execution modes applies.
160
+ *
161
+ * Trigger entry comes first: when this run was started by a delivered
162
+ * trigger event targeting this node, the node does not listen — it emits the
163
+ * event payload on its declared outputs via emitTriggerEvent() and
164
+ * completes. Runs without a trigger event (user pressed Run in the editor)
165
+ * fall through to the normal modes below, preserving the in-editor
166
+ * live-test experience.
167
+ */
168
+ private _runExecutionMode;
169
+ /**
170
+ * Loop mode: the kernel owns iteration, feedback matching, and termination
171
+ * for `nodetool.control.Loop`; the node's process() is never called.
172
+ * docs/workflow-loops.md.
173
+ */
174
+ private _runLoopMode;
175
+ /**
176
+ * Trigger entry: emit the delivered event's payload on the declared output
177
+ * slots and complete. One committed result per trigger event (RFC §5 site
178
+ * parity with the streaming-input run() path).
179
+ */
180
+ private _runTriggerEntry;
181
+ /**
182
+ * Streaming input mode with run(): the node drains the inbox via NodeInputs
183
+ * and pushes outputs via NodeOutputs. Passing _lastEnvelopes as the tracker
184
+ * lets unmigrated filters that call inputs.stream()+outputs.emit() inherit
185
+ * lineage from the single-edge input automatically — matching the buffered
186
+ * rule.
187
+ */
188
+ private _runStreamingInputMode;
189
+ /**
190
+ * Routing hints for one `outputs.emit()` from a streaming-input node.
191
+ *
192
+ * An explicit lineage from the caller wins outright — they own the lineage
193
+ * shape (e.g. forward(), or a source seeding its own root). Otherwise the
194
+ * emit inherits the invocation lineage, and the slot's own
195
+ * `output_correlation` may override it for that one slot: an `aggregate`
196
+ * output collapses a root from the consumed lineage (the static analyzer
197
+ * drops it from the output scope; the runtime lineage must match), an
198
+ * `iteration` output mints a token per (group, parent_key) so
199
+ * `outputs.emit()` still attaches the new root. A slot declares one kind or
200
+ * the other, so at most one of the two applies.
201
+ */
202
+ private _streamingEmitHints;
203
+ /**
204
+ * Streaming-input node declared without a run() implementation: call
205
+ * process() once with the node's own property values, matching the defaults
206
+ * merge every other execution path applies. process() reads no inbox data,
207
+ * so any value queued on a connected data handle is dropped. Surface that
208
+ * instead of completing silently: the node is misdeclared (registry says
209
+ * is_streaming_input, implementation has no run()). Downgraded to a warning
210
+ * rather than a hard error because existing fixtures rely on the fallback
211
+ * firing with connected inputs.
212
+ */
213
+ private _runStreamingInputWithoutRun;
214
+ /**
215
+ * Project an envelope's lineage onto a static scope, returning the
216
+ * canonical key or `null` if the lineage is incomplete for the scope.
217
+ */
218
+ private _projectKey;
219
+ /**
220
+ * Mint the next token index for `rootId` under `parentKey` and remember it.
221
+ * Counters never reset within one workflow run, matching §2's rule that
222
+ * repeated invocations with the same parent key continue numbering instead
223
+ * of restarting at 0.
224
+ */
225
+ private _mintIterationToken;
226
+ /**
227
+ * Correlated buffered scheduler — replaces `_runBuffered` under
228
+ * correlation.
229
+ *
230
+ * Algorithm (v1 of §4):
231
+ * 1. Classify each connected data handle by its static scope:
232
+ * - max-scope: scope length == invocation scope length → bucket per key
233
+ * - strict-prefix sticky: shorter non-empty scope → sticky per projected
234
+ * parent key
235
+ * - empty: empty scope → single sticky entry
236
+ * 2. Find the repeating driver, if any: at most one max-scope handle may be
237
+ * `repeats_per_key`. Static validation already rejects more than one.
238
+ * 3. Pull envelopes via `iterAnyWithEnvelope`. On each arrival:
239
+ * - record into the right bucket,
240
+ * - re-evaluate the keys that could now be ready.
241
+ * 4. For each ready key, gather values and call `_executeWithInputs`.
242
+ *
243
+ * Source nodes (no connected data handles) fire once with empty inputs.
244
+ */
245
+ private _runCorrelated;
246
+ private _runCorrelatedImpl;
247
+ /**
248
+ * Under the correlated scheduler the invocation lineage is the projected
249
+ * lineage of the consumed max-scope envelopes, written canonically. PR 2's
250
+ * fallback (single non-list handle) still applies when the analyzer is not
251
+ * available.
252
+ */
253
+ private _correlatedInvocationLineage;
254
+ /**
255
+ * Build the per-slot lineage map for an emission. Single/forward/chunk
256
+ * outputs inherit the invocation lineage; iteration outputs mint a token
257
+ * per group per frame.
258
+ */
259
+ private _correlatedOutputLineage;
260
+ /**
261
+ * Coerce and check every input that has a declared dynamic slot on this
262
+ * node (`dynamic_inputs`). Slots without a declaration are untyped and
263
+ * pass through untouched. Throws on a value that cannot fit its declared
264
+ * type; the caller's catch turns that into a node error.
265
+ */
266
+ private _applyDynamicSlots;
267
+ /**
268
+ * Put the node's static list items after the connected items on the handles
269
+ * the executor names in `appendStaticInputs`. Every other edge input still
270
+ * replaces the node's own property value.
271
+ */
272
+ private _appendStaticItems;
273
+ /**
274
+ * Execute process or genProcess with the given inputs.
275
+ */
276
+ /**
277
+ * Run one invocation under the supervisor, if there is one.
278
+ *
279
+ * The catch wraps node execution and nothing else. `sendOutputs` routes to
280
+ * downstream inboxes sequentially, so if edge 1 delivered and edge 2 threw, a
281
+ * retry would duplicate edge 1's delivery — routing failures therefore fail
282
+ * the node without escalation. Design §5.1.
283
+ *
284
+ * Returns the outputs to route, or `SKIPPED` when the invocation was retired
285
+ * without emitting.
286
+ */
287
+ private _invokeWithRecovery;
288
+ /**
289
+ * Build the escalation, ask the supervisor, and enforce the allowed set
290
+ * against whatever comes back. The schema shown to an agent is UX; this check
291
+ * is the guarantee — a buggy or third-party handle returning `retry` for an
292
+ * unsafe node gets `fail`.
293
+ */
294
+ private _escalate;
295
+ /**
296
+ * Mint the escalation record. Redaction happens *here*, not at some later
297
+ * prompt: `Escalation` is public — it becomes a message, lands in
298
+ * `RunResult.interventions`, and crosses the websocket — so no unredacted
299
+ * instance may exist anywhere in the system. Design §6.1.
300
+ */
301
+ private _buildEscalation;
302
+ /**
303
+ * A repaired value is type-checked against the node's declared outputs
304
+ * before it enters the graph. An invalid repair is not a repair.
305
+ */
306
+ private _validateSubstitute;
307
+ /**
308
+ * Retire this invocation without emitting: `lineage_done` plus scope closure
309
+ * on every outgoing edge, so downstream joins move past the skipped key and
310
+ * aggregates see the scopes the invocation would have opened get closed.
311
+ */
312
+ private _skipInvocation;
313
+ /**
314
+ * Whether to drop this item instead of the run, after the provider's own
315
+ * bounded retries failed to get past its content filter. The built-in policy
316
+ * for an unsupervised run — a supervised one escalates instead, because
317
+ * putting an agent on the failure path is what `--supervise` is for.
318
+ *
319
+ * Veo filtered one shot of a five-shot trailer on an ordinary cinematic
320
+ * prompt. Failing the node there fails the run and discards the four shots
321
+ * already generated and paid for, which is worse than delivering a four-shot
322
+ * cut and saying which shot was refused.
323
+ *
324
+ * Only for an invocation that is one item of a fan-out: a non-empty
325
+ * correlation lineage says an upstream item keyed this invocation, so the
326
+ * siblings are real work a failure would throw away. A single-shot node has
327
+ * no siblings to protect and still fails loudly. An invocation that already
328
+ * emitted is out too — its partial output is downstream, so retiring the
329
+ * lineage now would tell joins nothing arrived.
330
+ */
331
+ private _degradeOnContentFilter;
332
+ private _executeWithInputs;
333
+ /**
334
+ * The streaming-output invocation, with its own recovery rules.
335
+ *
336
+ * Frames are routed inside the generator loop, so "retry" only means
337
+ * something before the first emit — after that the coherent choices are
338
+ * ending the stream (keeping what was produced) or failing. Design §5.4.
339
+ */
340
+ private _executeStreaming;
341
+ /**
342
+ * The streaming-input invocation. A `run()` node drains its own inbox and may
343
+ * have consumed messages long before it threw, across arbitrary lineages —
344
+ * nothing is replayable and there is no single lineage for a skip to target.
345
+ * So the verdict set here is exactly `end_stream` · `fail`. Design §5.4.
346
+ */
347
+ private _runStreamingInput;
348
+ /** Route one yielded frame. Returns true when anything went downstream. */
349
+ private _routeStreamingFrame;
350
+ /**
351
+ * Route values downstream, tagging any failure as a routing failure so the
352
+ * recovery loops let it through instead of escalating a delivery problem as
353
+ * if the node had failed.
354
+ */
355
+ private _route;
356
+ /**
357
+ * Close every output slot, keeping whatever the stream already emitted —
358
+ * the `end_stream` verdict. Slots come from the node's declared outputs,
359
+ * falling back to what the stream actually produced.
360
+ */
361
+ private _completeOutputSlots;
362
+ /**
363
+ * For each iteration group present in `frame`, mint or reuse a token. If
364
+ * the frame supplies an `index` value for a group that has an `index`
365
+ * sibling handle declared, overwrite it with the actor-minted index. §1.
366
+ *
367
+ * Returns the override map (only the slots that needed mutation) or null
368
+ * when no iteration groups are in play.
369
+ */
370
+ private _mintIterationFrameOverrides;
371
+ /** Tokens minted for the most recent frame, reused by output lineage. */
372
+ private _lastMintedFrameTokens;
373
+ /**
374
+ * Atomically route a frame of values across multiple slots, minting one
375
+ * shared token per iteration group so sibling handles in the same group
376
+ * (e.g. Zip's `left` and `right`) end up as one logical item downstream.
377
+ * §1, §7.
378
+ *
379
+ * Algorithm:
380
+ * 1. Walk every slot in `values` and resolve its `output_correlation`.
381
+ * 2. For each iteration group present in this frame, mint exactly one
382
+ * token (per (root, parent_key)) and remember it for the duration of
383
+ * this emit.
384
+ * 3. Build a per-slot lineage map that attaches the same token to every
385
+ * sibling handle in a group. Non-iteration slots inherit the
386
+ * caller-supplied lineage (or the actor's invocation lineage).
387
+ * 4. Hand the whole frame to `_sendOutputs` in one call so the runner
388
+ * routes them as a single atomic delivery.
389
+ */
390
+ private _emitGroup;
391
+ /**
392
+ * For `aggregate(innermost)` outputs, drop the collapsed root from the
393
+ * inherited lineage so the emitted envelope sits at the parent scope.
394
+ * The static analyzer drops the root from the output scope at graph load;
395
+ * this is the runtime mirror.
396
+ *
397
+ * Returns the rewritten lineage, or `undefined` when no collapse applies.
398
+ */
399
+ private _maybeCollapseForSlot;
400
+ /**
401
+ * For stream-mode iteration outputs (e.g. `Zip.pair`), mint a fresh token
402
+ * whenever `outputs.emit()` is called without an explicit lineage. Each
403
+ * emit is a logical item, so the token advances per call. Sibling-handle
404
+ * reuse within a single frame is handled by genProcess via
405
+ * `_mintIterationFrameOverrides`, or by `outputs.emitGroup()` in stream
406
+ * mode — see `_emitGroup` above.
407
+ */
408
+ private _maybeMintForSlot;
409
+ /**
410
+ * For each outgoing edge that consumes `slot`, send `signalLineageDone` to
411
+ * the downstream inbox with the envelope's projected key. §5/§6.
412
+ */
413
+ private _propagateLineageDone;
414
+ /**
415
+ * True while `_runCorrelated` is the active execution path.
416
+ */
417
+ private _inCorrelatedBuffered;
418
+ /**
419
+ * Build routing hints for the current invocation.
420
+ *
421
+ * When correlation analysis is available and the invocation emitted handles,
422
+ * the actor mints per-slot lineage for those outputs and pairs it with the
423
+ * invocation lineage. Otherwise it forwards just the invocation lineage,
424
+ * which the runner applies to outputs that inherit the invocation scope.
425
+ * Returns undefined when no invocation lineage is known.
426
+ */
427
+ private _currentHints;
428
+ /**
429
+ * Compute the invocation lineage for the current set of consumed
430
+ * envelopes. Returns undefined when the case is ambiguous.
431
+ *
432
+ * In correlated buffered mode the lineage comes from the correlation
433
+ * scheduler. Otherwise the lineage is taken from the sole consumed data
434
+ * envelope when exactly one non-control, non-list data handle was consumed;
435
+ * any other arity is ambiguous and yields undefined.
436
+ *
437
+ * The map is NOT cleared here so that streaming-input nodes that emit
438
+ * multiple times per consumed envelope continue to inherit lineage on
439
+ * every emit. Buffered gather paths overwrite envelopes per handle on
440
+ * each iteration, which naturally tracks the latest consumed envelope.
441
+ */
442
+ private _computeInvocationLineage;
443
+ /**
444
+ * Controlled execution: wait for control events on __control__ handle.
445
+ *
446
+ * Unlike the generic iterAny() approach, this iterates ONLY the
447
+ * __control__ handle so that the loop terminates as soon as all
448
+ * controllers signal EOS (markSourceDone). Data inputs are drained
449
+ * from the inbox buffers before each execution and cached for replay.
450
+ */
451
+ private _runControlled;
452
+ /**
453
+ * Wait until every data handle has at least one buffered value.
454
+ * Drains items from the inbox as they arrive, caching them, until
455
+ * all required handles are satisfied.
456
+ */
457
+ private _waitForDataInputs;
458
+ /**
459
+ * Drain all buffered data (non-control) inputs and cache them.
460
+ * Called before each controlled execution to pick up any data that
461
+ * arrived while waiting for the next control event.
462
+ */
463
+ private _cacheBufferedDataInputs;
464
+ private _emitNodeStatus;
465
+ /**
466
+ * Emit a BARE `generation_complete` for one committed `process()` result
467
+ * (RFC §4.2 / §5). Routes through the same `_emitMessage` path as
468
+ * `node_update` (runner `_emit`), so it is NEVER edge-suppressed and is
469
+ * retained for replay. The actor stamps NO `job_id` and NO `index` — both
470
+ * are backfilled downstream by the relay (RFC Decision 8).
471
+ *
472
+ * Skips `nodetool.constant.*` / `nodetool.input.*` (the same set
473
+ * `_emitNodeStatus`'s `skipResult` rule covers): those nodes have no
474
+ * generation. List-valued results are carried as-is — no per-element
475
+ * fan-out happens in the actor (RFC Decision 1).
476
+ */
477
+ private _emitGenerationComplete;
478
+ private _filterStreamingPartial;
479
+ }
480
+ //# sourceMappingURL=actor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"actor.d.ts","sourceRoot":"","sources":["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