@graphrefly/ts 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions-types-CSC3NMDl.d.ts +657 -0
- package/dist/actions-types-wl9Mgkmr.d.cts +657 -0
- package/dist/adapters/index.cjs +5157 -2951
- package/dist/adapters/index.cjs.map +1 -1
- package/dist/adapters/index.d.cts +207 -70
- package/dist/adapters/index.d.ts +207 -70
- package/dist/adapters/index.js +3738 -1688
- package/dist/adapters/index.js.map +1 -1
- package/dist/adapters/nestjs/microservices.cjs +841 -0
- package/dist/adapters/nestjs/microservices.cjs.map +1 -0
- package/dist/adapters/nestjs/microservices.d.cts +45 -0
- package/dist/adapters/nestjs/microservices.d.ts +45 -0
- package/dist/adapters/nestjs/microservices.js +206 -0
- package/dist/adapters/nestjs/microservices.js.map +1 -0
- package/dist/adapters/nestjs/native.cjs +1391 -0
- package/dist/adapters/nestjs/native.cjs.map +1 -0
- package/dist/adapters/nestjs/native.d.cts +111 -0
- package/dist/adapters/nestjs/native.d.ts +111 -0
- package/dist/adapters/nestjs/native.js +577 -0
- package/dist/adapters/nestjs/native.js.map +1 -0
- package/dist/adapters/nestjs/websockets.cjs +924 -0
- package/dist/adapters/nestjs/websockets.cjs.map +1 -0
- package/dist/adapters/nestjs/websockets.d.cts +47 -0
- package/dist/adapters/nestjs/websockets.d.ts +47 -0
- package/dist/adapters/nestjs/websockets.js +286 -0
- package/dist/adapters/nestjs/websockets.js.map +1 -0
- package/dist/adapters/nestjs.cjs +1085 -0
- package/dist/adapters/nestjs.cjs.map +1 -0
- package/dist/adapters/nestjs.d.cts +385 -0
- package/dist/adapters/nestjs.d.ts +385 -0
- package/dist/adapters/nestjs.js +112 -0
- package/dist/adapters/nestjs.js.map +1 -0
- package/dist/adapters/observe-storage.d.cts +3 -3
- package/dist/adapters/observe-storage.d.ts +3 -3
- package/dist/adapters/observe-storage.js +4 -4
- package/dist/adapters/react.cjs.map +1 -1
- package/dist/adapters/react.d.cts +2 -2
- package/dist/adapters/react.d.ts +2 -2
- package/dist/adapters/react.js +1 -1
- package/dist/adapters/solid.cjs.map +1 -1
- package/dist/adapters/solid.d.cts +2 -2
- package/dist/adapters/solid.d.ts +2 -2
- package/dist/adapters/solid.js +1 -1
- package/dist/adapters/svelte.cjs.map +1 -1
- package/dist/adapters/svelte.d.cts +2 -2
- package/dist/adapters/svelte.d.ts +2 -2
- package/dist/adapters/svelte.js +1 -1
- package/dist/adapters/vue.cjs.map +1 -1
- package/dist/adapters/vue.d.cts +2 -2
- package/dist/adapters/vue.d.ts +2 -2
- package/dist/adapters/vue.js +1 -1
- package/dist/{agent-runtime-DZTJ3C-p.d.cts → agent-runtime-types-core-CaXfKNtY.d.cts} +171 -320
- package/dist/{agent-runtime-BesGDZcB.d.ts → agent-runtime-types-core-hU299uIC.d.ts} +171 -320
- package/dist/agent-runtime-types-tool-BEpSINol.d.ts +695 -0
- package/dist/agent-runtime-types-tool-DninPEzk.d.cts +695 -0
- package/dist/agentic-memory-retention-BmGX368S.d.ts +14 -0
- package/dist/agentic-memory-retention-Ih1qhX9Z.d.cts +14 -0
- package/dist/{agentic-memory-BmRCvh0d.d.ts → agentic-memory-types-CVSUS6XR.d.ts} +13 -57
- package/dist/{agentic-memory-DfuVZ-lY.d.cts → agentic-memory-types-FnnYlVUs.d.cts} +13 -57
- package/dist/{capability-admission-g0mn9hpq.d.ts → capability-admission-BW2CziT6.d.ts} +3 -3
- package/dist/{capability-admission-B0BzqAm5.d.cts → capability-admission-lwSecxXs.d.cts} +3 -3
- package/dist/chunk-2KUAG2GZ.js +9693 -0
- package/dist/chunk-2KUAG2GZ.js.map +1 -0
- package/dist/chunk-2NJP6GO4.js +1320 -0
- package/dist/chunk-2NJP6GO4.js.map +1 -0
- package/dist/{chunk-YDSIVHRR.js → chunk-4NWSNI4K.js} +1598 -1584
- package/dist/chunk-4NWSNI4K.js.map +1 -0
- package/dist/{chunk-Z2ANQ6JW.js → chunk-4Q77MMJY.js} +2 -2
- package/dist/chunk-6E76H4OU.js +132 -0
- package/dist/chunk-6E76H4OU.js.map +1 -0
- package/dist/chunk-7GOTIIQ7.js +819 -0
- package/dist/chunk-7GOTIIQ7.js.map +1 -0
- package/dist/{chunk-IXZBUWSP.js → chunk-7HZRJMN6.js} +2 -2
- package/dist/{chunk-SS2A464I.js → chunk-CJIFGJQG.js} +3 -3
- package/dist/{chunk-V7CIJE4B.js → chunk-CX6B6PO2.js} +92 -9
- package/dist/chunk-CX6B6PO2.js.map +1 -0
- package/dist/{chunk-FBUU43PM.js → chunk-E4QCH32M.js} +448 -446
- package/dist/chunk-E4QCH32M.js.map +1 -0
- package/dist/{chunk-HKK2JD7Z.js → chunk-ECURQ3HD.js} +12 -125
- package/dist/chunk-ECURQ3HD.js.map +1 -0
- package/dist/{chunk-3JR3EDB2.js → chunk-EOKT4QFF.js} +121 -115
- package/dist/chunk-EOKT4QFF.js.map +1 -0
- package/dist/{chunk-K3FXTC3I.js → chunk-HJACH5PU.js} +3 -3
- package/dist/{chunk-GTPCOEOZ.js → chunk-IDMLXLLG.js} +3 -3
- package/dist/{chunk-DKP56CSW.js → chunk-JKAYLDQV.js} +2 -2
- package/dist/{chunk-4VLAQHZI.js → chunk-K7FB3JTD.js} +17 -1
- package/dist/chunk-K7FB3JTD.js.map +1 -0
- package/dist/{chunk-H75VXTGT.js → chunk-L6LDXRWE.js} +3 -3
- package/dist/{chunk-H75VXTGT.js.map → chunk-L6LDXRWE.js.map} +1 -1
- package/dist/{chunk-YXMZ2N6J.js → chunk-M7J6Z4IJ.js} +1071 -1025
- package/dist/chunk-M7J6Z4IJ.js.map +1 -0
- package/dist/chunk-MQEQMS7B.js +1009 -0
- package/dist/chunk-MQEQMS7B.js.map +1 -0
- package/dist/chunk-MTELVIYR.js +1421 -0
- package/dist/chunk-MTELVIYR.js.map +1 -0
- package/dist/{chunk-QFY4AFY4.js → chunk-PVC7WDKI.js} +58 -52
- package/dist/chunk-PVC7WDKI.js.map +1 -0
- package/dist/{chunk-VTHLCFN4.js → chunk-RAHNUYA5.js} +2 -2
- package/dist/{chunk-XKXWK2KP.js → chunk-SHZDP2MQ.js} +1157 -1021
- package/dist/chunk-SHZDP2MQ.js.map +1 -0
- package/dist/{chunk-CZNV3VXM.js → chunk-SIDJO2T4.js} +11 -11
- package/dist/chunk-STXRMPW4.js +4131 -0
- package/dist/chunk-STXRMPW4.js.map +1 -0
- package/dist/{chunk-2747WN4Y.js → chunk-TPND5MJS.js} +3 -3
- package/dist/chunk-TQPCAIQI.js +612 -0
- package/dist/chunk-TQPCAIQI.js.map +1 -0
- package/dist/{chunk-43BKLFZU.js → chunk-YDWBXXQZ.js} +10 -10
- package/dist/{chunk-6PHB5CJS.js → chunk-ZLFRB6FI.js} +2 -2
- package/dist/composition/index.cjs +1228 -1076
- package/dist/composition/index.cjs.map +1 -1
- package/dist/composition/index.d.cts +3 -3
- package/dist/composition/index.d.ts +3 -3
- package/dist/composition/index.js +4 -4
- package/dist/core/index.cjs +1198 -1046
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +1 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.js +2 -2
- package/dist/cqrs/index.d.cts +3 -3
- package/dist/cqrs/index.d.ts +3 -3
- package/dist/cqrs/messaging.d.cts +4 -4
- package/dist/cqrs/messaging.d.ts +4 -4
- package/dist/cqrs/work-queue.d.cts +5 -5
- package/dist/cqrs/work-queue.d.ts +5 -5
- package/dist/data-structures/index.cjs +1226 -1074
- package/dist/data-structures/index.cjs.map +1 -1
- package/dist/data-structures/index.d.cts +8 -7
- package/dist/data-structures/index.d.ts +8 -7
- package/dist/data-structures/index.js +6 -5
- package/dist/{describe-BpyJuWkw.d.ts → describe-B_A5fbXH.d.ts} +1 -1
- package/dist/{describe-DYMw_l1C.d.cts → describe-CQRrkv-Q.d.cts} +1 -1
- package/dist/executors/tool-provider-adapters.cjs +3091 -0
- package/dist/executors/tool-provider-adapters.cjs.map +1 -0
- package/dist/executors/tool-provider-adapters.d.cts +174 -0
- package/dist/executors/tool-provider-adapters.d.ts +174 -0
- package/dist/executors/tool-provider-adapters.js +1336 -0
- package/dist/executors/tool-provider-adapters.js.map +1 -0
- package/dist/executors/tool-provider-runtime.cjs +5178 -0
- package/dist/executors/tool-provider-runtime.cjs.map +1 -0
- package/dist/executors/tool-provider-runtime.d.cts +17 -0
- package/dist/executors/tool-provider-runtime.d.ts +17 -0
- package/dist/executors/tool-provider-runtime.js +15 -0
- package/dist/executors/tool-provider-runtime.js.map +1 -0
- package/dist/executors/tool-provider.cjs +6392 -0
- package/dist/executors/tool-provider.cjs.map +1 -0
- package/dist/executors/tool-provider.d.cts +60 -0
- package/dist/executors/tool-provider.d.ts +60 -0
- package/dist/executors/tool-provider.js +89 -0
- package/dist/executors/tool-provider.js.map +1 -0
- package/dist/executors/work-queue.d.cts +6 -6
- package/dist/executors/work-queue.d.ts +6 -6
- package/dist/graph/index.cjs +1499 -1341
- package/dist/graph/index.cjs.map +1 -1
- package/dist/graph/index.d.cts +9 -8
- package/dist/graph/index.d.ts +9 -8
- package/dist/graph/index.js +23 -22
- package/dist/{graph-DCEWh4T2.d.cts → graph-CWK3HLPB.d.cts} +133 -131
- package/dist/{graph-D-1-SQeC.d.ts → graph-ho5sotHP.d.ts} +133 -131
- package/dist/{index-Bmxeu0nK.d.ts → index-CQWcE0Dw.d.ts} +18 -4
- package/dist/{index-72VZC0-E.d.cts → index-DHA1i67c.d.cts} +18 -4
- package/dist/index.cjs +3397 -3140
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -9
- package/dist/index.d.ts +12 -9
- package/dist/index.js +110 -109
- package/dist/inspection/boundary.d.cts +4 -4
- package/dist/inspection/boundary.d.ts +4 -4
- package/dist/measurements-C0mAvWU1.d.cts +164 -0
- package/dist/measurements-OMpCeBwh.d.ts +164 -0
- package/dist/messaging/index.cjs +57 -51
- package/dist/messaging/index.cjs.map +1 -1
- package/dist/messaging/index.d.cts +11 -276
- package/dist/messaging/index.d.ts +11 -276
- package/dist/messaging/index.js +1 -1
- package/dist/operators/index.cjs +1228 -1076
- 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 +5 -5
- package/dist/orchestration/index.cjs +8844 -6071
- package/dist/orchestration/index.cjs.map +1 -1
- package/dist/orchestration/index.d.cts +171 -224
- package/dist/orchestration/index.d.ts +171 -224
- package/dist/orchestration/index.js +42 -991
- package/dist/orchestration/index.js.map +1 -1
- package/dist/orchestration/messaging.d.cts +5 -8
- package/dist/orchestration/messaging.d.ts +5 -8
- package/dist/orchestration/work-queue.cjs +1243 -5
- package/dist/orchestration/work-queue.cjs.map +1 -1
- package/dist/orchestration/work-queue.d.cts +121 -10
- package/dist/orchestration/work-queue.d.ts +121 -10
- package/dist/orchestration/work-queue.js +1067 -4
- package/dist/orchestration/work-queue.js.map +1 -1
- package/dist/patterns/event-flow.cjs +6 -20
- package/dist/patterns/event-flow.cjs.map +1 -1
- package/dist/patterns/event-flow.d.cts +4 -4
- package/dist/patterns/event-flow.d.ts +4 -4
- package/dist/patterns/event-flow.js +2 -2
- package/dist/patterns/index.cjs +453 -465
- package/dist/patterns/index.cjs.map +1 -1
- package/dist/patterns/index.d.cts +6 -5
- package/dist/patterns/index.d.ts +6 -5
- package/dist/patterns/index.js +3 -3
- package/dist/process-types-C9uMYz3i.d.ts +200 -0
- package/dist/process-types-h3uRlzDc.d.cts +200 -0
- package/dist/{reactive-collection-DNV0-gFi.d.cts → reactive-collection-B9R0Bl1P.d.cts} +4 -34
- package/dist/{reactive-collection-BAmfrGjd.d.ts → reactive-collection-BXFrH0U2.d.ts} +4 -34
- package/dist/{reactive-collection-storage-BNEldDyi.d.cts → reactive-collection-storage-BLGv8Xp8.d.cts} +5 -5
- package/dist/{reactive-collection-storage-YZsAQsWK.d.ts → reactive-collection-storage-a4zD3665.d.ts} +5 -5
- package/dist/{reactive-map-DRD1LJ2H.d.cts → reactive-map-C_8sOfdS.d.cts} +3 -2
- package/dist/{reactive-map-EsDiCmJk.d.ts → reactive-map-jle5dnok.d.ts} +3 -2
- package/dist/render/index.d.cts +2 -2
- package/dist/render/index.d.ts +2 -2
- package/dist/scheduled-readiness-5rwQlyjV.d.ts +91 -0
- package/dist/scheduled-readiness-DpRY8jI0.d.cts +91 -0
- package/dist/semantic-memory-graph-C2ZUwIlq.d.ts +30 -0
- package/dist/semantic-memory-graph-DlZBD_Eu.d.cts +30 -0
- package/dist/{semantic-memory-graph-DKuNzuWw.d.cts → semantic-memory-graph-types-BvzdqmkY.d.cts} +2 -28
- package/dist/{semantic-memory-graph-uwbwJdhe.d.ts → semantic-memory-graph-types-Ci-OtahO.d.ts} +2 -28
- package/dist/solutions/index.cjs +6353 -6169
- package/dist/solutions/index.cjs.map +1 -1
- package/dist/solutions/index.d.cts +12 -10
- package/dist/solutions/index.d.ts +12 -10
- package/dist/solutions/index.js +5 -5
- package/dist/solutions/reactive-layout/browser/index.cjs +116 -108
- package/dist/solutions/reactive-layout/browser/index.cjs.map +1 -1
- package/dist/solutions/reactive-layout/browser/index.d.cts +4 -4
- package/dist/solutions/reactive-layout/browser/index.d.ts +4 -4
- package/dist/solutions/reactive-layout/browser/index.js +3 -3
- package/dist/solutions/reactive-layout/index.cjs +3578 -3350
- package/dist/solutions/reactive-layout/index.cjs.map +1 -1
- package/dist/solutions/reactive-layout/index.d.cts +32 -576
- package/dist/solutions/reactive-layout/index.d.ts +32 -576
- package/dist/solutions/reactive-layout/index.js +65 -5
- package/dist/solutions/reactive-layout/node-canvas/index.cjs +127 -117
- package/dist/solutions/reactive-layout/node-canvas/index.cjs.map +1 -1
- package/dist/solutions/reactive-layout/node-canvas/index.d.cts +4 -4
- package/dist/solutions/reactive-layout/node-canvas/index.d.ts +4 -4
- package/dist/solutions/reactive-layout/node-canvas/index.js +3 -3
- package/dist/solutions/reactive-layout/react-native/index.cjs +127 -117
- package/dist/solutions/reactive-layout/react-native/index.cjs.map +1 -1
- package/dist/solutions/reactive-layout/react-native/index.d.cts +4 -4
- package/dist/solutions/reactive-layout/react-native/index.d.ts +4 -4
- package/dist/solutions/reactive-layout/react-native/index.js +3 -3
- package/dist/solutions/reactive-layout/skia/index.cjs +127 -117
- package/dist/solutions/reactive-layout/skia/index.cjs.map +1 -1
- package/dist/solutions/reactive-layout/skia/index.d.cts +4 -4
- package/dist/solutions/reactive-layout/skia/index.d.ts +4 -4
- package/dist/solutions/reactive-layout/skia/index.js +3 -3
- package/dist/solutions/work-item/actions.cjs +1609 -1428
- package/dist/solutions/work-item/actions.cjs.map +1 -1
- package/dist/solutions/work-item/actions.d.cts +23 -184
- package/dist/solutions/work-item/actions.d.ts +23 -184
- package/dist/solutions/work-item/actions.js +1558 -934
- package/dist/solutions/work-item/actions.js.map +1 -1
- package/dist/solutions/work-item/scheduling.cjs +9181 -1838
- package/dist/solutions/work-item/scheduling.cjs.map +1 -1
- package/dist/solutions/work-item/scheduling.d.cts +1763 -328
- package/dist/solutions/work-item/scheduling.d.ts +1763 -328
- package/dist/solutions/work-item/scheduling.js +117 -3
- package/dist/solutions/work-item/work-queue.d.cts +7 -7
- package/dist/solutions/work-item/work-queue.d.ts +7 -7
- package/dist/sources/browser.cjs +1318 -1083
- package/dist/sources/browser.cjs.map +1 -1
- package/dist/sources/browser.d.cts +4 -4
- package/dist/sources/browser.d.ts +4 -4
- package/dist/sources/browser.js +4 -4
- package/dist/sources/index.cjs +1318 -1083
- package/dist/sources/index.cjs.map +1 -1
- package/dist/sources/index.d.cts +4 -4
- package/dist/sources/index.d.ts +4 -4
- package/dist/sources/index.js +4 -4
- package/dist/sources/node.d.cts +3 -3
- package/dist/sources/node.d.ts +3 -3
- package/dist/storage/browser.cjs +16 -0
- package/dist/storage/browser.cjs.map +1 -1
- package/dist/storage/browser.js +3 -3
- package/dist/storage/index.cjs +16 -0
- package/dist/storage/index.cjs.map +1 -1
- package/dist/storage/index.d.cts +5 -4
- package/dist/storage/index.d.ts +5 -4
- package/dist/storage/index.js +6 -6
- package/dist/storage/node.cjs +16 -0
- package/dist/storage/node.cjs.map +1 -1
- package/dist/storage/node.js +3 -3
- package/dist/{store-C-joM4gh.d.ts → store-BmtEs9mG.d.ts} +1 -1
- package/dist/{store-CNJwmT-h.d.cts → store-PAAsYvML.d.cts} +1 -1
- package/dist/types-BRNKoFHj.d.ts +357 -0
- package/dist/{types-CcPIn7sy.d.cts → types-BS6CyR-x.d.cts} +27 -108
- package/dist/types-BWK2ay3e.d.cts +457 -0
- package/dist/types-BXKSAoE1.d.cts +357 -0
- package/dist/types-BaPpZItj.d.ts +457 -0
- package/dist/types-BhveCMg5.d.cts +274 -0
- package/dist/{types-BsJvElYZ.d.ts → types-C9NOgNJw.d.ts} +27 -108
- package/dist/types-CTsQ8Ww4.d.ts +274 -0
- package/dist/types-DL_05n2M.d.ts +34 -0
- package/dist/types-XDoqxYO9.d.cts +34 -0
- package/dist/{work-item-runtime-C3M79vE9.d.ts → work-item-runtime-types-BqtWnSCS.d.ts} +3 -93
- package/dist/{work-item-runtime-qaVgsL0T.d.cts → work-item-runtime-types-CHO03AKh.d.cts} +3 -93
- package/dist/work-queue/index.cjs +957 -953
- package/dist/work-queue/index.cjs.map +1 -1
- package/dist/work-queue/index.d.cts +9 -357
- package/dist/work-queue/index.d.ts +9 -357
- package/dist/work-queue/index.js +957 -953
- package/dist/work-queue/index.js.map +1 -1
- package/package.json +603 -513
- package/dist/chunk-3JR3EDB2.js.map +0 -1
- package/dist/chunk-4VLAQHZI.js.map +0 -1
- package/dist/chunk-6XAIOL3X.js +0 -2407
- package/dist/chunk-6XAIOL3X.js.map +0 -1
- package/dist/chunk-FBUU43PM.js.map +0 -1
- package/dist/chunk-HKK2JD7Z.js.map +0 -1
- package/dist/chunk-PC3BTTBE.js +0 -3217
- package/dist/chunk-PC3BTTBE.js.map +0 -1
- package/dist/chunk-QFY4AFY4.js.map +0 -1
- package/dist/chunk-V7CIJE4B.js.map +0 -1
- package/dist/chunk-XKXWK2KP.js.map +0 -1
- package/dist/chunk-YDSIVHRR.js.map +0 -1
- package/dist/chunk-YXMZ2N6J.js.map +0 -1
- /package/dist/{chunk-Z2ANQ6JW.js.map → chunk-4Q77MMJY.js.map} +0 -0
- /package/dist/{chunk-IXZBUWSP.js.map → chunk-7HZRJMN6.js.map} +0 -0
- /package/dist/{chunk-SS2A464I.js.map → chunk-CJIFGJQG.js.map} +0 -0
- /package/dist/{chunk-K3FXTC3I.js.map → chunk-HJACH5PU.js.map} +0 -0
- /package/dist/{chunk-GTPCOEOZ.js.map → chunk-IDMLXLLG.js.map} +0 -0
- /package/dist/{chunk-DKP56CSW.js.map → chunk-JKAYLDQV.js.map} +0 -0
- /package/dist/{chunk-VTHLCFN4.js.map → chunk-RAHNUYA5.js.map} +0 -0
- /package/dist/{chunk-CZNV3VXM.js.map → chunk-SIDJO2T4.js.map} +0 -0
- /package/dist/{chunk-2747WN4Y.js.map → chunk-TPND5MJS.js.map} +0 -0
- /package/dist/{chunk-43BKLFZU.js.map → chunk-YDWBXXQZ.js.map} +0 -0
- /package/dist/{chunk-6PHB5CJS.js.map → chunk-ZLFRB6FI.js.map} +0 -0
|
@@ -21,7 +21,10 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var work_queue_exports = {};
|
|
22
22
|
__export(work_queue_exports, {
|
|
23
23
|
orchestrationWorkQueueRecipe: () => orchestrationWorkQueueRecipe,
|
|
24
|
-
processEffectSubmitCommand: () => processEffectSubmitCommand
|
|
24
|
+
processEffectSubmitCommand: () => processEffectSubmitCommand,
|
|
25
|
+
workQueueLeaseExpirationCommandProjector: () => workQueueLeaseExpirationCommandProjector,
|
|
26
|
+
workQueueReadinessHandoffProjector: () => workQueueReadinessHandoffProjector,
|
|
27
|
+
workQueueScheduledReadinessProjector: () => workQueueScheduledReadinessProjector
|
|
25
28
|
});
|
|
26
29
|
module.exports = __toCommonJS(work_queue_exports);
|
|
27
30
|
|
|
@@ -39,6 +42,1238 @@ function depBatch(ctx, depIndex) {
|
|
|
39
42
|
return flattened.length === 0 ? [] : flattened;
|
|
40
43
|
}
|
|
41
44
|
|
|
45
|
+
// src/orchestration/agent-runtime-common.ts
|
|
46
|
+
function uniqueSourceRefs(sourceRefs) {
|
|
47
|
+
const seen = /* @__PURE__ */ new Set();
|
|
48
|
+
const unique = [];
|
|
49
|
+
for (const sourceRef of sourceRefs) {
|
|
50
|
+
const key = `${sourceRef.kind}:${sourceRef.id}:${JSON.stringify(sourceRef.metadata ?? {})}`;
|
|
51
|
+
if (seen.has(key)) continue;
|
|
52
|
+
seen.add(key);
|
|
53
|
+
unique.push(sourceRef);
|
|
54
|
+
}
|
|
55
|
+
return Object.freeze(unique);
|
|
56
|
+
}
|
|
57
|
+
function stableJsonStringify(value) {
|
|
58
|
+
const seen = /* @__PURE__ */ new WeakSet();
|
|
59
|
+
return JSON.stringify(value, (_key, child) => {
|
|
60
|
+
if (typeof child === "bigint") return child.toString();
|
|
61
|
+
if (typeof child === "function") return "[Function]";
|
|
62
|
+
if (!isRecord(child) && !Array.isArray(child)) return child;
|
|
63
|
+
if (seen.has(child)) return "[Circular]";
|
|
64
|
+
seen.add(child);
|
|
65
|
+
if (Array.isArray(child)) return child;
|
|
66
|
+
return Object.keys(child).sort().reduce((out, key) => {
|
|
67
|
+
out[key] = child[key];
|
|
68
|
+
return out;
|
|
69
|
+
}, {});
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
function stableStringHash(value) {
|
|
73
|
+
let hash = 2166136261;
|
|
74
|
+
for (let i = 0; i < value.length; i += 1) {
|
|
75
|
+
hash ^= value.charCodeAt(i);
|
|
76
|
+
hash = Math.imul(hash, 16777619);
|
|
77
|
+
}
|
|
78
|
+
return (hash >>> 0).toString(36);
|
|
79
|
+
}
|
|
80
|
+
function projectRuntimeFact(graph, runtime, name, factory, pick) {
|
|
81
|
+
return graph.node(
|
|
82
|
+
[runtime],
|
|
83
|
+
(ctx) => {
|
|
84
|
+
for (const fact of depBatch(ctx, 0) ?? []) {
|
|
85
|
+
const typed = fact;
|
|
86
|
+
const value = pick(typed);
|
|
87
|
+
if (value !== void 0) ctx.down([["DATA", value]]);
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
{ name, factory }
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
function forbiddenDataKeys(value, path = [], seen = /* @__PURE__ */ new WeakSet()) {
|
|
94
|
+
if (typeof value === "function") return [{ path, reason: "function-value" }];
|
|
95
|
+
if (typeof value === "symbol" || typeof value === "bigint") {
|
|
96
|
+
return [{ path, reason: "non-graph-visible-primitive" }];
|
|
97
|
+
}
|
|
98
|
+
if (!isRecord(value) && !Array.isArray(value)) return [];
|
|
99
|
+
if (typeof value === "object" && value !== null) {
|
|
100
|
+
if (seen.has(value)) return [];
|
|
101
|
+
seen.add(value);
|
|
102
|
+
}
|
|
103
|
+
const issues = [];
|
|
104
|
+
if (Array.isArray(value)) {
|
|
105
|
+
value.forEach((item, index) => {
|
|
106
|
+
issues.push(...forbiddenDataKeys(item, [...path, index], seen));
|
|
107
|
+
});
|
|
108
|
+
return issues;
|
|
109
|
+
}
|
|
110
|
+
if (!isPlainRecord(value)) return [{ path, reason: "non-plain-runtime-object" }];
|
|
111
|
+
const symbolKeys = Object.getOwnPropertySymbols(value);
|
|
112
|
+
if (symbolKeys.length > 0) {
|
|
113
|
+
issues.push({ path, reason: "symbol-key" });
|
|
114
|
+
}
|
|
115
|
+
for (const [key, child] of Object.entries(value)) {
|
|
116
|
+
const nextPath = [...path, key];
|
|
117
|
+
if (/^(apiKey|api_key|secret|client|transport|subprocess|sdk|oauth|credential|credentials|accessToken|access_token|refreshToken|refresh_token|idToken|id_token|token|password|passphrase|authorization|authHeader|auth_header|bearer|privateKey|private_key|sessionCookie|session_cookie|cookie)$/i.test(
|
|
118
|
+
key
|
|
119
|
+
)) {
|
|
120
|
+
issues.push({ path: nextPath, reason: "forbidden-runtime-key" });
|
|
121
|
+
}
|
|
122
|
+
issues.push(...forbiddenDataKeys(child, nextPath, seen));
|
|
123
|
+
}
|
|
124
|
+
return issues;
|
|
125
|
+
}
|
|
126
|
+
function sanitizeGraphVisibleRecord(value, policy) {
|
|
127
|
+
return sanitizePublicRecord(value, { mode: "graph", policy });
|
|
128
|
+
}
|
|
129
|
+
function canonicalPublicSourceRefs(sourceRefs) {
|
|
130
|
+
return uniqueSourceRefs(
|
|
131
|
+
sourceRefs.map((sourceRef) => {
|
|
132
|
+
const metadata = sanitizePublicRecord(sourceRef.metadata, { mode: "provider" });
|
|
133
|
+
return metadata === void 0 ? { kind: sourceRef.kind, id: sourceRef.id } : { kind: sourceRef.kind, id: sourceRef.id, metadata };
|
|
134
|
+
})
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
function sanitizePublicRecord(value, opts) {
|
|
138
|
+
if (value === void 0 || publicMaterialForbiddenKeys(value, opts.mode).length > 0) {
|
|
139
|
+
return void 0;
|
|
140
|
+
}
|
|
141
|
+
return Object.freeze(boundRecordStrings(value, maxPublicMetadataStringChars(opts.policy)));
|
|
142
|
+
}
|
|
143
|
+
function publicMaterialForbiddenKeys(value, mode) {
|
|
144
|
+
const forbidden = [...forbiddenDataKeys(value)];
|
|
145
|
+
if (mode === "provider") forbidden.push(...forbiddenProviderRawMaterialKeys(value));
|
|
146
|
+
return forbidden;
|
|
147
|
+
}
|
|
148
|
+
function boundPublicText(text, limitChars) {
|
|
149
|
+
const limit = Math.max(0, limitChars);
|
|
150
|
+
if (text.length <= limit) {
|
|
151
|
+
return { text, truncated: false, originalChars: text.length, limitChars: limit };
|
|
152
|
+
}
|
|
153
|
+
const bounded = limit <= 1 ? text.slice(0, limit) : limit <= 3 ? text.slice(0, limit) : `${text.slice(0, limit - 3)}...`;
|
|
154
|
+
return { text: bounded, truncated: true, originalChars: text.length, limitChars: limit };
|
|
155
|
+
}
|
|
156
|
+
function boundRecordStrings(value, limitChars, seen = /* @__PURE__ */ new WeakSet()) {
|
|
157
|
+
if (seen.has(value)) return {};
|
|
158
|
+
seen.add(value);
|
|
159
|
+
return Object.entries(value).reduce((out, [key, child]) => {
|
|
160
|
+
if (typeof child === "string") {
|
|
161
|
+
out[key] = boundPublicText(child, limitChars).text;
|
|
162
|
+
} else if (Array.isArray(child)) {
|
|
163
|
+
out[key] = child.map(
|
|
164
|
+
(item) => typeof item === "string" ? boundPublicText(item, limitChars).text : isPlainRecord(item) ? boundRecordStrings(item, limitChars, seen) : item
|
|
165
|
+
);
|
|
166
|
+
} else if (isPlainRecord(child)) {
|
|
167
|
+
out[key] = boundRecordStrings(child, limitChars, seen);
|
|
168
|
+
} else {
|
|
169
|
+
out[key] = child;
|
|
170
|
+
}
|
|
171
|
+
return out;
|
|
172
|
+
}, {});
|
|
173
|
+
}
|
|
174
|
+
function maxPublicMetadataStringChars(policy) {
|
|
175
|
+
return normalizedPublicTextLimit(policy?.maxMetadataStringChars, 256);
|
|
176
|
+
}
|
|
177
|
+
function normalizedPublicTextLimit(value, fallback) {
|
|
178
|
+
if (value === void 0 || !Number.isFinite(value)) return fallback;
|
|
179
|
+
return Math.max(0, Math.floor(value));
|
|
180
|
+
}
|
|
181
|
+
function forbiddenProviderRawMaterialKeys(value, path = [], seen = /* @__PURE__ */ new WeakSet()) {
|
|
182
|
+
if (!isRecord(value) && !Array.isArray(value)) return [];
|
|
183
|
+
if (typeof value === "object" && value !== null) {
|
|
184
|
+
if (seen.has(value)) return [];
|
|
185
|
+
seen.add(value);
|
|
186
|
+
}
|
|
187
|
+
const issues = [];
|
|
188
|
+
if (Array.isArray(value)) {
|
|
189
|
+
value.forEach((item, index) => {
|
|
190
|
+
issues.push(...forbiddenProviderRawMaterialKeys(item, [...path, index], seen));
|
|
191
|
+
});
|
|
192
|
+
return issues;
|
|
193
|
+
}
|
|
194
|
+
for (const [key, child] of Object.entries(value)) {
|
|
195
|
+
const nextPath = [...path, key];
|
|
196
|
+
if (/^(stdout|stderr|stack|stackTrace|stack_trace|providerRaw|provider_raw|rawResponse|raw_response|diff|patch|fileContents|file_contents|binary|media)$/i.test(
|
|
197
|
+
key
|
|
198
|
+
)) {
|
|
199
|
+
issues.push({ path: nextPath, reason: "raw-provider-material" });
|
|
200
|
+
}
|
|
201
|
+
issues.push(...forbiddenProviderRawMaterialKeys(child, nextPath, seen));
|
|
202
|
+
}
|
|
203
|
+
return issues;
|
|
204
|
+
}
|
|
205
|
+
function dataIssue(code, message, opts = {}) {
|
|
206
|
+
return {
|
|
207
|
+
kind: "issue",
|
|
208
|
+
code,
|
|
209
|
+
message,
|
|
210
|
+
severity: opts.severity ?? "error",
|
|
211
|
+
subjectId: opts.subjectId,
|
|
212
|
+
refs: opts.refs?.map((r) => `${r.kind}:${r.id}`),
|
|
213
|
+
details: opts.details
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
function ref(kind, id) {
|
|
217
|
+
return { kind, id };
|
|
218
|
+
}
|
|
219
|
+
function isRecord(value) {
|
|
220
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
221
|
+
}
|
|
222
|
+
function isPlainRecord(value) {
|
|
223
|
+
if (!isRecord(value)) return false;
|
|
224
|
+
const proto = Object.getPrototypeOf(value);
|
|
225
|
+
return proto === Object.prototype || proto === null;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// src/orchestration/work-queue-scheduled-readiness.ts
|
|
229
|
+
var MAX_PUBLIC_COORDINATE_ID_CHARS = 160;
|
|
230
|
+
var MAX_COPIED_PUBLIC_REFS = 16;
|
|
231
|
+
var PRIVATE_COORDINATE_PATTERN = /(api[_-]?key|authorization|bearer|credential|oauth|password|private[_-]?key|secret|session[_-]?cookie|token)/i;
|
|
232
|
+
function workQueueScheduledReadinessProjector(graph, opts) {
|
|
233
|
+
const name = opts.name ?? "workQueueScheduledReadiness";
|
|
234
|
+
const runtime = graph.node(
|
|
235
|
+
[opts.records],
|
|
236
|
+
(ctx) => {
|
|
237
|
+
const state = ctx.state.get() ?? initialState();
|
|
238
|
+
for (const raw of depBatch(ctx, 0) ?? []) {
|
|
239
|
+
const translated = translateRecord(raw);
|
|
240
|
+
if (translated.kind === "none") continue;
|
|
241
|
+
if (translated.kind === "issue") {
|
|
242
|
+
emitIssue(ctx, state, translated.issue);
|
|
243
|
+
emitStatus(ctx, state, translated.status);
|
|
244
|
+
continue;
|
|
245
|
+
}
|
|
246
|
+
const identity = scheduleIdentity(translated.schedule);
|
|
247
|
+
const recordKey = `${translated.record.queueId}:${translated.record.recordSeq}`;
|
|
248
|
+
const existingRecordIdentity = state.recordScheduleIdentityByKey.get(recordKey);
|
|
249
|
+
if (existingRecordIdentity !== void 0) {
|
|
250
|
+
if (existingRecordIdentity !== identity) emitScheduleConflict(ctx, state, translated);
|
|
251
|
+
continue;
|
|
252
|
+
}
|
|
253
|
+
state.recordScheduleIdentityByKey.set(recordKey, identity);
|
|
254
|
+
const existing = state.schedulesById.get(translated.schedule.scheduleId);
|
|
255
|
+
if (existing !== void 0) {
|
|
256
|
+
if (scheduleIdentity(existing) !== identity) {
|
|
257
|
+
emitScheduleConflict(ctx, state, translated, existing);
|
|
258
|
+
}
|
|
259
|
+
continue;
|
|
260
|
+
}
|
|
261
|
+
state.schedulesById.set(translated.schedule.scheduleId, translated.schedule);
|
|
262
|
+
emitSchedule(ctx, state, translated.schedule);
|
|
263
|
+
emitStatus(ctx, state, translated.status);
|
|
264
|
+
emitAudit(ctx, state, "work-queue-scheduled-readiness-translated", {
|
|
265
|
+
subjectId: translated.schedule.scheduleId,
|
|
266
|
+
sourceRefs: translated.schedule.sourceRefs,
|
|
267
|
+
metadata: {
|
|
268
|
+
queueId: publicCoordinateId(translated.record.queueId),
|
|
269
|
+
workId: publicCoordinateId(translated.record.workId),
|
|
270
|
+
recordSeq: translated.record.recordSeq,
|
|
271
|
+
recordKind: translated.record.kind,
|
|
272
|
+
readyAtMs: translated.schedule.readyAtMs
|
|
273
|
+
}
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
ctx.down([["DATA", { kind: "views", views: buildViews(state) }]]);
|
|
277
|
+
ctx.state.set(state);
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
name: `${name}/runtime`,
|
|
281
|
+
factory: "workQueueScheduledReadinessProjector",
|
|
282
|
+
partial: true,
|
|
283
|
+
completeWhenDepsComplete: false,
|
|
284
|
+
errorWhenDepsError: false
|
|
285
|
+
}
|
|
286
|
+
);
|
|
287
|
+
return {
|
|
288
|
+
readinessSchedules: projectRuntimeFact(
|
|
289
|
+
graph,
|
|
290
|
+
runtime,
|
|
291
|
+
`${name}/readinessSchedules`,
|
|
292
|
+
"workQueueScheduledReadinessSchedules",
|
|
293
|
+
(fact) => fact.kind === "readiness-schedule" ? fact.schedule : void 0
|
|
294
|
+
),
|
|
295
|
+
status: projectRuntimeFact(
|
|
296
|
+
graph,
|
|
297
|
+
runtime,
|
|
298
|
+
`${name}/status`,
|
|
299
|
+
"workQueueScheduledReadinessStatus",
|
|
300
|
+
(fact) => fact.kind === "status" ? fact.status : void 0
|
|
301
|
+
),
|
|
302
|
+
issues: projectRuntimeFact(
|
|
303
|
+
graph,
|
|
304
|
+
runtime,
|
|
305
|
+
`${name}/issues`,
|
|
306
|
+
"workQueueScheduledReadinessIssues",
|
|
307
|
+
(fact) => fact.kind === "issue" ? fact.issue : void 0
|
|
308
|
+
),
|
|
309
|
+
audit: projectRuntimeFact(
|
|
310
|
+
graph,
|
|
311
|
+
runtime,
|
|
312
|
+
`${name}/audit`,
|
|
313
|
+
"workQueueScheduledReadinessAudit",
|
|
314
|
+
(fact) => fact.kind === "audit" ? fact.audit : void 0
|
|
315
|
+
),
|
|
316
|
+
views: projectRuntimeFact(
|
|
317
|
+
graph,
|
|
318
|
+
runtime,
|
|
319
|
+
`${name}/views`,
|
|
320
|
+
"workQueueScheduledReadinessViews",
|
|
321
|
+
(fact) => fact.kind === "views" ? fact.views : void 0
|
|
322
|
+
)
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
function workQueueReadinessHandoffProjector(graph, opts) {
|
|
326
|
+
const name = opts.name ?? "workQueueReadinessHandoff";
|
|
327
|
+
const deps = opts.overdue === void 0 ? [opts.records, opts.ready] : [opts.records, opts.ready, opts.overdue];
|
|
328
|
+
const runtime = graph.node(
|
|
329
|
+
deps,
|
|
330
|
+
(ctx) => {
|
|
331
|
+
const state = ctx.state.get() ?? handoffState();
|
|
332
|
+
for (const raw of depBatch(ctx, 0) ?? []) {
|
|
333
|
+
const record = raw;
|
|
334
|
+
ingestWorkQueueRecord(state, record);
|
|
335
|
+
}
|
|
336
|
+
for (const raw of depBatch(ctx, 1) ?? []) {
|
|
337
|
+
const ready = raw;
|
|
338
|
+
state.readyByScheduleId.set(ready.scheduleId, ready);
|
|
339
|
+
}
|
|
340
|
+
if (opts.overdue !== void 0) {
|
|
341
|
+
for (const raw of depBatch(ctx, 2) ?? []) {
|
|
342
|
+
emitOverdueHandoffStatus(ctx, state, raw);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
evaluateReadyHandoffs(ctx, state);
|
|
346
|
+
ctx.down([["DATA", { kind: "views", views: buildHandoffViews(state) }]]);
|
|
347
|
+
ctx.state.set(state);
|
|
348
|
+
},
|
|
349
|
+
{
|
|
350
|
+
name: `${name}/runtime`,
|
|
351
|
+
factory: "workQueueReadinessHandoffProjector",
|
|
352
|
+
partial: true,
|
|
353
|
+
completeWhenDepsComplete: false,
|
|
354
|
+
errorWhenDepsError: false
|
|
355
|
+
}
|
|
356
|
+
);
|
|
357
|
+
return {
|
|
358
|
+
candidates: projectRuntimeFact(
|
|
359
|
+
graph,
|
|
360
|
+
runtime,
|
|
361
|
+
`${name}/candidates`,
|
|
362
|
+
"workQueueReadinessHandoffCandidates",
|
|
363
|
+
(fact) => fact.kind === "candidate" ? fact.candidate : void 0
|
|
364
|
+
),
|
|
365
|
+
status: projectRuntimeFact(
|
|
366
|
+
graph,
|
|
367
|
+
runtime,
|
|
368
|
+
`${name}/status`,
|
|
369
|
+
"workQueueReadinessHandoffStatus",
|
|
370
|
+
(fact) => fact.kind === "status" ? fact.status : void 0
|
|
371
|
+
),
|
|
372
|
+
issues: projectRuntimeFact(
|
|
373
|
+
graph,
|
|
374
|
+
runtime,
|
|
375
|
+
`${name}/issues`,
|
|
376
|
+
"workQueueReadinessHandoffIssues",
|
|
377
|
+
(fact) => fact.kind === "issue" ? fact.issue : void 0
|
|
378
|
+
),
|
|
379
|
+
audit: projectRuntimeFact(
|
|
380
|
+
graph,
|
|
381
|
+
runtime,
|
|
382
|
+
`${name}/audit`,
|
|
383
|
+
"workQueueReadinessHandoffAudit",
|
|
384
|
+
(fact) => fact.kind === "audit" ? fact.audit : void 0
|
|
385
|
+
),
|
|
386
|
+
views: projectRuntimeFact(
|
|
387
|
+
graph,
|
|
388
|
+
runtime,
|
|
389
|
+
`${name}/views`,
|
|
390
|
+
"workQueueReadinessHandoffViews",
|
|
391
|
+
(fact) => fact.kind === "views" ? fact.views : void 0
|
|
392
|
+
)
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
function workQueueLeaseExpirationCommandProjector(graph, opts) {
|
|
396
|
+
const name = opts.name ?? "workQueueLeaseExpirationCommands";
|
|
397
|
+
const runtime = graph.node(
|
|
398
|
+
[opts.candidates],
|
|
399
|
+
(ctx) => {
|
|
400
|
+
const state = ctx.state.get() ?? leaseExpirationCommandState();
|
|
401
|
+
for (const raw of depBatch(ctx, 0) ?? []) {
|
|
402
|
+
const candidate = raw;
|
|
403
|
+
if (candidate.candidateKind !== "lease-expiration-eligible") continue;
|
|
404
|
+
if (state.commandByCandidateId.has(candidate.candidateId)) continue;
|
|
405
|
+
const command = Object.freeze({
|
|
406
|
+
kind: "expire-leases",
|
|
407
|
+
commandId: `${candidate.candidateId}:expire-leases`,
|
|
408
|
+
queueId: candidate.queueId,
|
|
409
|
+
workIds: [candidate.workId],
|
|
410
|
+
limit: 1,
|
|
411
|
+
nowMs: candidate.nowMs,
|
|
412
|
+
causationId: candidate.scheduleId,
|
|
413
|
+
...sourceRefStrings(candidate.sourceRefs) === void 0 ? {} : { sourceRefs: sourceRefStrings(candidate.sourceRefs) }
|
|
414
|
+
});
|
|
415
|
+
state.commandByCandidateId.set(candidate.candidateId, command);
|
|
416
|
+
ctx.down([["DATA", { kind: "command", command }]]);
|
|
417
|
+
emitLeaseCommandStatus(ctx, state, command, candidate);
|
|
418
|
+
}
|
|
419
|
+
ctx.down([["DATA", { kind: "views", views: buildLeaseCommandViews(state) }]]);
|
|
420
|
+
ctx.state.set(state);
|
|
421
|
+
},
|
|
422
|
+
{
|
|
423
|
+
name: `${name}/runtime`,
|
|
424
|
+
factory: "workQueueLeaseExpirationCommandProjector",
|
|
425
|
+
partial: true,
|
|
426
|
+
completeWhenDepsComplete: false,
|
|
427
|
+
errorWhenDepsError: false
|
|
428
|
+
}
|
|
429
|
+
);
|
|
430
|
+
return {
|
|
431
|
+
commands: projectRuntimeFact(
|
|
432
|
+
graph,
|
|
433
|
+
runtime,
|
|
434
|
+
`${name}/commands`,
|
|
435
|
+
"workQueueLeaseExpirationCommands",
|
|
436
|
+
(fact) => fact.kind === "command" ? fact.command : void 0
|
|
437
|
+
),
|
|
438
|
+
status: projectRuntimeFact(
|
|
439
|
+
graph,
|
|
440
|
+
runtime,
|
|
441
|
+
`${name}/status`,
|
|
442
|
+
"workQueueLeaseExpirationCommandStatus",
|
|
443
|
+
(fact) => fact.kind === "status" ? fact.status : void 0
|
|
444
|
+
),
|
|
445
|
+
views: projectRuntimeFact(
|
|
446
|
+
graph,
|
|
447
|
+
runtime,
|
|
448
|
+
`${name}/views`,
|
|
449
|
+
"workQueueLeaseExpirationCommandViews",
|
|
450
|
+
(fact) => fact.kind === "views" ? fact.views : void 0
|
|
451
|
+
)
|
|
452
|
+
};
|
|
453
|
+
}
|
|
454
|
+
function initialState() {
|
|
455
|
+
return {
|
|
456
|
+
recordScheduleIdentityByKey: /* @__PURE__ */ new Map(),
|
|
457
|
+
schedulesById: /* @__PURE__ */ new Map(),
|
|
458
|
+
statusById: /* @__PURE__ */ new Map(),
|
|
459
|
+
emittedKeys: /* @__PURE__ */ new Set(),
|
|
460
|
+
issueKeys: /* @__PURE__ */ new Set(),
|
|
461
|
+
auditSeq: 0
|
|
462
|
+
};
|
|
463
|
+
}
|
|
464
|
+
function handoffState() {
|
|
465
|
+
return {
|
|
466
|
+
originsByScheduleId: /* @__PURE__ */ new Map(),
|
|
467
|
+
worksById: /* @__PURE__ */ new Map(),
|
|
468
|
+
readyByScheduleId: /* @__PURE__ */ new Map(),
|
|
469
|
+
candidatesById: /* @__PURE__ */ new Map(),
|
|
470
|
+
statusById: /* @__PURE__ */ new Map(),
|
|
471
|
+
emittedKeys: /* @__PURE__ */ new Set(),
|
|
472
|
+
issueKeys: /* @__PURE__ */ new Set(),
|
|
473
|
+
auditSeq: 0
|
|
474
|
+
};
|
|
475
|
+
}
|
|
476
|
+
function leaseExpirationCommandState() {
|
|
477
|
+
return {
|
|
478
|
+
commandByCandidateId: /* @__PURE__ */ new Map(),
|
|
479
|
+
statusById: /* @__PURE__ */ new Map(),
|
|
480
|
+
emittedKeys: /* @__PURE__ */ new Set()
|
|
481
|
+
};
|
|
482
|
+
}
|
|
483
|
+
function ingestWorkQueueRecord(state, record) {
|
|
484
|
+
const translated = translateRecord(record);
|
|
485
|
+
if (translated.kind === "translated") {
|
|
486
|
+
state.originsByScheduleId.set(translated.schedule.scheduleId, {
|
|
487
|
+
record: translated.record,
|
|
488
|
+
schedule: translated.schedule,
|
|
489
|
+
scheduleKind: translated.status.scheduleKind
|
|
490
|
+
});
|
|
491
|
+
}
|
|
492
|
+
if (record.workId === void 0) return;
|
|
493
|
+
const recordWithWorkId = record;
|
|
494
|
+
const existing = state.worksById.get(
|
|
495
|
+
handoffWorkKey(recordWithWorkId.queueId, recordWithWorkId.workId)
|
|
496
|
+
);
|
|
497
|
+
if (existing !== void 0 && recordWithWorkId.recordSeq < existing.latestRecordSeq) return;
|
|
498
|
+
const work = ensureHandoffWorkState(state, recordWithWorkId);
|
|
499
|
+
work.latestRecordSeq = Math.max(work.latestRecordSeq, recordWithWorkId.recordSeq);
|
|
500
|
+
switch (recordWithWorkId.kind) {
|
|
501
|
+
case "work-admitted":
|
|
502
|
+
work.state = recordWithWorkId.notBeforeMs === void 0 ? "ready" : "scheduled";
|
|
503
|
+
work.notBeforeMs = recordWithWorkId.notBeforeMs;
|
|
504
|
+
work.retryAtMs = void 0;
|
|
505
|
+
work.deadlineMs = recordWithWorkId.deadlineMs;
|
|
506
|
+
clearHandoffLease(work);
|
|
507
|
+
break;
|
|
508
|
+
case "work-scheduled":
|
|
509
|
+
work.state = "scheduled";
|
|
510
|
+
work.notBeforeMs = recordWithWorkId.notBeforeMs;
|
|
511
|
+
work.deadlineMs = recordWithWorkId.deadlineMs;
|
|
512
|
+
break;
|
|
513
|
+
case "retry-scheduled":
|
|
514
|
+
work.state = recordWithWorkId.retryAtMs <= recordWithWorkId.recordedAtMs ? "ready" : "retry-wait";
|
|
515
|
+
work.retryAtMs = recordWithWorkId.retryAtMs;
|
|
516
|
+
work.notBeforeMs = void 0;
|
|
517
|
+
break;
|
|
518
|
+
case "work-claimed":
|
|
519
|
+
work.state = "leased";
|
|
520
|
+
work.leaseId = recordWithWorkId.leaseId;
|
|
521
|
+
work.attempt = recordWithWorkId.attempt;
|
|
522
|
+
work.workerId = recordWithWorkId.workerId;
|
|
523
|
+
work.leaseExpiresAtMs = recordWithWorkId.leaseExpiresAtMs;
|
|
524
|
+
break;
|
|
525
|
+
case "lease-renewed":
|
|
526
|
+
work.state = "leased";
|
|
527
|
+
work.leaseId = recordWithWorkId.leaseId;
|
|
528
|
+
work.attempt = recordWithWorkId.attempt;
|
|
529
|
+
work.workerId = recordWithWorkId.workerId;
|
|
530
|
+
work.leaseExpiresAtMs = recordWithWorkId.leaseExpiresAtMs;
|
|
531
|
+
break;
|
|
532
|
+
case "work-released":
|
|
533
|
+
case "lease-expired":
|
|
534
|
+
work.state = "ready";
|
|
535
|
+
clearHandoffLease(work);
|
|
536
|
+
break;
|
|
537
|
+
case "work-completed":
|
|
538
|
+
work.state = "completed";
|
|
539
|
+
clearHandoffLease(work);
|
|
540
|
+
break;
|
|
541
|
+
case "work-canceled":
|
|
542
|
+
work.state = "canceled";
|
|
543
|
+
clearHandoffLease(work);
|
|
544
|
+
break;
|
|
545
|
+
case "work-dead-lettered":
|
|
546
|
+
work.state = "dead-lettered";
|
|
547
|
+
clearHandoffLease(work);
|
|
548
|
+
break;
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
function ensureHandoffWorkState(state, record) {
|
|
552
|
+
const key = handoffWorkKey(record.queueId, record.workId);
|
|
553
|
+
const existing = state.worksById.get(key);
|
|
554
|
+
if (existing !== void 0) return existing;
|
|
555
|
+
const next = {
|
|
556
|
+
queueId: record.queueId,
|
|
557
|
+
workId: record.workId,
|
|
558
|
+
state: "ready",
|
|
559
|
+
latestRecordSeq: record.recordSeq
|
|
560
|
+
};
|
|
561
|
+
state.worksById.set(key, next);
|
|
562
|
+
return next;
|
|
563
|
+
}
|
|
564
|
+
function handoffWorkKey(queueId, workId) {
|
|
565
|
+
return stableJsonStringify([queueId, workId]);
|
|
566
|
+
}
|
|
567
|
+
function clearHandoffLease(work) {
|
|
568
|
+
work.leaseId = void 0;
|
|
569
|
+
work.attempt = void 0;
|
|
570
|
+
work.workerId = void 0;
|
|
571
|
+
work.leaseExpiresAtMs = void 0;
|
|
572
|
+
}
|
|
573
|
+
function evaluateReadyHandoffs(ctx, state) {
|
|
574
|
+
for (const ready of state.readyByScheduleId.values()) {
|
|
575
|
+
const origin = state.originsByScheduleId.get(ready.scheduleId);
|
|
576
|
+
if (origin === void 0) {
|
|
577
|
+
emitHandoffStatus(
|
|
578
|
+
ctx,
|
|
579
|
+
state,
|
|
580
|
+
handoffStatus("pending-origin", {
|
|
581
|
+
scheduleId: ready.scheduleId,
|
|
582
|
+
readyAtMs: ready.readyAtMs,
|
|
583
|
+
nowMs: ready.nowMs,
|
|
584
|
+
sourceRefs: ready.sourceRefs
|
|
585
|
+
})
|
|
586
|
+
);
|
|
587
|
+
continue;
|
|
588
|
+
}
|
|
589
|
+
const work = state.worksById.get(handoffWorkKey(origin.record.queueId, origin.record.workId));
|
|
590
|
+
if (work === void 0) {
|
|
591
|
+
emitHandoffStatus(
|
|
592
|
+
ctx,
|
|
593
|
+
state,
|
|
594
|
+
handoffStatus("pending-origin", {
|
|
595
|
+
queueId: origin.record.queueId,
|
|
596
|
+
workId: origin.record.workId,
|
|
597
|
+
scheduleId: ready.scheduleId,
|
|
598
|
+
readyAtMs: ready.readyAtMs,
|
|
599
|
+
nowMs: ready.nowMs,
|
|
600
|
+
sourceRefs: ready.sourceRefs
|
|
601
|
+
})
|
|
602
|
+
);
|
|
603
|
+
continue;
|
|
604
|
+
}
|
|
605
|
+
if (origin.record.recordSeq < work.latestRecordSeq) {
|
|
606
|
+
emitSuperseded(ctx, state, origin, work, ready, {
|
|
607
|
+
latestRecordSeq: work.latestRecordSeq
|
|
608
|
+
});
|
|
609
|
+
continue;
|
|
610
|
+
}
|
|
611
|
+
const terminal = terminalHandoffState(work.state);
|
|
612
|
+
if (terminal) {
|
|
613
|
+
emitHandoffStatus(
|
|
614
|
+
ctx,
|
|
615
|
+
state,
|
|
616
|
+
handoffStatus("ignored-terminal", {
|
|
617
|
+
queueId: work.queueId,
|
|
618
|
+
workId: work.workId,
|
|
619
|
+
scheduleId: ready.scheduleId,
|
|
620
|
+
readyAtMs: ready.readyAtMs,
|
|
621
|
+
nowMs: ready.nowMs,
|
|
622
|
+
currentState: work.state,
|
|
623
|
+
sourceRefs: ready.sourceRefs
|
|
624
|
+
})
|
|
625
|
+
);
|
|
626
|
+
continue;
|
|
627
|
+
}
|
|
628
|
+
if (origin.scheduleKind === "lease-expiration") {
|
|
629
|
+
evaluateLeaseExpirationReady(ctx, state, origin, work, ready);
|
|
630
|
+
continue;
|
|
631
|
+
}
|
|
632
|
+
evaluateClaimEligibilityReady(ctx, state, origin, work, ready);
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
function evaluateClaimEligibilityReady(ctx, state, origin, work, ready) {
|
|
636
|
+
if (work.state === "leased") {
|
|
637
|
+
emitHandoffStatus(
|
|
638
|
+
ctx,
|
|
639
|
+
state,
|
|
640
|
+
handoffStatus("ignored-stale", {
|
|
641
|
+
queueId: work.queueId,
|
|
642
|
+
workId: work.workId,
|
|
643
|
+
scheduleId: ready.scheduleId,
|
|
644
|
+
readyAtMs: ready.readyAtMs,
|
|
645
|
+
nowMs: ready.nowMs,
|
|
646
|
+
currentState: work.state,
|
|
647
|
+
sourceRefs: ready.sourceRefs
|
|
648
|
+
})
|
|
649
|
+
);
|
|
650
|
+
return;
|
|
651
|
+
}
|
|
652
|
+
if (work.notBeforeMs !== void 0 && work.notBeforeMs > ready.nowMs) {
|
|
653
|
+
emitSuperseded(ctx, state, origin, work, ready, { notBeforeMs: work.notBeforeMs });
|
|
654
|
+
return;
|
|
655
|
+
}
|
|
656
|
+
if (work.retryAtMs !== void 0 && work.retryAtMs > ready.nowMs) {
|
|
657
|
+
emitSuperseded(ctx, state, origin, work, ready, { retryAtMs: work.retryAtMs });
|
|
658
|
+
return;
|
|
659
|
+
}
|
|
660
|
+
emitCandidate(ctx, state, candidateFor(origin, ready, "claim-eligible"));
|
|
661
|
+
}
|
|
662
|
+
function evaluateLeaseExpirationReady(ctx, state, origin, work, ready) {
|
|
663
|
+
if (origin.record.kind !== "work-claimed" && origin.record.kind !== "lease-renewed") {
|
|
664
|
+
emitHandoffIssue(
|
|
665
|
+
ctx,
|
|
666
|
+
state,
|
|
667
|
+
dataIssue(
|
|
668
|
+
"work-queue-readiness-handoff-malformed-origin",
|
|
669
|
+
"Lease-expiration readiness must originate from a lease-bearing workQueue record.",
|
|
670
|
+
{ subjectId: ready.scheduleId, refs: ready.sourceRefs }
|
|
671
|
+
)
|
|
672
|
+
);
|
|
673
|
+
return;
|
|
674
|
+
}
|
|
675
|
+
if (work.state !== "leased" || work.leaseId !== origin.record.leaseId || work.attempt !== origin.record.attempt || work.workerId !== origin.record.workerId) {
|
|
676
|
+
emitHandoffStatus(
|
|
677
|
+
ctx,
|
|
678
|
+
state,
|
|
679
|
+
handoffStatus("ignored-stale", {
|
|
680
|
+
queueId: work.queueId,
|
|
681
|
+
workId: work.workId,
|
|
682
|
+
scheduleId: ready.scheduleId,
|
|
683
|
+
readyAtMs: ready.readyAtMs,
|
|
684
|
+
nowMs: ready.nowMs,
|
|
685
|
+
currentState: work.state,
|
|
686
|
+
sourceRefs: ready.sourceRefs
|
|
687
|
+
})
|
|
688
|
+
);
|
|
689
|
+
return;
|
|
690
|
+
}
|
|
691
|
+
if (work.leaseExpiresAtMs !== origin.record.leaseExpiresAtMs) {
|
|
692
|
+
emitSuperseded(ctx, state, origin, work, ready, {
|
|
693
|
+
leaseExpiresAtMs: work.leaseExpiresAtMs
|
|
694
|
+
});
|
|
695
|
+
return;
|
|
696
|
+
}
|
|
697
|
+
if (work.leaseExpiresAtMs !== void 0 && work.leaseExpiresAtMs > ready.nowMs) {
|
|
698
|
+
emitSuperseded(ctx, state, origin, work, ready, {
|
|
699
|
+
leaseExpiresAtMs: work.leaseExpiresAtMs
|
|
700
|
+
});
|
|
701
|
+
return;
|
|
702
|
+
}
|
|
703
|
+
emitCandidate(ctx, state, candidateFor(origin, ready, "lease-expiration-eligible"));
|
|
704
|
+
}
|
|
705
|
+
function emitSuperseded(ctx, state, origin, work, ready, metadata) {
|
|
706
|
+
emitHandoffStatus(
|
|
707
|
+
ctx,
|
|
708
|
+
state,
|
|
709
|
+
handoffStatus("ignored-superseded", {
|
|
710
|
+
queueId: work.queueId,
|
|
711
|
+
workId: work.workId,
|
|
712
|
+
scheduleId: ready.scheduleId,
|
|
713
|
+
readyAtMs: ready.readyAtMs,
|
|
714
|
+
nowMs: ready.nowMs,
|
|
715
|
+
currentState: work.state,
|
|
716
|
+
sourceRefs: ready.sourceRefs,
|
|
717
|
+
metadata: {
|
|
718
|
+
originRecordSeq: origin.record.recordSeq,
|
|
719
|
+
originRecordKind: origin.record.kind,
|
|
720
|
+
...metadata
|
|
721
|
+
}
|
|
722
|
+
})
|
|
723
|
+
);
|
|
724
|
+
}
|
|
725
|
+
function candidateFor(origin, ready, candidateKind) {
|
|
726
|
+
const lease = origin.record.kind === "work-claimed" || origin.record.kind === "lease-renewed" ? {
|
|
727
|
+
leaseId: origin.record.leaseId,
|
|
728
|
+
attempt: origin.record.attempt,
|
|
729
|
+
workerId: origin.record.workerId,
|
|
730
|
+
leaseExpiresAtMs: origin.record.leaseExpiresAtMs
|
|
731
|
+
} : {};
|
|
732
|
+
const metadata = sanitizeGraphVisibleRecord({
|
|
733
|
+
originRecordSeq: origin.record.recordSeq,
|
|
734
|
+
originRecordKind: origin.record.kind,
|
|
735
|
+
scheduleKind: origin.scheduleKind
|
|
736
|
+
});
|
|
737
|
+
return Object.freeze({
|
|
738
|
+
kind: "work-queue-readiness-candidate",
|
|
739
|
+
candidateId: `${ready.scheduleId}:work-queue:${candidateKind}`,
|
|
740
|
+
candidateKind,
|
|
741
|
+
queueId: origin.record.queueId,
|
|
742
|
+
workId: origin.record.workId,
|
|
743
|
+
scheduleId: ready.scheduleId,
|
|
744
|
+
readyAtMs: ready.readyAtMs,
|
|
745
|
+
nowMs: ready.nowMs,
|
|
746
|
+
originRecordSeq: origin.record.recordSeq,
|
|
747
|
+
originRecordKind: origin.record.kind,
|
|
748
|
+
...lease,
|
|
749
|
+
sourceRefs: canonicalPublicSourceRefs(
|
|
750
|
+
uniqueSourceRefs([
|
|
751
|
+
...ready.sourceRefs ?? [],
|
|
752
|
+
ref("work-queue-record", String(origin.record.recordSeq)),
|
|
753
|
+
ref("scheduled-readiness-ready", ready.scheduleId)
|
|
754
|
+
])
|
|
755
|
+
),
|
|
756
|
+
...metadata === void 0 ? {} : { metadata }
|
|
757
|
+
});
|
|
758
|
+
}
|
|
759
|
+
function emitCandidate(ctx, state, candidate) {
|
|
760
|
+
const key = `candidate:${candidate.candidateId}`;
|
|
761
|
+
if (!state.emittedKeys.has(key)) {
|
|
762
|
+
state.emittedKeys.add(key);
|
|
763
|
+
state.candidatesById.set(candidate.candidateId, candidate);
|
|
764
|
+
ctx.down([["DATA", { kind: "candidate", candidate }]]);
|
|
765
|
+
emitHandoffAudit(ctx, state, "work-queue-readiness-candidate", {
|
|
766
|
+
subjectId: candidate.candidateId,
|
|
767
|
+
sourceRefs: candidate.sourceRefs,
|
|
768
|
+
metadata: {
|
|
769
|
+
candidateKind: candidate.candidateKind,
|
|
770
|
+
queueId: candidate.queueId,
|
|
771
|
+
workId: candidate.workId,
|
|
772
|
+
readyAtMs: candidate.readyAtMs,
|
|
773
|
+
nowMs: candidate.nowMs
|
|
774
|
+
}
|
|
775
|
+
});
|
|
776
|
+
} else {
|
|
777
|
+
state.candidatesById.set(candidate.candidateId, candidate);
|
|
778
|
+
}
|
|
779
|
+
emitHandoffStatus(
|
|
780
|
+
ctx,
|
|
781
|
+
state,
|
|
782
|
+
handoffStatus("candidate", {
|
|
783
|
+
queueId: candidate.queueId,
|
|
784
|
+
workId: candidate.workId,
|
|
785
|
+
scheduleId: candidate.scheduleId,
|
|
786
|
+
candidateId: candidate.candidateId,
|
|
787
|
+
candidateKind: candidate.candidateKind,
|
|
788
|
+
readyAtMs: candidate.readyAtMs,
|
|
789
|
+
nowMs: candidate.nowMs,
|
|
790
|
+
sourceRefs: candidate.sourceRefs
|
|
791
|
+
})
|
|
792
|
+
);
|
|
793
|
+
}
|
|
794
|
+
function emitOverdueHandoffStatus(ctx, state, overdue) {
|
|
795
|
+
const origin = state.originsByScheduleId.get(overdue.scheduleId);
|
|
796
|
+
emitHandoffStatus(
|
|
797
|
+
ctx,
|
|
798
|
+
state,
|
|
799
|
+
handoffStatus("overdue", {
|
|
800
|
+
queueId: origin?.record.queueId,
|
|
801
|
+
workId: origin?.record.workId,
|
|
802
|
+
scheduleId: overdue.scheduleId,
|
|
803
|
+
readyAtMs: overdue.readyAtMs,
|
|
804
|
+
nowMs: overdue.nowMs,
|
|
805
|
+
sourceRefs: overdue.sourceRefs,
|
|
806
|
+
metadata: {
|
|
807
|
+
deadlineMs: overdue.deadlineMs,
|
|
808
|
+
...origin === void 0 ? {} : { originRecordSeq: origin.record.recordSeq, originRecordKind: origin.record.kind }
|
|
809
|
+
}
|
|
810
|
+
})
|
|
811
|
+
);
|
|
812
|
+
}
|
|
813
|
+
function handoffStatus(state, opts) {
|
|
814
|
+
const subject = opts.candidateId ?? opts.scheduleId ?? "unknown-work-queue-readiness";
|
|
815
|
+
const metadata = sanitizeGraphVisibleRecord(opts.metadata);
|
|
816
|
+
return Object.freeze({
|
|
817
|
+
kind: "work-queue-readiness-handoff-status",
|
|
818
|
+
statusId: `${subject}:work-queue-readiness-handoff-status:${state}`,
|
|
819
|
+
state,
|
|
820
|
+
...opts.queueId === void 0 ? {} : { queueId: opts.queueId },
|
|
821
|
+
...opts.workId === void 0 ? {} : { workId: opts.workId },
|
|
822
|
+
...opts.scheduleId === void 0 ? {} : { scheduleId: opts.scheduleId },
|
|
823
|
+
...opts.candidateId === void 0 ? {} : { candidateId: opts.candidateId },
|
|
824
|
+
...opts.candidateKind === void 0 ? {} : { candidateKind: opts.candidateKind },
|
|
825
|
+
...opts.readyAtMs === void 0 ? {} : { readyAtMs: opts.readyAtMs },
|
|
826
|
+
...opts.nowMs === void 0 ? {} : { nowMs: opts.nowMs },
|
|
827
|
+
...opts.currentState === void 0 ? {} : { currentState: opts.currentState },
|
|
828
|
+
...opts.sourceRefs === void 0 ? {} : { sourceRefs: canonicalPublicSourceRefs(opts.sourceRefs) },
|
|
829
|
+
...opts.issueCodes === void 0 ? {} : { issueCodes: opts.issueCodes },
|
|
830
|
+
...metadata === void 0 ? {} : { metadata }
|
|
831
|
+
});
|
|
832
|
+
}
|
|
833
|
+
function emitHandoffStatus(ctx, state, status) {
|
|
834
|
+
state.statusById.set(status.statusId, status);
|
|
835
|
+
const key = `handoff-status:${status.statusId}:${stableJsonStringify(status)}`;
|
|
836
|
+
if (state.emittedKeys.has(key)) return;
|
|
837
|
+
state.emittedKeys.add(key);
|
|
838
|
+
ctx.down([["DATA", { kind: "status", status }]]);
|
|
839
|
+
}
|
|
840
|
+
function emitHandoffIssue(ctx, state, issue) {
|
|
841
|
+
const key = `${issue.code}:${issue.subjectId ?? ""}:${JSON.stringify(issue.details ?? {})}`;
|
|
842
|
+
if (state.issueKeys.has(key)) return;
|
|
843
|
+
state.issueKeys.add(key);
|
|
844
|
+
ctx.down([["DATA", { kind: "issue", issue }]]);
|
|
845
|
+
emitHandoffStatus(
|
|
846
|
+
ctx,
|
|
847
|
+
state,
|
|
848
|
+
handoffStatus("issue", {
|
|
849
|
+
scheduleId: issue.subjectId,
|
|
850
|
+
sourceRefs: issue.refs?.map(sourceRefFromIssueRef),
|
|
851
|
+
issueCodes: [issue.code]
|
|
852
|
+
})
|
|
853
|
+
);
|
|
854
|
+
}
|
|
855
|
+
function emitHandoffAudit(ctx, state, kind, opts) {
|
|
856
|
+
state.auditSeq += 1;
|
|
857
|
+
const metadata = sanitizeGraphVisibleRecord(opts.metadata);
|
|
858
|
+
ctx.down([
|
|
859
|
+
[
|
|
860
|
+
"DATA",
|
|
861
|
+
{
|
|
862
|
+
kind: "audit",
|
|
863
|
+
audit: Object.freeze({
|
|
864
|
+
id: `work-queue-readiness-handoff-audit-${state.auditSeq}`,
|
|
865
|
+
kind,
|
|
866
|
+
subjectId: opts.subjectId,
|
|
867
|
+
...opts.sourceRefs === void 0 ? {} : { sourceRefs: canonicalPublicSourceRefs(opts.sourceRefs) },
|
|
868
|
+
...metadata === void 0 ? {} : { metadata }
|
|
869
|
+
})
|
|
870
|
+
}
|
|
871
|
+
]
|
|
872
|
+
]);
|
|
873
|
+
}
|
|
874
|
+
function buildHandoffViews(state) {
|
|
875
|
+
return Object.freeze({
|
|
876
|
+
candidatesById: new Map(state.candidatesById),
|
|
877
|
+
statusById: new Map(state.statusById)
|
|
878
|
+
});
|
|
879
|
+
}
|
|
880
|
+
function emitLeaseCommandStatus(ctx, state, command, candidate) {
|
|
881
|
+
const status = handoffStatus("candidate", {
|
|
882
|
+
queueId: candidate.queueId,
|
|
883
|
+
workId: candidate.workId,
|
|
884
|
+
scheduleId: candidate.scheduleId,
|
|
885
|
+
candidateId: candidate.candidateId,
|
|
886
|
+
candidateKind: candidate.candidateKind,
|
|
887
|
+
readyAtMs: candidate.readyAtMs,
|
|
888
|
+
nowMs: candidate.nowMs,
|
|
889
|
+
sourceRefs: candidate.sourceRefs,
|
|
890
|
+
metadata: {
|
|
891
|
+
commandId: command.commandId,
|
|
892
|
+
commandKind: command.kind
|
|
893
|
+
}
|
|
894
|
+
});
|
|
895
|
+
state.statusById.set(status.statusId, status);
|
|
896
|
+
const key = `lease-command-status:${status.statusId}`;
|
|
897
|
+
if (state.emittedKeys.has(key)) return;
|
|
898
|
+
state.emittedKeys.add(key);
|
|
899
|
+
ctx.down([["DATA", { kind: "status", status }]]);
|
|
900
|
+
}
|
|
901
|
+
function buildLeaseCommandViews(state) {
|
|
902
|
+
return Object.freeze({
|
|
903
|
+
candidatesById: /* @__PURE__ */ new Map(),
|
|
904
|
+
statusById: new Map(state.statusById)
|
|
905
|
+
});
|
|
906
|
+
}
|
|
907
|
+
function sourceRefStrings(sourceRefs) {
|
|
908
|
+
if (sourceRefs === void 0 || sourceRefs.length === 0) return void 0;
|
|
909
|
+
return sourceRefs.map((sourceRef) => `${sourceRef.kind}:${sourceRef.id}`);
|
|
910
|
+
}
|
|
911
|
+
function sourceRefFromIssueRef(issueRef) {
|
|
912
|
+
const [kind, ...rest] = issueRef.split(":");
|
|
913
|
+
return ref(kind || "issue-ref", rest.join(":") || issueRef);
|
|
914
|
+
}
|
|
915
|
+
function terminalHandoffState(state) {
|
|
916
|
+
return state === "completed" || state === "canceled" || state === "dead-lettered";
|
|
917
|
+
}
|
|
918
|
+
function hasWorkRecordCoordinates(record) {
|
|
919
|
+
return typeof record.queueId === "string" && typeof record.workId === "string" && typeof record.recordSeq === "number" && Number.isFinite(record.recordSeq);
|
|
920
|
+
}
|
|
921
|
+
function hasLeaseRecordCoordinates(record) {
|
|
922
|
+
return hasWorkRecordCoordinates(record) && typeof record.leaseId === "string" && typeof record.attempt === "number" && Number.isFinite(record.attempt) && typeof record.workerId === "string";
|
|
923
|
+
}
|
|
924
|
+
function malformedRecord(record, message) {
|
|
925
|
+
const subjectId = typeof record.kind === "string" ? `work-queue-record:${publicCoordinateId(record.kind)}` : "unknown-work-queue-record";
|
|
926
|
+
const issue = dataIssue("work-queue-scheduled-readiness-malformed-record", message, {
|
|
927
|
+
subjectId,
|
|
928
|
+
refs: [],
|
|
929
|
+
details: sanitizeGraphVisibleRecord({
|
|
930
|
+
recordKind: typeof record.kind === "string" ? record.kind : void 0,
|
|
931
|
+
queueId: typeof record.queueId === "string" ? publicCoordinateId(record.queueId) : void 0,
|
|
932
|
+
workId: typeof record.workId === "string" ? publicCoordinateId(record.workId) : void 0,
|
|
933
|
+
recordSeq: typeof record.recordSeq === "number" && Number.isFinite(record.recordSeq) ? record.recordSeq : void 0
|
|
934
|
+
})
|
|
935
|
+
});
|
|
936
|
+
return {
|
|
937
|
+
kind: "issue",
|
|
938
|
+
issue,
|
|
939
|
+
status: issueStatus(subjectId, [issue])
|
|
940
|
+
};
|
|
941
|
+
}
|
|
942
|
+
function translateRecord(raw) {
|
|
943
|
+
if (!isRecord(raw)) {
|
|
944
|
+
const issue = dataIssue(
|
|
945
|
+
"work-queue-scheduled-readiness-malformed-record",
|
|
946
|
+
"WorkQueue scheduled readiness requires a graph-visible workQueue record.",
|
|
947
|
+
{ subjectId: "unknown-work-queue-record", refs: [] }
|
|
948
|
+
);
|
|
949
|
+
return {
|
|
950
|
+
kind: "issue",
|
|
951
|
+
issue,
|
|
952
|
+
status: issueStatus("unknown-work-queue-record", [issue])
|
|
953
|
+
};
|
|
954
|
+
}
|
|
955
|
+
const unknownRecord = raw;
|
|
956
|
+
const rawRecord = unknownRecord;
|
|
957
|
+
switch (rawRecord.kind) {
|
|
958
|
+
case "work-admitted": {
|
|
959
|
+
const notBeforeMs = rawRecord.notBeforeMs;
|
|
960
|
+
if (notBeforeMs === void 0) return { kind: "none" };
|
|
961
|
+
if (typeof notBeforeMs !== "number") {
|
|
962
|
+
return malformedRecord(rawRecord, "Delayed work-admitted notBeforeMs must be a number.");
|
|
963
|
+
}
|
|
964
|
+
if (!hasWorkRecordCoordinates(rawRecord)) {
|
|
965
|
+
return malformedRecord(
|
|
966
|
+
rawRecord,
|
|
967
|
+
"Delayed work-admitted records require queueId, workId, and recordSeq."
|
|
968
|
+
);
|
|
969
|
+
}
|
|
970
|
+
const admitted = rawRecord;
|
|
971
|
+
return scheduleFromRecord(admitted, {
|
|
972
|
+
scheduleKind: "work-admitted",
|
|
973
|
+
scheduleId: workQueueScheduleId(admitted, "admission", admitted.recordSeq),
|
|
974
|
+
readyAtMs: notBeforeMs,
|
|
975
|
+
deadlineMs: admitted.deadlineMs,
|
|
976
|
+
reason: "work-queue-delayed-admission"
|
|
977
|
+
});
|
|
978
|
+
}
|
|
979
|
+
case "work-scheduled": {
|
|
980
|
+
if (!hasWorkRecordCoordinates(rawRecord)) {
|
|
981
|
+
return malformedRecord(
|
|
982
|
+
rawRecord,
|
|
983
|
+
"work-scheduled records require queueId, workId, and recordSeq."
|
|
984
|
+
);
|
|
985
|
+
}
|
|
986
|
+
const scheduled = rawRecord;
|
|
987
|
+
return scheduleFromRecord(scheduled, {
|
|
988
|
+
scheduleKind: "work-scheduled",
|
|
989
|
+
scheduleId: workQueueScheduleId(
|
|
990
|
+
scheduled,
|
|
991
|
+
"schedule",
|
|
992
|
+
scheduled.scheduleId ?? scheduled.commandId ?? scheduled.recordSeq
|
|
993
|
+
),
|
|
994
|
+
readyAtMs: scheduled.notBeforeMs,
|
|
995
|
+
deadlineMs: scheduled.deadlineMs,
|
|
996
|
+
reason: scheduled.reason ?? "work-queue-schedule"
|
|
997
|
+
});
|
|
998
|
+
}
|
|
999
|
+
case "retry-scheduled": {
|
|
1000
|
+
if (!hasWorkRecordCoordinates(rawRecord)) {
|
|
1001
|
+
return malformedRecord(
|
|
1002
|
+
rawRecord,
|
|
1003
|
+
"retry-scheduled records require queueId, workId, and recordSeq."
|
|
1004
|
+
);
|
|
1005
|
+
}
|
|
1006
|
+
const retry = rawRecord;
|
|
1007
|
+
return scheduleFromRecord(retry, {
|
|
1008
|
+
scheduleKind: "retry-scheduled",
|
|
1009
|
+
scheduleId: workQueueScheduleId(retry, "retry", retry.commandId ?? retry.recordSeq),
|
|
1010
|
+
readyAtMs: retry.retryAtMs,
|
|
1011
|
+
reason: retry.reason ?? "work-queue-retry",
|
|
1012
|
+
metadata: { delayMs: retry.delayMs }
|
|
1013
|
+
});
|
|
1014
|
+
}
|
|
1015
|
+
case "work-claimed": {
|
|
1016
|
+
if (!hasLeaseRecordCoordinates(rawRecord)) {
|
|
1017
|
+
return malformedRecord(
|
|
1018
|
+
rawRecord,
|
|
1019
|
+
"work-claimed records require queueId, workId, recordSeq, leaseId, attempt, and workerId."
|
|
1020
|
+
);
|
|
1021
|
+
}
|
|
1022
|
+
const claimed = rawRecord;
|
|
1023
|
+
return scheduleFromRecord(claimed, {
|
|
1024
|
+
scheduleKind: "lease-expiration",
|
|
1025
|
+
scheduleId: workQueueLeaseScheduleId(claimed),
|
|
1026
|
+
readyAtMs: claimed.leaseExpiresAtMs,
|
|
1027
|
+
reason: "work-queue-lease-expiration",
|
|
1028
|
+
leaseId: claimed.leaseId,
|
|
1029
|
+
metadata: { attempt: claimed.attempt }
|
|
1030
|
+
});
|
|
1031
|
+
}
|
|
1032
|
+
case "lease-renewed": {
|
|
1033
|
+
if (!hasLeaseRecordCoordinates(rawRecord)) {
|
|
1034
|
+
return malformedRecord(
|
|
1035
|
+
rawRecord,
|
|
1036
|
+
"lease-renewed records require queueId, workId, recordSeq, leaseId, attempt, and workerId."
|
|
1037
|
+
);
|
|
1038
|
+
}
|
|
1039
|
+
const renewed = rawRecord;
|
|
1040
|
+
return scheduleFromRecord(renewed, {
|
|
1041
|
+
scheduleKind: "lease-expiration",
|
|
1042
|
+
scheduleId: workQueueLeaseScheduleId(renewed),
|
|
1043
|
+
readyAtMs: renewed.leaseExpiresAtMs,
|
|
1044
|
+
reason: "work-queue-lease-expiration",
|
|
1045
|
+
leaseId: renewed.leaseId,
|
|
1046
|
+
metadata: {
|
|
1047
|
+
attempt: renewed.attempt,
|
|
1048
|
+
previousLeaseExpiresAtMs: renewed.previousLeaseExpiresAtMs
|
|
1049
|
+
}
|
|
1050
|
+
});
|
|
1051
|
+
}
|
|
1052
|
+
default:
|
|
1053
|
+
return { kind: "none" };
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
1056
|
+
function scheduleFromRecord(record, opts) {
|
|
1057
|
+
if (!Number.isFinite(opts.readyAtMs) || !finiteOrUndefined(opts.deadlineMs)) {
|
|
1058
|
+
const refs = recordSourceRefs(record, opts.leaseId);
|
|
1059
|
+
const issue = dataIssue(
|
|
1060
|
+
"work-queue-scheduled-readiness-malformed-record",
|
|
1061
|
+
"WorkQueue delayed eligibility record must carry finite readiness and deadline coordinates.",
|
|
1062
|
+
{
|
|
1063
|
+
subjectId: workQueueRecordSubjectId(record),
|
|
1064
|
+
refs,
|
|
1065
|
+
details: {
|
|
1066
|
+
recordKind: record.kind,
|
|
1067
|
+
readyAtMs: opts.readyAtMs,
|
|
1068
|
+
deadlineMs: opts.deadlineMs
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
);
|
|
1072
|
+
return {
|
|
1073
|
+
kind: "issue",
|
|
1074
|
+
issue,
|
|
1075
|
+
status: issueStatus(opts.scheduleId, [issue], record, refs)
|
|
1076
|
+
};
|
|
1077
|
+
}
|
|
1078
|
+
const subjectRefs = recordSubjectRefs(record, opts.leaseId);
|
|
1079
|
+
const sourceRefs = recordSourceRefs(record, opts.leaseId);
|
|
1080
|
+
const recordPolicyRefs = policyRefs(record);
|
|
1081
|
+
const metadata = sanitizeGraphVisibleRecord({
|
|
1082
|
+
queueId: publicCoordinateId(record.queueId),
|
|
1083
|
+
workId: publicCoordinateId(record.workId),
|
|
1084
|
+
recordSeq: record.recordSeq,
|
|
1085
|
+
recordKind: record.kind,
|
|
1086
|
+
scheduleKind: opts.scheduleKind,
|
|
1087
|
+
...record.commandId === void 0 ? {} : { commandId: publicCoordinateId(record.commandId) },
|
|
1088
|
+
...opts.leaseId === void 0 ? {} : { leaseId: publicCoordinateId(opts.leaseId) },
|
|
1089
|
+
...opts.metadata ?? {}
|
|
1090
|
+
});
|
|
1091
|
+
const schedule = Object.freeze({
|
|
1092
|
+
kind: "scheduled-readiness-requested",
|
|
1093
|
+
scheduleId: opts.scheduleId,
|
|
1094
|
+
subjectRefs,
|
|
1095
|
+
readyAtMs: opts.readyAtMs,
|
|
1096
|
+
...opts.deadlineMs === void 0 ? {} : { deadlineMs: opts.deadlineMs },
|
|
1097
|
+
reason: opts.reason,
|
|
1098
|
+
...recordPolicyRefs === void 0 ? {} : { policyRefs: recordPolicyRefs },
|
|
1099
|
+
sourceRefs,
|
|
1100
|
+
...metadata === void 0 ? {} : { metadata }
|
|
1101
|
+
});
|
|
1102
|
+
return {
|
|
1103
|
+
kind: "translated",
|
|
1104
|
+
record,
|
|
1105
|
+
schedule,
|
|
1106
|
+
status: Object.freeze({
|
|
1107
|
+
kind: "work-queue-scheduled-readiness-status",
|
|
1108
|
+
statusId: `${opts.scheduleId}:work-queue-scheduled-readiness-status:translated`,
|
|
1109
|
+
queueId: publicCoordinateId(record.queueId),
|
|
1110
|
+
workId: publicCoordinateId(record.workId),
|
|
1111
|
+
recordSeq: record.recordSeq,
|
|
1112
|
+
state: "translated",
|
|
1113
|
+
scheduleKind: opts.scheduleKind,
|
|
1114
|
+
scheduleId: opts.scheduleId,
|
|
1115
|
+
readyAtMs: opts.readyAtMs,
|
|
1116
|
+
...opts.deadlineMs === void 0 ? {} : { deadlineMs: opts.deadlineMs },
|
|
1117
|
+
sourceRefs,
|
|
1118
|
+
...metadata === void 0 ? {} : { metadata }
|
|
1119
|
+
})
|
|
1120
|
+
};
|
|
1121
|
+
}
|
|
1122
|
+
function recordSubjectRefs(record, leaseId) {
|
|
1123
|
+
return canonicalPublicSourceRefs(
|
|
1124
|
+
uniqueSourceRefs([
|
|
1125
|
+
ref("work-queue", publicCoordinateId(record.queueId)),
|
|
1126
|
+
ref("work-queue-work", publicCoordinateId(record.workId)),
|
|
1127
|
+
ref("work-queue-record", String(record.recordSeq)),
|
|
1128
|
+
...record.commandId === void 0 ? [] : [ref("work-queue-command", publicCoordinateId(record.commandId))],
|
|
1129
|
+
...leaseId === void 0 ? [] : [ref("work-queue-lease", publicCoordinateId(leaseId))]
|
|
1130
|
+
])
|
|
1131
|
+
);
|
|
1132
|
+
}
|
|
1133
|
+
function recordSourceRefs(record, leaseId) {
|
|
1134
|
+
return canonicalPublicSourceRefs(
|
|
1135
|
+
uniqueSourceRefs([
|
|
1136
|
+
ref("work-queue", publicCoordinateId(record.queueId)),
|
|
1137
|
+
ref("work-queue-record", String(record.recordSeq)),
|
|
1138
|
+
...record.workId === void 0 ? [] : [ref("work-queue-work", publicCoordinateId(record.workId))],
|
|
1139
|
+
...record.commandId === void 0 ? [] : [ref("work-queue-command", publicCoordinateId(record.commandId))],
|
|
1140
|
+
...leaseId === void 0 ? [] : [ref("work-queue-lease", publicCoordinateId(leaseId))],
|
|
1141
|
+
...copiedPublicRefs(record.sourceRefs, "work-queue-source-ref")
|
|
1142
|
+
])
|
|
1143
|
+
);
|
|
1144
|
+
}
|
|
1145
|
+
function policyRefs(record) {
|
|
1146
|
+
if (record.policyRefs === void 0 || record.policyRefs.length === 0) return void 0;
|
|
1147
|
+
return canonicalPublicSourceRefs(copiedPublicRefs(record.policyRefs, "work-queue-policy-ref"));
|
|
1148
|
+
}
|
|
1149
|
+
function workQueueScheduleId(record, part, id) {
|
|
1150
|
+
return `workQueue:${publicCoordinateId(record.queueId)}:${publicCoordinateId(record.workId)}:${part}:${publicCoordinateId(String(id))}`;
|
|
1151
|
+
}
|
|
1152
|
+
function workQueueLeaseScheduleId(record) {
|
|
1153
|
+
return `workQueue:${publicCoordinateId(record.queueId)}:${publicCoordinateId(record.workId)}:lease:${publicCoordinateId(record.leaseId)}:expires:${record.recordSeq}`;
|
|
1154
|
+
}
|
|
1155
|
+
function workQueueRecordSubjectId(record) {
|
|
1156
|
+
return `${publicCoordinateId(record.queueId)}:${publicCoordinateId(record.workId)}:${record.recordSeq}`;
|
|
1157
|
+
}
|
|
1158
|
+
function copiedPublicRefs(ids, kind) {
|
|
1159
|
+
if (ids === void 0 || ids.length === 0) return [];
|
|
1160
|
+
const copied = ids.slice(0, MAX_COPIED_PUBLIC_REFS).map((id) => ref(kind, publicCoordinateId(id)));
|
|
1161
|
+
if (ids.length <= MAX_COPIED_PUBLIC_REFS) return copied;
|
|
1162
|
+
return [
|
|
1163
|
+
...copied,
|
|
1164
|
+
ref(
|
|
1165
|
+
`${kind}-overflow`,
|
|
1166
|
+
`count:${ids.length}:hash:${stableStringHash(stableJsonStringify(ids))}`
|
|
1167
|
+
)
|
|
1168
|
+
];
|
|
1169
|
+
}
|
|
1170
|
+
function publicCoordinateId(id) {
|
|
1171
|
+
if (id.length <= MAX_PUBLIC_COORDINATE_ID_CHARS && !PRIVATE_COORDINATE_PATTERN.test(id)) {
|
|
1172
|
+
return id;
|
|
1173
|
+
}
|
|
1174
|
+
return `bounded:${stableStringHash(id)}:${id.length}`;
|
|
1175
|
+
}
|
|
1176
|
+
function issueStatus(statusId, issues, record, sourceRefs) {
|
|
1177
|
+
return Object.freeze({
|
|
1178
|
+
kind: "work-queue-scheduled-readiness-status",
|
|
1179
|
+
statusId: `${statusId}:work-queue-scheduled-readiness-status:issue`,
|
|
1180
|
+
...record?.queueId === void 0 ? {} : { queueId: publicCoordinateId(record.queueId) },
|
|
1181
|
+
...record?.workId === void 0 ? {} : { workId: publicCoordinateId(record.workId) },
|
|
1182
|
+
...record?.recordSeq === void 0 ? {} : { recordSeq: record.recordSeq },
|
|
1183
|
+
state: "issue",
|
|
1184
|
+
...sourceRefs === void 0 ? {} : { sourceRefs },
|
|
1185
|
+
issueCodes: issues.map((issue) => issue.code)
|
|
1186
|
+
});
|
|
1187
|
+
}
|
|
1188
|
+
function finiteOrUndefined(value) {
|
|
1189
|
+
return value === void 0 || Number.isFinite(value);
|
|
1190
|
+
}
|
|
1191
|
+
function scheduleIdentity(schedule) {
|
|
1192
|
+
return stableJsonStringify({
|
|
1193
|
+
scheduleId: schedule.scheduleId,
|
|
1194
|
+
subjectRefs: schedule.subjectRefs,
|
|
1195
|
+
readyAtMs: schedule.readyAtMs,
|
|
1196
|
+
deadlineMs: schedule.deadlineMs,
|
|
1197
|
+
reason: schedule.reason,
|
|
1198
|
+
policyRefs: schedule.policyRefs,
|
|
1199
|
+
sourceRefs: schedule.sourceRefs,
|
|
1200
|
+
metadata: schedule.metadata
|
|
1201
|
+
});
|
|
1202
|
+
}
|
|
1203
|
+
function emitScheduleConflict(ctx, state, translated, existing) {
|
|
1204
|
+
const issue = dataIssue(
|
|
1205
|
+
"work-queue-scheduled-readiness-schedule-conflict",
|
|
1206
|
+
"WorkQueue delayed eligibility replayed with conflicting scheduled-readiness material; the first schedule was retained.",
|
|
1207
|
+
{
|
|
1208
|
+
subjectId: translated.schedule.scheduleId,
|
|
1209
|
+
refs: translated.schedule.sourceRefs,
|
|
1210
|
+
details: {
|
|
1211
|
+
existingReadyAtMs: existing?.readyAtMs,
|
|
1212
|
+
incomingReadyAtMs: translated.schedule.readyAtMs,
|
|
1213
|
+
existingDeadlineMs: existing?.deadlineMs,
|
|
1214
|
+
incomingDeadlineMs: translated.schedule.deadlineMs,
|
|
1215
|
+
recordSeq: translated.record.recordSeq,
|
|
1216
|
+
recordKind: translated.record.kind
|
|
1217
|
+
}
|
|
1218
|
+
}
|
|
1219
|
+
);
|
|
1220
|
+
emitIssue(ctx, state, issue);
|
|
1221
|
+
emitStatus(
|
|
1222
|
+
ctx,
|
|
1223
|
+
state,
|
|
1224
|
+
issueStatus(
|
|
1225
|
+
`${translated.schedule.scheduleId}:conflict:${translated.record.recordSeq}`,
|
|
1226
|
+
[issue],
|
|
1227
|
+
translated.record,
|
|
1228
|
+
translated.schedule.sourceRefs
|
|
1229
|
+
)
|
|
1230
|
+
);
|
|
1231
|
+
}
|
|
1232
|
+
function emitSchedule(ctx, state, schedule) {
|
|
1233
|
+
const key = `schedule:${schedule.scheduleId}`;
|
|
1234
|
+
if (state.emittedKeys.has(key)) return;
|
|
1235
|
+
state.emittedKeys.add(key);
|
|
1236
|
+
ctx.down([["DATA", { kind: "readiness-schedule", schedule }]]);
|
|
1237
|
+
}
|
|
1238
|
+
function emitStatus(ctx, state, status) {
|
|
1239
|
+
state.statusById.set(status.statusId, status);
|
|
1240
|
+
const key = `status:${status.statusId}:${(status.issueCodes ?? []).join(",")}`;
|
|
1241
|
+
if (state.emittedKeys.has(key)) return;
|
|
1242
|
+
state.emittedKeys.add(key);
|
|
1243
|
+
ctx.down([["DATA", { kind: "status", status }]]);
|
|
1244
|
+
}
|
|
1245
|
+
function emitIssue(ctx, state, issue) {
|
|
1246
|
+
const key = `${issue.code}:${issue.subjectId ?? ""}:${JSON.stringify(issue.details ?? {})}`;
|
|
1247
|
+
if (state.issueKeys.has(key)) return;
|
|
1248
|
+
state.issueKeys.add(key);
|
|
1249
|
+
ctx.down([["DATA", { kind: "issue", issue }]]);
|
|
1250
|
+
}
|
|
1251
|
+
function emitAudit(ctx, state, kind, opts) {
|
|
1252
|
+
state.auditSeq += 1;
|
|
1253
|
+
const metadata = sanitizeGraphVisibleRecord(opts.metadata);
|
|
1254
|
+
ctx.down([
|
|
1255
|
+
[
|
|
1256
|
+
"DATA",
|
|
1257
|
+
{
|
|
1258
|
+
kind: "audit",
|
|
1259
|
+
audit: Object.freeze({
|
|
1260
|
+
id: `work-queue-scheduled-readiness-audit-${state.auditSeq}`,
|
|
1261
|
+
kind,
|
|
1262
|
+
subjectId: opts.subjectId,
|
|
1263
|
+
...opts.sourceRefs === void 0 ? {} : { sourceRefs: canonicalPublicSourceRefs(opts.sourceRefs) },
|
|
1264
|
+
...metadata === void 0 ? {} : { metadata }
|
|
1265
|
+
})
|
|
1266
|
+
}
|
|
1267
|
+
]
|
|
1268
|
+
]);
|
|
1269
|
+
}
|
|
1270
|
+
function buildViews(state) {
|
|
1271
|
+
return Object.freeze({
|
|
1272
|
+
schedulesById: new Map(state.schedulesById),
|
|
1273
|
+
statusById: new Map(state.statusById)
|
|
1274
|
+
});
|
|
1275
|
+
}
|
|
1276
|
+
|
|
42
1277
|
// src/orchestration/work-queue.ts
|
|
43
1278
|
function orchestrationWorkQueueRecipe(graph, opts) {
|
|
44
1279
|
const name = opts.name ?? "orchestrationWorkQueue";
|
|
@@ -135,7 +1370,7 @@ function reduceRecord(ctx, state, record) {
|
|
|
135
1370
|
if (isQueuedEffectPayload(record.payload)) {
|
|
136
1371
|
state.payloads.set(record.workId, record.payload);
|
|
137
1372
|
} else {
|
|
138
|
-
|
|
1373
|
+
emitIssue2(ctx, state, record, "orchestration-queue-malformed-payload");
|
|
139
1374
|
}
|
|
140
1375
|
return;
|
|
141
1376
|
}
|
|
@@ -145,7 +1380,7 @@ function reduceRecord(ctx, state, record) {
|
|
|
145
1380
|
state.terminalRecords.add(key);
|
|
146
1381
|
const payload = record.workId === void 0 ? void 0 : state.payloads.get(record.workId);
|
|
147
1382
|
if (payload === void 0) {
|
|
148
|
-
|
|
1383
|
+
emitIssue2(ctx, state, record, "orchestration-queue-record-without-payload");
|
|
149
1384
|
return;
|
|
150
1385
|
}
|
|
151
1386
|
const evidence = evidenceFromRecord(record, payload);
|
|
@@ -217,7 +1452,7 @@ function project(graph, runtime, name, factory, pick) {
|
|
|
217
1452
|
function emit(ctx, fact) {
|
|
218
1453
|
ctx.down([["DATA", fact]]);
|
|
219
1454
|
}
|
|
220
|
-
function
|
|
1455
|
+
function emitIssue2(ctx, state, record, code) {
|
|
221
1456
|
const issue = queueIssue(record, code);
|
|
222
1457
|
emit(ctx, { kind: "issue", issue });
|
|
223
1458
|
state.auditSeq += 1;
|
|
@@ -257,6 +1492,9 @@ function isObjectRecord(value) {
|
|
|
257
1492
|
// Annotate the CommonJS export names for ESM import in node:
|
|
258
1493
|
0 && (module.exports = {
|
|
259
1494
|
orchestrationWorkQueueRecipe,
|
|
260
|
-
processEffectSubmitCommand
|
|
1495
|
+
processEffectSubmitCommand,
|
|
1496
|
+
workQueueLeaseExpirationCommandProjector,
|
|
1497
|
+
workQueueReadinessHandoffProjector,
|
|
1498
|
+
workQueueScheduledReadinessProjector
|
|
261
1499
|
});
|
|
262
1500
|
//# sourceMappingURL=work-queue.cjs.map
|