@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
|
@@ -1,21 +1,28 @@
|
|
|
1
1
|
import {
|
|
2
2
|
build,
|
|
3
3
|
diffDeps,
|
|
4
|
+
emitDepsMismatch,
|
|
5
|
+
emitSchemaMismatch,
|
|
6
|
+
onceInRunSession,
|
|
4
7
|
syncIdleInTransaction,
|
|
5
8
|
trace
|
|
6
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-JBKYRTCS.js";
|
|
7
10
|
import {
|
|
8
11
|
RowIdStore,
|
|
9
12
|
collectListConfigs
|
|
10
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-KSZQYSEH.js";
|
|
11
14
|
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
} from "./chunk-
|
|
15
|
+
currentTxnOriginOverride,
|
|
16
|
+
getLogicUnitMeta
|
|
17
|
+
} from "./chunk-Y4VRBIS6.js";
|
|
15
18
|
import {
|
|
16
19
|
EvidenceCollectorTag,
|
|
17
20
|
ProcessRuntimeTag
|
|
18
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-G7ESIQTI.js";
|
|
22
|
+
import {
|
|
23
|
+
RuntimeServiceBuiltinsTag,
|
|
24
|
+
evaluateFullCutoverGate
|
|
25
|
+
} from "./chunk-5W2V2NVJ.js";
|
|
19
26
|
import {
|
|
20
27
|
FullCutoverGateModeTag,
|
|
21
28
|
RuntimeServicesRegistryTag,
|
|
@@ -25,7 +32,7 @@ import {
|
|
|
25
32
|
selectRuntimeService,
|
|
26
33
|
setKernelImplementationRef,
|
|
27
34
|
setRuntimeServicesEvidence
|
|
28
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-EB4RGQO3.js";
|
|
29
36
|
import {
|
|
30
37
|
LifecycleContext,
|
|
31
38
|
LogicPhaseServiceTag,
|
|
@@ -33,44 +40,47 @@ import {
|
|
|
33
40
|
emitEnvServiceNotFoundDiagnosticIfNeeded,
|
|
34
41
|
emitInvalidPhaseDiagnosticIfNeeded,
|
|
35
42
|
makeLifecycleManager
|
|
36
|
-
} from "./chunk-
|
|
37
|
-
import {
|
|
38
|
-
enterSyncTransaction,
|
|
39
|
-
exitSyncTransaction,
|
|
40
|
-
inSyncTransactionFiber
|
|
41
|
-
} from "./chunk-ZFLHVFUC.js";
|
|
43
|
+
} from "./chunk-34CF6OGE.js";
|
|
42
44
|
import {
|
|
43
45
|
Tag
|
|
44
46
|
} from "./chunk-KL5ACTCT.js";
|
|
45
47
|
import {
|
|
46
48
|
RootContextTag
|
|
47
|
-
} from "./chunk-
|
|
49
|
+
} from "./chunk-3VZYDNXZ.js";
|
|
48
50
|
import {
|
|
49
51
|
currentConvergeStaticIrCollectors
|
|
50
52
|
} from "./chunk-M3BFQ7HK.js";
|
|
51
53
|
import {
|
|
54
|
+
compareFieldPath,
|
|
52
55
|
dirtyPathsToRootIds,
|
|
53
56
|
getFieldPathId,
|
|
54
57
|
isPrefixOf,
|
|
55
58
|
normalizeFieldPath,
|
|
56
59
|
normalizePatchReason
|
|
57
|
-
} from "./chunk-
|
|
60
|
+
} from "./chunk-ZTFTABXV.js";
|
|
58
61
|
import {
|
|
59
62
|
setRuntimeInternals
|
|
60
|
-
} from "./chunk-
|
|
63
|
+
} from "./chunk-KLDVG3SY.js";
|
|
61
64
|
import {
|
|
62
65
|
ConcurrencyPolicyOverridesTag,
|
|
63
66
|
ConcurrencyPolicyTag,
|
|
64
67
|
ReadQueryStrictGateConfigTag,
|
|
68
|
+
RuntimeStoreTag,
|
|
65
69
|
StateTransactionConfigTag,
|
|
66
70
|
StateTransactionOverridesTag,
|
|
71
|
+
TickSchedulerTag,
|
|
72
|
+
enterSyncTransaction,
|
|
73
|
+
exitSyncTransaction,
|
|
67
74
|
getDefaultStateTxnInstrumentation,
|
|
68
|
-
|
|
69
|
-
|
|
75
|
+
inSyncTransactionFiber,
|
|
76
|
+
isDevEnv,
|
|
77
|
+
makeModuleInstanceKey
|
|
78
|
+
} from "./chunk-AQ7L2QZ5.js";
|
|
70
79
|
import {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
80
|
+
RunSessionTag,
|
|
81
|
+
make,
|
|
82
|
+
run
|
|
83
|
+
} from "./chunk-I4LCE5OY.js";
|
|
74
84
|
import {
|
|
75
85
|
currentDebugSinks,
|
|
76
86
|
currentDiagnosticsLevel,
|
|
@@ -81,20 +91,19 @@ import {
|
|
|
81
91
|
isErrorOnlyOnlySinks,
|
|
82
92
|
record,
|
|
83
93
|
toSerializableErrorSummary
|
|
84
|
-
} from "./chunk-
|
|
85
|
-
import {
|
|
86
|
-
fnv1a32,
|
|
87
|
-
stableStringify
|
|
88
|
-
} from "./chunk-GMPEOUP2.js";
|
|
89
|
-
import {
|
|
90
|
-
RunSessionTag,
|
|
91
|
-
make,
|
|
92
|
-
run
|
|
93
|
-
} from "./chunk-OFADUJWJ.js";
|
|
94
|
+
} from "./chunk-ZC7MSQ5U.js";
|
|
94
95
|
import {
|
|
95
96
|
EffectOpMiddlewareTag,
|
|
96
97
|
currentLinkId
|
|
97
|
-
} from "./chunk-
|
|
98
|
+
} from "./chunk-WYJUJV4L.js";
|
|
99
|
+
import {
|
|
100
|
+
compile,
|
|
101
|
+
evaluateStrictGate
|
|
102
|
+
} from "./chunk-M3M7JFAH.js";
|
|
103
|
+
import {
|
|
104
|
+
fnv1a32,
|
|
105
|
+
stableStringify
|
|
106
|
+
} from "./chunk-4MZ7BT3R.js";
|
|
98
107
|
|
|
99
108
|
// src/internal/runtime/core/ModuleRuntime.registry.ts
|
|
100
109
|
var runtimeRegistry = /* @__PURE__ */ new WeakMap();
|
|
@@ -113,39 +122,15 @@ var unregisterRuntimeByInstanceKey = (instanceKey) => {
|
|
|
113
122
|
runtimeByInstanceKey.delete(instanceKey);
|
|
114
123
|
};
|
|
115
124
|
|
|
116
|
-
// src/internal/runtime/core/
|
|
117
|
-
var LOGIC_UNIT_META = /* @__PURE__ */ Symbol.for("logix.module.logic.meta");
|
|
118
|
-
var getLogicUnitMeta = (logic) => {
|
|
119
|
-
if (!logic || typeof logic !== "object" && typeof logic !== "function") {
|
|
120
|
-
return void 0;
|
|
121
|
-
}
|
|
122
|
-
return logic[LOGIC_UNIT_META];
|
|
123
|
-
};
|
|
124
|
-
var attachLogicUnitMeta = (logic, meta) => {
|
|
125
|
-
try {
|
|
126
|
-
Object.defineProperty(logic, LOGIC_UNIT_META, {
|
|
127
|
-
value: meta,
|
|
128
|
-
enumerable: false,
|
|
129
|
-
configurable: true
|
|
130
|
-
});
|
|
131
|
-
} catch {
|
|
132
|
-
}
|
|
133
|
-
return logic;
|
|
134
|
-
};
|
|
135
|
-
var updateLogicUnitMeta = (logic, patch) => {
|
|
136
|
-
const prev = getLogicUnitMeta(logic);
|
|
137
|
-
return attachLogicUnitMeta(logic, { ...prev ?? {}, ...patch });
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
// src/internal/runtime/core/ModuleRuntime.ts
|
|
125
|
+
// src/internal/runtime/core/ModuleRuntime.impl.ts
|
|
141
126
|
import {
|
|
142
|
-
Effect as
|
|
127
|
+
Effect as Effect20,
|
|
143
128
|
Stream as Stream2,
|
|
144
129
|
SubscriptionRef as SubscriptionRef3,
|
|
145
130
|
PubSub as PubSub4,
|
|
146
131
|
Context as Context2,
|
|
147
132
|
FiberRef as FiberRef8,
|
|
148
|
-
Option as
|
|
133
|
+
Option as Option9,
|
|
149
134
|
Queue as Queue3,
|
|
150
135
|
Duration,
|
|
151
136
|
Chunk as Chunk3
|
|
@@ -426,7 +411,7 @@ var makeRunOperation = (args) => {
|
|
|
426
411
|
};
|
|
427
412
|
|
|
428
413
|
// src/internal/runtime/core/ModuleRuntime.dispatch.ts
|
|
429
|
-
import { Effect as Effect4, PubSub } from "effect";
|
|
414
|
+
import { Effect as Effect4, FiberRef as FiberRef2, PubSub } from "effect";
|
|
430
415
|
|
|
431
416
|
// src/internal/runtime/core/ReducerDiagnostics.ts
|
|
432
417
|
import { Cause, Chunk, Effect as Effect3 } from "effect";
|
|
@@ -597,9 +582,9 @@ var makeDispatchOps = (args) => {
|
|
|
597
582
|
)
|
|
598
583
|
);
|
|
599
584
|
};
|
|
600
|
-
const makeActionOrigin = (originName, action) => ({
|
|
601
|
-
kind: "action",
|
|
602
|
-
name: originName,
|
|
585
|
+
const makeActionOrigin = (originName, action, override) => ({
|
|
586
|
+
kind: override?.kind ?? "action",
|
|
587
|
+
name: override?.name ?? originName,
|
|
603
588
|
details: {
|
|
604
589
|
_tag: resolveActionTag2(action) ?? "unknown",
|
|
605
590
|
path: typeof action?.payload?.path === "string" ? action.payload.path : void 0,
|
|
@@ -642,16 +627,16 @@ var makeDispatchOps = (args) => {
|
|
|
642
627
|
yield* PubSub.publish(actionCommitHub, { value: action, meta });
|
|
643
628
|
}
|
|
644
629
|
});
|
|
645
|
-
const runDispatch = (action) => runOperation(
|
|
630
|
+
const runDispatch = (action, override) => runOperation(
|
|
646
631
|
"action",
|
|
647
632
|
"action:dispatch",
|
|
648
633
|
{
|
|
649
634
|
payload: action,
|
|
650
635
|
meta: { moduleId: optionsModuleId, instanceId }
|
|
651
636
|
},
|
|
652
|
-
runWithStateTransaction(makeActionOrigin("dispatch", action), () => dispatchInTransaction(action))
|
|
637
|
+
runWithStateTransaction(makeActionOrigin("dispatch", action, override), () => dispatchInTransaction(action))
|
|
653
638
|
).pipe(Effect4.asVoid);
|
|
654
|
-
const runDispatchLowPriority = (action) => runOperation(
|
|
639
|
+
const runDispatchLowPriority = (action, override) => runOperation(
|
|
655
640
|
"action",
|
|
656
641
|
"action:dispatchLowPriority",
|
|
657
642
|
{
|
|
@@ -659,7 +644,7 @@ var makeDispatchOps = (args) => {
|
|
|
659
644
|
meta: { moduleId: optionsModuleId, instanceId }
|
|
660
645
|
},
|
|
661
646
|
runWithStateTransaction(
|
|
662
|
-
makeActionOrigin("dispatchLowPriority", action),
|
|
647
|
+
makeActionOrigin("dispatchLowPriority", action, override),
|
|
663
648
|
() => Effect4.gen(function* () {
|
|
664
649
|
if (txnContext.current) {
|
|
665
650
|
;
|
|
@@ -670,7 +655,7 @@ var makeDispatchOps = (args) => {
|
|
|
670
655
|
})
|
|
671
656
|
)
|
|
672
657
|
).pipe(Effect4.asVoid);
|
|
673
|
-
const runDispatchBatch = (actions) => {
|
|
658
|
+
const runDispatchBatch = (actions, override) => {
|
|
674
659
|
if (actions.length === 0) return Effect4.void;
|
|
675
660
|
return runOperation(
|
|
676
661
|
"action",
|
|
@@ -680,7 +665,7 @@ var makeDispatchOps = (args) => {
|
|
|
680
665
|
meta: { moduleId: optionsModuleId, instanceId }
|
|
681
666
|
},
|
|
682
667
|
runWithStateTransaction(
|
|
683
|
-
{ kind: "action", name: "dispatchBatch", details: { count: actions.length } },
|
|
668
|
+
{ kind: override?.kind ?? "action", name: override?.name ?? "dispatchBatch", details: { count: actions.length } },
|
|
684
669
|
() => Effect4.gen(function* () {
|
|
685
670
|
if (txnContext.current) {
|
|
686
671
|
;
|
|
@@ -712,14 +697,26 @@ var makeDispatchOps = (args) => {
|
|
|
712
697
|
registerReducer,
|
|
713
698
|
// Note: publish is a lossless/backpressure channel and may wait.
|
|
714
699
|
// Must run outside the transaction window (FR-012) and must not block the txnQueue consumer fiber (avoid deadlock).
|
|
715
|
-
dispatch: (action) =>
|
|
716
|
-
Effect4.
|
|
700
|
+
dispatch: (action) => FiberRef2.get(currentTxnOriginOverride).pipe(
|
|
701
|
+
Effect4.flatMap(
|
|
702
|
+
(override) => enqueueTransaction(runDispatch(action, override)).pipe(
|
|
703
|
+
Effect4.zipRight(publishWithPressureDiagnostics("publish", PubSub.publish(actionHub, action)))
|
|
704
|
+
)
|
|
705
|
+
)
|
|
717
706
|
),
|
|
718
|
-
dispatchBatch: (actions) =>
|
|
719
|
-
Effect4.
|
|
707
|
+
dispatchBatch: (actions) => FiberRef2.get(currentTxnOriginOverride).pipe(
|
|
708
|
+
Effect4.flatMap(
|
|
709
|
+
(override) => enqueueTransaction(runDispatchBatch(actions, override)).pipe(
|
|
710
|
+
Effect4.zipRight(publishWithPressureDiagnostics("publishAll", PubSub.publishAll(actionHub, actions)))
|
|
711
|
+
)
|
|
712
|
+
)
|
|
720
713
|
),
|
|
721
|
-
dispatchLowPriority: (action) =>
|
|
722
|
-
Effect4.
|
|
714
|
+
dispatchLowPriority: (action) => FiberRef2.get(currentTxnOriginOverride).pipe(
|
|
715
|
+
Effect4.flatMap(
|
|
716
|
+
(override) => enqueueTransaction(runDispatchLowPriority(action, override)).pipe(
|
|
717
|
+
Effect4.zipRight(publishWithPressureDiagnostics("publish", PubSub.publish(actionHub, action)))
|
|
718
|
+
)
|
|
719
|
+
)
|
|
723
720
|
)
|
|
724
721
|
};
|
|
725
722
|
};
|
|
@@ -895,7 +892,7 @@ var makeEffectsRegistry = (args) => {
|
|
|
895
892
|
};
|
|
896
893
|
|
|
897
894
|
// src/internal/runtime/core/ModuleRuntime.transaction.ts
|
|
898
|
-
import { Cause as Cause2, Effect as
|
|
895
|
+
import { Cause as Cause2, Effect as Effect10, Exit, Fiber, FiberRef as FiberRef6, Option as Option3, PubSub as PubSub2, Queue, SubscriptionRef as SubscriptionRef2 } from "effect";
|
|
899
896
|
|
|
900
897
|
// src/internal/state-trait/plan-cache.ts
|
|
901
898
|
var rootIdsEquals = (a, b) => {
|
|
@@ -1062,8 +1059,8 @@ var StateTraitConfigError = class extends Error {
|
|
|
1062
1059
|
}
|
|
1063
1060
|
};
|
|
1064
1061
|
|
|
1065
|
-
// src/internal/state-trait/converge-in-transaction.ts
|
|
1066
|
-
import { Effect as
|
|
1062
|
+
// src/internal/state-trait/converge-in-transaction.impl.ts
|
|
1063
|
+
import { Effect as Effect8, FiberRef as FiberRef4 } from "effect";
|
|
1067
1064
|
|
|
1068
1065
|
// src/internal/state-trait/converge-ir.ts
|
|
1069
1066
|
var getConvergeStaticIrDigest = (ir) => {
|
|
@@ -1204,161 +1201,8 @@ var ShallowInPlaceDraft = class {
|
|
|
1204
1201
|
}
|
|
1205
1202
|
};
|
|
1206
1203
|
|
|
1207
|
-
// src/internal/state-trait/converge-diagnostics.ts
|
|
1208
|
-
import { Effect as Effect6, FiberRef as FiberRef2, Option as Option2 } from "effect";
|
|
1209
|
-
import * as SchemaAST from "effect/SchemaAST";
|
|
1210
|
-
var onceKeysFallback = /* @__PURE__ */ new Set();
|
|
1211
|
-
var onceInRunSession = (key) => Effect6.serviceOption(RunSessionTag).pipe(
|
|
1212
|
-
Effect6.map((maybe) => {
|
|
1213
|
-
if (Option2.isSome(maybe)) {
|
|
1214
|
-
return maybe.value.local.once(key);
|
|
1215
|
-
}
|
|
1216
|
-
if (onceKeysFallback.has(key)) return false;
|
|
1217
|
-
onceKeysFallback.add(key);
|
|
1218
|
-
return true;
|
|
1219
|
-
})
|
|
1220
|
-
);
|
|
1221
|
-
var formatList = (items, limit = 10) => {
|
|
1222
|
-
if (items.length === 0) return "";
|
|
1223
|
-
if (items.length <= limit) return items.join(", ");
|
|
1224
|
-
return `${items.slice(0, limit).join(", ")}, \u2026(+${items.length - limit})`;
|
|
1225
|
-
};
|
|
1226
|
-
var emitDepsMismatch = (params) => {
|
|
1227
|
-
return Effect6.gen(function* () {
|
|
1228
|
-
const key = `${params.moduleId ?? "unknown"}::${params.instanceId ?? "unknown"}::${params.kind}::${params.fieldPath}`;
|
|
1229
|
-
const shouldEmit = yield* onceInRunSession(`deps_mismatch:${key}`);
|
|
1230
|
-
if (!shouldEmit) return;
|
|
1231
|
-
yield* record({
|
|
1232
|
-
type: "diagnostic",
|
|
1233
|
-
moduleId: params.moduleId,
|
|
1234
|
-
instanceId: params.instanceId,
|
|
1235
|
-
code: "state_trait::deps_mismatch",
|
|
1236
|
-
severity: "warning",
|
|
1237
|
-
message: `[deps] ${params.kind} "${params.fieldPath}" declared=[${formatList(params.diff.declared)}] reads=[${formatList(params.diff.reads)}] missing=[${formatList(params.diff.missing)}] unused=[${formatList(params.diff.unused)}]`,
|
|
1238
|
-
hint: 'deps is the single source of truth for dependencies: incremental scheduling / reverse closures / performance optimizations rely on deps only. Keep deps consistent with actual reads; if you really depend on the whole object, declare a coarser-grained dep (e.g. "profile") to cover sub-field reads.',
|
|
1239
|
-
kind: `deps_mismatch:${params.kind}`
|
|
1240
|
-
});
|
|
1241
|
-
});
|
|
1242
|
-
};
|
|
1243
|
-
var schemaHasPath = (ast, segments, seen = /* @__PURE__ */ new Set()) => {
|
|
1244
|
-
if (segments.length === 0) return true;
|
|
1245
|
-
let current = ast;
|
|
1246
|
-
while (true) {
|
|
1247
|
-
if (SchemaAST.isSuspend(current)) {
|
|
1248
|
-
if (seen.has(current)) {
|
|
1249
|
-
return true;
|
|
1250
|
-
}
|
|
1251
|
-
seen.add(current);
|
|
1252
|
-
current = current.f();
|
|
1253
|
-
continue;
|
|
1254
|
-
}
|
|
1255
|
-
if (SchemaAST.isRefinement(current)) {
|
|
1256
|
-
current = current.from;
|
|
1257
|
-
continue;
|
|
1258
|
-
}
|
|
1259
|
-
break;
|
|
1260
|
-
}
|
|
1261
|
-
if (SchemaAST.isTransformation(current)) {
|
|
1262
|
-
return schemaHasPath(current.to, segments, seen) || schemaHasPath(current.from, segments, seen);
|
|
1263
|
-
}
|
|
1264
|
-
if (SchemaAST.isUnion(current)) {
|
|
1265
|
-
return current.types.some((t) => schemaHasPath(t, segments, seen));
|
|
1266
|
-
}
|
|
1267
|
-
if (SchemaAST.isTupleType(current)) {
|
|
1268
|
-
const candidates = [];
|
|
1269
|
-
for (const e of current.elements) candidates.push(e.type);
|
|
1270
|
-
for (const r of current.rest) candidates.push(r.type);
|
|
1271
|
-
if (candidates.length === 0) return true;
|
|
1272
|
-
return candidates.some((t) => schemaHasPath(t, segments, seen));
|
|
1273
|
-
}
|
|
1274
|
-
if (SchemaAST.isTypeLiteral(current)) {
|
|
1275
|
-
const [head, ...tail] = segments;
|
|
1276
|
-
for (const ps of current.propertySignatures) {
|
|
1277
|
-
if (String(ps.name) !== head) continue;
|
|
1278
|
-
return schemaHasPath(ps.type, tail, seen);
|
|
1279
|
-
}
|
|
1280
|
-
for (const sig of current.indexSignatures) {
|
|
1281
|
-
let param = sig.parameter;
|
|
1282
|
-
while (SchemaAST.isRefinement(param)) {
|
|
1283
|
-
param = param.from;
|
|
1284
|
-
}
|
|
1285
|
-
const tag2 = param?._tag;
|
|
1286
|
-
if (tag2 === "StringKeyword" || tag2 === "TemplateLiteral") {
|
|
1287
|
-
return schemaHasPath(sig.type, tail, seen);
|
|
1288
|
-
}
|
|
1289
|
-
}
|
|
1290
|
-
return false;
|
|
1291
|
-
}
|
|
1292
|
-
const tag = current?._tag;
|
|
1293
|
-
if (tag === "AnyKeyword" || tag === "UnknownKeyword" || tag === "ObjectKeyword" || tag === "Declaration") {
|
|
1294
|
-
return true;
|
|
1295
|
-
}
|
|
1296
|
-
return false;
|
|
1297
|
-
};
|
|
1298
|
-
var schemaHasFieldPath = (stateSchemaAst, path) => {
|
|
1299
|
-
if (!path) return true;
|
|
1300
|
-
if (path === "$root") return true;
|
|
1301
|
-
const normalized = normalizeFieldPath(path);
|
|
1302
|
-
if (!normalized) return false;
|
|
1303
|
-
const segs = normalized[0] === "$root" ? normalized.slice(1) : normalized;
|
|
1304
|
-
return schemaHasPath(stateSchemaAst, segs);
|
|
1305
|
-
};
|
|
1306
|
-
var formatSchemaMismatchLine = (ref) => {
|
|
1307
|
-
if (ref.kind === "fieldPath") {
|
|
1308
|
-
return `- ${ref.entryKind} "${ref.entryFieldPath}" fieldPath="${ref.path}"`;
|
|
1309
|
-
}
|
|
1310
|
-
if (ref.kind === "dep") {
|
|
1311
|
-
const rule = ref.ruleName ? ` rule="${ref.ruleName}"` : "";
|
|
1312
|
-
return `- ${ref.entryKind} "${ref.entryFieldPath}" deps="${ref.path}"${rule}`;
|
|
1313
|
-
}
|
|
1314
|
-
if (ref.kind === "link_from") {
|
|
1315
|
-
return `- link "${ref.entryFieldPath}" from="${ref.path}"`;
|
|
1316
|
-
}
|
|
1317
|
-
if (ref.kind === "check_writeback") {
|
|
1318
|
-
return `- check "${ref.entryFieldPath}" writeback="${ref.path}"`;
|
|
1319
|
-
}
|
|
1320
|
-
return `- ${ref.entryKind} "${ref.entryFieldPath}" path="${ref.path}"`;
|
|
1321
|
-
};
|
|
1322
|
-
var emitSchemaMismatch = (program, ctx) => Effect6.gen(function* () {
|
|
1323
|
-
if (!isDevEnv()) return;
|
|
1324
|
-
const level = yield* FiberRef2.get(currentDiagnosticsLevel);
|
|
1325
|
-
if (level === "off") return;
|
|
1326
|
-
const key = `${ctx.moduleId ?? "unknown"}::${ctx.instanceId}`;
|
|
1327
|
-
const shouldEmit = yield* onceInRunSession(`schema_mismatch:${key}`);
|
|
1328
|
-
if (!shouldEmit) return;
|
|
1329
|
-
const refs = program.schemaPaths ?? [];
|
|
1330
|
-
if (refs.length === 0) return;
|
|
1331
|
-
const stateSchemaAst = program.stateSchema.ast;
|
|
1332
|
-
const mismatches = [];
|
|
1333
|
-
const seen = /* @__PURE__ */ new Set();
|
|
1334
|
-
for (const ref of refs) {
|
|
1335
|
-
if (schemaHasFieldPath(stateSchemaAst, ref.path)) continue;
|
|
1336
|
-
const k = `${ref.kind}|${ref.entryKind}|${ref.entryFieldPath}|${ref.ruleName ?? ""}|${ref.path}`;
|
|
1337
|
-
if (seen.has(k)) continue;
|
|
1338
|
-
seen.add(k);
|
|
1339
|
-
mismatches.push(ref);
|
|
1340
|
-
}
|
|
1341
|
-
if (mismatches.length === 0) return;
|
|
1342
|
-
const limit = level === "light" ? 8 : 24;
|
|
1343
|
-
const lines = mismatches.slice(0, limit).map(formatSchemaMismatchLine);
|
|
1344
|
-
if (mismatches.length > limit) {
|
|
1345
|
-
lines.push(`- \u2026(+${mismatches.length - limit})`);
|
|
1346
|
-
}
|
|
1347
|
-
yield* record({
|
|
1348
|
-
type: "diagnostic",
|
|
1349
|
-
moduleId: ctx.moduleId,
|
|
1350
|
-
instanceId: ctx.instanceId,
|
|
1351
|
-
code: "state_trait::schema_mismatch",
|
|
1352
|
-
severity: "warning",
|
|
1353
|
-
message: `[schema] The following paths are not declared in stateSchema (total ${mismatches.length}):
|
|
1354
|
-
${lines.join("\n")}`,
|
|
1355
|
-
hint: "StateTrait writeback will create missing objects/fields. Declare all fieldPath/deps/link.from and errors.* writeback paths in stateSchema, or fix typos in trait paths.",
|
|
1356
|
-
kind: "schema_mismatch"
|
|
1357
|
-
});
|
|
1358
|
-
});
|
|
1359
|
-
|
|
1360
1204
|
// src/internal/state-trait/exec-vm-mode.ts
|
|
1361
|
-
import { Effect as
|
|
1205
|
+
import { Effect as Effect6, FiberRef as FiberRef3, Layer } from "effect";
|
|
1362
1206
|
var currentExecVmMode = FiberRef3.unsafeMake(false);
|
|
1363
1207
|
var execVmModeLayer = (enabled) => Layer.fiberRefLocallyScopedWith(currentExecVmMode, () => enabled);
|
|
1364
1208
|
|
|
@@ -1594,9 +1438,9 @@ var makeConvergeExecIr = (ir) => {
|
|
|
1594
1438
|
};
|
|
1595
1439
|
|
|
1596
1440
|
// src/internal/state-trait/converge-step.ts
|
|
1597
|
-
import { Effect as
|
|
1598
|
-
var getMiddlewareStack2 = () =>
|
|
1599
|
-
|
|
1441
|
+
import { Effect as Effect7, Option as Option2 } from "effect";
|
|
1442
|
+
var getMiddlewareStack2 = () => Effect7.serviceOption(EffectOpMiddlewareTag).pipe(
|
|
1443
|
+
Effect7.map((maybe) => Option2.isSome(maybe) ? maybe.value.stack : [])
|
|
1600
1444
|
);
|
|
1601
1445
|
var getWriterKind = (entry) => entry.kind === "computed" ? "computed" : entry.kind === "link" ? "link" : void 0;
|
|
1602
1446
|
var getWriterDeps = (entry) => {
|
|
@@ -1648,7 +1492,7 @@ var runWriterStep = (ctx, execIr, draft, stepId, entry, shouldCollectDecision, d
|
|
|
1648
1492
|
const instanceId = ctx.instanceId;
|
|
1649
1493
|
const fieldPath = entry.fieldPath;
|
|
1650
1494
|
const kind = getWriterKind(entry);
|
|
1651
|
-
if (!kind) return
|
|
1495
|
+
if (!kind) return Effect7.succeed(false);
|
|
1652
1496
|
const reason = kind === "computed" ? "trait-computed" : "trait-link";
|
|
1653
1497
|
const opKind = kind === "computed" ? "trait-computed" : "trait-link";
|
|
1654
1498
|
const opName = kind === "computed" ? "computed:update" : "link:propagate";
|
|
@@ -1658,14 +1502,14 @@ var runWriterStep = (ctx, execIr, draft, stepId, entry, shouldCollectDecision, d
|
|
|
1658
1502
|
const outPath = execIr.fieldPathsById[outPathId];
|
|
1659
1503
|
const fromPathId = execIr.stepFromFieldPathIdByStepId[stepId];
|
|
1660
1504
|
const fromPath = fromPathId >= 0 ? execIr.fieldPathsById[fromPathId] : void 0;
|
|
1661
|
-
return
|
|
1505
|
+
return Effect7.gen(function* () {
|
|
1662
1506
|
const stepLabel = diagnosticsLevel === "off" ? void 0 : execIr.stepLabelByStepId[stepId] ?? String(stepId);
|
|
1663
1507
|
let shouldTraceDeps = false;
|
|
1664
1508
|
if (kind === "computed" && shouldCollectDecision && isDevEnv()) {
|
|
1665
1509
|
const traceKey = `${moduleId ?? "unknown"}::${instanceId ?? "unknown"}::computed::${fieldPath}`;
|
|
1666
1510
|
shouldTraceDeps = yield* onceInRunSession(`deps_trace:settled:${traceKey}`);
|
|
1667
1511
|
}
|
|
1668
|
-
const body =
|
|
1512
|
+
const body = Effect7.sync(() => {
|
|
1669
1513
|
const current = draft.getRoot();
|
|
1670
1514
|
const prev = draft.getAt(outPath);
|
|
1671
1515
|
let next;
|
|
@@ -1694,14 +1538,14 @@ var runWriterStep = (ctx, execIr, draft, stepId, entry, shouldCollectDecision, d
|
|
|
1694
1538
|
ctx.recordPatch(outPathId, reason, prev, next, void 0, stepId);
|
|
1695
1539
|
return { changed: true, depsDiff };
|
|
1696
1540
|
}).pipe(
|
|
1697
|
-
|
|
1541
|
+
Effect7.flatMap(
|
|
1698
1542
|
({ changed, depsDiff }) => depsDiff && kind === "computed" ? emitDepsMismatch({
|
|
1699
1543
|
moduleId,
|
|
1700
1544
|
instanceId,
|
|
1701
1545
|
kind: "computed",
|
|
1702
1546
|
fieldPath,
|
|
1703
1547
|
diff: depsDiff
|
|
1704
|
-
}).pipe(
|
|
1548
|
+
}).pipe(Effect7.as(changed)) : Effect7.succeed(changed)
|
|
1705
1549
|
)
|
|
1706
1550
|
);
|
|
1707
1551
|
const meta = {
|
|
@@ -1718,8 +1562,8 @@ var runWriterStep = (ctx, execIr, draft, stepId, entry, shouldCollectDecision, d
|
|
|
1718
1562
|
...stepLabel ? { stepId: stepLabel } : null
|
|
1719
1563
|
};
|
|
1720
1564
|
if (!(typeof meta.opSeq === "number" && Number.isFinite(meta.opSeq))) {
|
|
1721
|
-
const sessionOpt = yield*
|
|
1722
|
-
if (
|
|
1565
|
+
const sessionOpt = yield* Effect7.serviceOption(RunSessionTag);
|
|
1566
|
+
if (Option2.isSome(sessionOpt)) {
|
|
1723
1567
|
const key = instanceId ?? "global";
|
|
1724
1568
|
meta.opSeq = sessionOpt.value.local.nextSeq("opSeq", key);
|
|
1725
1569
|
}
|
|
@@ -1737,7 +1581,7 @@ var runWriterStep = (ctx, execIr, draft, stepId, entry, shouldCollectDecision, d
|
|
|
1737
1581
|
});
|
|
1738
1582
|
};
|
|
1739
1583
|
|
|
1740
|
-
// src/internal/state-trait/converge-in-transaction.ts
|
|
1584
|
+
// src/internal/state-trait/converge-in-transaction.impl.ts
|
|
1741
1585
|
var pickTop3Steps = (steps) => {
|
|
1742
1586
|
let first;
|
|
1743
1587
|
let second;
|
|
@@ -1784,7 +1628,7 @@ var insertTopKHotspot = (args) => {
|
|
|
1784
1628
|
hotspots.length = topK;
|
|
1785
1629
|
}
|
|
1786
1630
|
};
|
|
1787
|
-
var convergeInTransaction = (program, ctx) =>
|
|
1631
|
+
var convergeInTransaction = (program, ctx) => Effect8.gen(function* () {
|
|
1788
1632
|
yield* emitSchemaMismatch(program, ctx);
|
|
1789
1633
|
const decisionStartedAt = ctx.now();
|
|
1790
1634
|
let decisionDurationMs;
|
|
@@ -1851,7 +1695,7 @@ var convergeInTransaction = (program, ctx) => Effect9.gen(function* () {
|
|
|
1851
1695
|
reasons.push("time_slicing_deferred");
|
|
1852
1696
|
}
|
|
1853
1697
|
}
|
|
1854
|
-
const emitTraitConvergeTraceEvent = (decision2) => !shouldCollectDecision ?
|
|
1698
|
+
const emitTraitConvergeTraceEvent = (decision2) => !shouldCollectDecision ? Effect8.void : record({
|
|
1855
1699
|
type: "trace:trait:converge",
|
|
1856
1700
|
moduleId: ctx.moduleId,
|
|
1857
1701
|
instanceId: ctx.instanceId,
|
|
@@ -1861,25 +1705,12 @@ var convergeInTransaction = (program, ctx) => Effect9.gen(function* () {
|
|
|
1861
1705
|
});
|
|
1862
1706
|
const registry = ir.fieldPathIdRegistry;
|
|
1863
1707
|
const dirtyPaths = ctx.dirtyPaths == null ? [] : Array.isArray(ctx.dirtyPaths) ? ctx.dirtyPaths : ctx.dirtyPaths;
|
|
1864
|
-
const
|
|
1865
|
-
|
|
1866
|
-
registry,
|
|
1867
|
-
dirtyAllReason: ctx.dirtyAllReason
|
|
1868
|
-
});
|
|
1708
|
+
const dirtyPathCountHint = Array.isArray(dirtyPaths) ? dirtyPaths.length : typeof dirtyPaths?.size === "number" ? dirtyPaths.size : void 0;
|
|
1709
|
+
let dirtyRootIds;
|
|
1869
1710
|
const DIRTY_ROOT_IDS_TOP_K = 3;
|
|
1870
1711
|
const AUTO_FLOOR_RATIO = 1.05;
|
|
1871
|
-
const
|
|
1872
|
-
|
|
1873
|
-
reason: dirtyRootIds.reason ?? "unknownWrite",
|
|
1874
|
-
rootCount: 0,
|
|
1875
|
-
rootIds: [],
|
|
1876
|
-
rootIdsTruncated: false
|
|
1877
|
-
} : {
|
|
1878
|
-
dirtyAll: false,
|
|
1879
|
-
rootCount: dirtyRootIds.rootCount,
|
|
1880
|
-
rootIds: dirtyRootIds.rootIds.slice(0, DIRTY_ROOT_IDS_TOP_K),
|
|
1881
|
-
rootIdsTruncated: dirtyRootIds.rootIds.length > DIRTY_ROOT_IDS_TOP_K
|
|
1882
|
-
};
|
|
1712
|
+
const MAX_CACHEABLE_ROOT_IDS = 128;
|
|
1713
|
+
const MAX_CACHEABLE_ROOT_RATIO = 0.5;
|
|
1883
1714
|
const configScope = ctx.configScope ?? "builtin";
|
|
1884
1715
|
const generationEvidence = ctx.generation ?? {
|
|
1885
1716
|
generation: ir.generation
|
|
@@ -2034,9 +1865,23 @@ var convergeInTransaction = (program, ctx) => Effect9.gen(function* () {
|
|
|
2034
1865
|
if (cacheMissReasonHint === "generation_bumped" && typeof generationEvidence.generationBumpCount === "number" && generationEvidence.generationBumpCount >= 3 && cache && !cache.isDisabled()) {
|
|
2035
1866
|
cache.disable("generation_thrash");
|
|
2036
1867
|
}
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
1868
|
+
let canUseCache = false;
|
|
1869
|
+
let planKeyHash = 0;
|
|
1870
|
+
let rootIdsKey = void 0;
|
|
1871
|
+
const ensureDirtyRootIds = () => {
|
|
1872
|
+
if (dirtyRootIds) return dirtyRootIds;
|
|
1873
|
+
dirtyRootIds = dirtyPathsToRootIds({
|
|
1874
|
+
dirtyPaths,
|
|
1875
|
+
registry,
|
|
1876
|
+
dirtyAllReason: ctx.dirtyAllReason
|
|
1877
|
+
});
|
|
1878
|
+
const rootRatioForCache = !dirtyRootIds.dirtyAll && scopeStepCount > 0 ? dirtyRootIds.rootCount / scopeStepCount : void 0;
|
|
1879
|
+
const cacheableBySize = !dirtyRootIds.dirtyAll && dirtyRootIds.rootIds.length > 0 && dirtyRootIds.rootIds.length <= MAX_CACHEABLE_ROOT_IDS && (rootRatioForCache == null || rootRatioForCache <= MAX_CACHEABLE_ROOT_RATIO);
|
|
1880
|
+
canUseCache = !!cache && !cache.isDisabled() && ctx.schedulingScopeStepIds == null && cacheableBySize;
|
|
1881
|
+
planKeyHash = dirtyRootIds.keyHash ^ (schedulingScope === "all" ? 0 : schedulingScope === "immediate" ? 1 : 2);
|
|
1882
|
+
rootIdsKey = canUseCache ? dirtyRootIds.rootIds : void 0;
|
|
1883
|
+
return dirtyRootIds;
|
|
1884
|
+
};
|
|
2040
1885
|
let cacheEvidence = shouldCollectDecisionHeavyDetails ? {
|
|
2041
1886
|
capacity: 0,
|
|
2042
1887
|
size: 0,
|
|
@@ -2048,11 +1893,12 @@ var convergeInTransaction = (program, ctx) => Effect9.gen(function* () {
|
|
|
2048
1893
|
let affectedSteps;
|
|
2049
1894
|
let planStepIds;
|
|
2050
1895
|
const getOrComputePlan = (options) => {
|
|
2051
|
-
|
|
1896
|
+
const dirty = ensureDirtyRootIds();
|
|
1897
|
+
if (dirty.dirtyAll) {
|
|
2052
1898
|
if (cacheEvidence && cache) {
|
|
2053
1899
|
cacheEvidence = cache.evidence({
|
|
2054
1900
|
hit: false,
|
|
2055
|
-
keySize:
|
|
1901
|
+
keySize: dirty.keySize,
|
|
2056
1902
|
missReason: options?.missReason ?? "unknown"
|
|
2057
1903
|
});
|
|
2058
1904
|
}
|
|
@@ -2066,7 +1912,7 @@ var convergeInTransaction = (program, ctx) => Effect9.gen(function* () {
|
|
|
2066
1912
|
if (cacheEvidence) {
|
|
2067
1913
|
cacheEvidence = cache.evidence({
|
|
2068
1914
|
hit: true,
|
|
2069
|
-
keySize:
|
|
1915
|
+
keySize: dirty.keySize
|
|
2070
1916
|
});
|
|
2071
1917
|
}
|
|
2072
1918
|
affectedSteps = cached.length;
|
|
@@ -2077,24 +1923,34 @@ var convergeInTransaction = (program, ctx) => Effect9.gen(function* () {
|
|
|
2077
1923
|
if (cacheEvidence && cache) {
|
|
2078
1924
|
cacheEvidence = cache.evidence({
|
|
2079
1925
|
hit: false,
|
|
2080
|
-
keySize:
|
|
1926
|
+
keySize: dirty.keySize,
|
|
2081
1927
|
missReason: options?.missReason ?? "unknown"
|
|
2082
1928
|
});
|
|
2083
1929
|
}
|
|
2084
|
-
|
|
1930
|
+
const fullPlan = scopeStepIds;
|
|
1931
|
+
affectedSteps = fullPlan.length;
|
|
1932
|
+
if (canUseCache && cache && rootIdsKey) {
|
|
1933
|
+
cache.set(planKeyHash, rootIdsKey, fullPlan);
|
|
1934
|
+
}
|
|
1935
|
+
return { plan: fullPlan, hit: false, budgetCutoff: true };
|
|
2085
1936
|
}
|
|
2086
|
-
const computed = computePlanStepIds(
|
|
1937
|
+
const computed = computePlanStepIds(dirty.rootIds, {
|
|
2087
1938
|
stopOnDecisionBudget: options?.stopOnDecisionBudget
|
|
2088
1939
|
});
|
|
2089
1940
|
if (computed.budgetCutoff) {
|
|
2090
1941
|
if (cacheEvidence && cache) {
|
|
2091
1942
|
cacheEvidence = cache.evidence({
|
|
2092
1943
|
hit: false,
|
|
2093
|
-
keySize:
|
|
1944
|
+
keySize: dirty.keySize,
|
|
2094
1945
|
missReason: options?.missReason ?? "unknown"
|
|
2095
1946
|
});
|
|
2096
1947
|
}
|
|
2097
|
-
|
|
1948
|
+
const fullPlan = scopeStepIds;
|
|
1949
|
+
affectedSteps = fullPlan.length;
|
|
1950
|
+
if (canUseCache && cache && rootIdsKey) {
|
|
1951
|
+
cache.set(planKeyHash, rootIdsKey, fullPlan);
|
|
1952
|
+
}
|
|
1953
|
+
return { plan: fullPlan, hit: false, budgetCutoff: true };
|
|
2098
1954
|
}
|
|
2099
1955
|
const plan = computed.plan ?? new Int32Array(0);
|
|
2100
1956
|
if (canUseCache && cache && rootIdsKey) {
|
|
@@ -2103,60 +1959,82 @@ var convergeInTransaction = (program, ctx) => Effect9.gen(function* () {
|
|
|
2103
1959
|
if (cacheEvidence && cache) {
|
|
2104
1960
|
cacheEvidence = cache.evidence({
|
|
2105
1961
|
hit: false,
|
|
2106
|
-
keySize:
|
|
1962
|
+
keySize: dirty.keySize,
|
|
2107
1963
|
missReason: options?.missReason ?? "not_cached"
|
|
2108
1964
|
});
|
|
2109
1965
|
}
|
|
2110
1966
|
affectedSteps = plan.length;
|
|
2111
1967
|
return { plan, hit: false };
|
|
2112
1968
|
};
|
|
2113
|
-
const
|
|
1969
|
+
const getNearFullRootRatioThreshold = (stepCount) => {
|
|
1970
|
+
if (stepCount >= 1536) return 0.65;
|
|
1971
|
+
if (stepCount >= 1024) return 0.7;
|
|
1972
|
+
if (stepCount >= 512) return 0.75;
|
|
1973
|
+
return 0.9;
|
|
1974
|
+
};
|
|
2114
1975
|
const NEAR_FULL_PLAN_RATIO_THRESHOLD = 0.9;
|
|
2115
1976
|
if (requestedMode === "auto") {
|
|
2116
1977
|
if (ctx.txnSeq === 1) {
|
|
2117
1978
|
mode = "full";
|
|
2118
1979
|
reasons.push("cold_start");
|
|
2119
|
-
} else if (
|
|
1980
|
+
} else if (ctx.dirtyAllReason) {
|
|
2120
1981
|
mode = "full";
|
|
2121
1982
|
reasons.push("dirty_all");
|
|
2122
1983
|
reasons.push("unknown_write");
|
|
2123
|
-
} else if (
|
|
1984
|
+
} else if (dirtyPathCountHint === 0) {
|
|
2124
1985
|
mode = "full";
|
|
2125
1986
|
reasons.push("unknown_write");
|
|
2126
1987
|
} else {
|
|
2127
|
-
const
|
|
2128
|
-
|
|
1988
|
+
const nearFullRootRatioThreshold = getNearFullRootRatioThreshold(scopeStepCount);
|
|
1989
|
+
const rootRatio = typeof dirtyPathCountHint === "number" && Number.isFinite(dirtyPathCountHint) && dirtyPathCountHint >= 0 ? scopeStepCount > 0 ? dirtyPathCountHint / scopeStepCount : 1 : void 0;
|
|
1990
|
+
if (rootRatio != null && rootRatio >= nearFullRootRatioThreshold) {
|
|
2129
1991
|
mode = "full";
|
|
2130
1992
|
reasons.push("near_full");
|
|
2131
1993
|
} else {
|
|
2132
|
-
const
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
1994
|
+
const dirty = ensureDirtyRootIds();
|
|
1995
|
+
if (dirty.dirtyAll) {
|
|
1996
|
+
mode = "full";
|
|
1997
|
+
reasons.push("dirty_all");
|
|
1998
|
+
reasons.push("unknown_write");
|
|
1999
|
+
} else if (dirty.rootIds.length === 0) {
|
|
2137
2000
|
mode = "full";
|
|
2138
|
-
|
|
2001
|
+
reasons.push("unknown_write");
|
|
2002
|
+
} else if ((scopeStepCount > 0 ? dirty.rootCount / scopeStepCount : 1) >= nearFullRootRatioThreshold) {
|
|
2003
|
+
mode = "full";
|
|
2004
|
+
reasons.push("near_full");
|
|
2139
2005
|
} else {
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
}
|
|
2006
|
+
const { plan, hit, budgetCutoff } = getOrComputePlan({
|
|
2007
|
+
missReason: cacheMissReasonHint ?? "not_cached",
|
|
2008
|
+
stopOnDecisionBudget: decisionBudgetMs != null
|
|
2009
|
+
});
|
|
2010
|
+
if (budgetCutoff) {
|
|
2011
|
+
markDecisionBudgetCutoff();
|
|
2012
|
+
}
|
|
2013
|
+
if (!plan) {
|
|
2147
2014
|
mode = "dirty";
|
|
2015
|
+
} else {
|
|
2016
|
+
planStepIds = plan;
|
|
2017
|
+
reasons.push(hit ? "cache_hit" : "cache_miss");
|
|
2018
|
+
const ratio = scopeStepCount > 0 ? plan.length / scopeStepCount : 1;
|
|
2019
|
+
if (ratio >= NEAR_FULL_PLAN_RATIO_THRESHOLD) {
|
|
2020
|
+
mode = "full";
|
|
2021
|
+
reasons.push("near_full");
|
|
2022
|
+
} else {
|
|
2023
|
+
mode = "dirty";
|
|
2024
|
+
}
|
|
2148
2025
|
}
|
|
2149
2026
|
}
|
|
2150
2027
|
}
|
|
2151
2028
|
}
|
|
2152
2029
|
} else {
|
|
2153
2030
|
reasons.push("module_override");
|
|
2031
|
+
const dirty = ensureDirtyRootIds();
|
|
2154
2032
|
if (mode === "dirty") {
|
|
2155
2033
|
const { plan, hit } = getOrComputePlan({ missReason: cacheMissReasonHint ?? "not_cached" });
|
|
2156
2034
|
planStepIds = plan;
|
|
2157
|
-
if (
|
|
2035
|
+
if (dirty.dirtyAll) {
|
|
2158
2036
|
reasons.push("dirty_all");
|
|
2159
|
-
} else if (cache &&
|
|
2037
|
+
} else if (cache && dirty.rootIds.length > 0) {
|
|
2160
2038
|
reasons.push(hit ? "cache_hit" : "cache_miss");
|
|
2161
2039
|
}
|
|
2162
2040
|
}
|
|
@@ -2164,6 +2042,48 @@ var convergeInTransaction = (program, ctx) => Effect9.gen(function* () {
|
|
|
2164
2042
|
if (cacheEvidence?.disabled && cacheEvidence.disableReason === "low_hit_rate" && !reasons.includes("low_hit_rate_protection")) {
|
|
2165
2043
|
reasons.push("low_hit_rate_protection");
|
|
2166
2044
|
}
|
|
2045
|
+
const getDirtySummary = () => {
|
|
2046
|
+
if (!shouldCollectDecisionDetails) return void 0;
|
|
2047
|
+
const requiresRootIds = diagnosticsLevel === "light" || diagnosticsLevel === "full" || requestedMode === "dirty" || mode === "dirty" || dirtyRootIds != null;
|
|
2048
|
+
const dirty = requiresRootIds && dirtyRootIds == null && (diagnosticsLevel === "light" || diagnosticsLevel === "full") ? ensureDirtyRootIds() : dirtyRootIds;
|
|
2049
|
+
if (dirty?.dirtyAll) {
|
|
2050
|
+
return {
|
|
2051
|
+
dirtyAll: true,
|
|
2052
|
+
reason: dirty.reason ?? "unknownWrite",
|
|
2053
|
+
rootCount: 0,
|
|
2054
|
+
...requiresRootIds ? { rootIds: [], rootIdsTruncated: false } : null
|
|
2055
|
+
};
|
|
2056
|
+
}
|
|
2057
|
+
if (dirty) {
|
|
2058
|
+
return {
|
|
2059
|
+
dirtyAll: false,
|
|
2060
|
+
rootCount: dirty.rootCount,
|
|
2061
|
+
...requiresRootIds ? {
|
|
2062
|
+
rootIds: dirty.rootIds.slice(0, DIRTY_ROOT_IDS_TOP_K),
|
|
2063
|
+
rootIdsTruncated: dirty.rootIds.length > DIRTY_ROOT_IDS_TOP_K
|
|
2064
|
+
} : null
|
|
2065
|
+
};
|
|
2066
|
+
}
|
|
2067
|
+
if (typeof dirtyPathCountHint === "number" && dirtyPathCountHint === 0) {
|
|
2068
|
+
return {
|
|
2069
|
+
dirtyAll: true,
|
|
2070
|
+
reason: "unknownWrite",
|
|
2071
|
+
rootCount: 0
|
|
2072
|
+
};
|
|
2073
|
+
}
|
|
2074
|
+
if (typeof dirtyPathCountHint === "number") {
|
|
2075
|
+
return {
|
|
2076
|
+
dirtyAll: false,
|
|
2077
|
+
rootCount: dirtyPathCountHint
|
|
2078
|
+
};
|
|
2079
|
+
}
|
|
2080
|
+
return {
|
|
2081
|
+
dirtyAll: true,
|
|
2082
|
+
reason: "unknownWrite",
|
|
2083
|
+
rootCount: 0,
|
|
2084
|
+
...requiresRootIds ? { rootIds: [], rootIdsTruncated: false } : null
|
|
2085
|
+
};
|
|
2086
|
+
};
|
|
2167
2087
|
executionStartedAt = ctx.now();
|
|
2168
2088
|
if (requestedMode === "auto") {
|
|
2169
2089
|
decisionDurationMs = Math.max(0, executionStartedAt - decisionStartedAt);
|
|
@@ -2185,8 +2105,8 @@ var convergeInTransaction = (program, ctx) => Effect9.gen(function* () {
|
|
|
2185
2105
|
staticIrDigest,
|
|
2186
2106
|
executionBudgetMs: ctx.budgetMs,
|
|
2187
2107
|
executionDurationMs: params.executionDurationMs,
|
|
2188
|
-
|
|
2189
|
-
|
|
2108
|
+
decisionBudgetMs: requestedMode === "auto" ? ctx.decisionBudgetMs : void 0,
|
|
2109
|
+
decisionDurationMs: requestedMode === "auto" ? decisionDurationMs : void 0,
|
|
2190
2110
|
reasons,
|
|
2191
2111
|
stepStats
|
|
2192
2112
|
};
|
|
@@ -2194,11 +2114,13 @@ var convergeInTransaction = (program, ctx) => Effect9.gen(function* () {
|
|
|
2194
2114
|
return base2;
|
|
2195
2115
|
}
|
|
2196
2116
|
if (!shouldCollectDecisionHeavyDetails) {
|
|
2117
|
+
const dirtySummary2 = getDirtySummary();
|
|
2197
2118
|
return {
|
|
2198
2119
|
...base2,
|
|
2199
|
-
dirty:
|
|
2120
|
+
dirty: dirtySummary2
|
|
2200
2121
|
};
|
|
2201
2122
|
}
|
|
2123
|
+
const dirtySummary = getDirtySummary();
|
|
2202
2124
|
return {
|
|
2203
2125
|
...base2,
|
|
2204
2126
|
thresholds: { floorRatio: AUTO_FLOOR_RATIO },
|
|
@@ -2220,6 +2142,7 @@ var convergeInTransaction = (program, ctx) => Effect9.gen(function* () {
|
|
|
2220
2142
|
const canUseInPlaceDraft = ctx.allowInPlaceDraft === true && execIr.allOutPathsShallow;
|
|
2221
2143
|
const draft = canUseInPlaceDraft ? new ShallowInPlaceDraft(base) : new CowDraft(base);
|
|
2222
2144
|
let budgetChecks = 0;
|
|
2145
|
+
const dirtyRootIdsForExecution = mode === "dirty" ? ensureDirtyRootIds() : void 0;
|
|
2223
2146
|
const rollbackDraft = () => {
|
|
2224
2147
|
if (draft instanceof ShallowInPlaceDraft) {
|
|
2225
2148
|
draft.rollback();
|
|
@@ -2227,14 +2150,10 @@ var convergeInTransaction = (program, ctx) => Effect9.gen(function* () {
|
|
|
2227
2150
|
ctx.setDraft(base);
|
|
2228
2151
|
};
|
|
2229
2152
|
try {
|
|
2230
|
-
if (mode === "dirty" && !planStepIds) {
|
|
2231
|
-
const { plan } = getOrComputePlan({ missReason: cacheMissReasonHint ?? "not_cached" });
|
|
2232
|
-
planStepIds = plan;
|
|
2233
|
-
}
|
|
2234
2153
|
let dirtyPrefixSet;
|
|
2235
|
-
if (mode === "dirty" && !
|
|
2154
|
+
if (mode === "dirty" && !planStepIds && dirtyRootIdsForExecution && !dirtyRootIdsForExecution.dirtyAll) {
|
|
2236
2155
|
dirtyPrefixBitSet.clear();
|
|
2237
|
-
const roots =
|
|
2156
|
+
const roots = dirtyRootIdsForExecution.rootIds;
|
|
2238
2157
|
for (let i = 0; i < roots.length; i++) {
|
|
2239
2158
|
addPathPrefixes(roots[i]);
|
|
2240
2159
|
}
|
|
@@ -2308,7 +2227,7 @@ var convergeInTransaction = (program, ctx) => Effect9.gen(function* () {
|
|
|
2308
2227
|
executedSteps += 1;
|
|
2309
2228
|
if (steps) {
|
|
2310
2229
|
const stepStartedAt = ctx.now();
|
|
2311
|
-
const exit2 = yield*
|
|
2230
|
+
const exit2 = yield* Effect8.exit(
|
|
2312
2231
|
runWriterStep(ctx, execIr, draft, stepId, entry, shouldCollectDecision, diagnosticsLevel, stack)
|
|
2313
2232
|
);
|
|
2314
2233
|
const stepEndedAt = ctx.now();
|
|
@@ -2378,7 +2297,7 @@ var convergeInTransaction = (program, ctx) => Effect9.gen(function* () {
|
|
|
2378
2297
|
}
|
|
2379
2298
|
if (hotspots) {
|
|
2380
2299
|
const stepStartedAt = ctx.now();
|
|
2381
|
-
const exit2 = yield*
|
|
2300
|
+
const exit2 = yield* Effect8.exit(
|
|
2382
2301
|
runWriterStep(ctx, execIr, draft, stepId, entry, shouldCollectDecision, diagnosticsLevel, stack)
|
|
2383
2302
|
);
|
|
2384
2303
|
const stepEndedAt = ctx.now();
|
|
@@ -2452,7 +2371,7 @@ var convergeInTransaction = (program, ctx) => Effect9.gen(function* () {
|
|
|
2452
2371
|
}
|
|
2453
2372
|
continue;
|
|
2454
2373
|
}
|
|
2455
|
-
const exit = yield*
|
|
2374
|
+
const exit = yield* Effect8.exit(
|
|
2456
2375
|
runWriterStep(ctx, execIr, draft, stepId, entry, shouldCollectDecision, diagnosticsLevel, stack)
|
|
2457
2376
|
);
|
|
2458
2377
|
if (exit._tag === "Failure") {
|
|
@@ -2554,8 +2473,8 @@ var convergeInTransaction = (program, ctx) => Effect9.gen(function* () {
|
|
|
2554
2473
|
};
|
|
2555
2474
|
});
|
|
2556
2475
|
|
|
2557
|
-
// src/internal/state-trait/validate.ts
|
|
2558
|
-
import { Effect as
|
|
2476
|
+
// src/internal/state-trait/validate.impl.ts
|
|
2477
|
+
import { Effect as Effect9, FiberRef as FiberRef5 } from "effect";
|
|
2559
2478
|
import { create } from "mutative";
|
|
2560
2479
|
|
|
2561
2480
|
// src/internal/state-trait/graph.ts
|
|
@@ -2589,7 +2508,7 @@ var reverseClosure = (graph, target) => {
|
|
|
2589
2508
|
return visited;
|
|
2590
2509
|
};
|
|
2591
2510
|
|
|
2592
|
-
// src/internal/state-trait/validate.ts
|
|
2511
|
+
// src/internal/state-trait/validate.impl.ts
|
|
2593
2512
|
var RULE_SKIP = /* @__PURE__ */ Symbol.for("logix.state-trait.validate.skip");
|
|
2594
2513
|
var parseSegments = (path) => {
|
|
2595
2514
|
if (!path) return [];
|
|
@@ -2996,11 +2915,11 @@ var evalCheck = (entry, input, ctx) => {
|
|
|
2996
2915
|
if (!ran) return RULE_SKIP;
|
|
2997
2916
|
return mergeRuleErrors(results);
|
|
2998
2917
|
};
|
|
2999
|
-
var validateInTransaction = (program, ctx, requests) =>
|
|
2918
|
+
var validateInTransaction = (program, ctx, requests) => Effect9.gen(function* () {
|
|
3000
2919
|
const diagnosticsLevel = yield* FiberRef5.get(currentDiagnosticsLevel);
|
|
3001
2920
|
const enableTrace = diagnosticsLevel !== "off";
|
|
3002
2921
|
const traceEvents = enableTrace ? [] : void 0;
|
|
3003
|
-
yield*
|
|
2922
|
+
yield* Effect9.sync(() => {
|
|
3004
2923
|
if (requests.length === 0) return;
|
|
3005
2924
|
const checks = program.entries.filter(
|
|
3006
2925
|
(e) => e.kind === "check"
|
|
@@ -3504,7 +3423,7 @@ var validateInTransaction = (program, ctx, requests) => Effect10.gen(function* (
|
|
|
3504
3423
|
}
|
|
3505
3424
|
});
|
|
3506
3425
|
if (traceEvents && traceEvents.length > 0) {
|
|
3507
|
-
yield*
|
|
3426
|
+
yield* Effect9.forEach(traceEvents, (event) => record(event), {
|
|
3508
3427
|
discard: true
|
|
3509
3428
|
});
|
|
3510
3429
|
}
|
|
@@ -3545,44 +3464,48 @@ var makeTransactionOps = (args) => {
|
|
|
3545
3464
|
txnHistory,
|
|
3546
3465
|
txnById
|
|
3547
3466
|
} = args;
|
|
3548
|
-
const readState =
|
|
3467
|
+
const readState = Effect10.gen(function* () {
|
|
3549
3468
|
const inTxn = yield* FiberRef6.get(inSyncTransactionFiber);
|
|
3550
3469
|
const current = txnContext.current;
|
|
3551
3470
|
if (inTxn && current) return current.draft;
|
|
3552
3471
|
return yield* SubscriptionRef2.get(stateRef);
|
|
3553
3472
|
});
|
|
3554
|
-
const runWithStateTransaction = (origin, body) =>
|
|
3473
|
+
const runWithStateTransaction = (origin, body) => Effect10.locally(
|
|
3555
3474
|
inSyncTransactionFiber,
|
|
3556
3475
|
true
|
|
3557
3476
|
)(
|
|
3558
|
-
|
|
3477
|
+
Effect10.gen(function* () {
|
|
3559
3478
|
const baseState = yield* SubscriptionRef2.get(stateRef);
|
|
3560
3479
|
beginTransaction(txnContext, origin, baseState);
|
|
3561
3480
|
const txnCurrent = txnContext.current;
|
|
3562
3481
|
txnCurrent.stateTraitValidateRequests = [];
|
|
3563
3482
|
txnCurrent.commitMode = "normal";
|
|
3564
3483
|
txnCurrent.priority = "normal";
|
|
3484
|
+
const stateCommitPriority = origin?.details?.stateCommit?.priority;
|
|
3485
|
+
if (stateCommitPriority === "low" || stateCommitPriority === "normal") {
|
|
3486
|
+
txnCurrent.priority = stateCommitPriority;
|
|
3487
|
+
}
|
|
3565
3488
|
const txnId = txnContext.current?.txnId;
|
|
3566
3489
|
const txnSeq = txnContext.current?.txnSeq;
|
|
3567
3490
|
enterSyncTransaction();
|
|
3568
3491
|
let exit;
|
|
3569
3492
|
try {
|
|
3570
|
-
exit = yield*
|
|
3571
|
-
|
|
3493
|
+
exit = yield* Effect10.exit(
|
|
3494
|
+
Effect10.locally(
|
|
3572
3495
|
currentTxnId,
|
|
3573
3496
|
txnId
|
|
3574
3497
|
)(
|
|
3575
|
-
|
|
3498
|
+
Effect10.gen(function* () {
|
|
3576
3499
|
let traitSummary;
|
|
3577
3500
|
if (isDevEnv2()) {
|
|
3578
|
-
const bodyFiber = yield*
|
|
3501
|
+
const bodyFiber = yield* Effect10.fork(body());
|
|
3579
3502
|
const YIELD_BUDGET = 5;
|
|
3580
3503
|
let polled = yield* Fiber.poll(bodyFiber);
|
|
3581
|
-
for (let i = 0; i < YIELD_BUDGET &&
|
|
3582
|
-
yield*
|
|
3504
|
+
for (let i = 0; i < YIELD_BUDGET && Option3.isNone(polled); i++) {
|
|
3505
|
+
yield* Effect10.yieldNow();
|
|
3583
3506
|
polled = yield* Fiber.poll(bodyFiber);
|
|
3584
3507
|
}
|
|
3585
|
-
if (
|
|
3508
|
+
if (Option3.isNone(polled)) {
|
|
3586
3509
|
yield* record({
|
|
3587
3510
|
type: "diagnostic",
|
|
3588
3511
|
moduleId: optionsModuleId,
|
|
@@ -3599,8 +3522,8 @@ var makeTransactionOps = (args) => {
|
|
|
3599
3522
|
}
|
|
3600
3523
|
const bodyExit = yield* Fiber.await(bodyFiber);
|
|
3601
3524
|
yield* Exit.match(bodyExit, {
|
|
3602
|
-
onFailure: (cause) =>
|
|
3603
|
-
onSuccess: () =>
|
|
3525
|
+
onFailure: (cause) => Effect10.failCause(cause),
|
|
3526
|
+
onSuccess: () => Effect10.void
|
|
3604
3527
|
});
|
|
3605
3528
|
} else {
|
|
3606
3529
|
yield* body();
|
|
@@ -3619,7 +3542,7 @@ var makeTransactionOps = (args) => {
|
|
|
3619
3542
|
deferredSlice.start,
|
|
3620
3543
|
deferredSlice.end
|
|
3621
3544
|
) : void 0;
|
|
3622
|
-
const convergeExit = yield*
|
|
3545
|
+
const convergeExit = yield* Effect10.exit(
|
|
3623
3546
|
convergeInTransaction(
|
|
3624
3547
|
stateTraitProgram,
|
|
3625
3548
|
{
|
|
@@ -3672,7 +3595,7 @@ var makeTransactionOps = (args) => {
|
|
|
3672
3595
|
kind: `state_trait_config_error:${configError.code}`
|
|
3673
3596
|
});
|
|
3674
3597
|
}
|
|
3675
|
-
return yield*
|
|
3598
|
+
return yield* Effect10.failCause(convergeExit.cause);
|
|
3676
3599
|
}
|
|
3677
3600
|
const outcome = convergeExit.value;
|
|
3678
3601
|
const dirtyAllReasonForDeferred = txnContext.current?.dirtyAllReason;
|
|
@@ -3692,8 +3615,8 @@ var makeTransactionOps = (args) => {
|
|
|
3692
3615
|
const runtimeLabel = yield* FiberRef6.get(currentRuntimeLabel);
|
|
3693
3616
|
const diagnosticsLevel = yield* FiberRef6.get(currentDiagnosticsLevel);
|
|
3694
3617
|
const debugSinks = yield* FiberRef6.get(currentDebugSinks);
|
|
3695
|
-
const overridesOpt = yield*
|
|
3696
|
-
const overrides =
|
|
3618
|
+
const overridesOpt = yield* Effect10.serviceOption(StateTransactionOverridesTag);
|
|
3619
|
+
const overrides = Option3.isSome(overridesOpt) ? overridesOpt.value : void 0;
|
|
3697
3620
|
traitConvergeTimeSlicing.capturedContext = {
|
|
3698
3621
|
runtimeLabel,
|
|
3699
3622
|
diagnosticsLevel,
|
|
@@ -3811,7 +3734,7 @@ var makeTransactionOps = (args) => {
|
|
|
3811
3734
|
"state",
|
|
3812
3735
|
"state:update",
|
|
3813
3736
|
{ meta: { moduleId: optionsModuleId, instanceId } },
|
|
3814
|
-
|
|
3737
|
+
Effect10.gen(function* () {
|
|
3815
3738
|
const replayEvent = txnContext.current?.lastReplayEvent;
|
|
3816
3739
|
const commitMode = txnContext.current?.commitMode ?? "normal";
|
|
3817
3740
|
const priority = txnContext.current?.priority ?? "normal";
|
|
@@ -3945,11 +3868,11 @@ var makeTransactionOps = (args) => {
|
|
|
3945
3868
|
}
|
|
3946
3869
|
if (exit._tag === "Failure") {
|
|
3947
3870
|
abort(txnContext);
|
|
3948
|
-
return yield*
|
|
3871
|
+
return yield* Effect10.failCause(exit.cause);
|
|
3949
3872
|
}
|
|
3950
3873
|
})
|
|
3951
3874
|
);
|
|
3952
|
-
const setStateInternal = (next, path, reason, from, to, traitNodeId, stepId) =>
|
|
3875
|
+
const setStateInternal = (next, path, reason, from, to, traitNodeId, stepId) => Effect10.gen(function* () {
|
|
3953
3876
|
const inTxn = yield* FiberRef6.get(inSyncTransactionFiber);
|
|
3954
3877
|
if (inTxn && txnContext.current) {
|
|
3955
3878
|
const current = txnContext.current;
|
|
@@ -3973,7 +3896,7 @@ var makeTransactionOps = (args) => {
|
|
|
3973
3896
|
kind: "state",
|
|
3974
3897
|
name: "setState"
|
|
3975
3898
|
},
|
|
3976
|
-
() =>
|
|
3899
|
+
() => Effect10.sync(() => {
|
|
3977
3900
|
updateDraft(txnContext, next);
|
|
3978
3901
|
recordStatePatch(path, reason, from, to, traitNodeId, stepId);
|
|
3979
3902
|
})
|
|
@@ -4000,7 +3923,7 @@ var makeTransactionOps = (args) => {
|
|
|
4000
3923
|
};
|
|
4001
3924
|
|
|
4002
3925
|
// src/internal/runtime/core/ModuleRuntime.concurrencyPolicy.ts
|
|
4003
|
-
import { Effect as
|
|
3926
|
+
import { Effect as Effect11, Option as Option4 } from "effect";
|
|
4004
3927
|
var normalizeConcurrencyLimit = (v) => v === "unbounded" ? "unbounded" : normalizePositiveInt(v);
|
|
4005
3928
|
var makeResolveConcurrencyPolicy = (args) => {
|
|
4006
3929
|
const builtinConcurrencyLimit = 16;
|
|
@@ -4009,11 +3932,11 @@ var makeResolveConcurrencyPolicy = (args) => {
|
|
|
4009
3932
|
const builtinThresholdBacklogCount = 1e3;
|
|
4010
3933
|
const builtinThresholdBacklogDurationMs = 5e3;
|
|
4011
3934
|
const builtinWarningCooldownMs = 3e4;
|
|
4012
|
-
return () =>
|
|
4013
|
-
const runtimeConfigOpt = yield*
|
|
4014
|
-
const overridesOpt = yield*
|
|
4015
|
-
const runtimeConfig =
|
|
4016
|
-
const providerOverrides =
|
|
3935
|
+
return () => Effect11.gen(function* () {
|
|
3936
|
+
const runtimeConfigOpt = yield* Effect11.serviceOption(ConcurrencyPolicyTag);
|
|
3937
|
+
const overridesOpt = yield* Effect11.serviceOption(ConcurrencyPolicyOverridesTag);
|
|
3938
|
+
const runtimeConfig = Option4.isSome(runtimeConfigOpt) ? runtimeConfigOpt.value : void 0;
|
|
3939
|
+
const providerOverrides = Option4.isSome(overridesOpt) ? overridesOpt.value : void 0;
|
|
4017
3940
|
let concurrencyLimit = builtinConcurrencyLimit;
|
|
4018
3941
|
let concurrencyLimitScope = "builtin";
|
|
4019
3942
|
let lastBoundedConcurrencyLimit = builtinConcurrencyLimit;
|
|
@@ -4110,7 +4033,7 @@ var makeResolveConcurrencyPolicy = (args) => {
|
|
|
4110
4033
|
};
|
|
4111
4034
|
|
|
4112
4035
|
// src/internal/runtime/core/ModuleRuntime.txnLanePolicy.ts
|
|
4113
|
-
import { Effect as
|
|
4036
|
+
import { Effect as Effect12, Option as Option5 } from "effect";
|
|
4114
4037
|
var normalizeMs = normalizeNonNegativeNumber;
|
|
4115
4038
|
var normalizeBool = normalizeBoolean;
|
|
4116
4039
|
var makeResolveTxnLanePolicy = (args) => {
|
|
@@ -4120,11 +4043,11 @@ var makeResolveTxnLanePolicy = (args) => {
|
|
|
4120
4043
|
const builtinMaxLagMs = normalizeMs(args.stateTransaction?.txnLanes?.maxLagMs) ?? 50;
|
|
4121
4044
|
const builtinAllowCoalesce = normalizeBool(args.stateTransaction?.txnLanes?.allowCoalesce) ?? true;
|
|
4122
4045
|
const builtinYieldStrategy = args.stateTransaction?.txnLanes?.yieldStrategy === "inputPending" ? "inputPending" : "baseline";
|
|
4123
|
-
return () =>
|
|
4124
|
-
const runtimeConfigOpt = yield*
|
|
4125
|
-
const overridesOpt = yield*
|
|
4126
|
-
const runtimeConfig =
|
|
4127
|
-
const providerOverrides =
|
|
4046
|
+
return () => Effect12.gen(function* () {
|
|
4047
|
+
const runtimeConfigOpt = yield* Effect12.serviceOption(StateTransactionConfigTag);
|
|
4048
|
+
const overridesOpt = yield* Effect12.serviceOption(StateTransactionOverridesTag);
|
|
4049
|
+
const runtimeConfig = Option5.isSome(runtimeConfigOpt) ? runtimeConfigOpt.value : void 0;
|
|
4050
|
+
const providerOverrides = Option5.isSome(overridesOpt) ? overridesOpt.value : void 0;
|
|
4128
4051
|
let enabled = builtinEnabled;
|
|
4129
4052
|
let budgetMs = builtinBudgetMs;
|
|
4130
4053
|
let debounceMs = builtinDebounceMs;
|
|
@@ -4201,7 +4124,7 @@ var makeResolveTxnLanePolicy = (args) => {
|
|
|
4201
4124
|
};
|
|
4202
4125
|
|
|
4203
4126
|
// src/internal/runtime/core/ModuleRuntime.traitConvergeConfig.ts
|
|
4204
|
-
import { Effect as
|
|
4127
|
+
import { Effect as Effect13, Option as Option6 } from "effect";
|
|
4205
4128
|
var normalizePositiveMs = normalizePositiveNumber;
|
|
4206
4129
|
var normalizeRequestedMode = (mode) => mode === "auto" || mode === "full" || mode === "dirty" ? mode : void 0;
|
|
4207
4130
|
var normalizeBool2 = (value) => typeof value === "boolean" ? value : void 0;
|
|
@@ -4212,11 +4135,11 @@ var makeResolveTraitConvergeConfig = (args) => {
|
|
|
4212
4135
|
const builtinTimeSlicingEnabled = normalizeBool2(args.stateTransaction?.traitConvergeTimeSlicing?.enabled) ?? false;
|
|
4213
4136
|
const builtinTimeSlicingDebounceMs = normalizePositiveMs(args.stateTransaction?.traitConvergeTimeSlicing?.debounceMs) ?? 16;
|
|
4214
4137
|
const builtinTimeSlicingMaxLagMs = normalizePositiveMs(args.stateTransaction?.traitConvergeTimeSlicing?.maxLagMs) ?? 200;
|
|
4215
|
-
return () =>
|
|
4216
|
-
const runtimeConfigOpt = yield*
|
|
4217
|
-
const overridesOpt = yield*
|
|
4218
|
-
const runtimeConfig =
|
|
4219
|
-
const providerOverrides =
|
|
4138
|
+
return () => Effect13.gen(function* () {
|
|
4139
|
+
const runtimeConfigOpt = yield* Effect13.serviceOption(StateTransactionConfigTag);
|
|
4140
|
+
const overridesOpt = yield* Effect13.serviceOption(StateTransactionOverridesTag);
|
|
4141
|
+
const runtimeConfig = Option6.isSome(runtimeConfigOpt) ? runtimeConfigOpt.value : void 0;
|
|
4142
|
+
const providerOverrides = Option6.isSome(overridesOpt) ? overridesOpt.value : void 0;
|
|
4220
4143
|
let traitConvergeMode = builtinTraitConvergeMode;
|
|
4221
4144
|
let traitConvergeBudgetMs = builtinTraitConvergeBudgetMs;
|
|
4222
4145
|
let traitConvergeDecisionBudgetMs = builtinTraitConvergeDecisionBudgetMs;
|
|
@@ -4286,14 +4209,14 @@ var makeResolveTraitConvergeConfig = (args) => {
|
|
|
4286
4209
|
};
|
|
4287
4210
|
|
|
4288
4211
|
// src/internal/runtime/core/ModuleRuntime.internalHooks.ts
|
|
4289
|
-
import { Effect as
|
|
4290
|
-
var installInternalHooks = (args) =>
|
|
4212
|
+
import { Effect as Effect14 } from "effect";
|
|
4213
|
+
var installInternalHooks = (args) => Effect14.sync(() => {
|
|
4291
4214
|
const { runtime, runtimeInternals } = args;
|
|
4292
4215
|
setRuntimeInternals(runtime, runtimeInternals);
|
|
4293
4216
|
});
|
|
4294
4217
|
|
|
4295
4218
|
// src/internal/runtime/core/SelectorGraph.ts
|
|
4296
|
-
import { Effect as
|
|
4219
|
+
import { Effect as Effect15, PubSub as PubSub3 } from "effect";
|
|
4297
4220
|
var getReadRootKeyFromPath = (path) => path[0] ?? "";
|
|
4298
4221
|
var overlaps = (a, b) => isPrefixOf(a, b) || isPrefixOf(b, a);
|
|
4299
4222
|
var equalsShallowStruct = (a, b) => {
|
|
@@ -4335,9 +4258,9 @@ var make2 = (args) => {
|
|
|
4335
4258
|
const ensureEntry = (readQuery) => {
|
|
4336
4259
|
const existing = selectorsById.get(readQuery.selectorId);
|
|
4337
4260
|
if (existing) {
|
|
4338
|
-
return
|
|
4261
|
+
return Effect15.succeed(existing);
|
|
4339
4262
|
}
|
|
4340
|
-
return
|
|
4263
|
+
return Effect15.gen(function* () {
|
|
4341
4264
|
const hub = yield* PubSub3.unbounded();
|
|
4342
4265
|
const reads = readQuery.reads.filter((x) => typeof x === "string").map((raw) => normalizeFieldPath(raw)).filter((x) => x != null);
|
|
4343
4266
|
const readRootKeys = Array.from(new Set(reads.map(getReadRootKeyFromPath)));
|
|
@@ -4379,7 +4302,7 @@ var make2 = (args) => {
|
|
|
4379
4302
|
}
|
|
4380
4303
|
}
|
|
4381
4304
|
};
|
|
4382
|
-
const onCommit = (state, meta, dirtySet, diagnosticsLevel) =>
|
|
4305
|
+
const onCommit = (state, meta, dirtySet, diagnosticsLevel, onSelectorChanged) => Effect15.gen(function* () {
|
|
4383
4306
|
if (selectorsById.size === 0) return;
|
|
4384
4307
|
const emitEvalEvent = diagnosticsLevel === "light" || diagnosticsLevel === "full" || diagnosticsLevel === "sampled";
|
|
4385
4308
|
const registry = dirtySet.dirtyAll || dirtySet.rootIds.length === 0 ? void 0 : getFieldPathIdRegistry?.();
|
|
@@ -4445,6 +4368,7 @@ var make2 = (args) => {
|
|
|
4445
4368
|
entry.cachedValue = next;
|
|
4446
4369
|
entry.hasValue = true;
|
|
4447
4370
|
entry.cachedAtTxnSeq = meta.txnSeq;
|
|
4371
|
+
onSelectorChanged?.(entry.selectorId);
|
|
4448
4372
|
yield* PubSub3.publish(entry.hub, {
|
|
4449
4373
|
value: entry.cachedValue,
|
|
4450
4374
|
meta
|
|
@@ -4546,6 +4470,7 @@ var make2 = (args) => {
|
|
|
4546
4470
|
entry.cachedValue = next;
|
|
4547
4471
|
entry.hasValue = true;
|
|
4548
4472
|
entry.cachedAtTxnSeq = meta.txnSeq;
|
|
4473
|
+
onSelectorChanged?.(selectorId);
|
|
4549
4474
|
yield* PubSub3.publish(entry.hub, {
|
|
4550
4475
|
value: entry.cachedValue,
|
|
4551
4476
|
meta
|
|
@@ -4576,9 +4501,11 @@ var make2 = (args) => {
|
|
|
4576
4501
|
};
|
|
4577
4502
|
|
|
4578
4503
|
// src/internal/runtime/core/ModuleRuntime.txnQueue.ts
|
|
4579
|
-
import { Deferred, Effect as
|
|
4580
|
-
var captureDiagnosticContext = (args) =>
|
|
4581
|
-
const overridesOpt = yield*
|
|
4504
|
+
import { Deferred, Effect as Effect16, Exit as Exit2, FiberRef as FiberRef7, Option as Option7, Queue as Queue2, Ref } from "effect";
|
|
4505
|
+
var captureDiagnosticContext = (args) => Effect16.gen(function* () {
|
|
4506
|
+
const overridesOpt = yield* Effect16.serviceOption(StateTransactionOverridesTag);
|
|
4507
|
+
const runtimeStoreOpt = yield* Effect16.serviceOption(RuntimeStoreTag);
|
|
4508
|
+
const tickSchedulerOpt = yield* Effect16.serviceOption(TickSchedulerTag);
|
|
4582
4509
|
const diagnosticsLevel = yield* FiberRef7.get(currentDiagnosticsLevel);
|
|
4583
4510
|
const runtimeLabel = yield* FiberRef7.get(currentRuntimeLabel);
|
|
4584
4511
|
const debugSinks = yield* FiberRef7.get(currentDebugSinks);
|
|
@@ -4589,19 +4516,23 @@ var captureDiagnosticContext = (args) => Effect17.gen(function* () {
|
|
|
4589
4516
|
runtimeLabel,
|
|
4590
4517
|
diagnosticsLevel,
|
|
4591
4518
|
debugSinks,
|
|
4592
|
-
overridesOpt
|
|
4519
|
+
overridesOpt,
|
|
4520
|
+
runtimeStoreOpt,
|
|
4521
|
+
tickSchedulerOpt
|
|
4593
4522
|
};
|
|
4594
4523
|
});
|
|
4595
4524
|
var withDiagnosticContext = (context, eff) => {
|
|
4596
|
-
const effWithOverrides =
|
|
4597
|
-
|
|
4598
|
-
|
|
4599
|
-
|
|
4600
|
-
|
|
4601
|
-
|
|
4525
|
+
const effWithOverrides = Option7.isSome(context.overridesOpt) ? Effect16.provideService(eff, StateTransactionOverridesTag, context.overridesOpt.value) : eff;
|
|
4526
|
+
const effWithRuntimeStore = Option7.isSome(context.runtimeStoreOpt) ? Effect16.provideService(effWithOverrides, RuntimeStoreTag, context.runtimeStoreOpt.value) : effWithOverrides;
|
|
4527
|
+
const effWithTickScheduler = Option7.isSome(context.tickSchedulerOpt) ? Effect16.provideService(effWithRuntimeStore, TickSchedulerTag, context.tickSchedulerOpt.value) : effWithRuntimeStore;
|
|
4528
|
+
return effWithTickScheduler.pipe(
|
|
4529
|
+
Effect16.locally(currentLinkId, context.linkId),
|
|
4530
|
+
Effect16.locally(currentRuntimeLabel, context.runtimeLabel),
|
|
4531
|
+
Effect16.locally(currentDiagnosticsLevel, context.diagnosticsLevel),
|
|
4532
|
+
Effect16.locally(currentDebugSinks, context.debugSinks)
|
|
4602
4533
|
);
|
|
4603
4534
|
};
|
|
4604
|
-
var makeEnqueueTransaction = (args) =>
|
|
4535
|
+
var makeEnqueueTransaction = (args) => Effect16.gen(function* () {
|
|
4605
4536
|
const urgentQueue = yield* Queue2.unbounded();
|
|
4606
4537
|
const nonUrgentQueue = yield* Queue2.unbounded();
|
|
4607
4538
|
const wakeQueue = yield* Queue2.unbounded();
|
|
@@ -4623,7 +4554,7 @@ var makeEnqueueTransaction = (args) => Effect17.gen(function* () {
|
|
|
4623
4554
|
waiters: 0,
|
|
4624
4555
|
signal: initialNonUrgentSignal
|
|
4625
4556
|
});
|
|
4626
|
-
const release = (stateRef) =>
|
|
4557
|
+
const release = (stateRef) => Effect16.gen(function* () {
|
|
4627
4558
|
let prevSignal;
|
|
4628
4559
|
const nextSignal = yield* Deferred.make();
|
|
4629
4560
|
yield* Ref.update(stateRef, (s) => {
|
|
@@ -4646,7 +4577,7 @@ var makeEnqueueTransaction = (args) => Effect17.gen(function* () {
|
|
|
4646
4577
|
yield* Deferred.succeed(prevSignal, void 0);
|
|
4647
4578
|
}
|
|
4648
4579
|
});
|
|
4649
|
-
const acquireBacklogSlot = (lane, capacity) =>
|
|
4580
|
+
const acquireBacklogSlot = (lane, capacity) => Effect16.gen(function* () {
|
|
4650
4581
|
const inTxn = yield* FiberRef7.get(inSyncTransactionFiber);
|
|
4651
4582
|
if (inTxn) {
|
|
4652
4583
|
yield* record({
|
|
@@ -4659,7 +4590,7 @@ var makeEnqueueTransaction = (args) => Effect17.gen(function* () {
|
|
|
4659
4590
|
hint: "Move dispatch/setState calls outside the transaction window, or use a multi-entry pattern (pending \u2192 IO \u2192 writeback).",
|
|
4660
4591
|
kind: "enqueue_in_transaction"
|
|
4661
4592
|
});
|
|
4662
|
-
yield*
|
|
4593
|
+
yield* Effect16.dieMessage("enqueueTransaction is not allowed inside a synchronous StateTransaction body");
|
|
4663
4594
|
}
|
|
4664
4595
|
const stateRef = lane === "urgent" ? urgentStateRef : nonUrgentStateRef;
|
|
4665
4596
|
let waitedFromMs;
|
|
@@ -4692,12 +4623,12 @@ var makeEnqueueTransaction = (args) => Effect17.gen(function* () {
|
|
|
4692
4623
|
backlogCount: attempt.backlogCount,
|
|
4693
4624
|
saturatedDurationMs
|
|
4694
4625
|
});
|
|
4695
|
-
yield*
|
|
4626
|
+
yield* Effect16.acquireUseRelease(
|
|
4696
4627
|
Ref.update(stateRef, (s) => ({
|
|
4697
4628
|
backlogCount: s.backlogCount,
|
|
4698
4629
|
waiters: s.waiters + 1,
|
|
4699
4630
|
signal: s.signal
|
|
4700
|
-
})).pipe(
|
|
4631
|
+
})).pipe(Effect16.as(attempt.signal)),
|
|
4701
4632
|
(signal) => Deferred.await(signal),
|
|
4702
4633
|
() => Ref.update(stateRef, (s) => ({
|
|
4703
4634
|
backlogCount: s.backlogCount,
|
|
@@ -4707,27 +4638,26 @@ var makeEnqueueTransaction = (args) => Effect17.gen(function* () {
|
|
|
4707
4638
|
);
|
|
4708
4639
|
}
|
|
4709
4640
|
});
|
|
4710
|
-
|
|
4711
|
-
|
|
4712
|
-
|
|
4713
|
-
|
|
4714
|
-
|
|
4715
|
-
|
|
4716
|
-
|
|
4717
|
-
|
|
4718
|
-
continue;
|
|
4719
|
-
}
|
|
4720
|
-
const nonUrgent = yield* Queue2.poll(nonUrgentQueue);
|
|
4721
|
-
if (Option8.isSome(nonUrgent)) {
|
|
4722
|
-
yield* nonUrgent.value;
|
|
4723
|
-
continue;
|
|
4724
|
-
}
|
|
4725
|
-
break;
|
|
4641
|
+
const consumerLoop = Effect16.forever(
|
|
4642
|
+
Effect16.gen(function* () {
|
|
4643
|
+
yield* Queue2.take(wakeQueue);
|
|
4644
|
+
while (true) {
|
|
4645
|
+
const urgent = yield* Queue2.poll(urgentQueue);
|
|
4646
|
+
if (Option7.isSome(urgent)) {
|
|
4647
|
+
yield* urgent.value;
|
|
4648
|
+
continue;
|
|
4726
4649
|
}
|
|
4727
|
-
|
|
4728
|
-
|
|
4650
|
+
const nonUrgent = yield* Queue2.poll(nonUrgentQueue);
|
|
4651
|
+
if (Option7.isSome(nonUrgent)) {
|
|
4652
|
+
yield* nonUrgent.value;
|
|
4653
|
+
continue;
|
|
4654
|
+
}
|
|
4655
|
+
break;
|
|
4656
|
+
}
|
|
4657
|
+
})
|
|
4729
4658
|
);
|
|
4730
|
-
|
|
4659
|
+
yield* Effect16.forkScoped(consumerLoop);
|
|
4660
|
+
const enqueueTransaction = (a0, a1) => Effect16.gen(function* () {
|
|
4731
4661
|
const lane = a1 ? a0 : "urgent";
|
|
4732
4662
|
const eff = a1 ? a1 : a0;
|
|
4733
4663
|
const stateRef = lane === "urgent" ? urgentStateRef : nonUrgentStateRef;
|
|
@@ -4738,30 +4668,30 @@ var makeEnqueueTransaction = (args) => Effect17.gen(function* () {
|
|
|
4738
4668
|
const capturedContext = yield* captureDiagnosticContext({ nextLinkId });
|
|
4739
4669
|
const effWithContext = withDiagnosticContext(capturedContext, eff);
|
|
4740
4670
|
const task = effWithContext.pipe(
|
|
4741
|
-
|
|
4742
|
-
|
|
4743
|
-
|
|
4744
|
-
|
|
4671
|
+
Effect16.exit,
|
|
4672
|
+
Effect16.flatMap((exit2) => Deferred.succeed(done, exit2)),
|
|
4673
|
+
Effect16.asVoid,
|
|
4674
|
+
Effect16.ensuring(release(stateRef))
|
|
4745
4675
|
);
|
|
4746
4676
|
const targetQueue = lane === "urgent" ? urgentQueue : nonUrgentQueue;
|
|
4747
|
-
yield*
|
|
4677
|
+
yield* Effect16.uninterruptible(Effect16.all([Queue2.offer(targetQueue, task), Queue2.offer(wakeQueue, void 0)]));
|
|
4748
4678
|
const exit = yield* Deferred.await(done);
|
|
4749
4679
|
return yield* Exit2.match(exit, {
|
|
4750
|
-
onFailure: (cause) =>
|
|
4751
|
-
onSuccess: (value) =>
|
|
4680
|
+
onFailure: (cause) => Effect16.failCause(cause),
|
|
4681
|
+
onSuccess: (value) => Effect16.succeed(value)
|
|
4752
4682
|
});
|
|
4753
4683
|
});
|
|
4754
4684
|
return enqueueTransaction;
|
|
4755
4685
|
});
|
|
4756
4686
|
|
|
4757
4687
|
// src/internal/runtime/core/ModuleRuntime.logics.ts
|
|
4758
|
-
import { Cause as Cause4, Effect as
|
|
4688
|
+
import { Cause as Cause4, Context, Deferred as Deferred2, Effect as Effect18, Exit as Exit3, Fiber as Fiber2, Option as Option8 } from "effect";
|
|
4759
4689
|
|
|
4760
4690
|
// src/internal/runtime/core/LifecycleDiagnostics.ts
|
|
4761
|
-
import { Cause as Cause3, Chunk as Chunk2, Effect as
|
|
4691
|
+
import { Cause as Cause3, Chunk as Chunk2, Effect as Effect17 } from "effect";
|
|
4762
4692
|
var emitMissingOnErrorDiagnosticIfNeeded = (lifecycle, moduleId) => lifecycle.hasOnErrorHandlers.pipe(
|
|
4763
|
-
|
|
4764
|
-
(has) => has || !moduleId ?
|
|
4693
|
+
Effect17.flatMap(
|
|
4694
|
+
(has) => has || !moduleId ? Effect17.void : record({
|
|
4765
4695
|
type: "diagnostic",
|
|
4766
4696
|
moduleId,
|
|
4767
4697
|
code: "lifecycle::missing_on_error",
|
|
@@ -4771,13 +4701,13 @@ var emitMissingOnErrorDiagnosticIfNeeded = (lifecycle, moduleId) => lifecycle.ha
|
|
|
4771
4701
|
})
|
|
4772
4702
|
)
|
|
4773
4703
|
);
|
|
4774
|
-
var emitAssemblyFailureDiagnosticIfNeeded = (cause, moduleId) =>
|
|
4704
|
+
var emitAssemblyFailureDiagnosticIfNeeded = (cause, moduleId) => Effect17.sync(() => {
|
|
4775
4705
|
const defects = Chunk2.toReadonlyArray(Cause3.defects(cause));
|
|
4776
4706
|
const missing = defects.find(
|
|
4777
4707
|
(e) => e && typeof e === "object" && e.name === "MissingModuleRuntimeError"
|
|
4778
4708
|
);
|
|
4779
4709
|
if (!missing) {
|
|
4780
|
-
return
|
|
4710
|
+
return Effect17.void;
|
|
4781
4711
|
}
|
|
4782
4712
|
const tokenId = typeof missing.tokenId === "string" ? missing.tokenId : "<unknown module id>";
|
|
4783
4713
|
const fix = Array.isArray(missing.fix) && missing.fix.every((l) => typeof l === "string") ? missing.fix.join("\n") : void 0;
|
|
@@ -4790,7 +4720,7 @@ var emitAssemblyFailureDiagnosticIfNeeded = (cause, moduleId) => Effect18.sync((
|
|
|
4790
4720
|
hint: fix ?? "Provide the child implementation in the same scope (imports), or provide a root singleton at app root.",
|
|
4791
4721
|
kind: "assembly_failure"
|
|
4792
4722
|
});
|
|
4793
|
-
}).pipe(
|
|
4723
|
+
}).pipe(Effect17.flatten);
|
|
4794
4724
|
|
|
4795
4725
|
// src/internal/runtime/core/LogicPlanMarker.ts
|
|
4796
4726
|
var LOGIC_PLAN_EFFECT = /* @__PURE__ */ Symbol.for("@logixjs/core/logicPlanEffect");
|
|
@@ -4828,17 +4758,17 @@ var createPhaseRef = () => ({ current: "run" });
|
|
|
4828
4758
|
var runModuleLogics = (args) => {
|
|
4829
4759
|
const { tag, logics, runtime, lifecycle, moduleId, instanceId } = args;
|
|
4830
4760
|
const moduleIdForLogs = moduleId;
|
|
4831
|
-
return
|
|
4761
|
+
return Effect18.gen(function* () {
|
|
4832
4762
|
const withRuntimeAndLifecycle = (eff, phaseRef, logicUnit) => {
|
|
4833
|
-
const withServices =
|
|
4834
|
-
|
|
4763
|
+
const withServices = Effect18.provideService(
|
|
4764
|
+
Effect18.provideService(eff, LifecycleContext, lifecycle),
|
|
4835
4765
|
tag,
|
|
4836
4766
|
runtime
|
|
4837
4767
|
);
|
|
4838
|
-
const annotated =
|
|
4768
|
+
const annotated = Effect18.annotateLogs({
|
|
4839
4769
|
"logix.moduleId": moduleIdForLogs
|
|
4840
4770
|
})(withServices);
|
|
4841
|
-
const withLogicUnit = logicUnit ?
|
|
4771
|
+
const withLogicUnit = logicUnit ? Effect18.provideService(annotated, LogicUnitServiceTag, logicUnit) : annotated;
|
|
4842
4772
|
if (!phaseRef) {
|
|
4843
4773
|
return withLogicUnit;
|
|
4844
4774
|
}
|
|
@@ -4847,8 +4777,19 @@ var runModuleLogics = (args) => {
|
|
|
4847
4777
|
return phaseRef.current;
|
|
4848
4778
|
}
|
|
4849
4779
|
};
|
|
4850
|
-
return
|
|
4780
|
+
return Effect18.provideService(withLogicUnit, LogicPhaseServiceTag, phaseService);
|
|
4851
4781
|
};
|
|
4782
|
+
const withRootEnvIfAvailable = (eff) => Effect18.gen(function* () {
|
|
4783
|
+
const rootOpt = yield* Effect18.serviceOption(RootContextTag);
|
|
4784
|
+
if (Option8.isNone(rootOpt)) {
|
|
4785
|
+
return yield* eff;
|
|
4786
|
+
}
|
|
4787
|
+
const root = rootOpt.value;
|
|
4788
|
+
const rootEnv = root.context ?? (yield* Deferred2.await(root.ready));
|
|
4789
|
+
const currentEnv = yield* Effect18.context();
|
|
4790
|
+
const mergedEnv = Context.merge(rootEnv, currentEnv);
|
|
4791
|
+
return yield* Effect18.provide(eff, mergedEnv);
|
|
4792
|
+
});
|
|
4852
4793
|
const formatSource = (source) => source ? `${source.file}:${source.line}:${source.column}` : void 0;
|
|
4853
4794
|
const resolveLogicUnitService = (rawLogic, index) => {
|
|
4854
4795
|
const meta = getLogicUnitMeta(rawLogic);
|
|
@@ -4867,7 +4808,7 @@ var runModuleLogics = (args) => {
|
|
|
4867
4808
|
};
|
|
4868
4809
|
const handleLogicFailure = (cause) => {
|
|
4869
4810
|
if (Cause4.isInterrupted(cause)) {
|
|
4870
|
-
return
|
|
4811
|
+
return Effect18.failCause(cause);
|
|
4871
4812
|
}
|
|
4872
4813
|
const phaseErrorMarker = [...Cause4.failures(cause), ...Cause4.defects(cause)].some(
|
|
4873
4814
|
(err) => err?._tag === "LogicPhaseError"
|
|
@@ -4879,24 +4820,24 @@ var runModuleLogics = (args) => {
|
|
|
4879
4820
|
instanceId,
|
|
4880
4821
|
origin: "logic.fork"
|
|
4881
4822
|
}).pipe(
|
|
4882
|
-
|
|
4883
|
-
|
|
4884
|
-
|
|
4885
|
-
|
|
4886
|
-
|
|
4823
|
+
Effect18.tap(() => emitMissingOnErrorDiagnosticIfNeeded(lifecycle, moduleId)),
|
|
4824
|
+
Effect18.tap(() => emitAssemblyFailureDiagnosticIfNeeded(cause, moduleId)),
|
|
4825
|
+
Effect18.tap(() => emitDiagnosticsFromCause(cause, moduleId)),
|
|
4826
|
+
Effect18.tap(() => emitEnvServiceNotFoundDiagnosticIfNeeded(cause, moduleId)),
|
|
4827
|
+
Effect18.tap(() => emitInvalidPhaseDiagnosticIfNeeded(cause, moduleId))
|
|
4887
4828
|
);
|
|
4888
4829
|
if (phaseErrorMarker) {
|
|
4889
4830
|
return base;
|
|
4890
4831
|
}
|
|
4891
|
-
return base.pipe(
|
|
4832
|
+
return base.pipe(Effect18.flatMap(() => Effect18.failCause(cause)));
|
|
4892
4833
|
};
|
|
4893
|
-
const handleInitFailure = (cause) => Cause4.isInterrupted(cause) ?
|
|
4894
|
-
|
|
4895
|
-
|
|
4896
|
-
|
|
4897
|
-
|
|
4898
|
-
|
|
4899
|
-
|
|
4834
|
+
const handleInitFailure = (cause) => Cause4.isInterrupted(cause) ? Effect18.failCause(cause) : Effect18.void.pipe(
|
|
4835
|
+
Effect18.tap(() => emitMissingOnErrorDiagnosticIfNeeded(lifecycle, moduleId)),
|
|
4836
|
+
Effect18.tap(() => emitAssemblyFailureDiagnosticIfNeeded(cause, moduleId)),
|
|
4837
|
+
Effect18.tap(() => emitDiagnosticsFromCause(cause, moduleId)),
|
|
4838
|
+
Effect18.tap(() => emitEnvServiceNotFoundDiagnosticIfNeeded(cause, moduleId)),
|
|
4839
|
+
Effect18.tap(() => emitInvalidPhaseDiagnosticIfNeeded(cause, moduleId)),
|
|
4840
|
+
Effect18.zipRight(Effect18.failCause(cause))
|
|
4900
4841
|
);
|
|
4901
4842
|
const isLogicPlan = (value) => Boolean(value && typeof value === "object" && "run" in value && "setup" in value);
|
|
4902
4843
|
const normalizeToPlan = (value, defaultPhaseRef) => {
|
|
@@ -4909,7 +4850,7 @@ var runModuleLogics = (args) => {
|
|
|
4909
4850
|
return plan2;
|
|
4910
4851
|
}
|
|
4911
4852
|
const plan = {
|
|
4912
|
-
setup:
|
|
4853
|
+
setup: Effect18.void,
|
|
4913
4854
|
run: value
|
|
4914
4855
|
};
|
|
4915
4856
|
attachPhaseRef(plan, phaseRef);
|
|
@@ -4925,13 +4866,13 @@ var runModuleLogics = (args) => {
|
|
|
4925
4866
|
const setupPhase = withRuntimeAndLifecycle(rawLogic.setup, phaseRef, logicUnit);
|
|
4926
4867
|
const runPhase2 = withRuntimeAndLifecycle(rawLogic.run, phaseRef, logicUnit);
|
|
4927
4868
|
phaseRef.current = "setup";
|
|
4928
|
-
yield* setupPhase.pipe(
|
|
4869
|
+
yield* setupPhase.pipe(Effect18.catchAllCause(handleLogicFailure));
|
|
4929
4870
|
pendingRunForks.push(
|
|
4930
|
-
|
|
4871
|
+
Effect18.sync(() => {
|
|
4931
4872
|
phaseRef.current = "run";
|
|
4932
4873
|
}).pipe(
|
|
4933
|
-
|
|
4934
|
-
|
|
4874
|
+
Effect18.zipRight(Effect18.forkScoped(runPhase2.pipe(Effect18.catchAllCause(handleLogicFailure)))),
|
|
4875
|
+
Effect18.asVoid
|
|
4935
4876
|
)
|
|
4936
4877
|
);
|
|
4937
4878
|
continue;
|
|
@@ -4940,8 +4881,8 @@ var runModuleLogics = (args) => {
|
|
|
4940
4881
|
const phaseRef = getPhaseRef(rawLogic) ?? createPhaseRef();
|
|
4941
4882
|
const makeNoopPlan = () => (() => {
|
|
4942
4883
|
const plan = {
|
|
4943
|
-
setup:
|
|
4944
|
-
run:
|
|
4884
|
+
setup: Effect18.void,
|
|
4885
|
+
run: Effect18.void
|
|
4945
4886
|
};
|
|
4946
4887
|
attachPhaseRef(plan, phaseRef);
|
|
4947
4888
|
markSkipRun(plan);
|
|
@@ -4953,21 +4894,21 @@ var runModuleLogics = (args) => {
|
|
|
4953
4894
|
phaseRef,
|
|
4954
4895
|
logicUnit
|
|
4955
4896
|
).pipe(
|
|
4956
|
-
|
|
4957
|
-
onSuccess: (value) =>
|
|
4897
|
+
Effect18.matchCauseEffect({
|
|
4898
|
+
onSuccess: (value) => Effect18.succeed(normalizeToPlan(value, phaseRef)),
|
|
4958
4899
|
onFailure: (cause) => {
|
|
4959
4900
|
const isLogicPhaseError = [...Cause4.failures(cause), ...Cause4.defects(cause)].some(
|
|
4960
4901
|
(err) => err?._tag === "LogicPhaseError"
|
|
4961
4902
|
);
|
|
4962
4903
|
if (isLogicPhaseError) {
|
|
4963
4904
|
return emitInvalidPhaseDiagnosticIfNeeded(cause, moduleId).pipe(
|
|
4964
|
-
|
|
4965
|
-
|
|
4905
|
+
Effect18.zipRight(handleLogicFailure(cause)),
|
|
4906
|
+
Effect18.as(makeNoopPlan())
|
|
4966
4907
|
);
|
|
4967
4908
|
}
|
|
4968
4909
|
return emitEnvServiceNotFoundDiagnosticIfNeeded(cause, moduleId).pipe(
|
|
4969
|
-
|
|
4970
|
-
|
|
4910
|
+
Effect18.zipRight(handleLogicFailure(cause)),
|
|
4911
|
+
Effect18.zipRight(Effect18.failCause(cause))
|
|
4971
4912
|
);
|
|
4972
4913
|
}
|
|
4973
4914
|
})
|
|
@@ -4981,14 +4922,14 @@ var runModuleLogics = (args) => {
|
|
|
4981
4922
|
const runPhase2 = withRuntimeAndLifecycle(resolvedPlan.run, planPhaseRef, logicUnit);
|
|
4982
4923
|
const skipRun = isSkipRun(resolvedPlan);
|
|
4983
4924
|
planPhaseRef.current = "setup";
|
|
4984
|
-
yield* setupPhase.pipe(
|
|
4925
|
+
yield* setupPhase.pipe(Effect18.catchAllCause(handleLogicFailure));
|
|
4985
4926
|
if (!skipRun) {
|
|
4986
4927
|
pendingRunForks.push(
|
|
4987
|
-
|
|
4928
|
+
Effect18.sync(() => {
|
|
4988
4929
|
planPhaseRef.current = "run";
|
|
4989
4930
|
}).pipe(
|
|
4990
|
-
|
|
4991
|
-
|
|
4931
|
+
Effect18.zipRight(Effect18.forkScoped(withRootEnvIfAvailable(runPhase2).pipe(Effect18.catchAllCause(handleLogicFailure)))),
|
|
4932
|
+
Effect18.asVoid
|
|
4992
4933
|
)
|
|
4993
4934
|
);
|
|
4994
4935
|
}
|
|
@@ -4996,16 +4937,16 @@ var runModuleLogics = (args) => {
|
|
|
4996
4937
|
}
|
|
4997
4938
|
const basePhaseRef = getPhaseRef(rawLogic);
|
|
4998
4939
|
const runPhase = withRuntimeAndLifecycle(rawLogic, basePhaseRef, logicUnit).pipe(
|
|
4999
|
-
|
|
4940
|
+
Effect18.catchAllCause(handleLogicFailure)
|
|
5000
4941
|
);
|
|
5001
4942
|
pendingRunForks.push(
|
|
5002
|
-
|
|
5003
|
-
const runFiber = yield*
|
|
5004
|
-
yield*
|
|
4943
|
+
Effect18.gen(function* () {
|
|
4944
|
+
const runFiber = yield* Effect18.forkScoped(withRootEnvIfAvailable(runPhase));
|
|
4945
|
+
yield* Effect18.forkScoped(
|
|
5005
4946
|
Fiber2.await(runFiber).pipe(
|
|
5006
|
-
|
|
4947
|
+
Effect18.flatMap(
|
|
5007
4948
|
(exit) => Exit3.match(exit, {
|
|
5008
|
-
onFailure: () =>
|
|
4949
|
+
onFailure: () => Effect18.void,
|
|
5009
4950
|
onSuccess: (value) => {
|
|
5010
4951
|
const executePlan = (plan) => {
|
|
5011
4952
|
const phaseRef = getPhaseRef(plan) ?? createPhaseRef();
|
|
@@ -5013,13 +4954,17 @@ var runModuleLogics = (args) => {
|
|
|
5013
4954
|
const runPlanPhase = withRuntimeAndLifecycle(plan.run, phaseRef, logicUnit);
|
|
5014
4955
|
phaseRef.current = "setup";
|
|
5015
4956
|
return setupPhase.pipe(
|
|
5016
|
-
|
|
5017
|
-
|
|
5018
|
-
|
|
4957
|
+
Effect18.catchAllCause(handleLogicFailure),
|
|
4958
|
+
Effect18.zipRight(
|
|
4959
|
+
Effect18.sync(() => {
|
|
5019
4960
|
phaseRef.current = "run";
|
|
5020
4961
|
}).pipe(
|
|
5021
|
-
|
|
5022
|
-
|
|
4962
|
+
Effect18.zipRight(
|
|
4963
|
+
Effect18.forkScoped(
|
|
4964
|
+
withRootEnvIfAvailable(runPlanPhase).pipe(Effect18.catchAllCause(handleLogicFailure))
|
|
4965
|
+
)
|
|
4966
|
+
),
|
|
4967
|
+
Effect18.asVoid
|
|
5023
4968
|
)
|
|
5024
4969
|
)
|
|
5025
4970
|
);
|
|
@@ -5033,14 +4978,14 @@ var runModuleLogics = (args) => {
|
|
|
5033
4978
|
basePhaseRef,
|
|
5034
4979
|
logicUnit
|
|
5035
4980
|
).pipe(
|
|
5036
|
-
|
|
5037
|
-
|
|
4981
|
+
Effect18.map((value2) => normalizeToPlan(value2, basePhaseRef)),
|
|
4982
|
+
Effect18.matchCauseEffect({
|
|
5038
4983
|
onFailure: (cause) => handleLogicFailure(cause),
|
|
5039
4984
|
onSuccess: (plan) => executePlan(plan)
|
|
5040
4985
|
})
|
|
5041
4986
|
);
|
|
5042
4987
|
}
|
|
5043
|
-
return
|
|
4988
|
+
return Effect18.void;
|
|
5044
4989
|
}
|
|
5045
4990
|
})
|
|
5046
4991
|
)
|
|
@@ -5050,9 +4995,9 @@ var runModuleLogics = (args) => {
|
|
|
5050
4995
|
);
|
|
5051
4996
|
continue;
|
|
5052
4997
|
}
|
|
5053
|
-
yield* lifecycle.runInitRequired.pipe(
|
|
5054
|
-
const platformOpt = yield*
|
|
5055
|
-
if (
|
|
4998
|
+
yield* lifecycle.runInitRequired.pipe(Effect18.catchAllCause(handleInitFailure));
|
|
4999
|
+
const platformOpt = yield* Effect18.serviceOption(Tag);
|
|
5000
|
+
if (Option8.isSome(platformOpt)) {
|
|
5056
5001
|
const platform = platformOpt.value;
|
|
5057
5002
|
const snapshot = yield* lifecycle.getTaskSnapshot;
|
|
5058
5003
|
const platformPhaseRef = { current: "run" };
|
|
@@ -5061,10 +5006,10 @@ var runModuleLogics = (args) => {
|
|
|
5061
5006
|
return platformPhaseRef.current;
|
|
5062
5007
|
}
|
|
5063
5008
|
};
|
|
5064
|
-
const providePlatformEnv = (eff) =>
|
|
5065
|
-
|
|
5066
|
-
|
|
5067
|
-
|
|
5009
|
+
const providePlatformEnv = (eff) => Effect18.provideService(
|
|
5010
|
+
Effect18.provideService(
|
|
5011
|
+
Effect18.provideService(
|
|
5012
|
+
Effect18.provideService(eff, Tag, platform),
|
|
5068
5013
|
LifecycleContext,
|
|
5069
5014
|
lifecycle
|
|
5070
5015
|
),
|
|
@@ -5074,13 +5019,13 @@ var runModuleLogics = (args) => {
|
|
|
5074
5019
|
LogicPhaseServiceTag,
|
|
5075
5020
|
phaseService
|
|
5076
5021
|
);
|
|
5077
|
-
const register = (label, subscribe) =>
|
|
5022
|
+
const register = (label, subscribe) => Effect18.forkScoped(
|
|
5078
5023
|
subscribe(
|
|
5079
5024
|
providePlatformEnv(
|
|
5080
5025
|
label === "suspend" ? lifecycle.runPlatformSuspend : label === "resume" ? lifecycle.runPlatformResume : lifecycle.runPlatformReset
|
|
5081
|
-
).pipe(
|
|
5026
|
+
).pipe(Effect18.asVoid)
|
|
5082
5027
|
).pipe(
|
|
5083
|
-
|
|
5028
|
+
Effect18.catchAllCause(
|
|
5084
5029
|
(cause) => lifecycle.notifyError(cause, {
|
|
5085
5030
|
phase: "platform",
|
|
5086
5031
|
hook: label,
|
|
@@ -5090,7 +5035,7 @@ var runModuleLogics = (args) => {
|
|
|
5090
5035
|
})
|
|
5091
5036
|
)
|
|
5092
5037
|
)
|
|
5093
|
-
).pipe(
|
|
5038
|
+
).pipe(Effect18.asVoid);
|
|
5094
5039
|
if (snapshot.platformSuspend.length > 0) {
|
|
5095
5040
|
yield* register("suspend", platform.lifecycle.onSuspend);
|
|
5096
5041
|
}
|
|
@@ -5101,21 +5046,21 @@ var runModuleLogics = (args) => {
|
|
|
5101
5046
|
yield* register("reset", platform.lifecycle.onReset);
|
|
5102
5047
|
}
|
|
5103
5048
|
}
|
|
5104
|
-
yield*
|
|
5049
|
+
yield* Effect18.forEach(pendingRunForks, (eff) => eff, { discard: true });
|
|
5105
5050
|
yield* lifecycle.runStart;
|
|
5106
|
-
yield*
|
|
5051
|
+
yield* Effect18.yieldNow();
|
|
5107
5052
|
});
|
|
5108
5053
|
};
|
|
5109
5054
|
|
|
5110
5055
|
// src/internal/runtime/core/ConcurrencyDiagnostics.ts
|
|
5111
|
-
import { Effect as
|
|
5056
|
+
import { Effect as Effect19, Ref as Ref2 } from "effect";
|
|
5112
5057
|
var keyOf = (trigger) => `${trigger.kind}::${typeof trigger.name === "string" ? trigger.name : ""}`;
|
|
5113
|
-
var nowMs3 =
|
|
5114
|
-
var make3 = (args) =>
|
|
5058
|
+
var nowMs3 = Effect19.clockWith((clock) => clock.currentTimeMillis);
|
|
5059
|
+
var make3 = (args) => Effect19.gen(function* () {
|
|
5115
5060
|
const pressureCooldownByKeyRef = yield* Ref2.make({});
|
|
5116
5061
|
const unboundedEnabledEmittedRef = yield* Ref2.make(false);
|
|
5117
5062
|
const unboundedBlockedEmittedRef = yield* Ref2.make(false);
|
|
5118
|
-
const emitPressureIfNeeded = (inArgs) =>
|
|
5063
|
+
const emitPressureIfNeeded = (inArgs) => Effect19.gen(function* () {
|
|
5119
5064
|
const policy = inArgs.policy;
|
|
5120
5065
|
const backlogCount = inArgs.backlogCount ?? 0;
|
|
5121
5066
|
const saturatedDurationMs = inArgs.saturatedDurationMs ?? 0;
|
|
@@ -5193,7 +5138,7 @@ var make3 = (args) => Effect20.gen(function* () {
|
|
|
5193
5138
|
}
|
|
5194
5139
|
});
|
|
5195
5140
|
});
|
|
5196
|
-
const emitUnboundedPolicyIfNeeded = (inArgs) =>
|
|
5141
|
+
const emitUnboundedPolicyIfNeeded = (inArgs) => Effect19.gen(function* () {
|
|
5197
5142
|
const policy = inArgs.policy;
|
|
5198
5143
|
if (policy.concurrencyLimit === "unbounded" && policy.allowUnbounded === true) {
|
|
5199
5144
|
const shouldEmit2 = yield* Ref2.modify(
|
|
@@ -5258,23 +5203,23 @@ var make3 = (args) => Effect20.gen(function* () {
|
|
|
5258
5203
|
return { emitPressureIfNeeded, emitUnboundedPolicyIfNeeded };
|
|
5259
5204
|
});
|
|
5260
5205
|
|
|
5261
|
-
// src/internal/runtime/core/ModuleRuntime.ts
|
|
5206
|
+
// src/internal/runtime/core/ModuleRuntime.impl.ts
|
|
5262
5207
|
var nextInstanceSeq = 0;
|
|
5263
5208
|
var makeDefaultInstanceId = () => {
|
|
5264
5209
|
nextInstanceSeq += 1;
|
|
5265
5210
|
return `i${nextInstanceSeq}`;
|
|
5266
5211
|
};
|
|
5267
5212
|
var make4 = (initialState, options = {}) => {
|
|
5268
|
-
const program =
|
|
5213
|
+
const program = Effect20.gen(function* () {
|
|
5269
5214
|
const stateRef = options.createState ? yield* options.createState : yield* SubscriptionRef3.make(initialState);
|
|
5270
5215
|
const commitHub = yield* PubSub4.unbounded();
|
|
5271
5216
|
const actionCommitHub = yield* PubSub4.unbounded();
|
|
5272
5217
|
let commitHubSubscriberCount = 0;
|
|
5273
5218
|
const fromCommitHub = Stream2.unwrapScoped(
|
|
5274
|
-
|
|
5219
|
+
Effect20.gen(function* () {
|
|
5275
5220
|
commitHubSubscriberCount += 1;
|
|
5276
|
-
yield*
|
|
5277
|
-
() =>
|
|
5221
|
+
yield* Effect20.addFinalizer(
|
|
5222
|
+
() => Effect20.sync(() => {
|
|
5278
5223
|
commitHubSubscriberCount = Math.max(0, commitHubSubscriberCount - 1);
|
|
5279
5224
|
})
|
|
5280
5225
|
);
|
|
@@ -5283,6 +5228,7 @@ var make4 = (initialState, options = {}) => {
|
|
|
5283
5228
|
);
|
|
5284
5229
|
const moduleId = options.moduleId ?? "unknown";
|
|
5285
5230
|
const instanceId = normalizeNonEmptyString(options.instanceId) ?? makeDefaultInstanceId();
|
|
5231
|
+
const moduleInstanceKey = makeModuleInstanceKey(moduleId, instanceId);
|
|
5286
5232
|
const runtimeLabel = yield* FiberRef8.get(currentRuntimeLabel);
|
|
5287
5233
|
const lifecycle = yield* makeLifecycleManager({
|
|
5288
5234
|
moduleId,
|
|
@@ -5293,8 +5239,8 @@ var make4 = (initialState, options = {}) => {
|
|
|
5293
5239
|
moduleId: options.moduleId,
|
|
5294
5240
|
instanceId
|
|
5295
5241
|
});
|
|
5296
|
-
const runtimeConfigOpt = yield*
|
|
5297
|
-
const runtimeInstrumentation =
|
|
5242
|
+
const runtimeConfigOpt = yield* Effect20.serviceOption(StateTransactionConfigTag);
|
|
5243
|
+
const runtimeInstrumentation = Option9.isSome(runtimeConfigOpt) ? runtimeConfigOpt.value.instrumentation : void 0;
|
|
5298
5244
|
const instrumentation = options.stateTransaction?.instrumentation ?? runtimeInstrumentation ?? getDefaultStateTxnInstrumentation();
|
|
5299
5245
|
const resolveTraitConvergeConfig = makeResolveTraitConvergeConfig({
|
|
5300
5246
|
moduleId: options.moduleId,
|
|
@@ -5308,7 +5254,7 @@ var make4 = (initialState, options = {}) => {
|
|
|
5308
5254
|
moduleId: options.moduleId,
|
|
5309
5255
|
stateTransaction: options.stateTransaction
|
|
5310
5256
|
});
|
|
5311
|
-
const actionHub = options.createActionHub ? yield* options.createActionHub : yield*
|
|
5257
|
+
const actionHub = options.createActionHub ? yield* options.createActionHub : yield* Effect20.gen(function* () {
|
|
5312
5258
|
const policy = yield* resolveConcurrencyPolicy();
|
|
5313
5259
|
return yield* PubSub4.bounded(policy.losslessBackpressureCapacity);
|
|
5314
5260
|
});
|
|
@@ -5324,6 +5270,8 @@ var make4 = (initialState, options = {}) => {
|
|
|
5324
5270
|
lastConvergeIrKeys: void 0,
|
|
5325
5271
|
listConfigs: []
|
|
5326
5272
|
};
|
|
5273
|
+
let externalOwnedFieldPaths = [];
|
|
5274
|
+
let externalOwnedFieldPathKeys = /* @__PURE__ */ new Set();
|
|
5327
5275
|
const rowIdStore = new RowIdStore(instanceId);
|
|
5328
5276
|
const selectorGraph = make2({
|
|
5329
5277
|
moduleId,
|
|
@@ -5345,6 +5293,72 @@ var make4 = (initialState, options = {}) => {
|
|
|
5345
5293
|
}
|
|
5346
5294
|
});
|
|
5347
5295
|
const recordStatePatch = (path, reason, from, to, traitNodeId, stepId) => {
|
|
5296
|
+
if (externalOwnedFieldPaths.length > 0) {
|
|
5297
|
+
const registry = txnContext.current?.fieldPathIdRegistry;
|
|
5298
|
+
const toFieldPathOrStar = (input) => {
|
|
5299
|
+
if (input === void 0) return void 0;
|
|
5300
|
+
if (input === "*") return "*";
|
|
5301
|
+
if (typeof input === "number") {
|
|
5302
|
+
if (!registry) return "*";
|
|
5303
|
+
if (!Number.isFinite(input)) return "*";
|
|
5304
|
+
const idx = Math.floor(input);
|
|
5305
|
+
if (idx < 0) return "*";
|
|
5306
|
+
const resolved2 = registry.fieldPaths[idx];
|
|
5307
|
+
return resolved2 && Array.isArray(resolved2) ? resolved2 : "*";
|
|
5308
|
+
}
|
|
5309
|
+
if (typeof input === "string") {
|
|
5310
|
+
if (!registry) return "*";
|
|
5311
|
+
const id = registry.pathStringToId?.get(input);
|
|
5312
|
+
if (id == null) return "*";
|
|
5313
|
+
const resolved2 = registry.fieldPaths[id];
|
|
5314
|
+
return resolved2 && Array.isArray(resolved2) ? resolved2 : "*";
|
|
5315
|
+
}
|
|
5316
|
+
const normalized = normalizeFieldPath(input);
|
|
5317
|
+
return normalized ?? "*";
|
|
5318
|
+
};
|
|
5319
|
+
const resolved = toFieldPathOrStar(path);
|
|
5320
|
+
const throwViolation = (details) => {
|
|
5321
|
+
const owned = details.owned ?? externalOwnedFieldPaths[0];
|
|
5322
|
+
const ownedPath = owned ? owned.join(".") : "<unknown>";
|
|
5323
|
+
const resolvedPath = details.resolvedPath === void 0 ? "<unknown>" : details.resolvedPath === "*" ? "*" : details.resolvedPath.join(".");
|
|
5324
|
+
const err = new Error(
|
|
5325
|
+
`[ExternalOwnedWriteError] State write overlaps an external-owned field.
|
|
5326
|
+
moduleId=${options.moduleId ?? "unknown"}
|
|
5327
|
+
instanceId=${instanceId}
|
|
5328
|
+
owned=${ownedPath}
|
|
5329
|
+
path=${resolvedPath}
|
|
5330
|
+
reason=${String(reason)}
|
|
5331
|
+
Fix: do not write external-owned fields via reducers/$.state.*; use StateTrait.externalStore to own the field, and avoid setState/state.update (root writes) on modules with external-owned fields.`
|
|
5332
|
+
);
|
|
5333
|
+
err.name = "ExternalOwnedWriteError";
|
|
5334
|
+
err._tag = "ExternalOwnedWriteError";
|
|
5335
|
+
err.moduleId = options.moduleId;
|
|
5336
|
+
err.instanceId = instanceId;
|
|
5337
|
+
err.reason = reason;
|
|
5338
|
+
err.path = path;
|
|
5339
|
+
throw err;
|
|
5340
|
+
};
|
|
5341
|
+
const ensureFieldPath = (input) => {
|
|
5342
|
+
if (input === void 0 || input === "*") {
|
|
5343
|
+
return throwViolation({ resolvedPath: input });
|
|
5344
|
+
}
|
|
5345
|
+
return input;
|
|
5346
|
+
};
|
|
5347
|
+
if (reason === "trait-external-store") {
|
|
5348
|
+
const resolvedFieldPath = ensureFieldPath(resolved);
|
|
5349
|
+
const key = JSON.stringify(resolvedFieldPath);
|
|
5350
|
+
if (!externalOwnedFieldPathKeys.has(key)) {
|
|
5351
|
+
throwViolation({ resolvedPath: resolvedFieldPath });
|
|
5352
|
+
}
|
|
5353
|
+
} else {
|
|
5354
|
+
const resolvedFieldPath = ensureFieldPath(resolved);
|
|
5355
|
+
for (const owned of externalOwnedFieldPaths) {
|
|
5356
|
+
if (isPrefixOf(owned, resolvedFieldPath) || isPrefixOf(resolvedFieldPath, owned)) {
|
|
5357
|
+
throwViolation({ resolvedPath: resolvedFieldPath, owned });
|
|
5358
|
+
}
|
|
5359
|
+
}
|
|
5360
|
+
}
|
|
5361
|
+
}
|
|
5348
5362
|
recordPatch(txnContext, path, reason, from, to, traitNodeId, stepId);
|
|
5349
5363
|
};
|
|
5350
5364
|
const updateDraft2 = (nextState) => {
|
|
@@ -5373,8 +5387,8 @@ var make4 = (initialState, options = {}) => {
|
|
|
5373
5387
|
const runtimeServicesOverrides = yield* resolveRuntimeServicesOverrides({
|
|
5374
5388
|
moduleId: options.moduleId
|
|
5375
5389
|
});
|
|
5376
|
-
const runtimeServicesRegistryOpt = yield*
|
|
5377
|
-
const runtimeServicesRegistry =
|
|
5390
|
+
const runtimeServicesRegistryOpt = yield* Effect20.serviceOption(RuntimeServicesRegistryTag);
|
|
5391
|
+
const runtimeServicesRegistry = Option9.isSome(runtimeServicesRegistryOpt) ? runtimeServicesRegistryOpt.value : void 0;
|
|
5378
5392
|
const resolveRuntimeServiceImpls = (serviceId, builtin) => {
|
|
5379
5393
|
const extraRaw = runtimeServicesRegistry?.implsByServiceId[serviceId];
|
|
5380
5394
|
if (!extraRaw || extraRaw.length === 0) return builtin;
|
|
@@ -5416,12 +5430,12 @@ var make4 = (initialState, options = {}) => {
|
|
|
5416
5430
|
]),
|
|
5417
5431
|
runtimeServicesOverrides
|
|
5418
5432
|
);
|
|
5419
|
-
const
|
|
5420
|
-
|
|
5421
|
-
getBuiltinMake: (serviceId) => serviceId === "txnQueue" ? makeTxnQueueBuiltin :
|
|
5433
|
+
const enqueueTransactionBase = yield* enqueueTxnSel.impl.make.pipe(
|
|
5434
|
+
Effect20.provideService(RuntimeServiceBuiltinsTag, {
|
|
5435
|
+
getBuiltinMake: (serviceId) => serviceId === "txnQueue" ? makeTxnQueueBuiltin : Effect20.dieMessage(`[Logix] builtin make not available: ${serviceId}`)
|
|
5422
5436
|
})
|
|
5423
5437
|
);
|
|
5424
|
-
const makeOperationRunnerBuiltin =
|
|
5438
|
+
const makeOperationRunnerBuiltin = Effect20.succeed(
|
|
5425
5439
|
makeRunOperation({
|
|
5426
5440
|
optionsModuleId: options.moduleId,
|
|
5427
5441
|
instanceId,
|
|
@@ -5440,8 +5454,8 @@ var make4 = (initialState, options = {}) => {
|
|
|
5440
5454
|
runtimeServicesOverrides
|
|
5441
5455
|
);
|
|
5442
5456
|
const runOperation = yield* runOperationSel.impl.make.pipe(
|
|
5443
|
-
|
|
5444
|
-
getBuiltinMake: (serviceId) => serviceId === "operationRunner" ? makeOperationRunnerBuiltin :
|
|
5457
|
+
Effect20.provideService(RuntimeServiceBuiltinsTag, {
|
|
5458
|
+
getBuiltinMake: (serviceId) => serviceId === "operationRunner" ? makeOperationRunnerBuiltin : Effect20.dieMessage(`[Logix] builtin make not available: ${serviceId}`)
|
|
5445
5459
|
})
|
|
5446
5460
|
);
|
|
5447
5461
|
yield* runOperation(
|
|
@@ -5467,7 +5481,34 @@ var make4 = (initialState, options = {}) => {
|
|
|
5467
5481
|
txnSeq: 0
|
|
5468
5482
|
})
|
|
5469
5483
|
);
|
|
5470
|
-
const
|
|
5484
|
+
const runtimeStoreOpt = yield* Effect20.serviceOption(RuntimeStoreTag);
|
|
5485
|
+
if (Option9.isSome(runtimeStoreOpt)) {
|
|
5486
|
+
runtimeStoreOpt.value.registerModuleInstance({
|
|
5487
|
+
moduleId,
|
|
5488
|
+
instanceId,
|
|
5489
|
+
moduleInstanceKey,
|
|
5490
|
+
initialState: initialSnapshot
|
|
5491
|
+
});
|
|
5492
|
+
}
|
|
5493
|
+
const rootContextSvcOpt = yield* Effect20.serviceOption(RootContextTag);
|
|
5494
|
+
const rootContext = Option9.isSome(rootContextSvcOpt) ? rootContextSvcOpt.value : void 0;
|
|
5495
|
+
const tickSchedulerOpt = yield* Effect20.serviceOption(TickSchedulerTag);
|
|
5496
|
+
let tickSchedulerCached = Option9.isSome(tickSchedulerOpt) ? tickSchedulerOpt.value : void 0;
|
|
5497
|
+
const enqueueTransaction = ((a0, a1) => Effect20.gen(function* () {
|
|
5498
|
+
if (!tickSchedulerCached) {
|
|
5499
|
+
const refreshed = yield* Effect20.serviceOption(TickSchedulerTag);
|
|
5500
|
+
if (Option9.isSome(refreshed)) {
|
|
5501
|
+
tickSchedulerCached = refreshed.value;
|
|
5502
|
+
} else if (rootContext?.context) {
|
|
5503
|
+
const fromRoot = Context2.getOption(rootContext.context, TickSchedulerTag);
|
|
5504
|
+
if (Option9.isSome(fromRoot)) {
|
|
5505
|
+
tickSchedulerCached = fromRoot.value;
|
|
5506
|
+
}
|
|
5507
|
+
}
|
|
5508
|
+
}
|
|
5509
|
+
return yield* a1 !== void 0 ? enqueueTransactionBase(a0, a1) : enqueueTransactionBase(a0);
|
|
5510
|
+
}));
|
|
5511
|
+
const makeTransactionBuiltin = Effect20.sync(
|
|
5471
5512
|
() => makeTransactionOps({
|
|
5472
5513
|
moduleId,
|
|
5473
5514
|
optionsModuleId: options.moduleId,
|
|
@@ -5476,7 +5517,73 @@ var make4 = (initialState, options = {}) => {
|
|
|
5476
5517
|
commitHub,
|
|
5477
5518
|
shouldPublishCommitHub: () => commitHubSubscriberCount > 0,
|
|
5478
5519
|
recordStatePatch,
|
|
5479
|
-
onCommit: ({ state, meta, dirtySet, diagnosticsLevel }) =>
|
|
5520
|
+
onCommit: ({ state, meta, dirtySet, diagnosticsLevel }) => Effect20.gen(function* () {
|
|
5521
|
+
let scheduler = tickSchedulerCached;
|
|
5522
|
+
if (!scheduler) {
|
|
5523
|
+
const refreshed = yield* Effect20.serviceOption(TickSchedulerTag);
|
|
5524
|
+
if (Option9.isSome(refreshed)) {
|
|
5525
|
+
scheduler = refreshed.value;
|
|
5526
|
+
tickSchedulerCached = refreshed.value;
|
|
5527
|
+
}
|
|
5528
|
+
}
|
|
5529
|
+
let root = rootContext;
|
|
5530
|
+
if (!root) {
|
|
5531
|
+
const rootOpt = yield* Effect20.serviceOption(RootContextTag);
|
|
5532
|
+
if (Option9.isSome(rootOpt)) {
|
|
5533
|
+
root = rootOpt.value;
|
|
5534
|
+
}
|
|
5535
|
+
}
|
|
5536
|
+
if (!scheduler && root?.context) {
|
|
5537
|
+
const fromRoot = Context2.getOption(root.context, TickSchedulerTag);
|
|
5538
|
+
if (Option9.isSome(fromRoot)) {
|
|
5539
|
+
scheduler = fromRoot.value;
|
|
5540
|
+
tickSchedulerCached = fromRoot.value;
|
|
5541
|
+
}
|
|
5542
|
+
}
|
|
5543
|
+
if (!scheduler && diagnosticsLevel !== "off" && isDevEnv()) {
|
|
5544
|
+
yield* record({
|
|
5545
|
+
type: "diagnostic",
|
|
5546
|
+
moduleId,
|
|
5547
|
+
instanceId,
|
|
5548
|
+
txnSeq: meta.txnSeq,
|
|
5549
|
+
txnId: meta.txnId,
|
|
5550
|
+
trigger: {
|
|
5551
|
+
kind: meta.originKind ?? "unknown",
|
|
5552
|
+
name: meta.originName ?? meta.originKind ?? "unknown"
|
|
5553
|
+
},
|
|
5554
|
+
code: "tick_scheduler::missing_service",
|
|
5555
|
+
severity: "error",
|
|
5556
|
+
message: "TickScheduler service is not visible in ModuleRuntime.onCommit; tickSeq will not advance and RuntimeStore subscribers will not flush.",
|
|
5557
|
+
hint: "Ensure TickSchedulerTag is available in the fiber Env for logic/task/txnQueue execution (AppRuntime baseLayer + RootContext wiring).",
|
|
5558
|
+
kind: "missing_tick_scheduler"
|
|
5559
|
+
});
|
|
5560
|
+
}
|
|
5561
|
+
yield* selectorGraph.onCommit(
|
|
5562
|
+
state,
|
|
5563
|
+
meta,
|
|
5564
|
+
dirtySet,
|
|
5565
|
+
diagnosticsLevel,
|
|
5566
|
+
scheduler ? (selectorId) => {
|
|
5567
|
+
scheduler.onSelectorChanged({
|
|
5568
|
+
moduleInstanceKey,
|
|
5569
|
+
selectorId,
|
|
5570
|
+
priority: meta.priority
|
|
5571
|
+
});
|
|
5572
|
+
} : void 0
|
|
5573
|
+
);
|
|
5574
|
+
if (scheduler) {
|
|
5575
|
+
const opSeqRaw = yield* FiberRef8.get(currentOpSeq);
|
|
5576
|
+
const opSeq = typeof opSeqRaw === "number" && Number.isFinite(opSeqRaw) && opSeqRaw >= 0 ? Math.floor(opSeqRaw) : void 0;
|
|
5577
|
+
yield* scheduler.onModuleCommit({
|
|
5578
|
+
moduleId,
|
|
5579
|
+
instanceId,
|
|
5580
|
+
moduleInstanceKey,
|
|
5581
|
+
state,
|
|
5582
|
+
meta,
|
|
5583
|
+
opSeq
|
|
5584
|
+
});
|
|
5585
|
+
}
|
|
5586
|
+
}),
|
|
5480
5587
|
enqueueTransaction,
|
|
5481
5588
|
runOperation,
|
|
5482
5589
|
txnContext,
|
|
@@ -5511,8 +5618,8 @@ var make4 = (initialState, options = {}) => {
|
|
|
5511
5618
|
runtimeServicesOverrides
|
|
5512
5619
|
);
|
|
5513
5620
|
const { readState, setStateInternal, runWithStateTransaction } = yield* transactionSel.impl.make.pipe(
|
|
5514
|
-
|
|
5515
|
-
getBuiltinMake: (serviceId) => serviceId === "transaction" ? makeTransactionBuiltin :
|
|
5621
|
+
Effect20.provideService(RuntimeServiceBuiltinsTag, {
|
|
5622
|
+
getBuiltinMake: (serviceId) => serviceId === "transaction" ? makeTransactionBuiltin : Effect20.dieMessage(`[Logix] builtin make not available: ${serviceId}`)
|
|
5516
5623
|
})
|
|
5517
5624
|
);
|
|
5518
5625
|
let deferredFlushCoalescedCount = 0;
|
|
@@ -5545,7 +5652,7 @@ var make4 = (initialState, options = {}) => {
|
|
|
5545
5652
|
name: "trait:deferredConvergeFlush",
|
|
5546
5653
|
details
|
|
5547
5654
|
},
|
|
5548
|
-
() =>
|
|
5655
|
+
() => Effect20.gen(function* () {
|
|
5549
5656
|
const current = txnContext.current;
|
|
5550
5657
|
if (current) {
|
|
5551
5658
|
capturedTxnSeq = current.txnSeq;
|
|
@@ -5570,16 +5677,16 @@ var make4 = (initialState, options = {}) => {
|
|
|
5570
5677
|
)
|
|
5571
5678
|
)
|
|
5572
5679
|
).pipe(
|
|
5573
|
-
|
|
5680
|
+
Effect20.as({
|
|
5574
5681
|
txnSeq: capturedTxnSeq,
|
|
5575
5682
|
txnId: capturedTxnId,
|
|
5576
5683
|
opSeq: capturedOpSeq
|
|
5577
5684
|
})
|
|
5578
5685
|
);
|
|
5579
5686
|
};
|
|
5580
|
-
yield*
|
|
5581
|
-
|
|
5582
|
-
|
|
5687
|
+
yield* Effect20.forkScoped(
|
|
5688
|
+
Effect20.forever(
|
|
5689
|
+
Effect20.gen(function* () {
|
|
5583
5690
|
yield* Queue3.take(traitConvergeTimeSlicingState.signal);
|
|
5584
5691
|
while (true) {
|
|
5585
5692
|
const config = traitConvergeTimeSlicingState.latestConvergeConfig?.traitConvergeTimeSlicing;
|
|
@@ -5594,7 +5701,7 @@ var make4 = (initialState, options = {}) => {
|
|
|
5594
5701
|
const firstPendingAtMs2 = traitConvergeTimeSlicingState.firstPendingAtMs ?? now;
|
|
5595
5702
|
traitConvergeTimeSlicingState.firstPendingAtMs = firstPendingAtMs2;
|
|
5596
5703
|
const captured2 = traitConvergeTimeSlicingState.capturedContext;
|
|
5597
|
-
const txnLanePolicy2 = yield* captured2?.overrides ?
|
|
5704
|
+
const txnLanePolicy2 = yield* captured2?.overrides ? Effect20.provideService(resolveTxnLanePolicy(), StateTransactionOverridesTag, captured2.overrides) : resolveTxnLanePolicy();
|
|
5598
5705
|
const debounceMs = txnLanePolicy2.enabled ? txnLanePolicy2.debounceMs : config.debounceMs;
|
|
5599
5706
|
const maxLagMs = txnLanePolicy2.enabled ? txnLanePolicy2.maxLagMs : config.maxLagMs;
|
|
5600
5707
|
const elapsedMs = Math.max(0, now - firstPendingAtMs2);
|
|
@@ -5604,9 +5711,9 @@ var make4 = (initialState, options = {}) => {
|
|
|
5604
5711
|
}
|
|
5605
5712
|
const sleepMs = Math.max(0, Math.min(debounceMs, remainingLagMs));
|
|
5606
5713
|
if (sleepMs > 0) {
|
|
5607
|
-
yield*
|
|
5714
|
+
yield* Effect20.sleep(Duration.millis(sleepMs));
|
|
5608
5715
|
} else {
|
|
5609
|
-
yield*
|
|
5716
|
+
yield* Effect20.yieldNow();
|
|
5610
5717
|
}
|
|
5611
5718
|
const drained = yield* Queue3.takeAll(traitConvergeTimeSlicingState.signal);
|
|
5612
5719
|
if (Chunk3.isEmpty(drained)) {
|
|
@@ -5628,19 +5735,19 @@ var make4 = (initialState, options = {}) => {
|
|
|
5628
5735
|
return;
|
|
5629
5736
|
}
|
|
5630
5737
|
const captured = traitConvergeTimeSlicingState.capturedContext;
|
|
5631
|
-
const txnLanePolicy = yield* captured?.overrides ?
|
|
5738
|
+
const txnLanePolicy = yield* captured?.overrides ? Effect20.provideService(resolveTxnLanePolicy(), StateTransactionOverridesTag, captured.overrides) : resolveTxnLanePolicy();
|
|
5632
5739
|
const shouldEmitLaneEvidence = captured != null && captured.diagnosticsLevel !== "off";
|
|
5633
5740
|
const shouldEmitLaneEvidenceForPolicy = shouldEmitLaneEvidence && (txnLanePolicy.enabled || txnLanePolicy.overrideMode != null);
|
|
5634
5741
|
const withCapturedContext = (eff) => {
|
|
5635
5742
|
let next = eff;
|
|
5636
5743
|
if (captured?.overrides) {
|
|
5637
|
-
next =
|
|
5744
|
+
next = Effect20.provideService(next, StateTransactionOverridesTag, captured.overrides);
|
|
5638
5745
|
}
|
|
5639
5746
|
if (captured) {
|
|
5640
5747
|
next = next.pipe(
|
|
5641
|
-
|
|
5642
|
-
|
|
5643
|
-
|
|
5748
|
+
Effect20.locally(currentRuntimeLabel, captured.runtimeLabel),
|
|
5749
|
+
Effect20.locally(currentDiagnosticsLevel, captured.diagnosticsLevel),
|
|
5750
|
+
Effect20.locally(currentDebugSinks, captured.debugSinks)
|
|
5644
5751
|
);
|
|
5645
5752
|
}
|
|
5646
5753
|
return next;
|
|
@@ -5712,7 +5819,7 @@ var make4 = (initialState, options = {}) => {
|
|
|
5712
5819
|
const sliceStart = cursor;
|
|
5713
5820
|
const sliceEnd = Math.min(totalSteps, cursor + chunkSize);
|
|
5714
5821
|
const { sliceDurationMs, anchor } = yield* withCapturedContext(
|
|
5715
|
-
|
|
5822
|
+
Effect20.gen(function* () {
|
|
5716
5823
|
const sliceStartedAtMs = Date.now();
|
|
5717
5824
|
const anchor2 = yield* runDeferredConvergeFlush({
|
|
5718
5825
|
dirtyPathsSnapshot,
|
|
@@ -5737,7 +5844,7 @@ var make4 = (initialState, options = {}) => {
|
|
|
5737
5844
|
const yieldReason = !shouldYield ? "none" : inputPending ? "input_pending" : budgetExceeded ? "budget_exceeded" : "forced_frame_yield";
|
|
5738
5845
|
if (shouldEmitLaneEvidence) {
|
|
5739
5846
|
yield* withCapturedContext(
|
|
5740
|
-
|
|
5847
|
+
Effect20.gen(function* () {
|
|
5741
5848
|
const reasons = ["queued_non_urgent"];
|
|
5742
5849
|
if (lagExceeded) reasons.push("max_lag_forced", "starvation_protection");
|
|
5743
5850
|
if (yieldReason === "budget_exceeded") reasons.push("budget_yield");
|
|
@@ -5833,7 +5940,7 @@ var make4 = (initialState, options = {}) => {
|
|
|
5833
5940
|
if (shouldYield) {
|
|
5834
5941
|
yieldCount += 1;
|
|
5835
5942
|
lastYieldAtMs = Date.now();
|
|
5836
|
-
yield*
|
|
5943
|
+
yield* Effect20.yieldNow();
|
|
5837
5944
|
}
|
|
5838
5945
|
}
|
|
5839
5946
|
if (traitConvergeTimeSlicingState.backlogDirtyPaths.size > 0 || traitConvergeTimeSlicingState.backlogDirtyAllReason != null) {
|
|
@@ -5849,7 +5956,7 @@ var make4 = (initialState, options = {}) => {
|
|
|
5849
5956
|
}
|
|
5850
5957
|
return new Set(Object.keys(actionMap));
|
|
5851
5958
|
})();
|
|
5852
|
-
const makeDispatchBuiltin =
|
|
5959
|
+
const makeDispatchBuiltin = Effect20.sync(
|
|
5853
5960
|
() => makeDispatchOps({
|
|
5854
5961
|
optionsModuleId: options.moduleId,
|
|
5855
5962
|
instanceId,
|
|
@@ -5881,8 +5988,8 @@ var make4 = (initialState, options = {}) => {
|
|
|
5881
5988
|
runtimeServicesOverrides
|
|
5882
5989
|
);
|
|
5883
5990
|
const dispatchOps = yield* dispatchSel.impl.make.pipe(
|
|
5884
|
-
|
|
5885
|
-
getBuiltinMake: (serviceId) => serviceId === "dispatch" ? makeDispatchBuiltin :
|
|
5991
|
+
Effect20.provideService(RuntimeServiceBuiltinsTag, {
|
|
5992
|
+
getBuiltinMake: (serviceId) => serviceId === "dispatch" ? makeDispatchBuiltin : Effect20.dieMessage(`[Logix] builtin make not available: ${serviceId}`)
|
|
5886
5993
|
})
|
|
5887
5994
|
);
|
|
5888
5995
|
const runtimeServicesEvidence = makeRuntimeServicesEvidence({
|
|
@@ -5897,8 +6004,8 @@ var make4 = (initialState, options = {}) => {
|
|
|
5897
6004
|
]
|
|
5898
6005
|
});
|
|
5899
6006
|
if (kernelImplementationRef.kernelId !== "core") {
|
|
5900
|
-
const modeOpt = yield*
|
|
5901
|
-
const mode =
|
|
6007
|
+
const modeOpt = yield* Effect20.serviceOption(FullCutoverGateModeTag);
|
|
6008
|
+
const mode = Option9.isSome(modeOpt) ? modeOpt.value : "trial";
|
|
5902
6009
|
if (mode === "fullCutover") {
|
|
5903
6010
|
const gate = evaluateFullCutoverGate({
|
|
5904
6011
|
mode: "fullCutover",
|
|
@@ -5947,9 +6054,9 @@ var make4 = (initialState, options = {}) => {
|
|
|
5947
6054
|
const compiled = input?.staticIr != null && typeof input?.lane === "string" && typeof input?.producer === "string" ? input : compile(input);
|
|
5948
6055
|
if (compiled.lane !== "static") {
|
|
5949
6056
|
return Stream2.unwrapScoped(
|
|
5950
|
-
|
|
5951
|
-
const strictGateOpt = yield*
|
|
5952
|
-
if (
|
|
6057
|
+
Effect20.gen(function* () {
|
|
6058
|
+
const strictGateOpt = yield* Effect20.serviceOption(ReadQueryStrictGateConfigTag);
|
|
6059
|
+
if (Option9.isSome(strictGateOpt)) {
|
|
5953
6060
|
const decision = evaluateStrictGate({
|
|
5954
6061
|
config: strictGateOpt.value,
|
|
5955
6062
|
moduleId,
|
|
@@ -5961,7 +6068,7 @@ var make4 = (initialState, options = {}) => {
|
|
|
5961
6068
|
yield* record(decision.diagnostic);
|
|
5962
6069
|
} else if (decision.verdict === "FAIL") {
|
|
5963
6070
|
yield* record(decision.diagnostic);
|
|
5964
|
-
yield*
|
|
6071
|
+
yield* Effect20.die(decision.error);
|
|
5965
6072
|
}
|
|
5966
6073
|
}
|
|
5967
6074
|
return Stream2.map(fromCommitHub, ({ value, meta }) => ({
|
|
@@ -5972,11 +6079,11 @@ var make4 = (initialState, options = {}) => {
|
|
|
5972
6079
|
);
|
|
5973
6080
|
}
|
|
5974
6081
|
return Stream2.unwrapScoped(
|
|
5975
|
-
|
|
6082
|
+
Effect20.gen(function* () {
|
|
5976
6083
|
const entry = yield* selectorGraph.ensureEntry(compiled);
|
|
5977
6084
|
entry.subscriberCount += 1;
|
|
5978
|
-
yield*
|
|
5979
|
-
() =>
|
|
6085
|
+
yield* Effect20.addFinalizer(
|
|
6086
|
+
() => Effect20.sync(() => {
|
|
5980
6087
|
selectorGraph.releaseEntry(compiled.selectorId);
|
|
5981
6088
|
})
|
|
5982
6089
|
);
|
|
@@ -5998,14 +6105,14 @@ var make4 = (initialState, options = {}) => {
|
|
|
5998
6105
|
return stateRef;
|
|
5999
6106
|
}
|
|
6000
6107
|
const readonlyRef = {
|
|
6001
|
-
get:
|
|
6002
|
-
modify: () =>
|
|
6108
|
+
get: Effect20.map(SubscriptionRef3.get(stateRef), selector),
|
|
6109
|
+
modify: () => Effect20.dieMessage("Cannot write to a derived ref")
|
|
6003
6110
|
};
|
|
6004
6111
|
const derived = {
|
|
6005
6112
|
// SubscriptionRef internals access self.ref / self.pubsub / self.semaphore.
|
|
6006
6113
|
ref: readonlyRef,
|
|
6007
6114
|
pubsub: {
|
|
6008
|
-
publish: () =>
|
|
6115
|
+
publish: () => Effect20.succeed(true)
|
|
6009
6116
|
},
|
|
6010
6117
|
semaphore: {
|
|
6011
6118
|
withPermits: () => (self) => self
|
|
@@ -6020,8 +6127,8 @@ var make4 = (initialState, options = {}) => {
|
|
|
6020
6127
|
};
|
|
6021
6128
|
setKernelImplementationRef(runtime, kernelImplementationRef);
|
|
6022
6129
|
setRuntimeServicesEvidence(runtime, runtimeServicesEvidence);
|
|
6023
|
-
const collectorOpt = yield*
|
|
6024
|
-
if (
|
|
6130
|
+
const collectorOpt = yield* Effect20.serviceOption(EvidenceCollectorTag);
|
|
6131
|
+
if (Option9.isSome(collectorOpt)) {
|
|
6025
6132
|
collectorOpt.value.setKernelImplementationRef(kernelImplementationRef);
|
|
6026
6133
|
const level = yield* FiberRef8.get(currentDiagnosticsLevel);
|
|
6027
6134
|
if (level !== "off") {
|
|
@@ -6036,15 +6143,15 @@ var make4 = (initialState, options = {}) => {
|
|
|
6036
6143
|
}
|
|
6037
6144
|
};
|
|
6038
6145
|
const sourceRefreshRegistry = /* @__PURE__ */ new Map();
|
|
6039
|
-
yield*
|
|
6040
|
-
() =>
|
|
6146
|
+
yield* Effect20.addFinalizer(
|
|
6147
|
+
() => Effect20.sync(() => {
|
|
6041
6148
|
sourceRefreshRegistry.clear();
|
|
6042
6149
|
})
|
|
6043
6150
|
);
|
|
6044
6151
|
const importsMap = /* @__PURE__ */ new Map();
|
|
6045
6152
|
for (const imported of options.imports ?? []) {
|
|
6046
|
-
const maybe = yield*
|
|
6047
|
-
if (
|
|
6153
|
+
const maybe = yield* Effect20.serviceOption(imported);
|
|
6154
|
+
if (Option9.isSome(maybe)) {
|
|
6048
6155
|
importsMap.set(imported, maybe.value);
|
|
6049
6156
|
}
|
|
6050
6157
|
}
|
|
@@ -6098,6 +6205,9 @@ var make4 = (initialState, options = {}) => {
|
|
|
6098
6205
|
convergeExecIr
|
|
6099
6206
|
};
|
|
6100
6207
|
traitState.listConfigs = collectListConfigs(program2.spec);
|
|
6208
|
+
const owned = (program2?.entries ?? []).filter((e) => e && e.kind === "externalStore" && typeof e.fieldPath === "string").map((e) => normalizeFieldPath(e.fieldPath)).filter((p) => p != null).sort(compareFieldPath);
|
|
6209
|
+
externalOwnedFieldPaths = owned;
|
|
6210
|
+
externalOwnedFieldPathKeys = new Set(owned.map((p) => JSON.stringify(p)));
|
|
6101
6211
|
if (!traitState.convergePlanCache) {
|
|
6102
6212
|
traitState.convergePlanCache = new ConvergePlanCache(convergePlanCacheCapacity);
|
|
6103
6213
|
}
|
|
@@ -6148,7 +6258,7 @@ var make4 = (initialState, options = {}) => {
|
|
|
6148
6258
|
)
|
|
6149
6259
|
);
|
|
6150
6260
|
const applyTransactionSnapshot = (txnId, mode) => enqueueTransaction(
|
|
6151
|
-
|
|
6261
|
+
Effect20.gen(function* () {
|
|
6152
6262
|
if (!isDevEnv()) {
|
|
6153
6263
|
return;
|
|
6154
6264
|
}
|
|
@@ -6169,7 +6279,7 @@ var make4 = (initialState, options = {}) => {
|
|
|
6169
6279
|
mode
|
|
6170
6280
|
}
|
|
6171
6281
|
},
|
|
6172
|
-
() =>
|
|
6282
|
+
() => Effect20.sync(() => {
|
|
6173
6283
|
updateDraft(txnContext, targetState);
|
|
6174
6284
|
recordPatch(txnContext, "*", "devtools");
|
|
6175
6285
|
})
|
|
@@ -6257,17 +6367,24 @@ var make4 = (initialState, options = {}) => {
|
|
|
6257
6367
|
}
|
|
6258
6368
|
};
|
|
6259
6369
|
yield* installInternalHooks({ runtime, runtimeInternals });
|
|
6260
|
-
yield*
|
|
6261
|
-
() =>
|
|
6370
|
+
yield* Effect20.addFinalizer(
|
|
6371
|
+
() => Effect20.sync(() => {
|
|
6262
6372
|
importsMap.clear();
|
|
6263
6373
|
})
|
|
6264
6374
|
);
|
|
6375
|
+
yield* Effect20.addFinalizer(
|
|
6376
|
+
() => Effect20.sync(() => {
|
|
6377
|
+
if (Option9.isSome(runtimeStoreOpt)) {
|
|
6378
|
+
runtimeStoreOpt.value.unregisterModuleInstance(moduleInstanceKey);
|
|
6379
|
+
}
|
|
6380
|
+
})
|
|
6381
|
+
);
|
|
6265
6382
|
if (options.tag) {
|
|
6266
6383
|
registerRuntime(options.tag, runtime);
|
|
6267
6384
|
}
|
|
6268
|
-
yield*
|
|
6385
|
+
yield* Effect20.addFinalizer(
|
|
6269
6386
|
() => lifecycle.runDestroy.pipe(
|
|
6270
|
-
|
|
6387
|
+
Effect20.flatMap(
|
|
6271
6388
|
() => runOperation(
|
|
6272
6389
|
"lifecycle",
|
|
6273
6390
|
"module:destroy",
|
|
@@ -6279,8 +6396,8 @@ var make4 = (initialState, options = {}) => {
|
|
|
6279
6396
|
})
|
|
6280
6397
|
)
|
|
6281
6398
|
),
|
|
6282
|
-
|
|
6283
|
-
() =>
|
|
6399
|
+
Effect20.tap(
|
|
6400
|
+
() => Effect20.sync(() => {
|
|
6284
6401
|
if (options.tag) {
|
|
6285
6402
|
unregisterRuntime(options.tag);
|
|
6286
6403
|
}
|
|
@@ -6302,20 +6419,20 @@ var make4 = (initialState, options = {}) => {
|
|
|
6302
6419
|
});
|
|
6303
6420
|
}
|
|
6304
6421
|
if (options.processes && options.processes.length > 0) {
|
|
6305
|
-
const env = yield*
|
|
6422
|
+
const env = yield* Effect20.context();
|
|
6306
6423
|
const rootContextOpt = Context2.getOption(env, RootContextTag);
|
|
6307
|
-
const isAppModule =
|
|
6424
|
+
const isAppModule = Option9.isSome(rootContextOpt) && Array.isArray(rootContextOpt.value.appModuleIds) && rootContextOpt.value.appModuleIds.includes(moduleId);
|
|
6308
6425
|
if (!isAppModule) {
|
|
6309
6426
|
const processRuntimeOpt = Context2.getOption(env, ProcessRuntimeTag);
|
|
6310
|
-
const processRuntime =
|
|
6427
|
+
const processRuntime = Option9.isSome(processRuntimeOpt) ? processRuntimeOpt.value : void 0;
|
|
6311
6428
|
const scope = {
|
|
6312
6429
|
type: "moduleInstance",
|
|
6313
6430
|
moduleId,
|
|
6314
6431
|
instanceId
|
|
6315
6432
|
};
|
|
6316
|
-
yield*
|
|
6433
|
+
yield* Effect20.forEach(
|
|
6317
6434
|
options.processes,
|
|
6318
|
-
(process) =>
|
|
6435
|
+
(process) => Effect20.gen(function* () {
|
|
6319
6436
|
if (processRuntime) {
|
|
6320
6437
|
const installEffect = processRuntime.install(process, {
|
|
6321
6438
|
scope,
|
|
@@ -6323,13 +6440,13 @@ var make4 = (initialState, options = {}) => {
|
|
|
6323
6440
|
installedAt: "moduleRuntime"
|
|
6324
6441
|
});
|
|
6325
6442
|
const installation = options.tag ? yield* installEffect.pipe(
|
|
6326
|
-
|
|
6443
|
+
Effect20.provideService(options.tag, runtime)
|
|
6327
6444
|
) : yield* installEffect;
|
|
6328
6445
|
if (installation !== void 0) {
|
|
6329
6446
|
return;
|
|
6330
6447
|
}
|
|
6331
6448
|
}
|
|
6332
|
-
yield*
|
|
6449
|
+
yield* Effect20.forkScoped(process);
|
|
6333
6450
|
}),
|
|
6334
6451
|
{ discard: true }
|
|
6335
6452
|
);
|
|
@@ -6349,11 +6466,8 @@ export {
|
|
|
6349
6466
|
execVmModeLayer,
|
|
6350
6467
|
getRuntimeByModuleAndInstance,
|
|
6351
6468
|
makeEnqueueTransaction,
|
|
6352
|
-
getLogicUnitMeta,
|
|
6353
|
-
attachLogicUnitMeta,
|
|
6354
|
-
updateLogicUnitMeta,
|
|
6355
6469
|
markAsLogicPlanEffect,
|
|
6356
6470
|
isLogicPlanEffect,
|
|
6357
6471
|
make4 as make
|
|
6358
6472
|
};
|
|
6359
|
-
//# sourceMappingURL=chunk-
|
|
6473
|
+
//# sourceMappingURL=chunk-MS77U77X.js.map
|