@brud/kernel 0.0.0-stage → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (286) 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 +56 -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 +133 -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 +68 -0
  60. package/dist/services/ExposedApiRegistry/orchestrator/ExposedApiRegistryService.js +452 -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 +155 -0
  88. package/dist/services/Interception/contracts/IInterceptionService.js +12 -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 +50 -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 +40 -0
  102. package/dist/services/Interception/orchestrator/InterceptionService.js +343 -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 +67 -0
  142. package/dist/services/Router/contracts/errors.js +90 -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 +110 -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 +93 -0
  158. package/dist/services/Router/orchestrator/RouterService.js +457 -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 +121 -0
  170. package/dist/services/WasmCage/src/caged.js +460 -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 +19 -0
  184. package/dist/src/bootstrap/bootKernelInternal.js +633 -0
  185. package/dist/src/bootstrap/bootTypes.d.ts +113 -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 +45 -0
  190. package/dist/src/bootstrap/config/integrity.js +92 -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 +13 -0
  202. package/dist/src/bootstrap/index.js +7 -0
  203. package/dist/src/bootstrap/loaded.d.ts +30 -0
  204. package/dist/src/bootstrap/loaded.js +45 -0
  205. package/dist/src/bootstrap/packageRequirements.d.ts +26 -0
  206. package/dist/src/bootstrap/packageRequirements.js +52 -0
  207. package/dist/src/bootstrap/reload.d.ts +44 -0
  208. package/dist/src/bootstrap/reload.js +45 -0
  209. package/dist/src/bootstrap/seal.d.ts +32 -0
  210. package/dist/src/bootstrap/seal.js +101 -0
  211. package/dist/src/contracts/accessBroker.d.ts +53 -0
  212. package/dist/src/contracts/accessBroker.js +1 -0
  213. package/dist/src/contracts/brudOperation.d.ts +20 -0
  214. package/dist/src/contracts/brudOperation.js +20 -0
  215. package/dist/src/contracts/callChain.d.ts +161 -0
  216. package/dist/src/contracts/callChain.js +19 -0
  217. package/dist/src/contracts/capability.d.ts +26 -0
  218. package/dist/src/contracts/capability.js +26 -0
  219. package/dist/src/contracts/capabilitySet.d.ts +23 -0
  220. package/dist/src/contracts/capabilitySet.js +72 -0
  221. package/dist/src/contracts/container.d.ts +17 -0
  222. package/dist/src/contracts/container.js +8 -0
  223. package/dist/src/contracts/context.d.ts +19 -0
  224. package/dist/src/contracts/context.js +1 -0
  225. package/dist/src/contracts/contextContract.d.ts +132 -0
  226. package/dist/src/contracts/contextContract.js +274 -0
  227. package/dist/src/contracts/dispatchView.d.ts +21 -0
  228. package/dist/src/contracts/dispatchView.js +1 -0
  229. package/dist/src/contracts/handler.d.ts +21 -0
  230. package/dist/src/contracts/handler.js +1 -0
  231. package/dist/src/contracts/index.d.ts +26 -0
  232. package/dist/src/contracts/index.js +9 -0
  233. package/dist/src/contracts/kernel.d.ts +60 -0
  234. package/dist/src/contracts/kernel.js +1 -0
  235. package/dist/src/contracts/lifecycle.d.ts +59 -0
  236. package/dist/src/contracts/lifecycle.js +1 -0
  237. package/dist/src/contracts/manifest.d.ts +180 -0
  238. package/dist/src/contracts/manifest.js +334 -0
  239. package/dist/src/contracts/pipeline.d.ts +8 -0
  240. package/dist/src/contracts/pipeline.js +1 -0
  241. package/dist/src/contracts/policy.d.ts +75 -0
  242. package/dist/src/contracts/policy.js +77 -0
  243. package/dist/src/contracts/registry.d.ts +7 -0
  244. package/dist/src/contracts/registry.js +1 -0
  245. package/dist/src/contracts/serviceDescriptor.d.ts +67 -0
  246. package/dist/src/contracts/serviceDescriptor.js +1 -0
  247. package/dist/src/contracts/serviceToken.d.ts +36 -0
  248. package/dist/src/contracts/serviceToken.js +16 -0
  249. package/dist/src/engine/BrudKernel.d.ts +120 -0
  250. package/dist/src/engine/BrudKernel.js +395 -0
  251. package/dist/src/engine/ExecutionPipeline.d.ts +13 -0
  252. package/dist/src/engine/ExecutionPipeline.js +62 -0
  253. package/dist/src/engine/KernelAccessBroker.d.ts +47 -0
  254. package/dist/src/engine/KernelAccessBroker.js +107 -0
  255. package/dist/src/engine/KernelRegistry.d.ts +14 -0
  256. package/dist/src/engine/KernelRegistry.js +33 -0
  257. package/dist/src/engine/OperationRegistry.d.ts +9 -0
  258. package/dist/src/engine/OperationRegistry.js +18 -0
  259. package/dist/src/engine/ServiceContainer.d.ts +13 -0
  260. package/dist/src/engine/ServiceContainer.js +53 -0
  261. package/dist/src/engine/callChain.d.ts +68 -0
  262. package/dist/src/engine/callChain.js +175 -0
  263. package/dist/src/engine/dag.d.ts +2 -0
  264. package/dist/src/engine/dag.js +34 -0
  265. package/dist/src/engine/errors.d.ts +26 -0
  266. package/dist/src/engine/errors.js +52 -0
  267. package/dist/src/engine/index.d.ts +11 -0
  268. package/dist/src/engine/index.js +8 -0
  269. package/dist/src/engine/state.d.ts +1 -0
  270. package/dist/src/engine/state.js +1 -0
  271. package/dist/src/validation/jsonSchema/compile.d.ts +8 -0
  272. package/dist/src/validation/jsonSchema/compile.js +386 -0
  273. package/dist/src/validation/jsonSchema/index.d.ts +3 -0
  274. package/dist/src/validation/jsonSchema/index.js +2 -0
  275. package/dist/src/validation/jsonSchema/jsonValue.d.ts +29 -0
  276. package/dist/src/validation/jsonSchema/jsonValue.js +190 -0
  277. package/dist/src/validation/jsonSchema/pattern.d.ts +28 -0
  278. package/dist/src/validation/jsonSchema/pattern.js +155 -0
  279. package/dist/src/validation/jsonSchema/types.d.ts +71 -0
  280. package/dist/src/validation/jsonSchema/types.js +15 -0
  281. package/package.json +59 -4
  282. package/services/WasmCage/native/brud-wasm-cage.darwin-arm64.node +0 -0
  283. package/services/WasmCage/native/brud-wasm-cage.darwin-x64.node +0 -0
  284. package/services/WasmCage/native/brud-wasm-cage.linux-arm64-gnu.node +0 -0
  285. package/services/WasmCage/native/brud-wasm-cage.linux-x64-gnu.node +0 -0
  286. package/services/WasmCage/native/brud-wasm-cage.win32-x64-msvc.node +0 -0
