@graphrefly/ts 0.0.0 → 0.0.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 +135 -0
- package/dist/adapters/index.cjs +105 -66
- package/dist/adapters/index.cjs.map +1 -1
- package/dist/adapters/index.d.cts +11 -136
- package/dist/adapters/index.d.ts +11 -136
- package/dist/adapters/index.js +27 -225
- package/dist/adapters/index.js.map +1 -1
- package/dist/adapters/observe-storage.d.cts +4 -4
- package/dist/adapters/observe-storage.d.ts +4 -4
- package/dist/adapters/observe-storage.js +1 -0
- package/dist/adapters/observe-storage.js.map +1 -1
- package/dist/adapters/react.cjs +166 -0
- package/dist/adapters/react.cjs.map +1 -0
- package/dist/adapters/react.d.cts +31 -0
- package/dist/adapters/react.d.ts +31 -0
- package/dist/adapters/react.js +51 -0
- package/dist/adapters/react.js.map +1 -0
- package/dist/adapters/solid.cjs +157 -0
- package/dist/adapters/solid.cjs.map +1 -0
- package/dist/adapters/solid.d.cts +26 -0
- package/dist/adapters/solid.d.ts +26 -0
- package/dist/adapters/solid.js +48 -0
- package/dist/adapters/solid.js.map +1 -0
- package/dist/adapters/svelte.cjs +148 -0
- package/dist/adapters/svelte.cjs.map +1 -0
- package/dist/adapters/svelte.d.cts +31 -0
- package/dist/adapters/svelte.d.ts +31 -0
- package/dist/adapters/svelte.js +46 -0
- package/dist/adapters/svelte.js.map +1 -0
- package/dist/adapters/vue.cjs +155 -0
- package/dist/adapters/vue.cjs.map +1 -0
- package/dist/adapters/vue.d.cts +26 -0
- package/dist/adapters/vue.d.ts +26 -0
- package/dist/adapters/vue.js +46 -0
- package/dist/adapters/vue.js.map +1 -0
- package/dist/agent-runtime-BesGDZcB.d.ts +555 -0
- package/dist/agent-runtime-DZTJ3C-p.d.cts +555 -0
- package/dist/agentic-memory-BmRCvh0d.d.ts +517 -0
- package/dist/agentic-memory-DfuVZ-lY.d.cts +517 -0
- package/dist/capability-admission-B0BzqAm5.d.cts +102 -0
- package/dist/capability-admission-g0mn9hpq.d.ts +102 -0
- package/dist/{chunk-JR4IKCR2.js → chunk-2747WN4Y.js} +5 -5
- package/dist/{chunk-2ILL7HQI.js → chunk-3JR3EDB2.js} +17 -17
- package/dist/{chunk-2ILL7HQI.js.map → chunk-3JR3EDB2.js.map} +1 -1
- package/dist/{chunk-GDL26N2T.js → chunk-3KN7NJDR.js} +2 -2
- package/dist/{chunk-DJC4CHLQ.js → chunk-43BKLFZU.js} +9 -9
- package/dist/chunk-6XAIOL3X.js +2407 -0
- package/dist/chunk-6XAIOL3X.js.map +1 -0
- package/dist/{chunk-SCRFRCGR.js → chunk-BSQGE5PS.js} +1 -1
- package/dist/{chunk-Y3ZLRGHC.js → chunk-CZNV3VXM.js} +16 -16
- package/dist/chunk-DGUM43GV.js +11 -0
- package/dist/chunk-DGUM43GV.js.map +1 -0
- package/dist/{chunk-JIMUDQN3.js → chunk-FBUU43PM.js} +2 -2
- package/dist/chunk-H75VXTGT.js +219 -0
- package/dist/chunk-H75VXTGT.js.map +1 -0
- package/dist/{chunk-RIIOUTGM.js → chunk-HKK2JD7Z.js} +12 -9
- package/dist/chunk-HKK2JD7Z.js.map +1 -0
- package/dist/{chunk-D6BG7U6A.js → chunk-IXZBUWSP.js} +3 -3
- package/dist/chunk-PC3BTTBE.js +3217 -0
- package/dist/chunk-PC3BTTBE.js.map +1 -0
- package/dist/chunk-QFY4AFY4.js +879 -0
- package/dist/chunk-QFY4AFY4.js.map +1 -0
- package/dist/{chunk-DK554R7P.js → chunk-S6HXABGL.js} +2 -1
- package/dist/chunk-S6HXABGL.js.map +1 -0
- package/dist/{chunk-PKVBHGBM.js → chunk-SS2A464I.js} +7 -7
- package/dist/chunk-UT3MHJCW.js +49 -0
- package/dist/chunk-UT3MHJCW.js.map +1 -0
- package/dist/{chunk-G4M3NHRJ.js → chunk-V7CIJE4B.js} +3 -3
- package/dist/{chunk-TEW47IVR.js → chunk-VPEFSDME.js} +2 -2
- package/dist/chunk-VTHLCFN4.js +368 -0
- package/dist/chunk-VTHLCFN4.js.map +1 -0
- package/dist/{chunk-SWTLEQL6.js → chunk-WQIA3GFB.js} +2 -2
- package/dist/chunk-WQIA3GFB.js.map +1 -0
- package/dist/{chunk-I3IHOHCJ.js → chunk-XKXWK2KP.js} +108 -64
- package/dist/chunk-XKXWK2KP.js.map +1 -0
- package/dist/{chunk-COHO25CZ.js → chunk-YDSIVHRR.js} +553 -7
- package/dist/chunk-YDSIVHRR.js.map +1 -0
- package/dist/chunk-YXMZ2N6J.js +1884 -0
- package/dist/chunk-YXMZ2N6J.js.map +1 -0
- package/dist/composition/index.cjs +102 -57
- package/dist/composition/index.cjs.map +1 -1
- package/dist/composition/index.d.cts +4 -4
- package/dist/composition/index.d.ts +4 -4
- package/dist/composition/index.js +6 -5
- package/dist/core/index.cjs +102 -57
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +2 -2
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.js +5 -4
- package/dist/cqrs/index.cjs.map +1 -1
- package/dist/cqrs/index.d.cts +4 -4
- package/dist/cqrs/index.d.ts +4 -4
- package/dist/cqrs/index.js +3 -2
- package/dist/cqrs/index.js.map +1 -1
- package/dist/cqrs/messaging.cjs +312 -0
- package/dist/cqrs/messaging.cjs.map +1 -0
- package/dist/cqrs/messaging.d.cts +57 -0
- package/dist/cqrs/messaging.d.ts +57 -0
- package/dist/cqrs/messaging.js +274 -0
- package/dist/cqrs/messaging.js.map +1 -0
- package/dist/cqrs/work-queue.cjs +329 -0
- package/dist/cqrs/work-queue.cjs.map +1 -0
- package/dist/cqrs/work-queue.d.cts +90 -0
- package/dist/cqrs/work-queue.d.ts +90 -0
- package/dist/cqrs/work-queue.js +292 -0
- package/dist/cqrs/work-queue.js.map +1 -0
- package/dist/data/index.cjs +19 -0
- package/dist/data/index.cjs.map +1 -0
- package/dist/data/index.d.cts +36 -0
- package/dist/data/index.d.ts +36 -0
- package/dist/data/index.js +1 -0
- package/dist/data/index.js.map +1 -0
- package/dist/data-structures/index.cjs +105 -57
- package/dist/data-structures/index.cjs.map +1 -1
- package/dist/data-structures/index.d.cts +8 -8
- package/dist/data-structures/index.d.ts +8 -8
- package/dist/data-structures/index.js +7 -6
- package/dist/{describe-BZb7AS2y.d.ts → describe-BpyJuWkw.d.ts} +1 -1
- package/dist/{describe-Ciu8SUnN.d.cts → describe-DYMw_l1C.d.cts} +1 -1
- package/dist/executors/work-queue.cjs +342 -0
- package/dist/executors/work-queue.cjs.map +1 -0
- package/dist/executors/work-queue.d.cts +90 -0
- package/dist/executors/work-queue.d.ts +90 -0
- package/dist/executors/work-queue.js +306 -0
- package/dist/executors/work-queue.js.map +1 -0
- package/dist/graph/index.cjs +112 -58
- package/dist/graph/index.cjs.map +1 -1
- package/dist/graph/index.d.cts +9 -9
- package/dist/graph/index.d.ts +9 -9
- package/dist/graph/index.js +18 -17
- package/dist/{graph-DfdF9zy4.d.ts → graph-D-1-SQeC.d.ts} +3 -3
- package/dist/{graph-s23RbbFO.d.cts → graph-DCEWh4T2.d.cts} +3 -3
- package/dist/{index-CAEmLCYF.d.cts → index-72VZC0-E.d.cts} +2 -2
- package/dist/{index-SnzZu3x7.d.ts → index-Bmxeu0nK.d.ts} +2 -2
- package/dist/index.cjs +112 -58
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -10
- package/dist/index.d.ts +11 -10
- package/dist/index.js +118 -113
- package/dist/inspection/boundary.cjs +98 -0
- package/dist/inspection/boundary.cjs.map +1 -0
- package/dist/inspection/boundary.d.cts +61 -0
- package/dist/inspection/boundary.d.ts +61 -0
- package/dist/inspection/boundary.js +75 -0
- package/dist/inspection/boundary.js.map +1 -0
- package/dist/{messages-BZqrGGm1.d.ts → messages-CAzUPPJM.d.cts} +10 -5
- package/dist/{messages-BZqrGGm1.d.cts → messages-CAzUPPJM.d.ts} +10 -5
- package/dist/messaging/index.cjs +744 -613
- package/dist/messaging/index.cjs.map +1 -1
- package/dist/messaging/index.d.cts +216 -160
- package/dist/messaging/index.d.ts +216 -160
- package/dist/messaging/index.js +19 -749
- package/dist/messaging/index.js.map +1 -1
- package/dist/operators/index.cjs +102 -57
- package/dist/operators/index.cjs.map +1 -1
- package/dist/operators/index.d.cts +6 -6
- package/dist/operators/index.d.ts +6 -6
- package/dist/operators/index.js +8 -7
- package/dist/orchestration/index.cjs +3333 -59
- package/dist/orchestration/index.cjs.map +1 -1
- package/dist/orchestration/index.d.cts +7 -4
- package/dist/orchestration/index.d.ts +7 -4
- package/dist/orchestration/index.js +49 -8
- package/dist/orchestration/index.js.map +1 -1
- package/dist/orchestration/messaging.cjs +314 -0
- package/dist/orchestration/messaging.cjs.map +1 -0
- package/dist/orchestration/messaging.d.cts +59 -0
- package/dist/orchestration/messaging.d.ts +59 -0
- package/dist/orchestration/messaging.js +276 -0
- package/dist/orchestration/messaging.js.map +1 -0
- package/dist/orchestration/work-queue.cjs +262 -0
- package/dist/orchestration/work-queue.cjs.map +1 -0
- package/dist/orchestration/work-queue.d.cts +85 -0
- package/dist/orchestration/work-queue.d.ts +85 -0
- package/dist/orchestration/work-queue.js +226 -0
- package/dist/orchestration/work-queue.js.map +1 -0
- package/dist/patterns/event-flow.cjs +447 -0
- package/dist/patterns/event-flow.cjs.map +1 -0
- package/dist/patterns/event-flow.d.cts +115 -0
- package/dist/patterns/event-flow.d.ts +115 -0
- package/dist/patterns/event-flow.js +14 -0
- package/dist/patterns/event-flow.js.map +1 -0
- package/dist/patterns/index.cjs +423 -18
- package/dist/patterns/index.cjs.map +1 -1
- package/dist/patterns/index.d.cts +8 -5
- package/dist/patterns/index.d.ts +8 -5
- package/dist/patterns/index.js +13 -4
- package/dist/{reactive-collection-Cb1II1Fi.d.ts → reactive-collection-BAmfrGjd.d.ts} +9 -9
- package/dist/{reactive-collection-BxBqtIOE.d.cts → reactive-collection-DNV0-gFi.d.cts} +9 -9
- package/dist/{reactive-collection-storage-D-KmjE0J.d.cts → reactive-collection-storage-BNEldDyi.d.cts} +5 -5
- package/dist/{reactive-collection-storage-BNiEc-Gd.d.ts → reactive-collection-storage-YZsAQsWK.d.ts} +5 -5
- package/dist/{reactive-map-D-g3dv8I.d.cts → reactive-map-DRD1LJ2H.d.cts} +6 -6
- package/dist/{reactive-map-BcB4KsQR.d.ts → reactive-map-EsDiCmJk.d.ts} +6 -6
- package/dist/render/index.d.cts +3 -3
- package/dist/render/index.d.ts +3 -3
- package/dist/render/index.js +1 -0
- package/dist/{semantic-memory-graph-BYoIlP35.d.cts → semantic-memory-graph-DKuNzuWw.d.cts} +2 -2
- package/dist/{semantic-memory-graph-CxyXLms3.d.ts → semantic-memory-graph-uwbwJdhe.d.ts} +2 -2
- package/dist/solutions/index.cjs +4478 -2
- package/dist/solutions/index.cjs.map +1 -1
- package/dist/solutions/index.d.cts +13 -519
- package/dist/solutions/index.d.ts +13 -519
- package/dist/solutions/index.js +90 -6
- package/dist/solutions/reactive-layout/browser/index.cjs +449 -0
- package/dist/solutions/reactive-layout/browser/index.cjs.map +1 -0
- package/dist/solutions/reactive-layout/browser/index.d.cts +44 -0
- package/dist/solutions/reactive-layout/browser/index.d.ts +44 -0
- package/dist/solutions/reactive-layout/browser/index.js +69 -0
- package/dist/solutions/reactive-layout/browser/index.js.map +1 -0
- package/dist/solutions/reactive-layout/index.cjs +4266 -0
- package/dist/solutions/reactive-layout/index.cjs.map +1 -0
- package/dist/solutions/reactive-layout/index.d.cts +581 -0
- package/dist/solutions/reactive-layout/index.d.ts +581 -0
- package/dist/solutions/reactive-layout/index.js +86 -0
- package/dist/solutions/reactive-layout/index.js.map +1 -0
- package/dist/solutions/reactive-layout/node-canvas/index.cjs +545 -0
- package/dist/solutions/reactive-layout/node-canvas/index.cjs.map +1 -0
- package/dist/solutions/reactive-layout/node-canvas/index.d.cts +54 -0
- package/dist/solutions/reactive-layout/node-canvas/index.d.ts +54 -0
- package/dist/solutions/reactive-layout/node-canvas/index.js +131 -0
- package/dist/solutions/reactive-layout/node-canvas/index.js.map +1 -0
- package/dist/solutions/reactive-layout/react-native/index.cjs +494 -0
- package/dist/solutions/reactive-layout/react-native/index.cjs.map +1 -0
- package/dist/solutions/reactive-layout/react-native/index.d.cts +51 -0
- package/dist/solutions/reactive-layout/react-native/index.d.ts +51 -0
- package/dist/solutions/reactive-layout/react-native/index.js +77 -0
- package/dist/solutions/reactive-layout/react-native/index.js.map +1 -0
- package/dist/solutions/reactive-layout/skia/index.cjs +547 -0
- package/dist/solutions/reactive-layout/skia/index.cjs.map +1 -0
- package/dist/solutions/reactive-layout/skia/index.d.cts +64 -0
- package/dist/solutions/reactive-layout/skia/index.d.ts +64 -0
- package/dist/solutions/reactive-layout/skia/index.js +70 -0
- package/dist/solutions/reactive-layout/skia/index.js.map +1 -0
- package/dist/solutions/work-item/actions.cjs +2164 -0
- package/dist/solutions/work-item/actions.cjs.map +1 -0
- package/dist/solutions/work-item/actions.d.cts +201 -0
- package/dist/solutions/work-item/actions.d.ts +201 -0
- package/dist/solutions/work-item/actions.js +1454 -0
- package/dist/solutions/work-item/actions.js.map +1 -0
- package/dist/solutions/work-item/scheduling.cjs +2454 -0
- package/dist/solutions/work-item/scheduling.cjs.map +1 -0
- package/dist/solutions/work-item/scheduling.d.cts +433 -0
- package/dist/solutions/work-item/scheduling.d.ts +433 -0
- package/dist/solutions/work-item/scheduling.js +32 -0
- package/dist/solutions/work-item/scheduling.js.map +1 -0
- package/dist/solutions/work-item/work-queue.cjs +306 -0
- package/dist/solutions/work-item/work-queue.cjs.map +1 -0
- package/dist/solutions/work-item/work-queue.d.cts +71 -0
- package/dist/solutions/work-item/work-queue.d.ts +71 -0
- package/dist/solutions/work-item/work-queue.js +270 -0
- package/dist/solutions/work-item/work-queue.js.map +1 -0
- package/dist/sources/browser.cjs +169 -57
- package/dist/sources/browser.cjs.map +1 -1
- package/dist/sources/browser.d.cts +33 -6
- package/dist/sources/browser.d.ts +33 -6
- package/dist/sources/browser.js +73 -6
- package/dist/sources/browser.js.map +1 -1
- package/dist/sources/index.cjs +102 -57
- package/dist/sources/index.cjs.map +1 -1
- package/dist/sources/index.d.cts +5 -5
- package/dist/sources/index.d.ts +5 -5
- package/dist/sources/index.js +6 -5
- package/dist/sources/node.cjs.map +1 -1
- package/dist/sources/node.d.cts +4 -4
- package/dist/sources/node.d.ts +4 -4
- package/dist/sources/node.js +2 -1
- package/dist/sources/node.js.map +1 -1
- package/dist/storage/browser.js +1 -0
- package/dist/storage/browser.js.map +1 -1
- package/dist/storage/index.d.cts +5 -5
- package/dist/storage/index.d.ts +5 -5
- package/dist/storage/index.js +5 -4
- package/dist/storage/node.js +1 -0
- package/dist/storage/node.js.map +1 -1
- package/dist/store-C-joM4gh.d.ts +123 -0
- package/dist/store-CNJwmT-h.d.cts +123 -0
- package/dist/testing/index.cjs +1 -0
- 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 +3 -2
- package/dist/{types-h12mNYbq.d.ts → types-BsJvElYZ.d.ts} +31 -31
- package/dist/{types-bNMSWKqF.d.cts → types-CcPIn7sy.d.cts} +31 -31
- package/dist/work-item-runtime-C3M79vE9.d.ts +228 -0
- package/dist/work-item-runtime-qaVgsL0T.d.cts +228 -0
- package/dist/work-queue/index.cjs +1132 -0
- package/dist/work-queue/index.cjs.map +1 -0
- package/dist/work-queue/index.d.cts +369 -0
- package/dist/work-queue/index.d.ts +369 -0
- package/dist/work-queue/index.js +1078 -0
- package/dist/work-queue/index.js.map +1 -0
- package/package.json +266 -2
- package/dist/chunk-COHO25CZ.js.map +0 -1
- package/dist/chunk-DK554R7P.js.map +0 -1
- package/dist/chunk-I3IHOHCJ.js.map +0 -1
- package/dist/chunk-RIIOUTGM.js.map +0 -1
- package/dist/chunk-SWTLEQL6.js.map +0 -1
- /package/dist/{chunk-JR4IKCR2.js.map → chunk-2747WN4Y.js.map} +0 -0
- /package/dist/{chunk-GDL26N2T.js.map → chunk-3KN7NJDR.js.map} +0 -0
- /package/dist/{chunk-DJC4CHLQ.js.map → chunk-43BKLFZU.js.map} +0 -0
- /package/dist/{chunk-SCRFRCGR.js.map → chunk-BSQGE5PS.js.map} +0 -0
- /package/dist/{chunk-Y3ZLRGHC.js.map → chunk-CZNV3VXM.js.map} +0 -0
- /package/dist/{chunk-JIMUDQN3.js.map → chunk-FBUU43PM.js.map} +0 -0
- /package/dist/{chunk-D6BG7U6A.js.map → chunk-IXZBUWSP.js.map} +0 -0
- /package/dist/{chunk-PKVBHGBM.js.map → chunk-SS2A464I.js.map} +0 -0
- /package/dist/{chunk-G4M3NHRJ.js.map → chunk-V7CIJE4B.js.map} +0 -0
- /package/dist/{chunk-TEW47IVR.js.map → chunk-VPEFSDME.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/cqrs/work-queue.ts","../../src/protocol/messages.ts","../../src/ctx/types.ts"],"sourcesContent":["/**\n * Optional CQRS-over-workQueue recipe (D350/D352/D353).\n *\n * The CQRS core remains synchronous graph-visible command/event truth. This\n * recipe only maps queue claims to CQRS command facts and maps visible CQRS\n * outcomes back to generic workQueue disposition commands.\n */\n\nimport type { CqrsCommand, CqrsError, CqrsErrorCode, CqrsStatus } from \"../cqrs/index.js\";\nimport { type Ctx, depBatch } from \"../ctx/types.js\";\nimport type { DataIssue } from \"../data/index.js\";\nimport type { Graph } from \"../graph/graph.js\";\nimport type { Node } from \"../node/node.js\";\nimport type { WorkQueueCommand, WorkQueueRecord } from \"../work-queue/index.js\";\n\nexport interface CqrsQueuedCommandPayload<TCommand = unknown> {\n\treadonly kind: \"cqrs-queued-command\";\n\treadonly command: CqrsCommand<TCommand>;\n\treadonly idempotencyKey?: string;\n\treadonly sourceRefs?: readonly string[];\n\treadonly policyRefs?: readonly string[];\n\treadonly actorRefs?: readonly string[];\n\treadonly auditRefs?: readonly string[];\n\treadonly metadata?: Record<string, unknown>;\n}\n\nexport interface CqrsWorkQueueAttempt<TCommand = unknown> {\n\treadonly kind: \"cqrs-work-queue-attempt\";\n\treadonly workId: string;\n\treadonly leaseId: string;\n\treadonly queueAttempt: number;\n\treadonly workerId: string;\n\treadonly command: CqrsCommand<TCommand>;\n\treadonly payload: CqrsQueuedCommandPayload<TCommand>;\n\treadonly sourceRefs?: readonly string[];\n}\n\nexport type CqrsWorkQueueAcceptedOutcome = {\n\treadonly kind: \"accepted\";\n\treadonly status: CqrsStatus;\n};\n\nexport type CqrsWorkQueueRejectedOutcome = {\n\treadonly kind: \"rejected\";\n\treadonly status: CqrsStatus;\n\treadonly error?: CqrsError;\n};\n\nexport type CqrsWorkQueueReleaseOutcome = {\n\treadonly kind: \"release\";\n\treadonly reason?: string;\n};\n\nexport type CqrsWorkQueueOutcome =\n\t| CqrsWorkQueueAcceptedOutcome\n\t| CqrsWorkQueueRejectedOutcome\n\t| CqrsWorkQueueReleaseOutcome;\n\nexport interface CqrsWorkQueuePolicy {\n\t/**\n\t * D352: handler-threw and clock-threw fail retryable:true by default. A\n\t * policy may classify a known deterministic handler failure as nonretryable.\n\t */\n\treadonly retryableFailure?: (\n\t\terrorCode: CqrsErrorCode,\n\t\toutcome: CqrsWorkQueueRejectedOutcome,\n\t) => boolean;\n\treadonly releaseReason?: (attempt: CqrsWorkQueueAttempt) => string | undefined;\n}\n\nexport interface CqrsWorkQueueRecipeOptions<TCommand = unknown> {\n\treadonly name?: string;\n\treadonly records: Node<WorkQueueRecord<CqrsQueuedCommandPayload<TCommand>>>;\n\treadonly status: Node<CqrsStatus>;\n\treadonly errors?: Node<CqrsError>;\n\treadonly workerId?: string;\n\treadonly policy?: CqrsWorkQueuePolicy;\n}\n\nexport interface CqrsWorkQueueRecipeBundle<TCommand = unknown> {\n\treadonly attempts: Node<CqrsWorkQueueAttempt<TCommand>>;\n\treadonly dispatches: Node<CqrsCommand<TCommand>>;\n\treadonly commands: Node<WorkQueueCommand<CqrsQueuedCommandPayload<TCommand>>>;\n\treadonly issues: Node<DataIssue>;\n}\n\ntype CqrsQueueFact<TCommand> =\n\t| { readonly kind: \"attempt\"; readonly attempt: CqrsWorkQueueAttempt<TCommand> }\n\t| { readonly kind: \"dispatch\"; readonly command: CqrsCommand<TCommand> }\n\t| {\n\t\t\treadonly kind: \"command\";\n\t\t\treadonly command: WorkQueueCommand<CqrsQueuedCommandPayload<TCommand>>;\n\t }\n\t| { readonly kind: \"issue\"; readonly issue: DataIssue };\n\ninterface CqrsQueueState<TCommand> {\n\treadonly payloads: Map<string, CqrsQueuedCommandPayload<TCommand>>;\n\treadonly activeClaims: Map<string, CqrsWorkQueueAttempt<TCommand>[]>;\n\treadonly errors: Map<string, CqrsError>;\n\treadonly terminalClaims: Set<string>;\n}\n\n/** Build the optional D350/D352 CQRS workQueue recipe. */\nexport function cqrsWorkQueueRecipe<TCommand = unknown>(\n\tgraph: Graph,\n\topts: CqrsWorkQueueRecipeOptions<TCommand>,\n): CqrsWorkQueueRecipeBundle<TCommand> {\n\tconst name = opts.name ?? \"cqrsWorkQueue\";\n\tconst deps =\n\t\topts.errors === undefined\n\t\t\t? [opts.records, opts.status]\n\t\t\t: [opts.records, opts.status, opts.errors];\n\tconst runtime = graph.node<CqrsQueueFact<TCommand>>(\n\t\tdeps,\n\t\t(ctx) => {\n\t\t\tconst state = ctx.state.get<CqrsQueueState<TCommand>>() ?? emptyState<TCommand>();\n\t\t\tfor (const raw of depBatch(ctx, 0) ?? []) {\n\t\t\t\treduceRecord(ctx, state, raw as WorkQueueRecord<CqrsQueuedCommandPayload<TCommand>>, opts);\n\t\t\t}\n\t\t\tif (opts.errors !== undefined) {\n\t\t\t\tfor (const raw of depBatch(ctx, 2) ?? []) {\n\t\t\t\t\tconst error = raw as CqrsError;\n\t\t\t\t\tif (error.commandId !== undefined) state.errors.set(error.commandId, error);\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (const raw of depBatch(ctx, 1) ?? []) {\n\t\t\t\treduceStatus(ctx, state, raw as CqrsStatus, opts);\n\t\t\t}\n\t\t\tctx.state.set(state);\n\t\t},\n\t\t{\n\t\t\tname: `${name}/runtime`,\n\t\t\tfactory: \"cqrsWorkQueueRuntime\",\n\t\t\tpartial: true,\n\t\t\tcompleteWhenDepsComplete: false,\n\t\t\terrorWhenDepsError: false,\n\t\t},\n\t);\n\treturn {\n\t\tattempts: project(graph, runtime, `${name}/attempts`, \"cqrsWorkQueueAttempts\", (fact) =>\n\t\t\tfact.kind === \"attempt\" ? fact.attempt : undefined,\n\t\t),\n\t\tdispatches: project(graph, runtime, `${name}/dispatches`, \"cqrsWorkQueueDispatches\", (fact) =>\n\t\t\tfact.kind === \"dispatch\" ? fact.command : undefined,\n\t\t),\n\t\tcommands: project(graph, runtime, `${name}/commands`, \"cqrsWorkQueueCommands\", (fact) =>\n\t\t\tfact.kind === \"command\" ? fact.command : undefined,\n\t\t),\n\t\tissues: project(graph, runtime, `${name}/issues`, \"cqrsWorkQueueIssues\", (fact) =>\n\t\t\tfact.kind === \"issue\" ? fact.issue : undefined,\n\t\t),\n\t};\n}\n\nexport function cqrsSubmitCommand<TCommand>(\n\tcommand: CqrsCommand<TCommand>,\n\topts: {\n\t\treadonly workId?: string;\n\t\treadonly commandId?: string;\n\t\treadonly idempotencyKey?: string;\n\t\treadonly sourceRefs?: readonly string[];\n\t\treadonly policyRefs?: readonly string[];\n\t\treadonly actorRefs?: readonly string[];\n\t\treadonly auditRefs?: readonly string[];\n\t\treadonly metadata?: Record<string, unknown>;\n\t} = {},\n): WorkQueueCommand<CqrsQueuedCommandPayload<TCommand>> {\n\tconst payload: CqrsQueuedCommandPayload<TCommand> = {\n\t\tkind: \"cqrs-queued-command\",\n\t\tcommand,\n\t\tidempotencyKey: opts.idempotencyKey ?? command.id,\n\t\tsourceRefs: opts.sourceRefs,\n\t\tpolicyRefs: opts.policyRefs,\n\t\tactorRefs: opts.actorRefs,\n\t\tauditRefs: opts.auditRefs,\n\t\tmetadata: opts.metadata,\n\t};\n\treturn {\n\t\tkind: \"submit\",\n\t\tcommandId: opts.commandId ?? `${command.id}:cqrs-work-queue-submit`,\n\t\tworkId: opts.workId ?? `cqrs:${command.id}`,\n\t\tpayload,\n\t\tidempotencyKey: opts.idempotencyKey ?? command.id,\n\t\tsourceRefs: opts.sourceRefs,\n\t\tpolicyRefs: opts.policyRefs,\n\t\tactorRefs: opts.actorRefs,\n\t\tauditRefs: opts.auditRefs,\n\t};\n}\n\nexport function cqrsWorkQueueDispositionCommand<TCommand>(\n\tattempt: CqrsWorkQueueAttempt<TCommand>,\n\toutcome: CqrsWorkQueueOutcome,\n\tpolicy?: CqrsWorkQueuePolicy,\n): WorkQueueCommand<CqrsQueuedCommandPayload<TCommand>> {\n\tif (outcome.kind === \"release\") {\n\t\treturn {\n\t\t\tkind: \"release\",\n\t\t\tcommandId: dispositionCommandId(attempt, \"release\"),\n\t\t\tworkId: attempt.workId,\n\t\t\tleaseId: attempt.leaseId,\n\t\t\tattempt: attempt.queueAttempt,\n\t\t\tworkerId: attempt.workerId,\n\t\t\treason: outcome.reason ?? policy?.releaseReason?.(attempt),\n\t\t};\n\t}\n\tif (outcome.kind === \"accepted\") {\n\t\treturn completeCommand(attempt, {\n\t\t\tkind: \"cqrs-accepted-result\",\n\t\t\tcommandId: outcome.status.commandId,\n\t\t\tcommandType: outcome.status.commandType,\n\t\t\teventCount: outcome.status.eventCount,\n\t\t\tcursor: outcome.status.cursor,\n\t\t});\n\t}\n\tconst code = outcome.status.errorCode;\n\tif (code === \"handler-threw\" || code === \"clock-threw\" || code === undefined) {\n\t\treturn {\n\t\t\tkind: \"fail\",\n\t\t\tcommandId: dispositionCommandId(attempt, \"fail\"),\n\t\t\tworkId: attempt.workId,\n\t\t\tleaseId: attempt.leaseId,\n\t\t\tattempt: attempt.queueAttempt,\n\t\t\tworkerId: attempt.workerId,\n\t\t\terror: outcome.error ?? {\n\t\t\t\tkind: \"issue\",\n\t\t\t\tcode: code ?? \"cqrs-outcome-ambiguous\",\n\t\t\t\tmessage: \"CQRS rejected without deterministic rejection evidence\",\n\t\t\t},\n\t\t\tretryable: code === undefined ? true : (policy?.retryableFailure?.(code, outcome) ?? true),\n\t\t};\n\t}\n\treturn completeCommand(attempt, {\n\t\tkind: \"cqrs-rejected-result\",\n\t\tcommandId: outcome.status.commandId,\n\t\tcommandType: outcome.status.commandType,\n\t\terrorCode: code,\n\t\terror: outcome.error,\n\t\teventCount: outcome.status.eventCount,\n\t\tcursor: outcome.status.cursor,\n\t});\n}\n\nfunction completeCommand<TCommand>(\n\tattempt: CqrsWorkQueueAttempt<TCommand>,\n\tresult: unknown,\n): WorkQueueCommand<CqrsQueuedCommandPayload<TCommand>> {\n\treturn {\n\t\tkind: \"complete\",\n\t\tcommandId: dispositionCommandId(attempt, \"complete\"),\n\t\tworkId: attempt.workId,\n\t\tleaseId: attempt.leaseId,\n\t\tattempt: attempt.queueAttempt,\n\t\tworkerId: attempt.workerId,\n\t\tresult,\n\t};\n}\n\nfunction reduceRecord<TCommand>(\n\tctx: Ctx,\n\tstate: CqrsQueueState<TCommand>,\n\trecord: WorkQueueRecord<CqrsQueuedCommandPayload<TCommand>>,\n\topts: CqrsWorkQueueRecipeOptions<TCommand>,\n): void {\n\tif (record.kind === \"work-admitted\") {\n\t\tif (isQueuedPayload(record.payload)) state.payloads.set(record.workId, record.payload);\n\t\telse emit(ctx, { kind: \"issue\", issue: queueIssue(record, \"cqrs-queue-malformed-payload\") });\n\t\treturn;\n\t}\n\tif (record.kind !== \"work-claimed\") return;\n\tif (opts.workerId !== undefined && record.workerId !== opts.workerId) return;\n\tconst payload = state.payloads.get(record.workId);\n\tif (payload === undefined) {\n\t\temit(ctx, { kind: \"issue\", issue: queueIssue(record, \"cqrs-claim-without-payload\") });\n\t\temit(ctx, {\n\t\t\tkind: \"command\",\n\t\t\tcommand: {\n\t\t\t\tkind: \"release\",\n\t\t\t\tcommandId: `cqrs:${record.workId}:${record.leaseId}:${record.attempt}:release-no-payload`,\n\t\t\t\tworkId: record.workId,\n\t\t\t\tleaseId: record.leaseId,\n\t\t\t\tattempt: record.attempt,\n\t\t\t\tworkerId: record.workerId,\n\t\t\t\treason: \"cqrs-claim-without-payload\",\n\t\t\t},\n\t\t});\n\t\treturn;\n\t}\n\tconst attempt: CqrsWorkQueueAttempt<TCommand> = {\n\t\tkind: \"cqrs-work-queue-attempt\",\n\t\tworkId: record.workId,\n\t\tleaseId: record.leaseId,\n\t\tqueueAttempt: record.attempt,\n\t\tworkerId: record.workerId,\n\t\tcommand: payload.command,\n\t\tpayload,\n\t\tsourceRefs: [...(payload.sourceRefs ?? []), `work-queue-record:${record.recordSeq}`],\n\t};\n\tpushActiveClaim(state, payload.command.id, attempt);\n\temit(ctx, { kind: \"attempt\", attempt });\n\temit(ctx, { kind: \"dispatch\", command: payload.command });\n}\n\nfunction reduceStatus<TCommand>(\n\tctx: Ctx,\n\tstate: CqrsQueueState<TCommand>,\n\tstatus: CqrsStatus,\n\topts: CqrsWorkQueueRecipeOptions<TCommand>,\n): void {\n\tif (status.commandId === undefined) return;\n\tconst attempt = shiftActiveClaim(state, status.commandId);\n\tif (attempt === undefined) {\n\t\temit(ctx, {\n\t\t\tkind: \"issue\",\n\t\t\tissue: {\n\t\t\t\tkind: \"issue\",\n\t\t\t\tcode: \"cqrs-status-without-active-queue-claim\",\n\t\t\t\tmessage:\n\t\t\t\t\t\"CQRS workQueue recipe observed a CQRS status without an active queue claim; no queue disposition was emitted\",\n\t\t\t\tseverity: \"error\",\n\t\t\t\tsource: \"cqrs.workQueue\",\n\t\t\t\trefs: [`cqrs-command:${status.commandId}`],\n\t\t\t\tdetails: status,\n\t\t\t},\n\t\t});\n\t\treturn;\n\t}\n\tconst claimKey = queueClaimKey(attempt);\n\tif (state.terminalClaims.has(claimKey)) {\n\t\temit(ctx, {\n\t\t\tkind: \"issue\",\n\t\t\tissue: {\n\t\t\t\tkind: \"issue\",\n\t\t\t\tcode: \"cqrs-duplicate-terminal-outcome-for-queue-claim\",\n\t\t\t\tmessage: `CQRS queue claim '${claimKey}' already produced a terminal queue disposition`,\n\t\t\t\trefs: [`cqrs-command:${status.commandId}`, `work-queue-work:${attempt.workId}`],\n\t\t\t},\n\t\t});\n\t\treturn;\n\t}\n\tstate.terminalClaims.add(claimKey);\n\tconst command = cqrsWorkQueueDispositionCommand(\n\t\tattempt,\n\t\tstatus.state === \"accepted\"\n\t\t\t? { kind: \"accepted\", status }\n\t\t\t: { kind: \"rejected\", status, error: state.errors.get(status.commandId) },\n\t\topts.policy,\n\t);\n\temit(ctx, { kind: \"command\", command });\n}\n\nfunction emptyState<TCommand>(): CqrsQueueState<TCommand> {\n\treturn {\n\t\tpayloads: new Map(),\n\t\tactiveClaims: new Map(),\n\t\terrors: new Map(),\n\t\tterminalClaims: new Set(),\n\t};\n}\n\nfunction pushActiveClaim<TCommand>(\n\tstate: CqrsQueueState<TCommand>,\n\tcommandId: string,\n\tattempt: CqrsWorkQueueAttempt<TCommand>,\n): void {\n\tconst claims = state.activeClaims.get(commandId) ?? [];\n\tstate.activeClaims.set(commandId, [...claims, attempt]);\n}\n\nfunction shiftActiveClaim<TCommand>(\n\tstate: CqrsQueueState<TCommand>,\n\tcommandId: string,\n): CqrsWorkQueueAttempt<TCommand> | undefined {\n\tconst claims = state.activeClaims.get(commandId);\n\tif (claims === undefined || claims.length === 0) return undefined;\n\tconst [first, ...rest] = claims;\n\tif (rest.length === 0) state.activeClaims.delete(commandId);\n\telse state.activeClaims.set(commandId, rest);\n\treturn first;\n}\n\nfunction queueClaimKey(attempt: CqrsWorkQueueAttempt): string {\n\treturn `${attempt.workId}:${attempt.leaseId}:${attempt.queueAttempt}`;\n}\n\nfunction dispositionCommandId(attempt: CqrsWorkQueueAttempt, kind: string): string {\n\treturn `${attempt.command.id}:${attempt.workId}:${attempt.leaseId}:${attempt.queueAttempt}:cqrs-queue-${kind}`;\n}\n\nfunction project<T, TCommand>(\n\tgraph: Graph,\n\truntime: Node<CqrsQueueFact<TCommand>>,\n\tname: string,\n\tfactory: string,\n\tpick: (fact: CqrsQueueFact<TCommand>) => T | undefined,\n): Node<T> {\n\treturn graph.node<T>(\n\t\t[runtime],\n\t\t(ctx) => {\n\t\t\tfor (const fact of depBatch(ctx, 0) ?? []) {\n\t\t\t\tconst value = pick(fact as CqrsQueueFact<TCommand>);\n\t\t\t\tif (value !== undefined) ctx.down([[\"DATA\", value]]);\n\t\t\t}\n\t\t},\n\t\t{ name, factory, partial: true, completeWhenDepsComplete: false, errorWhenDepsError: false },\n\t);\n}\n\nfunction emit<TCommand>(ctx: Ctx, fact: CqrsQueueFact<TCommand>): void {\n\tctx.down([[\"DATA\", fact]]);\n}\n\nfunction isQueuedPayload<TCommand>(value: unknown): value is CqrsQueuedCommandPayload<TCommand> {\n\tif (!isObjectRecord(value) || value.kind !== \"cqrs-queued-command\") return false;\n\treturn isObjectRecord(value.command) && typeof value.command.id === \"string\";\n}\n\nfunction queueIssue(record: WorkQueueRecord<unknown>, code: string): DataIssue {\n\treturn {\n\t\tkind: \"issue\",\n\t\tcode,\n\t\tmessage: `CQRS workQueue recipe could not map record '${record.kind}'`,\n\t\tseverity: \"error\",\n\t\tsource: \"cqrs.workQueue\",\n\t\trefs: record.workId === undefined ? undefined : [`work-queue-work:${record.workId}`],\n\t\tdetails: record,\n\t};\n}\n\nfunction isObjectRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null;\n}\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. */\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. */\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\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). */\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. */\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. */\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 */\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 */\nexport function isUpAllowed(t: MessageType): boolean {\n\tconst tier = TIER[t];\n\treturn tier !== TIER_VALUE && tier !== TIER_TERMINAL;\n}\n","/**\n * The fn-invocation context and per-dep input shapes.\n *\n * Canonical authority: ~/src/graphrefly/spec/rules.jsonl\n * R-fn-contract (D8/D27), R-ctx-state (D23/D29), R-cleanup-hooks (D28), R-ctx-up.\n */\n\nimport type { Dispatcher } from \"../dispatcher/index.js\";\nimport type { EnvironmentDrivers } from \"../graph/environment.js\";\nimport type { Node } from \"../node/node.js\";\nimport { type Message, type PullDemand, SENTINEL, type Wave } from \"../protocol/messages.js\";\n\n/** A downstream sink callback (the only way to connect to a node's output). */\nexport type Sink = (msg: Message, delivery?: DeliveryMeta) => void;\n\n/** Internal delivery metadata used to preserve the upstream `ctx.down(msgs)` wave boundary. */\nexport interface DeliveryMeta {\n\treadonly wave: object;\n\treadonly last: boolean;\n}\n\n/**\n * Internal current-value reader. It is deliberately a symbol-backed implementation detail:\n * raw ctx exposes `waveData` + `terminal`; helpers below derive from that plus this dep cache.\n */\nexport const CTX_DEP_CACHE: unique symbol = Symbol(\"graphrefly.ctx.depCache\");\n\nexport interface CtxDepCache {\n\treadonly latest: readonly unknown[];\n}\n\n/** Internal node-construction binding for graph-local helper-created deps. */\nexport const CTX_NODE_BINDING: unique symbol = Symbol(\"graphrefly.ctx.nodeBinding\");\n\nexport interface CtxNodeBinding {\n\treadonly dispatcher: Dispatcher;\n\tcreate<T>(factory: () => Node<T>): Node<T>;\n}\n\n/** Per-dep wave projections: dep -> waves -> values/SENTINEL markers. */\nexport type WaveData = readonly (readonly (readonly unknown[])[])[];\n\n/** Terminal metadata parallel to `waveData`: false = none, true = COMPLETE, otherwise ERROR payload. */\nexport type TerminalData = readonly unknown[];\n\nexport function isTerminalNone(t: unknown): boolean {\n\treturn t === false || t === undefined;\n}\n\nexport function isTerminalComplete(t: unknown): t is true {\n\treturn t === true;\n}\n\nexport function isTerminalError(t: unknown): boolean {\n\treturn !isTerminalNone(t) && !isTerminalComplete(t);\n}\n\nexport function terminalErrorValue(t: unknown): unknown {\n\treturn isTerminalError(t) ? t : undefined;\n}\n\n/**\n * Per-node private cross-wave state (R-ctx-state / D23,D29). Default fresh-lifecycle\n * wipe; `persist(true)` keeps it across lifecycle transitions.\n */\nexport interface CtxState {\n\tget<S = unknown>(): S | undefined;\n\tset<S = unknown>(v: S): void;\n\tpersist(on?: boolean): void;\n}\n\n/**\n * Deferred SELF-rewire (R-rewire-deferred / D47). A node fn may, DURING its run, request a\n * mutation of its OWN dep set; the request is QUEUED and applied at the committed wave boundary\n * (after the current wave settles / batch commit / final-lock RESUME) as a fresh wave, reusing\n * R-rewire surgical/Option-C semantics (D42). This is the ONLY legal self-triggered rewire — an\n * IMMEDIATE in-fn `node.subscribeDep/unsubscribeDep/replaceDeps` is the D37 mid-fn feedback-cycle ERROR. An\n * added cached dep pushes `[DIRTY,DATA]` on the boundary wave (R-push-subscribe); a removed dep\n * is drained and, if it loses its last subscriber, `_deactivate`s + fires `onDeactivation`\n * (input-side teardown — the basis for higher-order operator cancellation / abortInFlight).\n */\nexport interface RewireNext {\n\t/** Defer subscribing to a dep (paired with the re-supplied fn — positional fn-deps lock, SD-1). */\n\tsubscribeDep(dep: Node<unknown>, fn: NodeFn): void;\n\t/** Defer unsubscribing from a dep (its source is torn down if it loses its last subscriber). */\n\tunsubscribeDep(dep: Node<unknown>, fn: NodeFn): void;\n\t/** Defer replacing the whole dep set (surgical: kept deps untouched, removed drained, added fresh-subscribe). */\n\treplaceDeps(deps: Node<unknown>[], fn: NodeFn): void;\n}\n\n/**\n * The single argument to a node fn: `(ctx) => void` (R-fn-contract / D8). All emission\n * is explicit via `ctx.down`; there is no return-value framing.\n */\nexport interface Ctx {\n\t/**\n\t * Emit upstream toward deps — control tiers only (R-ctx-up). IMMEDIATE. `towardDep` (a dep index)\n\t * routes the wave up ONE declared edge (R-up-routing directed-up); omitted = broadcast up all deps.\n\t * A pull DEMAND is `up([[PULL, { pullId, params }]])` — but for a SELF-demand (demanding a dep\n\t * this fn also reads) use {@link Ctx.upNext} instead, since an immediate demand whose delivery loops back\n\t * re-enters this fn mid-wave (D37 / R-reentrancy).\n\t */\n\tup(msgs: Wave, towardDep?: number): void;\n\t/** Emit downstream toward sinks. */\n\tdown(msgs: Wave): void;\n\t/**\n\t * The single raw dep-value input surface (R-ctx-wave-data / D77): dep -> upstream waves ->\n\t * per-wave DATA payloads and INVALIDATE/SENTINEL markers. `waveData[i] = []` means dep i\n\t * delivered no wave to this invocation; `waveData[i] = [[]]` means RESOLVED-only.\n\t */\n\twaveData: WaveData;\n\t/** Terminal metadata for the same invocation; terminal values never enter `waveData`. */\n\tterminal: TerminalData;\n\tstate: CtxState;\n\t/** Release external resources on deactivation (R-cleanup-hooks). */\n\tonDeactivation(fn: () => void): void;\n\t/** Flush on INVALIDATE (R-cleanup-hooks). */\n\tonInvalidate(fn: () => void): void;\n\t/** Graph-owned environment drivers for source/adapter boundaries (D130/D131). */\n\tenvironment(): EnvironmentDrivers;\n\t/** Holder-visible context for a PULL-caused invocation (D272); absent for ordinary waves. */\n\treadonly pull?: PullDemand;\n\t/**\n\t * Deferred SELF-rewire (R-rewire-deferred / D47) — the substrate affordance higher-order\n\t * operators (switchMap/mergeMap/concatMap/exhaustMap/flatMap) use to grow/shrink their own\n\t * inner-source dep set in response to their own data. Always present; see {@link RewireNext}.\n\t */\n\trewireNext: RewireNext;\n\t/**\n\t * Deferred up — the boundary-deferred form of {@link Ctx.up} (R-up-routing / R-pull / D59). Routes\n\t * `msgs` up from this node at the COMMITTED wave boundary (broadcast, or up the single `towardDep`\n\t * edge), riding the same R-rewire-deferred (D47) drain as {@link RewireNext}. This is the\n\t * SELF-DEMAND path: a consumer issues `ctx.upNext([[PULL, { pullId, params }]])` to demand a pull\n\t * dep it ALSO reads — the cone-routed PULL reaches the pullId-holder, whose delivery loops back as a\n\t * FRESH wave (not a mid-fn re-entry → no D37). The consumer accepts one-wave latency (the\n\t * HTTP-request model). No node reference needed: the author writes the pullId verbatim.\n\t */\n\tupNext(msgs: Wave, towardDep?: number): void;\n\t/**\n\t * Read a dep's latest value by index (dynamicNode only, R-dynamic-node / D35).\n\t * Present only on dynamicNode fns; all declared deps still participate in wave\n\t * tracking. Under D49/R-resolved-undirty an unread dep's change still fires the fn,\n\t * which re-emits its (unchanged) output as a DATA occurrence — there is NO equals-\n\t * absorption; pair with distinctUntilChanged to suppress unchanged re-emits (opt-in).\n\t */\n\ttrack?(depIndex: number): unknown;\n\t[CTX_DEP_CACHE]?: CtxDepCache;\n\t[CTX_NODE_BINDING]?: CtxNodeBinding;\n}\n\n/** A node fn (R-fn-contract). Registered in a dispatcher pool, indexed by Handle. */\nexport type NodeFn = (ctx: Ctx) => void;\n\n/** Number of declared dep slots visible in this invocation. */\nexport function depCount(ctx: Ctx): number {\n\treturn ctx.waveData.length;\n}\n\n/** DATA/SENTINEL projection batches delivered by one dep in this invocation. */\nexport function depWaves(ctx: Ctx, depIndex: number): readonly (readonly unknown[])[] {\n\treturn ctx.waveData[depIndex] ?? [];\n}\n\n/** Flattened DATA projection for old event-counting operator bodies; null = no wave. */\nexport function depBatch(ctx: Ctx, depIndex: number): readonly unknown[] | null {\n\tconst waves = depWaves(ctx, depIndex);\n\tif (waves.length === 0) return null;\n\tconst flattened = waves.flat().filter((v) => v !== SENTINEL);\n\treturn flattened.length === 0 ? [] : flattened;\n}\n\n/** Latest cached DATA for a dep, derived from implementation-owned dep cache. */\nexport function depLatest(ctx: Ctx, depIndex: number): unknown {\n\treturn ctx[CTX_DEP_CACHE]?.latest[depIndex];\n}\n\n/** Terminal metadata for one dep: false = none, true = COMPLETE, otherwise ERROR payload. */\nexport function depTerminal(ctx: Ctx, depIndex: number): unknown {\n\tconst t = ctx.terminal[depIndex];\n\treturn t === undefined ? false : t;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;AC2CO,IAAM,WAAW;;;ACoHjB,SAAS,SAAS,KAAU,UAAmD;AACrF,SAAO,IAAI,SAAS,QAAQ,KAAK,CAAC;AACnC;AAGO,SAAS,SAAS,KAAU,UAA6C;AAC/E,QAAM,QAAQ,SAAS,KAAK,QAAQ;AACpC,MAAI,MAAM,WAAW,EAAG,QAAO;AAC/B,QAAM,YAAY,MAAM,KAAK,EAAE,OAAO,CAAC,MAAM,MAAM,QAAQ;AAC3D,SAAO,UAAU,WAAW,IAAI,CAAC,IAAI;AACtC;;;AFlEO,SAAS,oBACf,OACA,MACsC;AACtC,QAAM,OAAO,KAAK,QAAQ;AAC1B,QAAM,OACL,KAAK,WAAW,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U;AAC/C;","names":[]}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { CqrsCommand, CqrsStatus, CqrsError, CqrsErrorCode } from './index.cjs';
|
|
2
|
+
import { DataIssue } from '../data/index.cjs';
|
|
3
|
+
import { d as Graph } from '../graph-DCEWh4T2.cjs';
|
|
4
|
+
import { N as Node } from '../types-CcPIn7sy.cjs';
|
|
5
|
+
import { WorkQueueCommand, WorkQueueRecord } from '../work-queue/index.cjs';
|
|
6
|
+
import '../core/index.cjs';
|
|
7
|
+
import '../messages-CAzUPPJM.cjs';
|
|
8
|
+
import '../codec-BB7p8fJc.cjs';
|
|
9
|
+
import '../describe-DYMw_l1C.cjs';
|
|
10
|
+
import '../messaging/index.cjs';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Optional CQRS-over-workQueue recipe (D350/D352/D353).
|
|
14
|
+
*
|
|
15
|
+
* The CQRS core remains synchronous graph-visible command/event truth. This
|
|
16
|
+
* recipe only maps queue claims to CQRS command facts and maps visible CQRS
|
|
17
|
+
* outcomes back to generic workQueue disposition commands.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
interface CqrsQueuedCommandPayload<TCommand = unknown> {
|
|
21
|
+
readonly kind: "cqrs-queued-command";
|
|
22
|
+
readonly command: CqrsCommand<TCommand>;
|
|
23
|
+
readonly idempotencyKey?: string;
|
|
24
|
+
readonly sourceRefs?: readonly string[];
|
|
25
|
+
readonly policyRefs?: readonly string[];
|
|
26
|
+
readonly actorRefs?: readonly string[];
|
|
27
|
+
readonly auditRefs?: readonly string[];
|
|
28
|
+
readonly metadata?: Record<string, unknown>;
|
|
29
|
+
}
|
|
30
|
+
interface CqrsWorkQueueAttempt<TCommand = unknown> {
|
|
31
|
+
readonly kind: "cqrs-work-queue-attempt";
|
|
32
|
+
readonly workId: string;
|
|
33
|
+
readonly leaseId: string;
|
|
34
|
+
readonly queueAttempt: number;
|
|
35
|
+
readonly workerId: string;
|
|
36
|
+
readonly command: CqrsCommand<TCommand>;
|
|
37
|
+
readonly payload: CqrsQueuedCommandPayload<TCommand>;
|
|
38
|
+
readonly sourceRefs?: readonly string[];
|
|
39
|
+
}
|
|
40
|
+
type CqrsWorkQueueAcceptedOutcome = {
|
|
41
|
+
readonly kind: "accepted";
|
|
42
|
+
readonly status: CqrsStatus;
|
|
43
|
+
};
|
|
44
|
+
type CqrsWorkQueueRejectedOutcome = {
|
|
45
|
+
readonly kind: "rejected";
|
|
46
|
+
readonly status: CqrsStatus;
|
|
47
|
+
readonly error?: CqrsError;
|
|
48
|
+
};
|
|
49
|
+
type CqrsWorkQueueReleaseOutcome = {
|
|
50
|
+
readonly kind: "release";
|
|
51
|
+
readonly reason?: string;
|
|
52
|
+
};
|
|
53
|
+
type CqrsWorkQueueOutcome = CqrsWorkQueueAcceptedOutcome | CqrsWorkQueueRejectedOutcome | CqrsWorkQueueReleaseOutcome;
|
|
54
|
+
interface CqrsWorkQueuePolicy {
|
|
55
|
+
/**
|
|
56
|
+
* D352: handler-threw and clock-threw fail retryable:true by default. A
|
|
57
|
+
* policy may classify a known deterministic handler failure as nonretryable.
|
|
58
|
+
*/
|
|
59
|
+
readonly retryableFailure?: (errorCode: CqrsErrorCode, outcome: CqrsWorkQueueRejectedOutcome) => boolean;
|
|
60
|
+
readonly releaseReason?: (attempt: CqrsWorkQueueAttempt) => string | undefined;
|
|
61
|
+
}
|
|
62
|
+
interface CqrsWorkQueueRecipeOptions<TCommand = unknown> {
|
|
63
|
+
readonly name?: string;
|
|
64
|
+
readonly records: Node<WorkQueueRecord<CqrsQueuedCommandPayload<TCommand>>>;
|
|
65
|
+
readonly status: Node<CqrsStatus>;
|
|
66
|
+
readonly errors?: Node<CqrsError>;
|
|
67
|
+
readonly workerId?: string;
|
|
68
|
+
readonly policy?: CqrsWorkQueuePolicy;
|
|
69
|
+
}
|
|
70
|
+
interface CqrsWorkQueueRecipeBundle<TCommand = unknown> {
|
|
71
|
+
readonly attempts: Node<CqrsWorkQueueAttempt<TCommand>>;
|
|
72
|
+
readonly dispatches: Node<CqrsCommand<TCommand>>;
|
|
73
|
+
readonly commands: Node<WorkQueueCommand<CqrsQueuedCommandPayload<TCommand>>>;
|
|
74
|
+
readonly issues: Node<DataIssue>;
|
|
75
|
+
}
|
|
76
|
+
/** Build the optional D350/D352 CQRS workQueue recipe. */
|
|
77
|
+
declare function cqrsWorkQueueRecipe<TCommand = unknown>(graph: Graph, opts: CqrsWorkQueueRecipeOptions<TCommand>): CqrsWorkQueueRecipeBundle<TCommand>;
|
|
78
|
+
declare function cqrsSubmitCommand<TCommand>(command: CqrsCommand<TCommand>, opts?: {
|
|
79
|
+
readonly workId?: string;
|
|
80
|
+
readonly commandId?: string;
|
|
81
|
+
readonly idempotencyKey?: string;
|
|
82
|
+
readonly sourceRefs?: readonly string[];
|
|
83
|
+
readonly policyRefs?: readonly string[];
|
|
84
|
+
readonly actorRefs?: readonly string[];
|
|
85
|
+
readonly auditRefs?: readonly string[];
|
|
86
|
+
readonly metadata?: Record<string, unknown>;
|
|
87
|
+
}): WorkQueueCommand<CqrsQueuedCommandPayload<TCommand>>;
|
|
88
|
+
declare function cqrsWorkQueueDispositionCommand<TCommand>(attempt: CqrsWorkQueueAttempt<TCommand>, outcome: CqrsWorkQueueOutcome, policy?: CqrsWorkQueuePolicy): WorkQueueCommand<CqrsQueuedCommandPayload<TCommand>>;
|
|
89
|
+
|
|
90
|
+
export { type CqrsQueuedCommandPayload, type CqrsWorkQueueAcceptedOutcome, type CqrsWorkQueueAttempt, type CqrsWorkQueueOutcome, type CqrsWorkQueuePolicy, type CqrsWorkQueueRecipeBundle, type CqrsWorkQueueRecipeOptions, type CqrsWorkQueueRejectedOutcome, type CqrsWorkQueueReleaseOutcome, cqrsSubmitCommand, cqrsWorkQueueDispositionCommand, cqrsWorkQueueRecipe };
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { CqrsCommand, CqrsStatus, CqrsError, CqrsErrorCode } from './index.js';
|
|
2
|
+
import { DataIssue } from '../data/index.js';
|
|
3
|
+
import { d as Graph } from '../graph-D-1-SQeC.js';
|
|
4
|
+
import { N as Node } from '../types-BsJvElYZ.js';
|
|
5
|
+
import { WorkQueueCommand, WorkQueueRecord } from '../work-queue/index.js';
|
|
6
|
+
import '../core/index.js';
|
|
7
|
+
import '../messages-CAzUPPJM.js';
|
|
8
|
+
import '../codec-BB7p8fJc.js';
|
|
9
|
+
import '../describe-BpyJuWkw.js';
|
|
10
|
+
import '../messaging/index.js';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Optional CQRS-over-workQueue recipe (D350/D352/D353).
|
|
14
|
+
*
|
|
15
|
+
* The CQRS core remains synchronous graph-visible command/event truth. This
|
|
16
|
+
* recipe only maps queue claims to CQRS command facts and maps visible CQRS
|
|
17
|
+
* outcomes back to generic workQueue disposition commands.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
interface CqrsQueuedCommandPayload<TCommand = unknown> {
|
|
21
|
+
readonly kind: "cqrs-queued-command";
|
|
22
|
+
readonly command: CqrsCommand<TCommand>;
|
|
23
|
+
readonly idempotencyKey?: string;
|
|
24
|
+
readonly sourceRefs?: readonly string[];
|
|
25
|
+
readonly policyRefs?: readonly string[];
|
|
26
|
+
readonly actorRefs?: readonly string[];
|
|
27
|
+
readonly auditRefs?: readonly string[];
|
|
28
|
+
readonly metadata?: Record<string, unknown>;
|
|
29
|
+
}
|
|
30
|
+
interface CqrsWorkQueueAttempt<TCommand = unknown> {
|
|
31
|
+
readonly kind: "cqrs-work-queue-attempt";
|
|
32
|
+
readonly workId: string;
|
|
33
|
+
readonly leaseId: string;
|
|
34
|
+
readonly queueAttempt: number;
|
|
35
|
+
readonly workerId: string;
|
|
36
|
+
readonly command: CqrsCommand<TCommand>;
|
|
37
|
+
readonly payload: CqrsQueuedCommandPayload<TCommand>;
|
|
38
|
+
readonly sourceRefs?: readonly string[];
|
|
39
|
+
}
|
|
40
|
+
type CqrsWorkQueueAcceptedOutcome = {
|
|
41
|
+
readonly kind: "accepted";
|
|
42
|
+
readonly status: CqrsStatus;
|
|
43
|
+
};
|
|
44
|
+
type CqrsWorkQueueRejectedOutcome = {
|
|
45
|
+
readonly kind: "rejected";
|
|
46
|
+
readonly status: CqrsStatus;
|
|
47
|
+
readonly error?: CqrsError;
|
|
48
|
+
};
|
|
49
|
+
type CqrsWorkQueueReleaseOutcome = {
|
|
50
|
+
readonly kind: "release";
|
|
51
|
+
readonly reason?: string;
|
|
52
|
+
};
|
|
53
|
+
type CqrsWorkQueueOutcome = CqrsWorkQueueAcceptedOutcome | CqrsWorkQueueRejectedOutcome | CqrsWorkQueueReleaseOutcome;
|
|
54
|
+
interface CqrsWorkQueuePolicy {
|
|
55
|
+
/**
|
|
56
|
+
* D352: handler-threw and clock-threw fail retryable:true by default. A
|
|
57
|
+
* policy may classify a known deterministic handler failure as nonretryable.
|
|
58
|
+
*/
|
|
59
|
+
readonly retryableFailure?: (errorCode: CqrsErrorCode, outcome: CqrsWorkQueueRejectedOutcome) => boolean;
|
|
60
|
+
readonly releaseReason?: (attempt: CqrsWorkQueueAttempt) => string | undefined;
|
|
61
|
+
}
|
|
62
|
+
interface CqrsWorkQueueRecipeOptions<TCommand = unknown> {
|
|
63
|
+
readonly name?: string;
|
|
64
|
+
readonly records: Node<WorkQueueRecord<CqrsQueuedCommandPayload<TCommand>>>;
|
|
65
|
+
readonly status: Node<CqrsStatus>;
|
|
66
|
+
readonly errors?: Node<CqrsError>;
|
|
67
|
+
readonly workerId?: string;
|
|
68
|
+
readonly policy?: CqrsWorkQueuePolicy;
|
|
69
|
+
}
|
|
70
|
+
interface CqrsWorkQueueRecipeBundle<TCommand = unknown> {
|
|
71
|
+
readonly attempts: Node<CqrsWorkQueueAttempt<TCommand>>;
|
|
72
|
+
readonly dispatches: Node<CqrsCommand<TCommand>>;
|
|
73
|
+
readonly commands: Node<WorkQueueCommand<CqrsQueuedCommandPayload<TCommand>>>;
|
|
74
|
+
readonly issues: Node<DataIssue>;
|
|
75
|
+
}
|
|
76
|
+
/** Build the optional D350/D352 CQRS workQueue recipe. */
|
|
77
|
+
declare function cqrsWorkQueueRecipe<TCommand = unknown>(graph: Graph, opts: CqrsWorkQueueRecipeOptions<TCommand>): CqrsWorkQueueRecipeBundle<TCommand>;
|
|
78
|
+
declare function cqrsSubmitCommand<TCommand>(command: CqrsCommand<TCommand>, opts?: {
|
|
79
|
+
readonly workId?: string;
|
|
80
|
+
readonly commandId?: string;
|
|
81
|
+
readonly idempotencyKey?: string;
|
|
82
|
+
readonly sourceRefs?: readonly string[];
|
|
83
|
+
readonly policyRefs?: readonly string[];
|
|
84
|
+
readonly actorRefs?: readonly string[];
|
|
85
|
+
readonly auditRefs?: readonly string[];
|
|
86
|
+
readonly metadata?: Record<string, unknown>;
|
|
87
|
+
}): WorkQueueCommand<CqrsQueuedCommandPayload<TCommand>>;
|
|
88
|
+
declare function cqrsWorkQueueDispositionCommand<TCommand>(attempt: CqrsWorkQueueAttempt<TCommand>, outcome: CqrsWorkQueueOutcome, policy?: CqrsWorkQueuePolicy): WorkQueueCommand<CqrsQueuedCommandPayload<TCommand>>;
|
|
89
|
+
|
|
90
|
+
export { type CqrsQueuedCommandPayload, type CqrsWorkQueueAcceptedOutcome, type CqrsWorkQueueAttempt, type CqrsWorkQueueOutcome, type CqrsWorkQueuePolicy, type CqrsWorkQueueRecipeBundle, type CqrsWorkQueueRecipeOptions, type CqrsWorkQueueRejectedOutcome, type CqrsWorkQueueReleaseOutcome, cqrsSubmitCommand, cqrsWorkQueueDispositionCommand, cqrsWorkQueueRecipe };
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
import {
|
|
2
|
+
depBatch
|
|
3
|
+
} from "../chunk-WQIA3GFB.js";
|
|
4
|
+
import "../chunk-S6HXABGL.js";
|
|
5
|
+
import "../chunk-DGUM43GV.js";
|
|
6
|
+
|
|
7
|
+
// src/cqrs/work-queue.ts
|
|
8
|
+
function cqrsWorkQueueRecipe(graph, opts) {
|
|
9
|
+
const name = opts.name ?? "cqrsWorkQueue";
|
|
10
|
+
const deps = opts.errors === void 0 ? [opts.records, opts.status] : [opts.records, opts.status, opts.errors];
|
|
11
|
+
const runtime = graph.node(
|
|
12
|
+
deps,
|
|
13
|
+
(ctx) => {
|
|
14
|
+
const state = ctx.state.get() ?? emptyState();
|
|
15
|
+
for (const raw of depBatch(ctx, 0) ?? []) {
|
|
16
|
+
reduceRecord(ctx, state, raw, opts);
|
|
17
|
+
}
|
|
18
|
+
if (opts.errors !== void 0) {
|
|
19
|
+
for (const raw of depBatch(ctx, 2) ?? []) {
|
|
20
|
+
const error = raw;
|
|
21
|
+
if (error.commandId !== void 0) state.errors.set(error.commandId, error);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
for (const raw of depBatch(ctx, 1) ?? []) {
|
|
25
|
+
reduceStatus(ctx, state, raw, opts);
|
|
26
|
+
}
|
|
27
|
+
ctx.state.set(state);
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: `${name}/runtime`,
|
|
31
|
+
factory: "cqrsWorkQueueRuntime",
|
|
32
|
+
partial: true,
|
|
33
|
+
completeWhenDepsComplete: false,
|
|
34
|
+
errorWhenDepsError: false
|
|
35
|
+
}
|
|
36
|
+
);
|
|
37
|
+
return {
|
|
38
|
+
attempts: project(
|
|
39
|
+
graph,
|
|
40
|
+
runtime,
|
|
41
|
+
`${name}/attempts`,
|
|
42
|
+
"cqrsWorkQueueAttempts",
|
|
43
|
+
(fact) => fact.kind === "attempt" ? fact.attempt : void 0
|
|
44
|
+
),
|
|
45
|
+
dispatches: project(
|
|
46
|
+
graph,
|
|
47
|
+
runtime,
|
|
48
|
+
`${name}/dispatches`,
|
|
49
|
+
"cqrsWorkQueueDispatches",
|
|
50
|
+
(fact) => fact.kind === "dispatch" ? fact.command : void 0
|
|
51
|
+
),
|
|
52
|
+
commands: project(
|
|
53
|
+
graph,
|
|
54
|
+
runtime,
|
|
55
|
+
`${name}/commands`,
|
|
56
|
+
"cqrsWorkQueueCommands",
|
|
57
|
+
(fact) => fact.kind === "command" ? fact.command : void 0
|
|
58
|
+
),
|
|
59
|
+
issues: project(
|
|
60
|
+
graph,
|
|
61
|
+
runtime,
|
|
62
|
+
`${name}/issues`,
|
|
63
|
+
"cqrsWorkQueueIssues",
|
|
64
|
+
(fact) => fact.kind === "issue" ? fact.issue : void 0
|
|
65
|
+
)
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
function cqrsSubmitCommand(command, opts = {}) {
|
|
69
|
+
const payload = {
|
|
70
|
+
kind: "cqrs-queued-command",
|
|
71
|
+
command,
|
|
72
|
+
idempotencyKey: opts.idempotencyKey ?? command.id,
|
|
73
|
+
sourceRefs: opts.sourceRefs,
|
|
74
|
+
policyRefs: opts.policyRefs,
|
|
75
|
+
actorRefs: opts.actorRefs,
|
|
76
|
+
auditRefs: opts.auditRefs,
|
|
77
|
+
metadata: opts.metadata
|
|
78
|
+
};
|
|
79
|
+
return {
|
|
80
|
+
kind: "submit",
|
|
81
|
+
commandId: opts.commandId ?? `${command.id}:cqrs-work-queue-submit`,
|
|
82
|
+
workId: opts.workId ?? `cqrs:${command.id}`,
|
|
83
|
+
payload,
|
|
84
|
+
idempotencyKey: opts.idempotencyKey ?? command.id,
|
|
85
|
+
sourceRefs: opts.sourceRefs,
|
|
86
|
+
policyRefs: opts.policyRefs,
|
|
87
|
+
actorRefs: opts.actorRefs,
|
|
88
|
+
auditRefs: opts.auditRefs
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
function cqrsWorkQueueDispositionCommand(attempt, outcome, policy) {
|
|
92
|
+
if (outcome.kind === "release") {
|
|
93
|
+
return {
|
|
94
|
+
kind: "release",
|
|
95
|
+
commandId: dispositionCommandId(attempt, "release"),
|
|
96
|
+
workId: attempt.workId,
|
|
97
|
+
leaseId: attempt.leaseId,
|
|
98
|
+
attempt: attempt.queueAttempt,
|
|
99
|
+
workerId: attempt.workerId,
|
|
100
|
+
reason: outcome.reason ?? policy?.releaseReason?.(attempt)
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
if (outcome.kind === "accepted") {
|
|
104
|
+
return completeCommand(attempt, {
|
|
105
|
+
kind: "cqrs-accepted-result",
|
|
106
|
+
commandId: outcome.status.commandId,
|
|
107
|
+
commandType: outcome.status.commandType,
|
|
108
|
+
eventCount: outcome.status.eventCount,
|
|
109
|
+
cursor: outcome.status.cursor
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
const code = outcome.status.errorCode;
|
|
113
|
+
if (code === "handler-threw" || code === "clock-threw" || code === void 0) {
|
|
114
|
+
return {
|
|
115
|
+
kind: "fail",
|
|
116
|
+
commandId: dispositionCommandId(attempt, "fail"),
|
|
117
|
+
workId: attempt.workId,
|
|
118
|
+
leaseId: attempt.leaseId,
|
|
119
|
+
attempt: attempt.queueAttempt,
|
|
120
|
+
workerId: attempt.workerId,
|
|
121
|
+
error: outcome.error ?? {
|
|
122
|
+
kind: "issue",
|
|
123
|
+
code: code ?? "cqrs-outcome-ambiguous",
|
|
124
|
+
message: "CQRS rejected without deterministic rejection evidence"
|
|
125
|
+
},
|
|
126
|
+
retryable: code === void 0 ? true : policy?.retryableFailure?.(code, outcome) ?? true
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
return completeCommand(attempt, {
|
|
130
|
+
kind: "cqrs-rejected-result",
|
|
131
|
+
commandId: outcome.status.commandId,
|
|
132
|
+
commandType: outcome.status.commandType,
|
|
133
|
+
errorCode: code,
|
|
134
|
+
error: outcome.error,
|
|
135
|
+
eventCount: outcome.status.eventCount,
|
|
136
|
+
cursor: outcome.status.cursor
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
function completeCommand(attempt, result) {
|
|
140
|
+
return {
|
|
141
|
+
kind: "complete",
|
|
142
|
+
commandId: dispositionCommandId(attempt, "complete"),
|
|
143
|
+
workId: attempt.workId,
|
|
144
|
+
leaseId: attempt.leaseId,
|
|
145
|
+
attempt: attempt.queueAttempt,
|
|
146
|
+
workerId: attempt.workerId,
|
|
147
|
+
result
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
function reduceRecord(ctx, state, record, opts) {
|
|
151
|
+
if (record.kind === "work-admitted") {
|
|
152
|
+
if (isQueuedPayload(record.payload)) state.payloads.set(record.workId, record.payload);
|
|
153
|
+
else emit(ctx, { kind: "issue", issue: queueIssue(record, "cqrs-queue-malformed-payload") });
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
if (record.kind !== "work-claimed") return;
|
|
157
|
+
if (opts.workerId !== void 0 && record.workerId !== opts.workerId) return;
|
|
158
|
+
const payload = state.payloads.get(record.workId);
|
|
159
|
+
if (payload === void 0) {
|
|
160
|
+
emit(ctx, { kind: "issue", issue: queueIssue(record, "cqrs-claim-without-payload") });
|
|
161
|
+
emit(ctx, {
|
|
162
|
+
kind: "command",
|
|
163
|
+
command: {
|
|
164
|
+
kind: "release",
|
|
165
|
+
commandId: `cqrs:${record.workId}:${record.leaseId}:${record.attempt}:release-no-payload`,
|
|
166
|
+
workId: record.workId,
|
|
167
|
+
leaseId: record.leaseId,
|
|
168
|
+
attempt: record.attempt,
|
|
169
|
+
workerId: record.workerId,
|
|
170
|
+
reason: "cqrs-claim-without-payload"
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
const attempt = {
|
|
176
|
+
kind: "cqrs-work-queue-attempt",
|
|
177
|
+
workId: record.workId,
|
|
178
|
+
leaseId: record.leaseId,
|
|
179
|
+
queueAttempt: record.attempt,
|
|
180
|
+
workerId: record.workerId,
|
|
181
|
+
command: payload.command,
|
|
182
|
+
payload,
|
|
183
|
+
sourceRefs: [...payload.sourceRefs ?? [], `work-queue-record:${record.recordSeq}`]
|
|
184
|
+
};
|
|
185
|
+
pushActiveClaim(state, payload.command.id, attempt);
|
|
186
|
+
emit(ctx, { kind: "attempt", attempt });
|
|
187
|
+
emit(ctx, { kind: "dispatch", command: payload.command });
|
|
188
|
+
}
|
|
189
|
+
function reduceStatus(ctx, state, status, opts) {
|
|
190
|
+
if (status.commandId === void 0) return;
|
|
191
|
+
const attempt = shiftActiveClaim(state, status.commandId);
|
|
192
|
+
if (attempt === void 0) {
|
|
193
|
+
emit(ctx, {
|
|
194
|
+
kind: "issue",
|
|
195
|
+
issue: {
|
|
196
|
+
kind: "issue",
|
|
197
|
+
code: "cqrs-status-without-active-queue-claim",
|
|
198
|
+
message: "CQRS workQueue recipe observed a CQRS status without an active queue claim; no queue disposition was emitted",
|
|
199
|
+
severity: "error",
|
|
200
|
+
source: "cqrs.workQueue",
|
|
201
|
+
refs: [`cqrs-command:${status.commandId}`],
|
|
202
|
+
details: status
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
const claimKey = queueClaimKey(attempt);
|
|
208
|
+
if (state.terminalClaims.has(claimKey)) {
|
|
209
|
+
emit(ctx, {
|
|
210
|
+
kind: "issue",
|
|
211
|
+
issue: {
|
|
212
|
+
kind: "issue",
|
|
213
|
+
code: "cqrs-duplicate-terminal-outcome-for-queue-claim",
|
|
214
|
+
message: `CQRS queue claim '${claimKey}' already produced a terminal queue disposition`,
|
|
215
|
+
refs: [`cqrs-command:${status.commandId}`, `work-queue-work:${attempt.workId}`]
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
state.terminalClaims.add(claimKey);
|
|
221
|
+
const command = cqrsWorkQueueDispositionCommand(
|
|
222
|
+
attempt,
|
|
223
|
+
status.state === "accepted" ? { kind: "accepted", status } : { kind: "rejected", status, error: state.errors.get(status.commandId) },
|
|
224
|
+
opts.policy
|
|
225
|
+
);
|
|
226
|
+
emit(ctx, { kind: "command", command });
|
|
227
|
+
}
|
|
228
|
+
function emptyState() {
|
|
229
|
+
return {
|
|
230
|
+
payloads: /* @__PURE__ */ new Map(),
|
|
231
|
+
activeClaims: /* @__PURE__ */ new Map(),
|
|
232
|
+
errors: /* @__PURE__ */ new Map(),
|
|
233
|
+
terminalClaims: /* @__PURE__ */ new Set()
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
function pushActiveClaim(state, commandId, attempt) {
|
|
237
|
+
const claims = state.activeClaims.get(commandId) ?? [];
|
|
238
|
+
state.activeClaims.set(commandId, [...claims, attempt]);
|
|
239
|
+
}
|
|
240
|
+
function shiftActiveClaim(state, commandId) {
|
|
241
|
+
const claims = state.activeClaims.get(commandId);
|
|
242
|
+
if (claims === void 0 || claims.length === 0) return void 0;
|
|
243
|
+
const [first, ...rest] = claims;
|
|
244
|
+
if (rest.length === 0) state.activeClaims.delete(commandId);
|
|
245
|
+
else state.activeClaims.set(commandId, rest);
|
|
246
|
+
return first;
|
|
247
|
+
}
|
|
248
|
+
function queueClaimKey(attempt) {
|
|
249
|
+
return `${attempt.workId}:${attempt.leaseId}:${attempt.queueAttempt}`;
|
|
250
|
+
}
|
|
251
|
+
function dispositionCommandId(attempt, kind) {
|
|
252
|
+
return `${attempt.command.id}:${attempt.workId}:${attempt.leaseId}:${attempt.queueAttempt}:cqrs-queue-${kind}`;
|
|
253
|
+
}
|
|
254
|
+
function project(graph, runtime, name, factory, pick) {
|
|
255
|
+
return graph.node(
|
|
256
|
+
[runtime],
|
|
257
|
+
(ctx) => {
|
|
258
|
+
for (const fact of depBatch(ctx, 0) ?? []) {
|
|
259
|
+
const value = pick(fact);
|
|
260
|
+
if (value !== void 0) ctx.down([["DATA", value]]);
|
|
261
|
+
}
|
|
262
|
+
},
|
|
263
|
+
{ name, factory, partial: true, completeWhenDepsComplete: false, errorWhenDepsError: false }
|
|
264
|
+
);
|
|
265
|
+
}
|
|
266
|
+
function emit(ctx, fact) {
|
|
267
|
+
ctx.down([["DATA", fact]]);
|
|
268
|
+
}
|
|
269
|
+
function isQueuedPayload(value) {
|
|
270
|
+
if (!isObjectRecord(value) || value.kind !== "cqrs-queued-command") return false;
|
|
271
|
+
return isObjectRecord(value.command) && typeof value.command.id === "string";
|
|
272
|
+
}
|
|
273
|
+
function queueIssue(record, code) {
|
|
274
|
+
return {
|
|
275
|
+
kind: "issue",
|
|
276
|
+
code,
|
|
277
|
+
message: `CQRS workQueue recipe could not map record '${record.kind}'`,
|
|
278
|
+
severity: "error",
|
|
279
|
+
source: "cqrs.workQueue",
|
|
280
|
+
refs: record.workId === void 0 ? void 0 : [`work-queue-work:${record.workId}`],
|
|
281
|
+
details: record
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
function isObjectRecord(value) {
|
|
285
|
+
return typeof value === "object" && value !== null;
|
|
286
|
+
}
|
|
287
|
+
export {
|
|
288
|
+
cqrsSubmitCommand,
|
|
289
|
+
cqrsWorkQueueDispositionCommand,
|
|
290
|
+
cqrsWorkQueueRecipe
|
|
291
|
+
};
|
|
292
|
+
//# sourceMappingURL=work-queue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/cqrs/work-queue.ts"],"sourcesContent":["/**\n * Optional CQRS-over-workQueue recipe (D350/D352/D353).\n *\n * The CQRS core remains synchronous graph-visible command/event truth. This\n * recipe only maps queue claims to CQRS command facts and maps visible CQRS\n * outcomes back to generic workQueue disposition commands.\n */\n\nimport type { CqrsCommand, CqrsError, CqrsErrorCode, CqrsStatus } from \"../cqrs/index.js\";\nimport { type Ctx, depBatch } from \"../ctx/types.js\";\nimport type { DataIssue } from \"../data/index.js\";\nimport type { Graph } from \"../graph/graph.js\";\nimport type { Node } from \"../node/node.js\";\nimport type { WorkQueueCommand, WorkQueueRecord } from \"../work-queue/index.js\";\n\nexport interface CqrsQueuedCommandPayload<TCommand = unknown> {\n\treadonly kind: \"cqrs-queued-command\";\n\treadonly command: CqrsCommand<TCommand>;\n\treadonly idempotencyKey?: string;\n\treadonly sourceRefs?: readonly string[];\n\treadonly policyRefs?: readonly string[];\n\treadonly actorRefs?: readonly string[];\n\treadonly auditRefs?: readonly string[];\n\treadonly metadata?: Record<string, unknown>;\n}\n\nexport interface CqrsWorkQueueAttempt<TCommand = unknown> {\n\treadonly kind: \"cqrs-work-queue-attempt\";\n\treadonly workId: string;\n\treadonly leaseId: string;\n\treadonly queueAttempt: number;\n\treadonly workerId: string;\n\treadonly command: CqrsCommand<TCommand>;\n\treadonly payload: CqrsQueuedCommandPayload<TCommand>;\n\treadonly sourceRefs?: readonly string[];\n}\n\nexport type CqrsWorkQueueAcceptedOutcome = {\n\treadonly kind: \"accepted\";\n\treadonly status: CqrsStatus;\n};\n\nexport type CqrsWorkQueueRejectedOutcome = {\n\treadonly kind: \"rejected\";\n\treadonly status: CqrsStatus;\n\treadonly error?: CqrsError;\n};\n\nexport type CqrsWorkQueueReleaseOutcome = {\n\treadonly kind: \"release\";\n\treadonly reason?: string;\n};\n\nexport type CqrsWorkQueueOutcome =\n\t| CqrsWorkQueueAcceptedOutcome\n\t| CqrsWorkQueueRejectedOutcome\n\t| CqrsWorkQueueReleaseOutcome;\n\nexport interface CqrsWorkQueuePolicy {\n\t/**\n\t * D352: handler-threw and clock-threw fail retryable:true by default. A\n\t * policy may classify a known deterministic handler failure as nonretryable.\n\t */\n\treadonly retryableFailure?: (\n\t\terrorCode: CqrsErrorCode,\n\t\toutcome: CqrsWorkQueueRejectedOutcome,\n\t) => boolean;\n\treadonly releaseReason?: (attempt: CqrsWorkQueueAttempt) => string | undefined;\n}\n\nexport interface CqrsWorkQueueRecipeOptions<TCommand = unknown> {\n\treadonly name?: string;\n\treadonly records: Node<WorkQueueRecord<CqrsQueuedCommandPayload<TCommand>>>;\n\treadonly status: Node<CqrsStatus>;\n\treadonly errors?: Node<CqrsError>;\n\treadonly workerId?: string;\n\treadonly policy?: CqrsWorkQueuePolicy;\n}\n\nexport interface CqrsWorkQueueRecipeBundle<TCommand = unknown> {\n\treadonly attempts: Node<CqrsWorkQueueAttempt<TCommand>>;\n\treadonly dispatches: Node<CqrsCommand<TCommand>>;\n\treadonly commands: Node<WorkQueueCommand<CqrsQueuedCommandPayload<TCommand>>>;\n\treadonly issues: Node<DataIssue>;\n}\n\ntype CqrsQueueFact<TCommand> =\n\t| { readonly kind: \"attempt\"; readonly attempt: CqrsWorkQueueAttempt<TCommand> }\n\t| { readonly kind: \"dispatch\"; readonly command: CqrsCommand<TCommand> }\n\t| {\n\t\t\treadonly kind: \"command\";\n\t\t\treadonly command: WorkQueueCommand<CqrsQueuedCommandPayload<TCommand>>;\n\t }\n\t| { readonly kind: \"issue\"; readonly issue: DataIssue };\n\ninterface CqrsQueueState<TCommand> {\n\treadonly payloads: Map<string, CqrsQueuedCommandPayload<TCommand>>;\n\treadonly activeClaims: Map<string, CqrsWorkQueueAttempt<TCommand>[]>;\n\treadonly errors: Map<string, CqrsError>;\n\treadonly terminalClaims: Set<string>;\n}\n\n/** Build the optional D350/D352 CQRS workQueue recipe. */\nexport function cqrsWorkQueueRecipe<TCommand = unknown>(\n\tgraph: Graph,\n\topts: CqrsWorkQueueRecipeOptions<TCommand>,\n): CqrsWorkQueueRecipeBundle<TCommand> {\n\tconst name = opts.name ?? \"cqrsWorkQueue\";\n\tconst deps =\n\t\topts.errors === undefined\n\t\t\t? [opts.records, opts.status]\n\t\t\t: [opts.records, opts.status, opts.errors];\n\tconst runtime = graph.node<CqrsQueueFact<TCommand>>(\n\t\tdeps,\n\t\t(ctx) => {\n\t\t\tconst state = ctx.state.get<CqrsQueueState<TCommand>>() ?? emptyState<TCommand>();\n\t\t\tfor (const raw of depBatch(ctx, 0) ?? []) {\n\t\t\t\treduceRecord(ctx, state, raw as WorkQueueRecord<CqrsQueuedCommandPayload<TCommand>>, opts);\n\t\t\t}\n\t\t\tif (opts.errors !== undefined) {\n\t\t\t\tfor (const raw of depBatch(ctx, 2) ?? []) {\n\t\t\t\t\tconst error = raw as CqrsError;\n\t\t\t\t\tif (error.commandId !== undefined) state.errors.set(error.commandId, error);\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (const raw of depBatch(ctx, 1) ?? []) {\n\t\t\t\treduceStatus(ctx, state, raw as CqrsStatus, opts);\n\t\t\t}\n\t\t\tctx.state.set(state);\n\t\t},\n\t\t{\n\t\t\tname: `${name}/runtime`,\n\t\t\tfactory: \"cqrsWorkQueueRuntime\",\n\t\t\tpartial: true,\n\t\t\tcompleteWhenDepsComplete: false,\n\t\t\terrorWhenDepsError: false,\n\t\t},\n\t);\n\treturn {\n\t\tattempts: project(graph, runtime, `${name}/attempts`, \"cqrsWorkQueueAttempts\", (fact) =>\n\t\t\tfact.kind === \"attempt\" ? fact.attempt : undefined,\n\t\t),\n\t\tdispatches: project(graph, runtime, `${name}/dispatches`, \"cqrsWorkQueueDispatches\", (fact) =>\n\t\t\tfact.kind === \"dispatch\" ? fact.command : undefined,\n\t\t),\n\t\tcommands: project(graph, runtime, `${name}/commands`, \"cqrsWorkQueueCommands\", (fact) =>\n\t\t\tfact.kind === \"command\" ? fact.command : undefined,\n\t\t),\n\t\tissues: project(graph, runtime, `${name}/issues`, \"cqrsWorkQueueIssues\", (fact) =>\n\t\t\tfact.kind === \"issue\" ? fact.issue : undefined,\n\t\t),\n\t};\n}\n\nexport function cqrsSubmitCommand<TCommand>(\n\tcommand: CqrsCommand<TCommand>,\n\topts: {\n\t\treadonly workId?: string;\n\t\treadonly commandId?: string;\n\t\treadonly idempotencyKey?: string;\n\t\treadonly sourceRefs?: readonly string[];\n\t\treadonly policyRefs?: readonly string[];\n\t\treadonly actorRefs?: readonly string[];\n\t\treadonly auditRefs?: readonly string[];\n\t\treadonly metadata?: Record<string, unknown>;\n\t} = {},\n): WorkQueueCommand<CqrsQueuedCommandPayload<TCommand>> {\n\tconst payload: CqrsQueuedCommandPayload<TCommand> = {\n\t\tkind: \"cqrs-queued-command\",\n\t\tcommand,\n\t\tidempotencyKey: opts.idempotencyKey ?? command.id,\n\t\tsourceRefs: opts.sourceRefs,\n\t\tpolicyRefs: opts.policyRefs,\n\t\tactorRefs: opts.actorRefs,\n\t\tauditRefs: opts.auditRefs,\n\t\tmetadata: opts.metadata,\n\t};\n\treturn {\n\t\tkind: \"submit\",\n\t\tcommandId: opts.commandId ?? `${command.id}:cqrs-work-queue-submit`,\n\t\tworkId: opts.workId ?? `cqrs:${command.id}`,\n\t\tpayload,\n\t\tidempotencyKey: opts.idempotencyKey ?? command.id,\n\t\tsourceRefs: opts.sourceRefs,\n\t\tpolicyRefs: opts.policyRefs,\n\t\tactorRefs: opts.actorRefs,\n\t\tauditRefs: opts.auditRefs,\n\t};\n}\n\nexport function cqrsWorkQueueDispositionCommand<TCommand>(\n\tattempt: CqrsWorkQueueAttempt<TCommand>,\n\toutcome: CqrsWorkQueueOutcome,\n\tpolicy?: CqrsWorkQueuePolicy,\n): WorkQueueCommand<CqrsQueuedCommandPayload<TCommand>> {\n\tif (outcome.kind === \"release\") {\n\t\treturn {\n\t\t\tkind: \"release\",\n\t\t\tcommandId: dispositionCommandId(attempt, \"release\"),\n\t\t\tworkId: attempt.workId,\n\t\t\tleaseId: attempt.leaseId,\n\t\t\tattempt: attempt.queueAttempt,\n\t\t\tworkerId: attempt.workerId,\n\t\t\treason: outcome.reason ?? policy?.releaseReason?.(attempt),\n\t\t};\n\t}\n\tif (outcome.kind === \"accepted\") {\n\t\treturn completeCommand(attempt, {\n\t\t\tkind: \"cqrs-accepted-result\",\n\t\t\tcommandId: outcome.status.commandId,\n\t\t\tcommandType: outcome.status.commandType,\n\t\t\teventCount: outcome.status.eventCount,\n\t\t\tcursor: outcome.status.cursor,\n\t\t});\n\t}\n\tconst code = outcome.status.errorCode;\n\tif (code === \"handler-threw\" || code === \"clock-threw\" || code === undefined) {\n\t\treturn {\n\t\t\tkind: \"fail\",\n\t\t\tcommandId: dispositionCommandId(attempt, \"fail\"),\n\t\t\tworkId: attempt.workId,\n\t\t\tleaseId: attempt.leaseId,\n\t\t\tattempt: attempt.queueAttempt,\n\t\t\tworkerId: attempt.workerId,\n\t\t\terror: outcome.error ?? {\n\t\t\t\tkind: \"issue\",\n\t\t\t\tcode: code ?? \"cqrs-outcome-ambiguous\",\n\t\t\t\tmessage: \"CQRS rejected without deterministic rejection evidence\",\n\t\t\t},\n\t\t\tretryable: code === undefined ? true : (policy?.retryableFailure?.(code, outcome) ?? true),\n\t\t};\n\t}\n\treturn completeCommand(attempt, {\n\t\tkind: \"cqrs-rejected-result\",\n\t\tcommandId: outcome.status.commandId,\n\t\tcommandType: outcome.status.commandType,\n\t\terrorCode: code,\n\t\terror: outcome.error,\n\t\teventCount: outcome.status.eventCount,\n\t\tcursor: outcome.status.cursor,\n\t});\n}\n\nfunction completeCommand<TCommand>(\n\tattempt: CqrsWorkQueueAttempt<TCommand>,\n\tresult: unknown,\n): WorkQueueCommand<CqrsQueuedCommandPayload<TCommand>> {\n\treturn {\n\t\tkind: \"complete\",\n\t\tcommandId: dispositionCommandId(attempt, \"complete\"),\n\t\tworkId: attempt.workId,\n\t\tleaseId: attempt.leaseId,\n\t\tattempt: attempt.queueAttempt,\n\t\tworkerId: attempt.workerId,\n\t\tresult,\n\t};\n}\n\nfunction reduceRecord<TCommand>(\n\tctx: Ctx,\n\tstate: CqrsQueueState<TCommand>,\n\trecord: WorkQueueRecord<CqrsQueuedCommandPayload<TCommand>>,\n\topts: CqrsWorkQueueRecipeOptions<TCommand>,\n): void {\n\tif (record.kind === \"work-admitted\") {\n\t\tif (isQueuedPayload(record.payload)) state.payloads.set(record.workId, record.payload);\n\t\telse emit(ctx, { kind: \"issue\", issue: queueIssue(record, \"cqrs-queue-malformed-payload\") });\n\t\treturn;\n\t}\n\tif (record.kind !== \"work-claimed\") return;\n\tif (opts.workerId !== undefined && record.workerId !== opts.workerId) return;\n\tconst payload = state.payloads.get(record.workId);\n\tif (payload === undefined) {\n\t\temit(ctx, { kind: \"issue\", issue: queueIssue(record, \"cqrs-claim-without-payload\") });\n\t\temit(ctx, {\n\t\t\tkind: \"command\",\n\t\t\tcommand: {\n\t\t\t\tkind: \"release\",\n\t\t\t\tcommandId: `cqrs:${record.workId}:${record.leaseId}:${record.attempt}:release-no-payload`,\n\t\t\t\tworkId: record.workId,\n\t\t\t\tleaseId: record.leaseId,\n\t\t\t\tattempt: record.attempt,\n\t\t\t\tworkerId: record.workerId,\n\t\t\t\treason: \"cqrs-claim-without-payload\",\n\t\t\t},\n\t\t});\n\t\treturn;\n\t}\n\tconst attempt: CqrsWorkQueueAttempt<TCommand> = {\n\t\tkind: \"cqrs-work-queue-attempt\",\n\t\tworkId: record.workId,\n\t\tleaseId: record.leaseId,\n\t\tqueueAttempt: record.attempt,\n\t\tworkerId: record.workerId,\n\t\tcommand: payload.command,\n\t\tpayload,\n\t\tsourceRefs: [...(payload.sourceRefs ?? []), `work-queue-record:${record.recordSeq}`],\n\t};\n\tpushActiveClaim(state, payload.command.id, attempt);\n\temit(ctx, { kind: \"attempt\", attempt });\n\temit(ctx, { kind: \"dispatch\", command: payload.command });\n}\n\nfunction reduceStatus<TCommand>(\n\tctx: Ctx,\n\tstate: CqrsQueueState<TCommand>,\n\tstatus: CqrsStatus,\n\topts: CqrsWorkQueueRecipeOptions<TCommand>,\n): void {\n\tif (status.commandId === undefined) return;\n\tconst attempt = shiftActiveClaim(state, status.commandId);\n\tif (attempt === undefined) {\n\t\temit(ctx, {\n\t\t\tkind: \"issue\",\n\t\t\tissue: {\n\t\t\t\tkind: \"issue\",\n\t\t\t\tcode: \"cqrs-status-without-active-queue-claim\",\n\t\t\t\tmessage:\n\t\t\t\t\t\"CQRS workQueue recipe observed a CQRS status without an active queue claim; no queue disposition was emitted\",\n\t\t\t\tseverity: \"error\",\n\t\t\t\tsource: \"cqrs.workQueue\",\n\t\t\t\trefs: [`cqrs-command:${status.commandId}`],\n\t\t\t\tdetails: status,\n\t\t\t},\n\t\t});\n\t\treturn;\n\t}\n\tconst claimKey = queueClaimKey(attempt);\n\tif (state.terminalClaims.has(claimKey)) {\n\t\temit(ctx, {\n\t\t\tkind: \"issue\",\n\t\t\tissue: {\n\t\t\t\tkind: \"issue\",\n\t\t\t\tcode: \"cqrs-duplicate-terminal-outcome-for-queue-claim\",\n\t\t\t\tmessage: `CQRS queue claim '${claimKey}' already produced a terminal queue disposition`,\n\t\t\t\trefs: [`cqrs-command:${status.commandId}`, `work-queue-work:${attempt.workId}`],\n\t\t\t},\n\t\t});\n\t\treturn;\n\t}\n\tstate.terminalClaims.add(claimKey);\n\tconst command = cqrsWorkQueueDispositionCommand(\n\t\tattempt,\n\t\tstatus.state === \"accepted\"\n\t\t\t? { kind: \"accepted\", status }\n\t\t\t: { kind: \"rejected\", status, error: state.errors.get(status.commandId) },\n\t\topts.policy,\n\t);\n\temit(ctx, { kind: \"command\", command });\n}\n\nfunction emptyState<TCommand>(): CqrsQueueState<TCommand> {\n\treturn {\n\t\tpayloads: new Map(),\n\t\tactiveClaims: new Map(),\n\t\terrors: new Map(),\n\t\tterminalClaims: new Set(),\n\t};\n}\n\nfunction pushActiveClaim<TCommand>(\n\tstate: CqrsQueueState<TCommand>,\n\tcommandId: string,\n\tattempt: CqrsWorkQueueAttempt<TCommand>,\n): void {\n\tconst claims = state.activeClaims.get(commandId) ?? [];\n\tstate.activeClaims.set(commandId, [...claims, attempt]);\n}\n\nfunction shiftActiveClaim<TCommand>(\n\tstate: CqrsQueueState<TCommand>,\n\tcommandId: string,\n): CqrsWorkQueueAttempt<TCommand> | undefined {\n\tconst claims = state.activeClaims.get(commandId);\n\tif (claims === undefined || claims.length === 0) return undefined;\n\tconst [first, ...rest] = claims;\n\tif (rest.length === 0) state.activeClaims.delete(commandId);\n\telse state.activeClaims.set(commandId, rest);\n\treturn first;\n}\n\nfunction queueClaimKey(attempt: CqrsWorkQueueAttempt): string {\n\treturn `${attempt.workId}:${attempt.leaseId}:${attempt.queueAttempt}`;\n}\n\nfunction dispositionCommandId(attempt: CqrsWorkQueueAttempt, kind: string): string {\n\treturn `${attempt.command.id}:${attempt.workId}:${attempt.leaseId}:${attempt.queueAttempt}:cqrs-queue-${kind}`;\n}\n\nfunction project<T, TCommand>(\n\tgraph: Graph,\n\truntime: Node<CqrsQueueFact<TCommand>>,\n\tname: string,\n\tfactory: string,\n\tpick: (fact: CqrsQueueFact<TCommand>) => T | undefined,\n): Node<T> {\n\treturn graph.node<T>(\n\t\t[runtime],\n\t\t(ctx) => {\n\t\t\tfor (const fact of depBatch(ctx, 0) ?? []) {\n\t\t\t\tconst value = pick(fact as CqrsQueueFact<TCommand>);\n\t\t\t\tif (value !== undefined) ctx.down([[\"DATA\", value]]);\n\t\t\t}\n\t\t},\n\t\t{ name, factory, partial: true, completeWhenDepsComplete: false, errorWhenDepsError: false },\n\t);\n}\n\nfunction emit<TCommand>(ctx: Ctx, fact: CqrsQueueFact<TCommand>): void {\n\tctx.down([[\"DATA\", fact]]);\n}\n\nfunction isQueuedPayload<TCommand>(value: unknown): value is CqrsQueuedCommandPayload<TCommand> {\n\tif (!isObjectRecord(value) || value.kind !== \"cqrs-queued-command\") return false;\n\treturn isObjectRecord(value.command) && typeof value.command.id === \"string\";\n}\n\nfunction queueIssue(record: WorkQueueRecord<unknown>, code: string): DataIssue {\n\treturn {\n\t\tkind: \"issue\",\n\t\tcode,\n\t\tmessage: `CQRS workQueue recipe could not map record '${record.kind}'`,\n\t\tseverity: \"error\",\n\t\tsource: \"cqrs.workQueue\",\n\t\trefs: record.workId === undefined ? undefined : [`work-queue-work:${record.workId}`],\n\t\tdetails: record,\n\t};\n}\n\nfunction isObjectRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null;\n}\n"],"mappings":";;;;;;;AAuGO,SAAS,oBACf,OACA,MACsC;AACtC,QAAM,OAAO,KAAK,QAAQ;AAC1B,QAAM,OACL,KAAK,WAAW,SACb,CAAC,KAAK,SAAS,KAAK,MAAM,IAC1B,CAAC,KAAK,SAAS,KAAK,QAAQ,KAAK,MAAM;AAC3C,QAAM,UAAU,MAAM;AAAA,IACrB;AAAA,IACA,CAAC,QAAQ;AACR,YAAM,QAAQ,IAAI,MAAM,IAA8B,KAAK,WAAqB;AAChF,iBAAW,OAAO,SAAS,KAAK,CAAC,KAAK,CAAC,GAAG;AAC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AAQ,YAAY,eAAe,IAAI;AAC7G;AAEA,SAAS,QACR,OACA,SACA,MACA,SACA,MACU;AACV,SAAO,MAAM;AAAA,IACZ,CAAC,OAAO;AAAA,IACR,CAAC,QAAQ;AACR,iBAAW,QAAQ,SAAS,KAAK,CAAC,KAAK,CAAC,GAAG;AAC1C,cAAM,QAAQ,KAAK,IAA+B;AAClD,YAAI,UAAU,OAAW,KAAI,KAAK,CAAC,CAAC,QAAQ,KAAK,CAAC,CAAC;AAAA,MACpD;AAAA,IACD;AAAA,IACA,EAAE,MAAM,SAAS,SAAS,MAAM,0BAA0B,OAAO,oBAAoB,MAAM;AAAA,EAC5F;AACD;AAEA,SAAS,KAAe,KAAU,MAAqC;AACtE,MAAI,KAAK,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC;AAC1B;AAEA,SAAS,gBAA0B,OAA6D;AAC/F,MAAI,CAAC,eAAe,KAAK,KAAK,MAAM,SAAS,sBAAuB,QAAO;AAC3E,SAAO,eAAe,MAAM,OAAO,KAAK,OAAO,MAAM,QAAQ,OAAO;AACrE;AAEA,SAAS,WAAW,QAAkC,MAAyB;AAC9E,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA,SAAS,+CAA+C,OAAO,IAAI;AAAA,IACnE,UAAU;AAAA,IACV,QAAQ;AAAA,IACR,MAAM,OAAO,WAAW,SAAY,SAAY,CAAC,mBAAmB,OAAO,MAAM,EAAE;AAAA,IACnF,SAAS;AAAA,EACV;AACD;AAEA,SAAS,eAAe,OAAkD;AACzE,SAAO,OAAO,UAAU,YAAY,UAAU;AAC/C;","names":[]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
|
|
16
|
+
// src/data/index.ts
|
|
17
|
+
var data_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(data_exports);
|
|
19
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/data/index.ts"],"sourcesContent":["/**\n * Passive DATA-level result vocabulary (D184).\n *\n * These shapes are ordinary payload facts. They are not protocol ERROR messages and\n * carry no wave terminal or lifecycle semantics.\n */\n\nexport interface DataIssue {\n\treadonly kind: \"issue\";\n\treadonly code: string;\n\treadonly message: string;\n\treadonly severity?: \"info\" | \"warning\" | \"error\";\n\treadonly source?: string;\n\treadonly subjectId?: string;\n\treadonly correlationId?: string;\n\treadonly causationId?: string;\n\treadonly path?: readonly (string | number)[];\n\treadonly refs?: readonly string[];\n\treadonly retryable?: boolean;\n\treadonly details?: unknown;\n\treadonly metadata?: Record<string, unknown>;\n}\n\nexport interface DataOk<T> {\n\treadonly kind: \"ok\";\n\treadonly value: T;\n\treadonly issues?: readonly DataIssue[];\n\treadonly metadata?: Record<string, unknown>;\n}\n\nexport interface DataError<E extends DataIssue = DataIssue> {\n\treadonly kind: \"error\";\n\treadonly error: E;\n\treadonly issues?: readonly DataIssue[];\n\treadonly metadata?: Record<string, unknown>;\n}\n\nexport type DataResult<T, E extends DataIssue = DataIssue> = DataOk<T> | DataError<E>;\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|