@ultrst-armada/krnl 1.0.2 → 1.0.4

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.
Files changed (237) hide show
  1. package/README.md +67 -65
  2. package/package.json +15 -8
  3. package/packages/cli/dist/bin/krnl.cjs +808 -331
  4. package/packages/cli/dist/bin/krnl.js +50 -65
  5. package/packages/cli/dist/chunk-GHWYEAPD.js +1642 -0
  6. package/packages/cli/dist/index.cjs +761 -263
  7. package/packages/cli/dist/index.d.cts +45 -2
  8. package/packages/cli/dist/index.d.ts +45 -2
  9. package/packages/cli/dist/index.js +5 -1
  10. package/packages/cli/package.json +17 -10
  11. package/packages/core/dist/index.cjs +2912 -140
  12. package/packages/core/dist/index.d.cts +614 -27
  13. package/packages/core/dist/index.d.ts +614 -27
  14. package/packages/core/dist/index.js +2903 -140
  15. package/packages/core/package.json +15 -6
  16. package/packages/create-krnl/dist/index.cjs +102 -65
  17. package/packages/create-krnl/dist/index.js +102 -65
  18. package/packages/create-krnl/package.json +5 -3
  19. package/packages/eslint-plugin/dist/index.cjs +17 -55
  20. package/packages/eslint-plugin/dist/index.d.cts +8 -43
  21. package/packages/eslint-plugin/dist/index.d.ts +8 -43
  22. package/packages/eslint-plugin/dist/index.js +17 -55
  23. package/packages/eslint-plugin/package.json +5 -4
  24. package/packages/validate/dist/index.cjs +378 -85
  25. package/packages/validate/dist/index.d.cts +11 -1
  26. package/packages/validate/dist/index.d.ts +11 -1
  27. package/packages/validate/dist/index.js +375 -82
  28. package/packages/validate/package.json +14 -7
  29. package/packages/cli/dist/K_ENT_Entity-PQ5MURQY-ZG6FZXXX.js +0 -13
  30. package/packages/cli/dist/K_LIB_Krnl_Aiko_Client-OPZAVZCW-K4CRQYA5.js +0 -8
  31. package/packages/cli/dist/K_LIB_Krnl_Ep_Tools-ROOE2TQF-LNPXZYOE.js +0 -110
  32. package/packages/cli/dist/K_LIB_Krnl_Frontend_Builder-2ZDUH6PF-3ALZPNX4.js +0 -11
  33. package/packages/cli/dist/K_LIB_Krnl_Frontend_Generator-UYNRNX2X-PJTICYSW.js +0 -11
  34. package/packages/cli/dist/K_LIB_Krnl_Registry_Client-NXV6D2QW-M5TYU55O.js +0 -8
  35. package/packages/cli/dist/K_LIB_Krnl_SubApp_Engine-7HR5HWW2-H6STOXRK.js +0 -20
  36. package/packages/cli/dist/K_LIB_Krnl_SubApp_Registry-7XYGDKJK-XPJXSF7D.js +0 -19
  37. package/packages/cli/dist/K_LIB_Krnl_SubApp_Worker_Host-CQVTGGG7-CUYGTWOW.js +0 -7
  38. package/packages/cli/dist/K_LIB_Krnl_System_App_Adapter-M6FJKLGU-VR6T4N6J.js +0 -17
  39. package/packages/cli/dist/K_LIB_Krnl_System_Base_Functionality_APIs-ZZUZ6ZG5-RLJ4QWDP.js +0 -58
  40. package/packages/cli/dist/K_LIB_Krnl_System_Magnetic_Loader-XBQO2KXF-BOQGUASC.js +0 -22
  41. package/packages/cli/dist/K_LIB_Krnl_System_Unified_Http_Adapter-RCEGP3OG-XJI7KIT5.js +0 -8
  42. package/packages/cli/dist/K_LIB_Krnl_Telemetry-77FRZ3KV-K5VCWAFW.js +0 -9
  43. package/packages/cli/dist/chunk-3TRM6CYL.js +0 -152
  44. package/packages/cli/dist/chunk-5JDK35TG.js +0 -3872
  45. package/packages/cli/dist/chunk-63PTK33I.js +0 -997
  46. package/packages/cli/dist/chunk-6NIKAMUZ.js +0 -82
  47. package/packages/cli/dist/chunk-BOXWWXQG.js +0 -400
  48. package/packages/cli/dist/chunk-EEKLK7QJ.js +0 -565
  49. package/packages/cli/dist/chunk-EG7T2IAD.js +0 -107
  50. package/packages/cli/dist/chunk-ESTKOQ7T.js +0 -1146
  51. package/packages/cli/dist/chunk-F5EHXE2O.js +0 -1036
  52. package/packages/cli/dist/chunk-F65ANSQG.js +0 -269
  53. package/packages/cli/dist/chunk-FDNCADFE.js +0 -71
  54. package/packages/cli/dist/chunk-FZ6X7PHR.js +0 -1146
  55. package/packages/cli/dist/chunk-GDLRMDAN.js +0 -127
  56. package/packages/cli/dist/chunk-HWMTCMOS.js +0 -656
  57. package/packages/cli/dist/chunk-I74QIQOD.js +0 -5536
  58. package/packages/cli/dist/chunk-JTLSTO25.js +0 -71
  59. package/packages/cli/dist/chunk-JULBBJ27.js +0 -1033
  60. package/packages/cli/dist/chunk-OHVMVRBP.js +0 -117
  61. package/packages/cli/dist/chunk-P2PCLEKX.js +0 -666
  62. package/packages/cli/dist/chunk-PJQIUOX2.js +0 -7767
  63. package/packages/cli/dist/chunk-PPOF3DJW.js +0 -471
  64. package/packages/cli/dist/chunk-Q45257P6.js +0 -173
  65. package/packages/cli/dist/chunk-QNROWGBI.js +0 -1036
  66. package/packages/cli/dist/chunk-RJNYUXZD.js +0 -977
  67. package/packages/cli/dist/chunk-SRTOPJ5W.js +0 -104
  68. package/packages/cli/dist/chunk-TCEX3MPS.js +0 -702
  69. package/packages/cli/dist/chunk-TNOAJO2J.js +0 -675
  70. package/packages/cli/dist/chunk-UR2SUCSF.js +0 -701
  71. package/packages/cli/dist/chunk-X5LOIFM7.js +0 -68
  72. package/packages/cli/dist/chunk-XIRFOO3H.js +0 -589
  73. package/packages/cli/dist/chunk-ZAAV3JXQ.js +0 -809
  74. package/packages/core/dist/K_ENT_Entity-4MB7CU4A.js +0 -12
  75. package/packages/core/dist/K_ENT_Entity-DEJGIDGH.js +0 -12
  76. package/packages/core/dist/K_ENT_Entity-FXZO5UZ2.js +0 -12
  77. package/packages/core/dist/K_ENT_Entity-HDSCXC5F.js +0 -12
  78. package/packages/core/dist/K_ENT_Entity-JILABHLW.js +0 -12
  79. package/packages/core/dist/K_ENT_Entity-PQ5MURQY.js +0 -13
  80. package/packages/core/dist/K_ENT_Entity-ROAKDIHW.js +0 -12
  81. package/packages/core/dist/K_ENT_Entity-TBVFSKDV.js +0 -12
  82. package/packages/core/dist/K_ENT_Entity-ZFLKG3JO.js +0 -12
  83. package/packages/core/dist/K_LIB_Krnl_Aiko_Client-OPZAVZCW.js +0 -8
  84. package/packages/core/dist/K_LIB_Krnl_Ep_Tools-ROOE2TQF.js +0 -110
  85. package/packages/core/dist/K_LIB_Krnl_Frontend_Builder-2ZDUH6PF.js +0 -9
  86. package/packages/core/dist/K_LIB_Krnl_Frontend_Generator-UYNRNX2X.js +0 -9
  87. package/packages/core/dist/K_LIB_Krnl_Registry_Client-NXV6D2QW.js +0 -8
  88. package/packages/core/dist/K_LIB_Krnl_SubApp_Engine-7HR5HWW2.js +0 -20
  89. package/packages/core/dist/K_LIB_Krnl_SubApp_Registry-4C6GBQAG.js +0 -18
  90. package/packages/core/dist/K_LIB_Krnl_SubApp_Registry-6V23A6F6.js +0 -18
  91. package/packages/core/dist/K_LIB_Krnl_SubApp_Registry-7XYGDKJK.js +0 -19
  92. package/packages/core/dist/K_LIB_Krnl_SubApp_Registry-DYLLC5G2.js +0 -18
  93. package/packages/core/dist/K_LIB_Krnl_SubApp_Registry-F4FOFAUP.js +0 -18
  94. package/packages/core/dist/K_LIB_Krnl_SubApp_Registry-FBOXXMI3.js +0 -18
  95. package/packages/core/dist/K_LIB_Krnl_SubApp_Registry-Q73BWLNP.js +0 -18
  96. package/packages/core/dist/K_LIB_Krnl_SubApp_Registry-QM2C4MVA.js +0 -18
  97. package/packages/core/dist/K_LIB_Krnl_SubApp_Registry-QUGI6SMP.js +0 -18
  98. package/packages/core/dist/K_LIB_Krnl_SubApp_Registry-RGMTBHNP.js +0 -18
  99. package/packages/core/dist/K_LIB_Krnl_SubApp_Registry-RWR7UNDW.js +0 -18
  100. package/packages/core/dist/K_LIB_Krnl_SubApp_Worker_Host-CQVTGGG7.js +0 -7
  101. package/packages/core/dist/K_LIB_Krnl_System_App_Adapter-32MFJJ5Z.js +0 -17
  102. package/packages/core/dist/K_LIB_Krnl_System_App_Adapter-4J4CEWRY.js +0 -17
  103. package/packages/core/dist/K_LIB_Krnl_System_App_Adapter-A366YHF2.js +0 -17
  104. package/packages/core/dist/K_LIB_Krnl_System_App_Adapter-LK4LYJHI.js +0 -17
  105. package/packages/core/dist/K_LIB_Krnl_System_App_Adapter-M6FJKLGU.js +0 -17
  106. package/packages/core/dist/K_LIB_Krnl_System_App_Adapter-NW3K63II.js +0 -17
  107. package/packages/core/dist/K_LIB_Krnl_System_App_Adapter-QDHTI5ZV.js +0 -17
  108. package/packages/core/dist/K_LIB_Krnl_System_App_Adapter-VHCT6VIW.js +0 -17
  109. package/packages/core/dist/K_LIB_Krnl_System_App_Adapter-WBRKF24R.js +0 -17
  110. package/packages/core/dist/K_LIB_Krnl_System_App_Adapter-XKYQYT6Q.js +0 -17
  111. package/packages/core/dist/K_LIB_Krnl_System_App_Adapter-Z2PWZYDZ.js +0 -17
  112. package/packages/core/dist/K_LIB_Krnl_System_Base_Functionality_APIs-ZZUZ6ZG5.js +0 -58
  113. package/packages/core/dist/K_LIB_Krnl_System_Magnetic_Loader-2EZU7QF4.js +0 -21
  114. package/packages/core/dist/K_LIB_Krnl_System_Magnetic_Loader-6G3AQNAV.js +0 -21
  115. package/packages/core/dist/K_LIB_Krnl_System_Magnetic_Loader-B2NZMQUG.js +0 -21
  116. package/packages/core/dist/K_LIB_Krnl_System_Magnetic_Loader-C2RABMZP.js +0 -21
  117. package/packages/core/dist/K_LIB_Krnl_System_Magnetic_Loader-HHE3NZ4F.js +0 -21
  118. package/packages/core/dist/K_LIB_Krnl_System_Magnetic_Loader-LHFGR6WK.js +0 -21
  119. package/packages/core/dist/K_LIB_Krnl_System_Magnetic_Loader-M74BLM3N.js +0 -21
  120. package/packages/core/dist/K_LIB_Krnl_System_Magnetic_Loader-PT6ZA6EA.js +0 -21
  121. package/packages/core/dist/K_LIB_Krnl_System_Magnetic_Loader-SP52V3CX.js +0 -21
  122. package/packages/core/dist/K_LIB_Krnl_System_Magnetic_Loader-XBQO2KXF.js +0 -22
  123. package/packages/core/dist/K_LIB_Krnl_System_Magnetic_Loader-YNSEUHJJ.js +0 -21
  124. package/packages/core/dist/K_LIB_Krnl_System_Unified_Http_Adapter-M6SBHIVA.js +0 -8
  125. package/packages/core/dist/K_LIB_Krnl_System_Unified_Http_Adapter-RCEGP3OG.js +0 -8
  126. package/packages/core/dist/K_LIB_Krnl_Telemetry-77FRZ3KV.js +0 -9
  127. package/packages/core/dist/chunk-33L2J7V7.js +0 -82
  128. package/packages/core/dist/chunk-3ES4K2ZP.js +0 -817
  129. package/packages/core/dist/chunk-3SMHVVLL.js +0 -82
  130. package/packages/core/dist/chunk-3UEZ7JQA.js +0 -4877
  131. package/packages/core/dist/chunk-3XIE6KBD.js +0 -4877
  132. package/packages/core/dist/chunk-46ZLCML6.js +0 -107
  133. package/packages/core/dist/chunk-4UEL3DWJ.js +0 -107
  134. package/packages/core/dist/chunk-54GWZ5PC.js +0 -82
  135. package/packages/core/dist/chunk-6QCYRS5L.js +0 -127
  136. package/packages/core/dist/chunk-6ULMHNXR.js +0 -104
  137. package/packages/core/dist/chunk-7WUETJEV.js +0 -117
  138. package/packages/core/dist/chunk-A5KRAYDB.js +0 -107
  139. package/packages/core/dist/chunk-ANEAZ3PO.js +0 -107
  140. package/packages/core/dist/chunk-BE76RL6F.js +0 -82
  141. package/packages/core/dist/chunk-CIARVYDO.js +0 -107
  142. package/packages/core/dist/chunk-CR2ANE62.js +0 -107
  143. package/packages/core/dist/chunk-DI27MOR7.js +0 -173
  144. package/packages/core/dist/chunk-E6RLFHM5.js +0 -596
  145. package/packages/core/dist/chunk-EELAPMNV.js +0 -4877
  146. package/packages/core/dist/chunk-ENZ2RQVJ.js +0 -107
  147. package/packages/core/dist/chunk-F2U6CX4F.js +0 -4877
  148. package/packages/core/dist/chunk-FKG64OHL.js +0 -82
  149. package/packages/core/dist/chunk-FYAZJYM5.js +0 -772
  150. package/packages/core/dist/chunk-G4NP4RDQ.js +0 -82
  151. package/packages/core/dist/chunk-GADIRLRS.js +0 -473
  152. package/packages/core/dist/chunk-GR6CSLQJ.js +0 -772
  153. package/packages/core/dist/chunk-HDS7AT6O.js +0 -772
  154. package/packages/core/dist/chunk-HIMEZUU2.js +0 -71
  155. package/packages/core/dist/chunk-IB4UHG5I.js +0 -596
  156. package/packages/core/dist/chunk-J7ZYNVRS.js +0 -772
  157. package/packages/core/dist/chunk-JVLZU4K7.js +0 -604
  158. package/packages/core/dist/chunk-JYXXI7Q3.js +0 -82
  159. package/packages/core/dist/chunk-K54K2KZW.js +0 -192
  160. package/packages/core/dist/chunk-K6VHLBNH.js +0 -3316
  161. package/packages/core/dist/chunk-KCBP7ZYA.js +0 -596
  162. package/packages/core/dist/chunk-KFQGP6VL.js +0 -33
  163. package/packages/core/dist/chunk-KIUEUI7K.js +0 -82
  164. package/packages/core/dist/chunk-LB67NIZP.js +0 -949
  165. package/packages/core/dist/chunk-LDTYFUNW.js +0 -596
  166. package/packages/core/dist/chunk-MLVWARD4.js +0 -596
  167. package/packages/core/dist/chunk-MPYVXHKO.js +0 -2777
  168. package/packages/core/dist/chunk-MRQ3MITU.js +0 -772
  169. package/packages/core/dist/chunk-MVUN7I7O.js +0 -107
  170. package/packages/core/dist/chunk-NDDOIRW7.js +0 -596
  171. package/packages/core/dist/chunk-O3KDB5MH.js +0 -3330
  172. package/packages/core/dist/chunk-OEINUDSE.js +0 -400
  173. package/packages/core/dist/chunk-OPDENPT4.js +0 -4877
  174. package/packages/core/dist/chunk-P6XEM2LA.js +0 -429
  175. package/packages/core/dist/chunk-QKMRSQV4.js +0 -82
  176. package/packages/core/dist/chunk-R6CCWALL.js +0 -4877
  177. package/packages/core/dist/chunk-RAMMOO73.js +0 -774
  178. package/packages/core/dist/chunk-S3FTZFG6.js +0 -772
  179. package/packages/core/dist/chunk-T2ZVN434.js +0 -4877
  180. package/packages/core/dist/chunk-TFHLDMIA.js +0 -107
  181. package/packages/core/dist/chunk-TI3QUCIJ.js +0 -107
  182. package/packages/core/dist/chunk-TR2BAIGI.js +0 -107
  183. package/packages/core/dist/chunk-UGVVJKC6.js +0 -4877
  184. package/packages/core/dist/chunk-V2DX7YIU.js +0 -984
  185. package/packages/core/dist/chunk-W4IHYUYD.js +0 -772
  186. package/packages/core/dist/chunk-W6WBG5OY.js +0 -4877
  187. package/packages/core/dist/chunk-WN3M7O7H.js +0 -3312
  188. package/packages/core/dist/chunk-WR3NCU7U.js +0 -4877
  189. package/packages/core/dist/chunk-XC6B6L27.js +0 -82
  190. package/packages/core/dist/chunk-XNSE64ZY.js +0 -3316
  191. package/packages/core/dist/chunk-XROES2WN.js +0 -634
  192. package/packages/core/dist/chunk-XSCKNRCZ.js +0 -5020
  193. package/packages/core/dist/chunk-XVABPAUZ.js +0 -82
  194. package/packages/core/dist/chunk-YOBCB5C5.js +0 -596
  195. package/packages/core/dist/chunk-YUK6Q563.js +0 -666
  196. package/packages/core/dist/chunk-YXGL3ZEU.js +0 -1030
  197. package/packages/core/dist/chunk-ZINJ5OUX.js +0 -596
  198. package/packages/core/dist/chunk-ZPFD4BIQ.js +0 -604
  199. package/packages/core/dist/chunk-ZQZBFG6F.js +0 -4826
  200. package/packages/core/dist/chunk-ZZFRJGXM.js +0 -4877
  201. package/packages/create-krnl/dist/K_ENT_Entity-PQ5MURQY-R2OH4VXE.js +0 -14
  202. package/packages/create-krnl/dist/K_LIB_Krnl_Aiko_Client-OPZAVZCW-AZM5HF4M.js +0 -9
  203. package/packages/create-krnl/dist/K_LIB_Krnl_Ep_Tools-ROOE2TQF-X5N6SV2S.js +0 -111
  204. package/packages/create-krnl/dist/K_LIB_Krnl_Frontend_Builder-2ZDUH6PF-5PFHF4JU.js +0 -12
  205. package/packages/create-krnl/dist/K_LIB_Krnl_Frontend_Generator-UYNRNX2X-ED33OQPH.js +0 -12
  206. package/packages/create-krnl/dist/K_LIB_Krnl_Registry_Client-NXV6D2QW-YGQLVR4P.js +0 -9
  207. package/packages/create-krnl/dist/K_LIB_Krnl_SubApp_Engine-7HR5HWW2-VM7CTU2L.js +0 -21
  208. package/packages/create-krnl/dist/K_LIB_Krnl_SubApp_Registry-7XYGDKJK-Y2GQFJ7I.js +0 -21
  209. package/packages/create-krnl/dist/K_LIB_Krnl_SubApp_Worker_Host-CQVTGGG7-L3JQWO54.js +0 -8
  210. package/packages/create-krnl/dist/K_LIB_Krnl_System_App_Adapter-M6FJKLGU-KQARASPR.js +0 -19
  211. package/packages/create-krnl/dist/K_LIB_Krnl_System_Base_Functionality_APIs-ZZUZ6ZG5-OF3IGLVL.js +0 -59
  212. package/packages/create-krnl/dist/K_LIB_Krnl_System_Magnetic_Loader-XBQO2KXF-JOLHKOEX.js +0 -24
  213. package/packages/create-krnl/dist/K_LIB_Krnl_System_Unified_Http_Adapter-RCEGP3OG-L46LSHKQ.js +0 -10
  214. package/packages/create-krnl/dist/K_LIB_Krnl_Telemetry-77FRZ3KV-4JUPRR3X.js +0 -10
  215. package/packages/create-krnl/dist/chunk-3TRM6CYL.js +0 -152
  216. package/packages/create-krnl/dist/chunk-3URCB3QS.js +0 -127
  217. package/packages/create-krnl/dist/chunk-5JDK35TG.js +0 -3872
  218. package/packages/create-krnl/dist/chunk-A2XAXDOW.js +0 -812
  219. package/packages/create-krnl/dist/chunk-AN6TMQHG.js +0 -1033
  220. package/packages/create-krnl/dist/chunk-BOXWWXQG.js +0 -400
  221. package/packages/create-krnl/dist/chunk-BPTBREBG.js +0 -38
  222. package/packages/create-krnl/dist/chunk-FDNCADFE.js +0 -71
  223. package/packages/create-krnl/dist/chunk-JTLSTO25.js +0 -71
  224. package/packages/create-krnl/dist/chunk-M3NCUIPL.js +0 -107
  225. package/packages/create-krnl/dist/chunk-N2EONSOC.js +0 -7769
  226. package/packages/create-krnl/dist/chunk-OHVMVRBP.js +0 -117
  227. package/packages/create-krnl/dist/chunk-Q45257P6.js +0 -173
  228. package/packages/create-krnl/dist/chunk-QGM4M3NI.js +0 -37
  229. package/packages/create-krnl/dist/chunk-RJNYUXZD.js +0 -977
  230. package/packages/create-krnl/dist/chunk-SRTOPJ5W.js +0 -104
  231. package/packages/create-krnl/dist/chunk-UPBIGEC3.js +0 -666
  232. package/packages/create-krnl/dist/chunk-V2DB7UD7.js +0 -82
  233. package/packages/create-krnl/dist/chunk-WMHLIUI6.js +0 -3644
  234. package/packages/create-krnl/dist/chunk-XIRFOO3H.js +0 -589
  235. package/packages/create-krnl/dist/chunk-Y2CEEVZP.js +0 -5536
  236. package/packages/create-krnl/dist/main-DXUMPBND.js +0 -2217
  237. package/packages/create-krnl/dist/wrapper-SDF2VKX3.js +0 -31