@@ -0,0 +1,155 @@
1
+ import type { ExposedApiCaller } from '../../ExposedApiRegistry/contracts/types.js';
2
+ /** The plain caller view an interceptor sees. */
3
+ export interface InterceptedCaller {
4
+ readonly identity: string | null;
5
+ readonly callerClass: string;
6
+ readonly official: boolean;
7
+ readonly capabilities: ReadonlySet<string>;
8
+ readonly origin: string;
9
+ }
10
+ /** The plain, frozen record of one intercepted call. */
11
+ export interface InterceptedCall {
12
+ /** The interception point, `name@major`. */
13
+ readonly target: string;
14
+ /** The method of the target exposure being called. */
15
+ readonly method: string;
16
+ /** The call's arguments (plain JSON values). */
17
+ readonly args: readonly unknown[];
18
+ /** The original caller of the giver's exposure. */
19
+ readonly caller: InterceptedCaller;
20
+ }
21
+ /**
22
+ * An interceptor's verdict. `modify` replaces the call's arguments (same method,
23
+ * same target); it cannot re-route the call.
24
+ */
25
+ export type InterceptionVerdict = {
26
+ readonly verdict: 'allow';
27
+ } | {
28
+ readonly verdict: 'block';
29
+ readonly reason: string;
30
+ } | {
31
+ readonly verdict: 'modify';
32
+ readonly args: readonly unknown[];
33
+ };
34
+ /**
35
+ * What a giver implements on its instance to be called by the interception
36
+ * hardcore. A non-enumerable method, like `provideExposure`: it is reached only
37
+ * through the hardcore (`instanceOf` + `runAs`), never through `resolve`.
38
+ */
39
+ export interface IInterceptor {
40
+ intercept(call: InterceptedCall): InterceptionVerdict;
41
+ }
42
+ /** A stage of interception. */
43
+ export type InterceptionStage = 'input' | 'output';
44
+ /**
45
+ * Largest values the output stage allows, in bytes of canonical JSON. A point
46
+ * may lower any of them with `outputLimits` and can never raise one.
47
+ */
48
+ export declare const INTERCEPTION_OUTPUT_CEILINGS: Readonly<{
49
+ /** A giver's result, as shown to interceptors. */
50
+ maxResultBytes: 1048576;
51
+ /** The content of one interceptor's addition. */
52
+ maxAdditionBytes: 65536;
53
+ /** All additions to one result together. */
54
+ maxTotalBytes: 262144;
55
+ }>;
56
+ /** The intercepted call and the giver's result: plain, deep-frozen JSON. */
57
+ export interface InterceptedResult extends InterceptedCall {
58
+ /** What the giver returned. */
59
+ readonly result: unknown;
60
+ }
61
+ /**
62
+ * An output-stage verdict. An interceptor can only add: there is no way to
63
+ * change, replace or remove the result, or to withhold it.
64
+ */
65
+ export type InterceptionOutputVerdict = {
66
+ readonly verdict: 'none';
67
+ } | {
68
+ readonly verdict: 'append';
69
+ readonly content: unknown;
70
+ };
71
+ /**
72
+ * What an interceptor implements on its instance to take part in the output
73
+ * stage (non-enumerable, like `intercept`): reached only through the hardcore.
74
+ */
75
+ export interface IResultInterceptor {
76
+ interceptResult(call: InterceptedResult): InterceptionOutputVerdict;
77
+ }
78
+ /** One piece of content an interceptor appended, attributed to it. */
79
+ export interface InterceptionAddition {
80
+ /** Service token of the interceptor that appended it. */
81
+ readonly interceptor: string;
82
+ /** The appended plain JSON content. */
83
+ readonly content: unknown;
84
+ }
85
+ /** An output-stage interceptor the kernel skipped, and why. */
86
+ export interface InterceptionSkipped {
87
+ /** Service token of the interceptor that was skipped. */
88
+ readonly interceptor: string;
89
+ /** What it did wrong: it threw, returned anything but an append, or exceeded a limit. */
90
+ readonly reason: string;
91
+ }
92
+ /**
93
+ * What a caller of an intercepted exposure receives: the giver's result
94
+ * exactly as returned, the additions in the order the interceptors ran, the
95
+ * interceptors whose contribution was taken, and the interceptors that were
96
+ * skipped because they misbehaved.
97
+ */
98
+ export interface InterceptionEnvelope {
99
+ readonly result: unknown;
100
+ readonly additions: readonly InterceptionAddition[];
101
+ readonly interceptedBy: readonly string[];
102
+ readonly skipped: readonly InterceptionSkipped[];
103
+ }
104
+ /**
105
+ * The outcome of the output stage. `applied: false` means the giver returns
106
+ * its result as it always did: no admitted interceptor takes part in the
107
+ * stage, or the result is one the stage cannot carry. An interceptor that
108
+ * misbehaves never withholds the result: it is skipped and listed in
109
+ * `envelope.skipped`. `allowed: false` is returned only when the giver itself
110
+ * called the stage wrongly (it is not the point's owner, the point is
111
+ * unknown, or the arguments are not plain data).
112
+ */
113
+ export type InterceptionResultOutcome = {
114
+ readonly applied: false;
115
+ } | {
116
+ readonly applied: true;
117
+ readonly allowed: true;
118
+ readonly envelope: InterceptionEnvelope;
119
+ } | {
120
+ readonly applied: true;
121
+ readonly allowed: false;
122
+ readonly reason: string;
123
+ };
124
+ /** Options the giver passes to `evaluate`. */
125
+ export interface InterceptionEvaluateOptions {
126
+ /** The caller view the giver's projection received (delegation by the owner). */
127
+ readonly caller?: ExposedApiCaller;
128
+ }
129
+ /** The combined outcome the giver enforces. */
130
+ export type InterceptionOutcome = {
131
+ readonly allowed: true;
132
+ readonly args: readonly unknown[];
133
+ readonly modifiedBy: readonly string[];
134
+ } | {
135
+ readonly allowed: false;
136
+ readonly reason: string;
137
+ readonly interceptor?: string;
138
+ };
139
+ export interface IInterceptionService {
140
+ /**
141
+ * Runs the admitted interceptors of the giver's interception point, in the
142
+ * giver's order. Only the point's owner may evaluate it.
143
+ */
144
+ evaluate(target: string, method: string, args: readonly unknown[], options?: InterceptionEvaluateOptions): InterceptionOutcome;
145
+ /**
146
+ * Runs the output stage of the giver's interception point on the result the
147
+ * giver produced: each interceptor that declared the output stage may append
148
+ * content, in the giver's order. The result is never changed. Only the
149
+ * point's owner may evaluate it, and `args` are the final arguments of the
150
+ * call (after any input modification). The result must be plain JSON.
151
+ */
152
+ evaluateResult(target: string, method: string, args: readonly unknown[], result: unknown, options?: InterceptionEvaluateOptions): InterceptionResultOutcome;
153
+ /** The interception points in this composition, as `name@major`. */
154
+ list(): readonly string[];
155
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Largest values the output stage allows, in bytes of canonical JSON. A point
3
+ * may lower any of them with `outputLimits` and can never raise one.
4
+ */
5
+ export const INTERCEPTION_OUTPUT_CEILINGS = Object.freeze({
6
+ /** A giver's result, as shown to interceptors. */
7
+ maxResultBytes: 1_048_576,
8
+ /** The content of one interceptor's addition. */
9
+ maxAdditionBytes: 65_536,
10
+ /** All additions to one result together. */
11
+ maxTotalBytes: 262_144,
12
+ });
@@ -0,0 +1,26 @@
1
+ /** Stable, machine-readable codes for interception failures. */
2
+ export type InterceptionErrorCode = 'INTERCEPTION_DECLARATION_INVALID' | 'INTERCEPTION_BLOCKED';
3
+ /** Base class for every interception domain failure. */
4
+ export declare abstract class InterceptionError extends Error {
5
+ /** Stable, machine-readable error code. */
6
+ abstract readonly code: InterceptionErrorCode;
7
+ protected constructor(message: string, options?: ErrorOptions);
8
+ }
9
+ /** Raised at boot when an interception or an interception point is not admissible. */
10
+ export declare class InterceptionDeclarationError extends InterceptionError {
11
+ readonly code: "INTERCEPTION_DECLARATION_INVALID";
12
+ /** Service token of the declaring participant. */
13
+ readonly participant: string;
14
+ constructor(participant: string, reason: string);
15
+ }
16
+ /** Thrown by a giver when the interception outcome blocks the call. */
17
+ export declare class InterceptionBlockedError extends InterceptionError {
18
+ readonly code: "INTERCEPTION_BLOCKED";
19
+ /** The interception point, `name@major`. */
20
+ readonly target: string;
21
+ /** The blocking reason. */
22
+ readonly reason: string;
23
+ /** Service token of the blocking interceptor, when one blocked. */
24
+ readonly interceptor: string | undefined;
25
+ constructor(target: string, reason: string, interceptor?: string);
26
+ }
@@ -0,0 +1,35 @@
1
+ /** Base class for every interception domain failure. */
2
+ export class InterceptionError extends Error {
3
+ constructor(message, options) {
4
+ super(message, options);
5
+ this.name = 'InterceptionError';
6
+ }
7
+ }
8
+ /** Raised at boot when an interception or an interception point is not admissible. */
9
+ export class InterceptionDeclarationError extends InterceptionError {
10
+ code = 'INTERCEPTION_DECLARATION_INVALID';
11
+ /** Service token of the declaring participant. */
12
+ participant;
13
+ constructor(participant, reason) {
14
+ super(`Participant "${participant}": ${reason}`);
15
+ this.name = 'InterceptionDeclarationError';
16
+ this.participant = participant;
17
+ }
18
+ }
19
+ /** Thrown by a giver when the interception outcome blocks the call. */
20
+ export class InterceptionBlockedError extends InterceptionError {
21
+ code = 'INTERCEPTION_BLOCKED';
22
+ /** The interception point, `name@major`. */
23
+ target;
24
+ /** The blocking reason. */
25
+ reason;
26
+ /** Service token of the blocking interceptor, when one blocked. */
27
+ interceptor;
28
+ constructor(target, reason, interceptor) {
29
+ super(`Call to "${target}" was blocked by interception: ${reason}`);
30
+ this.name = 'InterceptionBlockedError';
31
+ this.target = target;
32
+ this.reason = reason;
33
+ this.interceptor = interceptor;
34
+ }
35
+ }
@@ -0,0 +1,3 @@
1
+ export * from './IInterceptionService.js';
2
+ export * from './tokens.js';
3
+ export * from './errors.js';
@@ -0,0 +1,3 @@
1
+ export * from './IInterceptionService.js';
2
+ export * from './tokens.js';
3
+ export * from './errors.js';
@@ -0,0 +1,2 @@
1
+ import type { IInterceptionService } from './IInterceptionService.js';
2
+ export declare const InterceptionToken: import("../../../src/contracts/serviceToken.js").ServiceToken<IInterceptionService>;
@@ -0,0 +1,2 @@
1
+ import { createServiceToken } from '../../../src/contracts/serviceToken.js';
2
+ export const InterceptionToken = createServiceToken('brud.core.interception');
@@ -0,0 +1,9 @@
1
+ import type { ServiceTier } from '../../../src/contracts/lifecycle.js';
2
+ import type { ServiceDescriptor } from '../../../src/contracts/serviceDescriptor.js';
3
+ import type { IInterceptionService } from '../contracts/IInterceptionService.js';
4
+ import { InterceptionService } from '../orchestrator/index.js';
5
+ export declare const INTERCEPTION_SERVICE_TIER: ServiceTier;
6
+ export declare const INTERCEPTION_CONTRACT_VERSION = "1.0.0";
7
+ export declare const INTERCEPTION_CONTRACT_METHODS: readonly ["evaluate", "evaluateResult", "list"];
8
+ export declare function createInterceptionDescriptor(): ServiceDescriptor<IInterceptionService, InterceptionService>;
9
+ export declare const InterceptionDescriptor: ServiceDescriptor<IInterceptionService, InterceptionService>;
@@ -0,0 +1,50 @@
1
+ import { withExposureBindings } from '../../ExposedApiRegistry/contracts/registrant.js';
2
+ import { InterceptionService } from '../orchestrator/index.js';
3
+ import { InterceptionToken } from './tokens.js';
4
+ export const INTERCEPTION_SERVICE_TIER = 'core';
5
+ export const INTERCEPTION_CONTRACT_VERSION = '1.0.0';
6
+ export const INTERCEPTION_CONTRACT_METHODS = ['evaluate', 'evaluateResult', 'list'];
7
+ /**
8
+ * Per-exposure projection bindings. Each projection captures the resolver's
9
+ * caller view at resolve time (the registry runs projection calls as the
10
+ * owner), so `evaluate` knows which giver is asking.
11
+ */
12
+ function interceptionExposureBindings(instance) {
13
+ return {
14
+ 'interception.evaluate@1': {
15
+ projection: (_service, caller) => ({
16
+ evaluate: (target, method, args, options) => instance.evaluateAs(caller, target, method, args, options),
17
+ evaluateResult: (target, method, args, result, options) => instance.evaluateResultAs(caller, target, method, args, result, options),
18
+ }),
19
+ },
20
+ 'interception.list@1': { projection: () => ({ list: () => instance.list() }) },
21
+ };
22
+ }
23
+ export function createInterceptionDescriptor() {
24
+ return {
25
+ token: InterceptionToken,
26
+ tier: INTERCEPTION_SERVICE_TIER,
27
+ dependencies: [],
28
+ contract: {
29
+ version: INTERCEPTION_CONTRACT_VERSION,
30
+ methods: INTERCEPTION_CONTRACT_METHODS,
31
+ },
32
+ accessPolicy: {
33
+ allowedCallers: ['kernel'],
34
+ },
35
+ manifest: {
36
+ exposures: [
37
+ // `any`: a giver's exposure may be called from any origin, and its
38
+ // binding evaluates in that caller's chain. `evaluate` itself admits
39
+ // only the point's owner.
40
+ { name: 'interception.evaluate', version: 1, scope: 'any' },
41
+ { name: 'interception.list', version: 1, scope: 'runtime' },
42
+ ],
43
+ },
44
+ factory: () => {
45
+ const instance = new InterceptionService();
46
+ return withExposureBindings(instance, interceptionExposureBindings(instance));
47
+ },
48
+ };
49
+ }
50
+ export const InterceptionDescriptor = createInterceptionDescriptor();
@@ -0,0 +1 @@
1
+ export { InterceptionToken } from '../contracts/tokens.js';
@@ -0,0 +1 @@
1
+ export { InterceptionToken } from '../contracts/tokens.js';
@@ -0,0 +1,4 @@
1
+ export * from './contracts/index.js';
2
+ export * from './descriptor/InterceptionDescriptor.js';
3
+ export * from './descriptor/tokens.js';
4
+ export * from './orchestrator/index.js';
@@ -0,0 +1,4 @@
1
+ export * from './contracts/index.js';
2
+ export * from './descriptor/InterceptionDescriptor.js';
3
+ export * from './descriptor/tokens.js';
4
+ export * from './orchestrator/index.js';
@@ -0,0 +1,40 @@
1
+ import type { AdmittedManifest, KernelCallAuthority } from '../../../src/contracts/index.js';
2
+ import type { ExposedApiCaller } from '../../ExposedApiRegistry/contracts/types.js';
3
+ import { type IInterceptionService, type InterceptionEvaluateOptions, type InterceptionOutcome, type InterceptionResultOutcome } from '../contracts/IInterceptionService.js';
4
+ /** One participant of the composition, as the boot hook hands it over. */
5
+ export interface InterceptionParticipant {
6
+ readonly token: string;
7
+ readonly identity: string | undefined;
8
+ readonly manifest: AdmittedManifest;
9
+ }
10
+ export declare class InterceptionService implements IInterceptionService {
11
+ #private;
12
+ private authority;
13
+ bindAuthority(value: KernelCallAuthority): void;
14
+ /**
15
+ * Builds the interception-point table from the composition's manifests.
16
+ *
17
+ * A point must sit on an exposure its giver declares; every admitted token
18
+ * must be a participant that declares an interception of that point; every
19
+ * declared interception must be admitted by a point. Anything else refuses
20
+ * the boot.
21
+ */
22
+ registerComposition(participants: readonly InterceptionParticipant[]): void;
23
+ evaluate(target: string, method: string, args: readonly unknown[], options?: InterceptionEvaluateOptions): InterceptionOutcome;
24
+ list(): readonly string[];
25
+ /**
26
+ * Evaluates the point for `resolver`, which must be the point's owner. The
27
+ * interceptors run in the giver's admitted order, each as itself: the first
28
+ * `block` wins; `modify` chains; a throw or an invalid verdict blocks
29
+ * (fail closed).
30
+ */
31
+ evaluateAs(resolver: ExposedApiCaller | undefined, target: string, method: string, args: readonly unknown[], options?: InterceptionEvaluateOptions): InterceptionOutcome;
32
+ evaluateResult(target: string, method: string, args: readonly unknown[], result: unknown, options?: InterceptionEvaluateOptions): InterceptionResultOutcome;
33
+ /**
34
+ * Runs the output stage for `resolver`, which must be the point's owner. The
35
+ * interceptors that declared the stage run in the giver's admitted order,
36
+ * each as itself and each seeing only the original result; each may append
37
+ * one piece of content and nothing else. Any failure withholds the result.
38
+ */
39
+ evaluateResultAs(resolver: ExposedApiCaller | undefined, target: string, method: string, args: readonly unknown[], result: unknown, options?: InterceptionEvaluateOptions): InterceptionResultOutcome;
40
+ }