@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,51 @@
1
+ import type { EventDeclaration, KernelCallAuthority } from '../../../src/contracts/index.js';
2
+ import type { ExposedApiCaller } from '../../ExposedApiRegistry/contracts/types.js';
3
+ import type { EventDeliveryRecord, EventsEmitResult, EventsPullOptions, EventsRefusal, EventsSubscribeOptions, IEventsService } from '../contracts/IEventsService.js';
4
+ export declare class EventsService implements IEventsService {
5
+ #private;
6
+ private authority;
7
+ bindAuthority(value: KernelCallAuthority): void;
8
+ /**
9
+ * Registers one declared event in the boot-time catalogue under `owner`.
10
+ *
11
+ * Refuses name collisions across different owners and duplicate
12
+ * `(name, major)` declarations by the same owner.
13
+ */
14
+ registerDeclaration(owner: string, declaration: EventDeclaration): void;
15
+ emit(name: string, payload: unknown): EventsEmitResult;
16
+ pull(subscriptionId: string, options?: EventsPullOptions): readonly EventDeliveryRecord[] | EventsRefusal;
17
+ close(subscriptionId: string): EventsRefusal | undefined;
18
+ list(): readonly string[];
19
+ subscribe(eventName: string, options?: EventsSubscribeOptions): string | null;
20
+ /**
21
+ * Emits `payload` on `name` for `caller` (the resolver of `events.emit`).
22
+ *
23
+ * Order: resolve the event; require the caller to be its catalogue owner;
24
+ * validate the payload; assign the per-event sequence; enforce each
25
+ * subscription's backpressure; append to the retention log.
26
+ */
27
+ emitAs(caller: ExposedApiCaller | undefined, name: string, payload: unknown): EventsEmitResult;
28
+ /**
29
+ * Pulls the next bounded batch for `caller`, which must be the subscriber.
30
+ *
31
+ * Scope and policy are not re-evaluated here: they were decided at subscribe
32
+ * (the giver's decision) and the registry re-checks the `events.pull`
33
+ * exposure's scope on every handle use. A participant's identity, class,
34
+ * capabilities, official status and origin are fixed at admission, so the
35
+ * outcome can only change through a reload or reboot.
36
+ */
37
+ pullAs(caller: ExposedApiCaller | undefined, subscriptionId: string, options?: EventsPullOptions): readonly EventDeliveryRecord[] | EventsRefusal;
38
+ /** Tombstones the subscription; only its subscriber may close it. */
39
+ closeAs(caller: ExposedApiCaller | undefined, subscriptionId: string): EventsRefusal | undefined;
40
+ /**
41
+ * Creates a subscription to the highest declared major of `eventName`.
42
+ *
43
+ * The subscriber is `caller` (a direct subscriber's own resolve) or, when
44
+ * `options.subscriber` is given, the forwarded view; forwarding is honoured
45
+ * only when `caller` is the event's catalogue owner (delegation by the
46
+ * owner). The event's scope and the owner's policy are evaluated here,
47
+ * against the subscriber's view (identity, class, capabilities, official,
48
+ * origin). Returns the assigned identity `name@major#n`, or the uniform `null`.
49
+ */
50
+ subscribeAs(caller: ExposedApiCaller | undefined, eventName: string, options?: EventsSubscribeOptions): string | null;
51
+ }
@@ -0,0 +1,339 @@
1
+ import { compileJsonSchema } from '../../../src/validation/jsonSchema/index.js';
2
+ import { freezeJsonCopy } from '../../../src/validation/jsonSchema/jsonValue.js';
3
+ import { evaluateExposedApiPolicy, parseExposedApiPolicy, } from '../../ExposedApiRegistry/contracts/policy.js';
4
+ import { EventDuplicateDeclarationError, EventNameCollisionError, } from '../contracts/errors.js';
5
+ import { eventsLimits } from './limits.js';
6
+ /** Source name the events hardcore records observations under. */
7
+ const OBSERVATION_SOURCE = 'brud.core.events';
8
+ const BACKPRESSURE_POLICIES = new Set(['drop-oldest', 'refuse-emit', 'drop-newest']);
9
+ /** Extracts the integer major version from a numeric or semver version. */
10
+ function eventMajorVersion(version) {
11
+ if (version === undefined) {
12
+ return 1;
13
+ }
14
+ if (typeof version === 'number') {
15
+ return version;
16
+ }
17
+ return Number.parseInt(version.split('.')[0] ?? '', 10);
18
+ }
19
+ /** Formats the deterministic `name@major` key for a catalogue entry. */
20
+ function catalogueKey(name, major) {
21
+ return `${name}@${String(major)}`;
22
+ }
23
+ function refusal(reason, detail) {
24
+ return Object.freeze({ refused: true, reason, ...(detail === undefined ? {} : { detail }) });
25
+ }
26
+ export class EventsService {
27
+ authority;
28
+ #catalogue = new Map();
29
+ #owners = new Map();
30
+ #logs = new Map();
31
+ #subscriptions = new Map();
32
+ /** Compiled payload schemas per catalogue key, or the compile failure reason. */
33
+ #schemas = new Map();
34
+ #nextSubscription = 1;
35
+ bindAuthority(value) {
36
+ this.authority = value;
37
+ }
38
+ /**
39
+ * Registers one declared event in the boot-time catalogue under `owner`.
40
+ *
41
+ * Refuses name collisions across different owners and duplicate
42
+ * `(name, major)` declarations by the same owner.
43
+ */
44
+ registerDeclaration(owner, declaration) {
45
+ const { name } = declaration;
46
+ const major = eventMajorVersion(declaration.version);
47
+ const scope = declaration.scope ?? 'kernel';
48
+ const nameOwner = this.#owners.get(name);
49
+ if (nameOwner !== undefined && nameOwner !== owner) {
50
+ throw new EventNameCollisionError(name, nameOwner);
51
+ }
52
+ const key = catalogueKey(name, major);
53
+ if (this.#catalogue.has(key)) {
54
+ throw new EventDuplicateDeclarationError(name, major);
55
+ }
56
+ this.#owners.set(name, owner);
57
+ this.#catalogue.set(key, Object.freeze({
58
+ name,
59
+ major,
60
+ scope,
61
+ ...(declaration.policy === undefined ? {} : { policy: declaration.policy }),
62
+ ...(declaration.payloadSchema === undefined ? {} : { payloadSchema: declaration.payloadSchema }),
63
+ owner,
64
+ }));
65
+ }
66
+ emit(name, payload) {
67
+ return this.emitAs(this.#currentCaller(), name, payload);
68
+ }
69
+ pull(subscriptionId, options) {
70
+ return this.pullAs(this.#currentCaller(), subscriptionId, options);
71
+ }
72
+ close(subscriptionId) {
73
+ return this.closeAs(this.#currentCaller(), subscriptionId);
74
+ }
75
+ list() {
76
+ return Array.from(this.#catalogue.keys());
77
+ }
78
+ subscribe(eventName, options) {
79
+ return this.subscribeAs(this.#currentCaller(), eventName, options);
80
+ }
81
+ /**
82
+ * Emits `payload` on `name` for `caller` (the resolver of `events.emit`).
83
+ *
84
+ * Order: resolve the event; require the caller to be its catalogue owner;
85
+ * validate the payload; assign the per-event sequence; enforce each
86
+ * subscription's backpressure; append to the retention log.
87
+ */
88
+ emitAs(caller, name, payload) {
89
+ const event = this.#highestMajor(name);
90
+ if (event === undefined) {
91
+ return this.#refuseEmit('refused', `event "${name}" is not declared`, name);
92
+ }
93
+ if (caller?.identity === null || caller?.identity === undefined || caller.identity !== event.owner) {
94
+ return this.#refuseEmit('refused', 'the emitter is not the event owner', name);
95
+ }
96
+ const key = catalogueKey(event.name, event.major);
97
+ const schema = this.#schemaFor(key, event);
98
+ if (typeof schema === 'string') {
99
+ return this.#refuseEmit('malformed', schema, name, 'events.emit.malformed');
100
+ }
101
+ const checked = schema.validate(payload);
102
+ if (!checked.valid) {
103
+ const detail = checked.violations
104
+ .map((violation) => `${violation.instancePath || '/'}: ${violation.message}`)
105
+ .join('; ');
106
+ return this.#refuseEmit('malformed', detail, name, 'events.emit.malformed');
107
+ }
108
+ const log = this.#logFor(key);
109
+ const sequence = log.nextSequence;
110
+ log.nextSequence += 1;
111
+ const record = Object.freeze({
112
+ eventName: event.name,
113
+ eventVersion: event.major,
114
+ emitterIdentity: caller.identity,
115
+ emitOrigin: this.authority?.current()?.origin ?? caller.origin,
116
+ sequence,
117
+ payload: freezeJsonCopy(payload),
118
+ });
119
+ const limits = eventsLimits();
120
+ const refusedSubscriptions = [];
121
+ for (const subscription of this.#subscriptions.values()) {
122
+ if (subscription.event !== key || subscription.retired) {
123
+ continue;
124
+ }
125
+ const pending = log.entries.filter((entry) => entry.sequence > subscription.cursor && !subscription.excluded.has(entry.sequence));
126
+ if (pending.length < limits.queueDepth) {
127
+ continue;
128
+ }
129
+ if (subscription.policy === 'drop-oldest') {
130
+ const oldest = pending[0]?.sequence ?? subscription.cursor;
131
+ subscription.cursor = oldest;
132
+ this.#observe('events.delivery.dropped', { subscription: subscription.id, sequence: oldest, reason: 'drop-oldest' });
133
+ continue;
134
+ }
135
+ subscription.excluded.add(sequence);
136
+ if (subscription.policy === 'refuse-emit') {
137
+ refusedSubscriptions.push(subscription.id);
138
+ }
139
+ this.#observe('events.delivery.dropped', { subscription: subscription.id, sequence, reason: subscription.policy });
140
+ }
141
+ log.entries.push(record);
142
+ while (log.entries.length > limits.retentionDepth) {
143
+ log.entries.shift();
144
+ }
145
+ this.#pruneExcluded(key, log);
146
+ return Object.freeze({ ok: true, sequence, refusedSubscriptions: Object.freeze(refusedSubscriptions) });
147
+ }
148
+ /**
149
+ * Pulls the next bounded batch for `caller`, which must be the subscriber.
150
+ *
151
+ * Scope and policy are not re-evaluated here: they were decided at subscribe
152
+ * (the giver's decision) and the registry re-checks the `events.pull`
153
+ * exposure's scope on every handle use. A participant's identity, class,
154
+ * capabilities, official status and origin are fixed at admission, so the
155
+ * outcome can only change through a reload or reboot.
156
+ */
157
+ pullAs(caller, subscriptionId, options) {
158
+ const subscription = this.#subscriptions.get(subscriptionId);
159
+ if (subscription === undefined) {
160
+ return this.#refusePull(subscriptionId, refusal('unknown-subscription'));
161
+ }
162
+ if (caller?.identity === null || caller?.identity === undefined || caller.identity !== subscription.subscriber.identity) {
163
+ return this.#refusePull(subscriptionId, refusal('not-subscriber'));
164
+ }
165
+ if (subscription.retired) {
166
+ return this.#refusePull(subscriptionId, refusal('closed'));
167
+ }
168
+ const limits = eventsLimits();
169
+ const requested = options?.maxBatch ?? limits.batchSize;
170
+ const max = Math.max(0, Math.min(limits.batchSize, Math.floor(requested)));
171
+ const start = options?.lastSequence ?? subscription.cursor;
172
+ const entries = (this.#logs.get(subscription.event)?.entries ?? [])
173
+ .filter((entry) => entry.sequence > start && !subscription.excluded.has(entry.sequence))
174
+ .slice(0, max);
175
+ const last = entries[entries.length - 1];
176
+ subscription.cursor = last === undefined ? start : last.sequence;
177
+ return Object.freeze(entries);
178
+ }
179
+ /** Tombstones the subscription; only its subscriber may close it. */
180
+ closeAs(caller, subscriptionId) {
181
+ const subscription = this.#subscriptions.get(subscriptionId);
182
+ if (subscription === undefined) {
183
+ return refusal('unknown-subscription');
184
+ }
185
+ if (caller?.identity === null || caller?.identity === undefined || caller.identity !== subscription.subscriber.identity) {
186
+ return refusal('not-subscriber');
187
+ }
188
+ subscription.retired = true;
189
+ return undefined;
190
+ }
191
+ /**
192
+ * Creates a subscription to the highest declared major of `eventName`.
193
+ *
194
+ * The subscriber is `caller` (a direct subscriber's own resolve) or, when
195
+ * `options.subscriber` is given, the forwarded view; forwarding is honoured
196
+ * only when `caller` is the event's catalogue owner (delegation by the
197
+ * owner). The event's scope and the owner's policy are evaluated here,
198
+ * against the subscriber's view (identity, class, capabilities, official,
199
+ * origin). Returns the assigned identity `name@major#n`, or the uniform `null`.
200
+ */
201
+ subscribeAs(caller, eventName, options) {
202
+ const event = this.#highestMajor(eventName);
203
+ if (event === undefined) {
204
+ return this.#refuseSubscribe(eventName, 'unknown-event');
205
+ }
206
+ if (caller?.identity === null || caller?.identity === undefined) {
207
+ return this.#refuseSubscribe(eventName, 'no-caller-identity');
208
+ }
209
+ let subscriber = caller;
210
+ if (options?.subscriber !== undefined) {
211
+ if (caller.identity !== event.owner) {
212
+ return this.#refuseSubscribe(eventName, 'forwarded subscriber from a resolver that is not the owner');
213
+ }
214
+ subscriber = options.subscriber;
215
+ }
216
+ if (subscriber.identity === null) {
217
+ return this.#refuseSubscribe(eventName, 'no-subscriber-identity');
218
+ }
219
+ const decision = this.#admits(event, subscriber);
220
+ if (!decision.allowed) {
221
+ return this.#refuseSubscribe(eventName, `policy-refused: ${decision.reason}`, subscriber);
222
+ }
223
+ const policy = options?.policy ?? 'drop-oldest';
224
+ if (!BACKPRESSURE_POLICIES.has(policy)) {
225
+ return this.#refuseSubscribe(eventName, 'unknown-backpressure-policy');
226
+ }
227
+ const lastSequence = options?.lastSequence;
228
+ if (lastSequence !== undefined && (!Number.isInteger(lastSequence) || lastSequence < 0)) {
229
+ return this.#refuseSubscribe(eventName, 'invalid-last-sequence');
230
+ }
231
+ const key = catalogueKey(event.name, event.major);
232
+ const subscriptionId = `${key}#${String(this.#nextSubscription)}`;
233
+ this.#nextSubscription += 1;
234
+ this.#subscriptions.set(subscriptionId, {
235
+ id: subscriptionId,
236
+ event: key,
237
+ subscriber: Object.freeze({
238
+ identity: subscriber.identity,
239
+ callerClass: subscriber.callerClass,
240
+ official: subscriber.official,
241
+ capabilities: new Set(subscriber.capabilities),
242
+ origin: subscriber.origin,
243
+ }),
244
+ policy,
245
+ cursor: lastSequence ?? 0,
246
+ excluded: new Set(),
247
+ retired: false,
248
+ });
249
+ return subscriptionId;
250
+ }
251
+ /** The current chain's caller as a caller view (direct-access path). */
252
+ #currentCaller() {
253
+ const context = this.authority?.current();
254
+ return context === undefined ? undefined : { ...context.caller, origin: context.origin };
255
+ }
256
+ #highestMajor(name) {
257
+ let event;
258
+ for (const entry of this.#catalogue.values()) {
259
+ if (entry.name === name && (event === undefined || entry.major > event.major)) {
260
+ event = entry;
261
+ }
262
+ }
263
+ return event;
264
+ }
265
+ #schemaFor(key, event) {
266
+ let schema = this.#schemas.get(key);
267
+ if (schema === undefined) {
268
+ const compiled = compileJsonSchema(event.payloadSchema ?? {});
269
+ schema = compiled.ok
270
+ ? compiled.schema
271
+ : `payload schema is invalid: ${compiled.errors.map((error) => error.message).join('; ')}`;
272
+ this.#schemas.set(key, schema);
273
+ }
274
+ return schema;
275
+ }
276
+ #logFor(key) {
277
+ let log = this.#logs.get(key);
278
+ if (log === undefined) {
279
+ log = { entries: [], nextSequence: 1 };
280
+ this.#logs.set(key, log);
281
+ }
282
+ return log;
283
+ }
284
+ #pruneExcluded(key, log) {
285
+ const oldest = log.entries[0]?.sequence;
286
+ if (oldest === undefined) {
287
+ return;
288
+ }
289
+ for (const subscription of this.#subscriptions.values()) {
290
+ if (subscription.event === key) {
291
+ for (const sequence of subscription.excluded) {
292
+ if (sequence < oldest) {
293
+ subscription.excluded.delete(sequence);
294
+ }
295
+ }
296
+ }
297
+ }
298
+ }
299
+ /** Evaluates the event's scope and the owner's policy for `subscriber`. */
300
+ #admits(event, subscriber) {
301
+ try {
302
+ return evaluateExposedApiPolicy(parseExposedApiPolicy(event.policy), event.scope, {
303
+ origin: subscriber.origin,
304
+ caller: {
305
+ identity: subscriber.identity,
306
+ callerClass: subscriber.callerClass,
307
+ official: subscriber.official,
308
+ capabilities: subscriber.capabilities,
309
+ },
310
+ });
311
+ }
312
+ catch (error) {
313
+ return { allowed: false, reason: error instanceof Error ? error.message : 'policy evaluation failed' };
314
+ }
315
+ }
316
+ #refuseEmit(reason, detail, name, observation = 'events.emit.refused') {
317
+ this.#observe(observation, { event: name, reason: detail });
318
+ return Object.freeze({ ok: false, reason, detail });
319
+ }
320
+ #refusePull(subscriptionId, refused) {
321
+ this.#observe('events.pull.refused', {
322
+ subscription: subscriptionId,
323
+ reason: refused.reason,
324
+ ...(refused.detail === undefined ? {} : { detail: refused.detail }),
325
+ });
326
+ return refused;
327
+ }
328
+ #refuseSubscribe(eventName, reason, subscriber) {
329
+ this.#observe('events.subscribe.refused', {
330
+ event: eventName,
331
+ reason,
332
+ ...(subscriber === undefined ? {} : { subscriber: subscriber.identity, origin: subscriber.origin }),
333
+ });
334
+ return null;
335
+ }
336
+ #observe(event, detail) {
337
+ this.authority?.observe(OBSERVATION_SOURCE, event, detail);
338
+ }
339
+ }
@@ -0,0 +1,2 @@
1
+ export * from './EventsService.js';
2
+ export * from './limits.js';
@@ -0,0 +1,2 @@
1
+ export * from './EventsService.js';
2
+ export * from './limits.js';
@@ -0,0 +1,22 @@
1
+ /** Numeric bounds of the events hardcore's delivery machinery. */
2
+ export interface EventsLimits {
3
+ /** Deliveries each event's retention log keeps (the event's bound). */
4
+ readonly retentionDepth: number;
5
+ /** Unread deliveries one subscription may hold before its backpressure applies. */
6
+ readonly queueDepth: number;
7
+ /** Maximum deliveries one pull returns. */
8
+ readonly batchSize: number;
9
+ }
10
+ /** Defaults: queue depth is below retention depth so a held backlog stays readable. */
11
+ export declare const DEFAULT_EVENTS_LIMITS: EventsLimits;
12
+ /** Returns the bounds in force. */
13
+ export declare function eventsLimits(): EventsLimits;
14
+ /**
15
+ * Overrides the bounds (tests use small bounds to exercise backpressure).
16
+ *
17
+ * @throws RangeError when a bound is not a positive integer or the queue depth
18
+ * is not below the retention depth.
19
+ */
20
+ export declare function configureEventsLimits(limits: Partial<EventsLimits>): void;
21
+ /** Restores the default bounds. */
22
+ export declare function resetEventsLimits(): void;
@@ -0,0 +1,33 @@
1
+ /** Defaults: queue depth is below retention depth so a held backlog stays readable. */
2
+ export const DEFAULT_EVENTS_LIMITS = Object.freeze({
3
+ retentionDepth: 100,
4
+ queueDepth: 50,
5
+ batchSize: 10,
6
+ });
7
+ let current = DEFAULT_EVENTS_LIMITS;
8
+ /** Returns the bounds in force. */
9
+ export function eventsLimits() {
10
+ return current;
11
+ }
12
+ /**
13
+ * Overrides the bounds (tests use small bounds to exercise backpressure).
14
+ *
15
+ * @throws RangeError when a bound is not a positive integer or the queue depth
16
+ * is not below the retention depth.
17
+ */
18
+ export function configureEventsLimits(limits) {
19
+ const next = { ...current, ...limits };
20
+ for (const [key, value] of Object.entries(next)) {
21
+ if (!Number.isInteger(value) || value < 1) {
22
+ throw new RangeError(`events limit "${key}" must be a positive integer`);
23
+ }
24
+ }
25
+ if (next.queueDepth >= next.retentionDepth) {
26
+ throw new RangeError('events queueDepth must be smaller than retentionDepth');
27
+ }
28
+ current = Object.freeze(next);
29
+ }
30
+ /** Restores the default bounds. */
31
+ export function resetEventsLimits() {
32
+ current = DEFAULT_EVENTS_LIMITS;
33
+ }
@@ -0,0 +1,2 @@
1
+ import type { KernelServiceModuleContext } from '../../src/bootstrap/bootTypes.js';
2
+ export declare function createService(context: KernelServiceModuleContext): import("../../index.js").ServiceDescriptor<import("./index.js").IEventsService, import("./index.js").EventsService>;
@@ -0,0 +1,5 @@
1
+ import { createEventsDescriptor } from './descriptor/EventsDescriptor.js';
2
+ export function createService(context) {
3
+ void context;
4
+ return createEventsDescriptor();
5
+ }
@@ -0,0 +1,44 @@
1
+ import type { ExposureDeclaration } from '../../../src/contracts/manifest.js';
2
+ import type { ExposedApiResolveOptions } from './types.js';
3
+ /**
4
+ * The resolution primitive, as every participant sees it.
5
+ *
6
+ * `resolve` is open to every participant in the composition. It takes no
7
+ * caller list and applies no policy of its own: it reads the caller and the
8
+ * chain's root origin from the kernel-provided execution context and evaluates
9
+ * the giver's declared Layer 1 policy.
10
+ */
11
+ export interface IExposedApiRegistry {
12
+ /**
13
+ * Resolves an exposure for the current caller.
14
+ *
15
+ * Layer 1 is evaluated here, to decide whether the caller may see the
16
+ * exposure, and again on every use of the returned handle, against the root
17
+ * origin of the chain using it. A handle is a reference, not a grant.
18
+ *
19
+ * A caller the policy does not permit receives exactly what it would receive
20
+ * for an exposure that does not exist: `null`. The detailed reason goes to
21
+ * the kernel's observation stream.
22
+ *
23
+ * @param name - Exposure name.
24
+ * @param options - Version and expected owner identity.
25
+ * @returns The handle, or `null`.
26
+ */
27
+ resolve<T = unknown>(name: string, options?: ExposedApiResolveOptions): T | null;
28
+ }
29
+ /**
30
+ * Registration, as only the kernel sees it.
31
+ *
32
+ * The kernel calls `register` during admission, on each participant's behalf,
33
+ * from that participant's manifest. It is never part of the view a participant
34
+ * receives, and it is refused for everyone once the boot window seals.
35
+ */
36
+ export interface IExposedApiAdmission {
37
+ /**
38
+ * Registers one declared exposure for its owner.
39
+ *
40
+ * @param owner - Kernel-issued identity token of the declaring participant.
41
+ * @param declaration - The exposure exactly as the manifest declares it.
42
+ */
43
+ register(owner: string, declaration: ExposureDeclaration): void;
44
+ }
@@ -0,0 +1,132 @@
1
+ /** Stable, machine-readable codes for Registry failures. */
2
+ export type ExposedApiErrorCode = 'EXPOSED_API_REGISTRATION_CLOSED' | 'EXPOSED_API_NAME_COLLISION' | 'EXPOSED_API_INVALID_NAME' | 'EXPOSED_API_OWNER_PIN' | 'EXPOSED_API_DUPLICATE_EXPOSURE' | 'EXPOSED_API_NOT_ATTACHED' | 'EXPOSED_API_UNAVAILABLE' | 'EXPOSED_API_INVALID_VERSION' | 'EXPOSED_API_INVALID_SCOPE' | 'EXPOSED_API_INVALID_POLICY' | 'EXPOSED_API_SCOPE_NARROWED' | 'EXPOSED_API_SCOPE_RECORD_CORRUPT' | 'EXPOSED_API_SCOPE_RECORD_PATH' | 'EXPOSED_API_SCOPE_RECORD_WRITE' | 'EXPOSED_API_DISPOSED';
3
+ /** Base class for every Registry domain failure. */
4
+ export declare abstract class ExposedApiError extends Error {
5
+ /** Stable, machine-readable error code. */
6
+ abstract readonly code: ExposedApiErrorCode;
7
+ protected constructor(message: string, options?: ErrorOptions);
8
+ }
9
+ /** Raised when an exposure is registered after the boot window closed. */
10
+ export declare class ExposedApiRegistrationClosedError extends ExposedApiError {
11
+ readonly code: "EXPOSED_API_REGISTRATION_CLOSED";
12
+ /** Rejected API name. */
13
+ readonly apiName: string;
14
+ constructor(apiName: string);
15
+ }
16
+ /**
17
+ * Raised when a second identity registers a name another identity owns.
18
+ *
19
+ * A name is owned by the identity that first registered it, across every major
20
+ * version: a version upgrade keeps ownership.
21
+ */
22
+ export declare class ExposedApiNameCollisionError extends ExposedApiError {
23
+ readonly code: "EXPOSED_API_NAME_COLLISION";
24
+ /** Contested API name. */
25
+ readonly apiName: string;
26
+ /** Identity token that owns the name. */
27
+ readonly owner: string;
28
+ constructor(apiName: string, owner: string);
29
+ }
30
+ /** Raised when a registration contradicts the composition's owner pin. */
31
+ export declare class ExposedApiOwnerPinError extends ExposedApiError {
32
+ readonly code: "EXPOSED_API_OWNER_PIN";
33
+ /** Pinned API name. */
34
+ readonly apiName: string;
35
+ constructor(apiName: string);
36
+ }
37
+ /** Raised when one identity declares the same name and major version twice. */
38
+ export declare class ExposedApiDuplicateExposureError extends ExposedApiError {
39
+ readonly code: "EXPOSED_API_DUPLICATE_EXPOSURE";
40
+ /** API name. */
41
+ readonly apiName: string;
42
+ /** Duplicated major version. */
43
+ readonly major: number;
44
+ constructor(apiName: string, major: number);
45
+ }
46
+ /** Raised when admission runs before the kernel attached its call authority. */
47
+ export declare class ExposedApiNotAttachedError extends ExposedApiError {
48
+ readonly code: "EXPOSED_API_NOT_ATTACHED";
49
+ constructor();
50
+ }
51
+ /**
52
+ * Raised when an exposure handle is used by a caller the exposure's policy
53
+ * does not permit at the time of use.
54
+ *
55
+ * Carries no reason. The detailed reason is on the kernel's observation
56
+ * stream, so a refused caller learns nothing about why.
57
+ */
58
+ export declare class ExposedApiUnavailableError extends ExposedApiError {
59
+ readonly code: "EXPOSED_API_UNAVAILABLE";
60
+ constructor();
61
+ }
62
+ /** Raised when an API name is malformed. */
63
+ export declare class ExposedApiInvalidNameError extends ExposedApiError {
64
+ readonly code: "EXPOSED_API_INVALID_NAME";
65
+ /** Rejected name. */
66
+ readonly apiName: string;
67
+ constructor(apiName: string);
68
+ }
69
+ /** Raised when the Registry is used after disposal. */
70
+ export declare class ExposedApiDisposedError extends ExposedApiError {
71
+ readonly code: "EXPOSED_API_DISPOSED";
72
+ constructor();
73
+ }
74
+ /** Raised when a registration declares an invalid API version. */
75
+ export declare class ExposedApiInvalidVersionError extends ExposedApiError {
76
+ readonly code: "EXPOSED_API_INVALID_VERSION";
77
+ /** Rejected version. */
78
+ readonly version: unknown;
79
+ constructor(version: unknown);
80
+ }
81
+ /** Raised when a registration declares an unsupported scope. */
82
+ export declare class ExposedApiInvalidScopeError extends ExposedApiError {
83
+ readonly code: "EXPOSED_API_INVALID_SCOPE";
84
+ /** Rejected scope. */
85
+ readonly scope: unknown;
86
+ constructor(scope: unknown);
87
+ }
88
+ /** Raised when a registration declares a malformed policy. */
89
+ export declare class ExposedApiInvalidPolicyError extends ExposedApiError {
90
+ readonly code: "EXPOSED_API_INVALID_POLICY";
91
+ /** Human-readable reason. */
92
+ readonly reason: string;
93
+ constructor(reason: string);
94
+ }
95
+ /** Raised when a registration narrows a persisted scope within one version. */
96
+ export declare class ExposedApiScopeNarrowingError extends ExposedApiError {
97
+ readonly code: "EXPOSED_API_SCOPE_NARROWED";
98
+ /** API name. */
99
+ readonly apiName: string;
100
+ /** API version. */
101
+ readonly version: string;
102
+ /** Scope already recorded for the identity. */
103
+ readonly persistedScope: string;
104
+ /** Scope the registration requested. */
105
+ readonly requestedScope: string;
106
+ constructor(apiName: string, version: string, persistedScope: string, requestedScope: string);
107
+ }
108
+ /** Raised when the protected scope record cannot be parsed or verified. */
109
+ export declare class ExposedApiScopeRecordCorruptError extends ExposedApiError {
110
+ readonly code: "EXPOSED_API_SCOPE_RECORD_CORRUPT";
111
+ /** Absolute storage path. */
112
+ readonly storagePath: string;
113
+ /** Human-readable reason. */
114
+ readonly reason: string;
115
+ constructor(storagePath: string, reason: string);
116
+ }
117
+ /** Raised when a scope-record storage path is not an absolute file path. */
118
+ export declare class ExposedApiScopeRecordPathError extends ExposedApiError {
119
+ readonly code: "EXPOSED_API_SCOPE_RECORD_PATH";
120
+ /** Rejected path. */
121
+ readonly storagePath: string;
122
+ constructor(storagePath: string);
123
+ }
124
+ /** Raised when the protected scope record cannot be written. */
125
+ export declare class ExposedApiScopeRecordWriteError extends ExposedApiError {
126
+ readonly code: "EXPOSED_API_SCOPE_RECORD_WRITE";
127
+ /** Absolute storage path. */
128
+ readonly storagePath: string;
129
+ /** Filesystem error code, when available. */
130
+ readonly reason: string;
131
+ constructor(storagePath: string, reason: string);
132
+ }