@nodetool-ai/kernel 0.7.0-rc.22 → 0.8.1

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