@graphrefly/ts 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/adapters/index.cjs +9015 -0
- package/dist/adapters/index.cjs.map +1 -0
- package/dist/adapters/index.d.cts +678 -0
- package/dist/adapters/index.d.ts +678 -0
- package/dist/adapters/index.js +2894 -0
- package/dist/adapters/index.js.map +1 -0
- package/dist/adapters/observe-storage.cjs +260 -0
- package/dist/adapters/observe-storage.cjs.map +1 -0
- package/dist/adapters/observe-storage.d.cts +77 -0
- package/dist/adapters/observe-storage.d.ts +77 -0
- package/dist/adapters/observe-storage.js +161 -0
- package/dist/adapters/observe-storage.js.map +1 -0
- package/dist/append-log-DisvEReb.d.cts +189 -0
- package/dist/append-log-DzKMmjxx.d.ts +189 -0
- package/dist/chunk-2ILL7HQI.js +1189 -0
- package/dist/chunk-2ILL7HQI.js.map +1 -0
- package/dist/chunk-4VLAQHZI.js +330 -0
- package/dist/chunk-4VLAQHZI.js.map +1 -0
- package/dist/chunk-6PHB5CJS.js +229 -0
- package/dist/chunk-6PHB5CJS.js.map +1 -0
- package/dist/chunk-COHO25CZ.js +2449 -0
- package/dist/chunk-COHO25CZ.js.map +1 -0
- package/dist/chunk-D6BG7U6A.js +161 -0
- package/dist/chunk-D6BG7U6A.js.map +1 -0
- package/dist/chunk-DJC4CHLQ.js +818 -0
- package/dist/chunk-DJC4CHLQ.js.map +1 -0
- package/dist/chunk-DK554R7P.js +67 -0
- package/dist/chunk-DK554R7P.js.map +1 -0
- package/dist/chunk-DKP56CSW.js +322 -0
- package/dist/chunk-DKP56CSW.js.map +1 -0
- package/dist/chunk-G4M3NHRJ.js +688 -0
- package/dist/chunk-G4M3NHRJ.js.map +1 -0
- package/dist/chunk-GAJW5I5P.js +1 -0
- package/dist/chunk-GAJW5I5P.js.map +1 -0
- package/dist/chunk-GDL26N2T.js +282 -0
- package/dist/chunk-GDL26N2T.js.map +1 -0
- package/dist/chunk-GTPCOEOZ.js +741 -0
- package/dist/chunk-GTPCOEOZ.js.map +1 -0
- package/dist/chunk-H2HTHFVN.js +1 -0
- package/dist/chunk-H2HTHFVN.js.map +1 -0
- package/dist/chunk-HDRL4VQQ.js +218 -0
- package/dist/chunk-HDRL4VQQ.js.map +1 -0
- package/dist/chunk-I3IHOHCJ.js +2267 -0
- package/dist/chunk-I3IHOHCJ.js.map +1 -0
- package/dist/chunk-JIMUDQN3.js +965 -0
- package/dist/chunk-JIMUDQN3.js.map +1 -0
- package/dist/chunk-JR4IKCR2.js +462 -0
- package/dist/chunk-JR4IKCR2.js.map +1 -0
- package/dist/chunk-K3FXTC3I.js +165 -0
- package/dist/chunk-K3FXTC3I.js.map +1 -0
- package/dist/chunk-OOEN33FB.js +65 -0
- package/dist/chunk-OOEN33FB.js.map +1 -0
- package/dist/chunk-PKVBHGBM.js +554 -0
- package/dist/chunk-PKVBHGBM.js.map +1 -0
- package/dist/chunk-RIIOUTGM.js +1857 -0
- package/dist/chunk-RIIOUTGM.js.map +1 -0
- package/dist/chunk-SCRFRCGR.js +33 -0
- package/dist/chunk-SCRFRCGR.js.map +1 -0
- package/dist/chunk-SWTLEQL6.js +53 -0
- package/dist/chunk-SWTLEQL6.js.map +1 -0
- package/dist/chunk-SZAETNNA.js +1 -0
- package/dist/chunk-SZAETNNA.js.map +1 -0
- package/dist/chunk-TEW47IVR.js +49 -0
- package/dist/chunk-TEW47IVR.js.map +1 -0
- package/dist/chunk-Y3ZLRGHC.js +1482 -0
- package/dist/chunk-Y3ZLRGHC.js.map +1 -0
- package/dist/chunk-Z2ANQ6JW.js +149 -0
- package/dist/chunk-Z2ANQ6JW.js.map +1 -0
- package/dist/codec-BB7p8fJc.d.cts +38 -0
- package/dist/codec-BB7p8fJc.d.ts +38 -0
- package/dist/composition/index.cjs +2505 -0
- package/dist/composition/index.cjs.map +1 -0
- package/dist/composition/index.d.cts +95 -0
- package/dist/composition/index.d.ts +95 -0
- package/dist/composition/index.js +19 -0
- package/dist/composition/index.js.map +1 -0
- package/dist/core/index.cjs +2475 -0
- package/dist/core/index.cjs.map +1 -0
- package/dist/core/index.d.cts +25 -0
- package/dist/core/index.d.ts +25 -0
- package/dist/core/index.js +74 -0
- package/dist/core/index.js.map +1 -0
- package/dist/cqrs/index.cjs +595 -0
- package/dist/cqrs/index.cjs.map +1 -0
- package/dist/cqrs/index.d.cts +200 -0
- package/dist/cqrs/index.d.ts +200 -0
- package/dist/cqrs/index.js +557 -0
- package/dist/cqrs/index.js.map +1 -0
- package/dist/data-structures/index.cjs +4277 -0
- package/dist/data-structures/index.cjs.map +1 -0
- package/dist/data-structures/index.d.cts +22 -0
- package/dist/data-structures/index.d.ts +22 -0
- package/dist/data-structures/index.js +31 -0
- package/dist/data-structures/index.js.map +1 -0
- package/dist/describe-BZb7AS2y.d.ts +57 -0
- package/dist/describe-Ciu8SUnN.d.cts +57 -0
- package/dist/graph/index.cjs +7832 -0
- package/dist/graph/index.cjs.map +1 -0
- package/dist/graph/index.d.cts +251 -0
- package/dist/graph/index.d.ts +251 -0
- package/dist/graph/index.js +131 -0
- package/dist/graph/index.js.map +1 -0
- package/dist/graph-DfdF9zy4.d.ts +666 -0
- package/dist/graph-s23RbbFO.d.cts +666 -0
- package/dist/index-CAEmLCYF.d.cts +166 -0
- package/dist/index-SnzZu3x7.d.ts +166 -0
- package/dist/index.cjs +15409 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +23 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +582 -0
- package/dist/index.js.map +1 -0
- package/dist/messages-BZqrGGm1.d.cts +55 -0
- package/dist/messages-BZqrGGm1.d.ts +55 -0
- package/dist/messaging/index.cjs +818 -0
- package/dist/messaging/index.cjs.map +1 -0
- package/dist/messaging/index.d.cts +235 -0
- package/dist/messaging/index.d.ts +235 -0
- package/dist/messaging/index.js +767 -0
- package/dist/messaging/index.js.map +1 -0
- package/dist/observe-event-log-0SVsx7JG.d.cts +88 -0
- package/dist/observe-event-log-Dnm76owp.d.ts +88 -0
- package/dist/operators/index.cjs +3774 -0
- package/dist/operators/index.cjs.map +1 -0
- package/dist/operators/index.d.cts +308 -0
- package/dist/operators/index.d.ts +308 -0
- package/dist/operators/index.js +112 -0
- package/dist/operators/index.js.map +1 -0
- package/dist/orchestration/index.cjs +3541 -0
- package/dist/orchestration/index.cjs.map +1 -0
- package/dist/orchestration/index.d.cts +302 -0
- package/dist/orchestration/index.d.ts +302 -0
- package/dist/orchestration/index.js +1004 -0
- package/dist/orchestration/index.js.map +1 -0
- package/dist/patterns/index.cjs +1045 -0
- package/dist/patterns/index.cjs.map +1 -0
- package/dist/patterns/index.d.cts +39 -0
- package/dist/patterns/index.d.ts +39 -0
- package/dist/patterns/index.js +33 -0
- package/dist/patterns/index.js.map +1 -0
- package/dist/reactive-collection-BxBqtIOE.d.cts +344 -0
- package/dist/reactive-collection-Cb1II1Fi.d.ts +344 -0
- package/dist/reactive-collection-storage-BNiEc-Gd.d.ts +217 -0
- package/dist/reactive-collection-storage-D-KmjE0J.d.cts +217 -0
- package/dist/reactive-map-BcB4KsQR.d.ts +256 -0
- package/dist/reactive-map-D-g3dv8I.d.cts +256 -0
- package/dist/read-through-B1CYPfq_.d.cts +82 -0
- package/dist/read-through-DwyJhGs1.d.ts +82 -0
- package/dist/render/index.cjs +250 -0
- package/dist/render/index.cjs.map +1 -0
- package/dist/render/index.d.cts +58 -0
- package/dist/render/index.d.ts +58 -0
- package/dist/render/index.js +20 -0
- package/dist/render/index.js.map +1 -0
- package/dist/resilience-Dig3Q7n0.d.cts +45 -0
- package/dist/resilience-Dig3Q7n0.d.ts +45 -0
- package/dist/semantic-memory-graph-BYoIlP35.d.cts +356 -0
- package/dist/semantic-memory-graph-CxyXLms3.d.ts +356 -0
- package/dist/solutions/index.cjs +3249 -0
- package/dist/solutions/index.cjs.map +1 -0
- package/dist/solutions/index.d.cts +520 -0
- package/dist/solutions/index.d.ts +520 -0
- package/dist/solutions/index.js +31 -0
- package/dist/solutions/index.js.map +1 -0
- package/dist/sources/browser.cjs +3095 -0
- package/dist/sources/browser.cjs.map +1 -0
- package/dist/sources/browser.d.cts +39 -0
- package/dist/sources/browser.d.ts +39 -0
- package/dist/sources/browser.js +137 -0
- package/dist/sources/browser.js.map +1 -0
- package/dist/sources/index.cjs +3021 -0
- package/dist/sources/index.cjs.map +1 -0
- package/dist/sources/index.d.cts +7 -0
- package/dist/sources/index.d.ts +7 -0
- package/dist/sources/index.js +63 -0
- package/dist/sources/index.js.map +1 -0
- package/dist/sources/node.cjs +675 -0
- package/dist/sources/node.cjs.map +1 -0
- package/dist/sources/node.d.cts +109 -0
- package/dist/sources/node.d.ts +109 -0
- package/dist/sources/node.js +639 -0
- package/dist/sources/node.js.map +1 -0
- package/dist/storage/browser.cjs +777 -0
- package/dist/storage/browser.cjs.map +1 -0
- package/dist/storage/browser.d.cts +40 -0
- package/dist/storage/browser.d.ts +40 -0
- package/dist/storage/browser.js +275 -0
- package/dist/storage/browser.js.map +1 -0
- package/dist/storage/index.cjs +1989 -0
- package/dist/storage/index.cjs.map +1 -0
- package/dist/storage/index.d.cts +92 -0
- package/dist/storage/index.d.ts +92 -0
- package/dist/storage/index.js +161 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/storage/node.cjs +898 -0
- package/dist/storage/node.cjs.map +1 -0
- package/dist/storage/node.d.cts +66 -0
- package/dist/storage/node.d.ts +66 -0
- package/dist/storage/node.js +402 -0
- package/dist/storage/node.js.map +1 -0
- package/dist/testing/index.cjs +95 -0
- package/dist/testing/index.cjs.map +1 -0
- package/dist/testing/index.d.cts +20 -0
- package/dist/testing/index.d.ts +20 -0
- package/dist/testing/index.js +8 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/types-bNMSWKqF.d.cts +732 -0
- package/dist/types-h12mNYbq.d.ts +732 -0
- package/package.json +250 -0
|
@@ -0,0 +1,554 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Node,
|
|
3
|
+
withNodeCore
|
|
4
|
+
} from "./chunk-I3IHOHCJ.js";
|
|
5
|
+
import {
|
|
6
|
+
strictJsonCodec
|
|
7
|
+
} from "./chunk-4VLAQHZI.js";
|
|
8
|
+
import {
|
|
9
|
+
depBatch,
|
|
10
|
+
depCount,
|
|
11
|
+
depLatest,
|
|
12
|
+
depTerminal,
|
|
13
|
+
isTerminalComplete,
|
|
14
|
+
isTerminalError,
|
|
15
|
+
terminalErrorValue
|
|
16
|
+
} from "./chunk-SWTLEQL6.js";
|
|
17
|
+
import {
|
|
18
|
+
SENTINEL,
|
|
19
|
+
errorPayload
|
|
20
|
+
} from "./chunk-DK554R7P.js";
|
|
21
|
+
|
|
22
|
+
// src/graph/checkpoint.ts
|
|
23
|
+
var GRAPH_CHECKPOINT_VERSION = "graphrefly.checkpoint.v1";
|
|
24
|
+
function toCheckpointJson(value, path = "$") {
|
|
25
|
+
try {
|
|
26
|
+
return strictJsonCodec.decode(strictJsonCodec.encode(value));
|
|
27
|
+
} catch (cause) {
|
|
28
|
+
throw new TypeError(`checkpoint: value at ${path} is not strict JSON compatible`, {
|
|
29
|
+
cause
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function checkpointValue(value, hasData, path) {
|
|
34
|
+
if (!hasData || value === SENTINEL) return { kind: "SENTINEL" };
|
|
35
|
+
return { kind: "DATA", data: toCheckpointJson(value, path) };
|
|
36
|
+
}
|
|
37
|
+
function checkpointTerminal(value, path) {
|
|
38
|
+
if (value === void 0) return { kind: "none" };
|
|
39
|
+
if (value === true) return { kind: "COMPLETE" };
|
|
40
|
+
return { kind: "ERROR", error: toCheckpointJson(value, path) };
|
|
41
|
+
}
|
|
42
|
+
var backendStateContributors = /* @__PURE__ */ new WeakMap();
|
|
43
|
+
function registerBackendStateContributor(node, contributor) {
|
|
44
|
+
backendStateContributors.set(node, contributor);
|
|
45
|
+
}
|
|
46
|
+
function checkpointBackendStateOfNode(node, path) {
|
|
47
|
+
const contributor = backendStateContributors.get(node);
|
|
48
|
+
if (contributor === void 0) return void 0;
|
|
49
|
+
return toCheckpointJson(contributor(), path);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// src/graph/operators.ts
|
|
53
|
+
function registryHas(registry, ref) {
|
|
54
|
+
return registry instanceof Map ? registry.has(ref) : Object.hasOwn(registry, ref);
|
|
55
|
+
}
|
|
56
|
+
function registrySet(registry, ref, entry) {
|
|
57
|
+
if (registryHas(registry, ref)) {
|
|
58
|
+
throw new Error(`restoreRegistry: duplicate ref '${ref}'`);
|
|
59
|
+
}
|
|
60
|
+
if (registry instanceof Map) registry.set(ref, entry);
|
|
61
|
+
else registry[ref] = entry;
|
|
62
|
+
}
|
|
63
|
+
function addToRestoreRegistry(registry, entry) {
|
|
64
|
+
registrySet(registry, entry.ref, entry);
|
|
65
|
+
}
|
|
66
|
+
function restoreRegistry(entries = [], base) {
|
|
67
|
+
const out = /* @__PURE__ */ new Map();
|
|
68
|
+
if (base instanceof Map) {
|
|
69
|
+
for (const [ref, entry] of base) registrySet(out, ref, entry);
|
|
70
|
+
} else if (base !== void 0) {
|
|
71
|
+
for (const [ref, entry] of Object.entries(base)) registrySet(out, ref, entry);
|
|
72
|
+
}
|
|
73
|
+
for (const entry of entries) addToRestoreRegistry(out, entry);
|
|
74
|
+
return out;
|
|
75
|
+
}
|
|
76
|
+
function isDefinition(fn) {
|
|
77
|
+
return typeof fn === "object" && fn !== null && fn.kind === "definition";
|
|
78
|
+
}
|
|
79
|
+
function define(ref, fn, opts = {}) {
|
|
80
|
+
const jsonRef = toCheckpointJson(ref, "define.ref");
|
|
81
|
+
if (typeof jsonRef !== "string") throw new TypeError("define: ref must be a string");
|
|
82
|
+
const definition = {
|
|
83
|
+
kind: "definition",
|
|
84
|
+
ref: jsonRef,
|
|
85
|
+
fn
|
|
86
|
+
};
|
|
87
|
+
if (opts.registry !== void 0) addToRestoreRegistry(opts.registry, definition);
|
|
88
|
+
return definition;
|
|
89
|
+
}
|
|
90
|
+
function initNode(op, deps, opts = {}) {
|
|
91
|
+
return makeInitNode(op, deps, opts);
|
|
92
|
+
}
|
|
93
|
+
function initNodeWithCore(core, op, deps, opts = {}) {
|
|
94
|
+
return withNodeCore(core, () => makeInitNode(op, deps, opts));
|
|
95
|
+
}
|
|
96
|
+
function makeInitNode(op, deps, opts) {
|
|
97
|
+
const body = operatorNodeFn(op);
|
|
98
|
+
return new Node([...deps], body, { factory: op.factory, ...op.opts, ...opts });
|
|
99
|
+
}
|
|
100
|
+
function operatorNodeFn(op) {
|
|
101
|
+
return (ctx) => {
|
|
102
|
+
try {
|
|
103
|
+
op.body(ctx);
|
|
104
|
+
} catch (e) {
|
|
105
|
+
ctx.down([["ERROR", errorPayload(e, "operator threw without a valid error payload")]]);
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
function map(fn) {
|
|
110
|
+
if (isDefinition(fn)) {
|
|
111
|
+
return mapFromFunction(fn.fn, {
|
|
112
|
+
ref: "map",
|
|
113
|
+
config: { fn: toCheckpointJson(fn.ref, `map.fn`) }
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
return mapFromFunction(fn);
|
|
117
|
+
}
|
|
118
|
+
function mapFromFunction(fn, restore) {
|
|
119
|
+
return {
|
|
120
|
+
factory: "map",
|
|
121
|
+
...restore ? { restore } : {},
|
|
122
|
+
body: (ctx) => {
|
|
123
|
+
const b = depBatch(ctx, 0);
|
|
124
|
+
if (!b) return;
|
|
125
|
+
for (const v of b) ctx.down([["DATA", fn(v)]]);
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
function filter(pred) {
|
|
130
|
+
return {
|
|
131
|
+
factory: "filter",
|
|
132
|
+
body: (ctx) => {
|
|
133
|
+
const b = depBatch(ctx, 0);
|
|
134
|
+
if (!b) return;
|
|
135
|
+
for (const v of b) if (pred(v)) ctx.down([["DATA", v]]);
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
function scan(reducer, seed) {
|
|
140
|
+
return {
|
|
141
|
+
factory: "scan",
|
|
142
|
+
body: (ctx) => {
|
|
143
|
+
const b = depBatch(ctx, 0);
|
|
144
|
+
if (!b) return;
|
|
145
|
+
let acc = ctx.state.get() ?? seed;
|
|
146
|
+
for (const v of b) {
|
|
147
|
+
acc = reducer(acc, v);
|
|
148
|
+
ctx.down([["DATA", acc]]);
|
|
149
|
+
}
|
|
150
|
+
ctx.state.set(acc);
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
function take(n) {
|
|
155
|
+
return {
|
|
156
|
+
factory: "take",
|
|
157
|
+
restore: { ref: "take", config: { n: toCheckpointJson(n, "take.n") } },
|
|
158
|
+
body: (ctx) => {
|
|
159
|
+
if (n <= 0) {
|
|
160
|
+
ctx.down([["COMPLETE"]]);
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
const b = depBatch(ctx, 0);
|
|
164
|
+
if (!b) return;
|
|
165
|
+
let count = ctx.state.get() ?? 0;
|
|
166
|
+
if (count >= n) return;
|
|
167
|
+
for (const v of b) {
|
|
168
|
+
if (count >= n) break;
|
|
169
|
+
count += 1;
|
|
170
|
+
ctx.down(count >= n ? [["DATA", v], ["COMPLETE"]] : [["DATA", v]]);
|
|
171
|
+
}
|
|
172
|
+
ctx.state.set(count);
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
function distinctUntilChanged(eq = Object.is) {
|
|
177
|
+
return {
|
|
178
|
+
factory: "distinctUntilChanged",
|
|
179
|
+
body: (ctx) => {
|
|
180
|
+
const b = depBatch(ctx, 0);
|
|
181
|
+
if (!b) return;
|
|
182
|
+
const prev = ctx.state.get();
|
|
183
|
+
let last2 = prev?.v;
|
|
184
|
+
let hasLast = prev !== void 0;
|
|
185
|
+
for (const v of b) {
|
|
186
|
+
if (hasLast && eq(last2, v)) continue;
|
|
187
|
+
last2 = v;
|
|
188
|
+
hasLast = true;
|
|
189
|
+
ctx.down([["DATA", v]]);
|
|
190
|
+
}
|
|
191
|
+
if (hasLast) ctx.state.set({ v: last2 });
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
function merge() {
|
|
196
|
+
return {
|
|
197
|
+
factory: "merge",
|
|
198
|
+
opts: { partial: true },
|
|
199
|
+
body: (ctx) => {
|
|
200
|
+
for (let i = 0; i < depCount(ctx); i++) {
|
|
201
|
+
const b = depBatch(ctx, i);
|
|
202
|
+
if (b && b.length > 0) {
|
|
203
|
+
for (const v of b) ctx.down([["DATA", v]]);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
function reduce(reducer, seed) {
|
|
210
|
+
return {
|
|
211
|
+
factory: "reduce",
|
|
212
|
+
opts: { completeWhenDepsComplete: false, terminalAsRealInput: true },
|
|
213
|
+
body: (ctx) => {
|
|
214
|
+
const b = depBatch(ctx, 0);
|
|
215
|
+
let acc = ctx.state.get() ?? seed;
|
|
216
|
+
if (b) for (const v of b) acc = reducer(acc, v);
|
|
217
|
+
ctx.state.set(acc);
|
|
218
|
+
if (isTerminalComplete(depTerminal(ctx, 0))) ctx.down([["DATA", acc], ["COMPLETE"]]);
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
function pairwise() {
|
|
223
|
+
return {
|
|
224
|
+
factory: "pairwise",
|
|
225
|
+
body: (ctx) => {
|
|
226
|
+
const b = depBatch(ctx, 0);
|
|
227
|
+
if (!b) return;
|
|
228
|
+
const st = ctx.state.get();
|
|
229
|
+
let prev = st?.prev;
|
|
230
|
+
let hasPrev = st !== void 0;
|
|
231
|
+
for (const v of b) {
|
|
232
|
+
if (hasPrev) ctx.down([["DATA", [prev, v]]]);
|
|
233
|
+
prev = v;
|
|
234
|
+
hasPrev = true;
|
|
235
|
+
}
|
|
236
|
+
if (hasPrev) ctx.state.set({ prev });
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
function skip(n) {
|
|
241
|
+
return {
|
|
242
|
+
factory: "skip",
|
|
243
|
+
body: (ctx) => {
|
|
244
|
+
const b = depBatch(ctx, 0);
|
|
245
|
+
if (!b) return;
|
|
246
|
+
let count = ctx.state.get() ?? 0;
|
|
247
|
+
for (const v of b) {
|
|
248
|
+
if (count < n) {
|
|
249
|
+
count += 1;
|
|
250
|
+
continue;
|
|
251
|
+
}
|
|
252
|
+
ctx.down([["DATA", v]]);
|
|
253
|
+
}
|
|
254
|
+
ctx.state.set(count);
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
function takeWhile(pred) {
|
|
259
|
+
return {
|
|
260
|
+
factory: "takeWhile",
|
|
261
|
+
body: (ctx) => {
|
|
262
|
+
const b = depBatch(ctx, 0);
|
|
263
|
+
if (!b) return;
|
|
264
|
+
for (const v of b) {
|
|
265
|
+
if (pred(v)) ctx.down([["DATA", v]]);
|
|
266
|
+
else {
|
|
267
|
+
ctx.down([["COMPLETE"]]);
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
function first(pred) {
|
|
275
|
+
return {
|
|
276
|
+
factory: "first",
|
|
277
|
+
body: (ctx) => {
|
|
278
|
+
const b = depBatch(ctx, 0);
|
|
279
|
+
if (!b) return;
|
|
280
|
+
for (const v of b) {
|
|
281
|
+
if (!pred || pred(v)) {
|
|
282
|
+
ctx.down([["DATA", v], ["COMPLETE"]]);
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
function last(pred) {
|
|
290
|
+
return {
|
|
291
|
+
factory: "last",
|
|
292
|
+
opts: { completeWhenDepsComplete: false, terminalAsRealInput: true },
|
|
293
|
+
body: (ctx) => {
|
|
294
|
+
const b = depBatch(ctx, 0);
|
|
295
|
+
if (b) {
|
|
296
|
+
for (const v of b) if (!pred || pred(v)) ctx.state.set({ v });
|
|
297
|
+
}
|
|
298
|
+
if (isTerminalComplete(depTerminal(ctx, 0))) {
|
|
299
|
+
const st = ctx.state.get();
|
|
300
|
+
ctx.down(st ? [["DATA", st.v], ["COMPLETE"]] : [["COMPLETE"]]);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
function find(pred) {
|
|
306
|
+
return {
|
|
307
|
+
factory: "find",
|
|
308
|
+
opts: { completeWhenDepsComplete: false, terminalAsRealInput: true },
|
|
309
|
+
body: (ctx) => {
|
|
310
|
+
const b = depBatch(ctx, 0);
|
|
311
|
+
if (b) {
|
|
312
|
+
for (const v of b) {
|
|
313
|
+
if (pred(v)) {
|
|
314
|
+
ctx.down([["DATA", v], ["COMPLETE"]]);
|
|
315
|
+
return;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
if (isTerminalComplete(depTerminal(ctx, 0))) ctx.down([["COMPLETE"]]);
|
|
320
|
+
}
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
function elementAt(index) {
|
|
324
|
+
return {
|
|
325
|
+
factory: "elementAt",
|
|
326
|
+
opts: { completeWhenDepsComplete: false, terminalAsRealInput: true },
|
|
327
|
+
body: (ctx) => {
|
|
328
|
+
const b = depBatch(ctx, 0);
|
|
329
|
+
let count = ctx.state.get() ?? 0;
|
|
330
|
+
if (b) {
|
|
331
|
+
for (const v of b) {
|
|
332
|
+
if (count === index) {
|
|
333
|
+
ctx.down([["DATA", v], ["COMPLETE"]]);
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
count++;
|
|
337
|
+
}
|
|
338
|
+
ctx.state.set(count);
|
|
339
|
+
}
|
|
340
|
+
if (isTerminalComplete(depTerminal(ctx, 0))) ctx.down([["COMPLETE"]]);
|
|
341
|
+
}
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
function tap(fnOrObserver) {
|
|
345
|
+
if (typeof fnOrObserver === "function") {
|
|
346
|
+
const fn = fnOrObserver;
|
|
347
|
+
return {
|
|
348
|
+
factory: "tap",
|
|
349
|
+
body: (ctx) => {
|
|
350
|
+
const b = depBatch(ctx, 0);
|
|
351
|
+
if (b)
|
|
352
|
+
for (const v of b) {
|
|
353
|
+
fn(v);
|
|
354
|
+
ctx.down([["DATA", v]]);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
const obs = fnOrObserver;
|
|
360
|
+
return {
|
|
361
|
+
factory: "tap",
|
|
362
|
+
opts: {
|
|
363
|
+
completeWhenDepsComplete: false,
|
|
364
|
+
errorWhenDepsError: false,
|
|
365
|
+
terminalAsRealInput: true
|
|
366
|
+
},
|
|
367
|
+
body: (ctx) => {
|
|
368
|
+
const terminal = depTerminal(ctx, 0);
|
|
369
|
+
if (isTerminalComplete(terminal)) {
|
|
370
|
+
obs.complete?.();
|
|
371
|
+
ctx.down([["COMPLETE"]]);
|
|
372
|
+
return;
|
|
373
|
+
}
|
|
374
|
+
if (isTerminalError(terminal)) {
|
|
375
|
+
const err = terminalErrorValue(terminal);
|
|
376
|
+
obs.error?.(err);
|
|
377
|
+
ctx.down([["ERROR", err]]);
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
380
|
+
const b = depBatch(ctx, 0);
|
|
381
|
+
if (b)
|
|
382
|
+
for (const v of b) {
|
|
383
|
+
obs.data?.(v);
|
|
384
|
+
ctx.down([["DATA", v]]);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
function onFirstData(fn, opts) {
|
|
390
|
+
const where = opts?.where ?? ((v) => v != null);
|
|
391
|
+
return {
|
|
392
|
+
factory: "onFirstData",
|
|
393
|
+
body: (ctx) => {
|
|
394
|
+
const b = depBatch(ctx, 0);
|
|
395
|
+
if (!b) return;
|
|
396
|
+
let fired = ctx.state.get() ?? false;
|
|
397
|
+
for (const v of b) {
|
|
398
|
+
if (!fired && where(v)) {
|
|
399
|
+
fired = true;
|
|
400
|
+
fn(v);
|
|
401
|
+
}
|
|
402
|
+
ctx.down([["DATA", v]]);
|
|
403
|
+
}
|
|
404
|
+
ctx.state.set(fired);
|
|
405
|
+
}
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
var tapFirst = onFirstData;
|
|
409
|
+
function settle(opts) {
|
|
410
|
+
const { quietWaves, maxWaves, equals } = opts;
|
|
411
|
+
if (!Number.isInteger(quietWaves) || quietWaves < 1) {
|
|
412
|
+
throw new RangeError(`settle: quietWaves must be a positive integer (got ${quietWaves})`);
|
|
413
|
+
}
|
|
414
|
+
if (maxWaves != null && (!Number.isInteger(maxWaves) || maxWaves < 1)) {
|
|
415
|
+
throw new RangeError(`settle: maxWaves must be a positive integer when set (got ${maxWaves})`);
|
|
416
|
+
}
|
|
417
|
+
return {
|
|
418
|
+
factory: "settle",
|
|
419
|
+
body: (ctx) => {
|
|
420
|
+
const st = ctx.state.get() ?? {
|
|
421
|
+
last: void 0,
|
|
422
|
+
hasValue: false,
|
|
423
|
+
quiet: 0,
|
|
424
|
+
waves: 0,
|
|
425
|
+
done: false
|
|
426
|
+
};
|
|
427
|
+
if (st.done) return;
|
|
428
|
+
st.waves++;
|
|
429
|
+
const b = depBatch(ctx, 0);
|
|
430
|
+
let sawChange = false;
|
|
431
|
+
if (b && b.length > 0) {
|
|
432
|
+
for (const v of b) {
|
|
433
|
+
const next = v;
|
|
434
|
+
const isChange = !st.hasValue || equals == null || !equals(st.last, next);
|
|
435
|
+
if (isChange) sawChange = true;
|
|
436
|
+
st.last = next;
|
|
437
|
+
st.hasValue = true;
|
|
438
|
+
ctx.down([["DATA", next]]);
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
st.quiet = sawChange ? 0 : st.quiet + 1;
|
|
442
|
+
const settled = st.hasValue && st.quiet >= quietWaves;
|
|
443
|
+
const exhausted = maxWaves != null && st.waves >= maxWaves;
|
|
444
|
+
if (settled || exhausted) {
|
|
445
|
+
st.done = true;
|
|
446
|
+
ctx.state.set(st);
|
|
447
|
+
ctx.down([["COMPLETE"]]);
|
|
448
|
+
return;
|
|
449
|
+
}
|
|
450
|
+
ctx.state.set(st);
|
|
451
|
+
}
|
|
452
|
+
};
|
|
453
|
+
}
|
|
454
|
+
function rescue(recover) {
|
|
455
|
+
return {
|
|
456
|
+
factory: "rescue",
|
|
457
|
+
opts: {
|
|
458
|
+
errorWhenDepsError: false,
|
|
459
|
+
completeWhenDepsComplete: false,
|
|
460
|
+
terminalAsRealInput: true
|
|
461
|
+
},
|
|
462
|
+
body: (ctx) => {
|
|
463
|
+
const b = depBatch(ctx, 0);
|
|
464
|
+
const terminal = depTerminal(ctx, 0);
|
|
465
|
+
if (b) for (const v of b) ctx.down([["DATA", v]]);
|
|
466
|
+
if (isTerminalComplete(terminal)) {
|
|
467
|
+
ctx.down([["COMPLETE"]]);
|
|
468
|
+
} else if (isTerminalError(terminal)) {
|
|
469
|
+
try {
|
|
470
|
+
ctx.down([["DATA", recover(terminalErrorValue(terminal))]]);
|
|
471
|
+
} catch (e) {
|
|
472
|
+
ctx.down([["ERROR", errorPayload(e, "rescue threw without a valid error payload")]]);
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
};
|
|
477
|
+
}
|
|
478
|
+
var catchError = rescue;
|
|
479
|
+
function valve(opts) {
|
|
480
|
+
const abortInFlight = opts?.abortInFlight;
|
|
481
|
+
return {
|
|
482
|
+
factory: "valve",
|
|
483
|
+
opts: { partial: true, completeWhenDepsComplete: false, terminalAsRealInput: true },
|
|
484
|
+
body: (ctx) => {
|
|
485
|
+
const srcBatch = depBatch(ctx, 0);
|
|
486
|
+
const ctlBatch = depBatch(ctx, 1);
|
|
487
|
+
const srcTerminal = depTerminal(ctx, 0);
|
|
488
|
+
const controlValue = depLatest(ctx, 1);
|
|
489
|
+
if (abortInFlight != null) {
|
|
490
|
+
const prev = ctx.state.get();
|
|
491
|
+
if (prev?.ctl === true && !controlValue) {
|
|
492
|
+
const c = typeof abortInFlight === "function" ? abortInFlight() : abortInFlight;
|
|
493
|
+
c?.abort();
|
|
494
|
+
}
|
|
495
|
+
ctx.state.set({
|
|
496
|
+
ctl: controlValue === true ? true : controlValue == null ? void 0 : false
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
if (isTerminalComplete(srcTerminal)) {
|
|
500
|
+
ctx.down([["COMPLETE"]]);
|
|
501
|
+
return;
|
|
502
|
+
}
|
|
503
|
+
if (isTerminalError(srcTerminal)) {
|
|
504
|
+
ctx.down([["ERROR", terminalErrorValue(srcTerminal)]]);
|
|
505
|
+
return;
|
|
506
|
+
}
|
|
507
|
+
if (!controlValue) return;
|
|
508
|
+
if (srcBatch && srcBatch.length > 0) {
|
|
509
|
+
for (const v of srcBatch) ctx.down([["DATA", v]]);
|
|
510
|
+
return;
|
|
511
|
+
}
|
|
512
|
+
const srcLatest = depLatest(ctx, 0);
|
|
513
|
+
if (ctlBatch && ctlBatch.length > 0 && srcLatest !== void 0) {
|
|
514
|
+
ctx.down([["DATA", srcLatest]]);
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
};
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
export {
|
|
521
|
+
GRAPH_CHECKPOINT_VERSION,
|
|
522
|
+
toCheckpointJson,
|
|
523
|
+
checkpointValue,
|
|
524
|
+
checkpointTerminal,
|
|
525
|
+
registerBackendStateContributor,
|
|
526
|
+
checkpointBackendStateOfNode,
|
|
527
|
+
restoreRegistry,
|
|
528
|
+
define,
|
|
529
|
+
initNode,
|
|
530
|
+
initNodeWithCore,
|
|
531
|
+
operatorNodeFn,
|
|
532
|
+
map,
|
|
533
|
+
filter,
|
|
534
|
+
scan,
|
|
535
|
+
take,
|
|
536
|
+
distinctUntilChanged,
|
|
537
|
+
merge,
|
|
538
|
+
reduce,
|
|
539
|
+
pairwise,
|
|
540
|
+
skip,
|
|
541
|
+
takeWhile,
|
|
542
|
+
first,
|
|
543
|
+
last,
|
|
544
|
+
find,
|
|
545
|
+
elementAt,
|
|
546
|
+
tap,
|
|
547
|
+
onFirstData,
|
|
548
|
+
tapFirst,
|
|
549
|
+
settle,
|
|
550
|
+
rescue,
|
|
551
|
+
catchError,
|
|
552
|
+
valve
|
|
553
|
+
};
|
|
554
|
+
//# sourceMappingURL=chunk-PKVBHGBM.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/graph/checkpoint.ts","../src/graph/operators.ts"],"sourcesContent":["/**\n * Graph checkpoint public data shape (D83/D86/D90/D116).\n *\n * Checkpoint is a graph lifecycle snapshot: strict-JSON-compatible data, no storage I/O,\n * no observe-log replay, and no restore runtime in this first TS slice.\n */\n\nimport { type StrictJsonValue, strictJsonCodec } from \"../json/codec.js\";\nimport type { Node } from \"../node/node.js\";\nimport type { NodeVersionJson } from \"../node/versioning.js\";\nimport { SENTINEL } from \"../protocol/messages.js\";\n\nexport const GRAPH_CHECKPOINT_VERSION = \"graphrefly.checkpoint.v1\" as const;\n\nexport type GraphCheckpointVersion = typeof GRAPH_CHECKPOINT_VERSION;\n\nexport type GraphCheckpointJson = StrictJsonValue;\n\nexport type GraphCheckpointValue =\n\t| { kind: \"SENTINEL\" }\n\t| { kind: \"DATA\"; data: GraphCheckpointJson };\n\nexport type GraphCheckpointTerminal =\n\t| { kind: \"none\" }\n\t| { kind: \"COMPLETE\" }\n\t| { kind: \"ERROR\"; error: GraphCheckpointJson };\n\nexport type GraphCheckpointFactory =\n\t| {\n\t\t\tkind: \"registry-ref\";\n\t\t\tref: string;\n\t\t\tconfig?: GraphCheckpointJson;\n\t\t\tconfigVersion?: GraphCheckpointJson;\n\t }\n\t| { kind: \"local-only\"; name: string; reason: string };\n\nexport interface GraphCheckpointNode {\n\tid: string;\n\tname?: string;\n\tfactory: GraphCheckpointFactory;\n\tstatus: string;\n\tdeps: string[];\n\tvalue: GraphCheckpointValue;\n\tbackendState?: GraphCheckpointJson;\n\tversion?: NodeVersionJson;\n\tterminal: GraphCheckpointTerminal;\n\tlifecycle: { activated: boolean; hasCalledFnOnce: boolean };\n\tctxState: { persist: boolean; value: GraphCheckpointValue };\n\tmeta?: { [key: string]: GraphCheckpointJson };\n}\n\nexport interface GraphCheckpointEdge {\n\tfrom: string;\n\tto: string;\n}\n\nexport interface GraphCheckpointMount {\n\tat: string;\n\tcheckpoint: GraphCheckpoint;\n}\n\nexport interface GraphCheckpoint {\n\tversion: GraphCheckpointVersion;\n\tname?: string;\n\tnodes: GraphCheckpointNode[];\n\tedges: GraphCheckpointEdge[];\n\tmounts?: GraphCheckpointMount[];\n}\n\nexport function toCheckpointJson(value: unknown, path = \"$\"): GraphCheckpointJson {\n\ttry {\n\t\treturn strictJsonCodec.decode(strictJsonCodec.encode(value)) as GraphCheckpointJson;\n\t} catch (cause) {\n\t\tthrow new TypeError(`checkpoint: value at ${path} is not strict JSON compatible`, {\n\t\t\tcause,\n\t\t});\n\t}\n}\n\nexport function checkpointValue(\n\tvalue: unknown,\n\thasData: boolean,\n\tpath: string,\n): GraphCheckpointValue {\n\tif (!hasData || value === SENTINEL) return { kind: \"SENTINEL\" };\n\treturn { kind: \"DATA\", data: toCheckpointJson(value, path) };\n}\n\nexport function checkpointTerminal(value: unknown, path: string): GraphCheckpointTerminal {\n\tif (value === undefined) return { kind: \"none\" };\n\tif (value === true) return { kind: \"COMPLETE\" };\n\treturn { kind: \"ERROR\", error: toCheckpointJson(value, path) };\n}\n\ntype BackendStateContributor = () => unknown;\n\nconst backendStateContributors = new WeakMap<Node<unknown>, BackendStateContributor>();\n\n/** @internal D160: collection-owned backend checkpoint contributor for graph checkpoint. */\nexport function registerBackendStateContributor(\n\tnode: Node<unknown>,\n\tcontributor: BackendStateContributor,\n): void {\n\tbackendStateContributors.set(node, contributor);\n}\n\n/** @internal D160: capture a node's collection backend state when it has a contributor. */\nexport function checkpointBackendStateOfNode(\n\tnode: Node<unknown>,\n\tpath: string,\n): GraphCheckpointJson | undefined {\n\tconst contributor = backendStateContributors.get(node);\n\tif (contributor === undefined) return undefined;\n\treturn toCheckpointJson(contributor(), path);\n}\n","/**\n * Operators as free-standing factory definitions (D43 / D6 / D40 Catalog-first).\n *\n * Operators are `node` sugar (D6), NOT verbs (D4) and NEVER in parity (D24). Each is a\n * pure {@link Operator} spec — `{factory, body, opts}` — built on the bare `node` primitive\n * (NOT the `derived` verb): `body` reads ctx dep slots positionally and emits via\n * `ctx.down`. Two ways to instantiate:\n *\n * - {@link initNode}(op, deps, opts?) — bare, no Graph; returns a working `Node<T>`.\n * - `g.initNode(op, deps, opts?)` — graph-bound; the SAME call, plus inspection registration\n * (the real factory name lands in the graph's `_entries`, so describe/observe/profile\n * show it — D6/R-describe — while the node stays thin, R-node-thin).\n *\n * The D30 throw→ERROR boundary lives once, in the free {@link initNode} (which `g.initNode`\n * funnels through). The pure-ts `operatorOpts/partialOperatorOpts/gatedOperatorOpts` trio is\n * NOT ported: its sole job (`describeKind:\"derived\"`) is dead under D6/D39 (factory = the\n * REAL operator name); only the `partial`/`terminalAsRealInput` flags survive, carried\n * per-operator in `op.opts`.\n *\n * Config is folded into the factory (`map(fn)`, `scan(reducer, seed)`, `take(n)`, `merge()`),\n * so fn params are annotated where the source type can't be inferred (RxJS-pipe cost);\n * dep-type safety is recovered by the typed `g.initNode` overloads.\n */\n\nimport {\n\ttype Ctx,\n\tdepBatch,\n\tdepCount,\n\tdepLatest,\n\tdepTerminal,\n\tisTerminalComplete,\n\tisTerminalError,\n\ttype NodeFn,\n\tterminalErrorValue,\n} from \"../ctx/types.js\";\nimport type { NodeCore } from \"../node/core.js\";\nimport { Node, type NodeOptions, withNodeCore } from \"../node/node.js\";\nimport { errorPayload } from \"../protocol/messages.js\";\nimport { type GraphCheckpointJson, toCheckpointJson } from \"./checkpoint.js\";\nimport type { GraphRestoreDefinition, GraphRestoreEntry, GraphRestoreRegistry } from \"./restore.js\";\n\n/**\n * A free-standing operator definition (D43). `TIn` = the element type each dep delivers\n * (the operator reads `depLatest(ctx, i) as TIn`); `TOut` = the emitted value type.\n * `__in`/`__out` are phantom-only (never assigned) — they let `g.initNode` infer + check the\n * dep tuple against the operator without an explicit type argument.\n */\nexport interface Operator<TIn = unknown, TOut = unknown> {\n\t/** Real operator name shown in describe (D6/L1.5) — recorded at `_add` by `g.initNode`. */\n\treadonly factory: string;\n\t/** The ctx-body: reads ctx dep slots positionally, emits via `ctx.down`. */\n\treadonly body: (ctx: Ctx) => void;\n\t/** Behavioral node options the operator needs (e.g. `partial:true` for combine-family). */\n\treadonly opts?: Partial<NodeOptions<TOut>>;\n\t/**\n\t * D97/D100 restore metadata derived from a named definition or static built-in config.\n\t * This is semantic metadata only; dispatcher handles stay graph-local runtime state.\n\t */\n\treadonly restore?: {\n\t\tref: string;\n\t\tconfig?: GraphCheckpointJson;\n\t\tconfigVersion?: GraphCheckpointJson;\n\t};\n\t/** @internal phantom — never set; carries the dep element type for `g.initNode` inference. */\n\treadonly __in?: TIn;\n\t/** @internal phantom — never set; carries the output value type. */\n\treadonly __out?: TOut;\n}\n\ntype MutableRestoreRegistry = Map<string, GraphRestoreEntry> | Record<string, GraphRestoreEntry>;\n\nexport type RestoreRegistryEntry = GraphRestoreEntry;\n\nexport interface Definition<S = unknown, T = unknown> extends GraphRestoreDefinition<S, T> {\n\treadonly ref: string;\n\treadonly fn: (v: S) => T;\n}\n\nexport interface DefineOpts {\n\tregistry?: MutableRestoreRegistry;\n}\n\nfunction registryHas(registry: MutableRestoreRegistry, ref: string): boolean {\n\treturn registry instanceof Map ? registry.has(ref) : Object.hasOwn(registry, ref);\n}\n\nfunction registrySet(\n\tregistry: MutableRestoreRegistry,\n\tref: string,\n\tentry: GraphRestoreEntry,\n): void {\n\tif (registryHas(registry, ref)) {\n\t\tthrow new Error(`restoreRegistry: duplicate ref '${ref}'`);\n\t}\n\tif (registry instanceof Map) registry.set(ref, entry);\n\telse registry[ref] = entry;\n}\n\nexport function addToRestoreRegistry(\n\tregistry: MutableRestoreRegistry,\n\tentry: GraphRestoreEntry,\n): void {\n\tregistrySet(registry, entry.ref, entry);\n}\n\nexport function restoreRegistry(\n\tentries: readonly GraphRestoreEntry[] = [],\n\tbase?: GraphRestoreRegistry,\n): Map<string, GraphRestoreEntry> {\n\tconst out = new Map<string, GraphRestoreEntry>();\n\tif (base instanceof Map) {\n\t\tfor (const [ref, entry] of base) registrySet(out, ref, entry);\n\t} else if (base !== undefined) {\n\t\tfor (const [ref, entry] of Object.entries(base)) registrySet(out, ref, entry);\n\t}\n\tfor (const entry of entries) addToRestoreRegistry(out, entry);\n\treturn out;\n}\n\nfunction isDefinition<S, T>(fn: ((v: S) => T) | Definition<S, T>): fn is Definition<S, T> {\n\treturn typeof fn === \"object\" && fn !== null && (fn as Definition<S, T>).kind === \"definition\";\n}\n\nexport function define<S, T>(\n\tref: string,\n\tfn: (v: S) => T,\n\topts: DefineOpts = {},\n): Definition<S, T> {\n\tconst jsonRef = toCheckpointJson(ref, \"define.ref\");\n\tif (typeof jsonRef !== \"string\") throw new TypeError(\"define: ref must be a string\");\n\tconst definition: Definition<S, T> = {\n\t\tkind: \"definition\",\n\t\tref: jsonRef,\n\t\tfn,\n\t};\n\tif (opts.registry !== undefined) addToRestoreRegistry(opts.registry, definition);\n\treturn definition;\n}\n\n/**\n * Instantiate an operator as a bare `Node<T>` — NO Graph required (D43 bare-node path).\n * Wraps `op.body` in the D30 value-throw→ERROR boundary; merges `op.opts` with caller `opts`\n * (caller wins, so `partial`/`pool`/`dispatcher` overrides take effect). The\n * dispatcher defaults to the process-global (D26) unless `opts.dispatcher` is passed.\n *\n * `g.initNode` is the same call PLUS graph registration; graph inspection\n * (describe/observe/profile) requires that path — a node built bare here is not registered in\n * any graph's index.\n */\nexport function initNode<TIn, TOut>(\n\top: Operator<TIn, TOut>,\n\tdeps: readonly Node<unknown>[],\n\topts: NodeOptions<TOut> = {},\n): Node<TOut> {\n\treturn makeInitNode(op, deps, opts);\n}\n\n/** @internal Graph-bound operator instantiation into a graph-local B49 core. */\nexport function initNodeWithCore<TIn, TOut>(\n\tcore: NodeCore,\n\top: Operator<TIn, TOut>,\n\tdeps: readonly Node<unknown>[],\n\topts: NodeOptions<TOut> = {},\n): Node<TOut> {\n\treturn withNodeCore(core, () => makeInitNode(op, deps, opts));\n}\n\nfunction makeInitNode<TIn, TOut>(\n\top: Operator<TIn, TOut>,\n\tdeps: readonly Node<unknown>[],\n\topts: NodeOptions<TOut>,\n): Node<TOut> {\n\tconst body = operatorNodeFn(op);\n\t// D43-reserved / D51: stamp the operator's real factory onto the bare node so a runtime *Map\n\t// inner (created here via fromAny, NOT registered in any graph) is named in describe's\n\t// auto-discovery. A graph-bound g.initNode also records it in `_entries` (entry.factory wins\n\t// there); this field is only read for a node absent from the graph index. Caller opts win.\n\treturn new Node<TOut>([...deps], body, { factory: op.factory, ...op.opts, ...opts });\n}\n\n/** @internal Build the dispatcher body for an Operator spec. */\nexport function operatorNodeFn<TIn, TOut>(op: Operator<TIn, TOut>): NodeFn {\n\treturn (ctx) => {\n\t\ttry {\n\t\t\top.body(ctx);\n\t\t} catch (e) {\n\t\t\tctx.down([[\"ERROR\", errorPayload(e, \"operator threw without a valid error payload\")]]); // D30: value-level throw → ERROR\n\t\t}\n\t};\n}\n\n// ── Slice 1 — single-dep map / take / control (CSP-2.7 catalog re-derive, D40) ──\n// All read dep 0 positionally + emit via ctx.down. Under D49 every occurrence is DATA (no\n// equals-absorption); a body that returns WITHOUT emitting gets a substrate-synthesized undirty\n// RESOLVED (R-resolved-undirty) — so a \"skip this wave\" is a bare `return`. Terminal-emitting\n// operators (reduce/last/find/elementAt) read `depTerminal(ctx, 0)` via the\n// `completeWhenDepsComplete:false + terminalAsRealInput:true` flags (R-deps-terminal): the fn fires\n// on the source's COMPLETE and emits its final value. NOT 1:1 pure-ts ports — the frozen reference\n// (D41) uses a producer + internal `subscribeOr`, the D45-banned describe island; these are\n// declared-dep nodes whose single edge `describe` shows truthfully.\n\n/** map: emit fn(value). A named {@link define} makes the map restorable via the map descriptor (D101). */\nexport function map<S, T>(fn: ((v: S) => T) | Definition<S, T>): Operator<S, T> {\n\tif (isDefinition(fn)) {\n\t\treturn mapFromFunction(fn.fn, {\n\t\t\tref: \"map\",\n\t\t\tconfig: { fn: toCheckpointJson(fn.ref, `map.fn`) },\n\t\t});\n\t}\n\treturn mapFromFunction(fn);\n}\n\nfunction mapFromFunction<S, T>(\n\tfn: (v: S) => T,\n\trestore?: {\n\t\tref: string;\n\t\tconfig?: GraphCheckpointJson;\n\t\tconfigVersion?: GraphCheckpointJson;\n\t},\n): Operator<S, T> {\n\treturn {\n\t\tfactory: \"map\",\n\t\t...(restore ? { restore } : {}),\n\t\tbody: (ctx) => {\n\t\t\tconst b = depBatch(ctx, 0);\n\t\t\tif (!b) return;\n\t\t\tfor (const v of b) ctx.down([[\"DATA\", fn(v as S)]]);\n\t\t},\n\t};\n}\n\n/** filter: emit value only when pred(value) (else skip the wave). */\nexport function filter<S>(pred: (v: S) => boolean): Operator<S, S> {\n\treturn {\n\t\tfactory: \"filter\",\n\t\tbody: (ctx) => {\n\t\t\tconst b = depBatch(ctx, 0);\n\t\t\tif (!b) return;\n\t\t\tfor (const v of b) if (pred(v as S)) ctx.down([[\"DATA\", v]]);\n\t\t},\n\t};\n}\n\n/** scan: stateful accumulator over the upstream (acc seeded once, kept in ctx.state). */\nexport function scan<S, T>(reducer: (acc: T, v: S) => T, seed: T): Operator<S, T> {\n\treturn {\n\t\tfactory: \"scan\",\n\t\tbody: (ctx) => {\n\t\t\tconst b = depBatch(ctx, 0);\n\t\t\tif (!b) return;\n\t\t\tlet acc = ctx.state.get<T>() ?? seed;\n\t\t\tfor (const v of b) {\n\t\t\t\tacc = reducer(acc, v as S);\n\t\t\t\tctx.down([[\"DATA\", acc]]);\n\t\t\t}\n\t\t\tctx.state.set(acc);\n\t\t},\n\t};\n}\n\n/** take: emit the first n values, then COMPLETE (terminal-is-forever). */\nexport function take<S>(n: number): Operator<S, S> {\n\treturn {\n\t\tfactory: \"take\",\n\t\trestore: { ref: \"take\", config: { n: toCheckpointJson(n, \"take.n\") } },\n\t\tbody: (ctx) => {\n\t\t\tif (n <= 0) {\n\t\t\t\tctx.down([[\"COMPLETE\"]]);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst b = depBatch(ctx, 0);\n\t\t\tif (!b) return;\n\t\t\tlet count = ctx.state.get<number>() ?? 0;\n\t\t\tif (count >= n) return; // already satisfied\n\t\t\tfor (const v of b) {\n\t\t\t\tif (count >= n) break;\n\t\t\t\tcount += 1;\n\t\t\t\tctx.down(count >= n ? [[\"DATA\", v], [\"COMPLETE\"]] : [[\"DATA\", v]]);\n\t\t\t}\n\t\t\tctx.state.set(count);\n\t\t},\n\t};\n}\n\n/** distinctUntilChanged: emit only when the value differs from the previous emit. */\nexport function distinctUntilChanged<S>(eq: (a: S, b: S) => boolean = Object.is): Operator<S, S> {\n\treturn {\n\t\tfactory: \"distinctUntilChanged\",\n\t\tbody: (ctx) => {\n\t\t\tconst b = depBatch(ctx, 0);\n\t\t\tif (!b) return;\n\t\t\tconst prev = ctx.state.get<{ v: S }>();\n\t\t\tlet last = prev?.v;\n\t\t\tlet hasLast = prev !== undefined;\n\t\t\tfor (const v of b as readonly S[]) {\n\t\t\t\tif (hasLast && eq(last as S, v)) continue;\n\t\t\t\tlast = v;\n\t\t\t\thasLast = true;\n\t\t\t\tctx.down([[\"DATA\", v]]);\n\t\t\t}\n\t\t\tif (hasLast) ctx.state.set({ v: last as S });\n\t\t},\n\t};\n}\n\n/**\n * merge: interleave several sources — emit each DATA from whichever dep fired. `partial:true`\n * (combine-family): fires on any single dep, not gated on all deps settling.\n */\nexport function merge<T>(): Operator<T, T> {\n\treturn {\n\t\tfactory: \"merge\",\n\t\topts: { partial: true },\n\t\tbody: (ctx) => {\n\t\t\tfor (let i = 0; i < depCount(ctx); i++) {\n\t\t\t\tconst b = depBatch(ctx, i);\n\t\t\t\tif (b && b.length > 0) {\n\t\t\t\t\tfor (const v of b) ctx.down([[\"DATA\", v]]);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t};\n}\n\n/**\n * reduce: accumulate over the whole source, emit ONE final value on the source's COMPLETE\n * (RxJS `reduce`). Unlike {@link scan} (which emits every step), reduce stays quiet until the\n * source terminates. `completeWhenDepsComplete:false + terminalAsRealInput:true`: the fn fires on\n * the source COMPLETE (reading `terminal===true`) and emits the accumulator + COMPLETE. An empty\n * source emits the seed (RxJS parity). A source ERROR auto-forwards (errorWhenDepsError default).\n */\nexport function reduce<S, T>(reducer: (acc: T, v: S) => T, seed: T): Operator<S, T> {\n\treturn {\n\t\tfactory: \"reduce\",\n\t\topts: { completeWhenDepsComplete: false, terminalAsRealInput: true },\n\t\tbody: (ctx) => {\n\t\t\tconst b = depBatch(ctx, 0);\n\t\t\tlet acc = ctx.state.get<T>() ?? seed;\n\t\t\tif (b) for (const v of b) acc = reducer(acc, v as S);\n\t\t\tctx.state.set(acc);\n\t\t\tif (isTerminalComplete(depTerminal(ctx, 0))) ctx.down([[\"DATA\", acc], [\"COMPLETE\"]]);\n\t\t\t// else (live DATA wave): no emit → substrate-synthesized undirty RESOLVED (D49).\n\t\t},\n\t};\n}\n\n/**\n * pairwise: emit `[previous, current]` for each consecutive pair; the very first value produces no\n * pair (quiet → undirty RESOLVED). Previous value is kept in `ctx.state`.\n */\nexport function pairwise<S>(): Operator<S, readonly [S, S]> {\n\treturn {\n\t\tfactory: \"pairwise\",\n\t\tbody: (ctx) => {\n\t\t\tconst b = depBatch(ctx, 0);\n\t\t\tif (!b) return;\n\t\t\tconst st = ctx.state.get<{ prev: S }>();\n\t\t\tlet prev = st?.prev;\n\t\t\tlet hasPrev = st !== undefined;\n\t\t\tfor (const v of b as readonly S[]) {\n\t\t\t\tif (hasPrev) ctx.down([[\"DATA\", [prev as S, v] as const]]);\n\t\t\t\tprev = v;\n\t\t\t\thasPrev = true;\n\t\t\t}\n\t\t\tif (hasPrev) ctx.state.set({ prev: prev as S });\n\t\t},\n\t};\n}\n\n/** skip: drop the first `n` DATA values, then pass the rest through. */\nexport function skip<S>(n: number): Operator<S, S> {\n\treturn {\n\t\tfactory: \"skip\",\n\t\tbody: (ctx) => {\n\t\t\tconst b = depBatch(ctx, 0);\n\t\t\tif (!b) return;\n\t\t\tlet count = ctx.state.get<number>() ?? 0;\n\t\t\tfor (const v of b) {\n\t\t\t\tif (count < n) {\n\t\t\t\t\tcount += 1;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tctx.down([[\"DATA\", v]]);\n\t\t\t}\n\t\t\tctx.state.set(count);\n\t\t},\n\t};\n}\n\n/**\n * takeWhile: emit values while `pred` holds; on the first value that fails `pred`, COMPLETE\n * WITHOUT emitting it (RxJS default, non-inclusive). Terminal-is-forever once it completes.\n */\nexport function takeWhile<S>(pred: (v: S) => boolean): Operator<S, S> {\n\treturn {\n\t\tfactory: \"takeWhile\",\n\t\tbody: (ctx) => {\n\t\t\tconst b = depBatch(ctx, 0);\n\t\t\tif (!b) return;\n\t\t\tfor (const v of b as readonly S[]) {\n\t\t\t\tif (pred(v)) ctx.down([[\"DATA\", v]]);\n\t\t\t\telse {\n\t\t\t\t\tctx.down([[\"COMPLETE\"]]);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t};\n}\n\n/**\n * first: emit the first value matching `pred` (or simply the first value), then COMPLETE. EDGE\n * (RxJS divergence, flagged — same class as last/find/elementAt): if the source COMPLETEs with no\n * matching value, the substrate auto-cascades a bare COMPLETE (no value); RxJS `first()` throws\n * EmptyError. Could align to `[[ERROR, EmptyError]]` (expressible) if strict RxJS parity is wanted.\n */\nexport function first<S>(pred?: (v: S) => boolean): Operator<S, S> {\n\treturn {\n\t\tfactory: \"first\",\n\t\tbody: (ctx) => {\n\t\t\tconst b = depBatch(ctx, 0);\n\t\t\tif (!b) return;\n\t\t\tfor (const v of b as readonly S[]) {\n\t\t\t\tif (!pred || pred(v)) {\n\t\t\t\t\tctx.down([[\"DATA\", v], [\"COMPLETE\"]]);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// no match in this wave → undirty RESOLVED (await next match)\n\t\t},\n\t};\n}\n\n/**\n * last: emit the last value matching `pred` (or the last value) on the source's COMPLETE.\n * `completeWhenDepsComplete:false + terminalAsRealInput:true`. EDGE (RxJS divergence, flagged):\n * RxJS `last()` throws EmptyError when no value matched; we COMPLETE without a value (no throw) —\n * the clean-slate substrate has no \"complete-or-throw\" terminal and SENTINEL forbids emitting a\n * placeholder.\n */\nexport function last<S>(pred?: (v: S) => boolean): Operator<S, S> {\n\treturn {\n\t\tfactory: \"last\",\n\t\topts: { completeWhenDepsComplete: false, terminalAsRealInput: true },\n\t\tbody: (ctx) => {\n\t\t\tconst b = depBatch(ctx, 0);\n\t\t\tif (b) for (const v of b) if (!pred || pred(v as S)) ctx.state.set({ v });\n\t\t\tif (isTerminalComplete(depTerminal(ctx, 0))) {\n\t\t\t\tconst st = ctx.state.get<{ v: S }>();\n\t\t\t\tctx.down(st ? [[\"DATA\", st.v], [\"COMPLETE\"]] : [[\"COMPLETE\"]]);\n\t\t\t}\n\t\t},\n\t};\n}\n\n/**\n * find: emit the first value matching `pred`, then COMPLETE. EDGE (RxJS divergence, flagged): RxJS\n * `find` emits `undefined` then COMPLETE when nothing matched — but `undefined` IS the SENTINEL\n * (R-sentinel), so a not-found source COMPLETE here emits a bare COMPLETE (no value).\n */\nexport function find<S>(pred: (v: S) => boolean): Operator<S, S> {\n\treturn {\n\t\tfactory: \"find\",\n\t\topts: { completeWhenDepsComplete: false, terminalAsRealInput: true },\n\t\tbody: (ctx) => {\n\t\t\tconst b = depBatch(ctx, 0);\n\t\t\tif (b) {\n\t\t\t\tfor (const v of b) {\n\t\t\t\t\tif (pred(v as S)) {\n\t\t\t\t\t\tctx.down([[\"DATA\", v], [\"COMPLETE\"]]);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (isTerminalComplete(depTerminal(ctx, 0))) ctx.down([[\"COMPLETE\"]]); // not found → bare COMPLETE\n\t\t},\n\t};\n}\n\n/**\n * elementAt: emit the value at zero-based `index`, then COMPLETE. EDGE (RxJS divergence, flagged):\n * RxJS throws ArgumentOutOfRangeError if the source completes before `index`; we COMPLETE without\n * a value (no throw), consistent with last/find.\n */\nexport function elementAt<S>(index: number): Operator<S, S> {\n\treturn {\n\t\tfactory: \"elementAt\",\n\t\topts: { completeWhenDepsComplete: false, terminalAsRealInput: true },\n\t\tbody: (ctx) => {\n\t\t\tconst b = depBatch(ctx, 0);\n\t\t\tlet count = ctx.state.get<number>() ?? 0;\n\t\t\tif (b) {\n\t\t\t\tfor (const v of b) {\n\t\t\t\t\tif (count === index) {\n\t\t\t\t\t\tctx.down([[\"DATA\", v], [\"COMPLETE\"]]);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t\tctx.state.set(count);\n\t\t\t}\n\t\t\tif (isTerminalComplete(depTerminal(ctx, 0))) ctx.down([[\"COMPLETE\"]]); // index out of range → bare COMPLETE\n\t\t},\n\t};\n}\n\n/** Observer object for {@link tap} — lifecycle-aware side effects (RxJS tap observer form). */\nexport interface TapObserver<T> {\n\tdata?: (value: T) => void;\n\terror?: (err: unknown) => void;\n\tcomplete?: () => void;\n}\n\n/**\n * tap: invoke a side effect on each DATA (function form) or on data/error/complete (observer form);\n * values pass through unchanged. The observer form reads source terminals\n * (`completeWhenDepsComplete:false + errorWhenDepsError:false + terminalAsRealInput:true`) so it can\n * call `error`/`complete` then forward the terminal; the function form lets the substrate\n * auto-cascade terminals.\n */\nexport function tap<S>(fnOrObserver: ((v: S) => void) | TapObserver<S>): Operator<S, S> {\n\tif (typeof fnOrObserver === \"function\") {\n\t\tconst fn = fnOrObserver;\n\t\treturn {\n\t\t\tfactory: \"tap\",\n\t\t\tbody: (ctx) => {\n\t\t\t\tconst b = depBatch(ctx, 0);\n\t\t\t\tif (b)\n\t\t\t\t\tfor (const v of b) {\n\t\t\t\t\t\tfn(v as S);\n\t\t\t\t\t\tctx.down([[\"DATA\", v]]);\n\t\t\t\t\t}\n\t\t\t},\n\t\t};\n\t}\n\tconst obs = fnOrObserver;\n\treturn {\n\t\tfactory: \"tap\",\n\t\topts: {\n\t\t\tcompleteWhenDepsComplete: false,\n\t\t\terrorWhenDepsError: false,\n\t\t\tterminalAsRealInput: true,\n\t\t},\n\t\tbody: (ctx) => {\n\t\t\tconst terminal = depTerminal(ctx, 0);\n\t\t\tif (isTerminalComplete(terminal)) {\n\t\t\t\tobs.complete?.();\n\t\t\t\tctx.down([[\"COMPLETE\"]]);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (isTerminalError(terminal)) {\n\t\t\t\tconst err = terminalErrorValue(terminal);\n\t\t\t\tobs.error?.(err);\n\t\t\t\tctx.down([[\"ERROR\", err]]);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst b = depBatch(ctx, 0);\n\t\t\tif (b)\n\t\t\t\tfor (const v of b) {\n\t\t\t\t\tobs.data?.(v as S);\n\t\t\t\t\tctx.down([[\"DATA\", v]]);\n\t\t\t\t}\n\t\t},\n\t};\n}\n\n/**\n * onFirstData (alias `tapFirst`): invoke `fn` exactly once on the first qualifying value (default\n * `where: v => v != null` — null/undefined pass through without counting as \"first\"), then pass all\n * values through unchanged. The one-shot guard is per-node `ctx.state` (NOT a factory closure, so a\n * second instantiation of the same factory re-arms — R-ctx-state).\n */\nexport function onFirstData<S>(\n\tfn: (v: S) => void,\n\topts?: { where?: (v: S) => boolean },\n): Operator<S, S> {\n\tconst where = opts?.where ?? ((v: S) => v != null);\n\treturn {\n\t\tfactory: \"onFirstData\",\n\t\tbody: (ctx) => {\n\t\t\tconst b = depBatch(ctx, 0);\n\t\t\tif (!b) return;\n\t\t\tlet fired = ctx.state.get<boolean>() ?? false;\n\t\t\tfor (const v of b) {\n\t\t\t\tif (!fired && where(v as S)) {\n\t\t\t\t\tfired = true;\n\t\t\t\t\tfn(v as S);\n\t\t\t\t}\n\t\t\t\tctx.down([[\"DATA\", v]]);\n\t\t\t}\n\t\t\tctx.state.set(fired);\n\t\t},\n\t};\n}\n\n/** tapFirst: alias of {@link onFirstData} (the one-shot companion to {@link tap}). */\nexport const tapFirst = onFirstData;\n\n/** Options for {@link settle}. */\nexport interface SettleOpts<S> {\n\t/** Consecutive no-change waves before declaring convergence + COMPLETE. */\n\tquietWaves: number;\n\t/** Optional hard cap on total waves before forced COMPLETE. */\n\tmaxWaves?: number;\n\t/** Optional comparator; a DATA equal to the previous one does NOT reset the quiet counter. */\n\tequals?: (a: S, b: S) => boolean;\n}\n\n/** Internal settle accumulator state (per-node, R-ctx-state). */\ninterface SettleState<S> {\n\tlast: S | undefined;\n\thasValue: boolean;\n\tquiet: number;\n\twaves: number;\n\tdone: boolean;\n}\n\n/**\n * settle: forward each DATA unchanged, watch for convergence, COMPLETE once the source has been\n * quiet for `quietWaves` consecutive waves (or `maxWaves` elapsed). \"Wave\" = one fn invocation\n * (a DATA batch OR a bare undirty RESOLVED end-of-wave). No polling (R-no-polling) — the counter\n * advances only on real upstream waves. `settle`'s own `equals` is a body comparator, NOT the\n * removed substrate `equals` (D49).\n */\nexport function settle<S>(opts: SettleOpts<S>): Operator<S, S> {\n\tconst { quietWaves, maxWaves, equals } = opts;\n\tif (!Number.isInteger(quietWaves) || quietWaves < 1) {\n\t\tthrow new RangeError(`settle: quietWaves must be a positive integer (got ${quietWaves})`);\n\t}\n\tif (maxWaves != null && (!Number.isInteger(maxWaves) || maxWaves < 1)) {\n\t\tthrow new RangeError(`settle: maxWaves must be a positive integer when set (got ${maxWaves})`);\n\t}\n\treturn {\n\t\tfactory: \"settle\",\n\t\tbody: (ctx) => {\n\t\t\tconst st: SettleState<S> = ctx.state.get<SettleState<S>>() ?? {\n\t\t\t\tlast: undefined,\n\t\t\t\thasValue: false,\n\t\t\t\tquiet: 0,\n\t\t\t\twaves: 0,\n\t\t\t\tdone: false,\n\t\t\t};\n\t\t\tif (st.done) return;\n\t\t\tst.waves++;\n\t\t\tconst b = depBatch(ctx, 0);\n\t\t\tlet sawChange = false;\n\t\t\tif (b && b.length > 0) {\n\t\t\t\tfor (const v of b) {\n\t\t\t\t\tconst next = v as S;\n\t\t\t\t\tconst isChange = !st.hasValue || equals == null || !equals(st.last as S, next);\n\t\t\t\t\tif (isChange) sawChange = true;\n\t\t\t\t\tst.last = next;\n\t\t\t\t\tst.hasValue = true;\n\t\t\t\t\tctx.down([[\"DATA\", next]]);\n\t\t\t\t}\n\t\t\t}\n\t\t\tst.quiet = sawChange ? 0 : st.quiet + 1;\n\t\t\tconst settled = st.hasValue && st.quiet >= quietWaves;\n\t\t\tconst exhausted = maxWaves != null && st.waves >= maxWaves;\n\t\t\tif (settled || exhausted) {\n\t\t\t\tst.done = true;\n\t\t\t\tctx.state.set(st);\n\t\t\t\tctx.down([[\"COMPLETE\"]]);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tctx.state.set(st);\n\t\t\t// A no-DATA wave that didn't converge → bare undirty RESOLVED is synthesized by the\n\t\t\t// substrate (D49); nothing to emit here.\n\t\t},\n\t};\n}\n\n// ── Slice 3 — error-handling control (CSP-2.7, D40) ──\n// rescue/catchError ABSORB the source ERROR (errorWhenDepsError:false) and read the error payload\n// from `depTerminal(ctx, 0)` (R-deps-terminal). They set completeWhenDepsComplete:false so a\n// normal source COMPLETE is forwarded explicitly — which ALSO sidesteps B40 (the\n// completeWhenDepsComplete:true × absorbed-errored-dep auto-complete gap): there is no auto-complete\n// to block. valve is a [source, control] gate (state-verb-legitimate control input).\n\n/**\n * rescue (alias `catchError`): replace an upstream ERROR with a recovered value. On source DATA →\n * forward; on source ERROR → emit `recover(err)` as DATA (if `recover` throws, forward THAT as\n * ERROR); on source COMPLETE → COMPLETE. After recovery the source is terminal-errored (dead) so no\n * further values flow — the recovered value is the final cached value (matches the frozen pure-ts\n * reference; it does NOT auto-COMPLETE, RxJS-`catchError(()=>of(x))` divergence, flagged).\n */\nexport function rescue<S>(recover: (err: unknown) => S): Operator<S, S> {\n\treturn {\n\t\tfactory: \"rescue\",\n\t\topts: {\n\t\t\terrorWhenDepsError: false,\n\t\t\tcompleteWhenDepsComplete: false,\n\t\t\tterminalAsRealInput: true,\n\t\t},\n\t\tbody: (ctx) => {\n\t\t\tconst b = depBatch(ctx, 0);\n\t\t\tconst terminal = depTerminal(ctx, 0);\n\t\t\tif (b) for (const v of b) ctx.down([[\"DATA\", v]]);\n\t\t\tif (isTerminalComplete(terminal)) {\n\t\t\t\tctx.down([[\"COMPLETE\"]]);\n\t\t\t} else if (isTerminalError(terminal)) {\n\t\t\t\t// ERROR payload absorbed → recover.\n\t\t\t\ttry {\n\t\t\t\t\tctx.down([[\"DATA\", recover(terminalErrorValue(terminal))]]);\n\t\t\t\t} catch (e) {\n\t\t\t\t\tctx.down([[\"ERROR\", errorPayload(e, \"rescue threw without a valid error payload\")]]);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t};\n}\n\n/** catchError: RxJS-named alias of {@link rescue}. */\nexport const catchError = rescue;\n\n/** Options for {@link valve}. */\nexport interface ValveOpts {\n\t/**\n\t * Optional AbortController (or a `() => AbortController | undefined` factory): on the control's\n\t * truthy→falsy edge, `valve` calls `controller.abort()` — cancel an in-flight async boundary\n\t * (LLM/fetch) the caller threaded `controller.signal` into. An external-resource cleanup (like\n\t * `ctx.onDeactivation`), NOT an imperative reactive trigger (R-no-imperative).\n\t */\n\tabortInFlight?: AbortController | (() => AbortController | undefined);\n}\n\n/**\n * valve: forward the source's DATA only while `control` (dep 1) is truthy; when closed, stay quiet\n * (undirty RESOLVED). `[source, control]` declared deps + `partial:true` (the control wave can fire\n * before the source ever delivers). `completeWhenDepsComplete:false` — closing the gate (control\n * terminating) does NOT complete the valve; only the SOURCE's terminal (read via\n * `terminalAsRealInput`) is forwarded. The `state`-verb control input is a legitimate external\n * boundary (D4 / D54), not a forbidden imperative trigger.\n */\nexport function valve<S>(opts?: ValveOpts): Operator<S, S> {\n\tconst abortInFlight = opts?.abortInFlight;\n\treturn {\n\t\tfactory: \"valve\",\n\t\topts: { partial: true, completeWhenDepsComplete: false, terminalAsRealInput: true },\n\t\tbody: (ctx) => {\n\t\t\tconst srcBatch = depBatch(ctx, 0);\n\t\t\tconst ctlBatch = depBatch(ctx, 1);\n\t\t\tconst srcTerminal = depTerminal(ctx, 0);\n\t\t\tconst controlValue = depLatest(ctx, 1) as boolean | undefined;\n\n\t\t\tif (abortInFlight != null) {\n\t\t\t\t// Fire abort on the truthy→falsy edge only (never on activation / no prior state).\n\t\t\t\tconst prev = ctx.state.get<{ ctl: boolean | undefined }>();\n\t\t\t\tif (prev?.ctl === true && !controlValue) {\n\t\t\t\t\tconst c = typeof abortInFlight === \"function\" ? abortInFlight() : abortInFlight;\n\t\t\t\t\tc?.abort();\n\t\t\t\t}\n\t\t\t\tctx.state.set({\n\t\t\t\t\tctl: controlValue === true ? true : controlValue == null ? undefined : false,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// Source terminal forwarding (control terminal is absorbed by completeWhenDepsComplete:false).\n\t\t\tif (isTerminalComplete(srcTerminal)) {\n\t\t\t\tctx.down([[\"COMPLETE\"]]);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (isTerminalError(srcTerminal)) {\n\t\t\t\tctx.down([[\"ERROR\", terminalErrorValue(srcTerminal)]]);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (!controlValue) return; // gate closed → quiet (undirty RESOLVED)\n\n\t\t\tif (srcBatch && srcBatch.length > 0) {\n\t\t\t\tfor (const v of srcBatch) ctx.down([[\"DATA\", v]]);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Gate just opened this wave (control fired, source didn't): re-emit the last source value.\n\t\t\tconst srcLatest = depLatest(ctx, 0);\n\t\t\tif (ctlBatch && ctlBatch.length > 0 && srcLatest !==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