@logixjs/core 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/LICENSE +201 -0
- package/dist/{Bound-BN1DQ_lM.d.ts → Bound-CEa1ihvH.d.ts} +2 -2
- package/dist/{Bound-BPIfH9SS.d.cts → Bound-CNLNkC7c.d.cts} +2 -2
- package/dist/Bound.cjs +620 -163
- package/dist/Bound.cjs.map +1 -1
- package/dist/Bound.d.cts +3 -3
- package/dist/Bound.d.ts +3 -3
- package/dist/Bound.js +14 -14
- package/dist/{Debug-Bq8Sqjcr.d.cts → Debug-BhMYr-1i.d.cts} +3 -3
- package/dist/{Debug-B5q5Bkzx.d.ts → Debug-ByM7m4Ft.d.ts} +3 -3
- package/dist/Debug.cjs +553 -32
- package/dist/Debug.cjs.map +1 -1
- package/dist/Debug.d.cts +10 -8
- package/dist/Debug.d.ts +10 -8
- package/dist/Debug.js +12 -10
- package/dist/EffectOp.cjs.map +1 -1
- package/dist/EffectOp.js +2 -3
- package/dist/EffectOp.js.map +1 -1
- package/dist/Env.cjs +664 -6
- package/dist/Env.cjs.map +1 -1
- package/dist/Env.js +5 -2
- package/dist/ExternalStore-BAz83PVq.d.cts +60 -0
- package/dist/ExternalStore-BYWPbYs8.d.ts +60 -0
- package/dist/ExternalStore.cjs +746 -0
- package/dist/ExternalStore.cjs.map +1 -0
- package/dist/ExternalStore.d.cts +4 -0
- package/dist/ExternalStore.d.ts +4 -0
- package/dist/ExternalStore.js +19 -0
- package/dist/ExternalStore.js.map +1 -0
- package/dist/{Flow-1fZT8MpX.d.cts → Flow-BlSoMmhV.d.cts} +2 -2
- package/dist/{Flow-BhpjE22E.d.ts → Flow-CQSGve5c.d.ts} +2 -2
- package/dist/Flow.cjs +2 -2
- package/dist/Flow.cjs.map +1 -1
- package/dist/Flow.d.cts +4 -4
- package/dist/Flow.d.ts +4 -4
- package/dist/Flow.js +7 -8
- package/dist/{Handle-D_cLW1Z3.d.ts → Handle-B7PSmsrY.d.ts} +1 -1
- package/dist/{Handle-D8D1zPb_.d.cts → Handle-ByovhL-c.d.cts} +1 -1
- package/dist/Handle.d.cts +3 -3
- package/dist/Handle.d.ts +3 -3
- package/dist/{Kernel-CnGE1Fyk.d.ts → Kernel-DGSpS4GM.d.ts} +2 -2
- package/dist/{Kernel-8kC-jOda.d.cts → Kernel-DZAk-Mrn.d.cts} +2 -2
- package/dist/Kernel.cjs +680 -22
- package/dist/Kernel.cjs.map +1 -1
- package/dist/Kernel.d.cts +10 -8
- package/dist/Kernel.d.ts +10 -8
- package/dist/Kernel.js +7 -4
- package/dist/{Link-Db7975nU.d.ts → Link-Cm4eR9n0.d.ts} +10 -3
- package/dist/{Link-fX8x1eCK.d.cts → Link-DF8i8iWR.d.cts} +10 -3
- package/dist/Link.cjs +1128 -86
- package/dist/Link.cjs.map +1 -1
- package/dist/Link.d.cts +3 -3
- package/dist/Link.d.ts +3 -3
- package/dist/Link.js +30 -25
- package/dist/{Logic-DRh4sDZj.d.cts → Logic-BcQA0AvE.d.cts} +1 -1
- package/dist/{Logic-BRjEMr-W.d.ts → Logic-OotSE1xw.d.ts} +1 -1
- package/dist/Logic.d.cts +3 -3
- package/dist/Logic.d.ts +3 -3
- package/dist/{MatchBuilder-CJk5oCkR.d.cts → MatchBuilder-BNDJ8waF.d.ts} +1 -1
- package/dist/{MatchBuilder-0QOc-nlU.d.ts → MatchBuilder-CvZ5WY1B.d.cts} +1 -1
- package/dist/MatchBuilder.d.cts +4 -4
- package/dist/MatchBuilder.d.ts +4 -4
- package/dist/Middleware-D8tUDLv_.d.cts +100 -0
- package/dist/Middleware-DS7CbTTN.d.ts +100 -0
- package/dist/Middleware.cjs +461 -13
- package/dist/Middleware.cjs.map +1 -1
- package/dist/Middleware.d.cts +2 -86
- package/dist/Middleware.d.ts +2 -86
- package/dist/Middleware.js +13 -11
- package/dist/{Module-DnzluX2J.d.ts → Module-CFj0I2yE.d.ts} +45 -18
- package/dist/{Module-B_0xRDMR.d.cts → Module-DpXPW9EQ.d.cts} +45 -18
- package/dist/Module.cjs +8583 -5741
- package/dist/Module.cjs.map +1 -1
- package/dist/Module.d.cts +5 -4
- package/dist/Module.d.ts +5 -4
- package/dist/Module.js +32 -27
- package/dist/ModuleTag-BcVF6z7B.d.ts +113 -0
- package/dist/ModuleTag-DuZXo_NS.d.cts +113 -0
- package/dist/ModuleTag.cjs +2609 -1232
- package/dist/ModuleTag.cjs.map +1 -1
- package/dist/ModuleTag.d.cts +4 -4
- package/dist/ModuleTag.d.ts +4 -4
- package/dist/ModuleTag.js +28 -25
- package/dist/{Observability-cY4kLn0S.d.ts → Observability-D-ZWeEVb.d.ts} +22 -15
- package/dist/{Observability-COqEvp2C.d.cts → Observability-V7sRMYTh.d.cts} +22 -15
- package/dist/Observability.cjs +1938 -640
- package/dist/Observability.cjs.map +1 -1
- package/dist/Observability.d.cts +4 -4
- package/dist/Observability.d.ts +4 -4
- package/dist/Observability.js +21 -19
- package/dist/{Process-mL8fHDSB.d.cts → Process-B55aJMFk.d.cts} +29 -4
- package/dist/{Process-CM9xbMdP.d.ts → Process-DvhFEwUS.d.ts} +29 -4
- package/dist/Process.cjs +1122 -85
- package/dist/Process.cjs.map +1 -1
- package/dist/Process.d.cts +4 -3
- package/dist/Process.d.ts +4 -3
- package/dist/Process.js +27 -22
- package/dist/{ReadQuery-BlMwhe-F.d.ts → ReadQuery-C4vZ8Prc.d.ts} +2 -2
- package/dist/{ReadQuery-SinbStGF.d.ts → ReadQuery-CafjlJQo.d.cts} +1 -1
- package/dist/{ReadQuery-SinbStGF.d.cts → ReadQuery-CafjlJQo.d.ts} +1 -1
- package/dist/{ReadQuery-CL5XlXts.d.cts → ReadQuery-mc0NgrFV.d.cts} +2 -2
- package/dist/ReadQuery.cjs +3 -3
- package/dist/ReadQuery.cjs.map +1 -1
- package/dist/ReadQuery.d.cts +2 -2
- package/dist/ReadQuery.d.ts +2 -2
- package/dist/ReadQuery.js +3 -3
- package/dist/{Reflection-CQnKwPXj.d.ts → Reflection-C8xZ267q.d.ts} +88 -7
- package/dist/{Reflection-Kabo1mlU.d.cts → Reflection-DP7Vsv3f.d.cts} +88 -7
- package/dist/Reflection.cjs +2934 -1553
- package/dist/Reflection.cjs.map +1 -1
- package/dist/Reflection.d.cts +14 -11
- package/dist/Reflection.d.ts +14 -11
- package/dist/Reflection.js +26 -21
- package/dist/Resource.cjs +670 -12
- package/dist/Resource.cjs.map +1 -1
- package/dist/Resource.js +6 -3
- package/dist/Root.cjs +675 -17
- package/dist/Root.cjs.map +1 -1
- package/dist/Root.js +7 -3
- package/dist/{Runtime-CtyzZG4i.d.ts → Runtime-BWc9YfUB.d.ts} +37 -7
- package/dist/{Runtime-B-aL-f29.d.cts → Runtime-PShIC4DW.d.cts} +37 -7
- package/dist/Runtime.cjs +1899 -809
- package/dist/Runtime.cjs.map +1 -1
- package/dist/Runtime.d.cts +14 -11
- package/dist/Runtime.d.ts +14 -11
- package/dist/Runtime.js +33 -28
- package/dist/ScopeRegistry.cjs +668 -10
- package/dist/ScopeRegistry.cjs.map +1 -1
- package/dist/ScopeRegistry.js +6 -3
- package/dist/{StateTrait-OWhbj12c.d.cts → StateTrait-CQsDlXJm.d.cts} +23 -6
- package/dist/{StateTrait-BGsZghTz.d.ts → StateTrait-YvJzVDKl.d.ts} +23 -6
- package/dist/StateTrait.cjs +1475 -370
- package/dist/StateTrait.cjs.map +1 -1
- package/dist/StateTrait.d.cts +7 -5
- package/dist/StateTrait.d.ts +7 -5
- package/dist/StateTrait.js +17 -14
- package/dist/{TraitLifecycle-LdIWmKlg.d.ts → TraitLifecycle-CjIBICAA.d.ts} +2 -2
- package/dist/{TraitLifecycle-CwV5WPFX.d.cts → TraitLifecycle-NmqGiXPC.d.cts} +2 -2
- package/dist/TraitLifecycle.cjs +489 -32
- package/dist/TraitLifecycle.cjs.map +1 -1
- package/dist/TraitLifecycle.d.cts +4 -4
- package/dist/TraitLifecycle.d.ts +4 -4
- package/dist/TraitLifecycle.js +7 -7
- package/dist/Workflow-BlFG_20_.d.cts +414 -0
- package/dist/Workflow-CW9S_aAP.d.ts +414 -0
- package/dist/Workflow.cjs +2977 -0
- package/dist/Workflow.cjs.map +1 -0
- package/dist/Workflow.d.cts +7 -0
- package/dist/Workflow.d.ts +7 -0
- package/dist/Workflow.js +55 -0
- package/dist/Workflow.js.map +1 -0
- package/dist/{chunk-G5ZBFPNU.js → chunk-2A4UKO2D.js} +2 -2
- package/dist/chunk-2DE6D42I.js +248 -0
- package/dist/chunk-2DE6D42I.js.map +1 -0
- package/dist/{chunk-ANLBCBDC.js → chunk-2DVLMSOE.js} +6 -6
- package/dist/{chunk-BE3HW4FY.js → chunk-34CF6OGE.js} +14 -16
- package/dist/chunk-34CF6OGE.js.map +1 -0
- package/dist/{chunk-ZFY7U2FR.js → chunk-3LPIXG56.js} +43 -3
- package/dist/chunk-3LPIXG56.js.map +1 -0
- package/dist/chunk-3VZYDNXZ.js +10 -0
- package/dist/chunk-3VZYDNXZ.js.map +1 -0
- package/dist/{chunk-3TMODYZV.js → chunk-3XO4HR6V.js} +2 -2
- package/dist/chunk-46FGVWRF.js +817 -0
- package/dist/chunk-46FGVWRF.js.map +1 -0
- package/dist/chunk-4LODUXFI.js +288 -0
- package/dist/chunk-4LODUXFI.js.map +1 -0
- package/dist/{chunk-GMPEOUP2.js → chunk-4MZ7BT3R.js} +2 -2
- package/dist/chunk-4MZ7BT3R.js.map +1 -0
- package/dist/{chunk-TKZ7MEIA.js → chunk-53GVPGSM.js} +2 -2
- package/dist/{chunk-KP7MUZNX.js → chunk-5W2V2NVJ.js} +2 -2
- package/dist/chunk-5W2V2NVJ.js.map +1 -0
- package/dist/chunk-6DACKW3D.js +613 -0
- package/dist/chunk-6DACKW3D.js.map +1 -0
- package/dist/chunk-AQ7L2QZ5.js +1395 -0
- package/dist/chunk-AQ7L2QZ5.js.map +1 -0
- package/dist/{chunk-NZJKFF45.js → chunk-C2UZZQ76.js} +2 -2
- package/dist/chunk-CCKP5Z6F.js +701 -0
- package/dist/chunk-CCKP5Z6F.js.map +1 -0
- package/dist/chunk-CUKM2XUW.js +27 -0
- package/dist/{chunk-QCHIQWAJ.js.map → chunk-CUKM2XUW.js.map} +1 -1
- package/dist/{chunk-M2RGJPXX.js → chunk-DBD6Q6JH.js} +3 -3
- package/dist/{chunk-ZGDVUPTM.js → chunk-EB4RGQO3.js} +2 -2
- package/dist/{chunk-PAYXCY6A.js → chunk-G7ESIQTI.js} +12 -14
- package/dist/chunk-G7ESIQTI.js.map +1 -0
- package/dist/chunk-GPBAZQ23.js +348 -0
- package/dist/chunk-GPBAZQ23.js.map +1 -0
- package/dist/{chunk-OFADUJWJ.js → chunk-I4LCE5OY.js} +3 -5
- package/dist/{chunk-OFADUJWJ.js.map → chunk-I4LCE5OY.js.map} +1 -1
- package/dist/{chunk-DFNM3WX2.js → chunk-IMCC6TBN.js} +158 -39
- package/dist/chunk-IMCC6TBN.js.map +1 -0
- package/dist/{chunk-76WT3HOR.js → chunk-IROZNQAF.js} +22 -21
- package/dist/chunk-IROZNQAF.js.map +1 -0
- package/dist/{chunk-TAAPQVZN.js → chunk-ISKNULNH.js} +2 -2
- package/dist/chunk-J3CWXIPV.js +242 -0
- package/dist/chunk-J3CWXIPV.js.map +1 -0
- package/dist/{chunk-PYOE4VSI.js → chunk-JBKYRTCS.js} +224 -161
- package/dist/chunk-JBKYRTCS.js.map +1 -0
- package/dist/{chunk-66ALHVEX.js → chunk-KKIAYH4X.js} +3 -3
- package/dist/{chunk-3RMKLXHX.js → chunk-KLDVG3SY.js} +2 -2
- package/dist/{chunk-BABLDP24.js → chunk-KSZQYSEH.js} +3 -3
- package/dist/chunk-KSZQYSEH.js.map +1 -0
- package/dist/{chunk-CW6T36TN.js → chunk-M3M7JFAH.js} +4 -4
- package/dist/chunk-M3M7JFAH.js.map +1 -0
- package/dist/{chunk-THATMZXD.js → chunk-MLB253V2.js} +2 -2
- package/dist/{chunk-THATMZXD.js.map → chunk-MLB253V2.js.map} +1 -1
- package/dist/{chunk-JGIWG6SR.js → chunk-MS77U77X.js} +664 -550
- package/dist/chunk-MS77U77X.js.map +1 -0
- package/dist/chunk-MW4FA3MW.js +23 -0
- package/dist/chunk-MW4FA3MW.js.map +1 -0
- package/dist/chunk-MYKNINNN.js +228 -0
- package/dist/chunk-MYKNINNN.js.map +1 -0
- package/dist/{chunk-4CQAV7YB.js → chunk-O6TTQXTY.js} +2 -2
- package/dist/{chunk-NBD3KUOZ.js → chunk-OJDJ4VDQ.js} +35 -24
- package/dist/chunk-OJDJ4VDQ.js.map +1 -0
- package/dist/{chunk-NQZ2OSGR.js → chunk-PVZEMNJY.js} +9 -9
- package/dist/chunk-PVZEMNJY.js.map +1 -0
- package/dist/chunk-RN26DV2M.js +271 -0
- package/dist/chunk-RN26DV2M.js.map +1 -0
- package/dist/{chunk-JCXGZRMU.js → chunk-RQQW3IQC.js} +3 -3
- package/dist/chunk-RQQW3IQC.js.map +1 -0
- package/dist/{chunk-24VULZ7A.js → chunk-TKOGZDD6.js} +3 -3
- package/dist/{chunk-EGK3KN7B.js → chunk-TQYLVXGY.js} +70 -39
- package/dist/chunk-TQYLVXGY.js.map +1 -0
- package/dist/{chunk-QMM6O4CD.js → chunk-UACD2CL2.js} +15 -3
- package/dist/{chunk-QMM6O4CD.js.map → chunk-UACD2CL2.js.map} +1 -1
- package/dist/{chunk-M3WTHJHJ.js → chunk-VH575UTV.js} +30 -34
- package/dist/chunk-VH575UTV.js.map +1 -0
- package/dist/{chunk-AUIR5O6W.js → chunk-WWBMC24F.js} +9 -15
- package/dist/chunk-WWBMC24F.js.map +1 -0
- package/dist/{chunk-JWOYLO27.js → chunk-WYJUJV4L.js} +80 -7
- package/dist/chunk-WYJUJV4L.js.map +1 -0
- package/dist/{chunk-EY4NZKDR.js → chunk-XFMMPYNU.js} +2 -2
- package/dist/chunk-Y4VRBIS6.js +35 -0
- package/dist/chunk-Y4VRBIS6.js.map +1 -0
- package/dist/{chunk-DMBALCE2.js → chunk-ZC7MSQ5U.js} +77 -4
- package/dist/chunk-ZC7MSQ5U.js.map +1 -0
- package/dist/{chunk-OGWBVHB3.js → chunk-ZCK6SCOE.js} +67 -8
- package/dist/chunk-ZCK6SCOE.js.map +1 -0
- package/dist/{chunk-IHVBV5C2.js → chunk-ZTFTABXV.js} +2 -1
- package/dist/chunk-ZTFTABXV.js.map +1 -0
- package/dist/index.cjs +9532 -5017
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +163 -27
- package/dist/index.d.ts +163 -27
- package/dist/index.js +119 -56
- package/dist/index.js.map +1 -1
- package/dist/{ir-BMP7yxJJ.d.cts → ir-C-Zm_GlZ.d.cts} +1 -1
- package/dist/{ir-DUOz6H-5.d.ts → ir-DGyGiwVe.d.ts} +1 -1
- package/dist/{module-k7m3txak.d.ts → module-DqQ1U-Me.d.ts} +129 -100
- package/dist/{module-B8CBqIZ_.d.cts → module-doenaCsZ.d.cts} +129 -100
- package/package.json +12 -1
- package/dist/ModuleTag-C8FHY_sY.d.ts +0 -93
- package/dist/ModuleTag-EGbgBMpZ.d.cts +0 -93
- package/dist/chunk-3QMIVH35.js +0 -43
- package/dist/chunk-3QMIVH35.js.map +0 -1
- package/dist/chunk-76WT3HOR.js.map +0 -1
- package/dist/chunk-AUIR5O6W.js.map +0 -1
- package/dist/chunk-BABLDP24.js.map +0 -1
- package/dist/chunk-BE3HW4FY.js.map +0 -1
- package/dist/chunk-CW6T36TN.js.map +0 -1
- package/dist/chunk-DFNM3WX2.js.map +0 -1
- package/dist/chunk-DMBALCE2.js.map +0 -1
- package/dist/chunk-EGK3KN7B.js.map +0 -1
- package/dist/chunk-GMPEOUP2.js.map +0 -1
- package/dist/chunk-IHVBV5C2.js.map +0 -1
- package/dist/chunk-JCXGZRMU.js.map +0 -1
- package/dist/chunk-JGIWG6SR.js.map +0 -1
- package/dist/chunk-JWOYLO27.js.map +0 -1
- package/dist/chunk-KIXAU3GM.js +0 -137
- package/dist/chunk-KIXAU3GM.js.map +0 -1
- package/dist/chunk-KP7MUZNX.js.map +0 -1
- package/dist/chunk-M3WTHJHJ.js.map +0 -1
- package/dist/chunk-M7IYCTJV.js +0 -79
- package/dist/chunk-M7IYCTJV.js.map +0 -1
- package/dist/chunk-NBD3KUOZ.js.map +0 -1
- package/dist/chunk-NQZ2OSGR.js.map +0 -1
- package/dist/chunk-OGWBVHB3.js.map +0 -1
- package/dist/chunk-PAYXCY6A.js.map +0 -1
- package/dist/chunk-PYOE4VSI.js.map +0 -1
- package/dist/chunk-QCHIQWAJ.js +0 -21
- package/dist/chunk-VZB726PE.js +0 -93
- package/dist/chunk-VZB726PE.js.map +0 -1
- package/dist/chunk-W3TEWHLO.js +0 -568
- package/dist/chunk-W3TEWHLO.js.map +0 -1
- package/dist/chunk-ZFLHVFUC.js +0 -192
- package/dist/chunk-ZFLHVFUC.js.map +0 -1
- package/dist/chunk-ZFY7U2FR.js.map +0 -1
- /package/dist/{chunk-G5ZBFPNU.js.map → chunk-2A4UKO2D.js.map} +0 -0
- /package/dist/{chunk-ANLBCBDC.js.map → chunk-2DVLMSOE.js.map} +0 -0
- /package/dist/{chunk-3TMODYZV.js.map → chunk-3XO4HR6V.js.map} +0 -0
- /package/dist/{chunk-TKZ7MEIA.js.map → chunk-53GVPGSM.js.map} +0 -0
- /package/dist/{chunk-NZJKFF45.js.map → chunk-C2UZZQ76.js.map} +0 -0
- /package/dist/{chunk-M2RGJPXX.js.map → chunk-DBD6Q6JH.js.map} +0 -0
- /package/dist/{chunk-ZGDVUPTM.js.map → chunk-EB4RGQO3.js.map} +0 -0
- /package/dist/{chunk-TAAPQVZN.js.map → chunk-ISKNULNH.js.map} +0 -0
- /package/dist/{chunk-66ALHVEX.js.map → chunk-KKIAYH4X.js.map} +0 -0
- /package/dist/{chunk-3RMKLXHX.js.map → chunk-KLDVG3SY.js.map} +0 -0
- /package/dist/{chunk-4CQAV7YB.js.map → chunk-O6TTQXTY.js.map} +0 -0
- /package/dist/{chunk-24VULZ7A.js.map → chunk-TKOGZDD6.js.map} +0 -0
- /package/dist/{chunk-EY4NZKDR.js.map → chunk-XFMMPYNU.js.map} +0 -0
package/dist/Reflection.cjs
CHANGED
|
@@ -31,16 +31,17 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
var Reflection_exports = {};
|
|
32
32
|
__export(Reflection_exports, {
|
|
33
33
|
diffManifest: () => diffManifest2,
|
|
34
|
+
exportControlSurface: () => exportControlSurface2,
|
|
34
35
|
exportStaticIr: () => exportStaticIr3,
|
|
35
36
|
extractManifest: () => extractManifest2,
|
|
36
37
|
verifyFullCutoverGate: () => verifyFullCutoverGate,
|
|
37
38
|
verifyKernelContract: () => verifyKernelContract2
|
|
38
39
|
});
|
|
39
40
|
module.exports = __toCommonJS(Reflection_exports);
|
|
40
|
-
var
|
|
41
|
+
var import_effect40 = require("effect");
|
|
41
42
|
|
|
42
43
|
// src/internal/reflection/manifest.ts
|
|
43
|
-
var
|
|
44
|
+
var import_effect10 = require("effect");
|
|
44
45
|
|
|
45
46
|
// src/internal/action.ts
|
|
46
47
|
var import_effect = require("effect");
|
|
@@ -58,7 +59,7 @@ var stableStringify = (value) => {
|
|
|
58
59
|
}
|
|
59
60
|
if (t === "object") {
|
|
60
61
|
const record2 = value;
|
|
61
|
-
const keys = Object.keys(record2).sort(
|
|
62
|
+
const keys = Object.keys(record2).sort();
|
|
62
63
|
return `{${keys.map((k) => `${JSON.stringify(k)}:${stableStringify(record2[k])}`).join(",")}}`;
|
|
63
64
|
}
|
|
64
65
|
return "null";
|
|
@@ -195,11 +196,12 @@ var toJsonValueInternal = (input, options, stats, seen, depth) => {
|
|
|
195
196
|
stats.nonSerializable += 1;
|
|
196
197
|
return truncateString(String(input), options.maxStringLength, stats);
|
|
197
198
|
}
|
|
198
|
-
const
|
|
199
|
-
const limit = Math.min(
|
|
199
|
+
const keys = Object.keys(input).sort();
|
|
200
|
+
const limit = Math.min(keys.length, options.maxObjectKeys);
|
|
200
201
|
const out = {};
|
|
201
202
|
for (let i = 0; i < limit; i++) {
|
|
202
|
-
const
|
|
203
|
+
const rawKey = keys[i];
|
|
204
|
+
const rawValue = input[rawKey];
|
|
203
205
|
const key = truncateString(rawKey, options.maxStringLength, stats);
|
|
204
206
|
if (rawValue === void 0) {
|
|
205
207
|
stats.dropped += 1;
|
|
@@ -207,9 +209,9 @@ var toJsonValueInternal = (input, options, stats, seen, depth) => {
|
|
|
207
209
|
}
|
|
208
210
|
out[key] = toJsonValueInternal(rawValue, options, stats, seen, depth + 1);
|
|
209
211
|
}
|
|
210
|
-
if (
|
|
212
|
+
if (keys.length > limit) {
|
|
211
213
|
stats.oversized += 1;
|
|
212
|
-
out.__truncatedKeys =
|
|
214
|
+
out.__truncatedKeys = keys.length - limit;
|
|
213
215
|
}
|
|
214
216
|
return out;
|
|
215
217
|
};
|
|
@@ -268,1519 +270,943 @@ var projectJsonValue = (input, options) => {
|
|
|
268
270
|
};
|
|
269
271
|
|
|
270
272
|
// src/internal/runtime/core/env.ts
|
|
271
|
-
var
|
|
272
|
-
|
|
273
|
+
var import_effect9 = require("effect");
|
|
274
|
+
|
|
275
|
+
// src/internal/runtime/core/HostScheduler.ts
|
|
276
|
+
var noopCancel = () => {
|
|
277
|
+
};
|
|
278
|
+
var safeNowMs = () => {
|
|
279
|
+
const perf = globalThis.performance;
|
|
280
|
+
if (perf && typeof perf.now === "function") {
|
|
281
|
+
try {
|
|
282
|
+
const v = perf.now();
|
|
283
|
+
if (typeof v === "number" && Number.isFinite(v)) return v;
|
|
284
|
+
} catch {
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
return Date.now();
|
|
288
|
+
};
|
|
289
|
+
var safeQueueMicrotask = (cb) => {
|
|
290
|
+
const qm = globalThis.queueMicrotask;
|
|
291
|
+
if (typeof qm === "function") {
|
|
292
|
+
try {
|
|
293
|
+
qm(cb);
|
|
294
|
+
return;
|
|
295
|
+
} catch {
|
|
296
|
+
}
|
|
297
|
+
}
|
|
273
298
|
try {
|
|
274
|
-
|
|
275
|
-
return typeof env?.NODE_ENV === "string" ? env.NODE_ENV : void 0;
|
|
299
|
+
Promise.resolve().then(cb);
|
|
276
300
|
} catch {
|
|
277
|
-
|
|
301
|
+
setTimeout(cb, 0);
|
|
278
302
|
}
|
|
279
303
|
};
|
|
280
|
-
var
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
304
|
+
var safeSetTimeout = (ms, cb) => {
|
|
305
|
+
const id = setTimeout(cb, ms);
|
|
306
|
+
return () => {
|
|
307
|
+
try {
|
|
308
|
+
clearTimeout(id);
|
|
309
|
+
} catch {
|
|
310
|
+
}
|
|
311
|
+
};
|
|
284
312
|
};
|
|
285
|
-
var
|
|
313
|
+
var makeMessageChannelMacrotask = () => {
|
|
314
|
+
const MC = globalThis.MessageChannel;
|
|
315
|
+
if (typeof MC !== "function") return void 0;
|
|
316
|
+
let channel;
|
|
317
|
+
try {
|
|
318
|
+
channel = new MC();
|
|
319
|
+
} catch {
|
|
320
|
+
return void 0;
|
|
321
|
+
}
|
|
322
|
+
const queue = [];
|
|
323
|
+
let scheduled = false;
|
|
324
|
+
const flush = () => {
|
|
325
|
+
scheduled = false;
|
|
326
|
+
const tasks = queue.splice(0, queue.length);
|
|
327
|
+
for (const t of tasks) {
|
|
328
|
+
if (t.canceled) continue;
|
|
329
|
+
try {
|
|
330
|
+
t.cb();
|
|
331
|
+
} catch {
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
};
|
|
335
|
+
try {
|
|
336
|
+
channel.port1.onmessage = flush;
|
|
337
|
+
} catch {
|
|
338
|
+
return void 0;
|
|
339
|
+
}
|
|
340
|
+
const schedule = (cb) => {
|
|
341
|
+
const task = { canceled: false, cb };
|
|
342
|
+
queue.push(task);
|
|
343
|
+
if (!scheduled) {
|
|
344
|
+
scheduled = true;
|
|
345
|
+
try {
|
|
346
|
+
channel.port2.postMessage(void 0);
|
|
347
|
+
} catch {
|
|
348
|
+
scheduled = false;
|
|
349
|
+
return safeSetTimeout(0, cb);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
return () => {
|
|
353
|
+
task.canceled = true;
|
|
354
|
+
};
|
|
355
|
+
};
|
|
356
|
+
return schedule;
|
|
286
357
|
};
|
|
287
|
-
var
|
|
358
|
+
var makeSetImmediateMacrotask = () => {
|
|
359
|
+
const si = globalThis.setImmediate;
|
|
360
|
+
const ci = globalThis.clearImmediate;
|
|
361
|
+
if (typeof si !== "function") return void 0;
|
|
362
|
+
return (cb) => {
|
|
363
|
+
let id;
|
|
364
|
+
try {
|
|
365
|
+
id = si(cb);
|
|
366
|
+
} catch {
|
|
367
|
+
return safeSetTimeout(0, cb);
|
|
368
|
+
}
|
|
369
|
+
return () => {
|
|
370
|
+
if (typeof ci !== "function") return;
|
|
371
|
+
try {
|
|
372
|
+
ci(id);
|
|
373
|
+
} catch {
|
|
374
|
+
}
|
|
375
|
+
};
|
|
376
|
+
};
|
|
288
377
|
};
|
|
289
|
-
var
|
|
378
|
+
var makeRaf = () => {
|
|
379
|
+
const raf = globalThis.requestAnimationFrame;
|
|
380
|
+
const cancel = globalThis.cancelAnimationFrame;
|
|
381
|
+
if (typeof raf !== "function") return void 0;
|
|
382
|
+
return (cb) => {
|
|
383
|
+
let id;
|
|
384
|
+
try {
|
|
385
|
+
id = raf(cb);
|
|
386
|
+
} catch {
|
|
387
|
+
return noopCancel;
|
|
388
|
+
}
|
|
389
|
+
return () => {
|
|
390
|
+
if (typeof cancel !== "function") return;
|
|
391
|
+
try {
|
|
392
|
+
cancel(id);
|
|
393
|
+
} catch {
|
|
394
|
+
}
|
|
395
|
+
};
|
|
396
|
+
};
|
|
290
397
|
};
|
|
291
|
-
var
|
|
398
|
+
var makeDefaultHostScheduler = () => {
|
|
399
|
+
const macrotask = makeSetImmediateMacrotask() ?? makeMessageChannelMacrotask() ?? ((cb) => safeSetTimeout(0, cb));
|
|
400
|
+
const raf = makeRaf();
|
|
401
|
+
return {
|
|
402
|
+
nowMs: safeNowMs,
|
|
403
|
+
scheduleMicrotask: safeQueueMicrotask,
|
|
404
|
+
scheduleMacrotask: macrotask,
|
|
405
|
+
scheduleAnimationFrame: (cb) => raf?.(cb) ?? macrotask(cb),
|
|
406
|
+
scheduleTimeout: safeSetTimeout
|
|
407
|
+
};
|
|
292
408
|
};
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
if (!module2) return void 0;
|
|
298
|
-
if (typeof module2 !== "object" && typeof module2 !== "function") return void 0;
|
|
299
|
-
return module2[MODULE_TRAITS_PROGRAM];
|
|
409
|
+
var globalHostScheduler;
|
|
410
|
+
var getGlobalHostScheduler = () => {
|
|
411
|
+
globalHostScheduler ?? (globalHostScheduler = makeDefaultHostScheduler());
|
|
412
|
+
return globalHostScheduler;
|
|
300
413
|
};
|
|
301
414
|
|
|
302
|
-
// src/internal/
|
|
303
|
-
var
|
|
304
|
-
|
|
305
|
-
if (
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
return
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
const segs = splitSegments(input);
|
|
313
|
-
if (!segs || segs.length === 0) return void 0;
|
|
314
|
-
const normalized2 = segs.filter(isFieldPathSegment);
|
|
315
|
-
return normalized2.length > 0 ? normalized2 : void 0;
|
|
415
|
+
// src/internal/runtime/core/RuntimeStore.ts
|
|
416
|
+
var parseTopicKey = (topicKey) => {
|
|
417
|
+
const idx = topicKey.indexOf("::");
|
|
418
|
+
if (idx <= 0) return void 0;
|
|
419
|
+
const moduleId = topicKey.slice(0, idx);
|
|
420
|
+
const rest = topicKey.slice(idx + 2);
|
|
421
|
+
if (rest.length === 0) return void 0;
|
|
422
|
+
const idx2 = rest.indexOf("::");
|
|
423
|
+
if (idx2 < 0) {
|
|
424
|
+
return { kind: "module", moduleInstanceKey: `${moduleId}::${rest}` };
|
|
316
425
|
}
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
426
|
+
const instanceId = rest.slice(0, idx2);
|
|
427
|
+
const suffix = rest.slice(idx2 + 2);
|
|
428
|
+
if (suffix.startsWith("rq:")) {
|
|
429
|
+
const selectorId = suffix.slice("rq:".length);
|
|
430
|
+
if (selectorId.length === 0) return void 0;
|
|
431
|
+
return {
|
|
432
|
+
kind: "readQuery",
|
|
433
|
+
moduleInstanceKey: `${moduleId}::${instanceId}`,
|
|
434
|
+
selectorId
|
|
435
|
+
};
|
|
324
436
|
}
|
|
325
|
-
|
|
326
|
-
const normalized = input.filter(isFieldPathSegment);
|
|
327
|
-
return normalized.length > 0 ? normalized : void 0;
|
|
437
|
+
return { kind: "module", moduleInstanceKey: `${moduleId}::${instanceId}` };
|
|
328
438
|
};
|
|
329
|
-
var
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
const
|
|
333
|
-
const
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
439
|
+
var makeRuntimeStore = () => {
|
|
440
|
+
let tickSeq = 0;
|
|
441
|
+
const moduleStates = /* @__PURE__ */ new Map();
|
|
442
|
+
const topicVersions = /* @__PURE__ */ new Map();
|
|
443
|
+
const topicPriorities = /* @__PURE__ */ new Map();
|
|
444
|
+
const listenersByTopic = /* @__PURE__ */ new Map();
|
|
445
|
+
const subscriberCountByModule = /* @__PURE__ */ new Map();
|
|
446
|
+
const getTopicVersion = (topicKey) => topicVersions.get(topicKey) ?? 0;
|
|
447
|
+
const getTopicPriority = (topicKey) => topicPriorities.get(topicKey) ?? "normal";
|
|
448
|
+
const commitTopicBump = (topicKey, priority) => {
|
|
449
|
+
const prev = topicVersions.get(topicKey) ?? 0;
|
|
450
|
+
topicVersions.set(topicKey, prev + 1);
|
|
451
|
+
topicPriorities.set(topicKey, priority);
|
|
452
|
+
};
|
|
453
|
+
const subscribeTopic = (topicKey, listener) => {
|
|
454
|
+
const info = parseTopicKey(topicKey);
|
|
455
|
+
const existing = listenersByTopic.get(topicKey);
|
|
456
|
+
const set = existing ?? /* @__PURE__ */ new Set();
|
|
457
|
+
const alreadyHas = set.has(listener);
|
|
458
|
+
if (!alreadyHas) {
|
|
459
|
+
set.add(listener);
|
|
338
460
|
}
|
|
339
|
-
if (
|
|
340
|
-
|
|
341
|
-
if (base) segs.push(base);
|
|
342
|
-
continue;
|
|
461
|
+
if (!existing) {
|
|
462
|
+
listenersByTopic.set(topicKey, set);
|
|
343
463
|
}
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
continue;
|
|
464
|
+
if (!alreadyHas && info) {
|
|
465
|
+
const prev = subscriberCountByModule.get(info.moduleInstanceKey) ?? 0;
|
|
466
|
+
subscriberCountByModule.set(info.moduleInstanceKey, prev + 1);
|
|
348
467
|
}
|
|
349
|
-
|
|
350
|
-
|
|
468
|
+
return () => {
|
|
469
|
+
const current = listenersByTopic.get(topicKey);
|
|
470
|
+
if (!current) return;
|
|
471
|
+
const deleted = current.delete(listener);
|
|
472
|
+
if (deleted && info) {
|
|
473
|
+
const prev = subscriberCountByModule.get(info.moduleInstanceKey) ?? 0;
|
|
474
|
+
const next = prev - 1;
|
|
475
|
+
if (next <= 0) {
|
|
476
|
+
subscriberCountByModule.delete(info.moduleInstanceKey);
|
|
477
|
+
} else {
|
|
478
|
+
subscriberCountByModule.set(info.moduleInstanceKey, next);
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
if (current.size === 0) {
|
|
482
|
+
listenersByTopic.delete(topicKey);
|
|
483
|
+
}
|
|
484
|
+
};
|
|
485
|
+
};
|
|
486
|
+
const getTopicSubscriberCount = (topicKey) => listenersByTopic.get(topicKey)?.size ?? 0;
|
|
487
|
+
const getModuleSubscriberCount = (moduleInstanceKey) => subscriberCountByModule.get(moduleInstanceKey) ?? 0;
|
|
488
|
+
const registerModuleInstance = (args) => {
|
|
489
|
+
moduleStates.set(args.moduleInstanceKey, args.initialState);
|
|
490
|
+
if (!topicVersions.has(args.moduleInstanceKey)) {
|
|
491
|
+
topicVersions.set(args.moduleInstanceKey, 0);
|
|
492
|
+
topicPriorities.set(args.moduleInstanceKey, "normal");
|
|
351
493
|
}
|
|
352
|
-
|
|
353
|
-
|
|
494
|
+
};
|
|
495
|
+
const unregisterModuleInstance = (moduleInstanceKey) => {
|
|
496
|
+
moduleStates.delete(moduleInstanceKey);
|
|
497
|
+
};
|
|
498
|
+
const commitTick = (args) => {
|
|
499
|
+
tickSeq = args.tickSeq;
|
|
500
|
+
for (const [key, commit] of args.accepted.modules) {
|
|
501
|
+
moduleStates.set(key, commit.state);
|
|
354
502
|
}
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
503
|
+
const changedTopics = /* @__PURE__ */ new Map();
|
|
504
|
+
for (const [topicKey, priority] of args.accepted.dirtyTopics) {
|
|
505
|
+
commitTopicBump(topicKey, priority);
|
|
506
|
+
const listeners = Array.from(listenersByTopic.get(topicKey) ?? []);
|
|
507
|
+
if (listeners.length > 0) {
|
|
508
|
+
changedTopics.set(topicKey, { priority, listeners });
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
return { changedTopics };
|
|
512
|
+
};
|
|
513
|
+
const getModuleState = (moduleInstanceKey) => moduleStates.get(moduleInstanceKey);
|
|
514
|
+
const dispose = () => {
|
|
515
|
+
moduleStates.clear();
|
|
516
|
+
topicVersions.clear();
|
|
517
|
+
topicPriorities.clear();
|
|
518
|
+
listenersByTopic.clear();
|
|
519
|
+
subscriberCountByModule.clear();
|
|
520
|
+
};
|
|
521
|
+
return {
|
|
522
|
+
getTickSeq: () => tickSeq,
|
|
523
|
+
getModuleState,
|
|
524
|
+
getTopicVersion,
|
|
525
|
+
getTopicPriority,
|
|
526
|
+
subscribeTopic,
|
|
527
|
+
getTopicSubscriberCount,
|
|
528
|
+
getModuleSubscriberCount,
|
|
529
|
+
registerModuleInstance,
|
|
530
|
+
unregisterModuleInstance,
|
|
531
|
+
commitTick,
|
|
532
|
+
dispose
|
|
533
|
+
};
|
|
358
534
|
};
|
|
359
535
|
|
|
360
|
-
// src/internal/
|
|
361
|
-
var
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
536
|
+
// src/internal/runtime/core/TickScheduler.ts
|
|
537
|
+
var import_effect7 = require("effect");
|
|
538
|
+
|
|
539
|
+
// src/internal/runtime/core/DebugSink.record.ts
|
|
540
|
+
var import_effect4 = require("effect");
|
|
541
|
+
|
|
542
|
+
// src/internal/runtime/core/errorSummary.ts
|
|
543
|
+
var import_effect2 = require("effect");
|
|
544
|
+
var truncate = (value, maxLen) => {
|
|
545
|
+
if (value.length <= maxLen) return { value, truncated: false };
|
|
546
|
+
return { value: value.slice(0, maxLen), truncated: true };
|
|
369
547
|
};
|
|
370
|
-
var
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
case "link-propagate":
|
|
376
|
-
return "link";
|
|
377
|
-
case "source-refresh":
|
|
378
|
-
return "source";
|
|
379
|
-
case "check-validate":
|
|
380
|
-
return "check";
|
|
548
|
+
var safeStringify = (value) => {
|
|
549
|
+
try {
|
|
550
|
+
return { ok: true, json: JSON.stringify(value) };
|
|
551
|
+
} catch {
|
|
552
|
+
return { ok: false };
|
|
381
553
|
}
|
|
382
554
|
};
|
|
383
|
-
var
|
|
384
|
-
|
|
385
|
-
if (
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
555
|
+
var getMessageFromUnknown = (cause) => {
|
|
556
|
+
if (typeof cause === "string") return cause;
|
|
557
|
+
if (typeof cause === "number" || typeof cause === "boolean" || typeof cause === "bigint") return String(cause);
|
|
558
|
+
if (cause instanceof Error) return cause.message || cause.name || "Error";
|
|
559
|
+
if (cause && typeof cause === "object" && "message" in cause && typeof cause.message === "string") {
|
|
560
|
+
return cause.message;
|
|
561
|
+
}
|
|
562
|
+
try {
|
|
563
|
+
const pretty = import_effect2.Cause.pretty(cause, { renderErrorCause: true });
|
|
564
|
+
if (typeof pretty === "string" && pretty.length > 0) return pretty;
|
|
565
|
+
} catch {
|
|
566
|
+
}
|
|
567
|
+
return "Unknown error";
|
|
390
568
|
};
|
|
391
|
-
var
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
569
|
+
var toSerializableErrorSummary = (cause, options) => {
|
|
570
|
+
const maxMessageLength = options?.maxMessageLength ?? 256;
|
|
571
|
+
const messageRaw = getMessageFromUnknown(cause);
|
|
572
|
+
const { value: message, truncated } = truncate(messageRaw, maxMessageLength);
|
|
573
|
+
const summary = {
|
|
574
|
+
message
|
|
575
|
+
};
|
|
576
|
+
if (cause instanceof Error) {
|
|
577
|
+
if (cause.name && cause.name !== "Error") summary.name = cause.name;
|
|
578
|
+
const anyCause = cause;
|
|
579
|
+
if (typeof anyCause.code === "string" && anyCause.code.length > 0) summary.code = anyCause.code;
|
|
580
|
+
else if (typeof anyCause.code === "number" && Number.isFinite(anyCause.code)) summary.code = String(anyCause.code);
|
|
581
|
+
if (typeof anyCause.hint === "string" && anyCause.hint.length > 0) summary.hint = anyCause.hint;
|
|
582
|
+
return {
|
|
583
|
+
errorSummary: summary,
|
|
584
|
+
downgrade: truncated ? "oversized" : void 0
|
|
585
|
+
};
|
|
395
586
|
}
|
|
396
|
-
if (
|
|
397
|
-
|
|
587
|
+
if (cause && typeof cause === "object") {
|
|
588
|
+
const anyCause = cause;
|
|
589
|
+
if (typeof anyCause.name === "string" && anyCause.name.length > 0) summary.name = anyCause.name;
|
|
590
|
+
if (typeof anyCause.code === "string" && anyCause.code.length > 0) summary.code = anyCause.code;
|
|
591
|
+
if (typeof anyCause.hint === "string" && anyCause.hint.length > 0) summary.hint = anyCause.hint;
|
|
398
592
|
}
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
return
|
|
593
|
+
const stringifyResult = safeStringify(cause);
|
|
594
|
+
if (!stringifyResult.ok) {
|
|
595
|
+
return {
|
|
596
|
+
errorSummary: summary,
|
|
597
|
+
downgrade: "non_serializable"
|
|
598
|
+
};
|
|
402
599
|
}
|
|
403
|
-
if (
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
const deps = rule?.deps;
|
|
409
|
-
if (deps) out.push(...deps);
|
|
410
|
-
}
|
|
411
|
-
return out;
|
|
600
|
+
if (truncated) {
|
|
601
|
+
return {
|
|
602
|
+
errorSummary: summary,
|
|
603
|
+
downgrade: "oversized"
|
|
604
|
+
};
|
|
412
605
|
}
|
|
413
|
-
|
|
606
|
+
if (message === "Unknown error") {
|
|
607
|
+
return {
|
|
608
|
+
errorSummary: summary,
|
|
609
|
+
downgrade: "unknown"
|
|
610
|
+
};
|
|
611
|
+
}
|
|
612
|
+
return { errorSummary: summary };
|
|
414
613
|
};
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
const meta = node.meta;
|
|
421
|
-
if (!meta || typeof meta !== "object") continue;
|
|
422
|
-
const label = typeof meta.label === "string" ? meta.label : void 0;
|
|
423
|
-
const description = typeof meta.description === "string" ? meta.description : void 0;
|
|
424
|
-
const tags = Array.isArray(meta.tags) && meta.tags.every((t) => typeof t === "string") ? meta.tags : void 0;
|
|
425
|
-
const group = typeof meta.group === "string" ? meta.group : void 0;
|
|
426
|
-
const docsUrl = typeof meta.docsUrl === "string" ? meta.docsUrl : void 0;
|
|
427
|
-
const cacheGroup = typeof meta.cacheGroup === "string" ? meta.cacheGroup : void 0;
|
|
428
|
-
const annotationsRaw = meta.annotations;
|
|
429
|
-
const annotations = annotationsRaw && typeof annotationsRaw === "object" && !Array.isArray(annotationsRaw) ? annotationsRaw : void 0;
|
|
430
|
-
if (label || description || tags || group || docsUrl || cacheGroup || annotations) {
|
|
431
|
-
metaByField.set(node.id, {
|
|
432
|
-
label,
|
|
433
|
-
description,
|
|
434
|
-
tags,
|
|
435
|
-
group,
|
|
436
|
-
docsUrl,
|
|
437
|
-
cacheGroup,
|
|
438
|
-
annotations
|
|
439
|
-
});
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
const nodes = params.program.plan.steps.map((step) => {
|
|
443
|
-
const kind = toNodeKind(step);
|
|
444
|
-
const entry = findEntryForStep(params.program, step);
|
|
445
|
-
const reads = normalizeFieldPaths(getReadsForEntry(entry));
|
|
446
|
-
const target = step.targetFieldPath;
|
|
447
|
-
const write = normalizeFieldPath2(target);
|
|
448
|
-
const writes = write ? [write] : [];
|
|
449
|
-
const meta = target ? metaByField.get(target) : void 0;
|
|
450
|
-
const base2 = {
|
|
451
|
-
nodeId: step.id,
|
|
452
|
-
kind,
|
|
453
|
-
reads,
|
|
454
|
-
writes: kind === "check" ? [] : writes,
|
|
455
|
-
meta
|
|
456
|
-
};
|
|
457
|
-
if (kind !== "check" && target && !write) {
|
|
458
|
-
return { ...base2, writesUnknown: true };
|
|
459
|
-
}
|
|
460
|
-
return base2;
|
|
461
|
-
});
|
|
462
|
-
const edges = params.program.graph.edges.map((edge) => ({
|
|
463
|
-
edgeId: edge.id,
|
|
464
|
-
from: edge.from,
|
|
465
|
-
to: edge.to,
|
|
466
|
-
kind: edge.kind
|
|
467
|
-
}));
|
|
468
|
-
const base = {
|
|
469
|
-
version,
|
|
470
|
-
moduleId,
|
|
471
|
-
nodes,
|
|
472
|
-
edges
|
|
473
|
-
};
|
|
474
|
-
const digest = `stir:${version}:${fnv1a32(stableStringify(base))}`;
|
|
475
|
-
return {
|
|
476
|
-
...base,
|
|
477
|
-
digest
|
|
478
|
-
};
|
|
614
|
+
|
|
615
|
+
// src/internal/runtime/core/EffectOpCore.ts
|
|
616
|
+
var import_effect3 = require("effect");
|
|
617
|
+
var currentLinkId = import_effect3.FiberRef.unsafeMake(void 0);
|
|
618
|
+
var EffectOpMiddlewareTag = class extends import_effect3.Context.Tag("Logix/EffectOpMiddleware")() {
|
|
479
619
|
};
|
|
480
620
|
|
|
481
|
-
// src/internal/
|
|
482
|
-
var
|
|
483
|
-
var
|
|
484
|
-
var
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
}
|
|
498
|
-
return "unknown";
|
|
621
|
+
// src/internal/runtime/core/DebugSink.record.ts
|
|
622
|
+
var currentDebugSinks = import_effect4.FiberRef.unsafeMake([]);
|
|
623
|
+
var currentRuntimeLabel = import_effect4.FiberRef.unsafeMake(void 0);
|
|
624
|
+
var currentTxnId = import_effect4.FiberRef.unsafeMake(void 0);
|
|
625
|
+
var currentOpSeq = import_effect4.FiberRef.unsafeMake(void 0);
|
|
626
|
+
var currentDiagnosticsLevel = import_effect4.FiberRef.unsafeMake("off");
|
|
627
|
+
var diagnosticsLevel = (level) => import_effect4.Layer.fiberRefLocallyScopedWith(currentDiagnosticsLevel, () => level);
|
|
628
|
+
var currentTraitConvergeDiagnosticsSampling = import_effect4.FiberRef.unsafeMake({
|
|
629
|
+
sampleEveryN: 32,
|
|
630
|
+
topK: 3
|
|
631
|
+
});
|
|
632
|
+
var appendSinks = (sinks) => import_effect4.Layer.fiberRefLocallyScopedWith(currentDebugSinks, (current) => [...current, ...sinks]);
|
|
633
|
+
var nextGlobalEventSeq = 0;
|
|
634
|
+
var nextEventSeq = () => {
|
|
635
|
+
nextGlobalEventSeq += 1;
|
|
636
|
+
return nextGlobalEventSeq;
|
|
499
637
|
};
|
|
500
|
-
var
|
|
501
|
-
|
|
502
|
-
if (
|
|
503
|
-
return
|
|
638
|
+
var makeEventId = (instanceId, eventSeq) => `${instanceId}::e${eventSeq}`;
|
|
639
|
+
var mergeDowngrade2 = (current, next) => {
|
|
640
|
+
if (!current) return next;
|
|
641
|
+
if (!next) return current;
|
|
642
|
+
if (current === "non_serializable" || next === "non_serializable") return "non_serializable";
|
|
643
|
+
if (current === "oversized" || next === "oversized") return "oversized";
|
|
644
|
+
return "unknown";
|
|
504
645
|
};
|
|
505
|
-
var
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
646
|
+
var browserLifecycleSeen = /* @__PURE__ */ new Set();
|
|
647
|
+
var browserDiagnosticSeen = /* @__PURE__ */ new Set();
|
|
648
|
+
var lastTxnByInstance = /* @__PURE__ */ new Map();
|
|
649
|
+
var pendingTxnAlignmentByInstance = /* @__PURE__ */ new Map();
|
|
650
|
+
var enqueuePendingTxnAlignment = (instanceId, ref) => {
|
|
651
|
+
const list = pendingTxnAlignmentByInstance.get(instanceId);
|
|
652
|
+
if (!list) {
|
|
653
|
+
pendingTxnAlignmentByInstance.set(instanceId, [ref]);
|
|
654
|
+
return;
|
|
655
|
+
}
|
|
656
|
+
list.push(ref);
|
|
657
|
+
if (list.length > 64) {
|
|
658
|
+
list.shift();
|
|
659
|
+
}
|
|
514
660
|
};
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
if (isModuleImpl2(input)) {
|
|
521
|
-
const id = input.module.id;
|
|
522
|
-
return typeof id === "string" && id.length > 0 ? id : "unknown";
|
|
661
|
+
var backfillPendingTxnAlignment = (instanceId, txn) => {
|
|
662
|
+
const pending = pendingTxnAlignmentByInstance.get(instanceId);
|
|
663
|
+
if (!pending || pending.length === 0) {
|
|
664
|
+
pendingTxnAlignmentByInstance.delete(instanceId);
|
|
665
|
+
return;
|
|
523
666
|
}
|
|
524
|
-
|
|
525
|
-
const
|
|
526
|
-
if (
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
667
|
+
for (const ref of pending) {
|
|
668
|
+
const anyRef = ref;
|
|
669
|
+
if (anyRef.txnId == null) {
|
|
670
|
+
anyRef.txnId = txn.txnId;
|
|
671
|
+
}
|
|
672
|
+
if (typeof anyRef.txnSeq !== "number" || anyRef.txnSeq <= 0) {
|
|
673
|
+
anyRef.txnSeq = txn.txnSeq;
|
|
531
674
|
}
|
|
532
675
|
}
|
|
533
|
-
|
|
676
|
+
pendingTxnAlignmentByInstance.delete(instanceId);
|
|
534
677
|
};
|
|
535
|
-
var
|
|
536
|
-
const
|
|
537
|
-
const
|
|
538
|
-
|
|
539
|
-
|
|
678
|
+
var lifecycleErrorLog = (event) => {
|
|
679
|
+
const moduleId = event.moduleId ?? "unknown";
|
|
680
|
+
const causePretty = (() => {
|
|
681
|
+
try {
|
|
682
|
+
return import_effect4.Cause.pretty(event.cause, {
|
|
683
|
+
renderErrorCause: true
|
|
684
|
+
});
|
|
685
|
+
} catch {
|
|
686
|
+
try {
|
|
687
|
+
return JSON.stringify(event.cause, null, 2);
|
|
688
|
+
} catch {
|
|
689
|
+
return String(event.cause);
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
})();
|
|
693
|
+
const message = `[Logix][module=${moduleId}] lifecycle:error
|
|
694
|
+
${causePretty}`;
|
|
695
|
+
return import_effect4.Effect.logError(message).pipe(
|
|
696
|
+
import_effect4.Effect.annotateLogs({
|
|
697
|
+
"logix.moduleId": moduleId,
|
|
698
|
+
"logix.event": "lifecycle:error",
|
|
699
|
+
"logix.cause": causePretty
|
|
700
|
+
})
|
|
701
|
+
);
|
|
540
702
|
};
|
|
541
|
-
var
|
|
542
|
-
|
|
543
|
-
const
|
|
544
|
-
const
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
703
|
+
var diagnosticLog = (event) => {
|
|
704
|
+
const moduleId = event.moduleId ?? "unknown";
|
|
705
|
+
const header = `[Logix][module=${moduleId}] diagnostic(${event.severity})`;
|
|
706
|
+
const detail = `code=${event.code} message=${event.message}${event.actionTag ? ` action=${event.actionTag}` : ""}${event.hint ? `
|
|
707
|
+
hint: ${event.hint}` : ""}`;
|
|
708
|
+
const msg = `${header}
|
|
709
|
+
${detail}`;
|
|
710
|
+
const base = event.severity === "warning" ? import_effect4.Effect.logWarning(msg) : event.severity === "info" ? import_effect4.Effect.logInfo(msg) : import_effect4.Effect.logError(msg);
|
|
711
|
+
const annotations = {
|
|
712
|
+
"logix.moduleId": moduleId,
|
|
713
|
+
"logix.event": `diagnostic(${event.severity})`,
|
|
714
|
+
"logix.diagnostic.code": event.code,
|
|
715
|
+
"logix.diagnostic.message": event.message
|
|
716
|
+
};
|
|
717
|
+
if (event.hint) {
|
|
718
|
+
annotations["logix.diagnostic.hint"] = event.hint;
|
|
719
|
+
}
|
|
720
|
+
if (event.actionTag) {
|
|
721
|
+
annotations["logix.diagnostic.actionTag"] = event.actionTag;
|
|
722
|
+
}
|
|
723
|
+
return base.pipe(import_effect4.Effect.annotateLogs(annotations));
|
|
550
724
|
};
|
|
551
|
-
var
|
|
552
|
-
|
|
553
|
-
|
|
725
|
+
var noopLayer = import_effect4.Layer.locallyScoped(currentDebugSinks, []);
|
|
726
|
+
var errorOnlySink = {
|
|
727
|
+
record: (event) => event.type === "lifecycle:error" ? lifecycleErrorLog(event) : event.type === "diagnostic" && event.severity !== "info" ? diagnosticLog(event) : import_effect4.Effect.void
|
|
554
728
|
};
|
|
555
|
-
var
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
const
|
|
565
|
-
const
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
729
|
+
var errorOnlyLayer = import_effect4.Layer.locallyScoped(currentDebugSinks, [errorOnlySink]);
|
|
730
|
+
var isErrorOnlyOnlySinks = (sinks) => sinks.length === 1 && sinks[0] === errorOnlySink;
|
|
731
|
+
var consoleSink = {
|
|
732
|
+
record: (event) => event.type === "lifecycle:error" ? lifecycleErrorLog(event) : event.type === "diagnostic" ? diagnosticLog(event) : import_effect4.Effect.logDebug({ debugEvent: event })
|
|
733
|
+
};
|
|
734
|
+
var consoleLayer = import_effect4.Layer.locallyScoped(currentDebugSinks, [consoleSink]);
|
|
735
|
+
var isBrowser = typeof window !== "undefined" && typeof document !== "undefined";
|
|
736
|
+
var renderBrowserConsoleEvent = (event) => {
|
|
737
|
+
if (typeof event.type === "string" && event.type.startsWith("trace:")) {
|
|
738
|
+
const moduleId = event.moduleId ?? "unknown";
|
|
739
|
+
const type = event.type;
|
|
740
|
+
return import_effect4.Effect.sync(() => {
|
|
741
|
+
console.groupCollapsed(
|
|
742
|
+
"%c[Logix]%c trace %c" + moduleId + "%c " + String(type),
|
|
743
|
+
"color:#6b7280;font-weight:bold",
|
|
744
|
+
// tag
|
|
745
|
+
"color:#3b82f6",
|
|
746
|
+
// label
|
|
747
|
+
"color:#9ca3af",
|
|
748
|
+
// module id
|
|
749
|
+
"color:#6b7280"
|
|
750
|
+
// type
|
|
751
|
+
);
|
|
752
|
+
console.log(event);
|
|
753
|
+
console.groupEnd();
|
|
573
754
|
});
|
|
574
755
|
}
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
const handlerIds = /* @__PURE__ */ new WeakMap();
|
|
587
|
-
let nextHandlerSeq = 0;
|
|
588
|
-
const out = [];
|
|
589
|
-
for (const actionTag of Object.keys(effectsRaw).sort()) {
|
|
590
|
-
if (!(actionTag in actionMap)) continue;
|
|
591
|
-
const handlers = effectsRaw[actionTag];
|
|
592
|
-
if (!Array.isArray(handlers)) continue;
|
|
593
|
-
for (const handler of handlers) {
|
|
594
|
-
if (typeof handler !== "function") continue;
|
|
595
|
-
let handlerId = handlerIds.get(handler);
|
|
596
|
-
if (!handlerId) {
|
|
597
|
-
nextHandlerSeq += 1;
|
|
598
|
-
handlerId = `h${nextHandlerSeq}`;
|
|
599
|
-
handlerIds.set(handler, handlerId);
|
|
756
|
+
if (event.type === "lifecycle:error") {
|
|
757
|
+
const moduleId = event.moduleId ?? "unknown";
|
|
758
|
+
const causePretty = (() => {
|
|
759
|
+
try {
|
|
760
|
+
return import_effect4.Cause.pretty(event.cause, { renderErrorCause: true });
|
|
761
|
+
} catch {
|
|
762
|
+
try {
|
|
763
|
+
return JSON.stringify(event.cause, null, 2);
|
|
764
|
+
} catch {
|
|
765
|
+
return String(event.cause);
|
|
766
|
+
}
|
|
600
767
|
}
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
kind: "declared",
|
|
606
|
-
...source ? { source } : {}
|
|
607
|
-
});
|
|
768
|
+
})();
|
|
769
|
+
const key = `${moduleId}|${causePretty}`;
|
|
770
|
+
if (browserLifecycleSeen.has(key)) {
|
|
771
|
+
return import_effect4.Effect.void;
|
|
608
772
|
}
|
|
773
|
+
browserLifecycleSeen.add(key);
|
|
774
|
+
return import_effect4.Effect.sync(() => {
|
|
775
|
+
console.groupCollapsed(
|
|
776
|
+
"%c[Logix]%c lifecycle:error %c" + moduleId,
|
|
777
|
+
"color:#ef4444;font-weight:bold",
|
|
778
|
+
// tag
|
|
779
|
+
"color:#ef4444",
|
|
780
|
+
// label
|
|
781
|
+
"color:#9ca3af"
|
|
782
|
+
// module id
|
|
783
|
+
);
|
|
784
|
+
console.error(causePretty);
|
|
785
|
+
console.groupEnd();
|
|
786
|
+
});
|
|
609
787
|
}
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
(a, b) => a.actionTag < b.actionTag ? -1 : a.actionTag > b.actionTag ? 1 : a.sourceKey.localeCompare(b.sourceKey)
|
|
620
|
-
);
|
|
621
|
-
return deduped.length > 0 ? deduped : void 0;
|
|
622
|
-
};
|
|
623
|
-
var resolveSchemaKeys = (input) => {
|
|
624
|
-
if (!isRecord2(input)) return void 0;
|
|
625
|
-
const schemas = input.schemas;
|
|
626
|
-
if (!isRecord2(schemas)) return void 0;
|
|
627
|
-
return Object.keys(schemas).sort();
|
|
628
|
-
};
|
|
629
|
-
var resolveSource = (input) => {
|
|
630
|
-
if (!isRecord2(input)) return void 0;
|
|
631
|
-
const dev = input.dev;
|
|
632
|
-
return resolveDevSource(dev?.source);
|
|
633
|
-
};
|
|
634
|
-
var resolveMeta = (input) => {
|
|
635
|
-
if (!isRecord2(input)) return void 0;
|
|
636
|
-
const meta = input.meta;
|
|
637
|
-
if (!isRecord2(meta)) return void 0;
|
|
638
|
-
const out = {};
|
|
639
|
-
for (const key of Object.keys(meta).sort()) {
|
|
640
|
-
const value = meta[key];
|
|
641
|
-
if (isJsonValue(value)) {
|
|
642
|
-
out[key] = value;
|
|
788
|
+
if (event.type === "diagnostic") {
|
|
789
|
+
const moduleId = event.moduleId ?? "unknown";
|
|
790
|
+
const detail = `code=${event.code} message=${event.message}${event.actionTag ? ` action=${event.actionTag}` : ""}${event.hint ? `
|
|
791
|
+
hint: ${event.hint}` : ""}`;
|
|
792
|
+
const color = event.severity === "warning" ? "color:#d97706" : event.severity === "info" ? "color:#3b82f6" : "color:#ef4444";
|
|
793
|
+
const label = event.severity === "warning" ? "diagnostic(warning)" : event.severity === "info" ? "diagnostic(info)" : "diagnostic(error)";
|
|
794
|
+
const key = `${moduleId}|${event.code}|${event.message}`;
|
|
795
|
+
if (browserDiagnosticSeen.has(key)) {
|
|
796
|
+
return import_effect4.Effect.void;
|
|
643
797
|
}
|
|
798
|
+
browserDiagnosticSeen.add(key);
|
|
799
|
+
return import_effect4.Effect.sync(() => {
|
|
800
|
+
console.groupCollapsed(
|
|
801
|
+
"%c[Logix]%c " + label + "%c module=" + moduleId,
|
|
802
|
+
"color:#6b7280;font-weight:bold",
|
|
803
|
+
color,
|
|
804
|
+
"color:#9ca3af"
|
|
805
|
+
);
|
|
806
|
+
if (event.severity === "warning") {
|
|
807
|
+
console.warn(detail);
|
|
808
|
+
} else if (event.severity === "info") {
|
|
809
|
+
console.info(detail);
|
|
810
|
+
} else {
|
|
811
|
+
console.error(detail);
|
|
812
|
+
}
|
|
813
|
+
console.groupEnd();
|
|
814
|
+
});
|
|
644
815
|
}
|
|
645
|
-
return
|
|
816
|
+
return import_effect4.Effect.void;
|
|
646
817
|
};
|
|
647
|
-
var
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
const out = [];
|
|
654
|
-
for (const unit of mounted) {
|
|
655
|
-
if (!isRecord2(unit)) continue;
|
|
656
|
-
const kind = unit.kind;
|
|
657
|
-
const id = unit.id;
|
|
658
|
-
if (typeof kind !== "string" || kind.length === 0) continue;
|
|
659
|
-
if (typeof id !== "string" || id.length === 0) continue;
|
|
660
|
-
const derived = unit.derived === true ? true : void 0;
|
|
661
|
-
const name = typeof unit.name === "string" ? unit.name : void 0;
|
|
662
|
-
out.push({ kind, id, derived, name });
|
|
818
|
+
var browserConsoleSink = {
|
|
819
|
+
record: (event) => {
|
|
820
|
+
if (!isBrowser) {
|
|
821
|
+
return event.type === "lifecycle:error" ? lifecycleErrorLog(event) : event.type === "diagnostic" ? diagnosticLog(event) : import_effect4.Effect.logDebug({ debugEvent: event });
|
|
822
|
+
}
|
|
823
|
+
return renderBrowserConsoleEvent(event);
|
|
663
824
|
}
|
|
664
|
-
out.sort((a, b) => a.id < b.id ? -1 : a.id > b.id ? 1 : a.kind.localeCompare(b.kind));
|
|
665
|
-
return out.length > 0 ? out : void 0;
|
|
666
825
|
};
|
|
667
|
-
var
|
|
668
|
-
var
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
826
|
+
var browserConsoleLayer = import_effect4.Layer.locallyScoped(currentDebugSinks, [browserConsoleSink]);
|
|
827
|
+
var browserDiagnosticConsoleSink = {
|
|
828
|
+
record: (event) => {
|
|
829
|
+
if (!isBrowser) {
|
|
830
|
+
return event.type === "lifecycle:error" ? lifecycleErrorLog(event) : event.type === "diagnostic" && event.severity !== "info" ? diagnosticLog(event) : import_effect4.Effect.void;
|
|
831
|
+
}
|
|
832
|
+
return event.type === "lifecycle:error" || event.type === "diagnostic" && event.severity !== "info" ? renderBrowserConsoleEvent(event) : import_effect4.Effect.void;
|
|
672
833
|
}
|
|
673
|
-
return json.length;
|
|
674
834
|
};
|
|
675
|
-
var
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
});
|
|
687
|
-
const withMarker = (next2) => {
|
|
688
|
-
const meta = {
|
|
689
|
-
__logix: baseMarker()
|
|
690
|
-
};
|
|
691
|
-
return { ...next2, meta };
|
|
692
|
-
};
|
|
693
|
-
let next = withMarker(manifest);
|
|
694
|
-
const markTruncatedArray = (name) => {
|
|
695
|
-
if (!truncatedArrays.includes(name)) {
|
|
696
|
-
truncatedArrays.push(name);
|
|
697
|
-
}
|
|
698
|
-
};
|
|
699
|
-
const dropField = (field) => {
|
|
700
|
-
if (next[field] !== void 0) {
|
|
701
|
-
dropped.push(String(field));
|
|
702
|
-
next = withMarker({ ...next, [field]: void 0 });
|
|
835
|
+
var browserDiagnosticConsoleLayer = import_effect4.Layer.locallyScoped(currentDebugSinks, [browserDiagnosticConsoleSink]);
|
|
836
|
+
var browserPrettyLoggerLayer = import_effect4.Logger.replace(
|
|
837
|
+
import_effect4.Logger.defaultLogger,
|
|
838
|
+
import_effect4.Logger.prettyLogger({ mode: "browser", colors: true })
|
|
839
|
+
);
|
|
840
|
+
var record = (event) => import_effect4.Effect.gen(function* () {
|
|
841
|
+
const sinks = yield* import_effect4.FiberRef.get(currentDebugSinks);
|
|
842
|
+
if (isErrorOnlyOnlySinks(sinks)) {
|
|
843
|
+
if (event.type === "lifecycle:error") {
|
|
844
|
+
yield* lifecycleErrorLog(event);
|
|
845
|
+
return;
|
|
703
846
|
}
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
dropField("source");
|
|
708
|
-
if (utf8ByteLength(next) <= maxBytes) return next;
|
|
709
|
-
dropField("staticIr");
|
|
710
|
-
if (utf8ByteLength(next) <= maxBytes) return next;
|
|
711
|
-
dropField("logicUnits");
|
|
712
|
-
if (utf8ByteLength(next) <= maxBytes) return next;
|
|
713
|
-
dropField("schemaKeys");
|
|
714
|
-
if (utf8ByteLength(next) <= maxBytes) return next;
|
|
715
|
-
dropField("effects");
|
|
716
|
-
if (utf8ByteLength(next) <= maxBytes) return next;
|
|
717
|
-
const truncateActionsToFit = () => {
|
|
718
|
-
const total = next.actions.length;
|
|
719
|
-
if (total <= 1) return;
|
|
720
|
-
let lo = 1;
|
|
721
|
-
let hi = total;
|
|
722
|
-
let best = 1;
|
|
723
|
-
while (lo <= hi) {
|
|
724
|
-
const mid = Math.floor((lo + hi) / 2);
|
|
725
|
-
const candidate = withMarker({
|
|
726
|
-
...next,
|
|
727
|
-
actions: next.actions.slice(0, mid),
|
|
728
|
-
actionKeys: next.actionKeys.slice(0, mid)
|
|
729
|
-
});
|
|
730
|
-
if (utf8ByteLength(candidate) <= maxBytes) {
|
|
731
|
-
best = mid;
|
|
732
|
-
lo = mid + 1;
|
|
847
|
+
if (event.type === "diagnostic") {
|
|
848
|
+
if (event.severity !== "info") {
|
|
849
|
+
yield* diagnosticLog(event);
|
|
733
850
|
} else {
|
|
734
|
-
|
|
851
|
+
yield* import_effect4.Effect.void;
|
|
735
852
|
}
|
|
853
|
+
return;
|
|
736
854
|
}
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
855
|
+
yield* import_effect4.Effect.void;
|
|
856
|
+
return;
|
|
857
|
+
}
|
|
858
|
+
if (sinks.length === 0) {
|
|
859
|
+
if (isBrowser) {
|
|
860
|
+
if (event.type === "lifecycle:error" || event.type === "diagnostic") {
|
|
861
|
+
yield* renderBrowserConsoleEvent(event);
|
|
862
|
+
return;
|
|
863
|
+
}
|
|
864
|
+
yield* import_effect4.Effect.void;
|
|
865
|
+
return;
|
|
866
|
+
}
|
|
867
|
+
if (event.type === "lifecycle:error") {
|
|
868
|
+
yield* lifecycleErrorLog(event);
|
|
869
|
+
return;
|
|
870
|
+
}
|
|
871
|
+
if (event.type === "diagnostic") {
|
|
872
|
+
yield* diagnosticLog(event);
|
|
873
|
+
return;
|
|
745
874
|
}
|
|
875
|
+
yield* import_effect4.Effect.void;
|
|
876
|
+
return;
|
|
877
|
+
}
|
|
878
|
+
const enriched = event;
|
|
879
|
+
const diagnosticsLevel2 = yield* import_effect4.FiberRef.get(currentDiagnosticsLevel);
|
|
880
|
+
let now;
|
|
881
|
+
const getNow = () => {
|
|
882
|
+
if (now === void 0) now = Date.now();
|
|
883
|
+
return now;
|
|
746
884
|
};
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
885
|
+
if (enriched.timestamp === void 0 && (diagnosticsLevel2 !== "off" || enriched.type === "lifecycle:error" || enriched.type === "diagnostic")) {
|
|
886
|
+
;
|
|
887
|
+
enriched.timestamp = getNow();
|
|
888
|
+
}
|
|
889
|
+
if (diagnosticsLevel2 !== "off" && enriched.runtimeLabel === void 0) {
|
|
890
|
+
const runtimeLabel = yield* import_effect4.FiberRef.get(currentRuntimeLabel);
|
|
891
|
+
if (runtimeLabel) {
|
|
892
|
+
;
|
|
893
|
+
enriched.runtimeLabel = runtimeLabel;
|
|
752
894
|
}
|
|
753
895
|
}
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
const actionKeys = resolveActionKeys(module2);
|
|
760
|
-
const actions = resolveActions(module2);
|
|
761
|
-
const effects = resolveEffects(module2);
|
|
762
|
-
const schemaKeys = resolveSchemaKeys(module2);
|
|
763
|
-
const logicUnits = resolveLogicUnits(module2);
|
|
764
|
-
const source = resolveSource(module2);
|
|
765
|
-
const meta = resolveMeta(module2);
|
|
766
|
-
const staticIr = options?.includeStaticIr ? exportStaticIr2(module2) : void 0;
|
|
767
|
-
const digestBase = {
|
|
768
|
-
manifestVersion,
|
|
769
|
-
moduleId,
|
|
770
|
-
actionKeys,
|
|
771
|
-
actions,
|
|
772
|
-
effects,
|
|
773
|
-
schemaKeys,
|
|
774
|
-
logicUnits,
|
|
775
|
-
staticIrDigest: staticIr?.digest
|
|
776
|
-
};
|
|
777
|
-
const digest = digestOf(digestBase);
|
|
778
|
-
const manifest = {
|
|
779
|
-
manifestVersion,
|
|
780
|
-
moduleId,
|
|
781
|
-
actionKeys,
|
|
782
|
-
actions,
|
|
783
|
-
effects,
|
|
784
|
-
schemaKeys,
|
|
785
|
-
logicUnits,
|
|
786
|
-
source,
|
|
787
|
-
meta,
|
|
788
|
-
staticIr,
|
|
789
|
-
digest
|
|
790
|
-
};
|
|
791
|
-
const maxBytes = options?.budgets?.maxBytes;
|
|
792
|
-
if (typeof maxBytes === "number" && Number.isFinite(maxBytes) && maxBytes > 0) {
|
|
793
|
-
return applyMaxBytes(manifest, maxBytes);
|
|
794
|
-
}
|
|
795
|
-
return manifest;
|
|
796
|
-
};
|
|
797
|
-
|
|
798
|
-
// src/internal/reflection/diff.ts
|
|
799
|
-
var SEVERITY_RANK = {
|
|
800
|
-
BREAKING: 0,
|
|
801
|
-
RISKY: 1,
|
|
802
|
-
INFO: 2
|
|
803
|
-
};
|
|
804
|
-
var uniqSorted = (input) => {
|
|
805
|
-
const out = Array.from(new Set(input.filter((x) => typeof x === "string" && x.length > 0)));
|
|
806
|
-
out.sort((a, b) => a.localeCompare(b));
|
|
807
|
-
return out;
|
|
808
|
-
};
|
|
809
|
-
var diffStringKeys = (before, after) => {
|
|
810
|
-
const beforeSet = new Set(uniqSorted(before ?? []));
|
|
811
|
-
const afterSet = new Set(uniqSorted(after ?? []));
|
|
812
|
-
const removed = [];
|
|
813
|
-
for (const k of beforeSet) {
|
|
814
|
-
if (!afterSet.has(k)) removed.push(k);
|
|
815
|
-
}
|
|
816
|
-
removed.sort((a, b) => a.localeCompare(b));
|
|
817
|
-
const added = [];
|
|
818
|
-
for (const k of afterSet) {
|
|
819
|
-
if (!beforeSet.has(k)) added.push(k);
|
|
820
|
-
}
|
|
821
|
-
added.sort((a, b) => a.localeCompare(b));
|
|
822
|
-
return { removed, added };
|
|
823
|
-
};
|
|
824
|
-
var eqJsonValue = (a, b) => stableStringify(a) === stableStringify(b);
|
|
825
|
-
var indexLogicUnits = (input) => {
|
|
826
|
-
const map = /* @__PURE__ */ new Map();
|
|
827
|
-
for (const unit of input ?? []) {
|
|
828
|
-
if (!unit || typeof unit !== "object") continue;
|
|
829
|
-
const id = unit.id;
|
|
830
|
-
if (typeof id !== "string" || id.length === 0) continue;
|
|
831
|
-
map.set(id, unit);
|
|
832
|
-
}
|
|
833
|
-
return map;
|
|
834
|
-
};
|
|
835
|
-
var diffManifest = (before, after, options) => {
|
|
836
|
-
const changes = [];
|
|
837
|
-
if (before.moduleId !== after.moduleId) {
|
|
838
|
-
changes.push({
|
|
839
|
-
severity: "BREAKING",
|
|
840
|
-
code: "moduleId.changed",
|
|
841
|
-
message: `moduleId changed (${before.moduleId} -> ${after.moduleId})`,
|
|
842
|
-
pointer: "/moduleId",
|
|
843
|
-
details: {
|
|
844
|
-
before: before.moduleId,
|
|
845
|
-
after: after.moduleId
|
|
846
|
-
}
|
|
847
|
-
});
|
|
848
|
-
}
|
|
849
|
-
if (before.manifestVersion !== after.manifestVersion) {
|
|
850
|
-
changes.push({
|
|
851
|
-
severity: "INFO",
|
|
852
|
-
code: "manifestVersion.changed",
|
|
853
|
-
message: `manifestVersion changed (${before.manifestVersion} -> ${after.manifestVersion})`,
|
|
854
|
-
pointer: "/manifestVersion",
|
|
855
|
-
details: {
|
|
856
|
-
before: before.manifestVersion,
|
|
857
|
-
after: after.manifestVersion
|
|
858
|
-
}
|
|
859
|
-
});
|
|
860
|
-
}
|
|
861
|
-
{
|
|
862
|
-
const { removed, added } = diffStringKeys(before.actionKeys, after.actionKeys);
|
|
863
|
-
if (removed.length > 0 || added.length > 0) {
|
|
864
|
-
changes.push({
|
|
865
|
-
severity: removed.length > 0 ? "BREAKING" : "INFO",
|
|
866
|
-
code: "actionKeys.changed",
|
|
867
|
-
message: removed.length > 0 ? `actionKeys removed: ${removed.join(", ")}` : `actionKeys added: ${added.join(", ")}`,
|
|
868
|
-
pointer: "/actionKeys",
|
|
869
|
-
details: { removed, added }
|
|
870
|
-
});
|
|
896
|
+
if (enriched.type === "diagnostic" && enriched.txnId === void 0) {
|
|
897
|
+
const txnId = yield* import_effect4.FiberRef.get(currentTxnId);
|
|
898
|
+
if (txnId) {
|
|
899
|
+
;
|
|
900
|
+
enriched.txnId = txnId;
|
|
871
901
|
}
|
|
872
902
|
}
|
|
873
|
-
{
|
|
874
|
-
const
|
|
875
|
-
if (
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
code: "schemaKeys.changed",
|
|
879
|
-
message: removed.length > 0 ? `schemaKeys removed: ${removed.join(", ")}` : `schemaKeys added: ${added.join(", ")}`,
|
|
880
|
-
pointer: "/schemaKeys",
|
|
881
|
-
details: { removed, added }
|
|
882
|
-
});
|
|
903
|
+
if (diagnosticsLevel2 !== "off" && enriched.type === "trace:effectop" && enriched.linkId === void 0) {
|
|
904
|
+
const linkId = yield* import_effect4.FiberRef.get(currentLinkId);
|
|
905
|
+
if (linkId) {
|
|
906
|
+
;
|
|
907
|
+
enriched.linkId = linkId;
|
|
883
908
|
}
|
|
884
909
|
}
|
|
885
|
-
{
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
910
|
+
if (sinks.length === 1) {
|
|
911
|
+
yield* sinks[0].record(enriched);
|
|
912
|
+
return;
|
|
913
|
+
}
|
|
914
|
+
yield* import_effect4.Effect.forEach(sinks, (sink) => sink.record(enriched), { discard: true });
|
|
915
|
+
});
|
|
916
|
+
var toRuntimeDebugEventRef = (event, options) => {
|
|
917
|
+
const diagnosticsLevel2 = options?.diagnosticsLevel ?? "full";
|
|
918
|
+
if (diagnosticsLevel2 === "off") {
|
|
919
|
+
return void 0;
|
|
920
|
+
}
|
|
921
|
+
const isLightLike = diagnosticsLevel2 === "light" || diagnosticsLevel2 === "sampled";
|
|
922
|
+
const timestamp = typeof event.timestamp === "number" && Number.isFinite(event.timestamp) ? event.timestamp : Date.now();
|
|
923
|
+
const moduleIdRaw = event.moduleId;
|
|
924
|
+
const moduleId = typeof moduleIdRaw === "string" && moduleIdRaw.length > 0 ? moduleIdRaw : "unknown";
|
|
925
|
+
const instanceIdRaw = event.instanceId;
|
|
926
|
+
const instanceId = typeof instanceIdRaw === "string" && instanceIdRaw.length > 0 ? instanceIdRaw : "unknown";
|
|
927
|
+
const runtimeLabelRaw = event.runtimeLabel;
|
|
928
|
+
const runtimeLabel = typeof runtimeLabelRaw === "string" && runtimeLabelRaw.length > 0 ? runtimeLabelRaw : void 0;
|
|
929
|
+
const txnSeqRaw = event.txnSeq;
|
|
930
|
+
const txnSeq = typeof txnSeqRaw === "number" && Number.isFinite(txnSeqRaw) && txnSeqRaw >= 0 ? Math.floor(txnSeqRaw) : 0;
|
|
931
|
+
const txnIdRaw = event.txnId;
|
|
932
|
+
const txnId = typeof txnIdRaw === "string" && txnIdRaw.length > 0 ? txnIdRaw : txnSeq > 0 ? `${instanceId}::t${txnSeq}` : void 0;
|
|
933
|
+
const linkId = (() => {
|
|
934
|
+
const linkIdRaw = event.linkId;
|
|
935
|
+
if (typeof linkIdRaw === "string" && linkIdRaw.length > 0) return linkIdRaw;
|
|
936
|
+
if (typeof event.type !== "string" || !event.type.startsWith("trace:")) {
|
|
937
|
+
return void 0;
|
|
912
938
|
}
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
939
|
+
const data = event.data;
|
|
940
|
+
const meta = data?.meta;
|
|
941
|
+
const linkIdFromMeta = meta?.linkId;
|
|
942
|
+
if (typeof linkIdFromMeta === "string" && linkIdFromMeta.length > 0) return linkIdFromMeta;
|
|
943
|
+
return void 0;
|
|
944
|
+
})();
|
|
945
|
+
const eventSeqRaw = options?.eventSeq;
|
|
946
|
+
const eventSeq = typeof eventSeqRaw === "number" && Number.isFinite(eventSeqRaw) && eventSeqRaw > 0 ? Math.floor(eventSeqRaw) : nextEventSeq();
|
|
947
|
+
const eventId = makeEventId(instanceId, eventSeq);
|
|
948
|
+
const base = {
|
|
949
|
+
eventId,
|
|
950
|
+
eventSeq,
|
|
951
|
+
moduleId,
|
|
952
|
+
instanceId,
|
|
953
|
+
runtimeLabel,
|
|
954
|
+
txnSeq,
|
|
955
|
+
txnId,
|
|
956
|
+
linkId,
|
|
957
|
+
timestamp
|
|
958
|
+
};
|
|
959
|
+
let downgrade;
|
|
960
|
+
const withDowngrade = (ref) => {
|
|
961
|
+
if (!downgrade) return ref;
|
|
962
|
+
return { ...ref, downgrade: { reason: downgrade } };
|
|
963
|
+
};
|
|
964
|
+
switch (event.type) {
|
|
965
|
+
case "module:init":
|
|
966
|
+
return withDowngrade({
|
|
967
|
+
...base,
|
|
968
|
+
kind: "lifecycle",
|
|
969
|
+
label: "module:init"
|
|
922
970
|
});
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
message: `logicUnits kind changed: ${kindChanged.map((x) => x.id).join(", ")}`,
|
|
929
|
-
pointer: "/logicUnits",
|
|
930
|
-
details: { kindChanged }
|
|
971
|
+
case "module:destroy":
|
|
972
|
+
return withDowngrade({
|
|
973
|
+
...base,
|
|
974
|
+
kind: "lifecycle",
|
|
975
|
+
label: "module:destroy"
|
|
931
976
|
});
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
details: { added }
|
|
977
|
+
case "lifecycle:phase": {
|
|
978
|
+
const e = event;
|
|
979
|
+
const metaInput = isLightLike ? { type: "lifecycle:phase", phase: e.phase, name: e.name } : { type: "lifecycle:phase", phase: e.phase, name: e.name, payload: e.payload };
|
|
980
|
+
const metaProjection = projectJsonValue(metaInput);
|
|
981
|
+
options?.onMetaProjection?.({
|
|
982
|
+
stats: metaProjection.stats,
|
|
983
|
+
downgrade: metaProjection.downgrade
|
|
940
984
|
});
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
pointer: "/logicUnits",
|
|
948
|
-
details: { changed: riskyChanged }
|
|
985
|
+
downgrade = mergeDowngrade2(downgrade, metaProjection.downgrade);
|
|
986
|
+
return withDowngrade({
|
|
987
|
+
...base,
|
|
988
|
+
kind: "lifecycle",
|
|
989
|
+
label: e.name,
|
|
990
|
+
meta: metaProjection.value
|
|
949
991
|
});
|
|
950
992
|
}
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
after: afterDigest ?? null
|
|
964
|
-
}
|
|
993
|
+
case "action:dispatch": {
|
|
994
|
+
const action = event.action;
|
|
995
|
+
const actionTagRaw = event.actionTag;
|
|
996
|
+
const tag = typeof actionTagRaw === "string" && actionTagRaw.length > 0 ? actionTagRaw : action?._tag ?? action?.type;
|
|
997
|
+
const label = String(tag ?? "action:dispatch");
|
|
998
|
+
const labelNormalized = label.length > 0 ? label : "unknown";
|
|
999
|
+
const unknownAction = event.unknownAction === true ? true : void 0;
|
|
1000
|
+
const metaInput = isLightLike ? { actionTag: labelNormalized, ...unknownAction ? { unknownAction: true } : {} } : { action, ...unknownAction ? { unknownAction: true } : {} };
|
|
1001
|
+
const metaProjection = projectJsonValue(metaInput);
|
|
1002
|
+
options?.onMetaProjection?.({
|
|
1003
|
+
stats: metaProjection.stats,
|
|
1004
|
+
downgrade: metaProjection.downgrade
|
|
965
1005
|
});
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
const metaBefore = before.meta ?? {};
|
|
970
|
-
const metaAfter = after.meta ?? {};
|
|
971
|
-
const allowlist = options?.metaAllowlist;
|
|
972
|
-
const keys = allowlist != null ? uniqSorted(allowlist) : uniqSorted([...Object.keys(metaBefore), ...Object.keys(metaAfter)]);
|
|
973
|
-
const changed = [];
|
|
974
|
-
for (const key of keys) {
|
|
975
|
-
const b = key in metaBefore ? metaBefore[key] : void 0;
|
|
976
|
-
const a = key in metaAfter ? metaAfter[key] : void 0;
|
|
977
|
-
if (!eqJsonValue(b, a)) {
|
|
978
|
-
changed.push({
|
|
979
|
-
key,
|
|
980
|
-
before: b ?? null,
|
|
981
|
-
after: a ?? null
|
|
982
|
-
});
|
|
1006
|
+
downgrade = mergeDowngrade2(downgrade, metaProjection.downgrade);
|
|
1007
|
+
if (unknownAction) {
|
|
1008
|
+
downgrade = mergeDowngrade2(downgrade, "unknown");
|
|
983
1009
|
}
|
|
1010
|
+
return withDowngrade({
|
|
1011
|
+
...base,
|
|
1012
|
+
kind: "action",
|
|
1013
|
+
label: labelNormalized,
|
|
1014
|
+
meta: metaProjection.value
|
|
1015
|
+
});
|
|
984
1016
|
}
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
1017
|
+
case "state:update": {
|
|
1018
|
+
const e = event;
|
|
1019
|
+
const resolveDirtySetRootPaths = () => {
|
|
1020
|
+
const resolve2 = options?.resolveConvergeStaticIr;
|
|
1021
|
+
if (!resolve2) return void 0;
|
|
1022
|
+
const digest = e.staticIrDigest;
|
|
1023
|
+
if (typeof digest !== "string" || digest.length === 0) return void 0;
|
|
1024
|
+
const dirtySet = e.dirtySet;
|
|
1025
|
+
if (!dirtySet || typeof dirtySet !== "object" || Array.isArray(dirtySet)) return void 0;
|
|
1026
|
+
const rootIds = dirtySet.rootIds;
|
|
1027
|
+
if (!Array.isArray(rootIds) || rootIds.length === 0) return void 0;
|
|
1028
|
+
const ir = resolve2(digest);
|
|
1029
|
+
const fieldPaths = ir?.fieldPaths;
|
|
1030
|
+
if (!Array.isArray(fieldPaths) || fieldPaths.length === 0) return void 0;
|
|
1031
|
+
const out = [];
|
|
1032
|
+
for (const rawId of rootIds) {
|
|
1033
|
+
if (typeof rawId !== "number" || !Number.isFinite(rawId)) continue;
|
|
1034
|
+
const id = Math.floor(rawId);
|
|
1035
|
+
if (id < 0) continue;
|
|
1036
|
+
const path = fieldPaths[id];
|
|
1037
|
+
if (!Array.isArray(path) || path.length === 0) continue;
|
|
1038
|
+
if (!path.every((seg) => typeof seg === "string" && seg.length > 0)) continue;
|
|
1039
|
+
out.push(path);
|
|
994
1040
|
}
|
|
1041
|
+
return out.length > 0 ? out : void 0;
|
|
1042
|
+
};
|
|
1043
|
+
const dirtySetWithRootPaths = (() => {
|
|
1044
|
+
const rootPaths = resolveDirtySetRootPaths();
|
|
1045
|
+
if (!rootPaths) return e.dirtySet;
|
|
1046
|
+
const dirtySet = e.dirtySet;
|
|
1047
|
+
if (!dirtySet || typeof dirtySet !== "object" || Array.isArray(dirtySet)) return e.dirtySet;
|
|
1048
|
+
return { ...dirtySet, rootPaths };
|
|
1049
|
+
})();
|
|
1050
|
+
const metaInput = isLightLike ? {
|
|
1051
|
+
state: e.state,
|
|
1052
|
+
dirtySet: dirtySetWithRootPaths,
|
|
1053
|
+
patchCount: e.patchCount,
|
|
1054
|
+
patchesTruncated: e.patchesTruncated,
|
|
1055
|
+
patchesTruncatedReason: e.patchesTruncatedReason,
|
|
1056
|
+
staticIrDigest: e.staticIrDigest,
|
|
1057
|
+
commitMode: e.commitMode,
|
|
1058
|
+
priority: e.priority,
|
|
1059
|
+
originKind: e.originKind,
|
|
1060
|
+
originName: e.originName
|
|
1061
|
+
} : {
|
|
1062
|
+
state: e.state,
|
|
1063
|
+
dirtySet: dirtySetWithRootPaths,
|
|
1064
|
+
patchCount: e.patchCount,
|
|
1065
|
+
patchesTruncated: e.patchesTruncated,
|
|
1066
|
+
patchesTruncatedReason: e.patchesTruncatedReason,
|
|
1067
|
+
staticIrDigest: e.staticIrDigest,
|
|
1068
|
+
commitMode: e.commitMode,
|
|
1069
|
+
priority: e.priority,
|
|
1070
|
+
originKind: e.originKind,
|
|
1071
|
+
originName: e.originName,
|
|
1072
|
+
traitSummary: e.traitSummary,
|
|
1073
|
+
replayEvent: e.replayEvent
|
|
1074
|
+
};
|
|
1075
|
+
const metaProjection = projectJsonValue(metaInput);
|
|
1076
|
+
options?.onMetaProjection?.({
|
|
1077
|
+
stats: metaProjection.stats,
|
|
1078
|
+
downgrade: metaProjection.downgrade
|
|
1079
|
+
});
|
|
1080
|
+
downgrade = mergeDowngrade2(downgrade, metaProjection.downgrade);
|
|
1081
|
+
if (txnId) {
|
|
1082
|
+
lastTxnByInstance.set(instanceId, { txnId, txnSeq });
|
|
1083
|
+
backfillPendingTxnAlignment(instanceId, { txnId, txnSeq });
|
|
1084
|
+
}
|
|
1085
|
+
return withDowngrade({
|
|
1086
|
+
...base,
|
|
1087
|
+
kind: "state",
|
|
1088
|
+
label: "state:update",
|
|
1089
|
+
meta: metaProjection.value
|
|
995
1090
|
});
|
|
996
1091
|
}
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1092
|
+
case "process:start":
|
|
1093
|
+
case "process:stop":
|
|
1094
|
+
case "process:restart":
|
|
1095
|
+
case "process:trigger":
|
|
1096
|
+
case "process:dispatch":
|
|
1097
|
+
case "process:error": {
|
|
1098
|
+
const e = event;
|
|
1099
|
+
const ts2 = typeof e.timestampMs === "number" && Number.isFinite(e.timestampMs) ? e.timestampMs : timestamp;
|
|
1100
|
+
const metaInput = {
|
|
1101
|
+
identity: e.identity,
|
|
1102
|
+
severity: e.severity,
|
|
1103
|
+
eventSeq: e.eventSeq,
|
|
1104
|
+
timestampMs: e.timestampMs,
|
|
1105
|
+
trigger: e.trigger,
|
|
1106
|
+
dispatch: e.dispatch,
|
|
1107
|
+
error: e.error
|
|
1108
|
+
};
|
|
1109
|
+
const metaProjection = projectJsonValue(metaInput);
|
|
1110
|
+
options?.onMetaProjection?.({
|
|
1111
|
+
stats: metaProjection.stats,
|
|
1112
|
+
downgrade: metaProjection.downgrade
|
|
1113
|
+
});
|
|
1114
|
+
downgrade = mergeDowngrade2(downgrade, metaProjection.downgrade);
|
|
1115
|
+
const errorSummary = e.type === "process:error" || e.type === "process:restart" ? e.error : void 0;
|
|
1116
|
+
return withDowngrade({
|
|
1117
|
+
...base,
|
|
1118
|
+
timestamp: ts2,
|
|
1119
|
+
kind: "process",
|
|
1120
|
+
label: e.type,
|
|
1121
|
+
meta: metaProjection.value,
|
|
1122
|
+
errorSummary
|
|
1011
1123
|
});
|
|
1012
1124
|
}
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
version: "025",
|
|
1032
|
-
moduleId: after.moduleId,
|
|
1033
|
-
before: {
|
|
1034
|
-
digest: before.digest,
|
|
1035
|
-
manifestVersion: before.manifestVersion
|
|
1036
|
-
},
|
|
1037
|
-
after: {
|
|
1038
|
-
digest: after.digest,
|
|
1039
|
-
manifestVersion: after.manifestVersion
|
|
1040
|
-
},
|
|
1041
|
-
verdict,
|
|
1042
|
-
changes,
|
|
1043
|
-
summary
|
|
1044
|
-
};
|
|
1045
|
-
};
|
|
1046
|
-
|
|
1047
|
-
// src/internal/reflection/kernelContract.ts
|
|
1048
|
-
var import_effect34 = require("effect");
|
|
1049
|
-
|
|
1050
|
-
// src/internal/observability/trialRun.ts
|
|
1051
|
-
var import_effect33 = require("effect");
|
|
1052
|
-
|
|
1053
|
-
// src/internal/observability/evidenceCollector.ts
|
|
1054
|
-
var import_effect8 = require("effect");
|
|
1055
|
-
|
|
1056
|
-
// src/internal/observability/runSession.ts
|
|
1057
|
-
var import_effect4 = require("effect");
|
|
1058
|
-
|
|
1059
|
-
// src/internal/observability/evidence.ts
|
|
1060
|
-
var OBSERVABILITY_PROTOCOL_VERSION = "v1";
|
|
1061
|
-
var exportEvidencePackage = (options) => {
|
|
1062
|
-
const protocolVersion = options.protocolVersion ?? OBSERVABILITY_PROTOCOL_VERSION;
|
|
1063
|
-
return {
|
|
1064
|
-
protocolVersion,
|
|
1065
|
-
runId: options.runId,
|
|
1066
|
-
createdAt: options.createdAt ?? Date.now(),
|
|
1067
|
-
source: options.source,
|
|
1068
|
-
events: options.events.slice().sort((a, b) => a.seq - b.seq),
|
|
1069
|
-
summary: options.summary
|
|
1070
|
-
};
|
|
1071
|
-
};
|
|
1072
|
-
|
|
1073
|
-
// src/internal/observability/runSession.ts
|
|
1074
|
-
var RunSessionTagImpl = class extends import_effect4.Context.Tag("@logixjs/core/RunSession")() {
|
|
1075
|
-
};
|
|
1076
|
-
var RunSessionTag = RunSessionTagImpl;
|
|
1077
|
-
var NEXT_RUN_SEQ_KEY = /* @__PURE__ */ Symbol.for("@logixjs/core/runSession/nextRunSeq");
|
|
1078
|
-
var fallbackNextRunSeq = 0;
|
|
1079
|
-
var nextRunSeq = () => {
|
|
1080
|
-
try {
|
|
1081
|
-
const g = globalThis;
|
|
1082
|
-
const prev = typeof g[NEXT_RUN_SEQ_KEY] === "number" ? g[NEXT_RUN_SEQ_KEY] : 0;
|
|
1083
|
-
const next = prev + 1;
|
|
1084
|
-
g[NEXT_RUN_SEQ_KEY] = next;
|
|
1085
|
-
return next;
|
|
1086
|
-
} catch {
|
|
1087
|
-
fallbackNextRunSeq += 1;
|
|
1088
|
-
return fallbackNextRunSeq;
|
|
1089
|
-
}
|
|
1090
|
-
};
|
|
1091
|
-
var makeRunId = (startedAt) => `run-${startedAt}.${nextRunSeq()}`;
|
|
1092
|
-
var makeRunSessionLocalState = () => {
|
|
1093
|
-
const onceKeys = /* @__PURE__ */ new Set();
|
|
1094
|
-
const seqByNamespace = /* @__PURE__ */ new Map();
|
|
1095
|
-
return {
|
|
1096
|
-
once: (key) => {
|
|
1097
|
-
if (onceKeys.has(key)) return false;
|
|
1098
|
-
onceKeys.add(key);
|
|
1099
|
-
return true;
|
|
1100
|
-
},
|
|
1101
|
-
nextSeq: (namespace, key) => {
|
|
1102
|
-
const byKey = seqByNamespace.get(namespace) ?? /* @__PURE__ */ new Map();
|
|
1103
|
-
if (!seqByNamespace.has(namespace)) seqByNamespace.set(namespace, byKey);
|
|
1104
|
-
const prev = byKey.get(key) ?? 0;
|
|
1105
|
-
const next = prev + 1;
|
|
1106
|
-
byKey.set(key, next);
|
|
1107
|
-
return next;
|
|
1108
|
-
},
|
|
1109
|
-
clear: () => {
|
|
1110
|
-
onceKeys.clear();
|
|
1111
|
-
seqByNamespace.clear();
|
|
1112
|
-
}
|
|
1113
|
-
};
|
|
1114
|
-
};
|
|
1115
|
-
var makeRunSession = (options) => {
|
|
1116
|
-
const startedAt = options?.startedAt ?? Date.now();
|
|
1117
|
-
return {
|
|
1118
|
-
runId: options?.runId ?? makeRunId(startedAt),
|
|
1119
|
-
source: options?.source ?? { host: "unknown" },
|
|
1120
|
-
startedAt,
|
|
1121
|
-
local: options?.local ?? makeRunSessionLocalState()
|
|
1122
|
-
};
|
|
1123
|
-
};
|
|
1124
|
-
var makeEvidenceSink = (session) => {
|
|
1125
|
-
const events = [];
|
|
1126
|
-
let nextSeq = 1;
|
|
1127
|
-
return {
|
|
1128
|
-
record: (type, payload, options) => {
|
|
1129
|
-
events.push({
|
|
1130
|
-
protocolVersion: OBSERVABILITY_PROTOCOL_VERSION,
|
|
1131
|
-
runId: session.runId,
|
|
1132
|
-
seq: nextSeq++,
|
|
1133
|
-
timestamp: options?.timestamp ?? Date.now(),
|
|
1134
|
-
type,
|
|
1135
|
-
payload
|
|
1125
|
+
case "lifecycle:error": {
|
|
1126
|
+
const e = event;
|
|
1127
|
+
const summary = toSerializableErrorSummary(e.cause);
|
|
1128
|
+
downgrade = mergeDowngrade2(downgrade, summary.downgrade);
|
|
1129
|
+
const metaInput = isLightLike ? { type: "lifecycle:error", phase: e.phase, name: e.hook } : {
|
|
1130
|
+
type: "lifecycle:error",
|
|
1131
|
+
phase: e.phase,
|
|
1132
|
+
name: e.hook,
|
|
1133
|
+
hook: e.hook,
|
|
1134
|
+
taskId: e.taskId,
|
|
1135
|
+
origin: e.origin,
|
|
1136
|
+
txnSeq: e.txnSeq,
|
|
1137
|
+
opSeq: e.opSeq
|
|
1138
|
+
};
|
|
1139
|
+
const metaProjection = projectJsonValue(metaInput);
|
|
1140
|
+
options?.onMetaProjection?.({
|
|
1141
|
+
stats: metaProjection.stats,
|
|
1142
|
+
downgrade: metaProjection.downgrade
|
|
1136
1143
|
});
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
runId: session.runId,
|
|
1145
|
-
source: session.source,
|
|
1146
|
-
createdAt: options?.createdAt,
|
|
1147
|
-
events: selected,
|
|
1148
|
-
summary: options?.summary
|
|
1144
|
+
downgrade = mergeDowngrade2(downgrade, metaProjection.downgrade);
|
|
1145
|
+
return withDowngrade({
|
|
1146
|
+
...base,
|
|
1147
|
+
kind: "lifecycle",
|
|
1148
|
+
label: "lifecycle:error",
|
|
1149
|
+
meta: metaProjection.value,
|
|
1150
|
+
errorSummary: summary.errorSummary
|
|
1149
1151
|
});
|
|
1150
|
-
},
|
|
1151
|
-
clear: () => {
|
|
1152
|
-
events.length = 0;
|
|
1153
|
-
nextSeq = 1;
|
|
1154
|
-
}
|
|
1155
|
-
};
|
|
1156
|
-
};
|
|
1157
|
-
var runSessionLayer = (session) => import_effect4.Layer.succeed(RunSessionTag, session ?? makeRunSession());
|
|
1158
|
-
|
|
1159
|
-
// src/internal/runtime/core/DebugSink.ts
|
|
1160
|
-
var import_effect7 = require("effect");
|
|
1161
|
-
|
|
1162
|
-
// src/internal/runtime/core/errorSummary.ts
|
|
1163
|
-
var import_effect5 = require("effect");
|
|
1164
|
-
var truncate = (value, maxLen) => {
|
|
1165
|
-
if (value.length <= maxLen) return { value, truncated: false };
|
|
1166
|
-
return { value: value.slice(0, maxLen), truncated: true };
|
|
1167
|
-
};
|
|
1168
|
-
var safeStringify = (value) => {
|
|
1169
|
-
try {
|
|
1170
|
-
return { ok: true, json: JSON.stringify(value) };
|
|
1171
|
-
} catch {
|
|
1172
|
-
return { ok: false };
|
|
1173
|
-
}
|
|
1174
|
-
};
|
|
1175
|
-
var getMessageFromUnknown = (cause) => {
|
|
1176
|
-
if (typeof cause === "string") return cause;
|
|
1177
|
-
if (typeof cause === "number" || typeof cause === "boolean" || typeof cause === "bigint") return String(cause);
|
|
1178
|
-
if (cause instanceof Error) return cause.message || cause.name || "Error";
|
|
1179
|
-
if (cause && typeof cause === "object" && "message" in cause && typeof cause.message === "string") {
|
|
1180
|
-
return cause.message;
|
|
1181
|
-
}
|
|
1182
|
-
try {
|
|
1183
|
-
const pretty = import_effect5.Cause.pretty(cause, { renderErrorCause: true });
|
|
1184
|
-
if (typeof pretty === "string" && pretty.length > 0) return pretty;
|
|
1185
|
-
} catch {
|
|
1186
|
-
}
|
|
1187
|
-
return "Unknown error";
|
|
1188
|
-
};
|
|
1189
|
-
var toSerializableErrorSummary = (cause, options) => {
|
|
1190
|
-
const maxMessageLength = options?.maxMessageLength ?? 256;
|
|
1191
|
-
const messageRaw = getMessageFromUnknown(cause);
|
|
1192
|
-
const { value: message, truncated } = truncate(messageRaw, maxMessageLength);
|
|
1193
|
-
const summary = {
|
|
1194
|
-
message
|
|
1195
|
-
};
|
|
1196
|
-
if (cause instanceof Error) {
|
|
1197
|
-
if (cause.name && cause.name !== "Error") summary.name = cause.name;
|
|
1198
|
-
const anyCause = cause;
|
|
1199
|
-
if (typeof anyCause.code === "string" && anyCause.code.length > 0) summary.code = anyCause.code;
|
|
1200
|
-
else if (typeof anyCause.code === "number" && Number.isFinite(anyCause.code)) summary.code = String(anyCause.code);
|
|
1201
|
-
if (typeof anyCause.hint === "string" && anyCause.hint.length > 0) summary.hint = anyCause.hint;
|
|
1202
|
-
return {
|
|
1203
|
-
errorSummary: summary,
|
|
1204
|
-
downgrade: truncated ? "oversized" : void 0
|
|
1205
|
-
};
|
|
1206
|
-
}
|
|
1207
|
-
if (cause && typeof cause === "object") {
|
|
1208
|
-
const anyCause = cause;
|
|
1209
|
-
if (typeof anyCause.name === "string" && anyCause.name.length > 0) summary.name = anyCause.name;
|
|
1210
|
-
if (typeof anyCause.code === "string" && anyCause.code.length > 0) summary.code = anyCause.code;
|
|
1211
|
-
if (typeof anyCause.hint === "string" && anyCause.hint.length > 0) summary.hint = anyCause.hint;
|
|
1212
|
-
}
|
|
1213
|
-
const stringifyResult = safeStringify(cause);
|
|
1214
|
-
if (!stringifyResult.ok) {
|
|
1215
|
-
return {
|
|
1216
|
-
errorSummary: summary,
|
|
1217
|
-
downgrade: "non_serializable"
|
|
1218
|
-
};
|
|
1219
|
-
}
|
|
1220
|
-
if (truncated) {
|
|
1221
|
-
return {
|
|
1222
|
-
errorSummary: summary,
|
|
1223
|
-
downgrade: "oversized"
|
|
1224
|
-
};
|
|
1225
|
-
}
|
|
1226
|
-
if (message === "Unknown error") {
|
|
1227
|
-
return {
|
|
1228
|
-
errorSummary: summary,
|
|
1229
|
-
downgrade: "unknown"
|
|
1230
|
-
};
|
|
1231
|
-
}
|
|
1232
|
-
return { errorSummary: summary };
|
|
1233
|
-
};
|
|
1234
|
-
|
|
1235
|
-
// src/internal/runtime/core/EffectOpCore.ts
|
|
1236
|
-
var import_effect6 = require("effect");
|
|
1237
|
-
var currentLinkId = import_effect6.FiberRef.unsafeMake(void 0);
|
|
1238
|
-
var EffectOpMiddlewareTag = class extends import_effect6.Context.Tag("Logix/EffectOpMiddleware")() {
|
|
1239
|
-
};
|
|
1240
|
-
|
|
1241
|
-
// src/internal/runtime/core/DebugSink.ts
|
|
1242
|
-
var currentDebugSinks = import_effect7.FiberRef.unsafeMake([]);
|
|
1243
|
-
var currentRuntimeLabel = import_effect7.FiberRef.unsafeMake(void 0);
|
|
1244
|
-
var currentTxnId = import_effect7.FiberRef.unsafeMake(void 0);
|
|
1245
|
-
var currentOpSeq = import_effect7.FiberRef.unsafeMake(void 0);
|
|
1246
|
-
var currentDiagnosticsLevel = import_effect7.FiberRef.unsafeMake("off");
|
|
1247
|
-
var diagnosticsLevel = (level) => import_effect7.Layer.fiberRefLocallyScopedWith(currentDiagnosticsLevel, () => level);
|
|
1248
|
-
var currentTraitConvergeDiagnosticsSampling = import_effect7.FiberRef.unsafeMake({
|
|
1249
|
-
sampleEveryN: 32,
|
|
1250
|
-
topK: 3
|
|
1251
|
-
});
|
|
1252
|
-
var appendSinks = (sinks) => import_effect7.Layer.fiberRefLocallyScopedWith(currentDebugSinks, (current) => [...current, ...sinks]);
|
|
1253
|
-
var nextGlobalEventSeq = 0;
|
|
1254
|
-
var nextEventSeq = () => {
|
|
1255
|
-
nextGlobalEventSeq += 1;
|
|
1256
|
-
return nextGlobalEventSeq;
|
|
1257
|
-
};
|
|
1258
|
-
var makeEventId = (instanceId, eventSeq) => `${instanceId}::e${eventSeq}`;
|
|
1259
|
-
var mergeDowngrade2 = (current, next) => {
|
|
1260
|
-
if (!current) return next;
|
|
1261
|
-
if (!next) return current;
|
|
1262
|
-
if (current === "non_serializable" || next === "non_serializable") return "non_serializable";
|
|
1263
|
-
if (current === "oversized" || next === "oversized") return "oversized";
|
|
1264
|
-
return "unknown";
|
|
1265
|
-
};
|
|
1266
|
-
var browserLifecycleSeen = /* @__PURE__ */ new Set();
|
|
1267
|
-
var browserDiagnosticSeen = /* @__PURE__ */ new Set();
|
|
1268
|
-
var lastTxnByInstance = /* @__PURE__ */ new Map();
|
|
1269
|
-
var pendingTxnAlignmentByInstance = /* @__PURE__ */ new Map();
|
|
1270
|
-
var enqueuePendingTxnAlignment = (instanceId, ref) => {
|
|
1271
|
-
const list = pendingTxnAlignmentByInstance.get(instanceId);
|
|
1272
|
-
if (!list) {
|
|
1273
|
-
pendingTxnAlignmentByInstance.set(instanceId, [ref]);
|
|
1274
|
-
return;
|
|
1275
|
-
}
|
|
1276
|
-
list.push(ref);
|
|
1277
|
-
if (list.length > 64) {
|
|
1278
|
-
list.shift();
|
|
1279
|
-
}
|
|
1280
|
-
};
|
|
1281
|
-
var backfillPendingTxnAlignment = (instanceId, txn) => {
|
|
1282
|
-
const pending = pendingTxnAlignmentByInstance.get(instanceId);
|
|
1283
|
-
if (!pending || pending.length === 0) {
|
|
1284
|
-
pendingTxnAlignmentByInstance.delete(instanceId);
|
|
1285
|
-
return;
|
|
1286
|
-
}
|
|
1287
|
-
for (const ref of pending) {
|
|
1288
|
-
const anyRef = ref;
|
|
1289
|
-
if (anyRef.txnId == null) {
|
|
1290
|
-
anyRef.txnId = txn.txnId;
|
|
1291
1152
|
}
|
|
1292
|
-
|
|
1293
|
-
|
|
1153
|
+
case "diagnostic": {
|
|
1154
|
+
const e = event;
|
|
1155
|
+
const metaInput = {
|
|
1156
|
+
code: e.code,
|
|
1157
|
+
severity: e.severity,
|
|
1158
|
+
message: e.message,
|
|
1159
|
+
hint: e.hint,
|
|
1160
|
+
actionTag: e.actionTag,
|
|
1161
|
+
kind: e.kind,
|
|
1162
|
+
trigger: e.trigger
|
|
1163
|
+
};
|
|
1164
|
+
const metaProjection = projectJsonValue(metaInput);
|
|
1165
|
+
options?.onMetaProjection?.({
|
|
1166
|
+
stats: metaProjection.stats,
|
|
1167
|
+
downgrade: metaProjection.downgrade
|
|
1168
|
+
});
|
|
1169
|
+
downgrade = mergeDowngrade2(downgrade, metaProjection.downgrade);
|
|
1170
|
+
return withDowngrade({
|
|
1171
|
+
...base,
|
|
1172
|
+
kind: "diagnostic",
|
|
1173
|
+
label: e.code,
|
|
1174
|
+
meta: metaProjection.value
|
|
1175
|
+
});
|
|
1294
1176
|
}
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1177
|
+
case "warn:priority-inversion": {
|
|
1178
|
+
const e = event;
|
|
1179
|
+
const metaInput = isLightLike ? {
|
|
1180
|
+
tickSeq: e.tickSeq,
|
|
1181
|
+
reason: e.reason,
|
|
1182
|
+
selectorId: e.selectorId
|
|
1183
|
+
} : {
|
|
1184
|
+
tickSeq: e.tickSeq,
|
|
1185
|
+
reason: e.reason,
|
|
1186
|
+
selectorId: e.selectorId
|
|
1187
|
+
};
|
|
1188
|
+
const metaProjection = projectJsonValue(metaInput);
|
|
1189
|
+
options?.onMetaProjection?.({
|
|
1190
|
+
stats: metaProjection.stats,
|
|
1191
|
+
downgrade: metaProjection.downgrade
|
|
1192
|
+
});
|
|
1193
|
+
downgrade = mergeDowngrade2(downgrade, metaProjection.downgrade);
|
|
1194
|
+
return withDowngrade({
|
|
1195
|
+
...base,
|
|
1196
|
+
kind: "diagnostic",
|
|
1197
|
+
label: e.type,
|
|
1198
|
+
meta: metaProjection.value
|
|
1304
1199
|
});
|
|
1305
|
-
} catch {
|
|
1306
|
-
try {
|
|
1307
|
-
return JSON.stringify(event.cause, null, 2);
|
|
1308
|
-
} catch {
|
|
1309
|
-
return String(event.cause);
|
|
1310
|
-
}
|
|
1311
1200
|
}
|
|
1312
|
-
|
|
1313
|
-
const message = `[Logix][module=${moduleId}] lifecycle:error
|
|
1314
|
-
${causePretty}`;
|
|
1315
|
-
return import_effect7.Effect.logError(message).pipe(
|
|
1316
|
-
import_effect7.Effect.annotateLogs({
|
|
1317
|
-
"logix.moduleId": moduleId,
|
|
1318
|
-
"logix.event": "lifecycle:error",
|
|
1319
|
-
"logix.cause": causePretty
|
|
1320
|
-
})
|
|
1321
|
-
);
|
|
1322
|
-
};
|
|
1323
|
-
var diagnosticLog = (event) => {
|
|
1324
|
-
const moduleId = event.moduleId ?? "unknown";
|
|
1325
|
-
const header = `[Logix][module=${moduleId}] diagnostic(${event.severity})`;
|
|
1326
|
-
const detail = `code=${event.code} message=${event.message}${event.actionTag ? ` action=${event.actionTag}` : ""}${event.hint ? `
|
|
1327
|
-
hint: ${event.hint}` : ""}`;
|
|
1328
|
-
const msg = `${header}
|
|
1329
|
-
${detail}`;
|
|
1330
|
-
const base = event.severity === "warning" ? import_effect7.Effect.logWarning(msg) : event.severity === "info" ? import_effect7.Effect.logInfo(msg) : import_effect7.Effect.logError(msg);
|
|
1331
|
-
const annotations = {
|
|
1332
|
-
"logix.moduleId": moduleId,
|
|
1333
|
-
"logix.event": `diagnostic(${event.severity})`,
|
|
1334
|
-
"logix.diagnostic.code": event.code,
|
|
1335
|
-
"logix.diagnostic.message": event.message
|
|
1336
|
-
};
|
|
1337
|
-
if (event.hint) {
|
|
1338
|
-
annotations["logix.diagnostic.hint"] = event.hint;
|
|
1339
|
-
}
|
|
1340
|
-
if (event.actionTag) {
|
|
1341
|
-
annotations["logix.diagnostic.actionTag"] = event.actionTag;
|
|
1342
|
-
}
|
|
1343
|
-
return base.pipe(import_effect7.Effect.annotateLogs(annotations));
|
|
1344
|
-
};
|
|
1345
|
-
var noopLayer = import_effect7.Layer.locallyScoped(currentDebugSinks, []);
|
|
1346
|
-
var errorOnlySink = {
|
|
1347
|
-
record: (event) => event.type === "lifecycle:error" ? lifecycleErrorLog(event) : event.type === "diagnostic" && event.severity !== "info" ? diagnosticLog(event) : import_effect7.Effect.void
|
|
1348
|
-
};
|
|
1349
|
-
var errorOnlyLayer = import_effect7.Layer.locallyScoped(currentDebugSinks, [errorOnlySink]);
|
|
1350
|
-
var isErrorOnlyOnlySinks = (sinks) => sinks.length === 1 && sinks[0] === errorOnlySink;
|
|
1351
|
-
var consoleSink = {
|
|
1352
|
-
record: (event) => event.type === "lifecycle:error" ? lifecycleErrorLog(event) : event.type === "diagnostic" ? diagnosticLog(event) : import_effect7.Effect.logDebug({ debugEvent: event })
|
|
1353
|
-
};
|
|
1354
|
-
var consoleLayer = import_effect7.Layer.locallyScoped(currentDebugSinks, [consoleSink]);
|
|
1355
|
-
var isBrowser = typeof window !== "undefined" && typeof document !== "undefined";
|
|
1356
|
-
var renderBrowserConsoleEvent = (event) => {
|
|
1357
|
-
if (typeof event.type === "string" && event.type.startsWith("trace:")) {
|
|
1358
|
-
const moduleId = event.moduleId ?? "unknown";
|
|
1359
|
-
const type = event.type;
|
|
1360
|
-
return import_effect7.Effect.sync(() => {
|
|
1361
|
-
console.groupCollapsed(
|
|
1362
|
-
"%c[Logix]%c trace %c" + moduleId + "%c " + String(type),
|
|
1363
|
-
"color:#6b7280;font-weight:bold",
|
|
1364
|
-
// tag
|
|
1365
|
-
"color:#3b82f6",
|
|
1366
|
-
// label
|
|
1367
|
-
"color:#9ca3af",
|
|
1368
|
-
// module id
|
|
1369
|
-
"color:#6b7280"
|
|
1370
|
-
// type
|
|
1371
|
-
);
|
|
1372
|
-
console.log(event);
|
|
1373
|
-
console.groupEnd();
|
|
1374
|
-
});
|
|
1375
|
-
}
|
|
1376
|
-
if (event.type === "lifecycle:error") {
|
|
1377
|
-
const moduleId = event.moduleId ?? "unknown";
|
|
1378
|
-
const causePretty = (() => {
|
|
1379
|
-
try {
|
|
1380
|
-
return import_effect7.Cause.pretty(event.cause, { renderErrorCause: true });
|
|
1381
|
-
} catch {
|
|
1382
|
-
try {
|
|
1383
|
-
return JSON.stringify(event.cause, null, 2);
|
|
1384
|
-
} catch {
|
|
1385
|
-
return String(event.cause);
|
|
1386
|
-
}
|
|
1387
|
-
}
|
|
1388
|
-
})();
|
|
1389
|
-
const key = `${moduleId}|${causePretty}`;
|
|
1390
|
-
if (browserLifecycleSeen.has(key)) {
|
|
1391
|
-
return import_effect7.Effect.void;
|
|
1392
|
-
}
|
|
1393
|
-
browserLifecycleSeen.add(key);
|
|
1394
|
-
return import_effect7.Effect.sync(() => {
|
|
1395
|
-
console.groupCollapsed(
|
|
1396
|
-
"%c[Logix]%c lifecycle:error %c" + moduleId,
|
|
1397
|
-
"color:#ef4444;font-weight:bold",
|
|
1398
|
-
// tag
|
|
1399
|
-
"color:#ef4444",
|
|
1400
|
-
// label
|
|
1401
|
-
"color:#9ca3af"
|
|
1402
|
-
// module id
|
|
1403
|
-
);
|
|
1404
|
-
console.error(causePretty);
|
|
1405
|
-
console.groupEnd();
|
|
1406
|
-
});
|
|
1407
|
-
}
|
|
1408
|
-
if (event.type === "diagnostic") {
|
|
1409
|
-
const moduleId = event.moduleId ?? "unknown";
|
|
1410
|
-
const detail = `code=${event.code} message=${event.message}${event.actionTag ? ` action=${event.actionTag}` : ""}${event.hint ? `
|
|
1411
|
-
hint: ${event.hint}` : ""}`;
|
|
1412
|
-
const color = event.severity === "warning" ? "color:#d97706" : event.severity === "info" ? "color:#3b82f6" : "color:#ef4444";
|
|
1413
|
-
const label = event.severity === "warning" ? "diagnostic(warning)" : event.severity === "info" ? "diagnostic(info)" : "diagnostic(error)";
|
|
1414
|
-
const key = `${moduleId}|${event.code}|${event.message}`;
|
|
1415
|
-
if (browserDiagnosticSeen.has(key)) {
|
|
1416
|
-
return import_effect7.Effect.void;
|
|
1417
|
-
}
|
|
1418
|
-
browserDiagnosticSeen.add(key);
|
|
1419
|
-
return import_effect7.Effect.sync(() => {
|
|
1420
|
-
console.groupCollapsed(
|
|
1421
|
-
"%c[Logix]%c " + label + "%c module=" + moduleId,
|
|
1422
|
-
"color:#6b7280;font-weight:bold",
|
|
1423
|
-
color,
|
|
1424
|
-
"color:#9ca3af"
|
|
1425
|
-
);
|
|
1426
|
-
if (event.severity === "warning") {
|
|
1427
|
-
console.warn(detail);
|
|
1428
|
-
} else if (event.severity === "info") {
|
|
1429
|
-
console.info(detail);
|
|
1430
|
-
} else {
|
|
1431
|
-
console.error(detail);
|
|
1432
|
-
}
|
|
1433
|
-
console.groupEnd();
|
|
1434
|
-
});
|
|
1435
|
-
}
|
|
1436
|
-
return import_effect7.Effect.void;
|
|
1437
|
-
};
|
|
1438
|
-
var browserConsoleSink = {
|
|
1439
|
-
record: (event) => {
|
|
1440
|
-
if (!isBrowser) {
|
|
1441
|
-
return event.type === "lifecycle:error" ? lifecycleErrorLog(event) : event.type === "diagnostic" ? diagnosticLog(event) : import_effect7.Effect.logDebug({ debugEvent: event });
|
|
1442
|
-
}
|
|
1443
|
-
return renderBrowserConsoleEvent(event);
|
|
1444
|
-
}
|
|
1445
|
-
};
|
|
1446
|
-
var browserConsoleLayer = import_effect7.Layer.locallyScoped(currentDebugSinks, [browserConsoleSink]);
|
|
1447
|
-
var browserDiagnosticConsoleSink = {
|
|
1448
|
-
record: (event) => {
|
|
1449
|
-
if (!isBrowser) {
|
|
1450
|
-
return event.type === "lifecycle:error" ? lifecycleErrorLog(event) : event.type === "diagnostic" && event.severity !== "info" ? diagnosticLog(event) : import_effect7.Effect.void;
|
|
1451
|
-
}
|
|
1452
|
-
return event.type === "lifecycle:error" || event.type === "diagnostic" && event.severity !== "info" ? renderBrowserConsoleEvent(event) : import_effect7.Effect.void;
|
|
1453
|
-
}
|
|
1454
|
-
};
|
|
1455
|
-
var browserDiagnosticConsoleLayer = import_effect7.Layer.locallyScoped(currentDebugSinks, [browserDiagnosticConsoleSink]);
|
|
1456
|
-
var browserPrettyLoggerLayer = import_effect7.Logger.replace(
|
|
1457
|
-
import_effect7.Logger.defaultLogger,
|
|
1458
|
-
import_effect7.Logger.prettyLogger({ mode: "browser", colors: true })
|
|
1459
|
-
);
|
|
1460
|
-
var record = (event) => import_effect7.Effect.gen(function* () {
|
|
1461
|
-
const sinks = yield* import_effect7.FiberRef.get(currentDebugSinks);
|
|
1462
|
-
if (isErrorOnlyOnlySinks(sinks)) {
|
|
1463
|
-
if (event.type === "lifecycle:error") {
|
|
1464
|
-
yield* lifecycleErrorLog(event);
|
|
1465
|
-
return;
|
|
1466
|
-
}
|
|
1467
|
-
if (event.type === "diagnostic") {
|
|
1468
|
-
if (event.severity !== "info") {
|
|
1469
|
-
yield* diagnosticLog(event);
|
|
1470
|
-
} else {
|
|
1471
|
-
yield* import_effect7.Effect.void;
|
|
1472
|
-
}
|
|
1473
|
-
return;
|
|
1474
|
-
}
|
|
1475
|
-
yield* import_effect7.Effect.void;
|
|
1476
|
-
return;
|
|
1477
|
-
}
|
|
1478
|
-
if (sinks.length === 0) {
|
|
1479
|
-
if (isBrowser) {
|
|
1480
|
-
if (event.type === "lifecycle:error" || event.type === "diagnostic") {
|
|
1481
|
-
yield* renderBrowserConsoleEvent(event);
|
|
1482
|
-
return;
|
|
1483
|
-
}
|
|
1484
|
-
yield* import_effect7.Effect.void;
|
|
1485
|
-
return;
|
|
1486
|
-
}
|
|
1487
|
-
if (event.type === "lifecycle:error") {
|
|
1488
|
-
yield* lifecycleErrorLog(event);
|
|
1489
|
-
return;
|
|
1490
|
-
}
|
|
1491
|
-
if (event.type === "diagnostic") {
|
|
1492
|
-
yield* diagnosticLog(event);
|
|
1493
|
-
return;
|
|
1494
|
-
}
|
|
1495
|
-
yield* import_effect7.Effect.void;
|
|
1496
|
-
return;
|
|
1497
|
-
}
|
|
1498
|
-
const enriched = event;
|
|
1499
|
-
const diagnosticsLevel2 = yield* import_effect7.FiberRef.get(currentDiagnosticsLevel);
|
|
1500
|
-
let now;
|
|
1501
|
-
const getNow = () => {
|
|
1502
|
-
if (now === void 0) now = Date.now();
|
|
1503
|
-
return now;
|
|
1504
|
-
};
|
|
1505
|
-
if (enriched.timestamp === void 0 && (diagnosticsLevel2 !== "off" || enriched.type === "lifecycle:error" || enriched.type === "diagnostic")) {
|
|
1506
|
-
;
|
|
1507
|
-
enriched.timestamp = getNow();
|
|
1508
|
-
}
|
|
1509
|
-
if (diagnosticsLevel2 !== "off" && enriched.runtimeLabel === void 0) {
|
|
1510
|
-
const runtimeLabel = yield* import_effect7.FiberRef.get(currentRuntimeLabel);
|
|
1511
|
-
if (runtimeLabel) {
|
|
1512
|
-
;
|
|
1513
|
-
enriched.runtimeLabel = runtimeLabel;
|
|
1514
|
-
}
|
|
1515
|
-
}
|
|
1516
|
-
if (enriched.type === "diagnostic" && enriched.txnId === void 0) {
|
|
1517
|
-
const txnId = yield* import_effect7.FiberRef.get(currentTxnId);
|
|
1518
|
-
if (txnId) {
|
|
1519
|
-
;
|
|
1520
|
-
enriched.txnId = txnId;
|
|
1521
|
-
}
|
|
1522
|
-
}
|
|
1523
|
-
if (diagnosticsLevel2 !== "off" && enriched.type === "trace:effectop" && enriched.linkId === void 0) {
|
|
1524
|
-
const linkId = yield* import_effect7.FiberRef.get(currentLinkId);
|
|
1525
|
-
if (linkId) {
|
|
1526
|
-
;
|
|
1527
|
-
enriched.linkId = linkId;
|
|
1528
|
-
}
|
|
1529
|
-
}
|
|
1530
|
-
if (sinks.length === 1) {
|
|
1531
|
-
yield* sinks[0].record(enriched);
|
|
1532
|
-
return;
|
|
1533
|
-
}
|
|
1534
|
-
yield* import_effect7.Effect.forEach(sinks, (sink) => sink.record(enriched), { discard: true });
|
|
1535
|
-
});
|
|
1536
|
-
var toRuntimeDebugEventRef = (event, options) => {
|
|
1537
|
-
const diagnosticsLevel2 = options?.diagnosticsLevel ?? "full";
|
|
1538
|
-
if (diagnosticsLevel2 === "off") {
|
|
1539
|
-
return void 0;
|
|
1540
|
-
}
|
|
1541
|
-
const isLightLike = diagnosticsLevel2 === "light" || diagnosticsLevel2 === "sampled";
|
|
1542
|
-
const timestamp = typeof event.timestamp === "number" && Number.isFinite(event.timestamp) ? event.timestamp : Date.now();
|
|
1543
|
-
const moduleIdRaw = event.moduleId;
|
|
1544
|
-
const moduleId = typeof moduleIdRaw === "string" && moduleIdRaw.length > 0 ? moduleIdRaw : "unknown";
|
|
1545
|
-
const instanceIdRaw = event.instanceId;
|
|
1546
|
-
const instanceId = typeof instanceIdRaw === "string" && instanceIdRaw.length > 0 ? instanceIdRaw : "unknown";
|
|
1547
|
-
const runtimeLabelRaw = event.runtimeLabel;
|
|
1548
|
-
const runtimeLabel = typeof runtimeLabelRaw === "string" && runtimeLabelRaw.length > 0 ? runtimeLabelRaw : void 0;
|
|
1549
|
-
const txnSeqRaw = event.txnSeq;
|
|
1550
|
-
const txnSeq = typeof txnSeqRaw === "number" && Number.isFinite(txnSeqRaw) && txnSeqRaw >= 0 ? Math.floor(txnSeqRaw) : 0;
|
|
1551
|
-
const txnIdRaw = event.txnId;
|
|
1552
|
-
const txnId = typeof txnIdRaw === "string" && txnIdRaw.length > 0 ? txnIdRaw : txnSeq > 0 ? `${instanceId}::t${txnSeq}` : void 0;
|
|
1553
|
-
const linkId = (() => {
|
|
1554
|
-
const linkIdRaw = event.linkId;
|
|
1555
|
-
if (typeof linkIdRaw === "string" && linkIdRaw.length > 0) return linkIdRaw;
|
|
1556
|
-
if (typeof event.type !== "string" || !event.type.startsWith("trace:")) {
|
|
1557
|
-
return void 0;
|
|
1558
|
-
}
|
|
1559
|
-
const data = event.data;
|
|
1560
|
-
const meta = data?.meta;
|
|
1561
|
-
const linkIdFromMeta = meta?.linkId;
|
|
1562
|
-
if (typeof linkIdFromMeta === "string" && linkIdFromMeta.length > 0) return linkIdFromMeta;
|
|
1563
|
-
return void 0;
|
|
1564
|
-
})();
|
|
1565
|
-
const eventSeqRaw = options?.eventSeq;
|
|
1566
|
-
const eventSeq = typeof eventSeqRaw === "number" && Number.isFinite(eventSeqRaw) && eventSeqRaw > 0 ? Math.floor(eventSeqRaw) : nextEventSeq();
|
|
1567
|
-
const eventId = makeEventId(instanceId, eventSeq);
|
|
1568
|
-
const base = {
|
|
1569
|
-
eventId,
|
|
1570
|
-
eventSeq,
|
|
1571
|
-
moduleId,
|
|
1572
|
-
instanceId,
|
|
1573
|
-
runtimeLabel,
|
|
1574
|
-
txnSeq,
|
|
1575
|
-
txnId,
|
|
1576
|
-
linkId,
|
|
1577
|
-
timestamp
|
|
1578
|
-
};
|
|
1579
|
-
let downgrade;
|
|
1580
|
-
const withDowngrade = (ref) => {
|
|
1581
|
-
if (!downgrade) return ref;
|
|
1582
|
-
return { ...ref, downgrade: { reason: downgrade } };
|
|
1583
|
-
};
|
|
1584
|
-
switch (event.type) {
|
|
1585
|
-
case "module:init":
|
|
1586
|
-
return withDowngrade({
|
|
1587
|
-
...base,
|
|
1588
|
-
kind: "lifecycle",
|
|
1589
|
-
label: "module:init"
|
|
1590
|
-
});
|
|
1591
|
-
case "module:destroy":
|
|
1592
|
-
return withDowngrade({
|
|
1593
|
-
...base,
|
|
1594
|
-
kind: "lifecycle",
|
|
1595
|
-
label: "module:destroy"
|
|
1596
|
-
});
|
|
1597
|
-
case "lifecycle:phase": {
|
|
1201
|
+
case "warn:microtask-starvation": {
|
|
1598
1202
|
const e = event;
|
|
1599
|
-
const metaInput = isLightLike ? {
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
return withDowngrade({
|
|
1607
|
-
...base,
|
|
1608
|
-
kind: "lifecycle",
|
|
1609
|
-
label: e.name,
|
|
1610
|
-
meta: metaProjection.value
|
|
1611
|
-
});
|
|
1612
|
-
}
|
|
1613
|
-
case "action:dispatch": {
|
|
1614
|
-
const action = event.action;
|
|
1615
|
-
const actionTagRaw = event.actionTag;
|
|
1616
|
-
const tag = typeof actionTagRaw === "string" && actionTagRaw.length > 0 ? actionTagRaw : action?._tag ?? action?.type;
|
|
1617
|
-
const label = String(tag ?? "action:dispatch");
|
|
1618
|
-
const labelNormalized = label.length > 0 ? label : "unknown";
|
|
1619
|
-
const unknownAction = event.unknownAction === true ? true : void 0;
|
|
1620
|
-
const metaInput = isLightLike ? { actionTag: labelNormalized, ...unknownAction ? { unknownAction: true } : {} } : { action, ...unknownAction ? { unknownAction: true } : {} };
|
|
1621
|
-
const metaProjection = projectJsonValue(metaInput);
|
|
1622
|
-
options?.onMetaProjection?.({
|
|
1623
|
-
stats: metaProjection.stats,
|
|
1624
|
-
downgrade: metaProjection.downgrade
|
|
1625
|
-
});
|
|
1626
|
-
downgrade = mergeDowngrade2(downgrade, metaProjection.downgrade);
|
|
1627
|
-
if (unknownAction) {
|
|
1628
|
-
downgrade = mergeDowngrade2(downgrade, "unknown");
|
|
1629
|
-
}
|
|
1630
|
-
return withDowngrade({
|
|
1631
|
-
...base,
|
|
1632
|
-
kind: "action",
|
|
1633
|
-
label: labelNormalized,
|
|
1634
|
-
meta: metaProjection.value
|
|
1635
|
-
});
|
|
1636
|
-
}
|
|
1637
|
-
case "state:update": {
|
|
1638
|
-
const e = event;
|
|
1639
|
-
const resolveDirtySetRootPaths = () => {
|
|
1640
|
-
const resolve2 = options?.resolveConvergeStaticIr;
|
|
1641
|
-
if (!resolve2) return void 0;
|
|
1642
|
-
const digest = e.staticIrDigest;
|
|
1643
|
-
if (typeof digest !== "string" || digest.length === 0) return void 0;
|
|
1644
|
-
const dirtySet = e.dirtySet;
|
|
1645
|
-
if (!dirtySet || typeof dirtySet !== "object" || Array.isArray(dirtySet)) return void 0;
|
|
1646
|
-
const rootIds = dirtySet.rootIds;
|
|
1647
|
-
if (!Array.isArray(rootIds) || rootIds.length === 0) return void 0;
|
|
1648
|
-
const ir = resolve2(digest);
|
|
1649
|
-
const fieldPaths = ir?.fieldPaths;
|
|
1650
|
-
if (!Array.isArray(fieldPaths) || fieldPaths.length === 0) return void 0;
|
|
1651
|
-
const out = [];
|
|
1652
|
-
for (const rawId of rootIds) {
|
|
1653
|
-
if (typeof rawId !== "number" || !Number.isFinite(rawId)) continue;
|
|
1654
|
-
const id = Math.floor(rawId);
|
|
1655
|
-
if (id < 0) continue;
|
|
1656
|
-
const path = fieldPaths[id];
|
|
1657
|
-
if (!Array.isArray(path) || path.length === 0) continue;
|
|
1658
|
-
if (!path.every((seg) => typeof seg === "string" && seg.length > 0)) continue;
|
|
1659
|
-
out.push(path);
|
|
1660
|
-
}
|
|
1661
|
-
return out.length > 0 ? out : void 0;
|
|
1662
|
-
};
|
|
1663
|
-
const dirtySetWithRootPaths = (() => {
|
|
1664
|
-
const rootPaths = resolveDirtySetRootPaths();
|
|
1665
|
-
if (!rootPaths) return e.dirtySet;
|
|
1666
|
-
const dirtySet = e.dirtySet;
|
|
1667
|
-
if (!dirtySet || typeof dirtySet !== "object" || Array.isArray(dirtySet)) return e.dirtySet;
|
|
1668
|
-
return { ...dirtySet, rootPaths };
|
|
1669
|
-
})();
|
|
1670
|
-
const metaInput = isLightLike ? {
|
|
1671
|
-
state: e.state,
|
|
1672
|
-
dirtySet: dirtySetWithRootPaths,
|
|
1673
|
-
patchCount: e.patchCount,
|
|
1674
|
-
patchesTruncated: e.patchesTruncated,
|
|
1675
|
-
patchesTruncatedReason: e.patchesTruncatedReason,
|
|
1676
|
-
staticIrDigest: e.staticIrDigest,
|
|
1677
|
-
commitMode: e.commitMode,
|
|
1678
|
-
priority: e.priority,
|
|
1679
|
-
originKind: e.originKind,
|
|
1680
|
-
originName: e.originName
|
|
1681
|
-
} : {
|
|
1682
|
-
state: e.state,
|
|
1683
|
-
dirtySet: dirtySetWithRootPaths,
|
|
1684
|
-
patchCount: e.patchCount,
|
|
1685
|
-
patchesTruncated: e.patchesTruncated,
|
|
1686
|
-
patchesTruncatedReason: e.patchesTruncatedReason,
|
|
1687
|
-
staticIrDigest: e.staticIrDigest,
|
|
1688
|
-
commitMode: e.commitMode,
|
|
1689
|
-
priority: e.priority,
|
|
1690
|
-
originKind: e.originKind,
|
|
1691
|
-
originName: e.originName,
|
|
1692
|
-
traitSummary: e.traitSummary,
|
|
1693
|
-
replayEvent: e.replayEvent
|
|
1694
|
-
};
|
|
1695
|
-
const metaProjection = projectJsonValue(metaInput);
|
|
1696
|
-
options?.onMetaProjection?.({
|
|
1697
|
-
stats: metaProjection.stats,
|
|
1698
|
-
downgrade: metaProjection.downgrade
|
|
1699
|
-
});
|
|
1700
|
-
downgrade = mergeDowngrade2(downgrade, metaProjection.downgrade);
|
|
1701
|
-
if (txnId) {
|
|
1702
|
-
lastTxnByInstance.set(instanceId, { txnId, txnSeq });
|
|
1703
|
-
backfillPendingTxnAlignment(instanceId, { txnId, txnSeq });
|
|
1704
|
-
}
|
|
1705
|
-
return withDowngrade({
|
|
1706
|
-
...base,
|
|
1707
|
-
kind: "state",
|
|
1708
|
-
label: "state:update",
|
|
1709
|
-
meta: metaProjection.value
|
|
1710
|
-
});
|
|
1711
|
-
}
|
|
1712
|
-
case "process:start":
|
|
1713
|
-
case "process:stop":
|
|
1714
|
-
case "process:restart":
|
|
1715
|
-
case "process:trigger":
|
|
1716
|
-
case "process:dispatch":
|
|
1717
|
-
case "process:error": {
|
|
1718
|
-
const e = event;
|
|
1719
|
-
const ts2 = typeof e.timestampMs === "number" && Number.isFinite(e.timestampMs) ? e.timestampMs : timestamp;
|
|
1720
|
-
const metaInput = {
|
|
1721
|
-
identity: e.identity,
|
|
1722
|
-
severity: e.severity,
|
|
1723
|
-
eventSeq: e.eventSeq,
|
|
1724
|
-
timestampMs: e.timestampMs,
|
|
1725
|
-
trigger: e.trigger,
|
|
1726
|
-
dispatch: e.dispatch,
|
|
1727
|
-
error: e.error
|
|
1728
|
-
};
|
|
1729
|
-
const metaProjection = projectJsonValue(metaInput);
|
|
1730
|
-
options?.onMetaProjection?.({
|
|
1731
|
-
stats: metaProjection.stats,
|
|
1732
|
-
downgrade: metaProjection.downgrade
|
|
1733
|
-
});
|
|
1734
|
-
downgrade = mergeDowngrade2(downgrade, metaProjection.downgrade);
|
|
1735
|
-
const errorSummary = e.type === "process:error" || e.type === "process:restart" ? e.error : void 0;
|
|
1736
|
-
return withDowngrade({
|
|
1737
|
-
...base,
|
|
1738
|
-
timestamp: ts2,
|
|
1739
|
-
kind: "process",
|
|
1740
|
-
label: e.type,
|
|
1741
|
-
meta: metaProjection.value,
|
|
1742
|
-
errorSummary
|
|
1743
|
-
});
|
|
1744
|
-
}
|
|
1745
|
-
case "lifecycle:error": {
|
|
1746
|
-
const e = event;
|
|
1747
|
-
const summary = toSerializableErrorSummary(e.cause);
|
|
1748
|
-
downgrade = mergeDowngrade2(downgrade, summary.downgrade);
|
|
1749
|
-
const metaInput = isLightLike ? { type: "lifecycle:error", phase: e.phase, name: e.hook } : {
|
|
1750
|
-
type: "lifecycle:error",
|
|
1751
|
-
phase: e.phase,
|
|
1752
|
-
name: e.hook,
|
|
1753
|
-
hook: e.hook,
|
|
1754
|
-
taskId: e.taskId,
|
|
1755
|
-
origin: e.origin,
|
|
1756
|
-
txnSeq: e.txnSeq,
|
|
1757
|
-
opSeq: e.opSeq
|
|
1758
|
-
};
|
|
1759
|
-
const metaProjection = projectJsonValue(metaInput);
|
|
1760
|
-
options?.onMetaProjection?.({
|
|
1761
|
-
stats: metaProjection.stats,
|
|
1762
|
-
downgrade: metaProjection.downgrade
|
|
1763
|
-
});
|
|
1764
|
-
downgrade = mergeDowngrade2(downgrade, metaProjection.downgrade);
|
|
1765
|
-
return withDowngrade({
|
|
1766
|
-
...base,
|
|
1767
|
-
kind: "lifecycle",
|
|
1768
|
-
label: "lifecycle:error",
|
|
1769
|
-
meta: metaProjection.value,
|
|
1770
|
-
errorSummary: summary.errorSummary
|
|
1771
|
-
});
|
|
1772
|
-
}
|
|
1773
|
-
case "diagnostic": {
|
|
1774
|
-
const e = event;
|
|
1775
|
-
const metaInput = {
|
|
1776
|
-
code: e.code,
|
|
1777
|
-
severity: e.severity,
|
|
1778
|
-
message: e.message,
|
|
1779
|
-
hint: e.hint,
|
|
1780
|
-
actionTag: e.actionTag,
|
|
1781
|
-
kind: e.kind,
|
|
1782
|
-
trigger: e.trigger
|
|
1783
|
-
};
|
|
1203
|
+
const metaInput = isLightLike ? {
|
|
1204
|
+
tickSeq: e.tickSeq,
|
|
1205
|
+
microtaskChainDepth: e.microtaskChainDepth
|
|
1206
|
+
} : {
|
|
1207
|
+
tickSeq: e.tickSeq,
|
|
1208
|
+
microtaskChainDepth: e.microtaskChainDepth
|
|
1209
|
+
};
|
|
1784
1210
|
const metaProjection = projectJsonValue(metaInput);
|
|
1785
1211
|
options?.onMetaProjection?.({
|
|
1786
1212
|
stats: metaProjection.stats,
|
|
@@ -1790,7 +1216,7 @@ var toRuntimeDebugEventRef = (event, options) => {
|
|
|
1790
1216
|
return withDowngrade({
|
|
1791
1217
|
...base,
|
|
1792
1218
|
kind: "diagnostic",
|
|
1793
|
-
label: e.
|
|
1219
|
+
label: e.type,
|
|
1794
1220
|
meta: metaProjection.value
|
|
1795
1221
|
});
|
|
1796
1222
|
}
|
|
@@ -1798,6 +1224,33 @@ var toRuntimeDebugEventRef = (event, options) => {
|
|
|
1798
1224
|
if (typeof event.type !== "string" || !event.type.startsWith("trace:")) {
|
|
1799
1225
|
return void 0;
|
|
1800
1226
|
}
|
|
1227
|
+
if (event.type === "trace:tick") {
|
|
1228
|
+
const data = event.data;
|
|
1229
|
+
const metaInput = isLightLike ? {
|
|
1230
|
+
tickSeq: data?.tickSeq,
|
|
1231
|
+
phase: data?.phase,
|
|
1232
|
+
schedule: data?.schedule,
|
|
1233
|
+
triggerSummary: data?.triggerSummary,
|
|
1234
|
+
anchors: data?.anchors,
|
|
1235
|
+
budget: data?.budget,
|
|
1236
|
+
backlog: data?.backlog,
|
|
1237
|
+
result: data?.result
|
|
1238
|
+
} : {
|
|
1239
|
+
data
|
|
1240
|
+
};
|
|
1241
|
+
const metaProjection2 = projectJsonValue(metaInput);
|
|
1242
|
+
options?.onMetaProjection?.({
|
|
1243
|
+
stats: metaProjection2.stats,
|
|
1244
|
+
downgrade: metaProjection2.downgrade
|
|
1245
|
+
});
|
|
1246
|
+
downgrade = mergeDowngrade2(downgrade, metaProjection2.downgrade);
|
|
1247
|
+
return withDowngrade({
|
|
1248
|
+
...base,
|
|
1249
|
+
kind: "devtools",
|
|
1250
|
+
label: event.type,
|
|
1251
|
+
meta: metaProjection2.value
|
|
1252
|
+
});
|
|
1253
|
+
}
|
|
1801
1254
|
if (event.type === "trace:txn-lane") {
|
|
1802
1255
|
const data = event.data;
|
|
1803
1256
|
const evidence = data?.evidence ?? data;
|
|
@@ -2144,34 +1597,1965 @@ var toRuntimeDebugEventRef = (event, options) => {
|
|
|
2144
1597
|
meta: metaProjection2.value
|
|
2145
1598
|
});
|
|
2146
1599
|
}
|
|
2147
|
-
const metaProjection = projectJsonValue(
|
|
2148
|
-
isLightLike ? {
|
|
2149
|
-
data: void 0
|
|
2150
|
-
} : {
|
|
2151
|
-
data: event.data
|
|
1600
|
+
const metaProjection = projectJsonValue(
|
|
1601
|
+
isLightLike ? {
|
|
1602
|
+
data: void 0
|
|
1603
|
+
} : {
|
|
1604
|
+
data: event.data
|
|
1605
|
+
}
|
|
1606
|
+
);
|
|
1607
|
+
options?.onMetaProjection?.({
|
|
1608
|
+
stats: metaProjection.stats,
|
|
1609
|
+
downgrade: metaProjection.downgrade
|
|
1610
|
+
});
|
|
1611
|
+
downgrade = mergeDowngrade2(downgrade, metaProjection.downgrade);
|
|
1612
|
+
return withDowngrade({
|
|
1613
|
+
...base,
|
|
1614
|
+
kind: "devtools",
|
|
1615
|
+
label: event.type,
|
|
1616
|
+
meta: metaProjection.value
|
|
1617
|
+
});
|
|
1618
|
+
}
|
|
1619
|
+
}
|
|
1620
|
+
};
|
|
1621
|
+
|
|
1622
|
+
// src/internal/runtime/core/DevtoolsHub.ts
|
|
1623
|
+
var import_effect5 = require("effect");
|
|
1624
|
+
|
|
1625
|
+
// src/internal/observability/evidence.ts
|
|
1626
|
+
var OBSERVABILITY_PROTOCOL_VERSION = "v1";
|
|
1627
|
+
var exportEvidencePackage = (options) => {
|
|
1628
|
+
const protocolVersion = options.protocolVersion ?? OBSERVABILITY_PROTOCOL_VERSION;
|
|
1629
|
+
return {
|
|
1630
|
+
protocolVersion,
|
|
1631
|
+
runId: options.runId,
|
|
1632
|
+
createdAt: options.createdAt ?? Date.now(),
|
|
1633
|
+
source: options.source,
|
|
1634
|
+
events: options.events.slice().sort((a, b) => a.seq - b.seq),
|
|
1635
|
+
summary: options.summary
|
|
1636
|
+
};
|
|
1637
|
+
};
|
|
1638
|
+
|
|
1639
|
+
// src/internal/runtime/core/DevtoolsHub.ts
|
|
1640
|
+
var lastRunTs = 0;
|
|
1641
|
+
var lastRunTsSeq = 0;
|
|
1642
|
+
var nextRunId = () => {
|
|
1643
|
+
const ts = Date.now();
|
|
1644
|
+
if (ts === lastRunTs) {
|
|
1645
|
+
lastRunTsSeq += 1;
|
|
1646
|
+
} else {
|
|
1647
|
+
lastRunTs = ts;
|
|
1648
|
+
lastRunTsSeq = 0;
|
|
1649
|
+
}
|
|
1650
|
+
return lastRunTsSeq === 0 ? `run-${ts}` : `run-${ts}.${lastRunTsSeq}`;
|
|
1651
|
+
};
|
|
1652
|
+
var currentRunId = nextRunId();
|
|
1653
|
+
|
|
1654
|
+
// src/internal/runtime/core/TaskRunner.ts
|
|
1655
|
+
var import_effect6 = require("effect");
|
|
1656
|
+
var inSyncTransactionFiber = import_effect6.FiberRef.unsafeMake(false);
|
|
1657
|
+
var forceSourceRefresh = import_effect6.FiberRef.unsafeMake(false);
|
|
1658
|
+
|
|
1659
|
+
// src/internal/runtime/core/DeclarativeLinkRuntime.ts
|
|
1660
|
+
var import_effect8 = require("effect");
|
|
1661
|
+
var makeDeclarativeLinkRuntime = () => {
|
|
1662
|
+
const moduleAsSourceById = /* @__PURE__ */ new Map();
|
|
1663
|
+
const moduleAsSourceIdsBySource = /* @__PURE__ */ new Map();
|
|
1664
|
+
const declarativeById = /* @__PURE__ */ new Map();
|
|
1665
|
+
const declarativeReadNodesBySource = /* @__PURE__ */ new Map();
|
|
1666
|
+
const registerModuleAsSourceLink = (link) => {
|
|
1667
|
+
const stored = {
|
|
1668
|
+
...link,
|
|
1669
|
+
hasValue: false,
|
|
1670
|
+
lastValue: void 0
|
|
1671
|
+
};
|
|
1672
|
+
moduleAsSourceById.set(link.id, stored);
|
|
1673
|
+
const set = moduleAsSourceIdsBySource.get(link.sourceModuleInstanceKey) ?? /* @__PURE__ */ new Set();
|
|
1674
|
+
set.add(link.id);
|
|
1675
|
+
moduleAsSourceIdsBySource.set(link.sourceModuleInstanceKey, set);
|
|
1676
|
+
return () => {
|
|
1677
|
+
moduleAsSourceById.delete(link.id);
|
|
1678
|
+
const current = moduleAsSourceIdsBySource.get(link.sourceModuleInstanceKey);
|
|
1679
|
+
if (!current) return;
|
|
1680
|
+
current.delete(link.id);
|
|
1681
|
+
if (current.size === 0) {
|
|
1682
|
+
moduleAsSourceIdsBySource.delete(link.sourceModuleInstanceKey);
|
|
1683
|
+
}
|
|
1684
|
+
};
|
|
1685
|
+
};
|
|
1686
|
+
const registerDeclarativeLink = (link) => {
|
|
1687
|
+
const readNodeById = /* @__PURE__ */ new Map();
|
|
1688
|
+
for (const n of link.readNodes) {
|
|
1689
|
+
readNodeById.set(n.nodeId, n);
|
|
1690
|
+
}
|
|
1691
|
+
const dispatchNodeById = /* @__PURE__ */ new Map();
|
|
1692
|
+
for (const n of link.dispatchNodes) {
|
|
1693
|
+
dispatchNodeById.set(n.nodeId, n);
|
|
1694
|
+
}
|
|
1695
|
+
const incomingByDispatch = /* @__PURE__ */ new Map();
|
|
1696
|
+
for (const e of link.ir.edges) {
|
|
1697
|
+
const to = e.to;
|
|
1698
|
+
const isDispatch = dispatchNodeById.has(to);
|
|
1699
|
+
if (!isDispatch) continue;
|
|
1700
|
+
incomingByDispatch.set(to, (incomingByDispatch.get(to) ?? 0) + 1);
|
|
1701
|
+
const count = incomingByDispatch.get(to) ?? 0;
|
|
1702
|
+
if (count > 1) {
|
|
1703
|
+
throw new Error(
|
|
1704
|
+
`[DeclarativeLinkRuntime] Invalid DeclarativeLinkIR: dispatch node has multiple incoming edges (linkId=${link.linkId}, nodeId=${to}).`
|
|
1705
|
+
);
|
|
1706
|
+
}
|
|
1707
|
+
}
|
|
1708
|
+
const dispatchTargetsByReadNode = /* @__PURE__ */ new Map();
|
|
1709
|
+
for (const e of link.ir.edges) {
|
|
1710
|
+
const from = e.from;
|
|
1711
|
+
const to = e.to;
|
|
1712
|
+
if (!readNodeById.has(from)) continue;
|
|
1713
|
+
if (!dispatchNodeById.has(to)) continue;
|
|
1714
|
+
const list = dispatchTargetsByReadNode.get(from) ?? [];
|
|
1715
|
+
list.push(to);
|
|
1716
|
+
dispatchTargetsByReadNode.set(from, list);
|
|
1717
|
+
}
|
|
1718
|
+
const stored = {
|
|
1719
|
+
...link,
|
|
1720
|
+
readNodeById,
|
|
1721
|
+
dispatchNodeById,
|
|
1722
|
+
dispatchTargetsByReadNode,
|
|
1723
|
+
readNodeState: /* @__PURE__ */ new Map()
|
|
1724
|
+
};
|
|
1725
|
+
declarativeById.set(link.linkId, stored);
|
|
1726
|
+
for (const n of link.readNodes) {
|
|
1727
|
+
const list = declarativeReadNodesBySource.get(n.moduleInstanceKey) ?? [];
|
|
1728
|
+
list.push({ linkId: link.linkId, nodeId: n.nodeId });
|
|
1729
|
+
declarativeReadNodesBySource.set(n.moduleInstanceKey, list);
|
|
1730
|
+
}
|
|
1731
|
+
return () => {
|
|
1732
|
+
declarativeById.delete(link.linkId);
|
|
1733
|
+
for (const n of link.readNodes) {
|
|
1734
|
+
const list = declarativeReadNodesBySource.get(n.moduleInstanceKey);
|
|
1735
|
+
if (!list) continue;
|
|
1736
|
+
const next = list.filter((x) => !(x.linkId === link.linkId && x.nodeId === n.nodeId));
|
|
1737
|
+
if (next.length === 0) {
|
|
1738
|
+
declarativeReadNodesBySource.delete(n.moduleInstanceKey);
|
|
1739
|
+
} else {
|
|
1740
|
+
declarativeReadNodesBySource.set(n.moduleInstanceKey, next);
|
|
1741
|
+
}
|
|
1742
|
+
}
|
|
1743
|
+
};
|
|
1744
|
+
};
|
|
1745
|
+
const applyForSources = (args) => import_effect8.Effect.gen(function* () {
|
|
1746
|
+
let scheduled = false;
|
|
1747
|
+
for (const sourceKey of args.changedModuleInstanceKeys) {
|
|
1748
|
+
const ids = moduleAsSourceIdsBySource.get(sourceKey);
|
|
1749
|
+
if (!ids || ids.size === 0) continue;
|
|
1750
|
+
const commit = args.acceptedModules.get(sourceKey);
|
|
1751
|
+
if (!commit) continue;
|
|
1752
|
+
for (const id of ids) {
|
|
1753
|
+
const link = moduleAsSourceById.get(id);
|
|
1754
|
+
if (!link) continue;
|
|
1755
|
+
let selected;
|
|
1756
|
+
try {
|
|
1757
|
+
selected = link.readQuery.select(commit.state);
|
|
1758
|
+
} catch {
|
|
1759
|
+
continue;
|
|
1760
|
+
}
|
|
1761
|
+
const nextValue = link.computeValue(selected);
|
|
1762
|
+
if (link.hasValue && link.equalsValue(link.lastValue, nextValue)) {
|
|
1763
|
+
continue;
|
|
1764
|
+
}
|
|
1765
|
+
link.hasValue = true;
|
|
1766
|
+
link.lastValue = nextValue;
|
|
1767
|
+
scheduled = true;
|
|
1768
|
+
yield* link.applyValue(nextValue);
|
|
1769
|
+
}
|
|
1770
|
+
}
|
|
1771
|
+
for (const sourceKey of args.changedModuleInstanceKeys) {
|
|
1772
|
+
const refs = declarativeReadNodesBySource.get(sourceKey);
|
|
1773
|
+
if (!refs || refs.length === 0) continue;
|
|
1774
|
+
const commit = args.acceptedModules.get(sourceKey);
|
|
1775
|
+
if (!commit) continue;
|
|
1776
|
+
for (const ref of refs) {
|
|
1777
|
+
const link = declarativeById.get(ref.linkId);
|
|
1778
|
+
if (!link) continue;
|
|
1779
|
+
const readNode = link.readNodeById.get(ref.nodeId);
|
|
1780
|
+
if (!readNode) continue;
|
|
1781
|
+
let value;
|
|
1782
|
+
try {
|
|
1783
|
+
value = readNode.readQuery.select(commit.state);
|
|
1784
|
+
} catch {
|
|
1785
|
+
continue;
|
|
1786
|
+
}
|
|
1787
|
+
const state = link.readNodeState.get(ref.nodeId) ?? { hasValue: false, lastValue: void 0 };
|
|
1788
|
+
const changed = !state.hasValue || !Object.is(state.lastValue, value);
|
|
1789
|
+
if (!changed) continue;
|
|
1790
|
+
state.hasValue = true;
|
|
1791
|
+
state.lastValue = value;
|
|
1792
|
+
link.readNodeState.set(ref.nodeId, state);
|
|
1793
|
+
const targets = link.dispatchTargetsByReadNode.get(ref.nodeId) ?? [];
|
|
1794
|
+
for (const dispatchNodeId of targets) {
|
|
1795
|
+
const node = link.dispatchNodeById.get(dispatchNodeId);
|
|
1796
|
+
if (!node) continue;
|
|
1797
|
+
scheduled = true;
|
|
1798
|
+
yield* node.dispatch(value);
|
|
1799
|
+
}
|
|
1800
|
+
}
|
|
1801
|
+
}
|
|
1802
|
+
return { scheduled };
|
|
1803
|
+
});
|
|
1804
|
+
return {
|
|
1805
|
+
registerModuleAsSourceLink,
|
|
1806
|
+
registerDeclarativeLink,
|
|
1807
|
+
applyForSources
|
|
1808
|
+
};
|
|
1809
|
+
};
|
|
1810
|
+
|
|
1811
|
+
// src/internal/runtime/core/env.ts
|
|
1812
|
+
var getNodeEnv = () => {
|
|
1813
|
+
try {
|
|
1814
|
+
const env = globalThis?.process?.env;
|
|
1815
|
+
return typeof env?.NODE_ENV === "string" ? env.NODE_ENV : void 0;
|
|
1816
|
+
} catch {
|
|
1817
|
+
return void 0;
|
|
1818
|
+
}
|
|
1819
|
+
};
|
|
1820
|
+
var isDevEnv = () => getNodeEnv() !== "production";
|
|
1821
|
+
var StateTransactionConfigTagImpl = class extends import_effect9.Context.Tag("@logixjs/core/StateTransactionRuntimeConfig")() {
|
|
1822
|
+
};
|
|
1823
|
+
var ReadQueryStrictGateConfigTagImpl = class extends import_effect9.Context.Tag("@logixjs/core/ReadQueryStrictGateRuntimeConfig")() {
|
|
1824
|
+
};
|
|
1825
|
+
var ReplayModeConfigTagImpl = class extends import_effect9.Context.Tag("@logixjs/core/ReplayModeConfig")() {
|
|
1826
|
+
};
|
|
1827
|
+
var StateTransactionOverridesTagImpl = class extends import_effect9.Context.Tag("@logixjs/core/StateTransactionOverrides")() {
|
|
1828
|
+
};
|
|
1829
|
+
var ConcurrencyPolicyTagImpl = class extends import_effect9.Context.Tag("@logixjs/core/ConcurrencyPolicy")() {
|
|
1830
|
+
};
|
|
1831
|
+
var ConcurrencyPolicyOverridesTagImpl = class extends import_effect9.Context.Tag("@logixjs/core/ConcurrencyPolicyOverrides")() {
|
|
1832
|
+
};
|
|
1833
|
+
var RuntimeStoreTag = class extends import_effect9.Context.Tag("@logixjs/core/RuntimeStore")() {
|
|
1834
|
+
};
|
|
1835
|
+
var runtimeStoreLayer = import_effect9.Layer.scoped(
|
|
1836
|
+
RuntimeStoreTag,
|
|
1837
|
+
import_effect9.Effect.acquireRelease(
|
|
1838
|
+
import_effect9.Effect.sync(() => makeRuntimeStore()),
|
|
1839
|
+
(store) => import_effect9.Effect.sync(() => store.dispose())
|
|
1840
|
+
)
|
|
1841
|
+
);
|
|
1842
|
+
var HostSchedulerTag = class extends import_effect9.Context.Tag("@logixjs/core/HostScheduler")() {
|
|
1843
|
+
};
|
|
1844
|
+
var hostSchedulerLayer = import_effect9.Layer.succeed(
|
|
1845
|
+
HostSchedulerTag,
|
|
1846
|
+
getGlobalHostScheduler()
|
|
1847
|
+
);
|
|
1848
|
+
var DeclarativeLinkRuntimeTag = class extends import_effect9.Context.Tag("@logixjs/core/DeclarativeLinkRuntime")() {
|
|
1849
|
+
};
|
|
1850
|
+
var declarativeLinkRuntimeLayer = import_effect9.Layer.succeed(
|
|
1851
|
+
DeclarativeLinkRuntimeTag,
|
|
1852
|
+
makeDeclarativeLinkRuntime()
|
|
1853
|
+
);
|
|
1854
|
+
var TickSchedulerTag = class extends import_effect9.Context.Tag("@logixjs/core/TickScheduler")() {
|
|
1855
|
+
};
|
|
1856
|
+
|
|
1857
|
+
// src/internal/runtime/core/runtimeInternalsAccessor.ts
|
|
1858
|
+
var MODULE_TRAITS_PROGRAM = /* @__PURE__ */ Symbol.for("@logixjs/core/moduleTraitsProgram");
|
|
1859
|
+
var getModuleTraitsProgram = (module2) => {
|
|
1860
|
+
if (!module2) return void 0;
|
|
1861
|
+
if (typeof module2 !== "object" && typeof module2 !== "function") return void 0;
|
|
1862
|
+
return module2[MODULE_TRAITS_PROGRAM];
|
|
1863
|
+
};
|
|
1864
|
+
|
|
1865
|
+
// src/internal/field-path.ts
|
|
1866
|
+
var isFieldPathSegment = (seg) => {
|
|
1867
|
+
if (!seg) return false;
|
|
1868
|
+
if (seg === "*") return false;
|
|
1869
|
+
if (/^\d+$/.test(seg)) return false;
|
|
1870
|
+
if (seg.includes("[") || seg.includes("]")) return false;
|
|
1871
|
+
return true;
|
|
1872
|
+
};
|
|
1873
|
+
var normalizeFieldPath = (input) => {
|
|
1874
|
+
if (typeof input === "string") {
|
|
1875
|
+
const segs = splitSegments(input);
|
|
1876
|
+
if (!segs || segs.length === 0) return void 0;
|
|
1877
|
+
const normalized2 = segs.filter(isFieldPathSegment);
|
|
1878
|
+
return normalized2.length > 0 ? normalized2 : void 0;
|
|
1879
|
+
}
|
|
1880
|
+
if (input.length === 0) return void 0;
|
|
1881
|
+
let needsFilter = false;
|
|
1882
|
+
for (const seg of input) {
|
|
1883
|
+
if (!isFieldPathSegment(seg)) {
|
|
1884
|
+
needsFilter = true;
|
|
1885
|
+
break;
|
|
1886
|
+
}
|
|
1887
|
+
}
|
|
1888
|
+
if (!needsFilter) return input;
|
|
1889
|
+
const normalized = input.filter(isFieldPathSegment);
|
|
1890
|
+
return normalized.length > 0 ? normalized : void 0;
|
|
1891
|
+
};
|
|
1892
|
+
var splitSegments = (path) => {
|
|
1893
|
+
if (!path) return void 0;
|
|
1894
|
+
if (path === "*") return void 0;
|
|
1895
|
+
const parts = path.split(".").filter((p) => p.length > 0);
|
|
1896
|
+
const segs = [];
|
|
1897
|
+
for (const part of parts) {
|
|
1898
|
+
if (!part) continue;
|
|
1899
|
+
if (part === "*") {
|
|
1900
|
+
return void 0;
|
|
1901
|
+
}
|
|
1902
|
+
if (part.endsWith("[]")) {
|
|
1903
|
+
const base = part.slice(0, -2);
|
|
1904
|
+
if (base) segs.push(base);
|
|
1905
|
+
continue;
|
|
1906
|
+
}
|
|
1907
|
+
const bracket = /^(.+)\[(\d+)\]$/.exec(part);
|
|
1908
|
+
if (bracket) {
|
|
1909
|
+
segs.push(bracket[1]);
|
|
1910
|
+
continue;
|
|
1911
|
+
}
|
|
1912
|
+
if (/^\d+$/.test(part)) {
|
|
1913
|
+
continue;
|
|
1914
|
+
}
|
|
1915
|
+
if (part.includes("[") || part.includes("]")) {
|
|
1916
|
+
return void 0;
|
|
1917
|
+
}
|
|
1918
|
+
segs.push(part);
|
|
1919
|
+
}
|
|
1920
|
+
return segs;
|
|
1921
|
+
};
|
|
1922
|
+
|
|
1923
|
+
// src/internal/external-store-descriptor.ts
|
|
1924
|
+
var EXTERNAL_STORE_DESCRIPTOR = /* @__PURE__ */ Symbol.for("@logixjs/core/externalStoreDescriptor");
|
|
1925
|
+
var getExternalStoreDescriptor = (store) => {
|
|
1926
|
+
if (!store || typeof store !== "object" && typeof store !== "function") return void 0;
|
|
1927
|
+
return store[EXTERNAL_STORE_DESCRIPTOR];
|
|
1928
|
+
};
|
|
1929
|
+
|
|
1930
|
+
// src/internal/state-trait/meta.ts
|
|
1931
|
+
var uniqSortedStrings = (input) => {
|
|
1932
|
+
const set = /* @__PURE__ */ new Set();
|
|
1933
|
+
for (const item of input) {
|
|
1934
|
+
const v = item.trim();
|
|
1935
|
+
if (!v) continue;
|
|
1936
|
+
set.add(v);
|
|
1937
|
+
}
|
|
1938
|
+
return Array.from(set).sort();
|
|
1939
|
+
};
|
|
1940
|
+
var isPlainRecord2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1941
|
+
var sanitizeJsonValue = (input, depth, stats) => {
|
|
1942
|
+
if (input === null) return null;
|
|
1943
|
+
if (typeof input === "string") return input;
|
|
1944
|
+
if (typeof input === "boolean") return input;
|
|
1945
|
+
if (typeof input === "number") {
|
|
1946
|
+
if (!Number.isFinite(input)) {
|
|
1947
|
+
stats.dropped += 1;
|
|
1948
|
+
stats.nonSerializable += 1;
|
|
1949
|
+
stats.nonFiniteNumber += 1;
|
|
1950
|
+
return void 0;
|
|
1951
|
+
}
|
|
1952
|
+
return input;
|
|
1953
|
+
}
|
|
1954
|
+
if (depth >= 6) {
|
|
1955
|
+
stats.dropped += 1;
|
|
1956
|
+
stats.depthExceeded += 1;
|
|
1957
|
+
return void 0;
|
|
1958
|
+
}
|
|
1959
|
+
if (Array.isArray(input)) {
|
|
1960
|
+
const out = [];
|
|
1961
|
+
for (const item of input) {
|
|
1962
|
+
const v = sanitizeJsonValue(item, depth + 1, stats);
|
|
1963
|
+
if (v !== void 0) out.push(v);
|
|
1964
|
+
}
|
|
1965
|
+
return out;
|
|
1966
|
+
}
|
|
1967
|
+
if (isPlainRecord2(input)) {
|
|
1968
|
+
const keys = Object.keys(input).sort();
|
|
1969
|
+
const out = {};
|
|
1970
|
+
for (const key of keys) {
|
|
1971
|
+
const v = sanitizeJsonValue(input[key], depth + 1, stats);
|
|
1972
|
+
if (v !== void 0) out[key] = v;
|
|
1973
|
+
}
|
|
1974
|
+
return out;
|
|
1975
|
+
}
|
|
1976
|
+
stats.dropped += 1;
|
|
1977
|
+
stats.nonSerializable += 1;
|
|
1978
|
+
return void 0;
|
|
1979
|
+
};
|
|
1980
|
+
var pushSample = (target, value, limit) => {
|
|
1981
|
+
if (target.length >= limit) return;
|
|
1982
|
+
target.push(value);
|
|
1983
|
+
};
|
|
1984
|
+
var sanitizeWithReport = (input) => {
|
|
1985
|
+
if (input === null || input === void 0) return {};
|
|
1986
|
+
if (typeof input !== "object" || Array.isArray(input)) {
|
|
1987
|
+
return { report: { invalidInput: true } };
|
|
1988
|
+
}
|
|
1989
|
+
const record2 = input;
|
|
1990
|
+
const out = {};
|
|
1991
|
+
const reportUnknownKeys = [];
|
|
1992
|
+
let unknownKeyCount = 0;
|
|
1993
|
+
const reportDroppedKeys = [];
|
|
1994
|
+
let droppedTagItems = 0;
|
|
1995
|
+
const reportIgnoredAnnotationKeys = [];
|
|
1996
|
+
let ignoredAnnotationKeyCount = 0;
|
|
1997
|
+
const reportDroppedAnnotationKeys = [];
|
|
1998
|
+
let droppedAnnotationKeyCount = 0;
|
|
1999
|
+
const stats = { dropped: 0, nonSerializable: 0, depthExceeded: 0, nonFiniteNumber: 0 };
|
|
2000
|
+
const allowed = /* @__PURE__ */ new Set([
|
|
2001
|
+
"label",
|
|
2002
|
+
"description",
|
|
2003
|
+
"group",
|
|
2004
|
+
"docsUrl",
|
|
2005
|
+
"cacheGroup",
|
|
2006
|
+
"canonical",
|
|
2007
|
+
"tags",
|
|
2008
|
+
"annotations"
|
|
2009
|
+
]);
|
|
2010
|
+
for (const key of Object.keys(record2)) {
|
|
2011
|
+
if (allowed.has(key) || key.startsWith("x-")) continue;
|
|
2012
|
+
unknownKeyCount += 1;
|
|
2013
|
+
pushSample(reportUnknownKeys, key, 8);
|
|
2014
|
+
}
|
|
2015
|
+
const pickString = (key) => {
|
|
2016
|
+
const value = record2[key];
|
|
2017
|
+
if (typeof value !== "string") return;
|
|
2018
|
+
const trimmed = value.trim();
|
|
2019
|
+
if (!trimmed) return;
|
|
2020
|
+
out[key] = trimmed;
|
|
2021
|
+
};
|
|
2022
|
+
pickString("label");
|
|
2023
|
+
pickString("description");
|
|
2024
|
+
pickString("group");
|
|
2025
|
+
pickString("docsUrl");
|
|
2026
|
+
pickString("cacheGroup");
|
|
2027
|
+
const canonical = record2.canonical;
|
|
2028
|
+
if (canonical !== void 0 && canonical !== null && typeof canonical !== "boolean") {
|
|
2029
|
+
pushSample(reportDroppedKeys, "canonical", 8);
|
|
2030
|
+
} else if (typeof canonical === "boolean") {
|
|
2031
|
+
out.canonical = canonical;
|
|
2032
|
+
}
|
|
2033
|
+
const tagsRaw = record2.tags;
|
|
2034
|
+
if (typeof tagsRaw === "string") {
|
|
2035
|
+
const tags = uniqSortedStrings([tagsRaw]);
|
|
2036
|
+
if (tags.length > 0) out.tags = tags;
|
|
2037
|
+
} else if (Array.isArray(tagsRaw)) {
|
|
2038
|
+
const raw = tagsRaw.filter((x) => typeof x === "string");
|
|
2039
|
+
droppedTagItems += tagsRaw.length - raw.length;
|
|
2040
|
+
const tags = uniqSortedStrings(raw);
|
|
2041
|
+
if (tags.length > 0) out.tags = tags;
|
|
2042
|
+
droppedTagItems += raw.length - tags.length;
|
|
2043
|
+
} else if (tagsRaw !== void 0 && tagsRaw !== null) {
|
|
2044
|
+
pushSample(reportDroppedKeys, "tags", 8);
|
|
2045
|
+
}
|
|
2046
|
+
const annotations = {};
|
|
2047
|
+
const annotationKeys = Object.keys(record2).filter((k) => k.startsWith("x-")).sort();
|
|
2048
|
+
for (const key of annotationKeys) {
|
|
2049
|
+
const v = sanitizeJsonValue(record2[key], 0, stats);
|
|
2050
|
+
if (v !== void 0) {
|
|
2051
|
+
annotations[key] = v;
|
|
2052
|
+
} else {
|
|
2053
|
+
droppedAnnotationKeyCount += 1;
|
|
2054
|
+
pushSample(reportDroppedAnnotationKeys, key, 8);
|
|
2055
|
+
}
|
|
2056
|
+
}
|
|
2057
|
+
const annotationsRaw = record2.annotations;
|
|
2058
|
+
if (annotationsRaw !== void 0 && annotationsRaw !== null && !isPlainRecord2(annotationsRaw)) {
|
|
2059
|
+
pushSample(reportDroppedKeys, "annotations", 8);
|
|
2060
|
+
} else if (isPlainRecord2(annotationsRaw)) {
|
|
2061
|
+
const keys = Object.keys(annotationsRaw).sort();
|
|
2062
|
+
for (const key of keys) {
|
|
2063
|
+
if (!key.startsWith("x-")) {
|
|
2064
|
+
ignoredAnnotationKeyCount += 1;
|
|
2065
|
+
pushSample(reportIgnoredAnnotationKeys, key, 8);
|
|
2066
|
+
continue;
|
|
2067
|
+
}
|
|
2068
|
+
const v = sanitizeJsonValue(annotationsRaw[key], 0, stats);
|
|
2069
|
+
if (v !== void 0) {
|
|
2070
|
+
annotations[key] = v;
|
|
2071
|
+
} else {
|
|
2072
|
+
droppedAnnotationKeyCount += 1;
|
|
2073
|
+
pushSample(reportDroppedAnnotationKeys, key, 8);
|
|
2074
|
+
}
|
|
2075
|
+
}
|
|
2076
|
+
}
|
|
2077
|
+
if (Object.keys(annotations).length > 0) out.annotations = annotations;
|
|
2078
|
+
for (const key of ["label", "description", "group", "docsUrl", "cacheGroup"]) {
|
|
2079
|
+
const value = record2[key];
|
|
2080
|
+
if (value !== void 0 && value !== null && typeof value !== "string") {
|
|
2081
|
+
pushSample(reportDroppedKeys, key, 8);
|
|
2082
|
+
}
|
|
2083
|
+
}
|
|
2084
|
+
const meta = Object.keys(out).length > 0 ? out : void 0;
|
|
2085
|
+
const report = (() => {
|
|
2086
|
+
const hasUnknownKeys = unknownKeyCount > 0;
|
|
2087
|
+
const hasDroppedKeys = reportDroppedKeys.length > 0;
|
|
2088
|
+
const hasDroppedTagItems = droppedTagItems > 0;
|
|
2089
|
+
const hasIgnoredAnnotationKeys = ignoredAnnotationKeyCount > 0;
|
|
2090
|
+
const hasDroppedAnnotations = droppedAnnotationKeyCount > 0 || stats.dropped > 0;
|
|
2091
|
+
if (!hasUnknownKeys && !hasDroppedKeys && !hasDroppedTagItems && !hasIgnoredAnnotationKeys && !hasDroppedAnnotations) {
|
|
2092
|
+
return void 0;
|
|
2093
|
+
}
|
|
2094
|
+
return {
|
|
2095
|
+
...hasUnknownKeys ? { unknownKeys: reportUnknownKeys, unknownKeyCount } : {},
|
|
2096
|
+
...hasDroppedKeys ? { droppedKeys: uniqSortedStrings(reportDroppedKeys) } : {},
|
|
2097
|
+
...hasDroppedTagItems ? { droppedTagItems } : {},
|
|
2098
|
+
...hasIgnoredAnnotationKeys ? { ignoredAnnotationKeys: uniqSortedStrings(reportIgnoredAnnotationKeys), ignoredAnnotationKeyCount } : {},
|
|
2099
|
+
...hasDroppedAnnotations ? {
|
|
2100
|
+
droppedAnnotationKeys: uniqSortedStrings(reportDroppedAnnotationKeys),
|
|
2101
|
+
droppedAnnotationKeyCount,
|
|
2102
|
+
droppedAnnotationValues: stats.dropped,
|
|
2103
|
+
droppedAnnotationNonSerializable: stats.nonSerializable,
|
|
2104
|
+
droppedAnnotationDepthExceeded: stats.depthExceeded,
|
|
2105
|
+
droppedAnnotationNonFiniteNumber: stats.nonFiniteNumber
|
|
2106
|
+
} : {}
|
|
2107
|
+
};
|
|
2108
|
+
})();
|
|
2109
|
+
return report ? { meta, report } : { meta };
|
|
2110
|
+
};
|
|
2111
|
+
var sanitize = (input) => sanitizeWithReport(input).meta;
|
|
2112
|
+
|
|
2113
|
+
// src/internal/state-trait/ir.ts
|
|
2114
|
+
var normalizeFieldPaths = (paths) => {
|
|
2115
|
+
if (!paths || paths.length === 0) return [];
|
|
2116
|
+
const out = [];
|
|
2117
|
+
for (const path of paths) {
|
|
2118
|
+
const normalized = normalizeFieldPath(path);
|
|
2119
|
+
if (normalized) out.push(normalized);
|
|
2120
|
+
}
|
|
2121
|
+
return out;
|
|
2122
|
+
};
|
|
2123
|
+
var normalizeFieldPath2 = (path) => path ? normalizeFieldPath(path) : void 0;
|
|
2124
|
+
var toNodeKind = (step) => {
|
|
2125
|
+
switch (step.kind) {
|
|
2126
|
+
case "computed-update":
|
|
2127
|
+
return "computed";
|
|
2128
|
+
case "link-propagate":
|
|
2129
|
+
return "link";
|
|
2130
|
+
case "source-refresh":
|
|
2131
|
+
return "source";
|
|
2132
|
+
case "external-store-sync":
|
|
2133
|
+
return "externalStore";
|
|
2134
|
+
case "check-validate":
|
|
2135
|
+
return "check";
|
|
2136
|
+
}
|
|
2137
|
+
};
|
|
2138
|
+
var findEntryForStep = (program, step) => {
|
|
2139
|
+
const fieldPath = step.targetFieldPath;
|
|
2140
|
+
if (!fieldPath) return void 0;
|
|
2141
|
+
const kind = toNodeKind(step);
|
|
2142
|
+
return program.entries.find(
|
|
2143
|
+
(e) => e.fieldPath === fieldPath && (e.kind === kind || kind === "check" && e.kind === "check" || kind === "source" && e.kind === "source" || kind === "link" && e.kind === "link" || kind === "computed" && e.kind === "computed")
|
|
2144
|
+
);
|
|
2145
|
+
};
|
|
2146
|
+
var getReadsForEntry = (entry) => {
|
|
2147
|
+
if (!entry) return void 0;
|
|
2148
|
+
if (entry.kind === "computed") {
|
|
2149
|
+
return entry.meta.deps;
|
|
2150
|
+
}
|
|
2151
|
+
if (entry.kind === "source") {
|
|
2152
|
+
return entry.meta.deps;
|
|
2153
|
+
}
|
|
2154
|
+
if (entry.kind === "link") {
|
|
2155
|
+
const from = entry.meta.from;
|
|
2156
|
+
return from ? [from] : [];
|
|
2157
|
+
}
|
|
2158
|
+
if (entry.kind === "externalStore") {
|
|
2159
|
+
return [];
|
|
2160
|
+
}
|
|
2161
|
+
if (entry.kind === "check") {
|
|
2162
|
+
const rules = entry.meta?.rules ?? {};
|
|
2163
|
+
const out = [];
|
|
2164
|
+
for (const name of Object.keys(rules)) {
|
|
2165
|
+
const rule = rules[name];
|
|
2166
|
+
const deps = rule?.deps;
|
|
2167
|
+
if (deps) out.push(...deps);
|
|
2168
|
+
}
|
|
2169
|
+
return out;
|
|
2170
|
+
}
|
|
2171
|
+
return void 0;
|
|
2172
|
+
};
|
|
2173
|
+
var exportStaticIr = (params) => {
|
|
2174
|
+
const moduleId = params.moduleId;
|
|
2175
|
+
const version = params.version ?? "009";
|
|
2176
|
+
const metaByField = /* @__PURE__ */ new Map();
|
|
2177
|
+
for (const node of params.program.graph.nodes) {
|
|
2178
|
+
const meta = node.meta;
|
|
2179
|
+
if (!meta || typeof meta !== "object") continue;
|
|
2180
|
+
const label = typeof meta.label === "string" ? meta.label : void 0;
|
|
2181
|
+
const description = typeof meta.description === "string" ? meta.description : void 0;
|
|
2182
|
+
const tags = Array.isArray(meta.tags) && meta.tags.every((t) => typeof t === "string") ? meta.tags : void 0;
|
|
2183
|
+
const group = typeof meta.group === "string" ? meta.group : void 0;
|
|
2184
|
+
const docsUrl = typeof meta.docsUrl === "string" ? meta.docsUrl : void 0;
|
|
2185
|
+
const cacheGroup = typeof meta.cacheGroup === "string" ? meta.cacheGroup : void 0;
|
|
2186
|
+
const annotationsRaw = meta.annotations;
|
|
2187
|
+
const annotations = annotationsRaw && typeof annotationsRaw === "object" && !Array.isArray(annotationsRaw) ? annotationsRaw : void 0;
|
|
2188
|
+
if (label || description || tags || group || docsUrl || cacheGroup || annotations) {
|
|
2189
|
+
metaByField.set(node.id, {
|
|
2190
|
+
label,
|
|
2191
|
+
description,
|
|
2192
|
+
tags,
|
|
2193
|
+
group,
|
|
2194
|
+
docsUrl,
|
|
2195
|
+
cacheGroup,
|
|
2196
|
+
annotations
|
|
2197
|
+
});
|
|
2198
|
+
}
|
|
2199
|
+
}
|
|
2200
|
+
const nodes = params.program.plan.steps.map((step) => {
|
|
2201
|
+
const kind = toNodeKind(step);
|
|
2202
|
+
const entry = findEntryForStep(params.program, step);
|
|
2203
|
+
const reads = normalizeFieldPaths(getReadsForEntry(entry));
|
|
2204
|
+
const target = step.targetFieldPath;
|
|
2205
|
+
const write = normalizeFieldPath2(target);
|
|
2206
|
+
const writes = write ? [write] : [];
|
|
2207
|
+
const meta = target ? metaByField.get(target) : void 0;
|
|
2208
|
+
const externalStorePolicy = () => {
|
|
2209
|
+
if (kind !== "externalStore") return void 0;
|
|
2210
|
+
if (!entry || entry.kind !== "externalStore") return void 0;
|
|
2211
|
+
const descriptor = getExternalStoreDescriptor(entry.meta.store);
|
|
2212
|
+
const storeId = descriptor?.storeId;
|
|
2213
|
+
const priorityRaw = entry.meta?.priority;
|
|
2214
|
+
const lane = priorityRaw === "nonUrgent" ? "nonUrgent" : "urgent";
|
|
2215
|
+
const meta2 = sanitize(entry.meta.meta);
|
|
2216
|
+
const source = descriptor?.kind === "module" ? {
|
|
2217
|
+
kind: "module",
|
|
2218
|
+
storeId,
|
|
2219
|
+
moduleId: descriptor.moduleId,
|
|
2220
|
+
...descriptor.instanceId ? { instanceKey: descriptor.instanceId } : {},
|
|
2221
|
+
selectorId: descriptor.readQuery.staticIr.selectorId,
|
|
2222
|
+
readsDigest: descriptor.readQuery.staticIr.readsDigest,
|
|
2223
|
+
fallbackReason: descriptor.readQuery.staticIr.fallbackReason
|
|
2224
|
+
} : descriptor ? { kind: "external", storeId } : { kind: "external", storeId: "unknown" };
|
|
2225
|
+
const coalesceWindowMs = entry.meta?.coalesceWindowMs;
|
|
2226
|
+
return {
|
|
2227
|
+
traitId: step.id,
|
|
2228
|
+
storeId: storeId ?? "unknown",
|
|
2229
|
+
source,
|
|
2230
|
+
ownership: "external-owned",
|
|
2231
|
+
lane,
|
|
2232
|
+
...typeof coalesceWindowMs === "number" && Number.isFinite(coalesceWindowMs) && coalesceWindowMs > 0 ? { coalesceWindowMs } : {},
|
|
2233
|
+
...meta2 ? { meta: meta2 } : {}
|
|
2234
|
+
};
|
|
2235
|
+
};
|
|
2236
|
+
const base2 = {
|
|
2237
|
+
nodeId: step.id,
|
|
2238
|
+
kind,
|
|
2239
|
+
reads,
|
|
2240
|
+
writes: kind === "check" ? [] : writes,
|
|
2241
|
+
...kind === "externalStore" ? { policy: externalStorePolicy() } : {},
|
|
2242
|
+
meta
|
|
2243
|
+
};
|
|
2244
|
+
if (kind !== "check" && target && !write) {
|
|
2245
|
+
return { ...base2, writesUnknown: true };
|
|
2246
|
+
}
|
|
2247
|
+
return base2;
|
|
2248
|
+
});
|
|
2249
|
+
const edges = params.program.graph.edges.map((edge) => ({
|
|
2250
|
+
edgeId: edge.id,
|
|
2251
|
+
from: edge.from,
|
|
2252
|
+
to: edge.to,
|
|
2253
|
+
kind: edge.kind
|
|
2254
|
+
}));
|
|
2255
|
+
const base = {
|
|
2256
|
+
version,
|
|
2257
|
+
moduleId,
|
|
2258
|
+
nodes,
|
|
2259
|
+
edges
|
|
2260
|
+
};
|
|
2261
|
+
const digest = `stir:${version}:${fnv1a32(stableStringify(base))}`;
|
|
2262
|
+
return {
|
|
2263
|
+
...base,
|
|
2264
|
+
digest
|
|
2265
|
+
};
|
|
2266
|
+
};
|
|
2267
|
+
|
|
2268
|
+
// src/internal/reflection/staticIr.ts
|
|
2269
|
+
var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2270
|
+
var isModuleImpl = (value) => isRecord(value) && value._tag === "ModuleImpl" && isRecord(value.module);
|
|
2271
|
+
var resolveModuleId = (input) => {
|
|
2272
|
+
if (isModuleImpl(input)) {
|
|
2273
|
+
const id = input.module.id;
|
|
2274
|
+
return typeof id === "string" && id.length > 0 ? id : "unknown";
|
|
2275
|
+
}
|
|
2276
|
+
if (isRecord(input)) {
|
|
2277
|
+
const id = input.id;
|
|
2278
|
+
if (typeof id === "string" && id.length > 0) return id;
|
|
2279
|
+
const tag = input.tag;
|
|
2280
|
+
if (tag && (typeof tag === "object" || typeof tag === "function")) {
|
|
2281
|
+
const tagId = tag.id;
|
|
2282
|
+
if (typeof tagId === "string" && tagId.length > 0) return tagId;
|
|
2283
|
+
}
|
|
2284
|
+
}
|
|
2285
|
+
return "unknown";
|
|
2286
|
+
};
|
|
2287
|
+
var resolveModuleTag = (input) => {
|
|
2288
|
+
if (isModuleImpl(input)) return input.module;
|
|
2289
|
+
if (isRecord(input) && input.tag) return input.tag;
|
|
2290
|
+
return void 0;
|
|
2291
|
+
};
|
|
2292
|
+
var exportStaticIr2 = (module2) => {
|
|
2293
|
+
const tag = resolveModuleTag(module2);
|
|
2294
|
+
if (!tag) return void 0;
|
|
2295
|
+
const program = getModuleTraitsProgram(tag);
|
|
2296
|
+
if (!program) return void 0;
|
|
2297
|
+
return exportStaticIr({
|
|
2298
|
+
program,
|
|
2299
|
+
moduleId: resolveModuleId(module2)
|
|
2300
|
+
});
|
|
2301
|
+
};
|
|
2302
|
+
|
|
2303
|
+
// src/internal/reflection/manifest.ts
|
|
2304
|
+
var isRecord2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2305
|
+
var isModuleImpl2 = (value) => isRecord2(value) && value._tag === "ModuleImpl" && isRecord2(value.module);
|
|
2306
|
+
var resolveModuleId2 = (input) => {
|
|
2307
|
+
if (isModuleImpl2(input)) {
|
|
2308
|
+
const id = input.module.id;
|
|
2309
|
+
return typeof id === "string" && id.length > 0 ? id : "unknown";
|
|
2310
|
+
}
|
|
2311
|
+
if (isRecord2(input)) {
|
|
2312
|
+
const id = input.id;
|
|
2313
|
+
if (typeof id === "string" && id.length > 0) return id;
|
|
2314
|
+
const tag = input.tag;
|
|
2315
|
+
if (tag && (typeof tag === "object" || typeof tag === "function")) {
|
|
2316
|
+
const tagId = tag.id;
|
|
2317
|
+
if (typeof tagId === "string" && tagId.length > 0) return tagId;
|
|
2318
|
+
}
|
|
2319
|
+
}
|
|
2320
|
+
return "unknown";
|
|
2321
|
+
};
|
|
2322
|
+
var resolveActionKeys = (input) => {
|
|
2323
|
+
const tag = isModuleImpl2(input) ? input.module : input?.tag;
|
|
2324
|
+
const actionMap = tag?.shape?.actionMap;
|
|
2325
|
+
if (!isRecord2(actionMap)) return [];
|
|
2326
|
+
return Object.keys(actionMap).sort();
|
|
2327
|
+
};
|
|
2328
|
+
var resolveDevSource = (input) => {
|
|
2329
|
+
if (!isRecord2(input)) return void 0;
|
|
2330
|
+
const file = input.file;
|
|
2331
|
+
const line = input.line;
|
|
2332
|
+
const column = input.column;
|
|
2333
|
+
if (typeof file !== "string" || file.length === 0) return void 0;
|
|
2334
|
+
if (typeof line !== "number" || !Number.isInteger(line) || line < 1) return void 0;
|
|
2335
|
+
if (typeof column !== "number" || !Number.isInteger(column) || column < 1) return void 0;
|
|
2336
|
+
return { file, line, column };
|
|
2337
|
+
};
|
|
2338
|
+
var resolveTokenSource = (token) => {
|
|
2339
|
+
if (!token || typeof token !== "object" && typeof token !== "function") return void 0;
|
|
2340
|
+
return resolveDevSource(token.source);
|
|
2341
|
+
};
|
|
2342
|
+
var resolveActions = (input) => {
|
|
2343
|
+
const tag = isModuleImpl2(input) ? input.module : input?.tag;
|
|
2344
|
+
const actionMap = tag?.shape?.actionMap;
|
|
2345
|
+
if (!isRecord2(actionMap)) return [];
|
|
2346
|
+
const moduleSource = resolveSource(input);
|
|
2347
|
+
const reducers = isRecord2(tag?.reducers) ? tag.reducers : void 0;
|
|
2348
|
+
const actionTags = Object.keys(actionMap).sort();
|
|
2349
|
+
const out = [];
|
|
2350
|
+
for (const actionTag of actionTags) {
|
|
2351
|
+
const token = actionMap[actionTag];
|
|
2352
|
+
const source = resolveTokenSource(token) ?? moduleSource;
|
|
2353
|
+
const payloadKind = isActionToken(token) && import_effect10.Schema.isSchema(token.schema) ? token.schema === import_effect10.Schema.Void ? "void" : "nonVoid" : "unknown";
|
|
2354
|
+
const primaryReducer = reducers && typeof reducers[actionTag] === "function" ? { kind: "declared" } : void 0;
|
|
2355
|
+
out.push({
|
|
2356
|
+
actionTag,
|
|
2357
|
+
payload: { kind: payloadKind },
|
|
2358
|
+
...primaryReducer ? { primaryReducer } : {},
|
|
2359
|
+
...source ? { source } : {}
|
|
2360
|
+
});
|
|
2361
|
+
}
|
|
2362
|
+
return out;
|
|
2363
|
+
};
|
|
2364
|
+
var MODULE_DECLARED_EFFECTS = /* @__PURE__ */ Symbol.for("logix.module.effects.declared");
|
|
2365
|
+
var resolveEffects = (input) => {
|
|
2366
|
+
const tag = isModuleImpl2(input) ? input.module : input?.tag;
|
|
2367
|
+
const actionMap = tag?.shape?.actionMap;
|
|
2368
|
+
if (!isRecord2(actionMap)) return void 0;
|
|
2369
|
+
const effectsRaw = tag?.[MODULE_DECLARED_EFFECTS];
|
|
2370
|
+
if (!isRecord2(effectsRaw)) return void 0;
|
|
2371
|
+
const source = resolveSource(input);
|
|
2372
|
+
const logicUnitId = "__logix_internal:effects:declared";
|
|
2373
|
+
const handlerIds = /* @__PURE__ */ new WeakMap();
|
|
2374
|
+
let nextHandlerSeq = 0;
|
|
2375
|
+
const out = [];
|
|
2376
|
+
for (const actionTag of Object.keys(effectsRaw).sort()) {
|
|
2377
|
+
if (!(actionTag in actionMap)) continue;
|
|
2378
|
+
const handlers = effectsRaw[actionTag];
|
|
2379
|
+
if (!Array.isArray(handlers)) continue;
|
|
2380
|
+
for (const handler of handlers) {
|
|
2381
|
+
if (typeof handler !== "function") continue;
|
|
2382
|
+
let handlerId = handlerIds.get(handler);
|
|
2383
|
+
if (!handlerId) {
|
|
2384
|
+
nextHandlerSeq += 1;
|
|
2385
|
+
handlerId = `h${nextHandlerSeq}`;
|
|
2386
|
+
handlerIds.set(handler, handlerId);
|
|
2387
|
+
}
|
|
2388
|
+
const sourceKey = `${logicUnitId}::${handlerId}`;
|
|
2389
|
+
out.push({
|
|
2390
|
+
actionTag,
|
|
2391
|
+
sourceKey,
|
|
2392
|
+
kind: "declared",
|
|
2393
|
+
...source ? { source } : {}
|
|
2394
|
+
});
|
|
2395
|
+
}
|
|
2396
|
+
}
|
|
2397
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2398
|
+
const deduped = [];
|
|
2399
|
+
for (const item of out) {
|
|
2400
|
+
const key = `${item.actionTag}\0${item.sourceKey}`;
|
|
2401
|
+
if (seen.has(key)) continue;
|
|
2402
|
+
seen.add(key);
|
|
2403
|
+
deduped.push(item);
|
|
2404
|
+
}
|
|
2405
|
+
deduped.sort(
|
|
2406
|
+
(a, b) => a.actionTag < b.actionTag ? -1 : a.actionTag > b.actionTag ? 1 : a.sourceKey < b.sourceKey ? -1 : a.sourceKey > b.sourceKey ? 1 : 0
|
|
2407
|
+
);
|
|
2408
|
+
return deduped.length > 0 ? deduped : void 0;
|
|
2409
|
+
};
|
|
2410
|
+
var resolveSchemaKeys = (input) => {
|
|
2411
|
+
if (!isRecord2(input)) return void 0;
|
|
2412
|
+
const schemas = input.schemas;
|
|
2413
|
+
if (!isRecord2(schemas)) return void 0;
|
|
2414
|
+
return Object.keys(schemas).sort();
|
|
2415
|
+
};
|
|
2416
|
+
var resolveSource = (input) => {
|
|
2417
|
+
if (!isRecord2(input)) return void 0;
|
|
2418
|
+
const dev = input.dev;
|
|
2419
|
+
return resolveDevSource(dev?.source);
|
|
2420
|
+
};
|
|
2421
|
+
var resolveMeta = (input) => {
|
|
2422
|
+
if (!isRecord2(input)) return void 0;
|
|
2423
|
+
const meta = input.meta;
|
|
2424
|
+
if (!isRecord2(meta)) return void 0;
|
|
2425
|
+
const out = {};
|
|
2426
|
+
for (const key of Object.keys(meta).sort()) {
|
|
2427
|
+
const value = meta[key];
|
|
2428
|
+
if (isJsonValue(value)) {
|
|
2429
|
+
out[key] = value;
|
|
2430
|
+
}
|
|
2431
|
+
}
|
|
2432
|
+
return Object.keys(out).length > 0 ? out : void 0;
|
|
2433
|
+
};
|
|
2434
|
+
var MODULE_INTERNAL = /* @__PURE__ */ Symbol.for("logix.module.internal");
|
|
2435
|
+
var resolveLogicUnits = (input) => {
|
|
2436
|
+
if (!isRecord2(input)) return void 0;
|
|
2437
|
+
const internal = input[MODULE_INTERNAL];
|
|
2438
|
+
const mounted = internal?.mounted;
|
|
2439
|
+
if (!Array.isArray(mounted)) return void 0;
|
|
2440
|
+
const out = [];
|
|
2441
|
+
for (const unit of mounted) {
|
|
2442
|
+
if (!isRecord2(unit)) continue;
|
|
2443
|
+
const kind = unit.kind;
|
|
2444
|
+
const id = unit.id;
|
|
2445
|
+
if (typeof kind !== "string" || kind.length === 0) continue;
|
|
2446
|
+
if (typeof id !== "string" || id.length === 0) continue;
|
|
2447
|
+
const derived = unit.derived === true ? true : void 0;
|
|
2448
|
+
const name = typeof unit.name === "string" ? unit.name : void 0;
|
|
2449
|
+
out.push({ kind, id, derived, name });
|
|
2450
|
+
}
|
|
2451
|
+
out.sort((a, b) => a.id < b.id ? -1 : a.id > b.id ? 1 : a.kind < b.kind ? -1 : a.kind > b.kind ? 1 : 0);
|
|
2452
|
+
return out.length > 0 ? out : void 0;
|
|
2453
|
+
};
|
|
2454
|
+
var digestOf = (base) => `manifest:067:${fnv1a32(stableStringify(base))}`;
|
|
2455
|
+
var utf8ByteLength = (value) => {
|
|
2456
|
+
const json = JSON.stringify(value);
|
|
2457
|
+
if (typeof TextEncoder !== "undefined") {
|
|
2458
|
+
return new TextEncoder().encode(json).length;
|
|
2459
|
+
}
|
|
2460
|
+
return json.length;
|
|
2461
|
+
};
|
|
2462
|
+
var applyMaxBytes = (manifest, maxBytes) => {
|
|
2463
|
+
const originalBytes = utf8ByteLength(manifest);
|
|
2464
|
+
if (originalBytes <= maxBytes) return manifest;
|
|
2465
|
+
const dropped = [];
|
|
2466
|
+
const truncatedArrays = [];
|
|
2467
|
+
const baseMarker = () => ({
|
|
2468
|
+
truncated: true,
|
|
2469
|
+
maxBytes,
|
|
2470
|
+
originalBytes,
|
|
2471
|
+
dropped,
|
|
2472
|
+
truncatedArrays
|
|
2473
|
+
});
|
|
2474
|
+
const withMarker = (next2) => {
|
|
2475
|
+
const meta = {
|
|
2476
|
+
__logix: baseMarker()
|
|
2477
|
+
};
|
|
2478
|
+
return { ...next2, meta };
|
|
2479
|
+
};
|
|
2480
|
+
let next = withMarker(manifest);
|
|
2481
|
+
const markTruncatedArray = (name) => {
|
|
2482
|
+
if (!truncatedArrays.includes(name)) {
|
|
2483
|
+
truncatedArrays.push(name);
|
|
2484
|
+
}
|
|
2485
|
+
};
|
|
2486
|
+
const dropField = (field) => {
|
|
2487
|
+
if (next[field] !== void 0) {
|
|
2488
|
+
dropped.push(String(field));
|
|
2489
|
+
next = withMarker({ ...next, [field]: void 0 });
|
|
2490
|
+
}
|
|
2491
|
+
};
|
|
2492
|
+
dropField("meta");
|
|
2493
|
+
if (utf8ByteLength(next) <= maxBytes) return next;
|
|
2494
|
+
dropField("source");
|
|
2495
|
+
if (utf8ByteLength(next) <= maxBytes) return next;
|
|
2496
|
+
dropField("staticIr");
|
|
2497
|
+
if (utf8ByteLength(next) <= maxBytes) return next;
|
|
2498
|
+
dropField("logicUnits");
|
|
2499
|
+
if (utf8ByteLength(next) <= maxBytes) return next;
|
|
2500
|
+
dropField("schemaKeys");
|
|
2501
|
+
if (utf8ByteLength(next) <= maxBytes) return next;
|
|
2502
|
+
dropField("effects");
|
|
2503
|
+
if (utf8ByteLength(next) <= maxBytes) return next;
|
|
2504
|
+
const truncateActionsToFit = () => {
|
|
2505
|
+
const total = next.actions.length;
|
|
2506
|
+
if (total <= 1) return;
|
|
2507
|
+
let lo = 1;
|
|
2508
|
+
let hi = total;
|
|
2509
|
+
let best = 1;
|
|
2510
|
+
while (lo <= hi) {
|
|
2511
|
+
const mid = Math.floor((lo + hi) / 2);
|
|
2512
|
+
const candidate = withMarker({
|
|
2513
|
+
...next,
|
|
2514
|
+
actions: next.actions.slice(0, mid),
|
|
2515
|
+
actionKeys: next.actionKeys.slice(0, mid)
|
|
2516
|
+
});
|
|
2517
|
+
if (utf8ByteLength(candidate) <= maxBytes) {
|
|
2518
|
+
best = mid;
|
|
2519
|
+
lo = mid + 1;
|
|
2520
|
+
} else {
|
|
2521
|
+
hi = mid - 1;
|
|
2522
|
+
}
|
|
2523
|
+
}
|
|
2524
|
+
if (best < total) {
|
|
2525
|
+
markTruncatedArray("actions");
|
|
2526
|
+
markTruncatedArray("actionKeys");
|
|
2527
|
+
next = withMarker({
|
|
2528
|
+
...next,
|
|
2529
|
+
actions: next.actions.slice(0, best),
|
|
2530
|
+
actionKeys: next.actionKeys.slice(0, best)
|
|
2531
|
+
});
|
|
2532
|
+
}
|
|
2533
|
+
};
|
|
2534
|
+
while (utf8ByteLength(next) > maxBytes) {
|
|
2535
|
+
const beforeLen = next.actions.length;
|
|
2536
|
+
truncateActionsToFit();
|
|
2537
|
+
if (next.actions.length === beforeLen) {
|
|
2538
|
+
break;
|
|
2539
|
+
}
|
|
2540
|
+
}
|
|
2541
|
+
return next;
|
|
2542
|
+
};
|
|
2543
|
+
var extractManifest = (module2, options) => {
|
|
2544
|
+
const manifestVersion = "067";
|
|
2545
|
+
const moduleId = resolveModuleId2(module2);
|
|
2546
|
+
const actionKeys = resolveActionKeys(module2);
|
|
2547
|
+
const actions = resolveActions(module2);
|
|
2548
|
+
const effects = resolveEffects(module2);
|
|
2549
|
+
const schemaKeys = resolveSchemaKeys(module2);
|
|
2550
|
+
const logicUnits = resolveLogicUnits(module2);
|
|
2551
|
+
const source = resolveSource(module2);
|
|
2552
|
+
const meta = resolveMeta(module2);
|
|
2553
|
+
const staticIr = options?.includeStaticIr ? exportStaticIr2(module2) : void 0;
|
|
2554
|
+
const digestBase = {
|
|
2555
|
+
manifestVersion,
|
|
2556
|
+
moduleId,
|
|
2557
|
+
actionKeys,
|
|
2558
|
+
actions,
|
|
2559
|
+
effects,
|
|
2560
|
+
schemaKeys,
|
|
2561
|
+
logicUnits,
|
|
2562
|
+
staticIrDigest: staticIr?.digest
|
|
2563
|
+
};
|
|
2564
|
+
const digest = digestOf(digestBase);
|
|
2565
|
+
const manifest = {
|
|
2566
|
+
manifestVersion,
|
|
2567
|
+
moduleId,
|
|
2568
|
+
actionKeys,
|
|
2569
|
+
actions,
|
|
2570
|
+
effects,
|
|
2571
|
+
schemaKeys,
|
|
2572
|
+
logicUnits,
|
|
2573
|
+
source,
|
|
2574
|
+
meta,
|
|
2575
|
+
staticIr,
|
|
2576
|
+
digest
|
|
2577
|
+
};
|
|
2578
|
+
const maxBytes = options?.budgets?.maxBytes;
|
|
2579
|
+
if (typeof maxBytes === "number" && Number.isFinite(maxBytes) && maxBytes > 0) {
|
|
2580
|
+
return applyMaxBytes(manifest, maxBytes);
|
|
2581
|
+
}
|
|
2582
|
+
return manifest;
|
|
2583
|
+
};
|
|
2584
|
+
|
|
2585
|
+
// src/internal/workflow/errors.ts
|
|
2586
|
+
var toJsonValue = (detail) => {
|
|
2587
|
+
if (isJsonValue(detail)) return detail;
|
|
2588
|
+
return projectJsonValue(detail).value;
|
|
2589
|
+
};
|
|
2590
|
+
var makeWorkflowError = (args) => {
|
|
2591
|
+
const detailJson = args.detail !== void 0 ? toJsonValue(args.detail) : void 0;
|
|
2592
|
+
const msg = args.detail !== void 0 ? `${args.message}
|
|
2593
|
+
(detail=${stableStringify(detailJson)})` : args.message;
|
|
2594
|
+
return Object.assign(new Error(msg), {
|
|
2595
|
+
_tag: "WorkflowError",
|
|
2596
|
+
code: args.code,
|
|
2597
|
+
programId: args.programId,
|
|
2598
|
+
source: args.source,
|
|
2599
|
+
detail: detailJson
|
|
2600
|
+
});
|
|
2601
|
+
};
|
|
2602
|
+
|
|
2603
|
+
// src/internal/workflow/compiler.ts
|
|
2604
|
+
var isRecord3 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2605
|
+
var asNonEmptyString = (value) => typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
|
|
2606
|
+
var asNonNegInt = (value) => {
|
|
2607
|
+
if (typeof value !== "number" || !Number.isFinite(value)) return void 0;
|
|
2608
|
+
const n = Math.floor(value);
|
|
2609
|
+
return n >= 0 ? n : void 0;
|
|
2610
|
+
};
|
|
2611
|
+
var asPosInt = (value) => {
|
|
2612
|
+
if (typeof value !== "number" || !Number.isFinite(value)) return void 0;
|
|
2613
|
+
const n = Math.floor(value);
|
|
2614
|
+
return n > 0 ? n : void 0;
|
|
2615
|
+
};
|
|
2616
|
+
var normalizeWorkflowDefV1 = (input) => {
|
|
2617
|
+
const normalizeStep = (step) => {
|
|
2618
|
+
if (!isRecord3(step)) return step;
|
|
2619
|
+
if (step.kind !== "call") return step;
|
|
2620
|
+
const raw = step;
|
|
2621
|
+
const onSuccessRaw = Array.isArray(raw.onSuccess) ? raw.onSuccess : [];
|
|
2622
|
+
const onFailureRaw = Array.isArray(raw.onFailure) ? raw.onFailure : [];
|
|
2623
|
+
return {
|
|
2624
|
+
...step,
|
|
2625
|
+
onSuccess: onSuccessRaw.map(normalizeStep),
|
|
2626
|
+
onFailure: onFailureRaw.map(normalizeStep)
|
|
2627
|
+
};
|
|
2628
|
+
};
|
|
2629
|
+
const normalizeSteps = (steps) => steps.map(normalizeStep);
|
|
2630
|
+
return {
|
|
2631
|
+
...input,
|
|
2632
|
+
steps: normalizeSteps(input.steps)
|
|
2633
|
+
};
|
|
2634
|
+
};
|
|
2635
|
+
function validateWorkflowDefV1(def, options) {
|
|
2636
|
+
if (!isRecord3(def)) {
|
|
2637
|
+
throw makeWorkflowError({
|
|
2638
|
+
code: "WORKFLOW_INVALID_DEF",
|
|
2639
|
+
message: "WorkflowDef must be an object.",
|
|
2640
|
+
detail: { def }
|
|
2641
|
+
});
|
|
2642
|
+
}
|
|
2643
|
+
if (def.astVersion !== 1) {
|
|
2644
|
+
throw makeWorkflowError({
|
|
2645
|
+
code: "WORKFLOW_UNSUPPORTED_VERSION",
|
|
2646
|
+
message: "Unsupported workflow astVersion.",
|
|
2647
|
+
detail: { astVersion: def.astVersion }
|
|
2648
|
+
});
|
|
2649
|
+
}
|
|
2650
|
+
if (!asNonEmptyString(def.localId)) {
|
|
2651
|
+
throw makeWorkflowError({
|
|
2652
|
+
code: "WORKFLOW_INVALID_DEF",
|
|
2653
|
+
message: "WorkflowDef.localId must be a non-empty string.",
|
|
2654
|
+
detail: { localId: def.localId }
|
|
2655
|
+
});
|
|
2656
|
+
}
|
|
2657
|
+
const trigger = def.trigger;
|
|
2658
|
+
if (!isRecord3(trigger)) {
|
|
2659
|
+
throw makeWorkflowError({
|
|
2660
|
+
code: "WORKFLOW_INVALID_TRIGGER",
|
|
2661
|
+
message: "Workflow trigger must be an object.",
|
|
2662
|
+
detail: { trigger }
|
|
2663
|
+
});
|
|
2664
|
+
}
|
|
2665
|
+
if (trigger.kind === "action") {
|
|
2666
|
+
if (!asNonEmptyString(trigger.actionTag)) {
|
|
2667
|
+
throw makeWorkflowError({
|
|
2668
|
+
code: "WORKFLOW_INVALID_TRIGGER",
|
|
2669
|
+
message: "Workflow trigger.actionTag must be a non-empty string.",
|
|
2670
|
+
detail: { trigger }
|
|
2671
|
+
});
|
|
2672
|
+
}
|
|
2673
|
+
} else if (trigger.kind === "lifecycle") {
|
|
2674
|
+
const phase = trigger.phase;
|
|
2675
|
+
if (phase !== "onStart" && phase !== "onInit") {
|
|
2676
|
+
throw makeWorkflowError({
|
|
2677
|
+
code: "WORKFLOW_INVALID_TRIGGER",
|
|
2678
|
+
message: 'Workflow trigger.phase must be "onStart" or "onInit".',
|
|
2679
|
+
detail: { trigger }
|
|
2680
|
+
});
|
|
2681
|
+
}
|
|
2682
|
+
} else {
|
|
2683
|
+
throw makeWorkflowError({
|
|
2684
|
+
code: "WORKFLOW_INVALID_TRIGGER",
|
|
2685
|
+
message: 'Workflow trigger.kind must be "action" or "lifecycle".',
|
|
2686
|
+
detail: { trigger }
|
|
2687
|
+
});
|
|
2688
|
+
}
|
|
2689
|
+
if (!Array.isArray(def.steps)) {
|
|
2690
|
+
throw makeWorkflowError({
|
|
2691
|
+
code: "WORKFLOW_INVALID_DEF",
|
|
2692
|
+
message: "WorkflowDef.steps must be an array.",
|
|
2693
|
+
detail: { steps: def.steps }
|
|
2694
|
+
});
|
|
2695
|
+
}
|
|
2696
|
+
const seenKeys = /* @__PURE__ */ new Set();
|
|
2697
|
+
const visit = (step, fragmentId) => {
|
|
2698
|
+
if (!isRecord3(step)) {
|
|
2699
|
+
throw makeWorkflowError({
|
|
2700
|
+
code: "WORKFLOW_INVALID_STEP",
|
|
2701
|
+
message: "Workflow step must be an object.",
|
|
2702
|
+
detail: { step },
|
|
2703
|
+
source: fragmentId ? { fragmentId } : void 0
|
|
2704
|
+
});
|
|
2705
|
+
}
|
|
2706
|
+
const key = asNonEmptyString(step.key);
|
|
2707
|
+
if (!key) {
|
|
2708
|
+
throw makeWorkflowError({
|
|
2709
|
+
code: "WORKFLOW_INVALID_STEP",
|
|
2710
|
+
message: "Workflow step.key must be a non-empty string.",
|
|
2711
|
+
detail: { stepKey: step.key, kind: step.kind },
|
|
2712
|
+
source: fragmentId ? { fragmentId } : void 0
|
|
2713
|
+
});
|
|
2714
|
+
}
|
|
2715
|
+
if (seenKeys.has(key)) {
|
|
2716
|
+
throw makeWorkflowError({
|
|
2717
|
+
code: "WORKFLOW_DUPLICATE_STEP_KEY",
|
|
2718
|
+
message: `Duplicate stepKey "${key}" detected.`,
|
|
2719
|
+
detail: { duplicateKey: key },
|
|
2720
|
+
source: { stepKey: key, ...fragmentId ? { fragmentId } : null }
|
|
2721
|
+
});
|
|
2722
|
+
}
|
|
2723
|
+
seenKeys.add(key);
|
|
2724
|
+
if (step.kind === "dispatch") {
|
|
2725
|
+
if (!asNonEmptyString(step.actionTag)) {
|
|
2726
|
+
throw makeWorkflowError({
|
|
2727
|
+
code: "WORKFLOW_INVALID_STEP",
|
|
2728
|
+
message: "dispatch.actionTag must be a non-empty string.",
|
|
2729
|
+
source: { stepKey: key, ...fragmentId ? { fragmentId } : null },
|
|
2730
|
+
detail: { actionTag: step.actionTag }
|
|
2731
|
+
});
|
|
2732
|
+
}
|
|
2733
|
+
const payload = step.payload;
|
|
2734
|
+
if (payload !== void 0) {
|
|
2735
|
+
validateInputExpr(payload, { stepKey: key });
|
|
2736
|
+
}
|
|
2737
|
+
return;
|
|
2738
|
+
}
|
|
2739
|
+
if (step.kind === "delay") {
|
|
2740
|
+
const ms = asNonNegInt(step.ms);
|
|
2741
|
+
if (ms === void 0) {
|
|
2742
|
+
throw makeWorkflowError({
|
|
2743
|
+
code: "WORKFLOW_INVALID_STEP",
|
|
2744
|
+
message: "delay.ms must be a non-negative integer.",
|
|
2745
|
+
source: { stepKey: key, ...fragmentId ? { fragmentId } : null },
|
|
2746
|
+
detail: { ms: step.ms }
|
|
2747
|
+
});
|
|
2748
|
+
}
|
|
2749
|
+
return;
|
|
2750
|
+
}
|
|
2751
|
+
if (step.kind === "call") {
|
|
2752
|
+
if (!asNonEmptyString(step.serviceId)) {
|
|
2753
|
+
throw makeWorkflowError({
|
|
2754
|
+
code: "WORKFLOW_INVALID_SERVICE_ID",
|
|
2755
|
+
message: "call.serviceId must be a non-empty string.",
|
|
2756
|
+
source: { stepKey: key, ...fragmentId ? { fragmentId } : null },
|
|
2757
|
+
detail: { serviceId: step.serviceId }
|
|
2758
|
+
});
|
|
2759
|
+
}
|
|
2760
|
+
const inputExpr = step.input;
|
|
2761
|
+
if (inputExpr !== void 0) {
|
|
2762
|
+
validateInputExpr(inputExpr, { stepKey: key });
|
|
2763
|
+
}
|
|
2764
|
+
const timeoutMsRaw = step.timeoutMs;
|
|
2765
|
+
if (timeoutMsRaw !== void 0 && asPosInt(timeoutMsRaw) === void 0) {
|
|
2766
|
+
throw makeWorkflowError({
|
|
2767
|
+
code: "WORKFLOW_INVALID_STEP",
|
|
2768
|
+
message: "call.timeoutMs must be a positive integer (milliseconds).",
|
|
2769
|
+
source: { stepKey: key, ...fragmentId ? { fragmentId } : null },
|
|
2770
|
+
detail: { timeoutMs: timeoutMsRaw }
|
|
2771
|
+
});
|
|
2772
|
+
}
|
|
2773
|
+
const retryRaw = step.retry;
|
|
2774
|
+
if (retryRaw !== void 0) {
|
|
2775
|
+
const times = isRecord3(retryRaw) ? asPosInt(retryRaw.times) : void 0;
|
|
2776
|
+
if (times === void 0) {
|
|
2777
|
+
throw makeWorkflowError({
|
|
2778
|
+
code: "WORKFLOW_INVALID_STEP",
|
|
2779
|
+
message: "call.retry.times must be a positive integer.",
|
|
2780
|
+
source: { stepKey: key, ...fragmentId ? { fragmentId } : null },
|
|
2781
|
+
detail: { retry: retryRaw }
|
|
2782
|
+
});
|
|
2783
|
+
}
|
|
2784
|
+
}
|
|
2785
|
+
const onSuccess = Array.isArray(step.onSuccess) ? step.onSuccess : [];
|
|
2786
|
+
const onFailure2 = Array.isArray(step.onFailure) ? step.onFailure : [];
|
|
2787
|
+
for (const inner of onSuccess) visit(inner, fragmentId);
|
|
2788
|
+
for (const inner of onFailure2) visit(inner, fragmentId);
|
|
2789
|
+
return;
|
|
2790
|
+
}
|
|
2791
|
+
throw makeWorkflowError({
|
|
2792
|
+
code: "WORKFLOW_INVALID_STEP",
|
|
2793
|
+
message: "Unknown step kind.",
|
|
2794
|
+
source: { stepKey: key, ...fragmentId ? { fragmentId } : null },
|
|
2795
|
+
detail: { kind: step.kind }
|
|
2796
|
+
});
|
|
2797
|
+
};
|
|
2798
|
+
const sources = def.sources;
|
|
2799
|
+
const fragmentByStepKey = /* @__PURE__ */ new Map();
|
|
2800
|
+
if (sources && typeof sources === "object") {
|
|
2801
|
+
for (const [k, v] of Object.entries(sources)) {
|
|
2802
|
+
fragmentByStepKey.set(k, isRecord3(v) ? asNonEmptyString(v.fragmentId) : void 0);
|
|
2803
|
+
}
|
|
2804
|
+
}
|
|
2805
|
+
for (const step of def.steps) {
|
|
2806
|
+
const key = isRecord3(step) ? asNonEmptyString(step.key) : void 0;
|
|
2807
|
+
const fragmentId = key ? fragmentByStepKey.get(key) : void 0;
|
|
2808
|
+
visit(step, fragmentId);
|
|
2809
|
+
}
|
|
2810
|
+
const generator = isRecord3(def.meta) ? def.meta.generator : void 0;
|
|
2811
|
+
if (generator !== void 0 && !isJsonValue(generator)) {
|
|
2812
|
+
throw makeWorkflowError({
|
|
2813
|
+
code: "WORKFLOW_INVALID_DEF",
|
|
2814
|
+
message: "WorkflowDef.meta.generator must be JSON-serializable.",
|
|
2815
|
+
detail: { generator }
|
|
2816
|
+
});
|
|
2817
|
+
}
|
|
2818
|
+
const policy = isRecord3(def.policy) ? def.policy : void 0;
|
|
2819
|
+
if (policy) {
|
|
2820
|
+
const concurrency = policy.concurrency;
|
|
2821
|
+
if (concurrency !== void 0 && concurrency !== "latest" && concurrency !== "exhaust" && concurrency !== "parallel") {
|
|
2822
|
+
throw makeWorkflowError({
|
|
2823
|
+
code: "WORKFLOW_INVALID_DEF",
|
|
2824
|
+
message: "policy.concurrency must be latest|exhaust|parallel.",
|
|
2825
|
+
detail: { concurrency }
|
|
2826
|
+
});
|
|
2827
|
+
}
|
|
2828
|
+
const priority = policy.priority;
|
|
2829
|
+
if (priority !== void 0 && priority !== "urgent" && priority !== "nonUrgent") {
|
|
2830
|
+
throw makeWorkflowError({
|
|
2831
|
+
code: "WORKFLOW_INVALID_DEF",
|
|
2832
|
+
message: "policy.priority must be urgent|nonUrgent.",
|
|
2833
|
+
detail: { priority }
|
|
2834
|
+
});
|
|
2835
|
+
}
|
|
2836
|
+
}
|
|
2837
|
+
void options?.moduleId;
|
|
2838
|
+
}
|
|
2839
|
+
var validateInputExpr = (expr, options) => {
|
|
2840
|
+
const visit = (e) => {
|
|
2841
|
+
if (!isRecord3(e)) {
|
|
2842
|
+
throw makeWorkflowError({
|
|
2843
|
+
code: "WORKFLOW_INVALID_INPUT_EXPR",
|
|
2844
|
+
message: "InputExpr must be an object.",
|
|
2845
|
+
source: { stepKey: options?.stepKey },
|
|
2846
|
+
detail: { expr: e }
|
|
2847
|
+
});
|
|
2848
|
+
}
|
|
2849
|
+
const kind = e.kind;
|
|
2850
|
+
switch (kind) {
|
|
2851
|
+
case "payload":
|
|
2852
|
+
return;
|
|
2853
|
+
case "payload.path": {
|
|
2854
|
+
const pointer = e.pointer;
|
|
2855
|
+
if (typeof pointer !== "string") {
|
|
2856
|
+
throw makeWorkflowError({
|
|
2857
|
+
code: "WORKFLOW_INVALID_INPUT_EXPR",
|
|
2858
|
+
message: "InputExpr.payload.path.pointer must be a string.",
|
|
2859
|
+
source: { stepKey: options?.stepKey },
|
|
2860
|
+
detail: { pointer }
|
|
2861
|
+
});
|
|
2862
|
+
}
|
|
2863
|
+
return;
|
|
2864
|
+
}
|
|
2865
|
+
case "const": {
|
|
2866
|
+
const value = e.value;
|
|
2867
|
+
if (!isJsonValue(value)) {
|
|
2868
|
+
throw makeWorkflowError({
|
|
2869
|
+
code: "WORKFLOW_INVALID_INPUT_EXPR",
|
|
2870
|
+
message: "InputExpr.const.value must be JSON-serializable.",
|
|
2871
|
+
source: { stepKey: options?.stepKey }
|
|
2872
|
+
});
|
|
2873
|
+
}
|
|
2874
|
+
return;
|
|
2875
|
+
}
|
|
2876
|
+
case "object": {
|
|
2877
|
+
const fields = e.fields;
|
|
2878
|
+
if (!isRecord3(fields)) {
|
|
2879
|
+
throw makeWorkflowError({
|
|
2880
|
+
code: "WORKFLOW_INVALID_INPUT_EXPR",
|
|
2881
|
+
message: "InputExpr.object.fields must be a record.",
|
|
2882
|
+
source: { stepKey: options?.stepKey }
|
|
2883
|
+
});
|
|
2884
|
+
}
|
|
2885
|
+
for (const v of Object.values(fields)) {
|
|
2886
|
+
visit(v);
|
|
2887
|
+
}
|
|
2888
|
+
return;
|
|
2889
|
+
}
|
|
2890
|
+
case "merge": {
|
|
2891
|
+
const items = e.items;
|
|
2892
|
+
if (!Array.isArray(items)) {
|
|
2893
|
+
throw makeWorkflowError({
|
|
2894
|
+
code: "WORKFLOW_INVALID_INPUT_EXPR",
|
|
2895
|
+
message: "InputExpr.merge.items must be an array.",
|
|
2896
|
+
source: { stepKey: options?.stepKey }
|
|
2897
|
+
});
|
|
2898
|
+
}
|
|
2899
|
+
for (const item of items) {
|
|
2900
|
+
visit(item);
|
|
2901
|
+
}
|
|
2902
|
+
return;
|
|
2903
|
+
}
|
|
2904
|
+
default:
|
|
2905
|
+
throw makeWorkflowError({
|
|
2906
|
+
code: "WORKFLOW_INVALID_INPUT_EXPR",
|
|
2907
|
+
message: "Unknown InputExpr kind.",
|
|
2908
|
+
source: { stepKey: options?.stepKey },
|
|
2909
|
+
detail: { kind }
|
|
2910
|
+
});
|
|
2911
|
+
}
|
|
2912
|
+
};
|
|
2913
|
+
visit(expr);
|
|
2914
|
+
};
|
|
2915
|
+
var makeDigest = (prefix, value) => `${prefix}:${fnv1a32(stableStringify(value))}`;
|
|
2916
|
+
var makeTriggerNodeId = (programId) => `wf_trigger_v1:${fnv1a32(programId)}`;
|
|
2917
|
+
var makeStepNodeId = (programId, stepKey, kind) => `wf_node_v1:${fnv1a32(`${programId}\0${stepKey}\0${kind}`)}`;
|
|
2918
|
+
var budgetJsonValue = (value) => projectJsonValue(value).value;
|
|
2919
|
+
var budgetInputExpr = (expr) => {
|
|
2920
|
+
switch (expr.kind) {
|
|
2921
|
+
case "payload":
|
|
2922
|
+
case "payload.path":
|
|
2923
|
+
return expr;
|
|
2924
|
+
case "const": {
|
|
2925
|
+
const value = expr.value;
|
|
2926
|
+
if (!isJsonValue(value)) return expr;
|
|
2927
|
+
return { ...expr, value: budgetJsonValue(expr.value) };
|
|
2928
|
+
}
|
|
2929
|
+
case "object": {
|
|
2930
|
+
const out = {};
|
|
2931
|
+
for (const k of Object.keys(expr.fields).sort()) {
|
|
2932
|
+
out[k] = budgetInputExpr(expr.fields[k]);
|
|
2933
|
+
}
|
|
2934
|
+
return { ...expr, fields: out };
|
|
2935
|
+
}
|
|
2936
|
+
case "merge":
|
|
2937
|
+
return { ...expr, items: expr.items.map(budgetInputExpr) };
|
|
2938
|
+
}
|
|
2939
|
+
};
|
|
2940
|
+
var toStaticStep = (step) => {
|
|
2941
|
+
switch (step.kind) {
|
|
2942
|
+
case "dispatch":
|
|
2943
|
+
return {
|
|
2944
|
+
kind: "dispatch",
|
|
2945
|
+
actionTag: step.actionTag,
|
|
2946
|
+
...step.payload ? { payload: budgetInputExpr(step.payload) } : null
|
|
2947
|
+
};
|
|
2948
|
+
case "delay":
|
|
2949
|
+
return { kind: "delay", ms: step.ms };
|
|
2950
|
+
case "call": {
|
|
2951
|
+
const policy = step.timeoutMs !== void 0 || step.retry !== void 0 ? {
|
|
2952
|
+
...step.timeoutMs !== void 0 ? { timeoutMs: step.timeoutMs } : null,
|
|
2953
|
+
...step.retry !== void 0 ? { retry: { times: step.retry.times } } : null
|
|
2954
|
+
} : void 0;
|
|
2955
|
+
return {
|
|
2956
|
+
kind: "call",
|
|
2957
|
+
serviceId: step.serviceId,
|
|
2958
|
+
...step.input ? { input: budgetInputExpr(step.input) } : null,
|
|
2959
|
+
...policy ? { policy } : null
|
|
2960
|
+
};
|
|
2961
|
+
}
|
|
2962
|
+
}
|
|
2963
|
+
};
|
|
2964
|
+
var compileWorkflowStaticIrV1 = (args) => {
|
|
2965
|
+
const normalized = normalizeWorkflowDefV1(args.def);
|
|
2966
|
+
validateWorkflowDefV1(normalized, { moduleId: args.moduleId });
|
|
2967
|
+
const programId = `${args.moduleId}.${normalized.localId}`;
|
|
2968
|
+
const triggerNodeId = makeTriggerNodeId(programId);
|
|
2969
|
+
const fragmentByStepKey = /* @__PURE__ */ new Map();
|
|
2970
|
+
if (normalized.sources && typeof normalized.sources === "object") {
|
|
2971
|
+
for (const [k, v] of Object.entries(normalized.sources)) {
|
|
2972
|
+
fragmentByStepKey.set(k, isRecord3(v) ? asNonEmptyString(v.fragmentId) : void 0);
|
|
2973
|
+
}
|
|
2974
|
+
}
|
|
2975
|
+
const nodesByKey = /* @__PURE__ */ new Map();
|
|
2976
|
+
const collectNodes = (steps) => {
|
|
2977
|
+
for (const step of steps) {
|
|
2978
|
+
const id = makeStepNodeId(programId, step.key, step.kind);
|
|
2979
|
+
nodesByKey.set(step.key, id);
|
|
2980
|
+
if (step.kind === "call") {
|
|
2981
|
+
collectNodes(step.onSuccess);
|
|
2982
|
+
collectNodes(step.onFailure);
|
|
2983
|
+
}
|
|
2984
|
+
}
|
|
2985
|
+
};
|
|
2986
|
+
collectNodes(normalized.steps);
|
|
2987
|
+
const nodes = [
|
|
2988
|
+
{
|
|
2989
|
+
id: triggerNodeId,
|
|
2990
|
+
kind: "trigger",
|
|
2991
|
+
trigger: normalized.trigger
|
|
2992
|
+
}
|
|
2993
|
+
];
|
|
2994
|
+
const addStepNodes = (steps) => {
|
|
2995
|
+
for (const step of steps) {
|
|
2996
|
+
const id = nodesByKey.get(step.key);
|
|
2997
|
+
if (!id) continue;
|
|
2998
|
+
const fragmentId = fragmentByStepKey.get(step.key);
|
|
2999
|
+
nodes.push({
|
|
3000
|
+
id,
|
|
3001
|
+
kind: "step",
|
|
3002
|
+
step: toStaticStep(step),
|
|
3003
|
+
source: {
|
|
3004
|
+
stepKey: step.key,
|
|
3005
|
+
...fragmentId ? { fragmentId } : null
|
|
3006
|
+
}
|
|
3007
|
+
});
|
|
3008
|
+
if (step.kind === "call") {
|
|
3009
|
+
addStepNodes(step.onSuccess);
|
|
3010
|
+
addStepNodes(step.onFailure);
|
|
3011
|
+
}
|
|
3012
|
+
}
|
|
3013
|
+
};
|
|
3014
|
+
addStepNodes(normalized.steps);
|
|
3015
|
+
const edges = [];
|
|
3016
|
+
const pushEdge = (from, to, kind) => {
|
|
3017
|
+
edges.push({ from, to, kind });
|
|
3018
|
+
};
|
|
3019
|
+
const compileBlock = (args2) => {
|
|
3020
|
+
if (args2.steps.length === 0) {
|
|
3021
|
+
if (args2.continuation) {
|
|
3022
|
+
for (const from of args2.entryFrom) {
|
|
3023
|
+
pushEdge(from, args2.continuation, args2.entryKind);
|
|
3024
|
+
}
|
|
3025
|
+
}
|
|
3026
|
+
return;
|
|
3027
|
+
}
|
|
3028
|
+
const first = args2.steps[0];
|
|
3029
|
+
const firstId = nodesByKey.get(first.key);
|
|
3030
|
+
if (!firstId) {
|
|
3031
|
+
throw makeWorkflowError({
|
|
3032
|
+
code: "WORKFLOW_INVALID_STEP",
|
|
3033
|
+
message: "Internal error: missing node id for stepKey.",
|
|
3034
|
+
programId,
|
|
3035
|
+
source: { stepKey: first.key }
|
|
3036
|
+
});
|
|
3037
|
+
}
|
|
3038
|
+
for (const from of args2.entryFrom) {
|
|
3039
|
+
pushEdge(from, firstId, args2.entryKind);
|
|
3040
|
+
}
|
|
3041
|
+
const compileStepAndTail = (step, tail, continuation) => {
|
|
3042
|
+
const stepId = nodesByKey.get(step.key);
|
|
3043
|
+
if (!stepId) return;
|
|
3044
|
+
if (step.kind !== "call") {
|
|
3045
|
+
compileBlock({ steps: tail, entryFrom: [stepId], entryKind: "next", continuation });
|
|
3046
|
+
return;
|
|
3047
|
+
}
|
|
3048
|
+
const cont = tail.length > 0 ? nodesByKey.get(tail[0].key) : continuation;
|
|
3049
|
+
compileBlock({
|
|
3050
|
+
steps: step.onSuccess,
|
|
3051
|
+
entryFrom: [stepId],
|
|
3052
|
+
entryKind: "success",
|
|
3053
|
+
continuation: cont
|
|
3054
|
+
});
|
|
3055
|
+
compileBlock({
|
|
3056
|
+
steps: step.onFailure,
|
|
3057
|
+
entryFrom: [stepId],
|
|
3058
|
+
entryKind: "failure",
|
|
3059
|
+
continuation: cont
|
|
3060
|
+
});
|
|
3061
|
+
compileBlock({ steps: tail, entryFrom: [], entryKind: "next", continuation });
|
|
3062
|
+
};
|
|
3063
|
+
compileStepAndTail(first, args2.steps.slice(1), args2.continuation);
|
|
3064
|
+
};
|
|
3065
|
+
compileBlock({ steps: normalized.steps, entryFrom: [triggerNodeId], entryKind: "next", continuation: void 0 });
|
|
3066
|
+
nodes.sort((a, b) => a.id < b.id ? -1 : a.id > b.id ? 1 : 0);
|
|
3067
|
+
edges.sort((a, b) => {
|
|
3068
|
+
if (a.from !== b.from) return a.from < b.from ? -1 : 1;
|
|
3069
|
+
if (a.to !== b.to) return a.to < b.to ? -1 : 1;
|
|
3070
|
+
const ak = String(a.kind ?? "");
|
|
3071
|
+
const bk = String(b.kind ?? "");
|
|
3072
|
+
if (ak !== bk) return ak < bk ? -1 : 1;
|
|
3073
|
+
return 0;
|
|
3074
|
+
});
|
|
3075
|
+
const meta = (() => {
|
|
3076
|
+
const generator = normalized.meta?.generator;
|
|
3077
|
+
if (generator === void 0) return void 0;
|
|
3078
|
+
return { generator: budgetJsonValue(generator) };
|
|
3079
|
+
})();
|
|
3080
|
+
const irNoDigest = {
|
|
3081
|
+
version: 1,
|
|
3082
|
+
programId,
|
|
3083
|
+
nodes,
|
|
3084
|
+
edges,
|
|
3085
|
+
policy: normalized.policy,
|
|
3086
|
+
meta
|
|
3087
|
+
};
|
|
3088
|
+
const digest = makeDigest("workflow_ir_v1", irNoDigest);
|
|
3089
|
+
return {
|
|
3090
|
+
...irNoDigest,
|
|
3091
|
+
digest
|
|
3092
|
+
};
|
|
3093
|
+
};
|
|
3094
|
+
|
|
3095
|
+
// src/internal/observability/controlSurfaceManifest.ts
|
|
3096
|
+
var makeDigest2 = (value) => `control_surface_v1:${fnv1a32(stableStringify(value))}`;
|
|
3097
|
+
var exportEffectsIndexDigest = (entries) => `effects_index_v1:${fnv1a32(stableStringify(entries))}`;
|
|
3098
|
+
var exportWorkflowEffectsIndex = (args) => {
|
|
3099
|
+
const moduleId = args.moduleId;
|
|
3100
|
+
return Array.from(args.workflowSurface).sort((a, b) => a.programId < b.programId ? -1 : a.programId > b.programId ? 1 : 0).map((ir) => {
|
|
3101
|
+
const localId = ir.programId.startsWith(`${moduleId}.`) ? ir.programId.slice(moduleId.length + 1) : ir.programId;
|
|
3102
|
+
const triggerNode = ir.nodes.find((n) => n.kind === "trigger");
|
|
3103
|
+
const trigger = triggerNode?.kind === "trigger" && triggerNode.trigger.kind === "action" ? { kind: "action", action: { moduleId, actionTag: triggerNode.trigger.actionTag } } : {
|
|
3104
|
+
kind: "lifecycle",
|
|
3105
|
+
phase: triggerNode?.kind === "trigger" && triggerNode.trigger.kind === "lifecycle" ? triggerNode.trigger.phase : "onStart"
|
|
3106
|
+
};
|
|
3107
|
+
return {
|
|
3108
|
+
kind: "workflow",
|
|
3109
|
+
effectId: `${moduleId}::workflow:${localId}`,
|
|
3110
|
+
trigger,
|
|
3111
|
+
programId: ir.programId,
|
|
3112
|
+
programDigest: ir.digest
|
|
3113
|
+
};
|
|
3114
|
+
});
|
|
3115
|
+
};
|
|
3116
|
+
var exportControlSurfaceManifest = (input) => {
|
|
3117
|
+
const modules = Array.from(input.modules).sort((a, b) => a.moduleId < b.moduleId ? -1 : a.moduleId > b.moduleId ? 1 : 0);
|
|
3118
|
+
const meta = input.meta;
|
|
3119
|
+
const base = {
|
|
3120
|
+
version: 1,
|
|
3121
|
+
modules,
|
|
3122
|
+
...meta ? { meta } : null
|
|
3123
|
+
};
|
|
3124
|
+
return {
|
|
3125
|
+
...base,
|
|
3126
|
+
digest: makeDigest2(base)
|
|
3127
|
+
};
|
|
3128
|
+
};
|
|
3129
|
+
|
|
3130
|
+
// src/internal/observability/workflowSurface.ts
|
|
3131
|
+
var makeDigest3 = (value) => `workflow_surface_v1:${fnv1a32(stableStringify(value))}`;
|
|
3132
|
+
var exportWorkflowSurface = (programs) => {
|
|
3133
|
+
const sorted = Array.from(programs).sort(
|
|
3134
|
+
(a, b) => a.programId < b.programId ? -1 : a.programId > b.programId ? 1 : 0
|
|
3135
|
+
);
|
|
3136
|
+
const base = { version: 1, programs: sorted };
|
|
3137
|
+
return { ...base, digest: makeDigest3(base) };
|
|
3138
|
+
};
|
|
3139
|
+
|
|
3140
|
+
// src/internal/reflection/controlSurface.ts
|
|
3141
|
+
var MODULE_INTERNAL2 = /* @__PURE__ */ Symbol.for("logix.module.internal");
|
|
3142
|
+
var isRecord4 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3143
|
+
var isObjectLike = (value) => typeof value === "object" && value !== null || typeof value === "function";
|
|
3144
|
+
var asNonEmptyString2 = (value) => typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
|
|
3145
|
+
var resolveTagId = (tag) => {
|
|
3146
|
+
if (!isObjectLike(tag)) return void 0;
|
|
3147
|
+
return asNonEmptyString2(tag.id);
|
|
3148
|
+
};
|
|
3149
|
+
var resolveModuleIdOrThrow = (module2) => {
|
|
3150
|
+
if (isRecord4(module2) && module2._tag === "ModuleImpl") {
|
|
3151
|
+
const id = resolveTagId(module2.module);
|
|
3152
|
+
if (id) return id;
|
|
3153
|
+
throw new Error(
|
|
3154
|
+
"[ControlSurfaceManifest] Failed to resolve moduleId from ModuleImpl.module.id.\nFix: pass a configured Module/ModuleImpl (has .id/.tag.id/.module.id), not a read-only handle."
|
|
3155
|
+
);
|
|
3156
|
+
}
|
|
3157
|
+
if (isRecord4(module2)) {
|
|
3158
|
+
const id = asNonEmptyString2(module2.id);
|
|
3159
|
+
if (id) return id;
|
|
3160
|
+
const tagId = resolveTagId(module2.tag);
|
|
3161
|
+
if (tagId) return tagId;
|
|
3162
|
+
}
|
|
3163
|
+
throw new Error(
|
|
3164
|
+
"[ControlSurfaceManifest] Failed to resolve moduleId.\nFix: pass a configured Module/ModuleImpl (has .id/.tag.id/.module.id), not a read-only handle."
|
|
3165
|
+
);
|
|
3166
|
+
};
|
|
3167
|
+
var resolveWorkflowDefs = (module2) => {
|
|
3168
|
+
if (!isObjectLike(module2)) return [];
|
|
3169
|
+
const internal = module2[MODULE_INTERNAL2];
|
|
3170
|
+
const defs = isRecord4(internal) ? internal.workflowDefs : void 0;
|
|
3171
|
+
return Array.isArray(defs) ? defs : [];
|
|
3172
|
+
};
|
|
3173
|
+
var exportControlSurface = (modules, options) => {
|
|
3174
|
+
const entries = [];
|
|
3175
|
+
const workflowSurfaces = [];
|
|
3176
|
+
const seen = /* @__PURE__ */ new Set();
|
|
3177
|
+
for (const module2 of modules) {
|
|
3178
|
+
const moduleId = resolveModuleIdOrThrow(module2);
|
|
3179
|
+
if (seen.has(moduleId)) {
|
|
3180
|
+
throw new Error(`[ControlSurfaceManifest] Duplicate moduleId "${moduleId}".`);
|
|
3181
|
+
}
|
|
3182
|
+
seen.add(moduleId);
|
|
3183
|
+
const defs = resolveWorkflowDefs(module2);
|
|
3184
|
+
if (defs.length === 0) {
|
|
3185
|
+
entries.push({ moduleId, effectsIndex: [] });
|
|
3186
|
+
continue;
|
|
3187
|
+
}
|
|
3188
|
+
const workflowIrs = defs.map((def) => compileWorkflowStaticIrV1({ moduleId, def }));
|
|
3189
|
+
const surface = exportWorkflowSurface(workflowIrs);
|
|
3190
|
+
workflowSurfaces.push({ moduleId, surface });
|
|
3191
|
+
const effectsIndex = exportWorkflowEffectsIndex({ moduleId, workflowSurface: surface.programs });
|
|
3192
|
+
const effectsIndexDigest = effectsIndex.length > 0 ? exportEffectsIndexDigest(effectsIndex) : void 0;
|
|
3193
|
+
entries.push({
|
|
3194
|
+
moduleId,
|
|
3195
|
+
workflowSurface: { digest: surface.digest },
|
|
3196
|
+
effectsIndex,
|
|
3197
|
+
...effectsIndexDigest ? { effectsIndexDigest } : null
|
|
3198
|
+
});
|
|
3199
|
+
}
|
|
3200
|
+
const manifest = exportControlSurfaceManifest({
|
|
3201
|
+
version: 1,
|
|
3202
|
+
modules: entries,
|
|
3203
|
+
...options?.meta ? { meta: options.meta } : null
|
|
3204
|
+
});
|
|
3205
|
+
return { manifest, workflowSurfaces };
|
|
3206
|
+
};
|
|
3207
|
+
|
|
3208
|
+
// src/internal/reflection/diff.ts
|
|
3209
|
+
var SEVERITY_RANK = {
|
|
3210
|
+
BREAKING: 0,
|
|
3211
|
+
RISKY: 1,
|
|
3212
|
+
INFO: 2
|
|
3213
|
+
};
|
|
3214
|
+
var uniqSorted = (input) => {
|
|
3215
|
+
const out = Array.from(new Set(input.filter((x) => typeof x === "string" && x.length > 0)));
|
|
3216
|
+
out.sort();
|
|
3217
|
+
return out;
|
|
3218
|
+
};
|
|
3219
|
+
var diffStringKeys = (before, after) => {
|
|
3220
|
+
const beforeSet = new Set(uniqSorted(before ?? []));
|
|
3221
|
+
const afterSet = new Set(uniqSorted(after ?? []));
|
|
3222
|
+
const removed = [];
|
|
3223
|
+
for (const k of beforeSet) {
|
|
3224
|
+
if (!afterSet.has(k)) removed.push(k);
|
|
3225
|
+
}
|
|
3226
|
+
removed.sort();
|
|
3227
|
+
const added = [];
|
|
3228
|
+
for (const k of afterSet) {
|
|
3229
|
+
if (!beforeSet.has(k)) added.push(k);
|
|
3230
|
+
}
|
|
3231
|
+
added.sort();
|
|
3232
|
+
return { removed, added };
|
|
3233
|
+
};
|
|
3234
|
+
var eqJsonValue = (a, b) => stableStringify(a) === stableStringify(b);
|
|
3235
|
+
var indexLogicUnits = (input) => {
|
|
3236
|
+
const map = /* @__PURE__ */ new Map();
|
|
3237
|
+
for (const unit of input ?? []) {
|
|
3238
|
+
if (!unit || typeof unit !== "object") continue;
|
|
3239
|
+
const id = unit.id;
|
|
3240
|
+
if (typeof id !== "string" || id.length === 0) continue;
|
|
3241
|
+
map.set(id, unit);
|
|
3242
|
+
}
|
|
3243
|
+
return map;
|
|
3244
|
+
};
|
|
3245
|
+
var diffManifest = (before, after, options) => {
|
|
3246
|
+
const changes = [];
|
|
3247
|
+
if (before.moduleId !== after.moduleId) {
|
|
3248
|
+
changes.push({
|
|
3249
|
+
severity: "BREAKING",
|
|
3250
|
+
code: "moduleId.changed",
|
|
3251
|
+
message: `moduleId changed (${before.moduleId} -> ${after.moduleId})`,
|
|
3252
|
+
pointer: "/moduleId",
|
|
3253
|
+
details: {
|
|
3254
|
+
before: before.moduleId,
|
|
3255
|
+
after: after.moduleId
|
|
3256
|
+
}
|
|
3257
|
+
});
|
|
3258
|
+
}
|
|
3259
|
+
if (before.manifestVersion !== after.manifestVersion) {
|
|
3260
|
+
changes.push({
|
|
3261
|
+
severity: "INFO",
|
|
3262
|
+
code: "manifestVersion.changed",
|
|
3263
|
+
message: `manifestVersion changed (${before.manifestVersion} -> ${after.manifestVersion})`,
|
|
3264
|
+
pointer: "/manifestVersion",
|
|
3265
|
+
details: {
|
|
3266
|
+
before: before.manifestVersion,
|
|
3267
|
+
after: after.manifestVersion
|
|
3268
|
+
}
|
|
3269
|
+
});
|
|
3270
|
+
}
|
|
3271
|
+
{
|
|
3272
|
+
const { removed, added } = diffStringKeys(before.actionKeys, after.actionKeys);
|
|
3273
|
+
if (removed.length > 0 || added.length > 0) {
|
|
3274
|
+
changes.push({
|
|
3275
|
+
severity: removed.length > 0 ? "BREAKING" : "INFO",
|
|
3276
|
+
code: "actionKeys.changed",
|
|
3277
|
+
message: removed.length > 0 ? `actionKeys removed: ${removed.join(", ")}` : `actionKeys added: ${added.join(", ")}`,
|
|
3278
|
+
pointer: "/actionKeys",
|
|
3279
|
+
details: { removed, added }
|
|
3280
|
+
});
|
|
3281
|
+
}
|
|
3282
|
+
}
|
|
3283
|
+
{
|
|
3284
|
+
const { removed, added } = diffStringKeys(before.schemaKeys, after.schemaKeys);
|
|
3285
|
+
if (removed.length > 0 || added.length > 0) {
|
|
3286
|
+
changes.push({
|
|
3287
|
+
severity: removed.length > 0 ? "BREAKING" : "INFO",
|
|
3288
|
+
code: "schemaKeys.changed",
|
|
3289
|
+
message: removed.length > 0 ? `schemaKeys removed: ${removed.join(", ")}` : `schemaKeys added: ${added.join(", ")}`,
|
|
3290
|
+
pointer: "/schemaKeys",
|
|
3291
|
+
details: { removed, added }
|
|
3292
|
+
});
|
|
3293
|
+
}
|
|
3294
|
+
}
|
|
3295
|
+
{
|
|
3296
|
+
const beforeById = indexLogicUnits(before.logicUnits);
|
|
3297
|
+
const afterById = indexLogicUnits(after.logicUnits);
|
|
3298
|
+
const removed = [];
|
|
3299
|
+
const added = [];
|
|
3300
|
+
const kindChanged = [];
|
|
3301
|
+
const riskyChanged = [];
|
|
3302
|
+
for (const id of beforeById.keys()) {
|
|
3303
|
+
if (!afterById.has(id)) removed.push(id);
|
|
3304
|
+
}
|
|
3305
|
+
for (const id of afterById.keys()) {
|
|
3306
|
+
if (!beforeById.has(id)) added.push(id);
|
|
3307
|
+
}
|
|
3308
|
+
removed.sort();
|
|
3309
|
+
added.sort();
|
|
3310
|
+
for (const id of beforeById.keys()) {
|
|
3311
|
+
const b = beforeById.get(id);
|
|
3312
|
+
const a = afterById.get(id);
|
|
3313
|
+
if (!b || !a) continue;
|
|
3314
|
+
const fields = [];
|
|
3315
|
+
if (b.kind !== a.kind) {
|
|
3316
|
+
kindChanged.push({ id, before: b.kind, after: a.kind });
|
|
3317
|
+
continue;
|
|
3318
|
+
}
|
|
3319
|
+
if (b.name !== a.name) fields.push("name");
|
|
3320
|
+
if (b.derived !== a.derived) fields.push("derived");
|
|
3321
|
+
if (fields.length > 0) riskyChanged.push({ id, fields });
|
|
3322
|
+
}
|
|
3323
|
+
kindChanged.sort((x, y) => x.id < y.id ? -1 : x.id > y.id ? 1 : 0);
|
|
3324
|
+
riskyChanged.sort((x, y) => x.id < y.id ? -1 : x.id > y.id ? 1 : 0);
|
|
3325
|
+
if (removed.length > 0) {
|
|
3326
|
+
changes.push({
|
|
3327
|
+
severity: "BREAKING",
|
|
3328
|
+
code: "logicUnits.removed",
|
|
3329
|
+
message: `logicUnits removed: ${removed.join(", ")}`,
|
|
3330
|
+
pointer: "/logicUnits",
|
|
3331
|
+
details: { removed }
|
|
3332
|
+
});
|
|
3333
|
+
}
|
|
3334
|
+
if (kindChanged.length > 0) {
|
|
3335
|
+
changes.push({
|
|
3336
|
+
severity: "BREAKING",
|
|
3337
|
+
code: "logicUnits.kindChanged",
|
|
3338
|
+
message: `logicUnits kind changed: ${kindChanged.map((x) => x.id).join(", ")}`,
|
|
3339
|
+
pointer: "/logicUnits",
|
|
3340
|
+
details: { kindChanged }
|
|
3341
|
+
});
|
|
3342
|
+
}
|
|
3343
|
+
if (added.length > 0) {
|
|
3344
|
+
changes.push({
|
|
3345
|
+
severity: "INFO",
|
|
3346
|
+
code: "logicUnits.added",
|
|
3347
|
+
message: `logicUnits added: ${added.join(", ")}`,
|
|
3348
|
+
pointer: "/logicUnits",
|
|
3349
|
+
details: { added }
|
|
3350
|
+
});
|
|
3351
|
+
}
|
|
3352
|
+
if (riskyChanged.length > 0) {
|
|
3353
|
+
changes.push({
|
|
3354
|
+
severity: "RISKY",
|
|
3355
|
+
code: "logicUnits.changed",
|
|
3356
|
+
message: `logicUnits changed: ${riskyChanged.map((x) => x.id).join(", ")}`,
|
|
3357
|
+
pointer: "/logicUnits",
|
|
3358
|
+
details: { changed: riskyChanged }
|
|
3359
|
+
});
|
|
3360
|
+
}
|
|
3361
|
+
}
|
|
3362
|
+
{
|
|
3363
|
+
const beforeDigest = before.staticIr?.digest;
|
|
3364
|
+
const afterDigest = after.staticIr?.digest;
|
|
3365
|
+
if (beforeDigest !== afterDigest) {
|
|
3366
|
+
changes.push({
|
|
3367
|
+
severity: "RISKY",
|
|
3368
|
+
code: "staticIr.digestChanged",
|
|
3369
|
+
message: "staticIr.digest changed",
|
|
3370
|
+
pointer: "/staticIr/digest",
|
|
3371
|
+
details: {
|
|
3372
|
+
before: beforeDigest ?? null,
|
|
3373
|
+
after: afterDigest ?? null
|
|
3374
|
+
}
|
|
3375
|
+
});
|
|
3376
|
+
}
|
|
3377
|
+
}
|
|
3378
|
+
{
|
|
3379
|
+
const metaBefore = before.meta ?? {};
|
|
3380
|
+
const metaAfter = after.meta ?? {};
|
|
3381
|
+
const allowlist = options?.metaAllowlist;
|
|
3382
|
+
const keys = allowlist != null ? uniqSorted(allowlist) : uniqSorted([...Object.keys(metaBefore), ...Object.keys(metaAfter)]);
|
|
3383
|
+
const changed = [];
|
|
3384
|
+
for (const key of keys) {
|
|
3385
|
+
const b = key in metaBefore ? metaBefore[key] : void 0;
|
|
3386
|
+
const a = key in metaAfter ? metaAfter[key] : void 0;
|
|
3387
|
+
if (!eqJsonValue(b, a)) {
|
|
3388
|
+
changed.push({
|
|
3389
|
+
key,
|
|
3390
|
+
before: b ?? null,
|
|
3391
|
+
after: a ?? null
|
|
3392
|
+
});
|
|
3393
|
+
}
|
|
3394
|
+
}
|
|
3395
|
+
if (changed.length > 0) {
|
|
3396
|
+
changes.push({
|
|
3397
|
+
severity: "RISKY",
|
|
3398
|
+
code: "meta.changed",
|
|
3399
|
+
message: "meta changed",
|
|
3400
|
+
pointer: "/meta",
|
|
3401
|
+
details: {
|
|
3402
|
+
keys: changed.map((x) => x.key),
|
|
3403
|
+
changed
|
|
2152
3404
|
}
|
|
2153
|
-
);
|
|
2154
|
-
options?.onMetaProjection?.({
|
|
2155
|
-
stats: metaProjection.stats,
|
|
2156
|
-
downgrade: metaProjection.downgrade
|
|
2157
3405
|
});
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
3406
|
+
}
|
|
3407
|
+
}
|
|
3408
|
+
{
|
|
3409
|
+
const b = before.source;
|
|
3410
|
+
const a = after.source;
|
|
3411
|
+
if (!eqJsonValue(b ?? null, a ?? null)) {
|
|
3412
|
+
changes.push({
|
|
3413
|
+
severity: "INFO",
|
|
3414
|
+
code: "source.changed",
|
|
3415
|
+
message: "source changed",
|
|
3416
|
+
pointer: "/source",
|
|
3417
|
+
details: {
|
|
3418
|
+
before: b ?? null,
|
|
3419
|
+
after: a ?? null
|
|
3420
|
+
}
|
|
2164
3421
|
});
|
|
2165
3422
|
}
|
|
2166
3423
|
}
|
|
3424
|
+
changes.sort((a, b) => {
|
|
3425
|
+
const ra = SEVERITY_RANK[a.severity];
|
|
3426
|
+
const rb = SEVERITY_RANK[b.severity];
|
|
3427
|
+
if (ra !== rb) return ra - rb;
|
|
3428
|
+
if (a.code !== b.code) return a.code < b.code ? -1 : 1;
|
|
3429
|
+
const pa = a.pointer ?? "";
|
|
3430
|
+
const pb = b.pointer ?? "";
|
|
3431
|
+
if (pa !== pb) return pa < pb ? -1 : 1;
|
|
3432
|
+
return 0;
|
|
3433
|
+
});
|
|
3434
|
+
const summary = {
|
|
3435
|
+
breaking: changes.filter((c) => c.severity === "BREAKING").length,
|
|
3436
|
+
risky: changes.filter((c) => c.severity === "RISKY").length,
|
|
3437
|
+
info: changes.filter((c) => c.severity === "INFO").length
|
|
3438
|
+
};
|
|
3439
|
+
const verdict = summary.breaking > 0 ? "FAIL" : summary.risky > 0 ? "WARN" : "PASS";
|
|
3440
|
+
return {
|
|
3441
|
+
version: "025",
|
|
3442
|
+
moduleId: after.moduleId,
|
|
3443
|
+
before: {
|
|
3444
|
+
digest: before.digest,
|
|
3445
|
+
manifestVersion: before.manifestVersion
|
|
3446
|
+
},
|
|
3447
|
+
after: {
|
|
3448
|
+
digest: after.digest,
|
|
3449
|
+
manifestVersion: after.manifestVersion
|
|
3450
|
+
},
|
|
3451
|
+
verdict,
|
|
3452
|
+
changes,
|
|
3453
|
+
summary
|
|
3454
|
+
};
|
|
3455
|
+
};
|
|
3456
|
+
|
|
3457
|
+
// src/internal/reflection/kernelContract.ts
|
|
3458
|
+
var import_effect37 = require("effect");
|
|
3459
|
+
|
|
3460
|
+
// src/internal/observability/trialRun.ts
|
|
3461
|
+
var import_effect36 = require("effect");
|
|
3462
|
+
|
|
3463
|
+
// src/internal/observability/evidenceCollector.ts
|
|
3464
|
+
var import_effect12 = require("effect");
|
|
3465
|
+
|
|
3466
|
+
// src/internal/observability/runSession.ts
|
|
3467
|
+
var import_effect11 = require("effect");
|
|
3468
|
+
var RunSessionTagImpl = class extends import_effect11.Context.Tag("@logixjs/core/RunSession")() {
|
|
3469
|
+
};
|
|
3470
|
+
var RunSessionTag = RunSessionTagImpl;
|
|
3471
|
+
var NEXT_RUN_SEQ_KEY = /* @__PURE__ */ Symbol.for("@logixjs/core/runSession/nextRunSeq");
|
|
3472
|
+
var fallbackNextRunSeq = 0;
|
|
3473
|
+
var nextRunSeq = () => {
|
|
3474
|
+
try {
|
|
3475
|
+
const g = globalThis;
|
|
3476
|
+
const prev = typeof g[NEXT_RUN_SEQ_KEY] === "number" ? g[NEXT_RUN_SEQ_KEY] : 0;
|
|
3477
|
+
const next = prev + 1;
|
|
3478
|
+
g[NEXT_RUN_SEQ_KEY] = next;
|
|
3479
|
+
return next;
|
|
3480
|
+
} catch {
|
|
3481
|
+
fallbackNextRunSeq += 1;
|
|
3482
|
+
return fallbackNextRunSeq;
|
|
3483
|
+
}
|
|
3484
|
+
};
|
|
3485
|
+
var makeRunId = (startedAt) => `run-${startedAt}.${nextRunSeq()}`;
|
|
3486
|
+
var makeRunSessionLocalState = () => {
|
|
3487
|
+
const onceKeys = /* @__PURE__ */ new Set();
|
|
3488
|
+
const seqByNamespace = /* @__PURE__ */ new Map();
|
|
3489
|
+
return {
|
|
3490
|
+
once: (key) => {
|
|
3491
|
+
if (onceKeys.has(key)) return false;
|
|
3492
|
+
onceKeys.add(key);
|
|
3493
|
+
return true;
|
|
3494
|
+
},
|
|
3495
|
+
nextSeq: (namespace, key) => {
|
|
3496
|
+
const byKey = seqByNamespace.get(namespace) ?? /* @__PURE__ */ new Map();
|
|
3497
|
+
if (!seqByNamespace.has(namespace)) seqByNamespace.set(namespace, byKey);
|
|
3498
|
+
const prev = byKey.get(key) ?? 0;
|
|
3499
|
+
const next = prev + 1;
|
|
3500
|
+
byKey.set(key, next);
|
|
3501
|
+
return next;
|
|
3502
|
+
},
|
|
3503
|
+
clear: () => {
|
|
3504
|
+
onceKeys.clear();
|
|
3505
|
+
seqByNamespace.clear();
|
|
3506
|
+
}
|
|
3507
|
+
};
|
|
3508
|
+
};
|
|
3509
|
+
var makeRunSession = (options) => {
|
|
3510
|
+
const startedAt = options?.startedAt ?? Date.now();
|
|
3511
|
+
return {
|
|
3512
|
+
runId: options?.runId ?? makeRunId(startedAt),
|
|
3513
|
+
source: options?.source ?? { host: "unknown" },
|
|
3514
|
+
startedAt,
|
|
3515
|
+
local: options?.local ?? makeRunSessionLocalState()
|
|
3516
|
+
};
|
|
3517
|
+
};
|
|
3518
|
+
var makeEvidenceSink = (session) => {
|
|
3519
|
+
const events = [];
|
|
3520
|
+
let nextSeq = 1;
|
|
3521
|
+
return {
|
|
3522
|
+
record: (type, payload, options) => {
|
|
3523
|
+
events.push({
|
|
3524
|
+
protocolVersion: OBSERVABILITY_PROTOCOL_VERSION,
|
|
3525
|
+
runId: session.runId,
|
|
3526
|
+
seq: nextSeq++,
|
|
3527
|
+
timestamp: options?.timestamp ?? Date.now(),
|
|
3528
|
+
type,
|
|
3529
|
+
payload
|
|
3530
|
+
});
|
|
3531
|
+
},
|
|
3532
|
+
export: (options) => {
|
|
3533
|
+
const protocolVersion = options?.protocolVersion ?? OBSERVABILITY_PROTOCOL_VERSION;
|
|
3534
|
+
const maxEvents = options?.maxEvents;
|
|
3535
|
+
const selected = typeof maxEvents === "number" && Number.isFinite(maxEvents) && maxEvents > 0 ? events.slice(Math.max(0, events.length - Math.floor(maxEvents))) : events.slice();
|
|
3536
|
+
return exportEvidencePackage({
|
|
3537
|
+
protocolVersion,
|
|
3538
|
+
runId: session.runId,
|
|
3539
|
+
source: session.source,
|
|
3540
|
+
createdAt: options?.createdAt,
|
|
3541
|
+
events: selected,
|
|
3542
|
+
summary: options?.summary
|
|
3543
|
+
});
|
|
3544
|
+
},
|
|
3545
|
+
clear: () => {
|
|
3546
|
+
events.length = 0;
|
|
3547
|
+
nextSeq = 1;
|
|
3548
|
+
}
|
|
3549
|
+
};
|
|
2167
3550
|
};
|
|
3551
|
+
var runSessionLayer = (session) => import_effect11.Layer.succeed(RunSessionTag, session ?? makeRunSession());
|
|
2168
3552
|
|
|
2169
3553
|
// src/internal/observability/evidenceCollector.ts
|
|
2170
|
-
var EvidenceCollectorTagImpl = class extends
|
|
3554
|
+
var EvidenceCollectorTagImpl = class extends import_effect12.Context.Tag("@logixjs/core/EvidenceCollector")() {
|
|
2171
3555
|
};
|
|
2172
3556
|
var EvidenceCollectorTag = EvidenceCollectorTagImpl;
|
|
2173
|
-
var evidenceCollectorLayer = (collector) =>
|
|
2174
|
-
var
|
|
3557
|
+
var evidenceCollectorLayer = (collector) => import_effect12.Layer.succeed(EvidenceCollectorTag, collector);
|
|
3558
|
+
var isRecord5 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2175
3559
|
var makeEvidenceCollector = (session) => {
|
|
2176
3560
|
const sink = makeEvidenceSink(session);
|
|
2177
3561
|
const convergeStaticIrByDigest = /* @__PURE__ */ new Map();
|
|
@@ -2183,8 +3567,8 @@ var makeEvidenceCollector = (session) => {
|
|
|
2183
3567
|
nonSerializable: 0
|
|
2184
3568
|
};
|
|
2185
3569
|
const debugSink = {
|
|
2186
|
-
record: (event) =>
|
|
2187
|
-
const level = yield*
|
|
3570
|
+
record: (event) => import_effect12.Effect.gen(function* () {
|
|
3571
|
+
const level = yield* import_effect12.FiberRef.get(currentDiagnosticsLevel);
|
|
2188
3572
|
const instanceIdRaw = event.instanceId;
|
|
2189
3573
|
const instanceId = typeof instanceIdRaw === "string" && instanceIdRaw.length > 0 ? instanceIdRaw : "unknown";
|
|
2190
3574
|
const eventSeq = level === "off" ? void 0 : session.local.nextSeq("eventSeq", instanceId);
|
|
@@ -2207,7 +3591,7 @@ var makeEvidenceCollector = (session) => {
|
|
|
2207
3591
|
})
|
|
2208
3592
|
};
|
|
2209
3593
|
const registerConvergeStaticIr = (staticIr) => {
|
|
2210
|
-
if (!
|
|
3594
|
+
if (!isRecord5(staticIr)) return;
|
|
2211
3595
|
const digest = staticIr.staticIrDigest;
|
|
2212
3596
|
if (typeof digest !== "string" || digest.length === 0) return;
|
|
2213
3597
|
const projected = projectJsonValue(staticIr);
|
|
@@ -2268,17 +3652,17 @@ var makeEvidenceCollector = (session) => {
|
|
|
2268
3652
|
};
|
|
2269
3653
|
|
|
2270
3654
|
// src/internal/runtime/core/RuntimeKernel.ts
|
|
2271
|
-
var
|
|
2272
|
-
var RuntimeServicesRuntimeConfigTagImpl = class extends
|
|
3655
|
+
var import_effect13 = require("effect");
|
|
3656
|
+
var RuntimeServicesRuntimeConfigTagImpl = class extends import_effect13.Context.Tag("@logixjs/core/RuntimeServicesRuntimeConfig")() {
|
|
2273
3657
|
};
|
|
2274
|
-
var RuntimeServicesProviderOverridesTagImpl = class extends
|
|
3658
|
+
var RuntimeServicesProviderOverridesTagImpl = class extends import_effect13.Context.Tag("@logixjs/core/RuntimeServicesProviderOverrides")() {
|
|
2275
3659
|
};
|
|
2276
|
-
var RuntimeServicesInstanceOverridesTagImpl = class extends
|
|
3660
|
+
var RuntimeServicesInstanceOverridesTagImpl = class extends import_effect13.Context.Tag("@logixjs/core/RuntimeServicesInstanceOverrides")() {
|
|
2277
3661
|
};
|
|
2278
3662
|
var RuntimeServicesInstanceOverridesTag = RuntimeServicesInstanceOverridesTagImpl;
|
|
2279
|
-
var FullCutoverGateModeTagImpl = class extends
|
|
3663
|
+
var FullCutoverGateModeTagImpl = class extends import_effect13.Context.Tag("@logixjs/core/FullCutoverGateMode")() {
|
|
2280
3664
|
};
|
|
2281
|
-
var RuntimeServicesRegistryTagImpl = class extends
|
|
3665
|
+
var RuntimeServicesRegistryTagImpl = class extends import_effect13.Context.Tag("@logixjs/core/RuntimeServicesRegistry")() {
|
|
2282
3666
|
};
|
|
2283
3667
|
var RUNTIME_SERVICES_EVIDENCE = /* @__PURE__ */ Symbol.for("@logixjs/core/runtimeServicesEvidence");
|
|
2284
3668
|
var formatScope = (moduleId, instanceId) => {
|
|
@@ -2313,24 +3697,24 @@ var getRuntimeServicesEvidence = (runtime) => {
|
|
|
2313
3697
|
};
|
|
2314
3698
|
|
|
2315
3699
|
// src/internal/runtime/core/ConvergeStaticIrCollector.ts
|
|
2316
|
-
var
|
|
2317
|
-
var currentConvergeStaticIrCollectors =
|
|
2318
|
-
var appendConvergeStaticIrCollectors = (collectors) =>
|
|
3700
|
+
var import_effect14 = require("effect");
|
|
3701
|
+
var currentConvergeStaticIrCollectors = import_effect14.FiberRef.unsafeMake([]);
|
|
3702
|
+
var appendConvergeStaticIrCollectors = (collectors) => import_effect14.Layer.fiberRefLocallyScopedWith(currentConvergeStaticIrCollectors, (current) => [
|
|
2319
3703
|
...current,
|
|
2320
3704
|
...collectors
|
|
2321
3705
|
]);
|
|
2322
3706
|
|
|
2323
3707
|
// src/internal/observability/trialRunModule.ts
|
|
2324
|
-
var
|
|
3708
|
+
var import_effect35 = require("effect");
|
|
2325
3709
|
|
|
2326
3710
|
// src/internal/platform/BuildEnv.ts
|
|
2327
|
-
var
|
|
3711
|
+
var import_effect17 = require("effect");
|
|
2328
3712
|
|
|
2329
3713
|
// src/internal/platform/ConstructionGuard.ts
|
|
2330
|
-
var
|
|
3714
|
+
var import_effect15 = require("effect");
|
|
2331
3715
|
|
|
2332
3716
|
// src/internal/platform/RuntimeHost.ts
|
|
2333
|
-
var
|
|
3717
|
+
var import_effect16 = require("effect");
|
|
2334
3718
|
var detectKind = () => {
|
|
2335
3719
|
const isBrowser2 = typeof window !== "undefined" && typeof document !== "undefined";
|
|
2336
3720
|
if (isBrowser2) return "browser";
|
|
@@ -2343,13 +3727,13 @@ var make = (kind) => ({
|
|
|
2343
3727
|
isNode: kind === "node",
|
|
2344
3728
|
isBrowser: kind === "browser"
|
|
2345
3729
|
});
|
|
2346
|
-
var RuntimeHost = class extends
|
|
3730
|
+
var RuntimeHost = class extends import_effect16.Context.Tag("@logixjs/RuntimeHost")() {
|
|
2347
3731
|
};
|
|
2348
|
-
var layer = (service) =>
|
|
3732
|
+
var layer = (service) => import_effect16.Layer.succeed(RuntimeHost, service);
|
|
2349
3733
|
var defaultLayer = layer(make(detectKind()));
|
|
2350
3734
|
|
|
2351
3735
|
// src/internal/runtime/core/KernelRef.ts
|
|
2352
|
-
var
|
|
3736
|
+
var import_effect18 = require("effect");
|
|
2353
3737
|
var isKernelId = (value) => typeof value === "string" && value.length > 0 && /^[a-z0-9-]+$/.test(value);
|
|
2354
3738
|
var defaultKernelImplementationRef = {
|
|
2355
3739
|
kernelId: "core",
|
|
@@ -2368,7 +3752,7 @@ var normalizeKernelImplementationRef = (value, fallback = defaultKernelImplement
|
|
|
2368
3752
|
...Array.isArray(v.capabilities) && v.capabilities.every((c) => typeof c === "string") ? { capabilities: v.capabilities } : {}
|
|
2369
3753
|
};
|
|
2370
3754
|
};
|
|
2371
|
-
var KernelImplementationRefTagImpl = class extends
|
|
3755
|
+
var KernelImplementationRefTagImpl = class extends import_effect18.Context.Tag("@logixjs/core/KernelImplementationRef")() {
|
|
2372
3756
|
};
|
|
2373
3757
|
var KERNEL_IMPLEMENTATION_REF = /* @__PURE__ */ Symbol.for("@logixjs/core/kernelImplementationRef");
|
|
2374
3758
|
var formatScope2 = (moduleId, instanceId) => {
|
|
@@ -2393,67 +3777,62 @@ var getKernelImplementationRef = (runtime) => {
|
|
|
2393
3777
|
};
|
|
2394
3778
|
|
|
2395
3779
|
// src/internal/runtime/core/runner/ProgramRunner.kernel.ts
|
|
2396
|
-
var
|
|
3780
|
+
var import_effect30 = require("effect");
|
|
2397
3781
|
|
|
2398
3782
|
// src/internal/runtime/core/BoundApiRuntime.ts
|
|
2399
|
-
var
|
|
2400
|
-
|
|
2401
|
-
// src/internal/runtime/core/TaskRunner.ts
|
|
2402
|
-
var import_effect15 = require("effect");
|
|
2403
|
-
var inSyncTransactionFiber = import_effect15.FiberRef.unsafeMake(false);
|
|
2404
|
-
var forceSourceRefresh = import_effect15.FiberRef.unsafeMake(false);
|
|
3783
|
+
var import_effect27 = require("effect");
|
|
2405
3784
|
|
|
2406
3785
|
// src/internal/runtime/core/mutativePatches.ts
|
|
2407
3786
|
var import_mutative = require("mutative");
|
|
2408
3787
|
|
|
2409
3788
|
// src/internal/runtime/core/FlowRuntime.ts
|
|
2410
|
-
var
|
|
3789
|
+
var import_effect20 = require("effect");
|
|
2411
3790
|
|
|
2412
3791
|
// src/internal/effect-op.ts
|
|
2413
|
-
var
|
|
3792
|
+
var import_effect19 = require("effect");
|
|
2414
3793
|
|
|
2415
3794
|
// src/internal/runtime/core/MatchBuilder.ts
|
|
2416
|
-
var
|
|
3795
|
+
var import_effect21 = require("effect");
|
|
2417
3796
|
|
|
2418
3797
|
// src/internal/runtime/core/Platform.ts
|
|
2419
|
-
var
|
|
2420
|
-
var Tag =
|
|
3798
|
+
var import_effect22 = require("effect");
|
|
3799
|
+
var Tag = import_effect22.Context.GenericTag("@logixjs/Platform");
|
|
2421
3800
|
|
|
2422
3801
|
// src/internal/runtime/core/Lifecycle.ts
|
|
2423
|
-
var
|
|
2424
|
-
var LifecycleContext =
|
|
3802
|
+
var import_effect23 = require("effect");
|
|
3803
|
+
var LifecycleContext = import_effect23.Context.GenericTag("@logixjs/LifecycleManager");
|
|
2425
3804
|
|
|
2426
3805
|
// src/internal/runtime/core/LogicDiagnostics.ts
|
|
2427
|
-
var
|
|
2428
|
-
var LogicPhaseServiceTag =
|
|
2429
|
-
var LogicUnitServiceTag = class extends
|
|
3806
|
+
var import_effect24 = require("effect");
|
|
3807
|
+
var LogicPhaseServiceTag = import_effect24.Context.GenericTag("@logixjs/LogicPhaseService");
|
|
3808
|
+
var LogicUnitServiceTag = class extends import_effect24.Context.Tag("@logixjs/LogicUnitService")() {
|
|
2430
3809
|
};
|
|
2431
3810
|
|
|
2432
3811
|
// src/internal/root.ts
|
|
2433
|
-
var
|
|
3812
|
+
var import_effect26 = require("effect");
|
|
2434
3813
|
|
|
2435
3814
|
// src/internal/runtime/core/RootContext.ts
|
|
2436
|
-
var
|
|
2437
|
-
var RootContextTagImpl = class extends
|
|
3815
|
+
var import_effect25 = require("effect");
|
|
3816
|
+
var RootContextTagImpl = class extends import_effect25.Context.Tag("@logixjs/core/RootContext")() {
|
|
2438
3817
|
};
|
|
2439
3818
|
|
|
2440
3819
|
// src/internal/runtime/core/runner/ProgramRunner.closeScope.ts
|
|
2441
|
-
var
|
|
3820
|
+
var import_effect28 = require("effect");
|
|
2442
3821
|
|
|
2443
3822
|
// src/internal/runtime/core/runner/ProgramRunner.signals.ts
|
|
2444
|
-
var
|
|
3823
|
+
var import_effect29 = require("effect");
|
|
2445
3824
|
|
|
2446
3825
|
// src/internal/runtime/Runtime.ts
|
|
2447
|
-
var
|
|
3826
|
+
var import_effect34 = require("effect");
|
|
2448
3827
|
|
|
2449
3828
|
// src/internal/runtime/AppRuntime.ts
|
|
2450
|
-
var
|
|
3829
|
+
var import_effect33 = require("effect");
|
|
2451
3830
|
|
|
2452
|
-
// src/internal/runtime/core/process/ProcessRuntime.ts
|
|
2453
|
-
var
|
|
3831
|
+
// src/internal/runtime/core/process/ProcessRuntime.make.ts
|
|
3832
|
+
var import_effect32 = require("effect");
|
|
2454
3833
|
|
|
2455
3834
|
// src/internal/runtime/core/process/concurrency.ts
|
|
2456
|
-
var
|
|
3835
|
+
var import_effect31 = require("effect");
|
|
2457
3836
|
|
|
2458
3837
|
// src/internal/runtime/core/process/events.ts
|
|
2459
3838
|
var PROCESS_EVENT_MAX_BYTES = 4 * 1024;
|
|
@@ -2461,11 +3840,11 @@ var PROCESS_EVENT_MAX_BYTES = 4 * 1024;
|
|
|
2461
3840
|
// src/internal/runtime/core/process/selectorSchema.ts
|
|
2462
3841
|
var SchemaAST = __toESM(require("effect/SchemaAST"), 1);
|
|
2463
3842
|
|
|
2464
|
-
// src/internal/runtime/core/process/ProcessRuntime.ts
|
|
2465
|
-
var ProcessRuntimeTag = class extends
|
|
3843
|
+
// src/internal/runtime/core/process/ProcessRuntime.make.ts
|
|
3844
|
+
var ProcessRuntimeTag = class extends import_effect32.Context.Tag("@logixjs/core/ProcessRuntime")() {
|
|
2466
3845
|
};
|
|
2467
|
-
var currentProcessTrigger =
|
|
2468
|
-
var currentProcessEventBudget =
|
|
3846
|
+
var currentProcessTrigger = import_effect32.FiberRef.unsafeMake(void 0);
|
|
3847
|
+
var currentProcessEventBudget = import_effect32.FiberRef.unsafeMake(
|
|
2469
3848
|
void 0
|
|
2470
3849
|
);
|
|
2471
3850
|
|
|
@@ -2477,7 +3856,7 @@ var defaultHost = () => {
|
|
|
2477
3856
|
if (typeof window !== "undefined" && typeof document !== "undefined") return "browser";
|
|
2478
3857
|
return "node";
|
|
2479
3858
|
};
|
|
2480
|
-
var trialRun = (program, options) =>
|
|
3859
|
+
var trialRun = (program, options) => import_effect36.Effect.gen(function* () {
|
|
2481
3860
|
const session = makeRunSession({
|
|
2482
3861
|
runId: options?.runId,
|
|
2483
3862
|
source: options?.source ?? { host: defaultHost(), label: "trial-run" },
|
|
@@ -2494,12 +3873,12 @@ var trialRun = (program, options) => import_effect33.Effect.gen(function* () {
|
|
|
2494
3873
|
const convergeLayer = appendConvergeStaticIrCollectors([convergeCollector]);
|
|
2495
3874
|
const collectorLayer = evidenceCollectorLayer(collector);
|
|
2496
3875
|
const sessionLayer = runSessionLayer(session);
|
|
2497
|
-
const overridesLayer = options?.runtimeServicesInstanceOverrides != null ?
|
|
3876
|
+
const overridesLayer = options?.runtimeServicesInstanceOverrides != null ? import_effect36.Layer.succeed(
|
|
2498
3877
|
RuntimeServicesInstanceOverridesTag,
|
|
2499
3878
|
options.runtimeServicesInstanceOverrides
|
|
2500
|
-
) :
|
|
2501
|
-
const trialLayer =
|
|
2502
|
-
options?.layer ??
|
|
3879
|
+
) : import_effect36.Layer.empty;
|
|
3880
|
+
const trialLayer = import_effect36.Layer.mergeAll(
|
|
3881
|
+
options?.layer ?? import_effect36.Layer.empty,
|
|
2503
3882
|
sessionLayer,
|
|
2504
3883
|
collectorLayer,
|
|
2505
3884
|
overridesLayer,
|
|
@@ -2507,9 +3886,9 @@ var trialRun = (program, options) => import_effect33.Effect.gen(function* () {
|
|
|
2507
3886
|
sinksLayer,
|
|
2508
3887
|
convergeLayer
|
|
2509
3888
|
);
|
|
2510
|
-
const scope = yield*
|
|
2511
|
-
const exit = yield*
|
|
2512
|
-
yield*
|
|
3889
|
+
const scope = yield* import_effect36.Scope.make();
|
|
3890
|
+
const exit = yield* import_effect36.Effect.exit(program).pipe(import_effect36.Effect.provideService(import_effect36.Scope.Scope, scope), import_effect36.Effect.provide(trialLayer));
|
|
3891
|
+
yield* import_effect36.Scope.close(scope, exit);
|
|
2513
3892
|
const evidence = collector.exportEvidencePackage({
|
|
2514
3893
|
maxEvents: options?.maxEvents
|
|
2515
3894
|
});
|
|
@@ -2518,15 +3897,15 @@ var trialRun = (program, options) => import_effect33.Effect.gen(function* () {
|
|
|
2518
3897
|
|
|
2519
3898
|
// src/internal/reflection/kernelContract.ts
|
|
2520
3899
|
var resolveRootImpl = (root) => root?._tag === "ModuleImpl" ? root : root?.impl;
|
|
2521
|
-
var
|
|
2522
|
-
var
|
|
3900
|
+
var asNonEmptyString3 = (value) => typeof value === "string" && value.length > 0 ? value : void 0;
|
|
3901
|
+
var asNonNegInt2 = (value, fallback = 0) => {
|
|
2523
3902
|
if (typeof value !== "number" || !Number.isFinite(value)) return fallback;
|
|
2524
3903
|
const n = Math.floor(value);
|
|
2525
3904
|
return n >= 0 ? n : fallback;
|
|
2526
3905
|
};
|
|
2527
|
-
var
|
|
3906
|
+
var isRecord6 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2528
3907
|
var makeTraceEffectOpObserver = () => {
|
|
2529
|
-
return (op) =>
|
|
3908
|
+
return (op) => import_effect37.Effect.gen(function* () {
|
|
2530
3909
|
if (op.meta?.policy?.disableObservers) {
|
|
2531
3910
|
return yield* op.effect;
|
|
2532
3911
|
}
|
|
@@ -2561,12 +3940,12 @@ var extractRuntimeSummary = (evidence) => {
|
|
|
2561
3940
|
};
|
|
2562
3941
|
};
|
|
2563
3942
|
var canonicalizeOpMeta = (opMetaRaw) => {
|
|
2564
|
-
if (!
|
|
3943
|
+
if (!isRecord6(opMetaRaw)) return void 0;
|
|
2565
3944
|
const out = {};
|
|
2566
3945
|
for (const [k, v] of Object.entries(opMetaRaw)) {
|
|
2567
3946
|
if (k === "instanceId" || k === "txnId" || k === "runtimeLabel" || k === "linkId") continue;
|
|
2568
3947
|
if ((k === "deps" || k === "trace" || k === "tags") && Array.isArray(v) && v.every((x) => typeof x === "string")) {
|
|
2569
|
-
out[k] = v.slice().sort(
|
|
3948
|
+
out[k] = v.slice().sort();
|
|
2570
3949
|
continue;
|
|
2571
3950
|
}
|
|
2572
3951
|
out[k] = v;
|
|
@@ -2589,17 +3968,17 @@ var extractKernelContractTraceOps = (evidence) => {
|
|
|
2589
3968
|
for (const e of evidence.events) {
|
|
2590
3969
|
if (e.type !== "debug:event") continue;
|
|
2591
3970
|
const payload = e.payload;
|
|
2592
|
-
if (!
|
|
3971
|
+
if (!isRecord6(payload)) continue;
|
|
2593
3972
|
const meta = payload.meta;
|
|
2594
3973
|
const opMeta = meta?.meta;
|
|
2595
|
-
const opSeq =
|
|
3974
|
+
const opSeq = asNonNegInt2(opMeta?.opSeq, -1);
|
|
2596
3975
|
if (opSeq < 0) continue;
|
|
2597
|
-
const instanceIdRaw =
|
|
3976
|
+
const instanceIdRaw = asNonEmptyString3(payload.instanceId) ?? "unknown";
|
|
2598
3977
|
const instanceId = mapInstanceId(instanceIdRaw);
|
|
2599
|
-
const txnSeq =
|
|
2600
|
-
const moduleId =
|
|
2601
|
-
const kind =
|
|
2602
|
-
const name =
|
|
3978
|
+
const txnSeq = asNonNegInt2(payload.txnSeq, 0);
|
|
3979
|
+
const moduleId = asNonEmptyString3(payload.moduleId) ?? "unknown";
|
|
3980
|
+
const kind = asNonEmptyString3(meta?.kind) ?? asNonEmptyString3(payload.kind) ?? "unknown";
|
|
3981
|
+
const name = asNonEmptyString3(meta?.name) ?? asNonEmptyString3(payload.label) ?? "effectop";
|
|
2603
3982
|
ops.push({
|
|
2604
3983
|
anchor: { instanceId, txnSeq, opSeq },
|
|
2605
3984
|
moduleId,
|
|
@@ -2609,7 +3988,7 @@ var extractKernelContractTraceOps = (evidence) => {
|
|
|
2609
3988
|
});
|
|
2610
3989
|
}
|
|
2611
3990
|
ops.sort((a, b) => {
|
|
2612
|
-
if (a.anchor.instanceId !== b.anchor.instanceId) return a.anchor.instanceId
|
|
3991
|
+
if (a.anchor.instanceId !== b.anchor.instanceId) return a.anchor.instanceId < b.anchor.instanceId ? -1 : 1;
|
|
2613
3992
|
if (a.anchor.txnSeq !== b.anchor.txnSeq) return a.anchor.txnSeq - b.anchor.txnSeq;
|
|
2614
3993
|
return a.anchor.opSeq - b.anchor.opSeq;
|
|
2615
3994
|
});
|
|
@@ -2626,7 +4005,7 @@ var diffKernelContractTraceOps = (before, after) => {
|
|
|
2626
4005
|
for (const op of after) {
|
|
2627
4006
|
afterByKey.set(anchorKey(op.anchor), op);
|
|
2628
4007
|
}
|
|
2629
|
-
const allKeys = Array.from(/* @__PURE__ */ new Set([...beforeByKey.keys(), ...afterByKey.keys()])).sort(
|
|
4008
|
+
const allKeys = Array.from(/* @__PURE__ */ new Set([...beforeByKey.keys(), ...afterByKey.keys()])).sort();
|
|
2630
4009
|
for (const key of allKeys) {
|
|
2631
4010
|
const b = beforeByKey.get(key);
|
|
2632
4011
|
const a = afterByKey.get(key);
|
|
@@ -2666,20 +4045,20 @@ var diffKernelContractTraceOps = (before, after) => {
|
|
|
2666
4045
|
return { changes, summary };
|
|
2667
4046
|
};
|
|
2668
4047
|
var VERSION = "v1";
|
|
2669
|
-
var runOnce = (rootImpl, run2, options) =>
|
|
4048
|
+
var runOnce = (rootImpl, run2, options) => import_effect37.Effect.gen(function* () {
|
|
2670
4049
|
const interaction = run2?.interaction;
|
|
2671
|
-
const program =
|
|
2672
|
-
const ctx = yield* rootImpl.layer.pipe(
|
|
2673
|
-
const runtime =
|
|
4050
|
+
const program = import_effect37.Effect.gen(function* () {
|
|
4051
|
+
const ctx = yield* rootImpl.layer.pipe(import_effect37.Layer.build);
|
|
4052
|
+
const runtime = import_effect37.Context.get(ctx, rootImpl.module);
|
|
2674
4053
|
if (interaction) {
|
|
2675
4054
|
yield* interaction(runtime);
|
|
2676
4055
|
}
|
|
2677
4056
|
return runtime.instanceId;
|
|
2678
4057
|
});
|
|
2679
|
-
const traceLayer =
|
|
4058
|
+
const traceLayer = import_effect37.Layer.succeed(EffectOpMiddlewareTag, {
|
|
2680
4059
|
stack: [makeTraceEffectOpObserver()]
|
|
2681
4060
|
});
|
|
2682
|
-
const extraLayer = run2?.layer ?
|
|
4061
|
+
const extraLayer = run2?.layer ? import_effect37.Layer.mergeAll(traceLayer, run2.layer) : traceLayer;
|
|
2683
4062
|
const result = yield* trialRun(program, {
|
|
2684
4063
|
runId: run2?.runId,
|
|
2685
4064
|
diagnosticsLevel: options.diagnosticsLevel ?? "light",
|
|
@@ -2687,9 +4066,9 @@ var runOnce = (rootImpl, run2, options) => import_effect34.Effect.gen(function*
|
|
|
2687
4066
|
layer: extraLayer,
|
|
2688
4067
|
runtimeServicesInstanceOverrides: run2?.runtimeServicesInstanceOverrides
|
|
2689
4068
|
});
|
|
2690
|
-
const ok =
|
|
2691
|
-
const error =
|
|
2692
|
-
const failure =
|
|
4069
|
+
const ok = import_effect37.Exit.isSuccess(result.exit);
|
|
4070
|
+
const error = import_effect37.Exit.isFailure(result.exit) && result.exit.cause != null ? (() => {
|
|
4071
|
+
const failure = import_effect37.Exit.isFailure(result.exit) ? result.exit.cause : void 0;
|
|
2693
4072
|
const err = failure?._tag === "Die" ? failure.defect : failure;
|
|
2694
4073
|
if (err instanceof Error) {
|
|
2695
4074
|
return { name: err.name, message: err.message };
|
|
@@ -2710,7 +4089,7 @@ var runOnce = (rootImpl, run2, options) => import_effect34.Effect.gen(function*
|
|
|
2710
4089
|
traceOps
|
|
2711
4090
|
};
|
|
2712
4091
|
});
|
|
2713
|
-
var verifyKernelContract = (root, options) =>
|
|
4092
|
+
var verifyKernelContract = (root, options) => import_effect37.Effect.gen(function* () {
|
|
2714
4093
|
const rootImpl = resolveRootImpl(root);
|
|
2715
4094
|
const beforeRun = yield* runOnce(rootImpl, options?.before, {
|
|
2716
4095
|
diagnosticsLevel: options?.diagnosticsLevel,
|
|
@@ -2734,7 +4113,7 @@ var verifyKernelContract = (root, options) => import_effect34.Effect.gen(functio
|
|
|
2734
4113
|
});
|
|
2735
4114
|
|
|
2736
4115
|
// src/Kernel.ts
|
|
2737
|
-
var
|
|
4116
|
+
var import_effect39 = require("effect");
|
|
2738
4117
|
|
|
2739
4118
|
// src/internal/runtime/core/FullCutoverGate.ts
|
|
2740
4119
|
var CutoverCoverageMatrix = {
|
|
@@ -2753,7 +4132,7 @@ var parseFallbackServiceIds = (overridesApplied) => {
|
|
|
2753
4132
|
const serviceId = entry.slice(colon + 1, eq);
|
|
2754
4133
|
if (serviceId.length > 0) out.add(serviceId);
|
|
2755
4134
|
}
|
|
2756
|
-
return Array.from(out).sort(
|
|
4135
|
+
return Array.from(out).sort();
|
|
2757
4136
|
};
|
|
2758
4137
|
var collectMissingServiceIds = (args) => {
|
|
2759
4138
|
const bindingByServiceId = /* @__PURE__ */ new Map();
|
|
@@ -2809,8 +4188,8 @@ var evaluateFullCutoverGate = (args) => {
|
|
|
2809
4188
|
};
|
|
2810
4189
|
|
|
2811
4190
|
// src/internal/runtime/core/RuntimeServiceBuiltins.ts
|
|
2812
|
-
var
|
|
2813
|
-
var RuntimeServiceBuiltinsTag = class extends
|
|
4191
|
+
var import_effect38 = require("effect");
|
|
4192
|
+
var RuntimeServiceBuiltinsTag = class extends import_effect38.Context.Tag("@logixjs/core/RuntimeServiceBuiltins")() {
|
|
2814
4193
|
};
|
|
2815
4194
|
|
|
2816
4195
|
// src/Kernel.ts
|
|
@@ -2829,12 +4208,12 @@ var getKernelImplementationRef2 = getKernelImplementationRef;
|
|
|
2829
4208
|
|
|
2830
4209
|
// src/Reflection.ts
|
|
2831
4210
|
var resolveRootImpl2 = (root) => root?._tag === "ModuleImpl" ? root : root?.impl;
|
|
2832
|
-
var
|
|
4211
|
+
var isRecord7 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2833
4212
|
var stableJson = (value) => JSON.stringify(value) ?? "";
|
|
2834
4213
|
var diffMetaKeys = (before, after) => {
|
|
2835
|
-
const b =
|
|
2836
|
-
const a =
|
|
2837
|
-
const keys = Array.from(/* @__PURE__ */ new Set([...Object.keys(b), ...Object.keys(a)])).sort(
|
|
4214
|
+
const b = isRecord7(before) ? before : {};
|
|
4215
|
+
const a = isRecord7(after) ? after : {};
|
|
4216
|
+
const keys = Array.from(/* @__PURE__ */ new Set([...Object.keys(b), ...Object.keys(a)])).sort();
|
|
2838
4217
|
const changed = [];
|
|
2839
4218
|
for (const k of keys) {
|
|
2840
4219
|
if (stableJson(b[k]) !== stableJson(a[k])) {
|
|
@@ -2858,7 +4237,7 @@ var tryAllowlistKernelContractDiff = (args) => {
|
|
|
2858
4237
|
}
|
|
2859
4238
|
const before = change.before;
|
|
2860
4239
|
const after = change.after;
|
|
2861
|
-
if (!
|
|
4240
|
+
if (!isRecord7(before) || !isRecord7(after)) {
|
|
2862
4241
|
return { verdict: "FAIL", allowedDiffs: [] };
|
|
2863
4242
|
}
|
|
2864
4243
|
const anchorBefore = before.anchor;
|
|
@@ -2887,14 +4266,15 @@ var tryAllowlistKernelContractDiff = (args) => {
|
|
|
2887
4266
|
metaKey,
|
|
2888
4267
|
count,
|
|
2889
4268
|
...allow.get(metaKey) ? { reason: allow.get(metaKey) } : {}
|
|
2890
|
-
})).sort((a, b) => a.metaKey.
|
|
4269
|
+
})).sort((a, b) => a.metaKey < b.metaKey ? -1 : a.metaKey > b.metaKey ? 1 : 0);
|
|
2891
4270
|
return { verdict: "PASS", allowedDiffs };
|
|
2892
4271
|
};
|
|
2893
4272
|
var extractManifest2 = (module2, options) => extractManifest(module2, options);
|
|
2894
4273
|
var diffManifest2 = (before, after, options) => diffManifest(before, after, options);
|
|
2895
4274
|
var exportStaticIr3 = (module2) => exportStaticIr2(module2);
|
|
4275
|
+
var exportControlSurface2 = (modules, options) => exportControlSurface(modules, options);
|
|
2896
4276
|
var verifyKernelContract2 = (module2, options) => verifyKernelContract(module2, options);
|
|
2897
|
-
var verifyFullCutoverGate = (module2, options) =>
|
|
4277
|
+
var verifyFullCutoverGate = (module2, options) => import_effect40.Effect.gen(function* () {
|
|
2898
4278
|
const rootImpl = resolveRootImpl2(module2);
|
|
2899
4279
|
const contractDiagnosticsLevel = options?.diagnosticsLevel === "off" ? "light" : options?.diagnosticsLevel ?? "light";
|
|
2900
4280
|
const contract = yield* verifyKernelContract(module2, {
|
|
@@ -2906,9 +4286,9 @@ var verifyFullCutoverGate = (module2, options) => import_effect37.Effect.gen(fun
|
|
|
2906
4286
|
const contractAllowed = tryAllowlistKernelContractDiff({ result: contract, allowlist });
|
|
2907
4287
|
const contractVerdict = allowlistEnabled ? contractAllowed.verdict : contract.verdict;
|
|
2908
4288
|
const gateRun = options?.gateAfter ?? options?.after;
|
|
2909
|
-
const gateProgram =
|
|
2910
|
-
const ctx = yield* rootImpl.layer.pipe(
|
|
2911
|
-
const runtime =
|
|
4289
|
+
const gateProgram = import_effect40.Effect.gen(function* () {
|
|
4290
|
+
const ctx = yield* rootImpl.layer.pipe(import_effect40.Layer.build);
|
|
4291
|
+
const runtime = import_effect40.Context.get(ctx, rootImpl.module);
|
|
2912
4292
|
if (gateRun?.interaction) {
|
|
2913
4293
|
yield* gateRun.interaction(runtime);
|
|
2914
4294
|
}
|
|
@@ -2923,8 +4303,8 @@ var verifyFullCutoverGate = (module2, options) => import_effect37.Effect.gen(fun
|
|
|
2923
4303
|
layer: gateRun?.layer,
|
|
2924
4304
|
runtimeServicesInstanceOverrides: gateRun?.runtimeServicesInstanceOverrides
|
|
2925
4305
|
});
|
|
2926
|
-
const gateValue =
|
|
2927
|
-
const msg =
|
|
4306
|
+
const gateValue = import_effect40.Exit.isSuccess(gateResult.exit) ? gateResult.exit.value : (() => {
|
|
4307
|
+
const msg = import_effect40.Exit.isFailure(gateResult.exit) ? String(gateResult.exit.cause ?? "trial-run failed") : "trial-run failed";
|
|
2928
4308
|
throw new Error(msg);
|
|
2929
4309
|
})();
|
|
2930
4310
|
const gate = evaluateFullCutoverGate2({
|
|
@@ -2946,6 +4326,7 @@ var verifyFullCutoverGate = (module2, options) => import_effect37.Effect.gen(fun
|
|
|
2946
4326
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2947
4327
|
0 && (module.exports = {
|
|
2948
4328
|
diffManifest,
|
|
4329
|
+
exportControlSurface,
|
|
2949
4330
|
exportStaticIr,
|
|
2950
4331
|
extractManifest,
|
|
2951
4332
|
verifyFullCutoverGate,
|