@graphrefly/ts 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -7
- package/dist/{actions-types-DfRob139.d.cts → actions-types-BYzAurt6.d.cts} +1 -1
- package/dist/{actions-types-DcDaBRTC.d.ts → actions-types-CFJILlFn.d.ts} +1 -1
- package/dist/adapters/index.cjs.map +1 -1
- package/dist/adapters/index.d.cts +5 -5
- package/dist/adapters/index.d.ts +5 -5
- package/dist/adapters/index.js +7 -7
- package/dist/adapters/nestjs/microservices.d.cts +1 -1
- package/dist/adapters/nestjs/microservices.d.ts +1 -1
- package/dist/adapters/nestjs/native.d.cts +2 -2
- package/dist/adapters/nestjs/native.d.ts +2 -2
- package/dist/adapters/nestjs/native.js +2 -2
- package/dist/adapters/nestjs/websockets.d.cts +1 -1
- package/dist/adapters/nestjs/websockets.d.ts +1 -1
- package/dist/adapters/nestjs.d.cts +1 -1
- package/dist/adapters/nestjs.d.ts +1 -1
- package/dist/adapters/observe-storage.d.cts +1 -1
- package/dist/adapters/observe-storage.d.ts +1 -1
- package/dist/adapters/react.cjs.map +1 -1
- package/dist/adapters/react.d.cts +1 -1
- package/dist/adapters/react.d.ts +1 -1
- package/dist/adapters/react.js +1 -1
- package/dist/adapters/solid.cjs.map +1 -1
- package/dist/adapters/solid.d.cts +1 -1
- package/dist/adapters/solid.d.ts +1 -1
- package/dist/adapters/solid.js +1 -1
- package/dist/adapters/svelte.cjs.map +1 -1
- package/dist/adapters/svelte.d.cts +1 -1
- package/dist/adapters/svelte.d.ts +1 -1
- package/dist/adapters/svelte.js +1 -1
- package/dist/adapters/vue.cjs.map +1 -1
- package/dist/adapters/vue.d.cts +1 -1
- package/dist/adapters/vue.d.ts +1 -1
- package/dist/adapters/vue.js +1 -1
- package/dist/{agent-runtime-types-tool-CTZx51kE.d.cts → agent-runtime-types-tool-DSzCWLK4.d.cts} +1 -1
- package/dist/{agent-runtime-types-tool-B0jR0euI.d.ts → agent-runtime-types-tool-DUZUxrl5.d.ts} +1 -1
- package/dist/{capability-admission-CGmtVzfS.d.ts → capability-admission--qmB5qYW.d.ts} +1 -1
- package/dist/{capability-admission-BwmsThnQ.d.cts → capability-admission-BbiUMnpF.d.cts} +1 -1
- package/dist/{chunk-BIGKAHSX.js → chunk-2U4G3PEU.js} +8 -8
- package/dist/{chunk-FLUPPSIP.js → chunk-3KYPNNBH.js} +1 -1
- package/dist/chunk-3KYPNNBH.js.map +1 -0
- package/dist/{chunk-AVPXWVRL.js → chunk-BOWKPNXS.js} +2 -2
- package/dist/{chunk-LRYGIKWY.js → chunk-G3J4KZLK.js} +5 -5
- package/dist/{chunk-32WGWBYO.js → chunk-HFPPLLLQ.js} +2 -2
- package/dist/{chunk-VYAEEKZ3.js → chunk-IISXKNWE.js} +1 -1
- package/dist/chunk-IISXKNWE.js.map +1 -0
- package/dist/{chunk-DXBOAAPS.js → chunk-KTJ5LEOL.js} +1 -1
- package/dist/chunk-KTJ5LEOL.js.map +1 -0
- package/dist/{chunk-HT5R7S47.js → chunk-LPC42V2E.js} +3 -3
- package/dist/{chunk-STLRNFU7.js → chunk-T3YMFLRH.js} +3 -3
- package/dist/chunk-T3YMFLRH.js.map +1 -0
- package/dist/{chunk-V3MSIDUQ.js → chunk-TWOPVCGK.js} +2 -2
- package/dist/{chunk-ND43YDGK.js → chunk-V3YEGWSH.js} +1 -1
- package/dist/chunk-V3YEGWSH.js.map +1 -0
- package/dist/{chunk-2BIF6BQ7.js → chunk-W4ATMMTH.js} +2 -2
- package/dist/{committed-fact-log-backend-Cjhgia-O.d.ts → committed-fact-log-backend-B_h6A6cN.d.ts} +1 -1
- package/dist/{committed-fact-log-backend-BE3Fx5Zv.d.cts → committed-fact-log-backend-CIhiKL-Q.d.cts} +1 -1
- package/dist/composition/index.cjs.map +1 -1
- package/dist/composition/index.d.cts +1 -1
- package/dist/composition/index.d.ts +1 -1
- package/dist/composition/index.js +2 -2
- package/dist/cqrs/index.d.cts +1 -1
- package/dist/cqrs/index.d.ts +1 -1
- package/dist/cqrs/messaging.d.cts +1 -1
- package/dist/cqrs/messaging.d.ts +1 -1
- package/dist/cqrs/work-queue.d.cts +1 -1
- package/dist/cqrs/work-queue.d.ts +1 -1
- package/dist/data-structures/index.cjs.map +1 -1
- package/dist/data-structures/index.d.cts +5 -5
- package/dist/data-structures/index.d.ts +5 -5
- package/dist/data-structures/index.js +3 -3
- package/dist/executors/tool-provider-adapters.d.cts +3 -3
- package/dist/executors/tool-provider-adapters.d.ts +3 -3
- package/dist/executors/tool-provider-adapters.js +4 -4
- package/dist/executors/tool-provider-runtime.d.cts +4 -4
- package/dist/executors/tool-provider-runtime.d.ts +4 -4
- package/dist/executors/tool-provider.d.cts +3 -3
- package/dist/executors/tool-provider.d.ts +3 -3
- package/dist/executors/tool-provider.js +3 -3
- package/dist/executors/work-queue.d.cts +1 -1
- package/dist/executors/work-queue.d.ts +1 -1
- package/dist/graph/index.cjs.map +1 -1
- package/dist/graph/index.d.cts +4 -4
- package/dist/graph/index.d.ts +4 -4
- package/dist/graph/index.js +7 -7
- package/dist/{graph-D7DgoW4r.d.ts → graph-BYcUX6Y-.d.ts} +1 -1
- package/dist/{graph-BpVjXE3p.d.cts → graph-DpUhfPg-.d.cts} +1 -1
- package/dist/{index-NxEHWqYL.d.ts → index-CBXYou1z.d.ts} +1 -1
- package/dist/{index-Df4kax8O.d.cts → index-sxZ52y0d.d.cts} +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +15 -15
- package/dist/inspection/boundary.d.cts +2 -2
- package/dist/inspection/boundary.d.ts +2 -2
- package/dist/{measurements-CIGHDnsE.d.ts → measurements-ByXwo0t6.d.ts} +2 -2
- package/dist/{measurements-BwkzVaf4.d.cts → measurements-CQONT7Qg.d.cts} +2 -2
- package/dist/memory/index.d.cts +1 -1
- package/dist/memory/index.d.ts +1 -1
- package/dist/memory/semantic/index.d.cts +1 -1
- package/dist/memory/semantic/index.d.ts +1 -1
- package/dist/messaging/index.d.cts +1 -1
- package/dist/messaging/index.d.ts +1 -1
- package/dist/operators/index.cjs.map +1 -1
- package/dist/operators/index.d.cts +5 -5
- package/dist/operators/index.d.ts +5 -5
- package/dist/operators/index.js +3 -3
- package/dist/orchestration/index.cjs.map +1 -1
- package/dist/orchestration/index.d.cts +5 -5
- package/dist/orchestration/index.d.ts +5 -5
- package/dist/orchestration/index.js +4 -4
- package/dist/orchestration/messaging.d.cts +1 -1
- package/dist/orchestration/messaging.d.ts +1 -1
- package/dist/orchestration/work-queue.d.cts +2 -2
- package/dist/orchestration/work-queue.d.ts +2 -2
- package/dist/patterns/event-flow.d.cts +1 -1
- package/dist/patterns/event-flow.d.ts +1 -1
- package/dist/patterns/index.cjs.map +1 -1
- package/dist/patterns/index.d.cts +2 -2
- package/dist/patterns/index.d.ts +2 -2
- package/dist/patterns/index.js +1 -1
- package/dist/{reactive-collection-yjdqrWkb.d.cts → reactive-collection-Bt5117qe.d.cts} +1 -1
- package/dist/{reactive-collection-BTdjAVpJ.d.ts → reactive-collection-CZGtOhEp.d.ts} +1 -1
- package/dist/{reactive-collection-storage-C1YIW_q2.d.cts → reactive-collection-storage-BzhzmEpP.d.cts} +3 -3
- package/dist/{reactive-collection-storage-BZozONHw.d.ts → reactive-collection-storage-NKUpbyyK.d.ts} +3 -3
- package/dist/{reactive-map-c-l8bYrl.d.cts → reactive-map-Cf9_oTOT.d.cts} +1 -1
- package/dist/{reactive-map-B6sA6p5U.d.ts → reactive-map-DQeA7ThE.d.ts} +1 -1
- package/dist/{scheduled-readiness-Batwa3Fm.d.ts → scheduled-readiness-BQdebv1Q.d.ts} +1 -1
- package/dist/{scheduled-readiness-BtUBoaGJ.d.cts → scheduled-readiness-D5qPFnZF.d.cts} +1 -1
- package/dist/solutions/agentic-memory/browser.d.cts +2 -2
- package/dist/solutions/agentic-memory/browser.d.ts +2 -2
- package/dist/solutions/agentic-memory/index.d.cts +3 -3
- package/dist/solutions/agentic-memory/index.d.ts +3 -3
- package/dist/solutions/agentic-memory/node.d.cts +2 -2
- package/dist/solutions/agentic-memory/node.d.ts +2 -2
- package/dist/solutions/agentic-work-item-memory/index.d.cts +1 -1
- package/dist/solutions/agentic-work-item-memory/index.d.ts +1 -1
- package/dist/solutions/agentic-work-item-memory-application/index.d.cts +1 -1
- package/dist/solutions/agentic-work-item-memory-application/index.d.ts +1 -1
- package/dist/solutions/index.d.cts +6 -6
- package/dist/solutions/index.d.ts +6 -6
- package/dist/solutions/reactive-layout/browser/index.d.cts +2 -2
- package/dist/solutions/reactive-layout/browser/index.d.ts +2 -2
- package/dist/solutions/reactive-layout/index.d.cts +4 -4
- package/dist/solutions/reactive-layout/index.d.ts +4 -4
- package/dist/solutions/reactive-layout/node-canvas/index.d.cts +2 -2
- package/dist/solutions/reactive-layout/node-canvas/index.d.ts +2 -2
- package/dist/solutions/reactive-layout/react-native/index.d.cts +2 -2
- package/dist/solutions/reactive-layout/react-native/index.d.ts +2 -2
- package/dist/solutions/reactive-layout/skia/index.d.cts +2 -2
- package/dist/solutions/reactive-layout/skia/index.d.ts +2 -2
- package/dist/solutions/work-item/actions.d.cts +5 -5
- package/dist/solutions/work-item/actions.d.ts +5 -5
- package/dist/solutions/work-item/index.d.cts +4 -4
- package/dist/solutions/work-item/index.d.ts +4 -4
- package/dist/solutions/work-item/scheduling.d.cts +4 -4
- package/dist/solutions/work-item/scheduling.d.ts +4 -4
- package/dist/solutions/work-item/work-queue.d.cts +1 -1
- package/dist/solutions/work-item/work-queue.d.ts +1 -1
- package/dist/sources/browser.cjs.map +1 -1
- package/dist/sources/browser.d.cts +2 -2
- package/dist/sources/browser.d.ts +2 -2
- package/dist/sources/browser.js +2 -2
- package/dist/sources/index.cjs.map +1 -1
- package/dist/sources/index.d.cts +2 -2
- package/dist/sources/index.d.ts +2 -2
- package/dist/sources/index.js +2 -2
- package/dist/sources/node.d.cts +1 -1
- package/dist/sources/node.d.ts +1 -1
- package/dist/storage/index.d.cts +2 -2
- package/dist/storage/index.d.ts +2 -2
- package/dist/{store-BnjczOv3.d.cts → store-Rxycbh-H.d.cts} +5 -5
- package/dist/{store-DEQq1IUZ.d.ts → store-piaqo-AU.d.ts} +5 -5
- package/dist/testing/index.cjs.map +1 -1
- package/dist/testing/index.d.cts +1 -1
- package/dist/testing/index.d.ts +1 -1
- package/dist/testing/index.js +1 -1
- package/dist/{types-CjoOI5fY.d.cts → types-084NQr4q.d.cts} +1 -1
- package/dist/{types-C_rZAUfY.d.ts → types-CIYYkmqF.d.ts} +1 -1
- package/dist/work-queue/index.d.cts +1 -1
- package/dist/work-queue/index.d.ts +1 -1
- package/package.json +2 -2
- package/dist/chunk-DXBOAAPS.js.map +0 -1
- package/dist/chunk-FLUPPSIP.js.map +0 -1
- package/dist/chunk-ND43YDGK.js.map +0 -1
- package/dist/chunk-STLRNFU7.js.map +0 -1
- package/dist/chunk-VYAEEKZ3.js.map +0 -1
- /package/dist/{chunk-BIGKAHSX.js.map → chunk-2U4G3PEU.js.map} +0 -0
- /package/dist/{chunk-AVPXWVRL.js.map → chunk-BOWKPNXS.js.map} +0 -0
- /package/dist/{chunk-LRYGIKWY.js.map → chunk-G3J4KZLK.js.map} +0 -0
- /package/dist/{chunk-32WGWBYO.js.map → chunk-HFPPLLLQ.js.map} +0 -0
- /package/dist/{chunk-HT5R7S47.js.map → chunk-LPC42V2E.js.map} +0 -0
- /package/dist/{chunk-V3MSIDUQ.js.map → chunk-TWOPVCGK.js.map} +0 -0
- /package/dist/{chunk-2BIF6BQ7.js.map → chunk-W4ATMMTH.js.map} +0 -0
package/dist/sources/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { c as DriverResult, g as HttpRequest, h as HttpResponse, y as SseDriverEvent, z as SseEvent, A as SseRequest, I as WebSocketDriverEvent, J as WebSocketEvent, M as WebSocketRequest, V as WebhookDriverEvent, X as WebhookEvent, Y as WebhookRegistration } from '../index-BNyz3GBZ.cjs';
|
|
2
|
-
export { A as AsyncSourceOpts, C as CronSchedule, E as EventListenerOptionsLike, a as EventTargetLike, F as FromCronOptions, b as FromEventOptions, N as NodeInput, P as PushRegister, c as PushUnsubscribe, S as SingleFromAnyOptions, T as TimerSourceOpts, e as empty, f as firstValueFrom, d as fromAny, g as fromAsyncIter, h as fromCron, i as fromEvent, j as fromHttp, k as fromHttpWithOptions, l as fromIter, n as fromPromise, o as fromPushNotification, p as fromSSE, q as fromSSEWithOptions, r as fromTimer, s as fromWebSocket, t as fromWebSocketWithOptions, u as fromWebhook, v as fromWebhookWithOptions, w as interval, x as matchesCron, y as never, z as of, B as parseCron, H as singleFromAny, I as throwError, J as timer } from '../index-
|
|
2
|
+
export { A as AsyncSourceOpts, C as CronSchedule, E as EventListenerOptionsLike, a as EventTargetLike, F as FromCronOptions, b as FromEventOptions, N as NodeInput, P as PushRegister, c as PushUnsubscribe, S as SingleFromAnyOptions, T as TimerSourceOpts, e as empty, f as firstValueFrom, d as fromAny, g as fromAsyncIter, h as fromCron, i as fromEvent, j as fromHttp, k as fromHttpWithOptions, l as fromIter, n as fromPromise, o as fromPushNotification, p as fromSSE, q as fromSSEWithOptions, r as fromTimer, s as fromWebSocket, t as fromWebSocketWithOptions, u as fromWebhook, v as fromWebhookWithOptions, w as interval, x as matchesCron, y as never, z as of, B as parseCron, H as singleFromAny, I as throwError, J as timer } from '../index-sxZ52y0d.cjs';
|
|
3
3
|
import '../messages-X4xsRuK0.cjs';
|
|
4
|
-
import '../graph-
|
|
4
|
+
import '../graph-DpUhfPg-.cjs';
|
|
5
5
|
import '../core/index.cjs';
|
|
6
6
|
import '../codec-C22dT0kb.cjs';
|
|
7
7
|
import '../describe-3SLgCxCd.cjs';
|
package/dist/sources/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { c as DriverResult, g as HttpRequest, h as HttpResponse, y as SseDriverEvent, z as SseEvent, A as SseRequest, I as WebSocketDriverEvent, J as WebSocketEvent, M as WebSocketRequest, V as WebhookDriverEvent, X as WebhookEvent, Y as WebhookRegistration } from '../index-D9ATwlam.js';
|
|
2
|
-
export { A as AsyncSourceOpts, C as CronSchedule, E as EventListenerOptionsLike, a as EventTargetLike, F as FromCronOptions, b as FromEventOptions, N as NodeInput, P as PushRegister, c as PushUnsubscribe, S as SingleFromAnyOptions, T as TimerSourceOpts, e as empty, f as firstValueFrom, d as fromAny, g as fromAsyncIter, h as fromCron, i as fromEvent, j as fromHttp, k as fromHttpWithOptions, l as fromIter, n as fromPromise, o as fromPushNotification, p as fromSSE, q as fromSSEWithOptions, r as fromTimer, s as fromWebSocket, t as fromWebSocketWithOptions, u as fromWebhook, v as fromWebhookWithOptions, w as interval, x as matchesCron, y as never, z as of, B as parseCron, H as singleFromAny, I as throwError, J as timer } from '../index-
|
|
2
|
+
export { A as AsyncSourceOpts, C as CronSchedule, E as EventListenerOptionsLike, a as EventTargetLike, F as FromCronOptions, b as FromEventOptions, N as NodeInput, P as PushRegister, c as PushUnsubscribe, S as SingleFromAnyOptions, T as TimerSourceOpts, e as empty, f as firstValueFrom, d as fromAny, g as fromAsyncIter, h as fromCron, i as fromEvent, j as fromHttp, k as fromHttpWithOptions, l as fromIter, n as fromPromise, o as fromPushNotification, p as fromSSE, q as fromSSEWithOptions, r as fromTimer, s as fromWebSocket, t as fromWebSocketWithOptions, u as fromWebhook, v as fromWebhookWithOptions, w as interval, x as matchesCron, y as never, z as of, B as parseCron, H as singleFromAny, I as throwError, J as timer } from '../index-CBXYou1z.js';
|
|
3
3
|
import '../messages-X4xsRuK0.js';
|
|
4
|
-
import '../graph-
|
|
4
|
+
import '../graph-BYcUX6Y-.js';
|
|
5
5
|
import '../core/index.js';
|
|
6
6
|
import '../codec-C22dT0kb.js';
|
|
7
7
|
import '../describe-DyUNCtFq.js';
|
package/dist/sources/index.js
CHANGED
|
@@ -26,8 +26,8 @@ import {
|
|
|
26
26
|
singleFromAny,
|
|
27
27
|
throwError,
|
|
28
28
|
timer
|
|
29
|
-
} from "../chunk-
|
|
30
|
-
import "../chunk-
|
|
29
|
+
} from "../chunk-HFPPLLLQ.js";
|
|
30
|
+
import "../chunk-3KYPNNBH.js";
|
|
31
31
|
import "../chunk-KXHUR56T.js";
|
|
32
32
|
import "../chunk-TCTOW52X.js";
|
|
33
33
|
import "../chunk-4GKAT72H.js";
|
package/dist/sources/node.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { i as LocalProcessDriver } from '../index-BNyz3GBZ.cjs';
|
|
2
|
-
import { L as Operator } from '../graph-
|
|
2
|
+
import { L as Operator } from '../graph-DpUhfPg-.cjs';
|
|
3
3
|
import '../messages-X4xsRuK0.cjs';
|
|
4
4
|
import '../core/index.cjs';
|
|
5
5
|
import '../codec-C22dT0kb.cjs';
|
package/dist/sources/node.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { i as LocalProcessDriver } from '../index-D9ATwlam.js';
|
|
2
|
-
import { L as Operator } from '../graph-
|
|
2
|
+
import { L as Operator } from '../graph-BYcUX6Y-.js';
|
|
3
3
|
import '../messages-X4xsRuK0.js';
|
|
4
4
|
import '../core/index.js';
|
|
5
5
|
import '../codec-C22dT0kb.js';
|
package/dist/storage/index.d.cts
CHANGED
|
@@ -4,12 +4,12 @@ import { b as ChangeLifecycle, S as StorageTimestampNs, N as NonNegativeDecimalI
|
|
|
4
4
|
export { C as ChangeEnvelope, a as ChangeEnvelopeOptions, D as DecimalIntegerString, O as ObserveEventFrame, c as ObserveEventLogPage, d as assertChangeEnvelope, e as assertDecimalIntegerString, f as assertNonNegativeDecimalIntegerString, g as assertObserveEventFrame, h as bigIntToDecimalString, i as bigIntToNonNegativeDecimalString, j as changeEnvelopeCodec, k as decimalStringToBigInt, l as envelopeChange, m as isDecimalIntegerString, n as isNonNegativeDecimalIntegerString, o as nonNegativeDecimalStringToBigInt, p as nowNs, q as observeEventFrame, r as observeEventFrameCodec, s as readObserveEventLogPage } from '../observe-event-log-DT34DPX5.cjs';
|
|
5
5
|
import { C as Codec } from '../codec-C22dT0kb.cjs';
|
|
6
6
|
export { S as StrictJsonObject, a as StrictJsonScalar, b as StrictJsonValue, c as assertStrictJsonObject, d as assertStrictJsonValue, j as jsonCodec, e as jsonCodecFor, s as stableJsonString, g as strictJsonCodec, h as strictJsonCodecFor } from '../codec-C22dT0kb.cjs';
|
|
7
|
-
export { b as LoadReactiveCollectionStateOptions, R as REACTIVE_COLLECTION_CHANGE_FORMAT, d as REACTIVE_COLLECTION_FRAME_VERSION, e as REACTIVE_COLLECTION_SNAPSHOT_FORMAT, f as ReactiveCollectionChangeFrame, g as ReactiveCollectionRestoreState, h as ReactiveCollectionSnapshotFrame, i as ReactiveCollectionStorageKind, o as ReactiveIndexRestoreState, p as ReactiveListRestoreState, q as ReactiveLogRestoreState, r as ReactiveMapRestoreState, t as assertReactiveCollectionChangeFrame, u as assertReactiveCollectionSnapshotFrame, v as collectionSnapshotKey, w as loadReactiveIndexState, x as loadReactiveListState, y as loadReactiveLogState, z as loadReactiveMapState, A as reactiveCollectionChangeFrame, B as reactiveCollectionChangeFrameCodec, C as reactiveCollectionSnapshotFrame, D as reactiveCollectionSnapshotFrameCodec } from '../reactive-collection-
|
|
7
|
+
export { b as LoadReactiveCollectionStateOptions, R as REACTIVE_COLLECTION_CHANGE_FORMAT, d as REACTIVE_COLLECTION_FRAME_VERSION, e as REACTIVE_COLLECTION_SNAPSHOT_FORMAT, f as ReactiveCollectionChangeFrame, g as ReactiveCollectionRestoreState, h as ReactiveCollectionSnapshotFrame, i as ReactiveCollectionStorageKind, o as ReactiveIndexRestoreState, p as ReactiveListRestoreState, q as ReactiveLogRestoreState, r as ReactiveMapRestoreState, t as assertReactiveCollectionChangeFrame, u as assertReactiveCollectionSnapshotFrame, v as collectionSnapshotKey, w as loadReactiveIndexState, x as loadReactiveListState, y as loadReactiveLogState, z as loadReactiveMapState, A as reactiveCollectionChangeFrame, B as reactiveCollectionChangeFrameCodec, C as reactiveCollectionSnapshotFrame, D as reactiveCollectionSnapshotFrameCodec } from '../reactive-collection-Bt5117qe.cjs';
|
|
8
8
|
export { R as ReadThroughErrorContext, a as ReadThroughLookupFact, b as ReadThroughLookupTier, c as ReadThroughMissContext, d as ReadThroughPromotionFact, T as TieredReadThroughOptions, e as TieredReadThroughResult, r as readThroughKv, t as tieredReadThrough } from '../read-through-k27vMrhT.cjs';
|
|
9
9
|
import '../index-BNyz3GBZ.cjs';
|
|
10
10
|
import '../messages-X4xsRuK0.cjs';
|
|
11
11
|
import '../types-C61D9Va8.cjs';
|
|
12
|
-
import '../graph-
|
|
12
|
+
import '../graph-DpUhfPg-.cjs';
|
|
13
13
|
import '../core/index.cjs';
|
|
14
14
|
import '../describe-3SLgCxCd.cjs';
|
|
15
15
|
|
package/dist/storage/index.d.ts
CHANGED
|
@@ -4,12 +4,12 @@ import { b as ChangeLifecycle, S as StorageTimestampNs, N as NonNegativeDecimalI
|
|
|
4
4
|
export { C as ChangeEnvelope, a as ChangeEnvelopeOptions, D as DecimalIntegerString, O as ObserveEventFrame, c as ObserveEventLogPage, d as assertChangeEnvelope, e as assertDecimalIntegerString, f as assertNonNegativeDecimalIntegerString, g as assertObserveEventFrame, h as bigIntToDecimalString, i as bigIntToNonNegativeDecimalString, j as changeEnvelopeCodec, k as decimalStringToBigInt, l as envelopeChange, m as isDecimalIntegerString, n as isNonNegativeDecimalIntegerString, o as nonNegativeDecimalStringToBigInt, p as nowNs, q as observeEventFrame, r as observeEventFrameCodec, s as readObserveEventLogPage } from '../observe-event-log-s1Rsnw0E.js';
|
|
5
5
|
import { C as Codec } from '../codec-C22dT0kb.js';
|
|
6
6
|
export { S as StrictJsonObject, a as StrictJsonScalar, b as StrictJsonValue, c as assertStrictJsonObject, d as assertStrictJsonValue, j as jsonCodec, e as jsonCodecFor, s as stableJsonString, g as strictJsonCodec, h as strictJsonCodecFor } from '../codec-C22dT0kb.js';
|
|
7
|
-
export { b as LoadReactiveCollectionStateOptions, R as REACTIVE_COLLECTION_CHANGE_FORMAT, d as REACTIVE_COLLECTION_FRAME_VERSION, e as REACTIVE_COLLECTION_SNAPSHOT_FORMAT, f as ReactiveCollectionChangeFrame, g as ReactiveCollectionRestoreState, h as ReactiveCollectionSnapshotFrame, i as ReactiveCollectionStorageKind, o as ReactiveIndexRestoreState, p as ReactiveListRestoreState, q as ReactiveLogRestoreState, r as ReactiveMapRestoreState, t as assertReactiveCollectionChangeFrame, u as assertReactiveCollectionSnapshotFrame, v as collectionSnapshotKey, w as loadReactiveIndexState, x as loadReactiveListState, y as loadReactiveLogState, z as loadReactiveMapState, A as reactiveCollectionChangeFrame, B as reactiveCollectionChangeFrameCodec, C as reactiveCollectionSnapshotFrame, D as reactiveCollectionSnapshotFrameCodec } from '../reactive-collection-
|
|
7
|
+
export { b as LoadReactiveCollectionStateOptions, R as REACTIVE_COLLECTION_CHANGE_FORMAT, d as REACTIVE_COLLECTION_FRAME_VERSION, e as REACTIVE_COLLECTION_SNAPSHOT_FORMAT, f as ReactiveCollectionChangeFrame, g as ReactiveCollectionRestoreState, h as ReactiveCollectionSnapshotFrame, i as ReactiveCollectionStorageKind, o as ReactiveIndexRestoreState, p as ReactiveListRestoreState, q as ReactiveLogRestoreState, r as ReactiveMapRestoreState, t as assertReactiveCollectionChangeFrame, u as assertReactiveCollectionSnapshotFrame, v as collectionSnapshotKey, w as loadReactiveIndexState, x as loadReactiveListState, y as loadReactiveLogState, z as loadReactiveMapState, A as reactiveCollectionChangeFrame, B as reactiveCollectionChangeFrameCodec, C as reactiveCollectionSnapshotFrame, D as reactiveCollectionSnapshotFrameCodec } from '../reactive-collection-CZGtOhEp.js';
|
|
8
8
|
export { R as ReadThroughErrorContext, a as ReadThroughLookupFact, b as ReadThroughLookupTier, c as ReadThroughMissContext, d as ReadThroughPromotionFact, T as TieredReadThroughOptions, e as TieredReadThroughResult, r as readThroughKv, t as tieredReadThrough } from '../read-through-DSLlf2Gz.js';
|
|
9
9
|
import '../index-D9ATwlam.js';
|
|
10
10
|
import '../messages-X4xsRuK0.js';
|
|
11
11
|
import '../types-CG2tcMHU.js';
|
|
12
|
-
import '../graph-
|
|
12
|
+
import '../graph-BYcUX6Y-.js';
|
|
13
13
|
import '../core/index.js';
|
|
14
14
|
import '../describe-DyUNCtFq.js';
|
|
15
15
|
|
|
@@ -13,7 +13,7 @@ interface ReadableStore<T> {
|
|
|
13
13
|
get(): T | undefined;
|
|
14
14
|
subscribe(run: (value: T | undefined) => void): () => void;
|
|
15
15
|
}
|
|
16
|
-
/** A minimal writable store contract over a
|
|
16
|
+
/** A minimal writable store contract over a GraphReFly writable node. */
|
|
17
17
|
interface WritableStore<T> extends ReadableStore<T> {
|
|
18
18
|
set(value: T): void;
|
|
19
19
|
update(fn: (value: T | undefined) => T): void;
|
|
@@ -28,7 +28,7 @@ interface ExternalStore<T> {
|
|
|
28
28
|
type NodeRecordFactory<K extends string, R extends Record<string, unknown>> = (key: K) => {
|
|
29
29
|
[P in keyof R]: Node<R[P]>;
|
|
30
30
|
};
|
|
31
|
-
/** Zustand-compatible store API over a caller-owned
|
|
31
|
+
/** Zustand-compatible store API over a caller-owned GraphReFly state node. */
|
|
32
32
|
interface ZustandStoreApi<T extends object> {
|
|
33
33
|
getState(): T;
|
|
34
34
|
setState(partial: T | Partial<T> | ((state: T) => T | Partial<T>), replace?: boolean): void;
|
|
@@ -111,7 +111,7 @@ declare function nodeSnapshot<T>(node: Node<T>): T | undefined;
|
|
|
111
111
|
* ```
|
|
112
112
|
*/
|
|
113
113
|
declare function subscribeNodeValues<T>(node: Node<T>, run: (value: T | undefined) => void, opts?: SubscribeValuesOptions<T>): () => void;
|
|
114
|
-
/** Build a Svelte/Nanostores-style readable store from a
|
|
114
|
+
/** Build a Svelte/Nanostores-style readable store from a GraphReFly Node.
|
|
115
115
|
* @param node - Node to observe, adapt, or connect.
|
|
116
116
|
* @param opts - Options that configure the helper.
|
|
117
117
|
* @returns A `ReadableStore<T>` value.
|
|
@@ -122,7 +122,7 @@ declare function subscribeNodeValues<T>(node: Node<T>, run: (value: T | undefine
|
|
|
122
122
|
* ```
|
|
123
123
|
*/
|
|
124
124
|
declare function readableStore<T>(node: Node<T>, opts?: SubscribeValuesOptions<T>): ReadableStore<T>;
|
|
125
|
-
/** Build a writable store over a StateNode or compatible
|
|
125
|
+
/** Build a writable store over a StateNode or compatible GraphReFly writable Node. */
|
|
126
126
|
declare function writableStore<T>(node: WritableNode<T>, opts?: WritableStoreOptions<T>): WritableStore<T>;
|
|
127
127
|
/**
|
|
128
128
|
* Creates a writable store.
|
|
@@ -162,7 +162,7 @@ declare function externalStore<T>(node: Node<T>, opts?: Pick<SubscribeValuesOpti
|
|
|
162
162
|
* ```
|
|
163
163
|
*/
|
|
164
164
|
declare function recordReadableStore<K extends string, R extends Record<string, unknown>>(keysNode: Node<readonly K[]>, factory: NodeRecordFactory<K, R>, opts?: SubscribeValuesOptions<Record<K, R>>): ReadableStore<Record<K, R>>;
|
|
165
|
-
/** Build a Zustand-compatible StoreApi over a caller-owned
|
|
165
|
+
/** Build a Zustand-compatible StoreApi over a caller-owned GraphReFly state node. */
|
|
166
166
|
declare function zustandStore<T extends object>(node: WritableNode<T>, initialState?: T, opts?: WritableStoreOptions<T>): ZustandStoreApi<T>;
|
|
167
167
|
/**
|
|
168
168
|
* Creates a zustand store.
|
|
@@ -13,7 +13,7 @@ interface ReadableStore<T> {
|
|
|
13
13
|
get(): T | undefined;
|
|
14
14
|
subscribe(run: (value: T | undefined) => void): () => void;
|
|
15
15
|
}
|
|
16
|
-
/** A minimal writable store contract over a
|
|
16
|
+
/** A minimal writable store contract over a GraphReFly writable node. */
|
|
17
17
|
interface WritableStore<T> extends ReadableStore<T> {
|
|
18
18
|
set(value: T): void;
|
|
19
19
|
update(fn: (value: T | undefined) => T): void;
|
|
@@ -28,7 +28,7 @@ interface ExternalStore<T> {
|
|
|
28
28
|
type NodeRecordFactory<K extends string, R extends Record<string, unknown>> = (key: K) => {
|
|
29
29
|
[P in keyof R]: Node<R[P]>;
|
|
30
30
|
};
|
|
31
|
-
/** Zustand-compatible store API over a caller-owned
|
|
31
|
+
/** Zustand-compatible store API over a caller-owned GraphReFly state node. */
|
|
32
32
|
interface ZustandStoreApi<T extends object> {
|
|
33
33
|
getState(): T;
|
|
34
34
|
setState(partial: T | Partial<T> | ((state: T) => T | Partial<T>), replace?: boolean): void;
|
|
@@ -111,7 +111,7 @@ declare function nodeSnapshot<T>(node: Node<T>): T | undefined;
|
|
|
111
111
|
* ```
|
|
112
112
|
*/
|
|
113
113
|
declare function subscribeNodeValues<T>(node: Node<T>, run: (value: T | undefined) => void, opts?: SubscribeValuesOptions<T>): () => void;
|
|
114
|
-
/** Build a Svelte/Nanostores-style readable store from a
|
|
114
|
+
/** Build a Svelte/Nanostores-style readable store from a GraphReFly Node.
|
|
115
115
|
* @param node - Node to observe, adapt, or connect.
|
|
116
116
|
* @param opts - Options that configure the helper.
|
|
117
117
|
* @returns A `ReadableStore<T>` value.
|
|
@@ -122,7 +122,7 @@ declare function subscribeNodeValues<T>(node: Node<T>, run: (value: T | undefine
|
|
|
122
122
|
* ```
|
|
123
123
|
*/
|
|
124
124
|
declare function readableStore<T>(node: Node<T>, opts?: SubscribeValuesOptions<T>): ReadableStore<T>;
|
|
125
|
-
/** Build a writable store over a StateNode or compatible
|
|
125
|
+
/** Build a writable store over a StateNode or compatible GraphReFly writable Node. */
|
|
126
126
|
declare function writableStore<T>(node: WritableNode<T>, opts?: WritableStoreOptions<T>): WritableStore<T>;
|
|
127
127
|
/**
|
|
128
128
|
* Creates a writable store.
|
|
@@ -162,7 +162,7 @@ declare function externalStore<T>(node: Node<T>, opts?: Pick<SubscribeValuesOpti
|
|
|
162
162
|
* ```
|
|
163
163
|
*/
|
|
164
164
|
declare function recordReadableStore<K extends string, R extends Record<string, unknown>>(keysNode: Node<readonly K[]>, factory: NodeRecordFactory<K, R>, opts?: SubscribeValuesOptions<Record<K, R>>): ReadableStore<Record<K, R>>;
|
|
165
|
-
/** Build a Zustand-compatible StoreApi over a caller-owned
|
|
165
|
+
/** Build a Zustand-compatible StoreApi over a caller-owned GraphReFly state node. */
|
|
166
166
|
declare function zustandStore<T extends object>(node: WritableNode<T>, initialState?: T, opts?: WritableStoreOptions<T>): ZustandStoreApi<T>;
|
|
167
167
|
/**
|
|
168
168
|
* Creates a zustand store.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/testing/index.ts","../../src/protocol/messages.ts","../../src/testing/assertions.ts"],"sourcesContent":["export {\n\tassertDirtyPrecedesTerminalData,\n\ttype MessageSequence,\n} from \"./assertions.js\";\n","/**\n * Wave-protocol message types and the tier const table.\n *\n * Canonical authority: ~/src/graphrefly/spec/rules.jsonl\n * R-msg-format, R-msg-closed-set, R-tier (D34), R-data-payload, R-sentinel.\n */\n\n/** Opaque pause-lock / pull identifier (R-pause-lockset, R-pull). */\nexport type LockId = string | symbol;\n\n/** Explicit pull demand payload (D269/D272). Params are holder-visible context, never DATA-up. */\nexport interface PullDemand {\n\treadonly pullId: LockId;\n\treadonly params?: unknown;\n}\n\n/**\n * The CLOSED set of 11 message types (R-msg-closed-set / D9 + D269 + START handshake).\n * No open set, no user-defined custom types. Adding a type is a spec change.\n */\nexport type Message =\n\t| readonly [\"START\"]\n\t| readonly [\"DIRTY\"]\n\t| readonly [\"DATA\", unknown]\n\t| readonly [\"RESOLVED\"]\n\t| readonly [\"INVALIDATE\"]\n\t| readonly [\"COMPLETE\"]\n\t| readonly [\"ERROR\", unknown]\n\t| readonly [\"TEARDOWN\"]\n\t| readonly [\"PAUSE\", LockId]\n\t| readonly [\"RESUME\", LockId]\n\t| readonly [\"PULL\", PullDemand];\n\n/** One array of messages delivered in one call = one Wave (R-wave-boundary). */\nexport type Wave = readonly Message[];\n\n/** The message-type tag (the first tuple element). */\nexport type MessageType = Message[0];\n\n/**\n * SENTINEL = absence-of-DATA (R-sentinel / D16). TS representation is `undefined`.\n * Never a valid DATA payload; `null` IS a valid DATA value (domain-level absence).\n */\nexport const SENTINEL = undefined;\n\n/** R-data-payload: ERROR payloads must not collide with terminal metadata shorthand.\n * @param v - v value used by the helper.\n * @returns `true` when the value matches the expected shape.\n * @category core\n * @example\n * ```ts\n * import { isInvalidErrorPayload } from \"@graphrefly/ts/core\";\n * ```\n */\nexport function isInvalidErrorPayload(v: unknown): boolean {\n\treturn v === SENTINEL || typeof v === \"boolean\";\n}\n\n/** R-data-payload / D78: host-language failures that collide with ctx.terminal shorthand become diagnostics.\n * @param reason - reason value used by the helper.\n * @param fallback - fallback value used by the helper.\n * @returns The error payload result.\n * @category core\n * @example\n * ```ts\n * import { errorPayload } from \"@graphrefly/ts/core\";\n * ```\n */\nexport function errorPayload(reason: unknown, fallback = \"error without a valid payload\"): unknown {\n\treturn isInvalidErrorPayload(reason) ? new Error(fallback) : reason;\n}\n\nexport const TIER_START = 0;\nexport const TIER_CONTROL = 1;\nexport const TIER_NOTIFICATION = 2;\nexport const TIER_VALUE = 3;\nexport const TIER_SETTLE = 4;\nexport const TIER_TERMINAL = 5;\nexport const TIER_TEARDOWN = 6;\n\n/**\n * Tier const table (R-tier / D34). Tiers below value dispatch immediately; value\n * and above are batch-deferred. This is a compile-time const table (D18), not runtime config.\n */\nconst TIER: Record<MessageType, number> = {\n\tSTART: TIER_START,\n\tPAUSE: TIER_CONTROL,\n\tRESUME: TIER_CONTROL,\n\tPULL: TIER_CONTROL,\n\tDIRTY: TIER_NOTIFICATION,\n\tDATA: TIER_VALUE,\n\tRESOLVED: TIER_VALUE,\n\tINVALIDATE: TIER_SETTLE,\n\tCOMPLETE: TIER_TERMINAL,\n\tERROR: TIER_TERMINAL,\n\tTEARDOWN: TIER_TEARDOWN,\n};\n\n/**\n * Look up the tier number for a message type.\n *\n * @param t - One of the closed-set protocol message tags.\n * @returns The tier assigned by the compile-time tier table.\n * @example\n * ```ts\n * messageTier(\"DATA\"); // 3\n * ```\n * @category core\n */\nexport function messageTier(t: MessageType): number {\n\treturn TIER[t];\n}\n\n/** Value and above are deferred inside a batch (DATA/RESOLVED/INVALIDATE/terminal/teardown).\n * @param t - t value used by the helper.\n * @returns `true` when the value matches the expected shape.\n * @category core\n * @example\n * ```ts\n * import { isDeferredTier } from \"@graphrefly/ts/core\";\n * ```\n */\nexport function isDeferredTier(t: MessageType): boolean {\n\treturn TIER[t] >= TIER_VALUE;\n}\n\n/** Value-tier messages (DATA/RESOLVED) occupy the tier-3 slot.\n * @param t - t value used by the helper.\n * @returns `true` when the value matches the expected shape.\n * @category core\n * @example\n * ```ts\n * import { isValueTier } from \"@graphrefly/ts/core\";\n * ```\n */\nexport function isValueTier(t: MessageType): boolean {\n\treturn TIER[t] === TIER_VALUE;\n}\n\n/** The pause buffer holds the settle slice only: value-tier DATA/RESOLVED plus INVALIDATE.\n * @param t - t value used by the helper.\n * @returns `true` when the value matches the expected shape.\n * @category core\n * @example\n * ```ts\n * import { isPauseBufferedTier } from \"@graphrefly/ts/core\";\n * ```\n */\nexport function isPauseBufferedTier(t: MessageType): boolean {\n\tconst tier = TIER[t];\n\treturn tier === TIER_VALUE || tier === TIER_SETTLE;\n}\n\n/**\n * A TERMINAL message = tier 5 (COMPLETE | ERROR), R-tier / D34. Detected via the CENTRAL tier\n * table, NOT a per-variant `=== \"COMPLETE\" || === \"ERROR\"` check — so terminal routing stays\n * driven by the one const table (feedback_use_tier_for_signal_routing); discriminate COMPLETE vs\n * ERROR within the tier by the message type only where the handling actually differs.\n * @param t - t value used by the helper.\n * @returns `true` when the value matches the expected shape.\n * @category core\n * @example\n * ```ts\n * import { isTerminal } from \"@graphrefly/ts/core\";\n * ```\n */\nexport function isTerminal(t: MessageType): boolean {\n\treturn TIER[t] === TIER_TERMINAL;\n}\n\n/**\n * ctx.up carries control/demand tiers only (R-ctx-up / D269): DIRTY, PAUSE, RESUME, PULL,\n * INVALIDATE, TEARDOWN. DATA/RESOLVED (tier 3) and COMPLETE/ERROR (tier 5) are\n * down-only.\n * @param t - t value used by the helper.\n * @returns `true` when the value matches the expected shape.\n * @category core\n * @example\n * ```ts\n * import { isUpAllowed } from \"@graphrefly/ts/core\";\n * ```\n */\nexport function isUpAllowed(t: MessageType): boolean {\n\tconst tier = TIER[t];\n\treturn tier !== TIER_VALUE && tier !== TIER_TERMINAL;\n}\n","/**\n * Public testing assertions for
|
|
1
|
+
{"version":3,"sources":["../../src/testing/index.ts","../../src/protocol/messages.ts","../../src/testing/assertions.ts"],"sourcesContent":["export {\n\tassertDirtyPrecedesTerminalData,\n\ttype MessageSequence,\n} from \"./assertions.js\";\n","/**\n * Wave-protocol message types and the tier const table.\n *\n * Canonical authority: ~/src/graphrefly/spec/rules.jsonl\n * R-msg-format, R-msg-closed-set, R-tier (D34), R-data-payload, R-sentinel.\n */\n\n/** Opaque pause-lock / pull identifier (R-pause-lockset, R-pull). */\nexport type LockId = string | symbol;\n\n/** Explicit pull demand payload (D269/D272). Params are holder-visible context, never DATA-up. */\nexport interface PullDemand {\n\treadonly pullId: LockId;\n\treadonly params?: unknown;\n}\n\n/**\n * The CLOSED set of 11 message types (R-msg-closed-set / D9 + D269 + START handshake).\n * No open set, no user-defined custom types. Adding a type is a spec change.\n */\nexport type Message =\n\t| readonly [\"START\"]\n\t| readonly [\"DIRTY\"]\n\t| readonly [\"DATA\", unknown]\n\t| readonly [\"RESOLVED\"]\n\t| readonly [\"INVALIDATE\"]\n\t| readonly [\"COMPLETE\"]\n\t| readonly [\"ERROR\", unknown]\n\t| readonly [\"TEARDOWN\"]\n\t| readonly [\"PAUSE\", LockId]\n\t| readonly [\"RESUME\", LockId]\n\t| readonly [\"PULL\", PullDemand];\n\n/** One array of messages delivered in one call = one Wave (R-wave-boundary). */\nexport type Wave = readonly Message[];\n\n/** The message-type tag (the first tuple element). */\nexport type MessageType = Message[0];\n\n/**\n * SENTINEL = absence-of-DATA (R-sentinel / D16). TS representation is `undefined`.\n * Never a valid DATA payload; `null` IS a valid DATA value (domain-level absence).\n */\nexport const SENTINEL = undefined;\n\n/** R-data-payload: ERROR payloads must not collide with terminal metadata shorthand.\n * @param v - v value used by the helper.\n * @returns `true` when the value matches the expected shape.\n * @category core\n * @example\n * ```ts\n * import { isInvalidErrorPayload } from \"@graphrefly/ts/core\";\n * ```\n */\nexport function isInvalidErrorPayload(v: unknown): boolean {\n\treturn v === SENTINEL || typeof v === \"boolean\";\n}\n\n/** R-data-payload / D78: host-language failures that collide with ctx.terminal shorthand become diagnostics.\n * @param reason - reason value used by the helper.\n * @param fallback - fallback value used by the helper.\n * @returns The error payload result.\n * @category core\n * @example\n * ```ts\n * import { errorPayload } from \"@graphrefly/ts/core\";\n * ```\n */\nexport function errorPayload(reason: unknown, fallback = \"error without a valid payload\"): unknown {\n\treturn isInvalidErrorPayload(reason) ? new Error(fallback) : reason;\n}\n\nexport const TIER_START = 0;\nexport const TIER_CONTROL = 1;\nexport const TIER_NOTIFICATION = 2;\nexport const TIER_VALUE = 3;\nexport const TIER_SETTLE = 4;\nexport const TIER_TERMINAL = 5;\nexport const TIER_TEARDOWN = 6;\n\n/**\n * Tier const table (R-tier / D34). Tiers below value dispatch immediately; value\n * and above are batch-deferred. This is a compile-time const table (D18), not runtime config.\n */\nconst TIER: Record<MessageType, number> = {\n\tSTART: TIER_START,\n\tPAUSE: TIER_CONTROL,\n\tRESUME: TIER_CONTROL,\n\tPULL: TIER_CONTROL,\n\tDIRTY: TIER_NOTIFICATION,\n\tDATA: TIER_VALUE,\n\tRESOLVED: TIER_VALUE,\n\tINVALIDATE: TIER_SETTLE,\n\tCOMPLETE: TIER_TERMINAL,\n\tERROR: TIER_TERMINAL,\n\tTEARDOWN: TIER_TEARDOWN,\n};\n\n/**\n * Look up the tier number for a message type.\n *\n * @param t - One of the closed-set protocol message tags.\n * @returns The tier assigned by the compile-time tier table.\n * @example\n * ```ts\n * messageTier(\"DATA\"); // 3\n * ```\n * @category core\n */\nexport function messageTier(t: MessageType): number {\n\treturn TIER[t];\n}\n\n/** Value and above are deferred inside a batch (DATA/RESOLVED/INVALIDATE/terminal/teardown).\n * @param t - t value used by the helper.\n * @returns `true` when the value matches the expected shape.\n * @category core\n * @example\n * ```ts\n * import { isDeferredTier } from \"@graphrefly/ts/core\";\n * ```\n */\nexport function isDeferredTier(t: MessageType): boolean {\n\treturn TIER[t] >= TIER_VALUE;\n}\n\n/** Value-tier messages (DATA/RESOLVED) occupy the tier-3 slot.\n * @param t - t value used by the helper.\n * @returns `true` when the value matches the expected shape.\n * @category core\n * @example\n * ```ts\n * import { isValueTier } from \"@graphrefly/ts/core\";\n * ```\n */\nexport function isValueTier(t: MessageType): boolean {\n\treturn TIER[t] === TIER_VALUE;\n}\n\n/** The pause buffer holds the settle slice only: value-tier DATA/RESOLVED plus INVALIDATE.\n * @param t - t value used by the helper.\n * @returns `true` when the value matches the expected shape.\n * @category core\n * @example\n * ```ts\n * import { isPauseBufferedTier } from \"@graphrefly/ts/core\";\n * ```\n */\nexport function isPauseBufferedTier(t: MessageType): boolean {\n\tconst tier = TIER[t];\n\treturn tier === TIER_VALUE || tier === TIER_SETTLE;\n}\n\n/**\n * A TERMINAL message = tier 5 (COMPLETE | ERROR), R-tier / D34. Detected via the CENTRAL tier\n * table, NOT a per-variant `=== \"COMPLETE\" || === \"ERROR\"` check — so terminal routing stays\n * driven by the one const table (feedback_use_tier_for_signal_routing); discriminate COMPLETE vs\n * ERROR within the tier by the message type only where the handling actually differs.\n * @param t - t value used by the helper.\n * @returns `true` when the value matches the expected shape.\n * @category core\n * @example\n * ```ts\n * import { isTerminal } from \"@graphrefly/ts/core\";\n * ```\n */\nexport function isTerminal(t: MessageType): boolean {\n\treturn TIER[t] === TIER_TERMINAL;\n}\n\n/**\n * ctx.up carries control/demand tiers only (R-ctx-up / D269): DIRTY, PAUSE, RESUME, PULL,\n * INVALIDATE, TEARDOWN. DATA/RESOLVED (tier 3) and COMPLETE/ERROR (tier 5) are\n * down-only.\n * @param t - t value used by the helper.\n * @returns `true` when the value matches the expected shape.\n * @category core\n * @example\n * ```ts\n * import { isUpAllowed } from \"@graphrefly/ts/core\";\n * ```\n */\nexport function isUpAllowed(t: MessageType): boolean {\n\tconst tier = TIER[t];\n\treturn tier !== TIER_VALUE && tier !== TIER_TERMINAL;\n}\n","/**\n * Public testing assertions for GraphReFly message streams.\n *\n * These helpers validate captured protocol output; they do not participate in propagation.\n */\n\nimport { isValueTier, type Message, type Wave } from \"../protocol/messages.js\";\n\n/** Captured subscriber messages grouped by wave. START/replay handshake messages occupy one wave. */\nexport type MessageSequence = readonly Wave[];\n\n/**\n * Assert that observed tier-3 settlements (DATA/RESOLVED) are preceded by DIRTY.\n *\n * This encodes R-dirty-before-data for wave-framed subscriber traces. The leading\n * START push-on-subscribe/replay handshake wave is exempt because cached/replay DATA is\n * advertised to a new subscriber without opening a propagation wave.\n * @param messages - messages value used by the helper.\n * @returns The narrowed, validated value.\n * @category testing\n * @example\n * ```ts\n * import { assertDirtyPrecedesTerminalData } from \"@graphrefly/ts/testing\";\n * ```\n */\nexport function assertDirtyPrecedesTerminalData(messages: MessageSequence): void {\n\tfor (let waveIndex = 0; waveIndex < messages.length; waveIndex += 1) {\n\t\tconst wave = messages[waveIndex];\n\t\tlet handshake = false;\n\t\tlet openedByDirty = false;\n\n\t\tfor (let msgIndex = 0; msgIndex < wave.length; msgIndex += 1) {\n\t\t\tconst msg = wave[msgIndex] as Message;\n\t\t\tconst type = msg[0];\n\n\t\t\tif (msgIndex === 0 && type === \"START\") {\n\t\t\t\thandshake = true;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (handshake && type === \"DATA\") {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\thandshake = false;\n\n\t\t\tif (type === \"DIRTY\") {\n\t\t\t\topenedByDirty = true;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (isValueTier(type)) {\n\t\t\t\tif (!openedByDirty) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`assertDirtyPrecedesTerminalData: ${type} at wave ${waveIndex}, index ${msgIndex} arrived without a preceding DIRTY in the same wave (R-dirty-before-data). Wave: ${describeWave(wave, msgIndex)}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\topenedByDirty = false;\n\t\t}\n\t}\n}\n\nfunction describeWave(wave: Wave, around: number): string {\n\tconst parts: string[] = [];\n\tfor (let i = 0; i < wave.length; i += 1) {\n\t\tparts.push(`${i === around ? \"-> \" : \" \"}[${wave[i]?.[0] ?? \"?\"}]`);\n\t}\n\treturn parts.join(\", \");\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACwEO,IAAM,aAAa;AACnB,IAAM,eAAe;AACrB,IAAM,oBAAoB;AAC1B,IAAM,aAAa;AACnB,IAAM,cAAc;AACpB,IAAM,gBAAgB;AACtB,IAAM,gBAAgB;AAM7B,IAAM,OAAoC;AAAA,EACzC,OAAO;AAAA,EACP,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,OAAO;AAAA,EACP,MAAM;AAAA,EACN,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,UAAU;AAAA,EACV,OAAO;AAAA,EACP,UAAU;AACX;AAuCO,SAAS,YAAY,GAAyB;AACpD,SAAO,KAAK,CAAC,MAAM;AACpB;;;AChHO,SAAS,gCAAgC,UAAiC;AAChF,WAAS,YAAY,GAAG,YAAY,SAAS,QAAQ,aAAa,GAAG;AACpE,UAAM,OAAO,SAAS,SAAS;AAC/B,QAAI,YAAY;AAChB,QAAI,gBAAgB;AAEpB,aAAS,WAAW,GAAG,WAAW,KAAK,QAAQ,YAAY,GAAG;AAC7D,YAAM,MAAM,KAAK,QAAQ;AACzB,YAAM,OAAO,IAAI,CAAC;AAElB,UAAI,aAAa,KAAK,SAAS,SAAS;AACvC,oBAAY;AACZ;AAAA,MACD;AAEA,UAAI,aAAa,SAAS,QAAQ;AACjC;AAAA,MACD;AACA,kBAAY;AAEZ,UAAI,SAAS,SAAS;AACrB,wBAAgB;AAChB;AAAA,MACD;AAEA,UAAI,YAAY,IAAI,GAAG;AACtB,YAAI,CAAC,eAAe;AACnB,gBAAM,IAAI;AAAA,YACT,oCAAoC,IAAI,YAAY,SAAS,WAAW,QAAQ,oFAAoF,aAAa,MAAM,QAAQ,CAAC;AAAA,UACjM;AAAA,QACD;AACA;AAAA,MACD;AAEA,sBAAgB;AAAA,IACjB;AAAA,EACD;AACD;AAEA,SAAS,aAAa,MAAY,QAAwB;AACzD,QAAM,QAAkB,CAAC;AACzB,WAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK,GAAG;AACxC,UAAM,KAAK,GAAG,MAAM,SAAS,QAAQ,KAAK,IAAI,KAAK,CAAC,IAAI,CAAC,KAAK,GAAG,GAAG;AAAA,EACrE;AACA,SAAO,MAAM,KAAK,IAAI;AACvB;","names":[]}
|
package/dist/testing/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { W as Wave } from '../messages-X4xsRuK0.cjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Public testing assertions for
|
|
4
|
+
* Public testing assertions for GraphReFly message streams.
|
|
5
5
|
*
|
|
6
6
|
* These helpers validate captured protocol output; they do not participate in propagation.
|
|
7
7
|
*/
|
package/dist/testing/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { W as Wave } from '../messages-X4xsRuK0.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Public testing assertions for
|
|
4
|
+
* Public testing assertions for GraphReFly message streams.
|
|
5
5
|
*
|
|
6
6
|
* These helpers validate captured protocol output; they do not participate in propagation.
|
|
7
7
|
*/
|
package/dist/testing/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as Graph } from '../graph-
|
|
1
|
+
import { d as Graph } from '../graph-DpUhfPg-.cjs';
|
|
2
2
|
import { b as WorkQueueOptions, c as WorkQueue } from '../types-CY_QjSyK.cjs';
|
|
3
3
|
export { d as WorkQueueAvailableItem, e as WorkQueueAvailablePage, f as WorkQueueAvailableParams, g as WorkQueueAvailableProjection, W as WorkQueueCommand, h as WorkQueueDeadLetterPage, i as WorkQueueDeadLetterParams, j as WorkQueueDerivedState, k as WorkQueueProjection, a as WorkQueueRecord, l as WorkQueueRetryPolicy, m as WorkQueueStatus, n as WorkQueueWorkSnapshot } from '../types-CY_QjSyK.cjs';
|
|
4
4
|
import '../core/index.cjs';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as Graph } from '../graph-
|
|
1
|
+
import { d as Graph } from '../graph-BYcUX6Y-.js';
|
|
2
2
|
import { b as WorkQueueOptions, c as WorkQueue } from '../types-C_vDxB5m.js';
|
|
3
3
|
export { d as WorkQueueAvailableItem, e as WorkQueueAvailablePage, f as WorkQueueAvailableParams, g as WorkQueueAvailableProjection, W as WorkQueueCommand, h as WorkQueueDeadLetterPage, i as WorkQueueDeadLetterParams, j as WorkQueueDerivedState, k as WorkQueueProjection, a as WorkQueueRecord, l as WorkQueueRetryPolicy, m as WorkQueueStatus, n as WorkQueueWorkSnapshot } from '../types-C_vDxB5m.js';
|
|
4
4
|
import '../core/index.js';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphrefly/ts",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "GraphReFly
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "GraphReFly TypeScript package: synchronous reactive graphs, operators, sources, storage, renderers, adapters, and testing helpers.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/graphrefly/graphrefly-ts"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/testing/assertions.ts"],"sourcesContent":["/**\n * Public testing assertions for clean-slate GraphReFly message streams.\n *\n * These helpers validate captured protocol output; they do not participate in propagation.\n */\n\nimport { isValueTier, type Message, type Wave } from \"../protocol/messages.js\";\n\n/** Captured subscriber messages grouped by wave. START/replay handshake messages occupy one wave. */\nexport type MessageSequence = readonly Wave[];\n\n/**\n * Assert that observed tier-3 settlements (DATA/RESOLVED) are preceded by DIRTY.\n *\n * This encodes R-dirty-before-data for wave-framed subscriber traces. The leading\n * START push-on-subscribe/replay handshake wave is exempt because cached/replay DATA is\n * advertised to a new subscriber without opening a propagation wave.\n * @param messages - messages value used by the helper.\n * @returns The narrowed, validated value.\n * @category testing\n * @example\n * ```ts\n * import { assertDirtyPrecedesTerminalData } from \"@graphrefly/ts/testing\";\n * ```\n */\nexport function assertDirtyPrecedesTerminalData(messages: MessageSequence): void {\n\tfor (let waveIndex = 0; waveIndex < messages.length; waveIndex += 1) {\n\t\tconst wave = messages[waveIndex];\n\t\tlet handshake = false;\n\t\tlet openedByDirty = false;\n\n\t\tfor (let msgIndex = 0; msgIndex < wave.length; msgIndex += 1) {\n\t\t\tconst msg = wave[msgIndex] as Message;\n\t\t\tconst type = msg[0];\n\n\t\t\tif (msgIndex === 0 && type === \"START\") {\n\t\t\t\thandshake = true;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (handshake && type === \"DATA\") {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\thandshake = false;\n\n\t\t\tif (type === \"DIRTY\") {\n\t\t\t\topenedByDirty = true;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (isValueTier(type)) {\n\t\t\t\tif (!openedByDirty) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`assertDirtyPrecedesTerminalData: ${type} at wave ${waveIndex}, index ${msgIndex} arrived without a preceding DIRTY in the same wave (R-dirty-before-data). Wave: ${describeWave(wave, msgIndex)}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\topenedByDirty = false;\n\t\t}\n\t}\n}\n\nfunction describeWave(wave: Wave, around: number): string {\n\tconst parts: string[] = [];\n\tfor (let i = 0; i < wave.length; i += 1) {\n\t\tparts.push(`${i === around ? \"-> \" : \" \"}[${wave[i]?.[0] ?? \"?\"}]`);\n\t}\n\treturn parts.join(\", \");\n}\n"],"mappings":";;;;;AAyBO,SAAS,gCAAgC,UAAiC;AAChF,WAAS,YAAY,GAAG,YAAY,SAAS,QAAQ,aAAa,GAAG;AACpE,UAAM,OAAO,SAAS,SAAS;AAC/B,QAAI,YAAY;AAChB,QAAI,gBAAgB;AAEpB,aAAS,WAAW,GAAG,WAAW,KAAK,QAAQ,YAAY,GAAG;AAC7D,YAAM,MAAM,KAAK,QAAQ;AACzB,YAAM,OAAO,IAAI,CAAC;AAElB,UAAI,aAAa,KAAK,SAAS,SAAS;AACvC,oBAAY;AACZ;AAAA,MACD;AAEA,UAAI,aAAa,SAAS,QAAQ;AACjC;AAAA,MACD;AACA,kBAAY;AAEZ,UAAI,SAAS,SAAS;AACrB,wBAAgB;AAChB;AAAA,MACD;AAEA,UAAI,YAAY,IAAI,GAAG;AACtB,YAAI,CAAC,eAAe;AACnB,gBAAM,IAAI;AAAA,YACT,oCAAoC,IAAI,YAAY,SAAS,WAAW,QAAQ,oFAAoF,aAAa,MAAM,QAAQ,CAAC;AAAA,UACjM;AAAA,QACD;AACA;AAAA,MACD;AAEA,sBAAgB;AAAA,IACjB;AAAA,EACD;AACD;AAEA,SAAS,aAAa,MAAY,QAAwB;AACzD,QAAM,QAAkB,CAAC;AACzB,WAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK,GAAG;AACxC,UAAM,KAAK,GAAG,MAAM,SAAS,QAAQ,KAAK,IAAI,KAAK,CAAC,IAAI,CAAC,KAAK,GAAG,GAAG;AAAA,EACrE;AACA,SAAO,MAAM,KAAK,IAAI;AACvB;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
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\n/**\n * Merge restore registry entries into a duplicate-checking Map.\n *\n * @param entries - Additional restore entries to add.\n * @param base - Optional base registry to copy from.\n * @returns A Map keyed by restore ref.\n * @example\n * ```ts\n * restoreRegistry([define(\"trim\", (value: string) => value.trim())]);\n * ```\n * @category operators\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\n/**\n * Register a named restore definition.\n *\n * @param ref - Stable restore reference name.\n * @param fn - Pure transform function used during restoration.\n * @param opts - Optional registry to receive the new definition.\n * @returns A named definition record.\n * @example\n * ```ts\n * define(\"trim\", (value: string) => value.trim());\n * ```\n * @category operators\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 * @param op - op value used by the helper.\n * @param deps - Declared dependency node or nodes.\n * @param opts - Options that configure the helper.\n * @returns A `Node<TOut>` value.\n * @category operators\n * @example\n * ```ts\n * import { initNode } from \"@graphrefly/ts/operators\";\n * ```\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/**\n * Transform each upstream DATA value with a synchronous mapping function.\n *\n * @param fn - Mapping function, or a named `define()` definition for checkpoint restoration.\n * @returns An operator that emits `fn(value)` for each upstream value.\n * @example\n * ```ts\n * import { graph } from \"@graphrefly/ts/graph\";\n * import { map } from \"@graphrefly/ts/operators\";\n *\n * const g = graph();\n * const count = g.state(1);\n * const doubled = g.initNode(map((value: number) => value * 2), [count]);\n * ```\n * @remarks **Restorable maps:** Passing a named `define()` registers semantic restore metadata.\n * @category operators\n */\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/**\n * Pass through upstream values that satisfy a predicate.\n *\n * @param pred - Predicate evaluated for each upstream DATA value.\n * @returns An operator that emits matching values and stays quiet for non-matches.\n * @example\n * ```ts\n * import { graph } from \"@graphrefly/ts/graph\";\n * import { filter } from \"@graphrefly/ts/operators\";\n *\n * const g = graph();\n * const count = g.state(0);\n * const even = g.initNode(filter((value: number) => value % 2 === 0), [count]);\n * ```\n * @category operators\n */\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/**\n * Accumulate upstream values and emit each intermediate accumulator.\n *\n * @param reducer - Reducer called with the previous accumulator and each upstream value.\n * @param seed - Initial accumulator value.\n * @returns An operator that emits the accumulator after every input value.\n * @example\n * ```ts\n * import { graph } from \"@graphrefly/ts/graph\";\n * import { scan } from \"@graphrefly/ts/operators\";\n *\n * const g = graph();\n * const values = g.state(1);\n * const total = g.initNode(scan((sum: number, value: number) => sum + value, 0), [values]);\n * ```\n * @category operators\n */\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/**\n * Emit the first `n` upstream values, then complete.\n *\n * @param n - Number of DATA values to pass before completion.\n * @returns An operator that forwards at most `n` values and then emits COMPLETE.\n * @example\n * ```ts\n * import { graph } from \"@graphrefly/ts/graph\";\n * import { take } from \"@graphrefly/ts/operators\";\n *\n * const firstThree = graph().initNode(take<number>(3), [source]);\n * ```\n * @category operators\n */\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/**\n * Suppress consecutive duplicate values.\n *\n * @param eq - Equality predicate; defaults to `Object.is`.\n * @returns An operator that emits only when the next value differs from the previous emitted value.\n * @example\n * ```ts\n * import { graph } from \"@graphrefly/ts/graph\";\n * import { distinctUntilChanged } from \"@graphrefly/ts/operators\";\n *\n * const stable = graph().initNode(distinctUntilChanged<number>(), [source]);\n * ```\n * @category operators\n */\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 *\n * @returns An operator that forwards DATA from any dependency.\n * @example\n * ```ts\n * import { graph } from \"@graphrefly/ts/graph\";\n * import { merge } from \"@graphrefly/ts/operators\";\n *\n * const merged = graph().initNode(merge<number>(), [left, right]);\n * ```\n * @category operators\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 *\n * @param reducer - Reducer called with the accumulator and each upstream DATA value.\n * @param seed - Initial accumulator value emitted if the source completes empty.\n * @returns An operator that emits one accumulated value when the source completes.\n * @example\n * ```ts\n * import { graph } from \"@graphrefly/ts/graph\";\n * import { reduce } from \"@graphrefly/ts/operators\";\n *\n * const total = graph().initNode(reduce((sum: number, value: number) => sum + value, 0), [source]);\n * ```\n * @category operators\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 * @returns A `Operator<S, readonly [S, S]>` value.\n * @category operators\n * @example\n * ```ts\n * import { pairwise } from \"@graphrefly/ts/operators\";\n * ```\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.\n * @param n - n value used by the helper.\n * @returns A `Operator<S, S>` value.\n * @category operators\n * @example\n * ```ts\n * import { skip } from \"@graphrefly/ts/operators\";\n * ```\n */\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 * @param pred - pred value used by the helper.\n * @returns A `Operator<S, S>` value.\n * @category operators\n * @example\n * ```ts\n * import { takeWhile } from \"@graphrefly/ts/operators\";\n * ```\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 * @param pred - pred value used by the helper.\n * @returns A `Operator<S, S>` value.\n * @category operators\n * @example\n * ```ts\n * import { first } from \"@graphrefly/ts/operators\";\n * ```\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 * @param pred - pred value used by the helper.\n * @returns A `Operator<S, S>` value.\n * @category operators\n * @example\n * ```ts\n * import { last } from \"@graphrefly/ts/operators\";\n * ```\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 * @param pred - pred value used by the helper.\n * @returns A `Operator<S, S>` value.\n * @category operators\n * @example\n * ```ts\n * import { find } from \"@graphrefly/ts/operators\";\n * ```\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 * @param index - index value used by the helper.\n * @returns A `Operator<S, S>` value.\n * @category operators\n * @example\n * ```ts\n * import { elementAt } from \"@graphrefly/ts/operators\";\n * ```\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 * @param fnOrObserver - fn or observer value used by the helper.\n * @returns A `Operator<S, S>` value.\n * @category operators\n * @example\n * ```ts\n * import { tap } from \"@graphrefly/ts/operators\";\n * ```\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 * @param fn - Synchronous function invoked by the helper.\n * @param opts - Options that configure the helper.\n * @returns A `Operator<S, S>` value.\n * @category operators\n * @example\n * ```ts\n * import { onFirstData } from \"@graphrefly/ts/operators\";\n * ```\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 * @param opts - Options that configure the helper.\n * @returns A `Operator<S, S>` value.\n * @category operators\n * @example\n * ```ts\n * import { settle } from \"@graphrefly/ts/operators\";\n * ```\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 * @param recover - recover value used by the helper.\n * @returns A `Operator<S, S>` value.\n * @category operators\n * @example\n * ```ts\n * import { rescue } from \"@graphrefly/ts/operators\";\n * ```\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 * @param opts - Options that configure the helper.\n * @returns A `Operator<S, S>` value.\n * @category operators\n * @example\n * ```ts\n * import { valve } from \"@graphrefly/ts/operators\";\n * ```\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 !== undefined) {\n\t\t\t\tctx.down([[\"DATA\", srcLatest as S]]);\n\t\t\t}\n\t\t},\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAYO,IAAM,2BAA2B;AAyDjC,SAAS,iBAAiB,OAAgB,OAAO,KAA0B;AACjF,MAAI;AACH,WAAO,gBAAgB,OAAO,gBAAgB,OAAO,KAAK,CAAC;AAAA,EAC5D,SAAS,OAAO;AACf,UAAM,IAAI,UAAU,wBAAwB,IAAI,kCAAkC;AAAA,MACjF;AAAA,IACD,CAAC;AAAA,EACF;AACD;AAEO,SAAS,gBACf,OACA,SACA,MACuB;AACvB,MAAI,CAAC,WAAW,UAAU,SAAU,QAAO,EAAE,MAAM,WAAW;AAC9D,SAAO,EAAE,MAAM,QAAQ,MAAM,iBAAiB,OAAO,IAAI,EAAE;AAC5D;AAEO,SAAS,mBAAmB,OAAgB,MAAuC;AACzF,MAAI,UAAU,OAAW,QAAO,EAAE,MAAM,OAAO;AAC/C,MAAI,UAAU,KAAM,QAAO,EAAE,MAAM,WAAW;AAC9C,SAAO,EAAE,MAAM,SAAS,OAAO,iBAAiB,OAAO,IAAI,EAAE;AAC9D;AAIA,IAAM,2BAA2B,oBAAI,QAAgD;AAG9E,SAAS,gCACf,MACA,aACO;AACP,2BAAyB,IAAI,MAAM,WAAW;AAC/C;AAGO,SAAS,6BACf,MACA,MACkC;AAClC,QAA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C,CAAC,CAAC;AACrD;AAAA,MACD;AAEA,UAAI,CAAC,aAAc;AAEnB,UAAI,YAAY,SAAS,SAAS,GAAG;AACpC,mBAAW,KAAK,SAAU,KAAI,KAAK,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;AAChD;AAAA,MACD;AAEA,YAAM,YAAY,UAAU,KAAK,CAAC;AAClC,UAAI,YAAY,SAAS,SAAS,KAAK,cAAc,QAAW;AAC/D,YAAI,KAAK,CAAC,CAAC,QAAQ,SAAc,CAAC,CAAC;AAAA,MACpC;AAAA,IACD;AAAA,EACD;AACD;","names":["last"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/patterns/inspection.ts"],"sourcesContent":["/**\n * Horizontal inspection patterns re-derived from old presets (B62 / D125).\n *\n * These helpers compose the clean-slate graph inspection egresses. They do not\n * add graph nodes, hidden subscriptions, policy gates, or storage ownership.\n */\n\nimport type { Graph } from \"../graph/graph.js\";\nimport type { NodeProfile } from \"../graph/inspect.js\";\n\nexport interface ProfileSummaryNode {\n\tpath: string;\n\tinvokes: number;\n\ttotalDurationNs: number;\n\tlastDurationNs: number;\n\tstatus: NodeProfile[\"status\"];\n}\n\nexport interface ProfileSummary {\n\t/** Number of nodes in describe(), including nodes with zero invokes. */\n\tnodeCount: number;\n\ttotalInvokes: number;\n\tbyStatus: Partial<Record<NodeProfile[\"status\"], number>>;\n\t/** Nodes sorted by invokes desc, then path asc. */\n\thotNodes: ProfileSummaryNode[];\n}\n\n/**\n * Summarize an opt-in Graph.profile() snapshot while keeping describe() as the\n * source of node cardinality. No counters are stored on nodes (R-profile).\n * @param graph - Graph that owns the created nodes or projector.\n * @param opts - Options that configure the helper.\n * @returns A `ProfileSummary` value.\n * @category patterns\n * @example\n * ```ts\n * import { profileSummary } from \"@graphrefly/ts/patterns\";\n * ```\n */\nexport function profileSummary(graph: Graph, opts: { limit?: number } = {}): ProfileSummary {\n\tconst profile = graph.profile();\n\tconst described = graph.describe();\n\tconst nodeIds = new Set(described.nodes.map((node) => node.id));\n\tfor (const id of Object.keys(profile.nodes)) nodeIds.add(id);\n\n\tconst byStatus: Partial<Record<NodeProfile[\"status\"], number>> = {};\n\tconst hotNodes: ProfileSummaryNode[] = [];\n\tfor (const path of [...nodeIds].sort()) {\n\t\tconst nodeProfile = profile.nodes[path];\n\t\tif (nodeProfile === undefined) continue;\n\t\tbyStatus[nodeProfile.status] = (byStatus[nodeProfile.status] ?? 0) + 1;\n\t\thotNodes.push({\n\t\t\tpath,\n\t\t\tinvokes: nodeProfile.invokes,\n\t\t\ttotalDurationNs: nodeProfile.totalDurationNs,\n\t\t\tlastDurationNs: nodeProfile.lastDurationNs,\n\t\t\tstatus: nodeProfile.status,\n\t\t});\n\t}\n\thotNodes.sort((a, b) => b.invokes - a.invokes || a.path.localeCompare(b.path));\n\treturn {\n\t\tnodeCount: nodeIds.size,\n\t\ttotalInvokes: profile.totalInvokes,\n\t\tbyStatus,\n\t\thotNodes: hotNodes.slice(0, opts.limit ?? hotNodes.length),\n\t};\n}\n"],"mappings":";AAuCO,SAAS,eAAe,OAAc,OAA2B,CAAC,GAAmB;AAC3F,QAAM,UAAU,MAAM,QAAQ;AAC9B,QAAM,YAAY,MAAM,SAAS;AACjC,QAAM,UAAU,IAAI,IAAI,UAAU,MAAM,IAAI,CAAC,SAAS,KAAK,EAAE,CAAC;AAC9D,aAAW,MAAM,OAAO,KAAK,QAAQ,KAAK,EAAG,SAAQ,IAAI,EAAE;AAE3D,QAAM,WAA2D,CAAC;AAClE,QAAM,WAAiC,CAAC;AACxC,aAAW,QAAQ,CAAC,GAAG,OAAO,EAAE,KAAK,GAAG;AACvC,UAAM,cAAc,QAAQ,MAAM,IAAI;AACtC,QAAI,gBAAgB,OAAW;AAC/B,aAAS,YAAY,MAAM,KAAK,SAAS,YAAY,MAAM,KAAK,KAAK;AACrE,aAAS,KAAK;AAAA,MACb;AAAA,MACA,SAAS,YAAY;AAAA,MACrB,iBAAiB,YAAY;AAAA,MAC7B,gBAAgB,YAAY;AAAA,MAC5B,QAAQ,YAAY;AAAA,IACrB,CAAC;AAAA,EACF;AACA,WAAS,KAAK,CAAC,GAAG,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,KAAK,cAAc,EAAE,IAAI,CAAC;AAC7E,SAAO;AAAA,IACN,WAAW,QAAQ;AAAA,IACnB,cAAc,QAAQ;AAAA,IACtB;AAAA,IACA,UAAU,SAAS,MAAM,GAAG,KAAK,SAAS,SAAS,MAAM;AAAA,EAC1D;AACD;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/graph/higher-order.ts","../src/graph/time.ts"],"sourcesContent":["/**\n * Higher-order operators — switchMap / mergeMap / concatMap / exhaustMap / flatMap\n * (D47 / R-rewire-deferred / CSP-2.7; per-language sugar, D6/D24, never in parity).\n *\n * Each projects every outer value to an INNER source and flattens the inners' emissions. The\n * inner sources are wired as runtime DEPS via the deferred-self-rewire substrate affordance\n * (`ctx.rewireNext`, D47) — NOT an internal subscribe (D45 bans that; it would create a describe\n * island). Growing/shrinking the dep set is deferred to the committed wave boundary, so a fn\n * never mutates its own topology mid-run (that is the D37 feedback-cycle ERROR). An inner that\n * COMPLETEs is `unsubscribeDep`'d → its source `_deactivate`s + fires `onDeactivation`: that is the\n * cancellation / abortInFlight basis (switchMap drops the superseded inner's WORK, not just its\n * output; mergeMap bounds memory). Built on the bare `node` primitive via the {@link Operator}\n * factory shape + the `g.initNode` funnel (D43), so the real factory name shows in describe.\n *\n * Lifecycle folding (D47/D81): completeWhenDepsComplete:false + terminalAsRealInput:true +\n * errorWhenDepsError:false — the operator owns completion (emit COMPLETE only when the SOURCE is\n * done AND no inner is live / pending), and observes source/inner ERROR so it can remove every live\n * inner before emitting ERROR. Those removals drain after terminal via D62: terminal seals output,\n * while helper-owned upstream work still sees unsubscribeDep->_deactivate->onDeactivation teardown.\n *\n * Alignment: each run issues REMOVES before ADDS so the per-node FIFO drain keeps the operator's\n * tracked inner list aligned with the live dep order across the intermediate boundary waves (a\n * removed dep is silent — no settle — and applies before any added dep's push-on-subscribe wave).\n */\n\nimport {\n\tCTX_NODE_BINDING,\n\ttype Ctx,\n\tdepBatch,\n\tdepCount,\n\tdepTerminal,\n\tisTerminalComplete,\n\tisTerminalError,\n\ttype NodeFn,\n\tterminalErrorValue,\n} from \"../ctx/types.js\";\nimport type { Node } from \"../node/node.js\";\nimport { errorPayload } from \"../protocol/messages.js\";\nimport { initNode, type Operator } from \"./operators.js\";\nimport { fromAsyncIter, fromIter, fromPromise, type NodeInput, of } from \"./sources.js\";\n\n/** Project an outer value to an inner source (a Node, Promise, (a)sync iterable, or scalar). */\nexport type Project<TIn, TOut> = (value: TIn) => NodeInput<TOut>;\n\ntype Mode = \"merge\" | \"switch\" | \"concat\" | \"exhaust\";\n\n/** Options for {@link mergeMap}. */\nexport interface MergeMapOptions {\n\t/**\n\t * Maximum number of live inner deps at once. `undefined`/`Infinity` keeps the default\n\t * unbounded mergeMap behavior; finite values queue outer values until an inner COMPLETEs.\n\t */\n\treadonly concurrent?: number;\n}\n\n/** Per-node bookkeeping (ctx.state): the live inner deps (aligned with deps[1..]) + pending queue. */\ninterface MapState<TIn> {\n\tinners: Node<unknown>[];\n\tqueue: TIn[]; // concatMap / bounded mergeMap pending values (lazy projection)\n\tsourceDone: boolean;\n}\n\nfunction uniqueNodes(nodes: readonly Node<unknown>[]): Node<unknown>[] {\n\tconst seen = new Set<Node<unknown>>();\n\tconst out: Node<unknown>[] = [];\n\tfor (const n of nodes) {\n\t\tif (seen.has(n)) continue;\n\t\tseen.add(n);\n\t\tout.push(n);\n\t}\n\treturn out;\n}\n\nfunction cleanupAllInners<TIn>(ctx: Ctx, st: MapState<TIn>, body: NodeFn): void {\n\tfor (const inner of uniqueNodes(st.inners)) ctx.rewireNext.unsubscribeDep(inner, body);\n\tst.inners = [];\n\tst.queue.length = 0;\n\tst.sourceDone = true;\n\tctx.state.set(st);\n}\n\nfunction firstErrorTerminal(ctx: Ctx): unknown {\n\tfor (let i = 0; i < depCount(ctx); i++) {\n\t\tconst terminal = depTerminal(ctx, i);\n\t\tif (isTerminalError(terminal)) return terminalErrorValue(terminal);\n\t}\n\treturn undefined;\n}\n\nfunction fromAnyInCtx<T>(ctx: Ctx, input: NodeInput<T>): Node<unknown> {\n\tconst binding = ctx[CTX_NODE_BINDING];\n\tif (isNode(input)) return input as Node<unknown>;\n\n\tconst nodeOpts = binding ? { dispatcher: binding.dispatcher } : {};\n\tconst make = (op: Operator<never, T>) =>\n\t\t(binding\n\t\t\t? binding.create(() => initNode(op, [], nodeOpts))\n\t\t\t: initNode(op, [], nodeOpts)) as Node<unknown>;\n\n\tif (isThenable(input)) return make(fromPromise(input as PromiseLike<T>));\n\tif (input !== null && input !== undefined) {\n\t\tconst candidate = input as {\n\t\t\t[Symbol.asyncIterator]?: unknown;\n\t\t\t[Symbol.iterator]?: unknown;\n\t\t};\n\t\tif (typeof candidate[Symbol.asyncIterator] === \"function\") {\n\t\t\treturn make(fromAsyncIter(input as AsyncIterable<T>));\n\t\t}\n\t\tif (typeof candidate[Symbol.iterator] === \"function\") {\n\t\t\treturn make(fromIter(input as Iterable<T>));\n\t\t}\n\t}\n\treturn make(of(input as T));\n}\n\nfunction isNode(x: unknown): x is Node {\n\treturn (\n\t\tx != null &&\n\t\ttypeof x === \"object\" &&\n\t\t\"cache\" in x &&\n\t\ttypeof (x as Node).subscribe === \"function\"\n\t);\n}\n\nfunction isThenable(x: unknown): x is PromiseLike<unknown> {\n\treturn x != null && typeof (x as PromiseLike<unknown>).then === \"function\";\n}\n\nfunction normalizeConcurrent(factory: string, concurrent: number | undefined): number {\n\tif (concurrent === undefined || concurrent === Number.POSITIVE_INFINITY) {\n\t\treturn Number.POSITIVE_INFINITY;\n\t}\n\tif (!Number.isInteger(concurrent) || concurrent < 1) {\n\t\tthrow new RangeError(`${factory}: concurrent must be a positive integer or Infinity`);\n\t}\n\treturn concurrent;\n}\n\n/**\n * The shared higher-order machinery. The operator depends on the source S at index 0; inner\n * sources occupy indices 1.. (added/removed at runtime via ctx.rewireNext). The body is\n * SELF-CATCHING (D30) and re-supplies itself on every rewire (the initNode wrap covers only the\n * first run; the re-supplied fn must stay self-catching).\n */\nfunction mapOperator<TIn, TOut>(\n\tfactory: string,\n\tproject: Project<TIn, TOut>,\n\tmode: Mode,\n\topts: { concurrent?: number } = {},\n): Operator<TIn, TOut> {\n\tconst maxConcurrent = normalizeConcurrent(factory, opts.concurrent);\n\tconst body: NodeFn = (ctx: Ctx) => {\n\t\tlet st: MapState<TIn> | undefined;\n\t\ttry {\n\t\t\tst = (ctx.state.get<MapState<TIn>>() ?? {\n\t\t\t\tinners: [],\n\t\t\t\tqueue: [],\n\t\t\t\tsourceDone: false,\n\t\t\t}) as MapState<TIn>;\n\t\t\tlet inners = st.inners;\n\t\t\tconst queue = st.queue;\n\n\t\t\t// 1. forward any inner DATA this wave (index-independent — flatten whichever inner fired).\n\t\t\tfor (let i = 1; i < depCount(ctx); i++) {\n\t\t\t\tconst b = depBatch(ctx, i);\n\t\t\t\tif (b && b.length > 0) for (const v of b) ctx.down([[\"DATA\", v]]);\n\t\t\t}\n\n\t\t\t// D81: source ERROR / inner ERROR are terminal operator edges. Detach live inners first,\n\t\t\t// then emit ERROR. Same-wave inner DATA that preceded the terminal is forwarded above.\n\t\t\t// Do not send COMPLETE/ERROR to those inner sources.\n\t\t\tconst terminalError = firstErrorTerminal(ctx);\n\t\t\tif (terminalError !== undefined) {\n\t\t\t\tcleanupAllInners(ctx, st, body);\n\t\t\t\tctx.down([[\"ERROR\", terminalError]]);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (isTerminalComplete(depTerminal(ctx, 0))) st.sourceDone = true;\n\n\t\t\t// 2. drop inners that terminated this/any wave (bounding); `inners` aligns with deps[1..].\n\t\t\tconst toRemove: Node<unknown>[] = [];\n\t\t\tconst survivors: Node<unknown>[] = [];\n\t\t\tfor (let i = 0; i < inners.length; i++) {\n\t\t\t\tif (isTerminalComplete(depTerminal(ctx, i + 1))) toRemove.push(inners[i]);\n\t\t\t\telse survivors.push(inners[i]);\n\t\t\t}\n\t\t\tinners = survivors;\n\n\t\t\t// 3. project the source's new value(s) per mode.\n\t\t\tconst toAdd: Node<unknown>[] = [];\n\t\t\tconst make = (v: TIn): Node<unknown> => fromAnyInCtx(ctx, project(v));\n\t\t\tconst isRemovedThisWave = (inner: Node<unknown>): boolean => toRemove.includes(inner);\n\t\t\tconst canTrackInner = (inner: Node<unknown>): boolean =>\n\t\t\t\t!inners.includes(inner) && !isRemovedThisWave(inner);\n\t\t\tconst enqueueMerge = (v: TIn) => {\n\t\t\t\tif (maxConcurrent === Number.POSITIVE_INFINITY && queue.length === 0) {\n\t\t\t\t\tconst inner = make(v);\n\t\t\t\t\t// a projector returning an ALREADY-LIVE Node is already merged: subscribeDep is\n\t\t\t\t\t// set-idempotent, so double-tracking it in `inners` would desync the\n\t\t\t\t\t// inners[i] <-> deps[i+1] map permanently. Skip the duplicate.\n\t\t\t\t\tif (!canTrackInner(inner)) return;\n\t\t\t\t\tinners.push(inner);\n\t\t\t\t\ttoAdd.push(inner);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tqueue.push(v);\n\t\t\t};\n\t\t\tconst drainMergeQueue = () => {\n\t\t\t\twhile (queue.length > 0 && inners.length < maxConcurrent) {\n\t\t\t\t\tconst inner = make(queue.shift() as TIn);\n\t\t\t\t\tif (!canTrackInner(inner)) continue;\n\t\t\t\t\tinners.push(inner);\n\t\t\t\t\ttoAdd.push(inner);\n\t\t\t\t}\n\t\t\t};\n\t\t\tconst sb = depBatch(ctx, 0) as readonly TIn[] | null;\n\t\t\tif (sb && sb.length > 0) {\n\t\t\t\tif (mode === \"switch\") {\n\t\t\t\t\t// switch to the latest value: cancel every current inner EXCEPT a (re-projected)\n\t\t\t\t\t// already-live one — the dep set is unique, so removing+re-adding the same Node\n\t\t\t\t\t// would needlessly tear down + re-subscribe it. Superseded sources torn down.\n\t\t\t\t\tconst inner = make(sb[sb.length - 1]);\n\t\t\t\t\tfor (const live of inners) if (live !== inner) toRemove.push(live);\n\t\t\t\t\tif (isRemovedThisWave(inner)) {\n\t\t\t\t\t\tinners = [];\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (!inners.includes(inner)) toAdd.push(inner);\n\t\t\t\t\t\tinners = [inner];\n\t\t\t\t\t}\n\t\t\t\t} else if (mode === \"merge\") {\n\t\t\t\t\tfor (const v of sb) {\n\t\t\t\t\t\tenqueueMerge(v);\n\t\t\t\t\t}\n\t\t\t\t} else if (mode === \"concat\") {\n\t\t\t\t\tfor (const v of sb) queue.push(v); // lazy: project on activation\n\t\t\t\t} else {\n\t\t\t\t\t// exhaust: ignore the source while an inner is active.\n\t\t\t\t\tif (inners.length === 0) {\n\t\t\t\t\t\tconst inner = make(sb[0]);\n\t\t\t\t\t\tif (canTrackInner(inner)) {\n\t\t\t\t\t\t\tinners.push(inner);\n\t\t\t\t\t\t\ttoAdd.push(inner);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// 3a. bounded mergeMap: drain queued outer values as inner COMPLETEs free slots.\n\t\t\tif (mode === \"merge\" && queue.length > 0) drainMergeQueue();\n\n\t\t\t// 3b. concat: activate the queue head when the single slot is free.\n\t\t\tif (mode === \"concat\" && inners.length === 0 && toAdd.length === 0 && queue.length > 0) {\n\t\t\t\tconst inner = make(queue.shift() as TIn);\n\t\t\t\tif (canTrackInner(inner)) {\n\t\t\t\t\tinners.push(inner);\n\t\t\t\t\ttoAdd.push(inner);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tctx.state.set({ inners, queue, sourceDone: st.sourceDone });\n\n\t\t\t// 4. issue REMOVES before ADDS (alignment): a removed dep is silent + applies before the\n\t\t\t// added dep's push-on-subscribe settle wave, so the tracked list stays aligned.\n\t\t\tfor (const r of toRemove) ctx.rewireNext.unsubscribeDep(r, body);\n\t\t\tfor (const a of toAdd) ctx.rewireNext.subscribeDep(a, body);\n\n\t\t\t// 5. completion: the SOURCE is done AND nothing is live or pending → COMPLETE (D47 folding;\n\t\t\t// a queued/just-added inner keeps it open). If terminal output happens in a wave that\n\t\t\t// also queued cleanup rewire, D62 still drains that queue after terminal.\n\t\t\tif (st.sourceDone && inners.length === 0 && toAdd.length === 0 && queue.length === 0) {\n\t\t\t\tctx.down([[\"COMPLETE\"]]);\n\t\t\t}\n\t\t} catch (e) {\n\t\t\tif (st) cleanupAllInners(ctx, st, body);\n\t\t\tctx.down([[\"ERROR\", errorPayload(e, \"projector threw without a valid error payload\")]]); // D30/D81: a throwing projector → cleanup inners, then ERROR\n\t\t}\n\t};\n\n\treturn {\n\t\tfactory,\n\t\tbody,\n\t\t// D47/D81 folding: the operator owns completion + terminal ERROR cleanup.\n\t\topts: { completeWhenDepsComplete: false, terminalAsRealInput: true, errorWhenDepsError: false },\n\t};\n}\n\n/**\n * switchMap: project each source value to an inner; on a new source value, CANCEL the in-flight\n * inner (its source `_deactivate`s — abortInFlight) and switch to the new one. Only the current\n * inner's emissions are forwarded.\n * @param project - project value used by the helper.\n * @returns A `Operator<TIn, TOut>` value.\n * @category operators\n * @example\n * ```ts\n * import { switchMap } from \"@graphrefly/ts/operators\";\n * ```\n */\nexport function switchMap<TIn, TOut>(project: Project<TIn, TOut>): Operator<TIn, TOut> {\n\treturn mapOperator(\"switchMap\", project, \"switch\");\n}\n\n/**\n * mergeMap (a.k.a. flatMap): project each source value to an inner and keep ALL inners live,\n * interleaving their emissions. A completed inner is removed (memory bounding). On source/inner\n * ERROR or projector failure, every live inner is removed before the operator emits ERROR (D81).\n * @param project - project value used by the helper.\n * @param opts - Options that configure the helper.\n * @returns A `Operator<TIn, TOut>` value.\n * @category operators\n * @example\n * ```ts\n * import { mergeMap } from \"@graphrefly/ts/operators\";\n * ```\n */\nexport function mergeMap<TIn, TOut>(\n\tproject: Project<TIn, TOut>,\n\topts: MergeMapOptions = {},\n): Operator<TIn, TOut> {\n\treturn mapOperator(\"mergeMap\", project, \"merge\", opts);\n}\n\n/** flatMap: alias of {@link mergeMap} (RxJS naming parity).\n * @param project - project value used by the helper.\n * @param opts - Options that configure the helper.\n * @returns A `Operator<TIn, TOut>` value.\n * @category operators\n * @example\n * ```ts\n * import { flatMap } from \"@graphrefly/ts/operators\";\n * ```\n */\nexport function flatMap<TIn, TOut>(\n\tproject: Project<TIn, TOut>,\n\topts: MergeMapOptions = {},\n): Operator<TIn, TOut> {\n\treturn mapOperator(\"flatMap\", project, \"merge\", opts);\n}\n\n/**\n * concatMap: project each source value to an inner, but run AT MOST ONE inner at a time — queue\n * later source values (lazy projection) and activate the next only when the active inner COMPLETEs.\n * Preserves source order.\n * @param project - project value used by the helper.\n * @returns A `Operator<TIn, TOut>` value.\n * @category operators\n * @example\n * ```ts\n * import { concatMap } from \"@graphrefly/ts/operators\";\n * ```\n */\nexport function concatMap<TIn, TOut>(project: Project<TIn, TOut>): Operator<TIn, TOut> {\n\treturn mapOperator(\"concatMap\", project, \"concat\");\n}\n\n/**\n * exhaustMap: while an inner is active, DROP new source values; project the next source value only\n * after the active inner COMPLETEs.\n * @param project - project value used by the helper.\n * @returns A `Operator<TIn, TOut>` value.\n * @category operators\n * @example\n * ```ts\n * import { exhaustMap } from \"@graphrefly/ts/operators\";\n * ```\n */\nexport function exhaustMap<TIn, TOut>(project: Project<TIn, TOut>): Operator<TIn, TOut> {\n\treturn mapOperator(\"exhaustMap\", project, \"exhaust\");\n}\n\n/** Per-node bookkeeping for {@link repeat}: the round index + the current live inner. */\ninterface RepeatState {\n\tstarted: boolean;\n\tround: number;\n\tinner: Node<unknown> | null;\n}\n\n/**\n * repeat: play a source `count` times in sequence (RxJS `repeat`). A DEPLESS self-driving operator\n * (Operator<never, S>, instantiate via `g.initNode(repeat(factory, count), [])`) — NOT a dep-operator.\n *\n * It takes a `factory: () => NodeInput<S>` (a RECIPE), not a source Node, because clean-slate Nodes\n * are HOT/shared (multicast + cache): re-subscribing the SAME node replays its cache, it does not\n * re-RUN the source. RxJS `repeat` re-subscribes the COLD source = a fresh subscription each round;\n * the clean-slate analogue is a fresh node per round → a factory. (A `repeat(count)`-over-a-Node\n * shape remains deferred: D47's no-net-change-is-a-no-op makes\n * `unsubscribeDep(S)+subscribeDep(S)` on the SAME boundary cancel out. D115 keeps the model to\n * ordinary unsubscribe plus a later subscribe, so same-node repeat needs a separate future design.)\n *\n * Mechanism (reuses the D47 self-rewire substrate, like the *Map family; NOT an internal subscribe,\n * D45): on activation it mints round 0's inner via `ctx.rewireNext.subscribeDep`; each round's inner DATA\n * is forwarded; on the inner's COMPLETE (`completeWhenDepsComplete:false + terminalAsRealInput:true`)\n * it unsubscribeDep's the finished inner and, if rounds remain, subscribeDep's a FRESH `factory()` inner (a\n * distinct node → a real net change, not the no-op same-node case); after the last round it emits\n * COMPLETE. An inner ERROR auto-forwards (errorWhenDepsError default → repeat errors). The body is\n * SELF-CATCHING (D30) and re-supplied on every rewire. The factory MUST mint a FRESH node per call\n * (a factory returning the same Node makes unsubscribeDep+subscribeDep a net-zero no-op → repeat wedges).\n * @param factory - factory value used by the helper.\n * @param count - count value used by the helper.\n * @returns A `Operator<never, S>` value.\n * @category operators\n * @example\n * ```ts\n * import { repeat } from \"@graphrefly/ts/operators\";\n * ```\n */\nexport function repeat<S>(factory: () => NodeInput<S>, count: number): Operator<never, S> {\n\tif (!Number.isInteger(count) || count < 1) {\n\t\tthrow new RangeError(`repeat: count must be a positive integer (got ${count})`);\n\t}\n\tconst body: NodeFn = (ctx: Ctx) => {\n\t\ttry {\n\t\t\tconst st = (ctx.state.get<RepeatState>() ?? {\n\t\t\t\tstarted: false,\n\t\t\t\tround: 0,\n\t\t\t\tinner: null,\n\t\t\t}) as RepeatState;\n\t\t\t// 1. forward the current inner's DATA this wave (the inner is the sole dep once wired).\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) for (const v of b) ctx.down([[\"DATA\", v]]);\n\t\t\t}\n\t\t\t// 2. activation: mint round 0's inner.\n\t\t\tif (!st.started) {\n\t\t\t\tst.started = true;\n\t\t\t\tst.round = 0;\n\t\t\t\tconst inner = fromAnyInCtx(ctx, factory());\n\t\t\t\tst.inner = inner;\n\t\t\t\tctx.state.set(st);\n\t\t\t\tctx.rewireNext.subscribeDep(inner, body);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// 3. inner COMPLETE → next round or terminal COMPLETE.\n\t\t\tif (st.inner !== null && isTerminalComplete(depTerminal(ctx, 0))) {\n\t\t\t\tconst old = st.inner;\n\t\t\t\tctx.rewireNext.unsubscribeDep(old, body); // bound the finished round's inner\n\t\t\t\tif (st.round + 1 < count) {\n\t\t\t\t\tst.round += 1;\n\t\t\t\t\tconst next = fromAnyInCtx(ctx, factory());\n\t\t\t\t\tst.inner = next;\n\t\t\t\t\tctx.state.set(st);\n\t\t\t\t\tctx.rewireNext.subscribeDep(next, body);\n\t\t\t\t} else {\n\t\t\t\t\tst.inner = null;\n\t\t\t\t\tctx.state.set(st);\n\t\t\t\t\tctx.down([[\"COMPLETE\"]]);\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (e) {\n\t\t\tctx.down([[\"ERROR\", errorPayload(e, \"repeat threw without a valid error payload\")]]); // D30 (self-catch survives rewire)\n\t\t}\n\t};\n\treturn {\n\t\tfactory: \"repeat\",\n\t\tbody,\n\t\topts: { completeWhenDepsComplete: false, terminalAsRealInput: true },\n\t};\n}\n","/**\n * Wall-clock time operators (CSP-2.7 / D52 / B23). Authored as COMPOSITIONS over the already-active\n * higher-order *Map machinery (D47) + the `timer` source — NO raw `setTimeout` in any operator body\n * (R-no-raw-async / check-no-raw-async; `setTimeout` stays confined to `sources.ts`'s `timer`). The\n * timer source's `onDeactivation` clearTimeout IS the reset/cancel: switchMap's unsubscribeDep on a new\n * source value tears the in-flight timer down (the declarative equivalent of the frozen reference's\n * imperative clearTimeout-then-setTimeout). Per-language (D6/D24), never in parity.\n *\n * Shipped this cut (clean *Map+timer):\n * - delay = mergeMap(v → timer(ms)→v) (every value delayed ms, ALL kept, order preserved)\n * - debounce(Time) = switchMap(v → timer(ms)→v) (cancel-and-restart; emit the latest after quiet ms)\n * - throttle(Time) = exhaustMap(v → [v now, alive ms]) (leading edge: emit v, ignore for ms)\n *\n * Behavior on source COMPLETE (per-operator, NOT a uniform DROP): debounce/debounceTime EMIT their\n * pending trailing value — switchMap does not cancel the in-flight inner on source COMPLETE (only a\n * superseding source value cancels it via unsubscribeDep→onDeactivation→clearTimeout), so the timer still\n * fires at `ms`, emits the debounced value, and only THEN does the operator COMPLETE (RxJS\n * debounceTime parity). delay emits every still-pending delayed value then COMPLETEs (mergeMap keeps\n * all inners). throttle/throttleTime have NO trailing value (leading-edge only, RxJS default\n * trailing:false) — an open window inner is dropped when the operator completes.\n *\n * B41 tail (landed 2026-05-31, the two shapes reflect WHEN the clock arms):\n * - audit / auditTime — VALUE-TRIGGERED trailing edge: a source value opens a duration window\n * (`audit(durationSelector)` = the general/notifier form, mirroring the *Map\n * `Project` idiom + D46; `auditTime(ms)` = `audit(() => timer(ms))`), emits the\n * window's LATEST value at the window's close. Self-wires the notifier via\n * ctx.rewireNext — a normal `g.initNode(audit(sel), [source])` operator.\n * - timeout / bufferTime — SUBSCRIBE-ARMED (RxJS-cold): the clock must run from activation, before\n * any source value, so the timer/interval is a CONSTRUCTION-time dep (a depless\n * source arms lazily on subscribe per node `_activate`). A dep-bearing operator\n * body never runs at activation (only depless nodes do, node.ts), so these ship\n * as graph composition HELPERS `timeout(source, ms)` / `bufferTime(source, ms)`\n * returning a Node — NOT `g.initNode(op, [deps])` operators. timeout resets its\n * idle timer per source value via ctx.rewireNext (ERROR on the gap); bufferTime\n * is buffer-over-interval with terminal cleanup via ctx.rewireNext.\n *\n * NOT ported (D58): window/windowCount/windowTime — the Node<Node<T>> higher-order forms are a D45\n * describe island; the array forms (buffer/bufferCount/bufferTime) are the graph-first equivalent.\n *\n * Inspection caveat (timeout/bufferTime): the helper returns a BARE node (free initNode) self-carrying\n * its factory for describe auto-discovery (D51), but it is NOT in a graph's _entries — so g.describe()\n * lists it only when it is a live dep of a registered node (a first-cut limit, like the *Map inners).\n */\n\nimport {\n\ttype Ctx,\n\tdepBatch,\n\tdepTerminal,\n\tisTerminalComplete,\n\tisTerminalError,\n\ttype NodeFn,\n\tterminalErrorValue,\n} from \"../ctx/types.js\";\nimport type { Node } from \"../node/node.js\";\nimport { errorPayload } from \"../protocol/messages.js\";\nimport { exhaustMap, mergeMap, switchMap } from \"./higher-order.js\";\nimport { filter, initNode, map, merge, type Operator } from \"./operators.js\";\nimport { fromAny, interval, type NodeInput, of, timer } from \"./sources.js\";\n\n/** A bare inner that emits `v` once after `ms`, then COMPLETEs (timer(ms)→map(v); auto-completes). */\nfunction delayedValue<S>(v: S, ms: number): Node<S> {\n\treturn initNode(\n\t\tmap(() => v),\n\t\t[initNode(timer(ms), [])],\n\t);\n}\n\n/**\n * An inner that emits `v` IMMEDIATELY (on activation) and stays alive for `ms` (then COMPLETEs),\n * emitting nothing more — the leading-edge throttle window. `merge(of(v), silentTimer)`: `of(v)`\n * emits v + COMPLETE at t=0; `filter(()=>false)` over `timer(ms)` emits no DATA and COMPLETEs at\n * t=ms; merge forwards v at t=0 and COMPLETEs (all deps complete) at t=ms.\n */\nfunction throttleWindow<S>(v: S, ms: number): Node<S> {\n\tconst silentTimer = initNode(\n\t\tfilter<number>(() => false),\n\t\t[initNode(timer(ms), [])],\n\t) as Node<S>;\n\treturn initNode(merge<S>(), [initNode(of(v), []), silentTimer]);\n}\n\n/**\n * delay: shift every value by `ms`, preserving all values + order. `mergeMap` keeps every inner\n * timer live (equal `ms`, so they fire in arrival order).\n * @param ms - Duration or timestamp in milliseconds.\n * @returns A `Operator<S, S>` value.\n * @category operators\n * @example\n * ```ts\n * import { delay } from \"@graphrefly/ts/operators\";\n * ```\n */\nexport function delay<S>(ms: number): Operator<S, S> {\n\treturn { ...mergeMap<S, S>((v) => delayedValue(v, ms)), factory: \"delay\" };\n}\n\n/**\n * debounce (alias `debounceTime`): emit the latest value only after `ms` of quiet. `switchMap`\n * cancels the prior timer (its onDeactivation clearTimeout) on each new source value and restarts —\n * the declarative debounce.\n *\n * RxJS-7 divergence (reference rxjs@7.8, B44): RxJS `debounceTime` FLUSHES the pending value\n * IMMEDIATELY when the source COMPLETEs (its `_complete` calls `debouncedNext()` before\n * `complete()`). This composition instead emits the pending value when the in-flight `timer(ms)`\n * fires — i.e. at `(last-value-time + ms)` — so if the source completes mid-window the trailing\n * value arrives up to `ms` later than RxJS. Inherent to the `*Map`+`timer` form (the composition\n * cannot flush early without detecting COMPLETE inside the switchMap inner); accepted, not a bug.\n * @param ms - Duration or timestamp in milliseconds.\n * @returns A `Operator<S, S>` value.\n * @category operators\n * @example\n * ```ts\n * import { debounce } from \"@graphrefly/ts/operators\";\n * ```\n */\nexport function debounce<S>(ms: number): Operator<S, S> {\n\treturn { ...switchMap<S, S>((v) => delayedValue(v, ms)), factory: \"debounce\" };\n}\n\n/** debounceTime: RxJS-named alias of {@link debounce}.\n * @param ms - Duration or timestamp in milliseconds.\n * @returns A `Operator<S, S>` value.\n * @category operators\n * @example\n * ```ts\n * import { debounceTime } from \"@graphrefly/ts/operators\";\n * ```\n */\nexport function debounceTime<S>(ms: number): Operator<S, S> {\n\treturn { ...switchMap<S, S>((v) => delayedValue(v, ms)), factory: \"debounceTime\" };\n}\n\n/**\n * throttle (alias `throttleTime`): leading-edge — emit a value immediately, then ignore the source\n * for `ms`. `exhaustMap` drops new source values while the current window inner is alive; the\n * window emits v at its leading edge and stays alive `ms`.\n *\n * Matches the RxJS-7 `throttleTime` DEFAULT (leading:true, trailing:false). The leading/trailing\n * OPTIONS RxJS exposes are NOT provided (a capability gap, not a behavior divergence; B44) — add a\n * trailing-window form if a consumer needs it.\n * @param ms - Duration or timestamp in milliseconds.\n * @returns A `Operator<S, S>` value.\n * @category operators\n * @example\n * ```ts\n * import { throttle } from \"@graphrefly/ts/operators\";\n * ```\n */\nexport function throttle<S>(ms: number): Operator<S, S> {\n\treturn { ...exhaustMap<S, S>((v) => throttleWindow(v, ms)), factory: \"throttle\" };\n}\n\n/** throttleTime: RxJS-named alias of {@link throttle}.\n * @param ms - Duration or timestamp in milliseconds.\n * @returns A `Operator<S, S>` value.\n * @category operators\n * @example\n * ```ts\n * import { throttleTime } from \"@graphrefly/ts/operators\";\n * ```\n */\nexport function throttleTime<S>(ms: number): Operator<S, S> {\n\treturn { ...exhaustMap<S, S>((v) => throttleWindow(v, ms)), factory: \"throttleTime\" };\n}\n\n// ── B41 tail: value-triggered (audit) + subscribe-armed (timeout/bufferTime) ──\n\n/** Per-node bookkeeping for {@link audit}: the open window's notifier + the latest value seen. */\ninterface AuditState<S> {\n\twindowOpen: boolean;\n\tlatest: { v: S } | undefined;\n\tnotifier: Node<unknown> | null;\n}\n\n/**\n * audit: VALUE-TRIGGERED trailing throttle. A source value (when no window is open) opens a duration\n * window via `durationSelector(value)` → a notifier `NodeInput` wired as dep 1 with `ctx.rewireNext`\n * (D47 — the *Map self-rewire idiom, NOT an internal subscribe, D45); during the window new source\n * values only UPDATE the tracked latest (no emit); when the notifier fires (its first DATA / COMPLETE)\n * the window closes and the LATEST value is emitted. This is throttle's trailing-edge twin\n * (throttle emits the window's FIRST value at the leading edge; audit emits the LAST at the close).\n *\n * `durationSelector` is the general/notifier form (mirrors the *Map `Project` idiom + D46); the source\n * is dep 0, the live notifier (if any) is dep 1. On source COMPLETE the pending latest is FLUSHED then\n * COMPLETE (RxJS-7 audit flush-on-complete, B44). A source/notifier ERROR is read as a real terminal\n * input so the live notifier can be removed before ERROR. Self-catching (D30); re-supplies its body on\n * every rewire.\n * @param durationSelector - duration selector value used by the helper.\n * @returns A `Operator<S, S>` value.\n * @category operators\n * @example\n * ```ts\n * import { audit } from \"@graphrefly/ts/operators\";\n * ```\n */\nexport function audit<S>(durationSelector: (v: S) => NodeInput<unknown>): Operator<S, S> {\n\tconst body: NodeFn = (ctx: Ctx) => {\n\t\ttry {\n\t\t\tconst st: AuditState<S> = ctx.state.get<AuditState<S>>() ?? {\n\t\t\t\twindowOpen: false,\n\t\t\t\tlatest: undefined,\n\t\t\t\tnotifier: null,\n\t\t\t};\n\t\t\tconst sourceBatch = depBatch(ctx, 0);\n\t\t\tconst notifierBatch = depBatch(ctx, 1); // live duration notifier while a window is open\n\t\t\tconst sourceTerminal = depTerminal(ctx, 0);\n\t\t\tconst notifierTerminal = depTerminal(ctx, 1);\n\n\t\t\t// every source value updates the window's latest (the value emitted at the window's close).\n\t\t\tconst sb = sourceBatch as readonly S[] | null;\n\t\t\tif (sb) for (const v of sb) st.latest = { v };\n\n\t\t\t// the window closes when its duration notifier fires (DATA or COMPLETE) → emit the latest.\n\t\t\tconst notifierFired =\n\t\t\t\tst.windowOpen &&\n\t\t\t\t((notifierBatch != null && notifierBatch.length > 0) ||\n\t\t\t\t\tisTerminalComplete(notifierTerminal));\n\t\t\tif (notifierFired) {\n\t\t\t\tif (st.latest !== undefined) ctx.down([[\"DATA\", st.latest.v]]);\n\t\t\t\tconst old = st.notifier;\n\t\t\t\tst.windowOpen = false;\n\t\t\t\tst.notifier = null;\n\t\t\t\tst.latest = undefined;\n\t\t\t\tif (old) ctx.rewireNext.unsubscribeDep(old, body);\n\t\t\t}\n\n\t\t\t// source/notifier ERROR → forward ERROR, but first remove the helper-owned notifier.\n\t\t\tconst sourceError = isTerminalError(sourceTerminal);\n\t\t\tconst notifierError = isTerminalError(notifierTerminal);\n\t\t\tif (sourceError || notifierError) {\n\t\t\t\tconst err = terminalErrorValue(sourceError ? sourceTerminal : notifierTerminal);\n\t\t\t\tif (st.notifier) ctx.rewireNext.unsubscribeDep(st.notifier, body);\n\t\t\t\tctx.state.set({ windowOpen: false, latest: undefined, notifier: null });\n\t\t\t\tctx.down([[\"ERROR\", err]]);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// source COMPLETE → flush the pending latest (B44 audit flush-on-complete) then COMPLETE.\n\t\t\tif (isTerminalComplete(sourceTerminal)) {\n\t\t\t\tif (st.windowOpen && st.latest !== undefined) ctx.down([[\"DATA\", st.latest.v]]);\n\t\t\t\tif (st.notifier) ctx.rewireNext.unsubscribeDep(st.notifier, body);\n\t\t\t\tctx.state.set({ windowOpen: false, latest: undefined, notifier: null });\n\t\t\t\tctx.down([[\"COMPLETE\"]]);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// a fresh source value with no open window → open one (value-triggered, trailing edge).\n\t\t\tif (!st.windowOpen && sb != null && sb.length > 0 && st.latest !== undefined) {\n\t\t\t\tconst n = fromAny<unknown>(durationSelector(st.latest.v), { iter: true });\n\t\t\t\tst.windowOpen = true;\n\t\t\t\tst.notifier = n;\n\t\t\t\tctx.rewireNext.subscribeDep(n, body); // (a same-wave close+reopen issues remove-before-add)\n\t\t\t}\n\n\t\t\tctx.state.set(st);\n\t\t} catch (e) {\n\t\t\tctx.down([[\"ERROR\", errorPayload(e, \"audit threw without a valid error payload\")]]);\n\t\t}\n\t};\n\treturn {\n\t\tfactory: \"audit\",\n\t\tbody,\n\t\topts: {\n\t\t\tpartial: true,\n\t\t\tcompleteWhenDepsComplete: false,\n\t\t\terrorWhenDepsError: false,\n\t\t\tterminalAsRealInput: true,\n\t\t},\n\t};\n}\n\n/** auditTime: the `ms`-specialization of {@link audit} — the window is a `timer(ms)`.\n * @param ms - Duration or timestamp in milliseconds.\n * @returns A `Operator<S, S>` value.\n * @category operators\n * @example\n * ```ts\n * import { auditTime } from \"@graphrefly/ts/operators\";\n * ```\n */\nexport function auditTime<S>(ms: number): Operator<S, S> {\n\treturn { ...audit<S>(() => initNode(timer(ms), [])), factory: \"auditTime\" };\n}\n\n/** Per-node bookkeeping for {@link timeout}: the live idle timer (reset on each source value). */\ninterface TimeoutState {\n\ttimer: Node<unknown> | null;\n}\n\n/**\n * timeout: idle watchdog — forward every source value, but ERROR if more than `ms` elapses with no\n * value (RxJS `timeout(ms)`, `first === each === ms`). SUBSCRIBE-ARMED: the first `timer(ms)` is a\n * CONSTRUCTION-time dep, so it arms when `timeout`'s node is subscribed/activated (a depless source\n * runs lazily on `_activate`) — i.e. a source that never emits its FIRST value within `ms` still\n * errors. A dep-bearing operator body never runs at activation (only depless nodes do, node.ts), which\n * is why this is a HELPER returning a Node, not a `g.initNode(op, [source])` operator.\n *\n * Each source value forwards as-is and RESETS the idle timer (unsubscribeDep the current `timer(ms)`,\n * subscribeDep a fresh one — its `onDeactivation` clearTimeout cancels the prior countdown). The timer\n * firing (its DATA/COMPLETE) is the timeout → `[[ERROR]]`. Source COMPLETE forwards COMPLETE (no\n * error) and removes the idle timer during the terminal wave (D62 terminal-drains-queued-rewire);\n * a source ERROR forwards likewise. The idle timer is also torn down when the consumer unsubscribes\n * (timeout deactivates → dep unsub → timer onDeactivation). Self-catching (D30).\n * @param source - Source node that provides graph-visible input.\n * @param ms - Duration or timestamp in milliseconds.\n * @returns A `Node<S>` value.\n * @category operators\n * @example\n * ```ts\n * import { timeout } from \"@graphrefly/ts/operators\";\n * ```\n */\nexport function timeout<S>(source: Node<S>, ms: number): Node<S> {\n\tconst makeTimer = (): Node<unknown> => initNode(timer(ms), []);\n\tconst initial = makeTimer();\n\tconst body: NodeFn = (ctx: Ctx) => {\n\t\ttry {\n\t\t\tconst st: TimeoutState = ctx.state.get<TimeoutState>() ?? { timer: initial };\n\t\t\tconst srcBatch = depBatch(ctx, 0);\n\t\t\tconst srcTerminal = depTerminal(ctx, 0);\n\n\t\t\t// a source value forwards as-is and resets the idle window.\n\t\t\tconst sb = srcBatch as readonly S[] | null;\n\t\t\tif (sb != null && sb.length > 0) {\n\t\t\t\tfor (const v of sb) ctx.down([[\"DATA\", v]]);\n\t\t\t\tconst old = st.timer;\n\t\t\t\tconst next = makeTimer();\n\t\t\t\tst.timer = next;\n\t\t\t\tctx.state.set(st);\n\t\t\t\tif (old) ctx.rewireNext.unsubscribeDep(old, body); // remove-before-add (alignment)\n\t\t\t\tctx.rewireNext.subscribeDep(next, body);\n\t\t\t\treturn; // a value-bearing wave is never also a timeout-fire wave\n\t\t\t}\n\n\t\t\t// source COMPLETE → forward COMPLETE (no timeout fires).\n\t\t\tif (isTerminalComplete(srcTerminal)) {\n\t\t\t\tif (st.timer) ctx.rewireNext.unsubscribeDep(st.timer, body);\n\t\t\t\tctx.down([[\"COMPLETE\"]]);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// source ERROR (absorbed via errorWhenDepsError:false) → forward it.\n\t\t\tif (isTerminalError(srcTerminal)) {\n\t\t\t\tif (st.timer) ctx.rewireNext.unsubscribeDep(st.timer, body);\n\t\t\t\tctx.down([[\"ERROR\", terminalErrorValue(srcTerminal)]]);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// otherwise this wave is the idle timer firing → timeout ERROR.\n\t\t\tconst timerBatch = depBatch(ctx, 1);\n\t\t\tif (\n\t\t\t\t(timerBatch != null && timerBatch.length > 0) ||\n\t\t\t\tisTerminalComplete(depTerminal(ctx, 1))\n\t\t\t) {\n\t\t\t\tctx.down([[\"ERROR\", new Error(`timeout: no value within ${ms}ms`)]]);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tctx.state.set(st);\n\t\t} catch (e) {\n\t\t\tctx.down([[\"ERROR\", errorPayload(e, \"timeout threw without a valid error payload\")]]);\n\t\t}\n\t};\n\treturn initNode<S, S>(\n\t\t{\n\t\t\tfactory: \"timeout\",\n\t\t\tbody,\n\t\t\topts: {\n\t\t\t\tpartial: true,\n\t\t\t\tcompleteWhenDepsComplete: false,\n\t\t\t\terrorWhenDepsError: false,\n\t\t\t\tterminalAsRealInput: true,\n\t\t\t},\n\t\t},\n\t\t[source as Node<unknown>, initial],\n\t);\n}\n\n/**\n * bufferTime: buffer source values and flush them as an array every `ms` (RxJS `bufferTime(ms)`).\n * SUBSCRIBE-ARMED: the `interval(ms)` notifier is a CONSTRUCTION-time dep (arms on subscribe), so an\n * empty window flushes `[]` even before the first source value — matching the landed {@link buffer}\n * (which flushes on every notifier signal). On source COMPLETE the remainder flushes then COMPLETE\n * (B44), and D62 lets the terminal wave still drain `unsubscribeDep(interval)` so the helper-owned\n * interval source deactivates instead of ticking forever.\n * @param source - Source node that provides graph-visible input.\n * @param ms - Duration or timestamp in milliseconds.\n * @returns A `Node<S[]>` value.\n * @category operators\n * @example\n * ```ts\n * import { bufferTime } from \"@graphrefly/ts/operators\";\n * ```\n */\nexport function bufferTime<S>(source: Node<S>, ms: number): Node<S[]> {\n\tconst iv: Node<unknown> = initNode(interval(ms), []);\n\tconst body: NodeFn = (ctx: Ctx) => {\n\t\tconst srcBatch = depBatch(ctx, 0);\n\t\tconst tickBatch = depBatch(ctx, 1);\n\t\tconst srcTerminal = depTerminal(ctx, 0);\n\t\tconst buf = ctx.state.get<S[]>() ?? [];\n\t\tif (srcBatch) for (const v of srcBatch) buf.push(v as S);\n\t\tif (isTerminalComplete(srcTerminal)) {\n\t\t\tif (buf.length > 0) ctx.down([[\"DATA\", [...buf]]]);\n\t\t\tctx.state.set([]);\n\t\t\tctx.rewireNext.unsubscribeDep(iv, body);\n\t\t\tctx.down([[\"COMPLETE\"]]);\n\t\t\treturn;\n\t\t}\n\t\tif (isTerminalError(srcTerminal)) {\n\t\t\tctx.state.set([]);\n\t\t\tctx.rewireNext.unsubscribeDep(iv, body);\n\t\t\tctx.down([[\"ERROR\", terminalErrorValue(srcTerminal)]]);\n\t\t\treturn;\n\t\t}\n\t\tif (tickBatch && tickBatch.length > 0) {\n\t\t\tctx.down([[\"DATA\", [...buf]]]);\n\t\t\tctx.state.set([]);\n\t\t\treturn;\n\t\t}\n\t\tctx.state.set(buf);\n\t};\n\treturn initNode<unknown, S[]>(\n\t\t{\n\t\t\tfactory: \"bufferTime\",\n\t\t\tbody,\n\t\t\topts: {\n\t\t\t\tpartial: true,\n\t\t\t\tcompleteWhenDepsComplete: false,\n\t\t\t\terrorWhenDepsError: false,\n\t\t\t\tterminalAsRealInput: true,\n\t\t\t},\n\t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