@@ -1,8 +1,26 @@
1
+ import * as gutts from '@dinilmusick/gutts';
2
+ export { gutts };
3
+
4
+ /**
5
+ * @file LifecycleManager.ts
6
+ * @description Explicit, deterministic lifecycle state machine for services.
7
+ */
8
+ type ServiceStatus = 'uninitialized' | 'initializing' | 'ready' | 'starting' | 'running' | 'stopping' | 'stopped';
9
+ declare class LifecycleManager {
10
+ private status;
11
+ getStatus(): ServiceStatus;
12
+ canTransitionTo(next: ServiceStatus): boolean;
13
+ transitionTo(next: ServiceStatus): void;
14
+ setStatus(next: ServiceStatus): void;
15
+ assertRunning(serviceName: string): void;
16
+ }
17
+
1
18
  /**
2
19
  * @file ServiceContract.ts
3
20
  * @description Canonical service contracts for the KrnlTS Service Kernel.
4
- * Invariant: KrnlTS.Service = Skipo.Service = RemoteService.Contract
21
+ * Invariant: local and remote services share the same IService contract.
5
22
  */
23
+
6
24
  type ProtocolType = 'http' | 'https' | 'ws' | 'wss' | 'udp' | 'p2p' | 'signaling' | 'memory';
7
25
  interface OperationContext {
8
26
  caller?: string;
@@ -10,6 +28,8 @@ interface OperationContext {
10
28
  accessKey?: string;
11
29
  metadata?: Record<string, unknown>;
12
30
  protocol?: ProtocolType;
31
+ correlationId?: string;
32
+ idempotencyKey?: string;
13
33
  }
14
34
  interface OperationContract<TInput = unknown, TOutput = unknown> {
15
35
  id: string;
@@ -50,6 +70,17 @@ interface ServiceCapability {
50
70
  protocols: ProtocolType[];
51
71
  metadata?: Record<string, unknown>;
52
72
  }
73
+ interface ServiceNamespace<TLibraries extends Record<string, unknown> = Record<string, unknown>, TFunctionalities extends Record<string, unknown> = Record<string, unknown>, TOrchestrations extends Record<string, unknown> = Record<string, unknown>> {
74
+ readonly serviceId: string;
75
+ readonly serviceName: string;
76
+ readonly version: string;
77
+ readonly description?: string;
78
+ readonly libraries: TLibraries;
79
+ readonly functionalities: TFunctionalities;
80
+ readonly functionalityOrchestrations: TOrchestrations;
81
+ readonly capabilities: readonly ServiceCapability[];
82
+ readonly dependencies: readonly DependencyContract[];
83
+ }
53
84
  interface EndpointDescriptor {
54
85
  protocol: ProtocolType;
55
86
  address: string;
@@ -81,8 +112,10 @@ interface IService<TState extends Record<string, unknown> = Record<string, unkno
81
112
  setState(mutation: Partial<TState>): void;
82
113
  on<K extends keyof TEvents & string>(event: K, handler: (payload: TEvents[K]) => void): () => void;
83
114
  emit<K extends keyof TEvents & string>(event: K, payload: TEvents[K]): void;
115
+ getStatus(): ServiceStatus;
84
116
  start(): Promise<void>;
85
117
  stop(): Promise<void>;
118
+ dispose(): Promise<void>;
86
119
  getDefinition(): ServiceDefinition<TState, TEvents>;
87
120
  }
88
121
 
@@ -92,17 +125,21 @@ interface IService<TState extends Record<string, unknown> = Record<string, unkno
92
125
  */
93
126
 
94
127
  declare class ServiceInstance<TState extends Record<string, unknown> = Record<string, unknown>, TEvents extends Record<string, unknown> = Record<string, unknown>> implements IService<TState, TEvents> {
95
- private definition;
128
+ private readonly definition;
96
129
  readonly id: string;
97
130
  readonly name: string;
98
131
  readonly version: string;
99
132
  private stateStore?;
100
- private eventBus;
101
- private lifecycle;
133
+ private readonly eventBus;
134
+ private readonly lifecycle;
135
+ private initialized;
136
+ private disposed;
102
137
  constructor(definition: ServiceDefinition<TState, TEvents>);
103
138
  getDefinition(): ServiceDefinition<TState, TEvents>;
139
+ getStatus(): ReturnType<LifecycleManager['getStatus']>;
104
140
  start(): Promise<void>;
105
141
  stop(): Promise<void>;
142
+ dispose(): Promise<void>;
106
143
  call<TIn = unknown, TOut = unknown>(op: string, input?: TIn, ctx?: OperationContext): Promise<TOut>;
107
144
  getState(): Readonly<TState>;
108
145
  setState(mutation: Partial<TState>): void;
@@ -152,23 +189,29 @@ interface ProtocolAdapter {
152
189
 
153
190
  /**
154
191
  * @file ServiceProxy.ts
155
- * @description Transparent client proxy invoking a remote or mediated service.
156
- * Invariant: LOCAL SERVICE = REMOTE SERVICE CONTRACT.
192
+ * @description Transparent client proxy for the remote service contract.
193
+ *
194
+ * Lifecycle is local client lifecycle. Remote execution remains transport-mediated.
195
+ * State and event methods are local cache/subscription semantics.
157
196
  */
158
197
 
159
198
  declare class ServiceProxy<TState extends Record<string, unknown> = Record<string, unknown>, TEvents extends Record<string, unknown> = Record<string, unknown>> implements IService<TState, TEvents> {
160
- private definition;
161
- private adapter;
162
- private endpoint;
199
+ private readonly definition;
200
+ private readonly adapter;
201
+ private readonly endpoint;
163
202
  readonly id: string;
164
203
  readonly name: string;
165
204
  readonly version: string;
166
205
  private stateCache;
167
- private eventHandlers;
206
+ private readonly eventHandlers;
207
+ private readonly lifecycle;
208
+ private disposed;
168
209
  constructor(definition: ServiceDefinition<TState, TEvents>, adapter: ProtocolAdapter, endpoint: EndpointDescriptor);
169
210
  getDefinition(): ServiceDefinition<TState, TEvents>;
211
+ getStatus(): ReturnType<LifecycleManager['getStatus']>;
170
212
  start(): Promise<void>;
171
213
  stop(): Promise<void>;
214
+ dispose(): Promise<void>;
172
215
  call<TIn = unknown, TOut = unknown>(op: string, input?: TIn, ctx?: OperationContext): Promise<TOut>;
173
216
  getState(): Readonly<TState>;
174
217
  setState(mutation: Partial<TState>): void;
@@ -178,13 +221,539 @@ declare class ServiceProxy<TState extends Record<string, unknown> = Record<strin
178
221
 
179
222
  /**
180
223
  * @file ServiceGenerators.ts
181
- * @description Factory generators for services and definitions.
224
+ * @description Validated factory generators for services and definitions.
182
225
  */
183
226
 
227
+ declare function validateServiceDefinition<TState extends Record<string, unknown> = Record<string, unknown>, TEvents extends Record<string, unknown> = Record<string, unknown>>(definition: ServiceDefinition<TState, TEvents>): ServiceDefinition<TState, TEvents>;
184
228
  declare function createServiceDefinition<TState extends Record<string, unknown> = Record<string, unknown>, TEvents extends Record<string, unknown> = Record<string, unknown>>(definition: ServiceDefinition<TState, TEvents>): ServiceDefinition<TState, TEvents>;
185
229
  declare function createService<TState extends Record<string, unknown> = Record<string, unknown>, TEvents extends Record<string, unknown> = Record<string, unknown>>(definition: ServiceDefinition<TState, TEvents>): ServiceInstance<TState, TEvents>;
186
230
  declare function createServiceProxy<TState extends Record<string, unknown> = Record<string, unknown>, TEvents extends Record<string, unknown> = Record<string, unknown>>(definition: ServiceDefinition<TState, TEvents>, adapter: ProtocolAdapter, endpoint: EndpointDescriptor): IService<TState, TEvents>;
187
231
 
232
+ /**
233
+ * @file model.ts
234
+ * @description Canonical Isomorphic Orchestration Model.
235
+ * Provides unified schema, serializable definition contracts, and invariants for
236
+ * FunctionalityOrchestration (KrnlTS) and ServiceOrchestration (Skipo).
237
+ */
238
+ type StepType = 'task' | 'sequential' | 'parallel' | 'branch' | 'conditional' | 'fanOut' | 'fanIn' | 'diamond' | 'delay' | 'nested';
239
+ type StepStatus = 'PENDING' | 'RUNNING' | 'COMPLETED' | 'FAILED' | 'CANCELLED' | 'SKIPPED' | 'TIMED_OUT';
240
+ type StepExecutionStatus = StepStatus;
241
+ type OrchestrationStatus = 'PENDING' | 'RUNNING' | 'COMPLETED' | 'FAILED' | 'CANCELLED' | 'TIMED_OUT';
242
+ interface StepRetryPolicy {
243
+ readonly maxAttempts: number;
244
+ readonly backoff?: 'linear' | 'exponential';
245
+ readonly backoffMs?: number;
246
+ readonly maxBackoffMs?: number;
247
+ readonly jitter?: boolean;
248
+ readonly retryOnErrors?: readonly string[];
249
+ readonly backoffMultiplier?: number;
250
+ readonly initialDelayMs?: number;
251
+ }
252
+ interface StepTimeoutPolicy {
253
+ readonly timeoutMs: number;
254
+ }
255
+ interface StepCompensation<TContext = OrchestrationContext> {
256
+ readonly name?: string;
257
+ readonly handler?: (context: TContext) => Promise<void>;
258
+ readonly target?: string;
259
+ readonly operation?: string;
260
+ }
261
+ type SagaCompensationHandler<TOutput = unknown> = (output: TOutput, context: OrchestrationContext) => Promise<void>;
262
+ type StepCondition<TContext = OrchestrationContext> = (context: TContext) => boolean | Promise<boolean>;
263
+ /**
264
+ * Pure serializable definition of a step (Distributable through Kloks).
265
+ * Free from arbitrary runtime closures.
266
+ */
267
+ interface OrchestrationFrontendReference {
268
+ readonly component: string;
269
+ readonly package?: string;
270
+ readonly export?: string;
271
+ readonly relationship?: 'recommended' | 'required';
272
+ }
273
+ interface StepDefinition {
274
+ readonly id: string;
275
+ readonly name: string;
276
+ readonly type: StepType;
277
+ readonly target?: string;
278
+ readonly operation?: string;
279
+ readonly dependsOn?: readonly string[];
280
+ readonly conditionExpression?: string;
281
+ readonly retryPolicy?: StepRetryPolicy;
282
+ readonly timeoutPolicy?: StepTimeoutPolicy;
283
+ readonly compensationTarget?: string;
284
+ readonly compensationOperation?: string;
285
+ readonly concurrency?: number;
286
+ readonly nestedOrchestrationId?: string;
287
+ readonly metadata?: Record<string, unknown>;
288
+ }
289
+ /**
290
+ * Pure serializable definition of an orchestration workflow (Distributable through Kloks).
291
+ * Zero execution machinery, zero runtime closures.
292
+ */
293
+ interface OrchestrationDefinition<TInput = unknown, TOutput = unknown> {
294
+ readonly id: string;
295
+ readonly name: string;
296
+ readonly version: string;
297
+ readonly description?: string;
298
+ readonly scope: 'functionality' | 'service';
299
+ readonly dependencies: readonly string[];
300
+ readonly defaultFrontend?: OrchestrationFrontendReference;
301
+ readonly timeoutMs?: number;
302
+ readonly concurrency?: number;
303
+ readonly steps: readonly StepDefinition[];
304
+ readonly metadata?: Record<string, unknown>;
305
+ }
306
+ /**
307
+ * Runtime execution step representation with bound handlers.
308
+ */
309
+ interface OrchestrationStep<TInput = unknown, TOutput = unknown> {
310
+ readonly id: string;
311
+ readonly name: string;
312
+ readonly type: StepType;
313
+ readonly target?: string;
314
+ readonly operation?: string;
315
+ readonly dependsOn?: readonly string[];
316
+ readonly handler?: (input: TInput, context: OrchestrationContext) => Promise<TOutput>;
317
+ readonly condition?: StepCondition;
318
+ readonly thenStepId?: string;
319
+ readonly elseStepId?: string;
320
+ readonly parallelStepIds?: readonly string[];
321
+ readonly getItems?: (context: OrchestrationContext) => unknown[] | Promise<unknown[]>;
322
+ readonly concurrency?: number;
323
+ readonly retryPolicy?: StepRetryPolicy;
324
+ readonly timeoutPolicy?: StepTimeoutPolicy;
325
+ readonly compensation?: StepCompensation;
326
+ readonly catchHandler?: (error: Error, context: OrchestrationContext) => Promise<TOutput>;
327
+ readonly nestedOrchestrationId?: string;
328
+ }
329
+ interface OrchestrationDescriptor {
330
+ readonly id: string;
331
+ readonly name?: string;
332
+ readonly version?: string;
333
+ readonly description?: string;
334
+ readonly timeoutMs?: number;
335
+ readonly concurrency?: number;
336
+ readonly scope?: 'functionality' | 'service';
337
+ }
338
+ interface OrchestrationContext {
339
+ readonly correlationId: string;
340
+ readonly parentCorrelationId?: string;
341
+ readonly orchestrationId: string;
342
+ readonly executionId: string;
343
+ readonly idempotencyKey?: string;
344
+ readonly scope: 'functionality' | 'service';
345
+ readonly serviceId?: string;
346
+ readonly results: Record<string, unknown>;
347
+ readonly metadata: Record<string, unknown>;
348
+ readonly timestamp: number;
349
+ isCancelled: boolean;
350
+ abortSignal?: AbortSignal;
351
+ }
352
+ interface StepExecutionResult<T = unknown> {
353
+ readonly stepId: string;
354
+ readonly status: StepStatus;
355
+ readonly attempts: number;
356
+ readonly output?: T;
357
+ readonly error?: string;
358
+ readonly startedAt: number;
359
+ readonly completedAt: number;
360
+ }
361
+ interface OrchestrationResult<T = unknown> {
362
+ readonly orchestrationId: string;
363
+ readonly correlationId: string;
364
+ readonly status: OrchestrationStatus;
365
+ readonly output?: T;
366
+ readonly stepResults: Record<string, StepExecutionResult>;
367
+ readonly error?: string;
368
+ readonly startedAt: number;
369
+ readonly completedAt: number;
370
+ readonly executionMetadata: Record<string, unknown>;
371
+ }
372
+ interface DAGValidationResult {
373
+ readonly valid: boolean;
374
+ readonly order: readonly string[];
375
+ readonly errors: readonly string[];
376
+ }
377
+ /**
378
+ * Validates DAG structure & semantic policies:
379
+ * - Duplicate step IDs
380
+ * - Missing dependencies
381
+ * - Cycles / circular dependencies (topological sort via Kahn's algorithm)
382
+ * - Negative or invalid timeouts
383
+ * - Invalid retry policies (attempts < 1, negative backoff)
384
+ * - Empty step targets
385
+ * - Concurrency bounds
386
+ */
387
+ declare function validateOrchestrationDAG(steps: readonly OrchestrationStep[]): DAGValidationResult;
388
+
389
+ interface FunctionalityFlowStep {
390
+ readonly id: string;
391
+ readonly type: 'functionality' | 'functionalityOrchestration';
392
+ readonly target: string;
393
+ readonly flow?: string;
394
+ readonly dependsOn?: readonly string[];
395
+ readonly retryPolicy?: StepRetryPolicy;
396
+ readonly timeoutPolicy?: StepTimeoutPolicy;
397
+ }
398
+ interface FunctionalityFlow {
399
+ readonly name: string;
400
+ readonly steps: FunctionalityFlowStep[];
401
+ visibility: 'public' | 'private' | 'internal';
402
+ thenFunctionality(funcName: string, options?: {
403
+ retry?: StepRetryPolicy;
404
+ timeoutMs?: number;
405
+ dependsOn?: string[];
406
+ }): FunctionalityFlow;
407
+ thenFunctionalityOrchestration(childOrchestrationName: string, flowName?: string): FunctionalityFlow;
408
+ register(options?: {
409
+ visibility?: 'public' | 'private' | 'internal';
410
+ }): FunctionalityFlow;
411
+ }
412
+ interface FunctionalityStepOptions {
413
+ id?: string;
414
+ dependsOn?: string[];
415
+ retry?: StepRetryPolicy;
416
+ timeoutMs?: number;
417
+ compensation?: string;
418
+ catchHandler?: (err: Error, ctx: OrchestrationContext) => Promise<any>;
419
+ }
420
+ /**
421
+ * FunctionalityOrchestration
422
+ * Composes functionalities belonging strictly to ONE service into a deterministic DAG workflow.
423
+ */
424
+ declare class FunctionalityOrchestration {
425
+ readonly id: string;
426
+ readonly name: string;
427
+ readonly version: string;
428
+ readonly description: string;
429
+ readonly timeoutMs?: number;
430
+ readonly scope: 'functionality';
431
+ private readonly steps;
432
+ private readonly flows;
433
+ constructor(descriptor: OrchestrationDescriptor);
434
+ /**
435
+ * Adds a sequential functionality step to the DAG.
436
+ */
437
+ thenFunctionality(funcName: any, options?: FunctionalityStepOptions): this;
438
+ /**
439
+ * Adds parallel functionality steps to the DAG.
440
+ */
441
+ parallel(name: string, functionalityNames: readonly string[], options?: {
442
+ dependsOn?: string[];
443
+ }): this;
444
+ /**
445
+ * Adds conditional branching to the DAG.
446
+ */
447
+ branch(name: string, condition: StepCondition, thenFunc: string, elseFunc?: string, options?: {
448
+ dependsOn?: string[];
449
+ }): this;
450
+ /**
451
+ * Adds fan-out step processing items through a functionality.
452
+ */
453
+ fanOut(name: string, funcName: string, getItems: (ctx: OrchestrationContext) => unknown[] | Promise<unknown[]>, options?: {
454
+ dependsOn?: string[];
455
+ concurrency?: number;
456
+ }): this;
457
+ /**
458
+ * Nested orchestration: Invokes a child FunctionalityOrchestration within the same service boundary.
459
+ */
460
+ thenFunctionalityOrchestration(childOrchId: string, options?: FunctionalityStepOptions): this;
461
+ getSteps(): readonly OrchestrationStep[];
462
+ /**
463
+ * Converts this FunctionalityOrchestration to a pure serializable OrchestrationDefinition.
464
+ */
465
+ toDefinition(): OrchestrationDefinition;
466
+ /**
467
+ * Named flow builder interface.
468
+ */
469
+ flow(name: string): FunctionalityFlow;
470
+ getFlow(name: string): FunctionalityFlow | undefined;
471
+ listFlows(): FunctionalityFlow[];
472
+ clearFlows(): void;
473
+ private assertServiceBoundary;
474
+ }
475
+
476
+ /**
477
+ * @file WorkerExecutionBoundary.ts
478
+ * @description Worker Execution Boundary mediating all job execution from Krnl workers
479
+ * to service functionalities and orchestrations.
480
+ * Enforces worker context invariants (no synchronous/unmediated direct execution).
481
+ */
482
+ interface ExecutionContext {
483
+ readonly isWorkerContext: boolean;
484
+ readonly workerId: string;
485
+ readonly timestamp: number;
486
+ readonly correlationId?: string;
487
+ readonly metadata?: Record<string, unknown>;
488
+ }
489
+ interface BackendCommand<TPayload = unknown> {
490
+ readonly id: string;
491
+ readonly type: string;
492
+ readonly payload: TPayload;
493
+ readonly correlationId: string;
494
+ readonly idempotencyKey?: string;
495
+ readonly createdAt: number;
496
+ }
497
+ interface NormalizedResult<T = unknown> {
498
+ readonly correlationId: string;
499
+ readonly status: 'COMPLETED' | 'FAILED' | 'CANCELLED';
500
+ readonly data?: T;
501
+ readonly error?: string;
502
+ readonly executionTimestamp: number;
503
+ }
504
+ declare class WorkerExecutionBoundary {
505
+ readonly workerId: string;
506
+ private readonly handler?;
507
+ constructor(workerId: string, handler?: ((command: BackendCommand<any>, context: ExecutionContext) => Promise<NormalizedResult<any>>) | undefined);
508
+ processJob<T = unknown>(command: BackendCommand<any>, metadata?: Record<string, unknown>): Promise<NormalizedResult<T>>;
509
+ static assertWorkerContext(context?: ExecutionContext): void;
510
+ }
511
+
512
+ /**
513
+ * @file KrnlWorkerPool.ts
514
+ * @description Worker lifecycle management and context factory for KrnlTS services.
515
+ * Tracks worker state transitions: created -> started -> running -> draining -> stopped.
516
+ * Ensures all job executions happen with valid ExecutionContext.
517
+ */
518
+
519
+ type KrnlWorkerState = 'created' | 'started' | 'running' | 'draining' | 'stopped';
520
+ interface KrnlWorkerInfo {
521
+ readonly id: string;
522
+ readonly queueName: string;
523
+ readonly state: KrnlWorkerState;
524
+ readonly startedAt: number;
525
+ readonly activeJobs: number;
526
+ }
527
+ declare class KrnlWorkerPool {
528
+ readonly queueName: string;
529
+ readonly workerId: string;
530
+ private state;
531
+ private activeJobsCount;
532
+ private readonly startedAt;
533
+ private readonly workerBoundary;
534
+ constructor(queueName: string, workerId?: string);
535
+ getState(): KrnlWorkerState;
536
+ getActiveJobs(): number;
537
+ getWorkerBoundary(): WorkerExecutionBoundary;
538
+ getInfo(): KrnlWorkerInfo;
539
+ start(): void;
540
+ createContext(correlationId?: string, metadata?: Record<string, unknown>): ExecutionContext;
541
+ runWithContext<T>(correlationId: string | undefined, metadata: Record<string, unknown> | undefined, fn: (ctx: ExecutionContext) => Promise<T>): Promise<T>;
542
+ drain(): Promise<void>;
543
+ stop(): Promise<void>;
544
+ }
545
+
546
+ /**
547
+ * @file KrnlQ.ts
548
+ * @description In-process execution queue for a single KrnlTS service.
549
+ * Uses p-queue internally as the low-level scheduling and concurrency primitive.
550
+ * Zero Redis, zero Docker, zero BullMQ, 100% portable TypeScript.
551
+ */
552
+
553
+ type JobStatus = 'waiting' | 'active' | 'completed' | 'failed' | 'cancelled';
554
+ interface KrnlJobOptions {
555
+ priority?: number;
556
+ timeoutMs?: number;
557
+ retries?: number;
558
+ backoffMs?: number;
559
+ backoffPolicy?: 'fixed' | 'exponential';
560
+ idempotencyKey?: string;
561
+ correlationId?: string;
562
+ metadata?: Record<string, unknown>;
563
+ abortSignal?: AbortSignal;
564
+ }
565
+ interface KrnlJobDefinition<TInput = unknown, TOutput = unknown> {
566
+ id?: string;
567
+ name: string;
568
+ payload: TInput;
569
+ handler: (payload: TInput, context: ExecutionContext) => Promise<TOutput>;
570
+ options?: KrnlJobOptions;
571
+ }
572
+ interface KrnlJobHandle<TOutput = unknown> {
573
+ readonly id: string;
574
+ readonly name: string;
575
+ getStatus(): JobStatus;
576
+ result(): Promise<TOutput>;
577
+ cancel(): boolean;
578
+ }
579
+ interface KrnlQueueOptions {
580
+ queueName?: string;
581
+ concurrency?: number;
582
+ autoStart?: boolean;
583
+ maxRetainedJobs?: number;
584
+ }
585
+ interface InternalJobRecord<TOutput = unknown> {
586
+ id: string;
587
+ name: string;
588
+ status: JobStatus;
589
+ createdAt: number;
590
+ startedAt?: number;
591
+ completedAt?: number;
592
+ result?: TOutput;
593
+ error?: string;
594
+ abortController: AbortController;
595
+ resolvePromise: (val: TOutput) => void;
596
+ rejectPromise: (err: any) => void;
597
+ promise: Promise<TOutput>;
598
+ }
599
+ declare class KrnlQueue {
600
+ readonly queueName: string;
601
+ private readonly queue;
602
+ private readonly workerPool;
603
+ private readonly jobs;
604
+ private readonly idempotencyStore;
605
+ private readonly activeOrchestrations;
606
+ private readonly maxRetainedJobs;
607
+ constructor(options?: KrnlQueueOptions);
608
+ get concurrency(): number;
609
+ set concurrency(value: number);
610
+ get size(): number;
611
+ get pending(): number;
612
+ get isPaused(): boolean;
613
+ getWorkerBoundary(): WorkerExecutionBoundary;
614
+ getWorkerPool(): KrnlWorkerPool;
615
+ pause(): void;
616
+ resume(): void;
617
+ clear(): void;
618
+ private pruneJobs;
619
+ drain(): Promise<void>;
620
+ shutdown(options?: {
621
+ drain?: boolean;
622
+ }): Promise<void>;
623
+ close(): Promise<void>;
624
+ dispose(): Promise<void>;
625
+ start(): Promise<void>;
626
+ stop(): Promise<void>;
627
+ /**
628
+ * Enqueues a job returning a strong handle.
629
+ */
630
+ enqueue<TInput = unknown, TOutput = unknown>(jobDef: KrnlJobDefinition<TInput, TOutput>): KrnlJobHandle<TOutput>;
631
+ cancel(jobId: string): boolean;
632
+ getJob(jobId: string): InternalJobRecord | undefined;
633
+ /**
634
+ * Dispatches a single command through the KrnlQ worker boundary.
635
+ */
636
+ executeCommand<TIn = unknown, TOut = unknown>(command: BackendCommand<TIn>, handler: (payload: TIn, context: ExecutionContext) => Promise<TOut>): Promise<NormalizedResult<TOut>>;
637
+ /**
638
+ * Executes a full Canonical Orchestration DAG through KrnlQ and worker boundary.
639
+ * This is a first-class queued job scheduled via this.enqueue() to respect concurrency and worker limits.
640
+ */
641
+ executeOrchestration<TInput = unknown, TOutput = unknown>(descriptor: OrchestrationDescriptor, steps: readonly OrchestrationStep[], input: TInput, options?: {
642
+ correlationId?: string;
643
+ parentCorrelationId?: string;
644
+ idempotencyKey?: string;
645
+ timeoutMs?: number;
646
+ metadata?: Record<string, unknown>;
647
+ nestedRunner?: (orchId: string, input: unknown, ctx: OrchestrationContext) => Promise<unknown>;
648
+ abortSignal?: AbortSignal;
649
+ }): Promise<OrchestrationResult<TOutput>>;
650
+ private executeSingleStep;
651
+ private computeBackoff;
652
+ cancelExecution(executionId: string): boolean;
653
+ }
654
+
655
+ /**
656
+ * @file ServiceFacade.ts
657
+ * @description Canonical ServiceFacade for KrnlTS services.
658
+ * Callable boundary of a service, composing functionalities, functionality orchestrations,
659
+ * state, events, dependencies, capabilities, and lifecycle.
660
+ * All external invocations strictly route through KrnlQ and worker execution boundary.
661
+ */
662
+
663
+ interface DefaultFrontendReference {
664
+ component: string;
665
+ package?: string;
666
+ export?: string;
667
+ relationship?: 'recommended' | 'required';
668
+ }
669
+ interface ServiceFacadeConfig<TState extends Record<string, unknown> = Record<string, unknown>, TEvents extends Record<string, unknown> = Record<string, unknown>, TLibraries extends Record<string, unknown> = Record<string, unknown>> {
670
+ id: string;
671
+ name?: string;
672
+ version?: string;
673
+ description?: string;
674
+ functionalities?: Record<string, unknown>;
675
+ functionalityOrchestrations?: Record<string, FunctionalityOrchestration>;
676
+ /** @deprecated Use functionalityOrchestrations */
677
+ orchestrations?: Record<string, FunctionalityOrchestration>;
678
+ libraries?: TLibraries;
679
+ definition?: ServiceDefinition<TState, TEvents>;
680
+ instance?: IService<TState, TEvents>;
681
+ dependencies?: DependencyContract[];
682
+ capabilities?: ServiceCapability[];
683
+ queueOptions?: KrnlQueueOptions;
684
+ concurrency?: number;
685
+ /** Canonical FLOKS frontend component recommended for this service. */
686
+ defaultFrontend?: DefaultFrontendReference;
687
+ }
688
+ type IServiceFacade = ServiceFacade<any, any, any>;
689
+ declare class ServiceFacade<TState extends Record<string, unknown> = Record<string, unknown>, TEvents extends Record<string, unknown> = Record<string, unknown>, TLibraries extends Record<string, unknown> = Record<string, unknown>> {
690
+ readonly id: string;
691
+ readonly name: string;
692
+ readonly version: string;
693
+ readonly description: string;
694
+ readonly functionalities: Record<string, unknown>;
695
+ readonly functionalityOrchestrations: Record<string, FunctionalityOrchestration>;
696
+ readonly libraries: TLibraries;
697
+ readonly dependencies: readonly DependencyContract[];
698
+ readonly capabilities: readonly ServiceCapability[];
699
+ readonly defaultFrontend?: DefaultFrontendReference;
700
+ private readonly instance;
701
+ private readonly queue;
702
+ constructor(config: ServiceFacadeConfig<TState, TEvents, TLibraries>);
703
+ get orchestrations(): Record<string, FunctionalityOrchestration>;
704
+ getInstance(): IService<TState, TEvents>;
705
+ getQueue(): KrnlQueue;
706
+ getExecutionEngine(): KrnlQueue;
707
+ getWorkerBoundary(): WorkerExecutionBoundary;
708
+ getStatus(): ServiceStatus;
709
+ start(): Promise<void>;
710
+ stop(): Promise<void>;
711
+ dispose(): Promise<void>;
712
+ /**
713
+ * External caller callable boundary for single functionality / operation execution.
714
+ * Path: External Caller -> Service Facade -> KrnlQ Job -> Worker -> Functionality -> Result.
715
+ * Strictly avoids synchronous unmediated execution outside the queue.
716
+ */
717
+ call<TIn = unknown, TOut = unknown>(op: string, input?: TIn, ctx?: OperationContext): Promise<TOut>;
718
+ /**
719
+ * External caller callable boundary for functionality orchestration execution.
720
+ * Path: External Caller -> Service Facade -> KrnlQ Command -> Worker -> FunctionalityOrchestration -> Result.
721
+ */
722
+ orchestrate<TIn = unknown, TOut = unknown>(orchestrationName: string, input?: TIn, options?: {
723
+ correlationId?: string;
724
+ idempotencyKey?: string;
725
+ timeoutMs?: number;
726
+ metadata?: Record<string, unknown>;
727
+ abortSignal?: AbortSignal;
728
+ }): Promise<OrchestrationResult<TOut>>;
729
+ /**
730
+ * Executes a callable operation or orchestration through KrnlQ and worker boundary.
731
+ * Path: External Caller -> Service Facade -> KrnlQ Command -> Worker -> Functionality / Orchestration -> Result.
732
+ * Strictly queue-mediated; zero unmediated bypasses.
733
+ */
734
+ execute<TIn = unknown, TOut = unknown>(target: string, input?: TIn, options?: {
735
+ correlationId?: string;
736
+ idempotencyKey?: string;
737
+ timeoutMs?: number;
738
+ metadata?: Record<string, unknown>;
739
+ abortSignal?: AbortSignal;
740
+ }): Promise<any>;
741
+ getState(): Readonly<TState>;
742
+ setState(mutation: Partial<TState>): void;
743
+ on<K extends keyof TEvents & string>(event: K, handler: (payload: TEvents[K]) => void): () => void;
744
+ emit<K extends keyof TEvents & string>(event: K, payload: TEvents[K]): void;
745
+ registerFunctionality(name: string, functionality: unknown): this;
746
+ registerFunctionalityOrchestration(name: string, orchestration: FunctionalityOrchestration): this;
747
+ /** @deprecated Use registerFunctionalityOrchestration */
748
+ registerOrchestration(name: string, orchestration: FunctionalityOrchestration): this;
749
+ registerLibrary<TLib = unknown>(name: string, library: TLib): this;
750
+ getLibrary<TLib = unknown>(name: string): TLib;
751
+ get namespace(): ServiceNamespace<TLibraries, Record<string, unknown>, Record<string, FunctionalityOrchestration>>;
752
+ getNamespace(): ServiceNamespace<TLibraries, Record<string, unknown>, Record<string, FunctionalityOrchestration>>;
753
+ getServiceFacadeMetadata(): ServiceNamespace<TLibraries, Record<string, unknown>, Record<string, FunctionalityOrchestration>>;
754
+ }
755
+ declare function createServiceFacade<TState extends Record<string, unknown> = Record<string, unknown>, TEvents extends Record<string, unknown> = Record<string, unknown>, TLibraries extends Record<string, unknown> = Record<string, unknown>>(config: ServiceFacadeConfig<TState, TEvents, TLibraries>): ServiceFacade<TState, TEvents, TLibraries>;
756
+
188
757
  /**
189
758
  * @file HttpProtocolAdapter.ts
190
759
  * @description HTTP/HTTPS adapter for service exposition and remote consumption.
@@ -267,10 +836,37 @@ interface RegisteredServiceRecord {
267
836
  endpoints: EndpointDescriptor[];
268
837
  registeredAt: number;
269
838
  }
839
+ /**
840
+ * Central service catalog and capabilities registry.
841
+ *
842
+ * Registration Semantics:
843
+ * 1. register():
844
+ * Strict uniqueness enforced. If a service with the same ID is already registered
845
+ * (whether same version or different version), an Error is thrown.
846
+ * 2. replace():
847
+ * Explicit replacement method. Overwrites existing service registration while
848
+ * preserving the original registration timestamp (`registeredAt`).
849
+ */
270
850
  declare class ServiceRegistry {
271
- private services;
851
+ private readonly services;
852
+ /**
853
+ * Registers a service definition and its endpoints into the registry.
854
+ *
855
+ * @param definition Validated service definition.
856
+ * @param endpoints Optional list of active endpoint descriptors.
857
+ * @throws Error if definition or endpoints fail validation.
858
+ * @throws Error if service is already registered under the same ID.
859
+ */
272
860
  register(definition: ServiceDefinition, endpoints?: EndpointDescriptor[]): void;
273
- unregister(serviceId: string): void;
861
+ /**
862
+ * Explicitly replaces or updates a service definition and its endpoints in the registry.
863
+ * Preserves original registeredAt timestamp if the service was previously registered.
864
+ *
865
+ * @param definition Validated service definition.
866
+ * @param endpoints Optional list of active endpoint descriptors.
867
+ */
868
+ replace(definition: ServiceDefinition, endpoints?: EndpointDescriptor[]): void;
869
+ unregister(serviceId: string): boolean;
274
870
  get(serviceId: string): RegisteredServiceRecord | undefined;
275
871
  list(): RegisteredServiceRecord[];
276
872
  findByCapability(capabilityName: string): RegisteredServiceRecord[];
@@ -282,13 +878,16 @@ declare class ServiceRegistry {
282
878
  */
283
879
 
284
880
  declare class ServiceRuntime {
285
- private instances;
881
+ private readonly instances;
286
882
  readonly registry: ServiceRegistry;
287
883
  constructor(registry?: ServiceRegistry);
288
884
  register(service: IService): this;
885
+ unregister(serviceId: string): boolean;
289
886
  get(serviceId: string): IService | undefined;
887
+ list(): IService[];
290
888
  execute<TIn = unknown, TOut = unknown>(target: string, operation: string, input?: TIn, ctx?: OperationContext): Promise<TOut>;
291
889
  startAll(): Promise<void>;
890
+ disposeAll(): Promise<void>;
292
891
  stopAll(): Promise<void>;
293
892
  }
294
893
 
@@ -357,18 +956,6 @@ declare class ServiceEventBus<TEvents extends Record<string, unknown> = Record<s
357
956
  clear(): void;
358
957
  }
359
958
 
360
- /**
361
- * @file LifecycleManager.ts
362
- * @description Standard lifecycle transitions for services.
363
- */
364
- type ServiceStatus = 'uninitialized' | 'initializing' | 'ready' | 'starting' | 'running' | 'stopping' | 'stopped';
365
- declare class LifecycleManager {
366
- private status;
367
- getStatus(): ServiceStatus;
368
- setStatus(next: ServiceStatus): void;
369
- assertRunning(serviceName: string): void;
370
- }
371
-
372
959
  /**
373
960
  * @file ProtocolResolver.ts
374
961
  * @description Protocol selection resolving matching adapters from capabilities.
@@ -379,4 +966,4 @@ declare class ProtocolResolver {
379
966
  static getSupportedProtocols(definition: ServiceDefinition): ProtocolType[];
380
967
  }
381
968
 
382
- export { type Connection, type DependencyContract, type EndpointDescriptor, type EventContract, HttpProtocolAdapter, type IService, KrnlPackageReconciler, type LifecycleContract, LifecycleManager, MemoryTransport, type OperationContext, type OperationContract, P2PProtocolAdapter, type PeerRecord, type ProtocolAdapter, type ProtocolCapabilities, type ProtocolEnvelope, ProtocolResolver, type ProtocolType, type ReconcileResult, type RegisteredServiceRecord, type ServiceCapability, type ServiceDefinition, ServiceDiscovery, ServiceEventBus, ServiceInstance, ServiceProxy, ServiceRegistry, ServiceRuntime, ServiceStateStore, type ServiceStatus, type StateContract, UdpProtocolAdapter, WebSocketProtocolAdapter, createService, createServiceDefinition, createServiceProxy };
969
+ export { type BackendCommand, type Connection, type DAGValidationResult, type DefaultFrontendReference, type DependencyContract, type EndpointDescriptor, type EventContract, type ExecutionContext, type FunctionalityFlow, type FunctionalityFlowStep, FunctionalityOrchestration, type FunctionalityStepOptions, HttpProtocolAdapter, type IService, type IServiceFacade, type JobStatus, type KrnlJobDefinition, type KrnlJobHandle, type KrnlJobOptions, KrnlPackageReconciler, KrnlQueue, type KrnlQueueOptions, type KrnlWorkerInfo, KrnlWorkerPool, type KrnlWorkerState, type LifecycleContract, LifecycleManager, MemoryTransport, type NormalizedResult, type OperationContext, type OperationContract, type OrchestrationContext, type OrchestrationDefinition, type OrchestrationDescriptor, type OrchestrationFrontendReference, type OrchestrationResult, type OrchestrationStatus, type OrchestrationStep, P2PProtocolAdapter, type PeerRecord, type ProtocolAdapter, type ProtocolCapabilities, type ProtocolEnvelope, ProtocolResolver, type ProtocolType, type ReconcileResult, type RegisteredServiceRecord, type SagaCompensationHandler, type ServiceCapability, type ServiceDefinition, ServiceDiscovery, ServiceEventBus, ServiceFacade, type ServiceFacadeConfig, ServiceInstance, type ServiceNamespace, ServiceProxy, ServiceRegistry, ServiceRuntime, ServiceStateStore, type ServiceStatus, type StateContract, type StepCompensation, type StepCondition, type StepDefinition, type StepExecutionResult, type StepExecutionStatus, type StepRetryPolicy, type StepStatus, type StepTimeoutPolicy, type StepType, UdpProtocolAdapter, WebSocketProtocolAdapter, WorkerExecutionBoundary, createService, createServiceDefinition, createServiceFacade, createServiceProxy, validateOrchestrationDAG, validateServiceDefinition };