@brud/kernel 0.0.0-stage → 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (278) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +63 -2
  3. package/dist/index.d.ts +15 -0
  4. package/dist/index.js +13 -0
  5. package/dist/serviceModules/events.d.ts +1 -0
  6. package/dist/serviceModules/events.js +1 -0
  7. package/dist/serviceModules/exposedApiRegistry.d.ts +1 -0
  8. package/dist/serviceModules/exposedApiRegistry.js +1 -0
  9. package/dist/serviceModules/identityRegistry.d.ts +1 -0
  10. package/dist/serviceModules/identityRegistry.js +1 -0
  11. package/dist/serviceModules/interception.d.ts +1 -0
  12. package/dist/serviceModules/interception.js +1 -0
  13. package/dist/serviceModules/parser.d.ts +1 -0
  14. package/dist/serviceModules/parser.js +1 -0
  15. package/dist/serviceModules/router.d.ts +1 -0
  16. package/dist/serviceModules/router.js +1 -0
  17. package/dist/serviceModules/wasmCage.d.ts +1 -0
  18. package/dist/serviceModules/wasmCage.js +1 -0
  19. package/dist/services/Events/contracts/IEventsService.d.ts +64 -0
  20. package/dist/services/Events/contracts/IEventsService.js +1 -0
  21. package/dist/services/Events/contracts/errors.d.ts +31 -0
  22. package/dist/services/Events/contracts/errors.js +40 -0
  23. package/dist/services/Events/contracts/index.d.ts +3 -0
  24. package/dist/services/Events/contracts/index.js +3 -0
  25. package/dist/services/Events/contracts/tokens.d.ts +2 -0
  26. package/dist/services/Events/contracts/tokens.js +2 -0
  27. package/dist/services/Events/descriptor/EventsDescriptor.d.ts +9 -0
  28. package/dist/services/Events/descriptor/EventsDescriptor.js +56 -0
  29. package/dist/services/Events/descriptor/tokens.d.ts +1 -0
  30. package/dist/services/Events/descriptor/tokens.js +1 -0
  31. package/dist/services/Events/index.d.ts +4 -0
  32. package/dist/services/Events/index.js +4 -0
  33. package/dist/services/Events/orchestrator/EventsService.d.ts +51 -0
  34. package/dist/services/Events/orchestrator/EventsService.js +339 -0
  35. package/dist/services/Events/orchestrator/index.d.ts +2 -0
  36. package/dist/services/Events/orchestrator/index.js +2 -0
  37. package/dist/services/Events/orchestrator/limits.d.ts +22 -0
  38. package/dist/services/Events/orchestrator/limits.js +33 -0
  39. package/dist/services/Events/serviceModule.d.ts +2 -0
  40. package/dist/services/Events/serviceModule.js +5 -0
  41. package/dist/services/ExposedApiRegistry/contracts/IExposedApiRegistry.d.ts +44 -0
  42. package/dist/services/ExposedApiRegistry/contracts/IExposedApiRegistry.js +1 -0
  43. package/dist/services/ExposedApiRegistry/contracts/errors.d.ts +132 -0
  44. package/dist/services/ExposedApiRegistry/contracts/errors.js +195 -0
  45. package/dist/services/ExposedApiRegistry/contracts/index.d.ts +9 -0
  46. package/dist/services/ExposedApiRegistry/contracts/index.js +4 -0
  47. package/dist/services/ExposedApiRegistry/contracts/policy.d.ts +90 -0
  48. package/dist/services/ExposedApiRegistry/contracts/policy.js +169 -0
  49. package/dist/services/ExposedApiRegistry/contracts/registrant.d.ts +37 -0
  50. package/dist/services/ExposedApiRegistry/contracts/registrant.js +36 -0
  51. package/dist/services/ExposedApiRegistry/contracts/types.d.ts +112 -0
  52. package/dist/services/ExposedApiRegistry/contracts/types.js +73 -0
  53. package/dist/services/ExposedApiRegistry/descriptor/ExposedApiRegistryDescriptor.d.ts +44 -0
  54. package/dist/services/ExposedApiRegistry/descriptor/ExposedApiRegistryDescriptor.js +58 -0
  55. package/dist/services/ExposedApiRegistry/descriptor/tokens.d.ts +8 -0
  56. package/dist/services/ExposedApiRegistry/descriptor/tokens.js +8 -0
  57. package/dist/services/ExposedApiRegistry/index.d.ts +6 -0
  58. package/dist/services/ExposedApiRegistry/index.js +5 -0
  59. package/dist/services/ExposedApiRegistry/orchestrator/ExposedApiRegistryService.d.ts +61 -0
  60. package/dist/services/ExposedApiRegistry/orchestrator/ExposedApiRegistryService.js +407 -0
  61. package/dist/services/ExposedApiRegistry/orchestrator/index.d.ts +2 -0
  62. package/dist/services/ExposedApiRegistry/orchestrator/index.js +1 -0
  63. package/dist/services/ExposedApiRegistry/serviceModule.d.ts +10 -0
  64. package/dist/services/ExposedApiRegistry/serviceModule.js +20 -0
  65. package/dist/services/ExposedApiRegistry/storage/protection.d.ts +21 -0
  66. package/dist/services/ExposedApiRegistry/storage/protection.js +35 -0
  67. package/dist/services/ExposedApiRegistry/storage/scopeRecord.d.ts +45 -0
  68. package/dist/services/ExposedApiRegistry/storage/scopeRecord.js +178 -0
  69. package/dist/services/IdentityRegistry/contracts/errors.d.ts +88 -0
  70. package/dist/services/IdentityRegistry/contracts/errors.js +128 -0
  71. package/dist/services/IdentityRegistry/contracts/index.d.ts +5 -0
  72. package/dist/services/IdentityRegistry/contracts/index.js +3 -0
  73. package/dist/services/IdentityRegistry/contracts/types.d.ts +77 -0
  74. package/dist/services/IdentityRegistry/contracts/types.js +18 -0
  75. package/dist/services/IdentityRegistry/descriptor/descriptor.d.ts +36 -0
  76. package/dist/services/IdentityRegistry/descriptor/descriptor.js +44 -0
  77. package/dist/services/IdentityRegistry/descriptor/tokens.d.ts +8 -0
  78. package/dist/services/IdentityRegistry/descriptor/tokens.js +8 -0
  79. package/dist/services/IdentityRegistry/index.d.ts +11 -0
  80. package/dist/services/IdentityRegistry/index.js +6 -0
  81. package/dist/services/IdentityRegistry/orchestrator/IdentityRegistryService.d.ts +47 -0
  82. package/dist/services/IdentityRegistry/orchestrator/IdentityRegistryService.js +240 -0
  83. package/dist/services/IdentityRegistry/serviceModule.d.ts +10 -0
  84. package/dist/services/IdentityRegistry/serviceModule.js +24 -0
  85. package/dist/services/IdentityRegistry/storage/registryDocument.d.ts +55 -0
  86. package/dist/services/IdentityRegistry/storage/registryDocument.js +235 -0
  87. package/dist/services/Interception/contracts/IInterceptionService.d.ts +65 -0
  88. package/dist/services/Interception/contracts/IInterceptionService.js +1 -0
  89. package/dist/services/Interception/contracts/errors.d.ts +26 -0
  90. package/dist/services/Interception/contracts/errors.js +35 -0
  91. package/dist/services/Interception/contracts/index.d.ts +3 -0
  92. package/dist/services/Interception/contracts/index.js +3 -0
  93. package/dist/services/Interception/contracts/tokens.d.ts +2 -0
  94. package/dist/services/Interception/contracts/tokens.js +2 -0
  95. package/dist/services/Interception/descriptor/InterceptionDescriptor.d.ts +9 -0
  96. package/dist/services/Interception/descriptor/InterceptionDescriptor.js +49 -0
  97. package/dist/services/Interception/descriptor/tokens.d.ts +1 -0
  98. package/dist/services/Interception/descriptor/tokens.js +1 -0
  99. package/dist/services/Interception/index.d.ts +4 -0
  100. package/dist/services/Interception/index.js +4 -0
  101. package/dist/services/Interception/orchestrator/InterceptionService.d.ts +32 -0
  102. package/dist/services/Interception/orchestrator/InterceptionService.js +180 -0
  103. package/dist/services/Interception/orchestrator/index.d.ts +1 -0
  104. package/dist/services/Interception/orchestrator/index.js +1 -0
  105. package/dist/services/Interception/serviceModule.d.ts +2 -0
  106. package/dist/services/Interception/serviceModule.js +5 -0
  107. package/dist/services/Parser/contracts/IParserService.d.ts +21 -0
  108. package/dist/services/Parser/contracts/IParserService.js +1 -0
  109. package/dist/services/Parser/contracts/errors.d.ts +25 -0
  110. package/dist/services/Parser/contracts/errors.js +33 -0
  111. package/dist/services/Parser/contracts/index.d.ts +4 -0
  112. package/dist/services/Parser/contracts/index.js +1 -0
  113. package/dist/services/Parser/contracts/types.d.ts +42 -0
  114. package/dist/services/Parser/contracts/types.js +1 -0
  115. package/dist/services/Parser/descriptor/ParserDescriptor.d.ts +23 -0
  116. package/dist/services/Parser/descriptor/ParserDescriptor.js +50 -0
  117. package/dist/services/Parser/descriptor/tokens.d.ts +8 -0
  118. package/dist/services/Parser/descriptor/tokens.js +8 -0
  119. package/dist/services/Parser/index.d.ts +8 -0
  120. package/dist/services/Parser/index.js +8 -0
  121. package/dist/services/Parser/orchestrator/ParserService.d.ts +20 -0
  122. package/dist/services/Parser/orchestrator/ParserService.js +105 -0
  123. package/dist/services/Parser/orchestrator/index.d.ts +1 -0
  124. package/dist/services/Parser/orchestrator/index.js +1 -0
  125. package/dist/services/Parser/parser/indexSynthesis.d.ts +11 -0
  126. package/dist/services/Parser/parser/indexSynthesis.js +13 -0
  127. package/dist/services/Parser/parser/parameters.d.ts +14 -0
  128. package/dist/services/Parser/parser/parameters.js +89 -0
  129. package/dist/services/Parser/parser/scanner.d.ts +48 -0
  130. package/dist/services/Parser/parser/scanner.js +156 -0
  131. package/dist/services/Parser/parser/syntax.d.ts +30 -0
  132. package/dist/services/Parser/parser/syntax.js +34 -0
  133. package/dist/services/Parser/serviceModule.d.ts +2 -0
  134. package/dist/services/Parser/serviceModule.js +5 -0
  135. package/dist/services/Router/bootOptions.d.ts +2 -0
  136. package/dist/services/Router/bootOptions.js +2 -0
  137. package/dist/services/Router/contracts/IRouterService.d.ts +43 -0
  138. package/dist/services/Router/contracts/IRouterService.js +1 -0
  139. package/dist/services/Router/contracts/caller.d.ts +6 -0
  140. package/dist/services/Router/contracts/caller.js +6 -0
  141. package/dist/services/Router/contracts/errors.d.ts +56 -0
  142. package/dist/services/Router/contracts/errors.js +75 -0
  143. package/dist/services/Router/contracts/index.d.ts +8 -0
  144. package/dist/services/Router/contracts/index.js +4 -0
  145. package/dist/services/Router/contracts/kind.d.ts +7 -0
  146. package/dist/services/Router/contracts/kind.js +10 -0
  147. package/dist/services/Router/contracts/registrant.d.ts +23 -0
  148. package/dist/services/Router/contracts/registrant.js +13 -0
  149. package/dist/services/Router/contracts/types.d.ts +90 -0
  150. package/dist/services/Router/contracts/types.js +1 -0
  151. package/dist/services/Router/descriptor/RouterDescriptor.d.ts +32 -0
  152. package/dist/services/Router/descriptor/RouterDescriptor.js +92 -0
  153. package/dist/services/Router/descriptor/tokens.d.ts +9 -0
  154. package/dist/services/Router/descriptor/tokens.js +9 -0
  155. package/dist/services/Router/index.d.ts +4 -0
  156. package/dist/services/Router/index.js +4 -0
  157. package/dist/services/Router/orchestrator/RouterService.d.ts +74 -0
  158. package/dist/services/Router/orchestrator/RouterService.js +332 -0
  159. package/dist/services/Router/orchestrator/index.d.ts +2 -0
  160. package/dist/services/Router/orchestrator/index.js +1 -0
  161. package/dist/services/Router/serviceModule.d.ts +4 -0
  162. package/dist/services/Router/serviceModule.js +22 -0
  163. package/dist/services/WasmCage/index.d.ts +7 -0
  164. package/dist/services/WasmCage/index.js +4 -0
  165. package/dist/services/WasmCage/scripts/prepin.d.ts +1 -0
  166. package/dist/services/WasmCage/scripts/prepin.js +38 -0
  167. package/dist/services/WasmCage/serviceModule.d.ts +12 -0
  168. package/dist/services/WasmCage/serviceModule.js +18 -0
  169. package/dist/services/WasmCage/src/caged.d.ts +104 -0
  170. package/dist/services/WasmCage/src/caged.js +381 -0
  171. package/dist/services/WasmCage/src/descriptor.d.ts +47 -0
  172. package/dist/services/WasmCage/src/descriptor.js +56 -0
  173. package/dist/services/WasmCage/src/native.d.ts +29 -0
  174. package/dist/services/WasmCage/src/native.js +66 -0
  175. package/dist/services/WasmCage/src/nativeDigests.d.ts +9 -0
  176. package/dist/services/WasmCage/src/nativeDigests.js +15 -0
  177. package/dist/services/WasmCage/src/package.d.ts +36 -0
  178. package/dist/services/WasmCage/src/package.js +122 -0
  179. package/dist/services/shared/canonicalJson.d.ts +29 -0
  180. package/dist/services/shared/canonicalJson.js +93 -0
  181. package/dist/services/shared/documentStore.d.ts +16 -0
  182. package/dist/services/shared/documentStore.js +98 -0
  183. package/dist/src/bootstrap/bootKernelInternal.d.ts +18 -0
  184. package/dist/src/bootstrap/bootKernelInternal.js +420 -0
  185. package/dist/src/bootstrap/bootTypes.d.ts +89 -0
  186. package/dist/src/bootstrap/bootTypes.js +1 -0
  187. package/dist/src/bootstrap/config/index.d.ts +3 -0
  188. package/dist/src/bootstrap/config/index.js +2 -0
  189. package/dist/src/bootstrap/config/integrity.d.ts +34 -0
  190. package/dist/src/bootstrap/config/integrity.js +79 -0
  191. package/dist/src/bootstrap/config/parse.d.ts +15 -0
  192. package/dist/src/bootstrap/config/parse.js +81 -0
  193. package/dist/src/bootstrap/config/pathWriteGuard.d.ts +20 -0
  194. package/dist/src/bootstrap/config/pathWriteGuard.js +349 -0
  195. package/dist/src/bootstrap/config/types.d.ts +41 -0
  196. package/dist/src/bootstrap/config/types.js +15 -0
  197. package/dist/src/bootstrap/hardcore.d.ts +212 -0
  198. package/dist/src/bootstrap/hardcore.js +312 -0
  199. package/dist/src/bootstrap/hardcoreServices.d.ts +10 -0
  200. package/dist/src/bootstrap/hardcoreServices.js +258 -0
  201. package/dist/src/bootstrap/index.d.ts +8 -0
  202. package/dist/src/bootstrap/index.js +5 -0
  203. package/dist/src/bootstrap/packageRequirements.d.ts +26 -0
  204. package/dist/src/bootstrap/packageRequirements.js +52 -0
  205. package/dist/src/contracts/accessBroker.d.ts +53 -0
  206. package/dist/src/contracts/accessBroker.js +1 -0
  207. package/dist/src/contracts/brudOperation.d.ts +20 -0
  208. package/dist/src/contracts/brudOperation.js +20 -0
  209. package/dist/src/contracts/callChain.d.ts +161 -0
  210. package/dist/src/contracts/callChain.js +19 -0
  211. package/dist/src/contracts/capability.d.ts +26 -0
  212. package/dist/src/contracts/capability.js +26 -0
  213. package/dist/src/contracts/container.d.ts +17 -0
  214. package/dist/src/contracts/container.js +8 -0
  215. package/dist/src/contracts/context.d.ts +19 -0
  216. package/dist/src/contracts/context.js +1 -0
  217. package/dist/src/contracts/contextContract.d.ts +129 -0
  218. package/dist/src/contracts/contextContract.js +285 -0
  219. package/dist/src/contracts/dispatchView.d.ts +21 -0
  220. package/dist/src/contracts/dispatchView.js +1 -0
  221. package/dist/src/contracts/handler.d.ts +28 -0
  222. package/dist/src/contracts/handler.js +1 -0
  223. package/dist/src/contracts/index.d.ts +25 -0
  224. package/dist/src/contracts/index.js +8 -0
  225. package/dist/src/contracts/kernel.d.ts +60 -0
  226. package/dist/src/contracts/kernel.js +1 -0
  227. package/dist/src/contracts/lifecycle.d.ts +59 -0
  228. package/dist/src/contracts/lifecycle.js +1 -0
  229. package/dist/src/contracts/manifest.d.ts +145 -0
  230. package/dist/src/contracts/manifest.js +295 -0
  231. package/dist/src/contracts/pipeline.d.ts +8 -0
  232. package/dist/src/contracts/pipeline.js +1 -0
  233. package/dist/src/contracts/policy.d.ts +75 -0
  234. package/dist/src/contracts/policy.js +77 -0
  235. package/dist/src/contracts/registry.d.ts +7 -0
  236. package/dist/src/contracts/registry.js +1 -0
  237. package/dist/src/contracts/serviceDescriptor.d.ts +67 -0
  238. package/dist/src/contracts/serviceDescriptor.js +1 -0
  239. package/dist/src/contracts/serviceToken.d.ts +36 -0
  240. package/dist/src/contracts/serviceToken.js +16 -0
  241. package/dist/src/engine/BrudKernel.d.ts +118 -0
  242. package/dist/src/engine/BrudKernel.js +366 -0
  243. package/dist/src/engine/ExecutionPipeline.d.ts +13 -0
  244. package/dist/src/engine/ExecutionPipeline.js +62 -0
  245. package/dist/src/engine/KernelAccessBroker.d.ts +47 -0
  246. package/dist/src/engine/KernelAccessBroker.js +107 -0
  247. package/dist/src/engine/KernelRegistry.d.ts +14 -0
  248. package/dist/src/engine/KernelRegistry.js +33 -0
  249. package/dist/src/engine/OperationRegistry.d.ts +9 -0
  250. package/dist/src/engine/OperationRegistry.js +18 -0
  251. package/dist/src/engine/ServiceContainer.d.ts +13 -0
  252. package/dist/src/engine/ServiceContainer.js +53 -0
  253. package/dist/src/engine/callChain.d.ts +68 -0
  254. package/dist/src/engine/callChain.js +180 -0
  255. package/dist/src/engine/dag.d.ts +2 -0
  256. package/dist/src/engine/dag.js +34 -0
  257. package/dist/src/engine/errors.d.ts +26 -0
  258. package/dist/src/engine/errors.js +52 -0
  259. package/dist/src/engine/index.d.ts +11 -0
  260. package/dist/src/engine/index.js +8 -0
  261. package/dist/src/engine/state.d.ts +1 -0
  262. package/dist/src/engine/state.js +1 -0
  263. package/dist/src/validation/jsonSchema/compile.d.ts +8 -0
  264. package/dist/src/validation/jsonSchema/compile.js +386 -0
  265. package/dist/src/validation/jsonSchema/index.d.ts +3 -0
  266. package/dist/src/validation/jsonSchema/index.js +2 -0
  267. package/dist/src/validation/jsonSchema/jsonValue.d.ts +29 -0
  268. package/dist/src/validation/jsonSchema/jsonValue.js +190 -0
  269. package/dist/src/validation/jsonSchema/pattern.d.ts +28 -0
  270. package/dist/src/validation/jsonSchema/pattern.js +155 -0
  271. package/dist/src/validation/jsonSchema/types.d.ts +71 -0
  272. package/dist/src/validation/jsonSchema/types.js +15 -0
  273. package/package.json +59 -4
  274. package/services/WasmCage/native/brud-wasm-cage.darwin-arm64.node +0 -0
  275. package/services/WasmCage/native/brud-wasm-cage.darwin-x64.node +0 -0
  276. package/services/WasmCage/native/brud-wasm-cage.linux-arm64-gnu.node +0 -0
  277. package/services/WasmCage/native/brud-wasm-cage.linux-x64-gnu.node +0 -0
  278. package/services/WasmCage/native/brud-wasm-cage.win32-x64-msvc.node +0 -0
