@nodetool-ai/kernel 0.8.8 → 0.8.9-beta.2
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/dist/.nodetool-build-stamp +1 -1
- package/dist/actor.d.ts +1 -479
- package/dist/actor.d.ts.map +1 -1
- package/dist/actor.js +1 -1911
- package/dist/actor.js.map +1 -1
- package/dist/correlation-analysis.d.ts +1 -103
- package/dist/correlation-analysis.d.ts.map +1 -1
- package/dist/correlation-analysis.js +1 -845
- package/dist/correlation-analysis.js.map +1 -1
- package/dist/durable-inbox.d.ts +1 -90
- package/dist/durable-inbox.d.ts.map +1 -1
- package/dist/durable-inbox.js +1 -210
- package/dist/durable-inbox.js.map +1 -1
- package/dist/dynamic-slots.d.ts +1 -72
- package/dist/dynamic-slots.d.ts.map +1 -1
- package/dist/dynamic-slots.js +1 -191
- package/dist/dynamic-slots.js.map +1 -1
- package/dist/edge-ids.d.ts +1 -10
- package/dist/edge-ids.d.ts.map +1 -1
- package/dist/edge-ids.js +1 -14
- package/dist/edge-ids.js.map +1 -1
- package/dist/graph-utils.d.ts +1 -71
- package/dist/graph-utils.d.ts.map +1 -1
- package/dist/graph-utils.js +1 -283
- package/dist/graph-utils.js.map +1 -1
- package/dist/graph.d.ts +1 -203
- package/dist/graph.d.ts.map +1 -1
- package/dist/graph.js +1 -867
- package/dist/graph.js.map +1 -1
- package/dist/inbox.d.ts +1 -264
- package/dist/inbox.d.ts.map +1 -1
- package/dist/inbox.js +1 -551
- package/dist/inbox.js.map +1 -1
- package/dist/index.d.ts +1 -19
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -19
- package/dist/index.js.map +1 -1
- package/dist/io.d.ts +1 -188
- package/dist/io.d.ts.map +1 -1
- package/dist/io.js +1 -238
- package/dist/io.js.map +1 -1
- package/dist/loop.d.ts +1 -35
- package/dist/loop.d.ts.map +1 -1
- package/dist/loop.js +1 -165
- package/dist/loop.js.map +1 -1
- package/dist/message-stream.d.ts +1 -31
- package/dist/message-stream.d.ts.map +1 -1
- package/dist/message-stream.js +1 -63
- package/dist/message-stream.js.map +1 -1
- package/dist/predicates.d.ts +1 -7
- package/dist/predicates.d.ts.map +1 -1
- package/dist/predicates.js +1 -7
- package/dist/predicates.js.map +1 -1
- package/dist/run-state.d.ts +1 -64
- package/dist/run-state.d.ts.map +1 -1
- package/dist/run-state.js +1 -41
- package/dist/run-state.js.map +1 -1
- package/dist/runner.d.ts +1 -523
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js +1 -2126
- package/dist/runner.js.map +1 -1
- package/dist/substitute-validator.d.ts +1 -43
- package/dist/substitute-validator.d.ts.map +1 -1
- package/dist/substitute-validator.js +1 -168
- package/dist/substitute-validator.js.map +1 -1
- package/dist/supervisor.d.ts +1 -147
- package/dist/supervisor.d.ts.map +1 -1
- package/dist/supervisor.js +1 -286
- package/dist/supervisor.js.map +1 -1
- package/dist/trigger-wakeup.d.ts +1 -122
- package/dist/trigger-wakeup.d.ts.map +1 -1
- package/dist/trigger-wakeup.js +1 -220
- package/dist/trigger-wakeup.js.map +1 -1
- package/package.json +4 -4
package/dist/inbox.js
CHANGED
|
@@ -1,552 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
* NodeInbox – per-node input queuing with backpressure.
|
|
3
|
-
*
|
|
4
|
-
* Port of src/nodetool/workflows/inbox.py.
|
|
5
|
-
*
|
|
6
|
-
* Core semantics:
|
|
7
|
-
* - Per-handle FIFO buffers.
|
|
8
|
-
* - Upstream source counting for EOS detection.
|
|
9
|
-
* - Async iteration with backpressure (optional buffer limit).
|
|
10
|
-
* - Arrival-order multiplexing for iterAny.
|
|
11
|
-
* - MessageEnvelope wrapping for metadata propagation.
|
|
12
|
-
*/
|
|
13
|
-
import { getNodeBuiltinSync } from "@nodetool-ai/config";
|
|
14
|
-
// Stryker disable next-line StringLiteral: module name; on failure getNodeBuiltinSync returns null and randomUUID falls back, so the literal is not behaviourally observable
|
|
15
|
-
const _nodeCrypto = getNodeBuiltinSync("node:crypto");
|
|
16
|
-
/**
|
|
17
|
-
* RFC4122 v4 UUID derived from a `[0, 1)` random source. This is the fallback
|
|
18
|
-
* for runtimes without a native `crypto.randomUUID`. Exported so the bit-twiddling
|
|
19
|
-
* can be verified deterministically with a fixed `rand`.
|
|
20
|
-
*/
|
|
21
|
-
export function fallbackUuidV4(rand = Math.random) {
|
|
22
|
-
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
|
|
23
|
-
const r = (rand() * 16) | 0;
|
|
24
|
-
const v = c === "x" ? r : (r & 0x3) | 0x8;
|
|
25
|
-
return v.toString(16);
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
function randomUUID() {
|
|
29
|
-
// Stryker disable next-line ConditionalExpression,OptionalChaining: equivalent — _nodeCrypto and globalThis.crypto both yield a valid UUID, so which native source provides it is unobservable
|
|
30
|
-
if (_nodeCrypto?.randomUUID)
|
|
31
|
-
return _nodeCrypto.randomUUID();
|
|
32
|
-
// Stryker disable next-line ConditionalExpression,OptionalChaining: equivalent — see above; in Node this branch is never reached because the line above returns
|
|
33
|
-
if (globalThis.crypto?.randomUUID)
|
|
34
|
-
return globalThis.crypto.randomUUID();
|
|
35
|
-
return fallbackUuidV4();
|
|
36
|
-
}
|
|
37
|
-
import { EMPTY_LINEAGE } from "@nodetool-ai/protocol";
|
|
38
|
-
import { tryProjectLineageKey } from "./correlation-analysis.js";
|
|
39
|
-
function makeEnvelope(data, opts = {}) {
|
|
40
|
-
return {
|
|
41
|
-
data,
|
|
42
|
-
metadata: opts.metadata ?? {},
|
|
43
|
-
timestamp: Date.now(),
|
|
44
|
-
event_id: randomUUID(),
|
|
45
|
-
correlation_lineage: opts.correlation_lineage ?? EMPTY_LINEAGE,
|
|
46
|
-
source_edge_id: opts.source_edge_id ?? ""
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
function deferred() {
|
|
50
|
-
let resolve;
|
|
51
|
-
let reject;
|
|
52
|
-
const promise = new Promise((res, rej) => {
|
|
53
|
-
resolve = res;
|
|
54
|
-
reject = rej;
|
|
55
|
-
});
|
|
56
|
-
return { promise, resolve, reject };
|
|
57
|
-
}
|
|
58
|
-
export class NodeInbox {
|
|
59
|
-
/** Per-handle FIFO of envelopes. */
|
|
60
|
-
_buffers = new Map();
|
|
61
|
-
/** Number of open upstream sources per handle. */
|
|
62
|
-
_openCounts = new Map();
|
|
63
|
-
/** Global arrival order queue of handle names. */
|
|
64
|
-
// Stryker disable next-line ArrayDeclaration: a non-empty seed is equivalent — a bogus handle has no matching buffer entry and is skipped by tryPopAny's stale guard
|
|
65
|
-
_arrival = [];
|
|
66
|
-
/** Optional per-handle buffer capacity. */
|
|
67
|
-
_bufferLimit;
|
|
68
|
-
/**
|
|
69
|
-
* Pending-key safety limits. Default to conservative finite values so the
|
|
70
|
-
* correlated scheduler cannot accumulate unbounded buckets when an upstream
|
|
71
|
-
* close is missing. Hitting either is a terminal execution error. §6.
|
|
72
|
-
*/
|
|
73
|
-
_maxPendingKeys;
|
|
74
|
-
_maxPendingMessagesPerKey;
|
|
75
|
-
/** Flag: inbox is closed (no more data accepted). */
|
|
76
|
-
_closed = false;
|
|
77
|
-
/**
|
|
78
|
-
* Flag: backpressure is disabled because nothing will read this inbox again
|
|
79
|
-
* (its actor finished). See {@link releaseBackpressure}.
|
|
80
|
-
*/
|
|
81
|
-
_backpressureReleased = false;
|
|
82
|
-
/** Waiters: consumers blocking for new data. */
|
|
83
|
-
_waiters = [];
|
|
84
|
-
/** Waiters: producers blocking when buffer is full. */
|
|
85
|
-
_putWaiters = [];
|
|
86
|
-
/**
|
|
87
|
-
* Per-(source_edge_id, projected lineage key) record of `lineage_done`
|
|
88
|
-
* signals. The projection is canonical (root=index in scope order) so
|
|
89
|
-
* lookup is unaffected by JavaScript object property order. §6.
|
|
90
|
-
*/
|
|
91
|
-
_doneByEdge = new Map();
|
|
92
|
-
/**
|
|
93
|
-
* Per-(source_edge_id, parent lineage key) → set of closed root ids.
|
|
94
|
-
* Used by `lineage_scope_closed`. §6.
|
|
95
|
-
*/
|
|
96
|
-
_closedByEdge = new Map();
|
|
97
|
-
/**
|
|
98
|
-
* Per-handle set of source edge ids that have ever emitted a signal we
|
|
99
|
-
* recorded. Lets the actor query "did any contributor announce a
|
|
100
|
-
* close/done?" without scanning every edge.
|
|
101
|
-
*/
|
|
102
|
-
_signalEdgesByHandle = new Map();
|
|
103
|
-
/** Runner hooks for quiescence detection; see {@link setObserver}. */
|
|
104
|
-
_observer = null;
|
|
105
|
-
/** Set by {@link notifyQuiescent}, cleared by {@link takeQuiescent}. */
|
|
106
|
-
_quiescent = false;
|
|
107
|
-
constructor(bufferLimit = null, opts = {}) {
|
|
108
|
-
this._bufferLimit = bufferLimit;
|
|
109
|
-
this._maxPendingKeys = opts.maxPendingKeys ?? 10_000;
|
|
110
|
-
this._maxPendingMessagesPerKey = opts.maxPendingMessagesPerKey ?? 10_000;
|
|
111
|
-
}
|
|
112
|
-
/** Configured pending-key limit (read by the actor for diagnostics). */
|
|
113
|
-
get maxPendingKeys() {
|
|
114
|
-
return this._maxPendingKeys;
|
|
115
|
-
}
|
|
116
|
-
/** Configured per-key message limit. */
|
|
117
|
-
get maxPendingMessagesPerKey() {
|
|
118
|
-
return this._maxPendingMessagesPerKey;
|
|
119
|
-
}
|
|
120
|
-
// -----------------------------------------------------------------------
|
|
121
|
-
// Producer API
|
|
122
|
-
// -----------------------------------------------------------------------
|
|
123
|
-
/**
|
|
124
|
-
* Register upstream producer count for a handle.
|
|
125
|
-
* Must be called before `put()`.
|
|
126
|
-
*/
|
|
127
|
-
addUpstream(handle, count = 1) {
|
|
128
|
-
const cur = this._openCounts.get(handle) ?? 0;
|
|
129
|
-
this._openCounts.set(handle, cur + count);
|
|
130
|
-
if (!this._buffers.has(handle)) {
|
|
131
|
-
this._buffers.set(handle, []);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Enqueue an item for a handle.
|
|
136
|
-
* Blocks (via returned promise) if the per-handle buffer is at capacity.
|
|
137
|
-
*/
|
|
138
|
-
async put(handle, item, opts = {}) {
|
|
139
|
-
if (this._closed)
|
|
140
|
-
return;
|
|
141
|
-
const buf = this._buffers.get(handle);
|
|
142
|
-
if (!buf) {
|
|
143
|
-
// Handle not registered – auto-create
|
|
144
|
-
this._buffers.set(handle, []);
|
|
145
|
-
}
|
|
146
|
-
// Backpressure: wait if buffer is at limit
|
|
147
|
-
if (this._bufferLimit !== null && !this._backpressureReleased) {
|
|
148
|
-
while (!this._closed &&
|
|
149
|
-
!this._backpressureReleased &&
|
|
150
|
-
// Stryker disable next-line OptionalChaining: the buffer was auto-created above, so get(handle) is always defined here — the ?. is defensive
|
|
151
|
-
(this._buffers.get(handle)?.length ?? 0) >= this._bufferLimit) {
|
|
152
|
-
const d = deferred();
|
|
153
|
-
this._putWaiters.push(d);
|
|
154
|
-
await d.promise;
|
|
155
|
-
}
|
|
156
|
-
if (this._closed)
|
|
157
|
-
return;
|
|
158
|
-
}
|
|
159
|
-
const envelope = makeEnvelope(item, opts);
|
|
160
|
-
this._buffers.get(handle).push(envelope);
|
|
161
|
-
this._arrival.push(handle);
|
|
162
|
-
this._observer?.onActivity();
|
|
163
|
-
this._notifyWaiters();
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* Prepend an envelope back to the front of a handle's buffer.
|
|
167
|
-
* Used for push-back scenarios.
|
|
168
|
-
*/
|
|
169
|
-
prepend(handle, envelope) {
|
|
170
|
-
const buf = this._buffers.get(handle);
|
|
171
|
-
if (buf) {
|
|
172
|
-
buf.unshift(envelope);
|
|
173
|
-
this._arrival.unshift(handle);
|
|
174
|
-
this._notifyWaiters();
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
/**
|
|
178
|
-
* Record a `lineage_done` signal: this source edge will not produce a value
|
|
179
|
-
* for `signal.lineage` on `signal.output`.
|
|
180
|
-
*
|
|
181
|
-
* The lineage is canonicalized against the supplied static scope so lookups
|
|
182
|
-
* are order-independent. If `scope` is empty the lineage projects to the
|
|
183
|
-
* empty key, which matches "source edge done at the root scope".
|
|
184
|
-
*
|
|
185
|
-
* `handle` is the inbox's target handle for the edge. The actor uses this
|
|
186
|
-
* to decide which firings to drop or propagate.
|
|
187
|
-
*/
|
|
188
|
-
signalLineageDone(handle, signal, scope) {
|
|
189
|
-
const key = tryProjectLineageKey(signal.lineage, scope);
|
|
190
|
-
const finalKey = key ?? "";
|
|
191
|
-
let set = this._doneByEdge.get(signal.source_edge_id);
|
|
192
|
-
if (!set) {
|
|
193
|
-
set = new Set();
|
|
194
|
-
this._doneByEdge.set(signal.source_edge_id, set);
|
|
195
|
-
}
|
|
196
|
-
set.add(finalKey);
|
|
197
|
-
this._registerSignalEdge(handle, signal.source_edge_id);
|
|
198
|
-
this._observer?.onActivity();
|
|
199
|
-
this._notifyWaiters();
|
|
200
|
-
}
|
|
201
|
-
/**
|
|
202
|
-
* Record a `lineage_scope_closed` signal: this source edge will not produce
|
|
203
|
-
* any more descendants for `signal.closed_root` under
|
|
204
|
-
* `signal.parent_lineage` on `signal.output`.
|
|
205
|
-
*
|
|
206
|
-
* Like `signalLineageDone`, the parent lineage is canonicalized using the
|
|
207
|
-
* supplied static parent scope.
|
|
208
|
-
*/
|
|
209
|
-
signalLineageScopeClosed(handle, signal, parentScope) {
|
|
210
|
-
const key = tryProjectLineageKey(signal.parent_lineage, parentScope);
|
|
211
|
-
const finalKey = key ?? "";
|
|
212
|
-
let perEdge = this._closedByEdge.get(signal.source_edge_id);
|
|
213
|
-
if (!perEdge) {
|
|
214
|
-
perEdge = new Map();
|
|
215
|
-
this._closedByEdge.set(signal.source_edge_id, perEdge);
|
|
216
|
-
}
|
|
217
|
-
let roots = perEdge.get(finalKey);
|
|
218
|
-
if (!roots) {
|
|
219
|
-
roots = new Set();
|
|
220
|
-
perEdge.set(finalKey, roots);
|
|
221
|
-
}
|
|
222
|
-
roots.add(signal.closed_root);
|
|
223
|
-
this._registerSignalEdge(handle, signal.source_edge_id);
|
|
224
|
-
this._observer?.onActivity();
|
|
225
|
-
this._notifyWaiters();
|
|
226
|
-
}
|
|
227
|
-
/**
|
|
228
|
-
* True if the given source edge has emitted `lineage_done` for `lineageKey`.
|
|
229
|
-
* `lineageKey` is the canonical projection produced by `projectLineageKey`.
|
|
230
|
-
*/
|
|
231
|
-
isEdgeDoneFor(sourceEdgeId, lineageKey) {
|
|
232
|
-
return this._doneByEdge.get(sourceEdgeId)?.has(lineageKey) ?? false;
|
|
233
|
-
}
|
|
234
|
-
/**
|
|
235
|
-
* True if `closed_root` has been closed under `parentKey` for the given
|
|
236
|
-
* source edge.
|
|
237
|
-
*/
|
|
238
|
-
isScopeClosedFor(sourceEdgeId, parentKey, closedRoot) {
|
|
239
|
-
return (this._closedByEdge.get(sourceEdgeId)?.get(parentKey)?.has(closedRoot) ??
|
|
240
|
-
false);
|
|
241
|
-
}
|
|
242
|
-
/**
|
|
243
|
-
* Source edge ids that have emitted at least one lineage signal targeting
|
|
244
|
-
* `handle`. Used by the close-barrier machinery to enumerate contributors
|
|
245
|
-
* that have already announced something.
|
|
246
|
-
*/
|
|
247
|
-
signalEdgesForHandle(handle) {
|
|
248
|
-
return this._signalEdgesByHandle.get(handle) ?? new Set();
|
|
249
|
-
}
|
|
250
|
-
_registerSignalEdge(handle, edgeId) {
|
|
251
|
-
let set = this._signalEdgesByHandle.get(handle);
|
|
252
|
-
if (!set) {
|
|
253
|
-
set = new Set();
|
|
254
|
-
this._signalEdgesByHandle.set(handle, set);
|
|
255
|
-
}
|
|
256
|
-
set.add(edgeId);
|
|
257
|
-
}
|
|
258
|
-
/**
|
|
259
|
-
* Signal that one upstream source for `handle` is done.
|
|
260
|
-
* When all sources are done and buffer is empty, EOS for that handle.
|
|
261
|
-
*/
|
|
262
|
-
markSourceDone(handle) {
|
|
263
|
-
const cur = this._openCounts.get(handle) ?? 0;
|
|
264
|
-
if (cur > 0) {
|
|
265
|
-
this._openCounts.set(handle, cur - 1);
|
|
266
|
-
}
|
|
267
|
-
this._observer?.onActivity();
|
|
268
|
-
this._notifyWaiters();
|
|
269
|
-
}
|
|
270
|
-
// -----------------------------------------------------------------------
|
|
271
|
-
// Consumer API – async iterators
|
|
272
|
-
// -----------------------------------------------------------------------
|
|
273
|
-
/**
|
|
274
|
-
* Yield items for a single handle until EOS.
|
|
275
|
-
*/
|
|
276
|
-
async *iterInput(handle) {
|
|
277
|
-
while (true) {
|
|
278
|
-
const buf = this._buffers.get(handle);
|
|
279
|
-
if (buf && buf.length > 0) {
|
|
280
|
-
const envelope = buf.shift();
|
|
281
|
-
this._removeFromArrival(handle);
|
|
282
|
-
this._notifyPutWaiters();
|
|
283
|
-
yield envelope.data;
|
|
284
|
-
continue;
|
|
285
|
-
}
|
|
286
|
-
// Check EOS
|
|
287
|
-
if (this._isHandleDone(handle) || this._closed) {
|
|
288
|
-
return;
|
|
289
|
-
}
|
|
290
|
-
// Wait for new data
|
|
291
|
-
await this._waitForData();
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
/**
|
|
295
|
-
* Yield MessageEnvelopes for a single handle until EOS.
|
|
296
|
-
*/
|
|
297
|
-
async *iterInputWithEnvelope(handle) {
|
|
298
|
-
while (true) {
|
|
299
|
-
const buf = this._buffers.get(handle);
|
|
300
|
-
if (buf && buf.length > 0) {
|
|
301
|
-
const envelope = buf.shift();
|
|
302
|
-
this._removeFromArrival(handle);
|
|
303
|
-
this._notifyPutWaiters();
|
|
304
|
-
yield envelope;
|
|
305
|
-
continue;
|
|
306
|
-
}
|
|
307
|
-
if (this._isHandleDone(handle) || this._closed) {
|
|
308
|
-
return;
|
|
309
|
-
}
|
|
310
|
-
await this._waitForData();
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
/**
|
|
314
|
-
* Yield (handle, item) tuples in arrival order across all handles.
|
|
315
|
-
* Completes when all handles are drained.
|
|
316
|
-
*/
|
|
317
|
-
async *iterAny() {
|
|
318
|
-
while (true) {
|
|
319
|
-
const popped = this.tryPopAny();
|
|
320
|
-
if (popped) {
|
|
321
|
-
yield popped;
|
|
322
|
-
continue;
|
|
323
|
-
}
|
|
324
|
-
if (this.isFullyDrained() || this._closed) {
|
|
325
|
-
return;
|
|
326
|
-
}
|
|
327
|
-
await this._waitForData();
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
/**
|
|
331
|
-
* Yield (handle, MessageEnvelope) in arrival order.
|
|
332
|
-
*/
|
|
333
|
-
async *iterAnyWithEnvelope() {
|
|
334
|
-
while (true) {
|
|
335
|
-
const popped = this.tryPopAnyWithEnvelope();
|
|
336
|
-
if (popped) {
|
|
337
|
-
yield popped;
|
|
338
|
-
continue;
|
|
339
|
-
}
|
|
340
|
-
if (this.isFullyDrained() || this._closed) {
|
|
341
|
-
return;
|
|
342
|
-
}
|
|
343
|
-
await this._waitForData();
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
// -----------------------------------------------------------------------
|
|
347
|
-
// Non-blocking pop
|
|
348
|
-
// -----------------------------------------------------------------------
|
|
349
|
-
/**
|
|
350
|
-
* Non-blocking: pop the earliest-arriving item across all handles.
|
|
351
|
-
* Returns [handle, item] or null.
|
|
352
|
-
*/
|
|
353
|
-
tryPopAny() {
|
|
354
|
-
const env = this.tryPopAnyWithEnvelope();
|
|
355
|
-
if (!env)
|
|
356
|
-
return null;
|
|
357
|
-
return [env[0], env[1].data];
|
|
358
|
-
}
|
|
359
|
-
/**
|
|
360
|
-
* Non-blocking: pop the earliest-arriving envelope.
|
|
361
|
-
*/
|
|
362
|
-
tryPopAnyWithEnvelope() {
|
|
363
|
-
while (this._arrival.length > 0) {
|
|
364
|
-
const handle = this._arrival[0];
|
|
365
|
-
const buf = this._buffers.get(handle);
|
|
366
|
-
// Stryker disable next-line ConditionalExpression,LogicalOperator,EqualityOperator: defensive stale guard — _removeFromArrival keeps the arrival queue in lock-step with buffers, so the head is always backed by a non-empty buffer; the empty/undefined case is unreachable
|
|
367
|
-
if (buf && buf.length > 0) {
|
|
368
|
-
this._arrival.shift();
|
|
369
|
-
const envelope = buf.shift();
|
|
370
|
-
this._notifyPutWaiters();
|
|
371
|
-
return [handle, envelope];
|
|
372
|
-
}
|
|
373
|
-
// Stale arrival entry (buffer already consumed) – skip
|
|
374
|
-
this._arrival.shift();
|
|
375
|
-
}
|
|
376
|
-
return null;
|
|
377
|
-
}
|
|
378
|
-
// -----------------------------------------------------------------------
|
|
379
|
-
// State queries
|
|
380
|
-
// -----------------------------------------------------------------------
|
|
381
|
-
/** All handle names registered on this inbox. */
|
|
382
|
-
handles() {
|
|
383
|
-
return [...this._buffers.keys()];
|
|
384
|
-
}
|
|
385
|
-
/**
|
|
386
|
-
* Drain and return every buffered envelope for a handle, releasing
|
|
387
|
-
* backpressure on blocked producers and clearing arrival entries.
|
|
388
|
-
*/
|
|
389
|
-
drainHandle(handle) {
|
|
390
|
-
const buf = this._buffers.get(handle);
|
|
391
|
-
if (!buf?.length)
|
|
392
|
-
return [];
|
|
393
|
-
const drained = buf.splice(0);
|
|
394
|
-
this._arrival = this._arrival.filter((h) => h !== handle);
|
|
395
|
-
this._notifyPutWaiters();
|
|
396
|
-
return drained;
|
|
397
|
-
}
|
|
398
|
-
/** Whether any handle has buffered data. */
|
|
399
|
-
hasAny() {
|
|
400
|
-
for (const buf of this._buffers.values()) {
|
|
401
|
-
if (buf.length > 0)
|
|
402
|
-
return true;
|
|
403
|
-
}
|
|
404
|
-
return false;
|
|
405
|
-
}
|
|
406
|
-
/** Whether a specific handle has buffered data. */
|
|
407
|
-
hasBuffered(handle) {
|
|
408
|
-
const buf = this._buffers.get(handle);
|
|
409
|
-
return buf !== undefined && buf.length > 0;
|
|
410
|
-
}
|
|
411
|
-
/** Whether a handle still has open upstream sources. */
|
|
412
|
-
isOpen(handle) {
|
|
413
|
-
return (this._openCounts.get(handle) ?? 0) > 0;
|
|
414
|
-
}
|
|
415
|
-
/**
|
|
416
|
-
* Whether `closeAll()` has run. A closed inbox accepts no further writes, so
|
|
417
|
-
* anything not already buffered can never arrive. Consumers that manage their
|
|
418
|
-
* own draining must treat this as terminal — `closeAll()` deliberately leaves
|
|
419
|
-
* `_openCounts` alone, so `isOpen()` keeps reporting true after a close.
|
|
420
|
-
*/
|
|
421
|
-
isClosed() {
|
|
422
|
-
return this._closed;
|
|
423
|
-
}
|
|
424
|
-
/**
|
|
425
|
-
* Whether the inbox is fully drained:
|
|
426
|
-
* all handles have no buffered data AND no open upstream sources.
|
|
427
|
-
*/
|
|
428
|
-
isFullyDrained() {
|
|
429
|
-
for (const [handle, buf] of this._buffers) {
|
|
430
|
-
if (buf.length > 0)
|
|
431
|
-
return false;
|
|
432
|
-
if ((this._openCounts.get(handle) ?? 0) > 0)
|
|
433
|
-
return false;
|
|
434
|
-
}
|
|
435
|
-
return true;
|
|
436
|
-
}
|
|
437
|
-
/** Inverse of isFullyDrained. */
|
|
438
|
-
hasPendingWork() {
|
|
439
|
-
return !this.isFullyDrained();
|
|
440
|
-
}
|
|
441
|
-
// -----------------------------------------------------------------------
|
|
442
|
-
// Control
|
|
443
|
-
// -----------------------------------------------------------------------
|
|
444
|
-
/** Close the inbox – wake all consumers, reject further writes. */
|
|
445
|
-
async closeAll() {
|
|
446
|
-
this._closed = true;
|
|
447
|
-
this._notifyWaiters();
|
|
448
|
-
this._notifyPutWaiters();
|
|
449
|
-
}
|
|
450
|
-
/**
|
|
451
|
-
* Stop applying backpressure: wake every producer parked on a full buffer and
|
|
452
|
-
* let later `put`s through without waiting.
|
|
453
|
-
*
|
|
454
|
-
* Called when the consuming actor has finished, so no one will ever drain
|
|
455
|
-
* this inbox again. Without it, an upstream actor blocked in `put()` on a
|
|
456
|
-
* full buffer waits on a `_putWaiters` deferred that only a consumer pop can
|
|
457
|
-
* resolve — the producer never returns, and the runner's `Promise.all` over
|
|
458
|
-
* all actors never settles, hanging the whole workflow.
|
|
459
|
-
*
|
|
460
|
-
* Unlike `closeAll()`, writes are still accepted and buffered, so the
|
|
461
|
-
* runner's post-run "pending inbox work" check still reports the undelivered
|
|
462
|
-
* values instead of silently dropping them.
|
|
463
|
-
*/
|
|
464
|
-
releaseBackpressure() {
|
|
465
|
-
this._backpressureReleased = true;
|
|
466
|
-
this._notifyPutWaiters();
|
|
467
|
-
}
|
|
468
|
-
// -----------------------------------------------------------------------
|
|
469
|
-
// Internal helpers
|
|
470
|
-
// -----------------------------------------------------------------------
|
|
471
|
-
_isHandleDone(handle) {
|
|
472
|
-
const buf = this._buffers.get(handle);
|
|
473
|
-
// Stryker disable next-line ConditionalExpression,BooleanLiteral: equivalent — _isHandleDone is only consulted after the iterator's buffered-data branch, so `buf` is always empty here; forcing `empty` true changes nothing
|
|
474
|
-
const empty = !buf || buf.length === 0;
|
|
475
|
-
const noUpstream = (this._openCounts.get(handle) ?? 0) === 0;
|
|
476
|
-
return empty && noUpstream;
|
|
477
|
-
}
|
|
478
|
-
/** Wake one consumer waiter. */
|
|
479
|
-
_notifyWaiters() {
|
|
480
|
-
while (this._waiters.length > 0) {
|
|
481
|
-
const w = this._waiters.shift();
|
|
482
|
-
w.resolve();
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
/** Wake one producer waiter (backpressure relief). */
|
|
486
|
-
_notifyPutWaiters() {
|
|
487
|
-
while (this._putWaiters.length > 0) {
|
|
488
|
-
const w = this._putWaiters.shift();
|
|
489
|
-
w.resolve();
|
|
490
|
-
}
|
|
491
|
-
}
|
|
492
|
-
/** Wait until notified of new data or close. */
|
|
493
|
-
_waitForData() {
|
|
494
|
-
const d = deferred();
|
|
495
|
-
this._waiters.push(d);
|
|
496
|
-
this._observer?.onPark();
|
|
497
|
-
return d.promise;
|
|
498
|
-
}
|
|
499
|
-
// -----------------------------------------------------------------------
|
|
500
|
-
// Quiescence (workflow loops, docs/workflow-loops.md)
|
|
501
|
-
// -----------------------------------------------------------------------
|
|
502
|
-
/** Install the runner's park/activity hooks. */
|
|
503
|
-
setObserver(observer) {
|
|
504
|
-
this._observer = observer;
|
|
505
|
-
}
|
|
506
|
-
/** True while the consumer is parked waiting for input. */
|
|
507
|
-
isParked() {
|
|
508
|
-
return this._waiters.length > 0;
|
|
509
|
-
}
|
|
510
|
-
/**
|
|
511
|
-
* Tell the consumer the whole graph is quiescent: every actor is parked,
|
|
512
|
-
* so no input it is waiting for can still arrive. Wakes the consumer.
|
|
513
|
-
*/
|
|
514
|
-
notifyQuiescent() {
|
|
515
|
-
this._quiescent = true;
|
|
516
|
-
this._notifyWaiters();
|
|
517
|
-
}
|
|
518
|
-
/** Read and clear the quiescent flag set by {@link notifyQuiescent}. */
|
|
519
|
-
takeQuiescent() {
|
|
520
|
-
const was = this._quiescent;
|
|
521
|
-
this._quiescent = false;
|
|
522
|
-
return was;
|
|
523
|
-
}
|
|
524
|
-
/**
|
|
525
|
-
* Resolve when the inbox is next notified of activity — a `put`, `prepend`,
|
|
526
|
-
* lineage signal, `markSourceDone`, or `closeAll`. Yields nothing: unlike the
|
|
527
|
-
* iterators, a close that produces no envelope still wakes the caller. Used by
|
|
528
|
-
* consumers that manage their own draining (the controlled-node wait) and must
|
|
529
|
-
* re-check handle state after an upstream close arrives while blocked.
|
|
530
|
-
*
|
|
531
|
-
* Returns immediately on a closed inbox: `closeAll()` wakes the waiters that
|
|
532
|
-
* exist at that moment and never fires again, so parking here after a close
|
|
533
|
-
* would block forever.
|
|
534
|
-
*/
|
|
535
|
-
async waitForActivity() {
|
|
536
|
-
if (this._closed)
|
|
537
|
-
return;
|
|
538
|
-
await this._waitForData();
|
|
539
|
-
}
|
|
540
|
-
/**
|
|
541
|
-
* Remove the first occurrence of `handle` from the arrival queue.
|
|
542
|
-
* Called after consuming from a specific handle.
|
|
543
|
-
*/
|
|
544
|
-
_removeFromArrival(handle) {
|
|
545
|
-
const idx = this._arrival.indexOf(handle);
|
|
546
|
-
// Stryker disable next-line ConditionalExpression: forcing this true is equivalent — _removeFromArrival is only called right after consuming a buffered item, so the handle is always present (idx >= 0); the guard is defensive against an idx === -1 that cannot occur
|
|
547
|
-
if (idx >= 0) {
|
|
548
|
-
this._arrival.splice(idx, 1);
|
|
549
|
-
}
|
|
550
|
-
}
|
|
551
|
-
}
|
|
1
|
+
export * from "@nodetool-ai/execution-core/inbox";
|
|
552
2
|
//# sourceMappingURL=inbox.js.map
|
package/dist/inbox.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inbox.js","sourceRoot":"","sources":["../src/inbox.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAOzD,6KAA6K;AAC7K,MAAM,WAAW,GAAG,kBAAkB,CAA+B,aAAa,CAAC,CAAC;AAEpF;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,IAAI,GAAiB,IAAI,CAAC,MAAM;IAC7D,OAAO,sCAAsC,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE;QACnE,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC;QAC5B,MAAM,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC;QAC1C,OAAO,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IACxB,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,UAAU;IACjB,+LAA+L;IAC/L,IAAI,WAAW,EAAE,UAAU;QAAE,OAAO,WAAW,CAAC,UAAU,EAAE,CAAC;IAC7D,gKAAgK;IAChK,IAAI,UAAU,CAAC,MAAM,EAAE,UAAU;QAAE,OAAO,UAAU,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;IACzE,OAAO,cAAc,EAAE,CAAC;AAC1B,CAAC;AACD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACt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;YACb,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;QAC/B,CAAC;IACH,CAAC;CACF"}
|
|
1
|
+
{"version":3,"file":"inbox.js","sourceRoot":"","sources":["../src/inbox.ts"],"names":[],"mappings":"AAAA,cAAc,mCAAmC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,20 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
* @nodetool-ai/kernel – Public API
|
|
3
|
-
*/
|
|
4
|
-
export { Graph, GraphValidationError, withExplicitNodeFlags, type HydratedGraph, type GraphValidationIssue, type GraphFromDictOptions, type GraphLoadOptions, type NodeTypeResolver, type ResolvedNodeType } from "./graph.js";
|
|
5
|
-
export { NodeInbox, type InboxObserver, type MessageEnvelope } from "./inbox.js";
|
|
6
|
-
export { DEFAULT_MAX_ITERATIONS, MAX_ITERATIONS_LIMIT, resolveMaxIterations } from "./loop.js";
|
|
7
|
-
export { syntheticEdgeId, externalEdgeId } from "./edge-ids.js";
|
|
8
|
-
export { analyzeCorrelation, CorrelationAnalysisError, comparable, isPrefixOf, iterationRootId, edgeKey, projectLineageKey, tryProjectLineageKey, type Scope, type EdgeAnalysis, type OutputAnalysis, type InputAnalysis, type NodeAnalysis, type CorrelationAnalysisIssue, type CorrelationAnalysisResult, type AnalyzeOptions } from "./correlation-analysis.js";
|
|
9
|
-
export { NodeActor, type NodeExecutor, type ActorResult } from "./actor.js";
|
|
10
|
-
export { BoundedHandle, ensureBounded, FailClosedHandle, computeAllowedActions, failureSignature, redactRecord, redactValue, DEFAULT_SUPERVISOR_BOUNDS, MAX_ESCALATION_VALUE_CHARS, type SupervisorHandle, type DecisionOutcome, type SupervisorBounds, type AllowedActionsInput } from "./supervisor.js";
|
|
11
|
-
export { lineageRelated, type RunStateReader, type RunStateDigest, type NodeRunState, type NodeOutputRead } from "./run-state.js";
|
|
12
|
-
export { validateSubstituteOutputs, hasFullValidatorCoverage, type SubstituteValidationResult, type SubstituteValidatorOptions } from "./substitute-validator.js";
|
|
13
|
-
export { WorkflowRunner, type RunJobRequest, type WorkflowRunnerOptions, type RunResult, type NodeValidationIssue, type NodeValidator, type OutputRoutingHints } from "./runner.js";
|
|
14
|
-
export { NodeInputs, NodeOutputs, type NodeOutputsOptions, type EmitOptions } from "./io.js";
|
|
15
|
-
export { applyDynamicSlotTypes, dynamicSlotPropertyTypes, dynamicSlotTypeErrorMessage, dynamicSlotTypeString, getDynamicSlotTypeString, mergeDerivedSlots, type DerivedDynamicSlots } from "./dynamic-slots.js";
|
|
16
|
-
export { findNodeOrThrow, getInputTypeString, getNodeInputTypes, getDownstreamSubgraph, isNodeBypassed, rewriteBypassedNodes } from "./graph-utils.js";
|
|
17
|
-
export { DurableInbox, MemoryDurableInboxStore, type DurableInboxStore, type DurableMessage } from "./durable-inbox.js";
|
|
18
|
-
export { TriggerWakeupService, MemoryTriggerInputStore, type TriggerInput, type TriggerInputStore } from "./trigger-wakeup.js";
|
|
19
|
-
export { MessageStream, DEFAULT_MESSAGE_BUFFER_LIMIT } from "./message-stream.js";
|
|
1
|
+
export * from "@nodetool-ai/execution-core";
|
|
20
2
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,20 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
* @nodetool-ai/kernel – Public API
|
|
3
|
-
*/
|
|
4
|
-
export { Graph, GraphValidationError, withExplicitNodeFlags } from "./graph.js";
|
|
5
|
-
export { NodeInbox } from "./inbox.js";
|
|
6
|
-
export { DEFAULT_MAX_ITERATIONS, MAX_ITERATIONS_LIMIT, resolveMaxIterations } from "./loop.js";
|
|
7
|
-
export { syntheticEdgeId, externalEdgeId } from "./edge-ids.js";
|
|
8
|
-
export { analyzeCorrelation, CorrelationAnalysisError, comparable, isPrefixOf, iterationRootId, edgeKey, projectLineageKey, tryProjectLineageKey } from "./correlation-analysis.js";
|
|
9
|
-
export { NodeActor } from "./actor.js";
|
|
10
|
-
export { BoundedHandle, ensureBounded, FailClosedHandle, computeAllowedActions, failureSignature, redactRecord, redactValue, DEFAULT_SUPERVISOR_BOUNDS, MAX_ESCALATION_VALUE_CHARS } from "./supervisor.js";
|
|
11
|
-
export { lineageRelated } from "./run-state.js";
|
|
12
|
-
export { validateSubstituteOutputs, hasFullValidatorCoverage } from "./substitute-validator.js";
|
|
13
|
-
export { WorkflowRunner } from "./runner.js";
|
|
14
|
-
export { NodeInputs, NodeOutputs } from "./io.js";
|
|
15
|
-
export { applyDynamicSlotTypes, dynamicSlotPropertyTypes, dynamicSlotTypeErrorMessage, dynamicSlotTypeString, getDynamicSlotTypeString, mergeDerivedSlots } from "./dynamic-slots.js";
|
|
16
|
-
export { findNodeOrThrow, getInputTypeString, getNodeInputTypes, getDownstreamSubgraph, isNodeBypassed, rewriteBypassedNodes } from "./graph-utils.js";
|
|
17
|
-
export { DurableInbox, MemoryDurableInboxStore } from "./durable-inbox.js";
|
|
18
|
-
export { TriggerWakeupService, MemoryTriggerInputStore } from "./trigger-wakeup.js";
|
|
19
|
-
export { MessageStream, DEFAULT_MESSAGE_BUFFER_LIMIT } from "./message-stream.js";
|
|
1
|
+
export * from "@nodetool-ai/execution-core";
|
|
20
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC"}
|