@@ -0,0 +1,258 @@
1
+ /**
2
+ * The kernel's fixed hardcore service set.
3
+ *
4
+ * This list is compiled into the kernel. It is not read from config and cannot
5
+ * be edited at runtime. Each entry declares its own token, its own pinned
6
+ * package digests, its own contract version, its own contract interface, and
7
+ * its own boot hook. The generic mechanism in `hardcore.ts` verifies and boots
8
+ * every entry the same way and knows nothing about what any entry's service
9
+ * does.
10
+ *
11
+ * The kernel core never imports a hardcore service. Each boot hook narrows its
12
+ * instance structurally to the one surface it calls.
13
+ *
14
+ * Two representations of each package ship from one source tree: the
15
+ * TypeScript sources the kernel tests load, and the compiled JavaScript the
16
+ * built package loads. Both digests are pinned per entry. Changing any file in
17
+ * an entry's package graph requires a kernel rebuild with new pinned digests.
18
+ */
19
+ /** Pinned digests of the identity registry package. */
20
+ const IDENTITY_REGISTRY_SOURCE_HASH = 'c141250710c3dc8b446fc616f2769a7f76ac000e83a89aa61329d50787946500';
21
+ const IDENTITY_REGISTRY_BUILT_HASH = 'e169f2b42cfdc6d277bb01a164f569d29c03687bcfc50ccdce9f6ebf4f7f1895';
22
+ /** Pinned digests of the exposed API registry package. */
23
+ const EXPOSED_API_REGISTRY_SOURCE_HASH = '1f90bc7913dbf4de5448fbb33631966a4508fd73289aa4d510ec6b4eefe3d00f';
24
+ const EXPOSED_API_REGISTRY_BUILT_HASH = '1be233d60e6ae4d136531be3198bf5033f8b34b0cd4d8af9ca8a2563420b793f';
25
+ /** Pinned digests of the parser package. */
26
+ const PARSER_SOURCE_HASH = '32f5efdf99cb14cf1a1d1ed35180aabcce3f16fd51d9fcd44f3c184ca3b0cbe6';
27
+ const PARSER_BUILT_HASH = '2b2520552e7652a0992677bd8607cbe0d4b798e4e629963a4a27727a851e3c37';
28
+ /** Pinned digests of the router package. */
29
+ const ROUTER_SOURCE_HASH = '4050d73a4bc998f6f38c51524b801b1dca2ed27881d944b9d08daab95afa6a5c';
30
+ const ROUTER_BUILT_HASH = '502d309405265145cfb2cf39e28f044b088e36e6ac917ffa477a241454d253c4';
31
+ /**
32
+ * Pinned digests of the WASM cage package.
33
+ *
34
+ * The source pin is computed by `computePackageContentHash` over the cage's
35
+ * package graph, which includes the cage's built `.node` artifact as a binary
36
+ * leaf. The built pin is recorded as needing a build: no built kernel has been
37
+ * produced since the cage was added, so the value below is a placeholder that
38
+ * a kernel build replaces.
39
+ */
40
+ const WASM_CAGE_SOURCE_HASH = '4160218f3ee904370cf2972b725511e65b50704a88f4d88547fb536cc0b5e0ff';
41
+ const WASM_CAGE_BUILT_HASH = '579ec2449e6a73e28ea9c88095d7750f01b1eb787e729c5ef7054758125f4873';
42
+ /**
43
+ * Pinned digests of the events hardcore package.
44
+ *
45
+ * The source pin is computed by `computePackageContentHash` over the events
46
+ * package graph. The built pin is recorded as needing a build: no built kernel
47
+ * has been produced since the events package was added, so the value below is a
48
+ * placeholder that a kernel build replaces.
49
+ */
50
+ /** Pinned digests of the interception package (recomputed with computePackageContentHash). */
51
+ const INTERCEPTION_SOURCE_HASH = 'ad319b6ad6828bb3e5eed4411c79294a093b2740880e20f942f280ffda0b7da3';
52
+ const INTERCEPTION_BUILT_HASH = '372361ad9c50b00e5956319891b615f5f3397d911a0fd168438a34985153d960';
53
+ const EVENTS_SOURCE_HASH = 'a79dde9ab18890ec10b47fd6c0570edeab15cc29ea3c0341373662bef4c0cc41';
54
+ const EVENTS_BUILT_HASH = 'b91fc7107e7c7ba65304262ffd6daf35dd7d5e2f64c6d8ec707db74348a41cfa';
55
+ /** Narrows an instance to the identity registry's boot surface. */
56
+ function asIdentityBootSurface(instance, token) {
57
+ if (instance === null
58
+ || typeof instance !== 'object'
59
+ || typeof instance.issue !== 'function') {
60
+ throw new TypeError(`Hardcore service "${token}" does not expose its declared boot surface`);
61
+ }
62
+ return instance;
63
+ }
64
+ /** Narrows an instance to the exposed API registry's boot surface. */
65
+ function asExposedApiBootSurface(instance, token) {
66
+ if (instance === null
67
+ || typeof instance !== 'object'
68
+ || typeof instance.attachKernel !== 'function'
69
+ || typeof instance.register !== 'function'
70
+ || typeof instance.seal !== 'function') {
71
+ throw new TypeError(`Hardcore service "${token}" does not expose its declared boot surface`);
72
+ }
73
+ return instance;
74
+ }
75
+ /** The fixed hardcore list compiled into the kernel. */
76
+ export const HARDCORE_SERVICES = [
77
+ {
78
+ token: 'brud.core.identityRegistry',
79
+ expectedContentHash: IDENTITY_REGISTRY_SOURCE_HASH,
80
+ expectedBuiltContentHash: IDENTITY_REGISTRY_BUILT_HASH,
81
+ contractVersion: '1.0.0',
82
+ contractInterface: ['issue', 'resolve', 'retire', 'revoke'],
83
+ // Records one provisional binding per composed participant while the
84
+ // registry is still mutable, and records the issued token as that
85
+ // participant's kernel identity.
86
+ boot: (instance, context) => {
87
+ const registry = asIdentityBootSurface(instance, context.token);
88
+ for (const entry of context.composition) {
89
+ const record = registry.issue({
90
+ publisher: entry.token,
91
+ contentHash: entry.contentHash,
92
+ metadata: Object.freeze({
93
+ source: 'kernel.composition',
94
+ path: entry.path,
95
+ official: entry.official,
96
+ provisional: true,
97
+ }),
98
+ });
99
+ context.recordIdentity(entry.token, record.token);
100
+ }
101
+ },
102
+ },
103
+ {
104
+ token: 'brud.core.exposedApiRegistry',
105
+ expectedContentHash: EXPOSED_API_REGISTRY_SOURCE_HASH,
106
+ expectedBuiltContentHash: EXPOSED_API_REGISTRY_BUILT_HASH,
107
+ contractVersion: '1.0.0',
108
+ contractInterface: ['register', 'resolve'],
109
+ // Admission. Attaches the kernel's call authority and the composition's
110
+ // name pins, registers every exposure each participant's manifest declares
111
+ // under that participant's kernel identity, and seals the window before
112
+ // any composed participant is constructed.
113
+ boot: (instance, context) => {
114
+ const registry = asExposedApiBootSurface(instance, context.token);
115
+ registry.attachKernel(context.authority, context.config.exposureOwners ?? {});
116
+ for (const entry of context.composition) {
117
+ if (entry.manifest.exposures.length === 0) {
118
+ continue;
119
+ }
120
+ const owner = context.identityOf(entry.token);
121
+ if (owner === undefined) {
122
+ throw new TypeError(`Participant "${entry.token}" declares exposures but has no kernel identity`);
123
+ }
124
+ for (const declaration of entry.manifest.exposures) {
125
+ registry.register(owner, declaration);
126
+ }
127
+ }
128
+ registry.seal();
129
+ },
130
+ },
131
+ {
132
+ token: 'brud.core.parser',
133
+ expectedContentHash: PARSER_SOURCE_HASH,
134
+ expectedBuiltContentHash: PARSER_BUILT_HASH,
135
+ contractVersion: '1.0.0',
136
+ contractInterface: ['parse'],
137
+ // The Parser performs no boot-time work. Its instance is ready once the
138
+ // kernel initializes it; this hook only satisfies the uniform signature.
139
+ boot: (_instance, _context) => {
140
+ void _instance;
141
+ void _context;
142
+ },
143
+ },
144
+ {
145
+ token: 'brud.core.router',
146
+ expectedContentHash: ROUTER_SOURCE_HASH,
147
+ expectedBuiltContentHash: ROUTER_BUILT_HASH,
148
+ contractVersion: '2.0.0',
149
+ contractInterface: [
150
+ 'register',
151
+ 'closeRegistration',
152
+ 'isRegistrationOpen',
153
+ 'registeredKinds',
154
+ 'kinds',
155
+ 'route',
156
+ 'dispatch',
157
+ ],
158
+ // Binds the call chain. The registration window is opened by its
159
+ // descriptor and closed by its module's boot-registrant hook, which the
160
+ // kernel calls after composed construction.
161
+ boot: (instance, context) => {
162
+ const router = instance;
163
+ // The Router reads the real caller from the kernel call chain.
164
+ router.bindAuthority(context.authority);
165
+ // Declared kinds (`manifest.kinds`): any participant, native or caged.
166
+ for (const entry of context.composition) {
167
+ if (entry.manifest.kinds.length === 0) {
168
+ continue;
169
+ }
170
+ const owner = context.identityOf(entry.token);
171
+ if (owner === undefined) {
172
+ throw new TypeError(`Participant "${entry.token}" declares kinds but has no kernel identity`);
173
+ }
174
+ for (const declaration of entry.manifest.kinds) {
175
+ router.registerDeclared(owner, declaration);
176
+ }
177
+ }
178
+ },
179
+ },
180
+ {
181
+ token: 'brud.core.wasmCage',
182
+ expectedContentHash: WASM_CAGE_SOURCE_HASH,
183
+ expectedBuiltContentHash: WASM_CAGE_BUILT_HASH,
184
+ contractVersion: '1.0.0',
185
+ contractInterface: ['resolve'],
186
+ // The cage is a mechanism, not an official participant: it holds the
187
+ // participants the composition has not declared official. The identity-to-
188
+ // official mapping reads this and maps the cage to non-official.
189
+ mechanism: true,
190
+ // The cage's boot hook binds the kernel's call authority so its `resolve`
191
+ // can start a runtime-origin chain. It opens no participant-facing
192
+ // registration, so the seal is a no-op.
193
+ boot: (instance, context) => {
194
+ const cage = instance;
195
+ cage.bindAuthority(context.authority);
196
+ },
197
+ },
198
+ {
199
+ token: 'brud.core.events',
200
+ expectedContentHash: EVENTS_SOURCE_HASH,
201
+ expectedBuiltContentHash: EVENTS_BUILT_HASH,
202
+ contractVersion: '1.0.0',
203
+ contractInterface: ['emit', 'pull', 'close', 'list', 'subscribe'],
204
+ // Events are a mechanism, not an official participant: the events hardcore
205
+ // holds the declared events and carries deliveries; the participant that
206
+ // declares an event is the giver. The identity-to-official mapping reads
207
+ // this and maps the events hardcore to non-official.
208
+ mechanism: true,
209
+ // The events hardcore's boot hook binds the kernel's call authority and
210
+ // populates its boot-time catalogue from each participant's
211
+ // `manifest.events`.
212
+ boot: (instance, context) => {
213
+ const events = instance;
214
+ events.bindAuthority(context.authority);
215
+ for (const entry of context.composition) {
216
+ if (entry.manifest.events.length === 0) {
217
+ continue;
218
+ }
219
+ const owner = context.identityOf(entry.token);
220
+ if (owner === undefined) {
221
+ throw new TypeError(`Participant "${entry.token}" declares events but has no kernel identity`);
222
+ }
223
+ for (const declaration of entry.manifest.events) {
224
+ events.registerDeclaration(owner, declaration);
225
+ }
226
+ }
227
+ },
228
+ },
229
+ {
230
+ token: 'brud.core.interception',
231
+ expectedContentHash: INTERCEPTION_SOURCE_HASH,
232
+ expectedBuiltContentHash: INTERCEPTION_BUILT_HASH,
233
+ contractVersion: '1.0.0',
234
+ contractInterface: ['evaluate', 'list'],
235
+ // Interception is a mechanism: the giver of an interception point and the
236
+ // admitted interceptors are the participants; the hardcore only pairs them
237
+ // at boot and runs the verdicts.
238
+ mechanism: true,
239
+ boot: (instance, context) => {
240
+ const interception = instance;
241
+ interception.bindAuthority(context.authority);
242
+ interception.registerComposition(context.composition.map((entry) => ({
243
+ token: entry.token,
244
+ identity: context.identityOf(entry.token),
245
+ manifest: entry.manifest,
246
+ })));
247
+ },
248
+ },
249
+ ];
250
+ /**
251
+ * Reports whether a token is named by the compiled hardcore list.
252
+ *
253
+ * Planned: this universal membership helper has no production caller yet. The
254
+ * engine currently receives the set it needs from the loader.
255
+ */
256
+ export function isHardcoreToken(token) {
257
+ return HARDCORE_SERVICES.some((hardcore) => hardcore.token === token);
258
+ }
@@ -0,0 +1,8 @@
1
+ export { bootKernel, createDeferredKernel, } from './bootKernelInternal.js';
2
+ export { HardcoreIdentityError, HardcoreServiceError, buildHardcoreBootEntries, computePackageContentHash, hashPackageFile, invokeHardcoreBootHooks, verifyHardcoreServices, } from './hardcore.js';
3
+ export type { ComposedServiceDescriptor, HardcoreBootContext, HardcoreBootEntry, HardcoreBootHook, HardcoreCheck, HardcoreContract, HardcoreInitializedInstance, HardcoreService, } from './hardcore.js';
4
+ export { HARDCORE_SERVICES, isHardcoreToken, } from './hardcoreServices.js';
5
+ export type { BootKernelOptions, ComposeKernelOptions, KernelServiceModuleContext, ServiceModule, } from './bootTypes.js';
6
+ export type { BrudConfig, BrudConfigEntry, BrudConfigErrorCode, } from './config/types.js';
7
+ export { BrudConfigError } from './config/types.js';
8
+ export { parseBrudConfig } from './config/parse.js';
@@ -0,0 +1,5 @@
1
+ export { bootKernel, createDeferredKernel, } from './bootKernelInternal.js';
2
+ export { HardcoreIdentityError, HardcoreServiceError, buildHardcoreBootEntries, computePackageContentHash, hashPackageFile, invokeHardcoreBootHooks, verifyHardcoreServices, } from './hardcore.js';
3
+ export { HARDCORE_SERVICES, isHardcoreToken, } from './hardcoreServices.js';
4
+ export { BrudConfigError } from './config/types.js';
5
+ export { parseBrudConfig } from './config/parse.js';
@@ -0,0 +1,26 @@
1
+ /**
2
+ * The powers a participant package may say it needs. A fixed vocabulary, so the
3
+ * refusal message is never free text from the package.
4
+ */
5
+ export declare const PACKAGE_POWERS: readonly ["environment", "filesystem", "network", "process"];
6
+ /** What a participant package requires of the composition that loads it. */
7
+ export interface PackageRequirements {
8
+ /** The package refuses to load unless the composition declares its entry official. */
9
+ readonly official: boolean;
10
+ /** The powers it will use, shown to the owner next to the refusal. */
11
+ readonly powers: readonly string[];
12
+ }
13
+ /** A `requires` section that is malformed. */
14
+ export declare class PackageRequirementsError extends Error {
15
+ constructor(message: string);
16
+ }
17
+ /**
18
+ * Reads the optional `requires` section of a participant package's data file.
19
+ * A requirement can only refuse a load; it never grants officialness, which
20
+ * stays the composition owner's decision.
21
+ *
22
+ * @param manifestPath - Absolute path of `brud.participant.json`.
23
+ * @returns The requirements; none when the section is absent.
24
+ * @throws {PackageRequirementsError} When the file is unreadable or the section is malformed.
25
+ */
26
+ export declare function readPackageRequirements(manifestPath: string): PackageRequirements;
@@ -0,0 +1,52 @@
1
+ import { readFileSync } from 'node:fs';
2
+ /**
3
+ * The powers a participant package may say it needs. A fixed vocabulary, so the
4
+ * refusal message is never free text from the package.
5
+ */
6
+ export const PACKAGE_POWERS = ['environment', 'filesystem', 'network', 'process'];
7
+ /** A `requires` section that is malformed. */
8
+ export class PackageRequirementsError extends Error {
9
+ constructor(message) {
10
+ super(message);
11
+ this.name = 'PackageRequirementsError';
12
+ }
13
+ }
14
+ const NONE = Object.freeze({ official: false, powers: Object.freeze([]) });
15
+ const isRecord = (value) => value !== null && typeof value === 'object' && !Array.isArray(value);
16
+ /**
17
+ * Reads the optional `requires` section of a participant package's data file.
18
+ * A requirement can only refuse a load; it never grants officialness, which
19
+ * stays the composition owner's decision.
20
+ *
21
+ * @param manifestPath - Absolute path of `brud.participant.json`.
22
+ * @returns The requirements; none when the section is absent.
23
+ * @throws {PackageRequirementsError} When the file is unreadable or the section is malformed.
24
+ */
25
+ export function readPackageRequirements(manifestPath) {
26
+ let pkg;
27
+ try {
28
+ pkg = JSON.parse(readFileSync(manifestPath, 'utf8'));
29
+ }
30
+ catch (error) {
31
+ throw new PackageRequirementsError(`unreadable (${error instanceof Error ? error.message : String(error)})`);
32
+ }
33
+ const requires = isRecord(pkg) ? pkg.requires : undefined;
34
+ if (requires === undefined) {
35
+ return NONE;
36
+ }
37
+ if (!isRecord(requires)) {
38
+ throw new PackageRequirementsError('requires must be an object');
39
+ }
40
+ const unknownKeys = Object.keys(requires).filter((key) => key !== 'official' && key !== 'powers');
41
+ if (unknownKeys.length > 0) {
42
+ throw new PackageRequirementsError(`unknown requires key(s) ${unknownKeys.join(', ')}`);
43
+ }
44
+ if (requires.official !== true) {
45
+ throw new PackageRequirementsError('requires.official must be true when requires is present');
46
+ }
47
+ const powers = requires.powers ?? [];
48
+ if (!Array.isArray(powers) || powers.some((power) => !PACKAGE_POWERS.includes(power))) {
49
+ throw new PackageRequirementsError(`requires.powers must list only: ${PACKAGE_POWERS.join(', ')}`);
50
+ }
51
+ return Object.freeze({ official: true, powers: Object.freeze([...new Set(powers)].sort()) });
52
+ }
@@ -0,0 +1,53 @@
1
+ import type { ServiceContext, ServiceTier } from './lifecycle.js';
2
+ import type { ServiceToken } from './serviceToken.js';
3
+ /**
4
+ * Read-only metadata describing a registered service.
5
+ */
6
+ export interface ServiceInfo {
7
+ /** Stable identifier of the service. */
8
+ readonly id: string;
9
+ /** Short explanation of what the service provides. */
10
+ readonly description: string;
11
+ /** Privilege tier the service belongs to. */
12
+ readonly tier: ServiceTier;
13
+ /** Whether the service has completed initialization. */
14
+ readonly initialized: boolean;
15
+ }
16
+ /**
17
+ * Mediated entry point for resolving services across the microkernel boundary.
18
+ *
19
+ * Every resolution is subject to the target service's access policy and the
20
+ * caller's {@link ServiceContext}.
21
+ */
22
+ export interface IKernelAccessBroker {
23
+ /**
24
+ * Resolves a service for the given caller.
25
+ *
26
+ * @typeParam TService - The public interface carried by `token`.
27
+ * @param caller - Context identifying the requesting caller.
28
+ * @param token - Token identifying the requested service.
29
+ * @returns The caller-facing view of the service.
30
+ */
31
+ requestAccess<TService>(caller: ServiceContext, token: ServiceToken<TService>): TService;
32
+ /**
33
+ * Reports whether a service is registered.
34
+ *
35
+ * @param token - Token identifying the service.
36
+ */
37
+ hasService(token: ServiceToken<unknown>): boolean;
38
+ /** Lists metadata for every registered service. */
39
+ listServices(): readonly ServiceInfo[];
40
+ /**
41
+ * Suspends the lifecycle gate for a bounded boot-window operation.
42
+ *
43
+ * This is a general rule available to every participant on the same terms,
44
+ * not a service-specific exception. It removes only the "broker is idle"
45
+ * state check while the operation runs; every access policy, denial list,
46
+ * and allowlist still applies, so a suspended gate never widens authority.
47
+ * The kernel uses it around the boot pinner, where any module's
48
+ * `pinBootPolicies` hook may ingest its boot snapshot before `RUNNING`.
49
+ *
50
+ * @param operation - Work performed while the gate is suspended.
51
+ */
52
+ withLifecycleGateSuspended?<T>(operation: () => Promise<T>): Promise<T>;
53
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Operation-kind mechanism.
3
+ *
4
+ * An operation kind is an open, shape-validated token. Any participant may
5
+ * claim a kind and any participant may emit one. The kernel defines only the
6
+ * token's shape; it does not define which kinds exist, which kind is assumed
7
+ * when none is written, or which participant serves a kind. Concrete kind
8
+ * values belong to the participants that claim them.
9
+ */
10
+ /** Open operation-kind identity. */
11
+ export type BrudOperationKind = string;
12
+ /** Safe kind token: starts with a letter, then letters, digits, `_` or `-`. */
13
+ export declare const BRUD_KIND_PATTERN: RegExp;
14
+ /**
15
+ * Validates an untrusted kind token.
16
+ *
17
+ * @param value - Candidate kind.
18
+ * @returns `true` when the token is safe to register and route.
19
+ */
20
+ export declare function isValidBrudKind(value: string): boolean;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Operation-kind mechanism.
3
+ *
4
+ * An operation kind is an open, shape-validated token. Any participant may
5
+ * claim a kind and any participant may emit one. The kernel defines only the
6
+ * token's shape; it does not define which kinds exist, which kind is assumed
7
+ * when none is written, or which participant serves a kind. Concrete kind
8
+ * values belong to the participants that claim them.
9
+ */
10
+ /** Safe kind token: starts with a letter, then letters, digits, `_` or `-`. */
11
+ export const BRUD_KIND_PATTERN = /^[A-Za-z][A-Za-z0-9_-]*$/;
12
+ /**
13
+ * Validates an untrusted kind token.
14
+ *
15
+ * @param value - Candidate kind.
16
+ * @returns `true` when the token is safe to register and route.
17
+ */
18
+ export function isValidBrudKind(value) {
19
+ return BRUD_KIND_PATTERN.test(value);
20
+ }
@@ -0,0 +1,161 @@
1
+ /**
2
+ * Kernel call chain.
3
+ *
4
+ * Every call the kernel mediates runs inside a call chain the kernel starts.
5
+ * The kernel fixes the chain's root origin when the chain starts and never
6
+ * changes it while the chain runs. The kernel also records who the current
7
+ * caller is. Neither value is a string a caller supplies: both are read only
8
+ * from the execution context the kernel provides.
9
+ */
10
+ /** Root origins a call chain can carry. */
11
+ export declare const CALL_ORIGINS: readonly ["kernel", "runtime", "host"];
12
+ /**
13
+ * Root origin of a call chain.
14
+ *
15
+ * `kernel` is a chain the kernel itself starts for its own work. `runtime` is a
16
+ * chain the kernel starts when it runs a participant inside the runtime.
17
+ * `host` is a chain the host starts from its authenticated session through the
18
+ * kernel's host entry point.
19
+ */
20
+ export type CallOrigin = (typeof CALL_ORIGINS)[number];
21
+ /** Identity classes a caller can belong to. */
22
+ export declare const CALLER_CLASSES: readonly ["kernel", "participant", "host"];
23
+ /**
24
+ * Identity class of a caller.
25
+ *
26
+ * `kernel` is the kernel itself, `participant` is a participant admitted to
27
+ * the composition, and `host` is a host session.
28
+ */
29
+ export type CallerClass = (typeof CALLER_CLASSES)[number];
30
+ /**
31
+ * A caller as the kernel knows it.
32
+ *
33
+ * Every field is assigned by the kernel. A participant cannot set any of them.
34
+ */
35
+ export interface KernelCaller {
36
+ /** Identity class of the caller. */
37
+ readonly callerClass: CallerClass;
38
+ /**
39
+ * Kernel-issued identity token of the caller.
40
+ *
41
+ * Present for an admitted participant. `null` for the kernel itself and for
42
+ * a host session, which are identified by their class.
43
+ */
44
+ readonly identity: string | null;
45
+ /**
46
+ * The caller's official status in this composition.
47
+ *
48
+ * Read from the kernel's identity-to-official mapping, which the kernel
49
+ * builds at boot from the composition's frozen config. Never supplied by the
50
+ * caller.
51
+ */
52
+ readonly official: boolean;
53
+ /** Capabilities the caller declared it wants. A request, not a grant. */
54
+ readonly capabilities: ReadonlySet<string>;
55
+ /**
56
+ * The parent's kernel-issued identity token, when the caller is a caged child.
57
+ *
58
+ * Optional. A top-level participant has no parent and omits the field. A caged
59
+ * child carries the identity token of the participant that loaded it, or the
60
+ * cage's own identity token, as the kernel issued it at admission. The value
61
+ * is the parent's identity, never the parent's name, token id, or descriptor
62
+ * label. The child's own identity is separate and unchanged.
63
+ */
64
+ readonly parentIdentity?: string;
65
+ }
66
+ /** The kernel-provided execution context of the current call. */
67
+ export interface KernelCallContext {
68
+ /** Root origin fixed when the chain started; propagated unchanged. */
69
+ readonly origin: CallOrigin;
70
+ /** The caller currently executing inside the chain. */
71
+ readonly caller: KernelCaller;
72
+ }
73
+ /** One record on the kernel's observation stream. */
74
+ export interface KernelObservation {
75
+ /** Milliseconds since the epoch at which the record was made. */
76
+ readonly at: number;
77
+ /** Kernel component or root primitive that made the record. */
78
+ readonly source: string;
79
+ /** Stable event name. */
80
+ readonly event: string;
81
+ /** Detailed, structured reason. Never returned to the refused caller. */
82
+ readonly detail: Readonly<Record<string, unknown>>;
83
+ }
84
+ /** Per-identity limits applied to every call the kernel mediates. */
85
+ export interface KernelCallLimits {
86
+ /** Calls one caller may make inside one window. */
87
+ readonly maxCallsPerWindow: number;
88
+ /** Window length in milliseconds. */
89
+ readonly windowMs: number;
90
+ /** Largest accepted request size, in bytes, for one mediated call. */
91
+ readonly maxRequestBytes: number;
92
+ }
93
+ /** Limits used when the host does not supply its own. */
94
+ export declare const DEFAULT_KERNEL_CALL_LIMITS: KernelCallLimits;
95
+ /**
96
+ * Kernel authority over the call chain.
97
+ *
98
+ * The kernel hands this only to root primitives, through the hardcore boot
99
+ * context. It is never reachable through the access broker.
100
+ */
101
+ export interface KernelCallAuthority {
102
+ /** The current call's kernel-provided context, or `undefined` outside a chain. */
103
+ current(): KernelCallContext | undefined;
104
+ /**
105
+ * Runs an operation as an admitted participant, keeping the root origin.
106
+ *
107
+ * Used when the kernel mediates a call into a participant's code. The chain's
108
+ * root origin does not change.
109
+ *
110
+ * @param identity - Kernel-issued identity token of the participant.
111
+ * @param operation - Work performed as that participant.
112
+ * @throws {Error} When no chain is active or the identity is not live.
113
+ */
114
+ runAs<T>(identity: string, operation: () => T): T;
115
+ /** Whether an identity is live in the composition. */
116
+ isLive(identity: string): boolean;
117
+ /** The initialized instance of a live participant, or `undefined`. */
118
+ instanceOf(identity: string): unknown;
119
+ /**
120
+ * Starts a chain with the given origin and a participant's recorded caller.
121
+ *
122
+ * The caller is the participant the kernel admitted under `identity`; it is
123
+ * resolved from the same admission record {@link callerForIdentity} reads, so
124
+ * the frame carries the participant's kernel-issued identity and its parent
125
+ * relation exactly as the kernel recorded them. Unlike {@link runAs}, this
126
+ * member sets the chain's root origin and does not require an active chain.
127
+ * It composes what the kernel's own root-start and run-as paths do, without
128
+ * exposing either.
129
+ *
130
+ * @param origin - Root origin the new chain starts with.
131
+ * @param identity - Kernel-issued identity token of the participant.
132
+ * @param operation - Work performed inside the chain as that participant.
133
+ * @throws {Error} When the identity is not live in this composition.
134
+ */
135
+ runAsOrigin<T>(origin: CallOrigin, identity: string, operation: () => T): T;
136
+ /**
137
+ * The kernel caller recorded for an identity token, or `undefined`.
138
+ *
139
+ * Reads the same admission record `isLive` and `instanceOf` read. Used to
140
+ * resolve the caller's class for a caller that is named by another caller's
141
+ * frame — the parent of a caged child — without the caller supplying it.
142
+ *
143
+ * @param identity - Kernel-issued identity token.
144
+ */
145
+ callerForIdentity(identity: string): KernelCaller | undefined;
146
+ /**
147
+ * Applies the per-identity call and size limits to one mediated call.
148
+ *
149
+ * @param caller - The caller making the call.
150
+ * @param requestBytes - Size of the call's request.
151
+ * @returns `true` when the call is within the limits.
152
+ */
153
+ admitCall(caller: KernelCaller, requestBytes: number): boolean;
154
+ /** Appends one record to the kernel's observation stream. */
155
+ observe(source: string, event: string, detail: Readonly<Record<string, unknown>>): void;
156
+ }
157
+ /** A host session's declaration when it enters a host-origin chain. */
158
+ export interface KernelHostSession {
159
+ /** Capabilities the host session declares it wants. */
160
+ readonly capabilities?: Iterable<string>;
161
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Kernel call chain.
3
+ *
4
+ * Every call the kernel mediates runs inside a call chain the kernel starts.
5
+ * The kernel fixes the chain's root origin when the chain starts and never
6
+ * changes it while the chain runs. The kernel also records who the current
7
+ * caller is. Neither value is a string a caller supplies: both are read only
8
+ * from the execution context the kernel provides.
9
+ */
10
+ /** Root origins a call chain can carry. */
11
+ export const CALL_ORIGINS = ['kernel', 'runtime', 'host'];
12
+ /** Identity classes a caller can belong to. */
13
+ export const CALLER_CLASSES = ['kernel', 'participant', 'host'];
14
+ /** Limits used when the host does not supply its own. */
15
+ export const DEFAULT_KERNEL_CALL_LIMITS = Object.freeze({
16
+ maxCallsPerWindow: 10_000,
17
+ windowMs: 1_000,
18
+ maxRequestBytes: 65_536,
19
+ });
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Extensible capability token vocabulary.
3
+ *
4
+ * Capabilities are declared by the service that exposes an API and claimed by
5
+ * callers. They are open strings: the kernel validates their shape, not
6
+ * membership in a closed list. A token is one or more lowercase segments
7
+ * separated by `:`, for example `fs:read` or `photoshop:access`.
8
+ *
9
+ * The kernel provides this mechanism only. A giver that wants a public preset
10
+ * declares it in its own contract; the kernel ships none.
11
+ */
12
+ /** Open capability token. */
13
+ export type CapabilityToken = string;
14
+ /**
15
+ * Shape accepted for capability tokens.
16
+ *
17
+ * Lowercase-only keeps diagnostics and manifest comparisons deterministic.
18
+ */
19
+ export declare const CAPABILITY_TOKEN_PATTERN: RegExp;
20
+ /**
21
+ * Validates a declarable capability token.
22
+ *
23
+ * @param value - Untrusted capability.
24
+ * @returns `true` when the value has the accepted capability shape.
25
+ */
26
+ export declare function isCapabilityToken(value: unknown): value is CapabilityToken;