@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.
- package/LICENSE +201 -0
- package/README.md +63 -2
- package/dist/index.d.ts +15 -0
- package/dist/index.js +13 -0
- package/dist/serviceModules/events.d.ts +1 -0
- package/dist/serviceModules/events.js +1 -0
- package/dist/serviceModules/exposedApiRegistry.d.ts +1 -0
- package/dist/serviceModules/exposedApiRegistry.js +1 -0
- package/dist/serviceModules/identityRegistry.d.ts +1 -0
- package/dist/serviceModules/identityRegistry.js +1 -0
- package/dist/serviceModules/interception.d.ts +1 -0
- package/dist/serviceModules/interception.js +1 -0
- package/dist/serviceModules/parser.d.ts +1 -0
- package/dist/serviceModules/parser.js +1 -0
- package/dist/serviceModules/router.d.ts +1 -0
- package/dist/serviceModules/router.js +1 -0
- package/dist/serviceModules/wasmCage.d.ts +1 -0
- package/dist/serviceModules/wasmCage.js +1 -0
- package/dist/services/Events/contracts/IEventsService.d.ts +64 -0
- package/dist/services/Events/contracts/IEventsService.js +1 -0
- package/dist/services/Events/contracts/errors.d.ts +31 -0
- package/dist/services/Events/contracts/errors.js +40 -0
- package/dist/services/Events/contracts/index.d.ts +3 -0
- package/dist/services/Events/contracts/index.js +3 -0
- package/dist/services/Events/contracts/tokens.d.ts +2 -0
- package/dist/services/Events/contracts/tokens.js +2 -0
- package/dist/services/Events/descriptor/EventsDescriptor.d.ts +9 -0
- package/dist/services/Events/descriptor/EventsDescriptor.js +56 -0
- package/dist/services/Events/descriptor/tokens.d.ts +1 -0
- package/dist/services/Events/descriptor/tokens.js +1 -0
- package/dist/services/Events/index.d.ts +4 -0
- package/dist/services/Events/index.js +4 -0
- package/dist/services/Events/orchestrator/EventsService.d.ts +51 -0
- package/dist/services/Events/orchestrator/EventsService.js +339 -0
- package/dist/services/Events/orchestrator/index.d.ts +2 -0
- package/dist/services/Events/orchestrator/index.js +2 -0
- package/dist/services/Events/orchestrator/limits.d.ts +22 -0
- package/dist/services/Events/orchestrator/limits.js +33 -0
- package/dist/services/Events/serviceModule.d.ts +2 -0
- package/dist/services/Events/serviceModule.js +5 -0
- package/dist/services/ExposedApiRegistry/contracts/IExposedApiRegistry.d.ts +56 -0
- package/dist/services/ExposedApiRegistry/contracts/IExposedApiRegistry.js +1 -0
- package/dist/services/ExposedApiRegistry/contracts/errors.d.ts +132 -0
- package/dist/services/ExposedApiRegistry/contracts/errors.js +195 -0
- package/dist/services/ExposedApiRegistry/contracts/index.d.ts +9 -0
- package/dist/services/ExposedApiRegistry/contracts/index.js +4 -0
- package/dist/services/ExposedApiRegistry/contracts/policy.d.ts +90 -0
- package/dist/services/ExposedApiRegistry/contracts/policy.js +169 -0
- package/dist/services/ExposedApiRegistry/contracts/registrant.d.ts +37 -0
- package/dist/services/ExposedApiRegistry/contracts/registrant.js +36 -0
- package/dist/services/ExposedApiRegistry/contracts/types.d.ts +133 -0
- package/dist/services/ExposedApiRegistry/contracts/types.js +73 -0
- package/dist/services/ExposedApiRegistry/descriptor/ExposedApiRegistryDescriptor.d.ts +44 -0
- package/dist/services/ExposedApiRegistry/descriptor/ExposedApiRegistryDescriptor.js +58 -0
- package/dist/services/ExposedApiRegistry/descriptor/tokens.d.ts +8 -0
- package/dist/services/ExposedApiRegistry/descriptor/tokens.js +8 -0
- package/dist/services/ExposedApiRegistry/index.d.ts +6 -0
- package/dist/services/ExposedApiRegistry/index.js +5 -0
- package/dist/services/ExposedApiRegistry/orchestrator/ExposedApiRegistryService.d.ts +68 -0
- package/dist/services/ExposedApiRegistry/orchestrator/ExposedApiRegistryService.js +452 -0
- package/dist/services/ExposedApiRegistry/orchestrator/index.d.ts +2 -0
- package/dist/services/ExposedApiRegistry/orchestrator/index.js +1 -0
- package/dist/services/ExposedApiRegistry/serviceModule.d.ts +10 -0
- package/dist/services/ExposedApiRegistry/serviceModule.js +20 -0
- package/dist/services/ExposedApiRegistry/storage/protection.d.ts +21 -0
- package/dist/services/ExposedApiRegistry/storage/protection.js +35 -0
- package/dist/services/ExposedApiRegistry/storage/scopeRecord.d.ts +45 -0
- package/dist/services/ExposedApiRegistry/storage/scopeRecord.js +178 -0
- package/dist/services/IdentityRegistry/contracts/errors.d.ts +88 -0
- package/dist/services/IdentityRegistry/contracts/errors.js +128 -0
- package/dist/services/IdentityRegistry/contracts/index.d.ts +5 -0
- package/dist/services/IdentityRegistry/contracts/index.js +3 -0
- package/dist/services/IdentityRegistry/contracts/types.d.ts +77 -0
- package/dist/services/IdentityRegistry/contracts/types.js +18 -0
- package/dist/services/IdentityRegistry/descriptor/descriptor.d.ts +36 -0
- package/dist/services/IdentityRegistry/descriptor/descriptor.js +44 -0
- package/dist/services/IdentityRegistry/descriptor/tokens.d.ts +8 -0
- package/dist/services/IdentityRegistry/descriptor/tokens.js +8 -0
- package/dist/services/IdentityRegistry/index.d.ts +11 -0
- package/dist/services/IdentityRegistry/index.js +6 -0
- package/dist/services/IdentityRegistry/orchestrator/IdentityRegistryService.d.ts +47 -0
- package/dist/services/IdentityRegistry/orchestrator/IdentityRegistryService.js +240 -0
- package/dist/services/IdentityRegistry/serviceModule.d.ts +10 -0
- package/dist/services/IdentityRegistry/serviceModule.js +24 -0
- package/dist/services/IdentityRegistry/storage/registryDocument.d.ts +55 -0
- package/dist/services/IdentityRegistry/storage/registryDocument.js +235 -0
- package/dist/services/Interception/contracts/IInterceptionService.d.ts +155 -0
- package/dist/services/Interception/contracts/IInterceptionService.js +12 -0
- package/dist/services/Interception/contracts/errors.d.ts +26 -0
- package/dist/services/Interception/contracts/errors.js +35 -0
- package/dist/services/Interception/contracts/index.d.ts +3 -0
- package/dist/services/Interception/contracts/index.js +3 -0
- package/dist/services/Interception/contracts/tokens.d.ts +2 -0
- package/dist/services/Interception/contracts/tokens.js +2 -0
- package/dist/services/Interception/descriptor/InterceptionDescriptor.d.ts +9 -0
- package/dist/services/Interception/descriptor/InterceptionDescriptor.js +50 -0
- package/dist/services/Interception/descriptor/tokens.d.ts +1 -0
- package/dist/services/Interception/descriptor/tokens.js +1 -0
- package/dist/services/Interception/index.d.ts +4 -0
- package/dist/services/Interception/index.js +4 -0
- package/dist/services/Interception/orchestrator/InterceptionService.d.ts +40 -0
- package/dist/services/Interception/orchestrator/InterceptionService.js +343 -0
- package/dist/services/Interception/orchestrator/index.d.ts +1 -0
- package/dist/services/Interception/orchestrator/index.js +1 -0
- package/dist/services/Interception/serviceModule.d.ts +2 -0
- package/dist/services/Interception/serviceModule.js +5 -0
- package/dist/services/Parser/contracts/IParserService.d.ts +21 -0
- package/dist/services/Parser/contracts/IParserService.js +1 -0
- package/dist/services/Parser/contracts/errors.d.ts +25 -0
- package/dist/services/Parser/contracts/errors.js +33 -0
- package/dist/services/Parser/contracts/index.d.ts +4 -0
- package/dist/services/Parser/contracts/index.js +1 -0
- package/dist/services/Parser/contracts/types.d.ts +42 -0
- package/dist/services/Parser/contracts/types.js +1 -0
- package/dist/services/Parser/descriptor/ParserDescriptor.d.ts +23 -0
- package/dist/services/Parser/descriptor/ParserDescriptor.js +50 -0
- package/dist/services/Parser/descriptor/tokens.d.ts +8 -0
- package/dist/services/Parser/descriptor/tokens.js +8 -0
- package/dist/services/Parser/index.d.ts +8 -0
- package/dist/services/Parser/index.js +8 -0
- package/dist/services/Parser/orchestrator/ParserService.d.ts +20 -0
- package/dist/services/Parser/orchestrator/ParserService.js +105 -0
- package/dist/services/Parser/orchestrator/index.d.ts +1 -0
- package/dist/services/Parser/orchestrator/index.js +1 -0
- package/dist/services/Parser/parser/indexSynthesis.d.ts +11 -0
- package/dist/services/Parser/parser/indexSynthesis.js +13 -0
- package/dist/services/Parser/parser/parameters.d.ts +14 -0
- package/dist/services/Parser/parser/parameters.js +89 -0
- package/dist/services/Parser/parser/scanner.d.ts +48 -0
- package/dist/services/Parser/parser/scanner.js +156 -0
- package/dist/services/Parser/parser/syntax.d.ts +30 -0
- package/dist/services/Parser/parser/syntax.js +34 -0
- package/dist/services/Parser/serviceModule.d.ts +2 -0
- package/dist/services/Parser/serviceModule.js +5 -0
- package/dist/services/Router/bootOptions.d.ts +2 -0
- package/dist/services/Router/bootOptions.js +2 -0
- package/dist/services/Router/contracts/IRouterService.d.ts +43 -0
- package/dist/services/Router/contracts/IRouterService.js +1 -0
- package/dist/services/Router/contracts/caller.d.ts +6 -0
- package/dist/services/Router/contracts/caller.js +6 -0
- package/dist/services/Router/contracts/errors.d.ts +67 -0
- package/dist/services/Router/contracts/errors.js +90 -0
- package/dist/services/Router/contracts/index.d.ts +8 -0
- package/dist/services/Router/contracts/index.js +4 -0
- package/dist/services/Router/contracts/kind.d.ts +7 -0
- package/dist/services/Router/contracts/kind.js +10 -0
- package/dist/services/Router/contracts/registrant.d.ts +23 -0
- package/dist/services/Router/contracts/registrant.js +13 -0
- package/dist/services/Router/contracts/types.d.ts +110 -0
- package/dist/services/Router/contracts/types.js +1 -0
- package/dist/services/Router/descriptor/RouterDescriptor.d.ts +32 -0
- package/dist/services/Router/descriptor/RouterDescriptor.js +92 -0
- package/dist/services/Router/descriptor/tokens.d.ts +9 -0
- package/dist/services/Router/descriptor/tokens.js +9 -0
- package/dist/services/Router/index.d.ts +4 -0
- package/dist/services/Router/index.js +4 -0
- package/dist/services/Router/orchestrator/RouterService.d.ts +93 -0
- package/dist/services/Router/orchestrator/RouterService.js +457 -0
- package/dist/services/Router/orchestrator/index.d.ts +2 -0
- package/dist/services/Router/orchestrator/index.js +1 -0
- package/dist/services/Router/serviceModule.d.ts +4 -0
- package/dist/services/Router/serviceModule.js +22 -0
- package/dist/services/WasmCage/index.d.ts +7 -0
- package/dist/services/WasmCage/index.js +4 -0
- package/dist/services/WasmCage/scripts/prepin.d.ts +1 -0
- package/dist/services/WasmCage/scripts/prepin.js +38 -0
- package/dist/services/WasmCage/serviceModule.d.ts +12 -0
- package/dist/services/WasmCage/serviceModule.js +18 -0
- package/dist/services/WasmCage/src/caged.d.ts +121 -0
- package/dist/services/WasmCage/src/caged.js +460 -0
- package/dist/services/WasmCage/src/descriptor.d.ts +47 -0
- package/dist/services/WasmCage/src/descriptor.js +56 -0
- package/dist/services/WasmCage/src/native.d.ts +29 -0
- package/dist/services/WasmCage/src/native.js +66 -0
- package/dist/services/WasmCage/src/nativeDigests.d.ts +9 -0
- package/dist/services/WasmCage/src/nativeDigests.js +15 -0
- package/dist/services/WasmCage/src/package.d.ts +36 -0
- package/dist/services/WasmCage/src/package.js +122 -0
- package/dist/services/shared/canonicalJson.d.ts +29 -0
- package/dist/services/shared/canonicalJson.js +93 -0
- package/dist/services/shared/documentStore.d.ts +16 -0
- package/dist/services/shared/documentStore.js +98 -0
- package/dist/src/bootstrap/bootKernelInternal.d.ts +19 -0
- package/dist/src/bootstrap/bootKernelInternal.js +633 -0
- package/dist/src/bootstrap/bootTypes.d.ts +113 -0
- package/dist/src/bootstrap/bootTypes.js +1 -0
- package/dist/src/bootstrap/config/index.d.ts +3 -0
- package/dist/src/bootstrap/config/index.js +2 -0
- package/dist/src/bootstrap/config/integrity.d.ts +45 -0
- package/dist/src/bootstrap/config/integrity.js +92 -0
- package/dist/src/bootstrap/config/parse.d.ts +15 -0
- package/dist/src/bootstrap/config/parse.js +81 -0
- package/dist/src/bootstrap/config/pathWriteGuard.d.ts +20 -0
- package/dist/src/bootstrap/config/pathWriteGuard.js +349 -0
- package/dist/src/bootstrap/config/types.d.ts +41 -0
- package/dist/src/bootstrap/config/types.js +15 -0
- package/dist/src/bootstrap/hardcore.d.ts +212 -0
- package/dist/src/bootstrap/hardcore.js +312 -0
- package/dist/src/bootstrap/hardcoreServices.d.ts +10 -0
- package/dist/src/bootstrap/hardcoreServices.js +258 -0
- package/dist/src/bootstrap/index.d.ts +13 -0
- package/dist/src/bootstrap/index.js +7 -0
- package/dist/src/bootstrap/loaded.d.ts +30 -0
- package/dist/src/bootstrap/loaded.js +45 -0
- package/dist/src/bootstrap/packageRequirements.d.ts +26 -0
- package/dist/src/bootstrap/packageRequirements.js +52 -0
- package/dist/src/bootstrap/reload.d.ts +44 -0
- package/dist/src/bootstrap/reload.js +45 -0
- package/dist/src/bootstrap/seal.d.ts +32 -0
- package/dist/src/bootstrap/seal.js +101 -0
- package/dist/src/contracts/accessBroker.d.ts +53 -0
- package/dist/src/contracts/accessBroker.js +1 -0
- package/dist/src/contracts/brudOperation.d.ts +20 -0
- package/dist/src/contracts/brudOperation.js +20 -0
- package/dist/src/contracts/callChain.d.ts +161 -0
- package/dist/src/contracts/callChain.js +19 -0
- package/dist/src/contracts/capability.d.ts +26 -0
- package/dist/src/contracts/capability.js +26 -0
- package/dist/src/contracts/capabilitySet.d.ts +23 -0
- package/dist/src/contracts/capabilitySet.js +72 -0
- package/dist/src/contracts/container.d.ts +17 -0
- package/dist/src/contracts/container.js +8 -0
- package/dist/src/contracts/context.d.ts +19 -0
- package/dist/src/contracts/context.js +1 -0
- package/dist/src/contracts/contextContract.d.ts +132 -0
- package/dist/src/contracts/contextContract.js +274 -0
- package/dist/src/contracts/dispatchView.d.ts +21 -0
- package/dist/src/contracts/dispatchView.js +1 -0
- package/dist/src/contracts/handler.d.ts +21 -0
- package/dist/src/contracts/handler.js +1 -0
- package/dist/src/contracts/index.d.ts +26 -0
- package/dist/src/contracts/index.js +9 -0
- package/dist/src/contracts/kernel.d.ts +60 -0
- package/dist/src/contracts/kernel.js +1 -0
- package/dist/src/contracts/lifecycle.d.ts +59 -0
- package/dist/src/contracts/lifecycle.js +1 -0
- package/dist/src/contracts/manifest.d.ts +180 -0
- package/dist/src/contracts/manifest.js +334 -0
- package/dist/src/contracts/pipeline.d.ts +8 -0
- package/dist/src/contracts/pipeline.js +1 -0
- package/dist/src/contracts/policy.d.ts +75 -0
- package/dist/src/contracts/policy.js +77 -0
- package/dist/src/contracts/registry.d.ts +7 -0
- package/dist/src/contracts/registry.js +1 -0
- package/dist/src/contracts/serviceDescriptor.d.ts +67 -0
- package/dist/src/contracts/serviceDescriptor.js +1 -0
- package/dist/src/contracts/serviceToken.d.ts +36 -0
- package/dist/src/contracts/serviceToken.js +16 -0
- package/dist/src/engine/BrudKernel.d.ts +120 -0
- package/dist/src/engine/BrudKernel.js +395 -0
- package/dist/src/engine/ExecutionPipeline.d.ts +13 -0
- package/dist/src/engine/ExecutionPipeline.js +62 -0
- package/dist/src/engine/KernelAccessBroker.d.ts +47 -0
- package/dist/src/engine/KernelAccessBroker.js +107 -0
- package/dist/src/engine/KernelRegistry.d.ts +14 -0
- package/dist/src/engine/KernelRegistry.js +33 -0
- package/dist/src/engine/OperationRegistry.d.ts +9 -0
- package/dist/src/engine/OperationRegistry.js +18 -0
- package/dist/src/engine/ServiceContainer.d.ts +13 -0
- package/dist/src/engine/ServiceContainer.js +53 -0
- package/dist/src/engine/callChain.d.ts +68 -0
- package/dist/src/engine/callChain.js +175 -0
- package/dist/src/engine/dag.d.ts +2 -0
- package/dist/src/engine/dag.js +34 -0
- package/dist/src/engine/errors.d.ts +26 -0
- package/dist/src/engine/errors.js +52 -0
- package/dist/src/engine/index.d.ts +11 -0
- package/dist/src/engine/index.js +8 -0
- package/dist/src/engine/state.d.ts +1 -0
- package/dist/src/engine/state.js +1 -0
- package/dist/src/validation/jsonSchema/compile.d.ts +8 -0
- package/dist/src/validation/jsonSchema/compile.js +386 -0
- package/dist/src/validation/jsonSchema/index.d.ts +3 -0
- package/dist/src/validation/jsonSchema/index.js +2 -0
- package/dist/src/validation/jsonSchema/jsonValue.d.ts +29 -0
- package/dist/src/validation/jsonSchema/jsonValue.js +190 -0
- package/dist/src/validation/jsonSchema/pattern.d.ts +28 -0
- package/dist/src/validation/jsonSchema/pattern.js +155 -0
- package/dist/src/validation/jsonSchema/types.d.ts +71 -0
- package/dist/src/validation/jsonSchema/types.js +15 -0
- package/package.json +59 -4
- package/services/WasmCage/native/brud-wasm-cage.darwin-arm64.node +0 -0
- package/services/WasmCage/native/brud-wasm-cage.darwin-x64.node +0 -0
- package/services/WasmCage/native/brud-wasm-cage.linux-arm64-gnu.node +0 -0
- package/services/WasmCage/native/brud-wasm-cage.linux-x64-gnu.node +0 -0
- package/services/WasmCage/native/brud-wasm-cage.win32-x64-msvc.node +0 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { ServiceToken } from './serviceToken.js';
|
|
2
|
+
/**
|
|
3
|
+
* Declarative access control rules applied when a caller requests a service.
|
|
4
|
+
*
|
|
5
|
+
* A denied caller is always rejected. When `allowedCallers` is provided, only
|
|
6
|
+
* the listed callers may access the service; otherwise access is open.
|
|
7
|
+
*/
|
|
8
|
+
export interface ServiceAccessPolicy {
|
|
9
|
+
/** Callers that can never access the service. */
|
|
10
|
+
readonly deniedCallers?: readonly (string | ServiceToken<unknown>)[];
|
|
11
|
+
/** Callers explicitly permitted to access the service. */
|
|
12
|
+
readonly allowedCallers?: readonly (string | ServiceToken<unknown>)[];
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Base class for every rejection produced by a service access policy.
|
|
16
|
+
*
|
|
17
|
+
* Callers should branch on this type when they only need to know that the
|
|
18
|
+
* broker refused access; the concrete subclasses carry the finer reason.
|
|
19
|
+
*/
|
|
20
|
+
export declare abstract class AccessDeniedError extends Error {
|
|
21
|
+
/** Stable, machine-readable error code. */
|
|
22
|
+
abstract readonly code: string;
|
|
23
|
+
/** Identifier of the caller that attempted access. */
|
|
24
|
+
readonly callerId: string;
|
|
25
|
+
/** Identifier of the service that denied access. */
|
|
26
|
+
readonly targetServiceId: string;
|
|
27
|
+
/**
|
|
28
|
+
* @param message - Path-free, human-readable denial description.
|
|
29
|
+
* @param callerId - Identifier of the caller that attempted access.
|
|
30
|
+
* @param targetServiceId - Identifier of the service that denied access.
|
|
31
|
+
*/
|
|
32
|
+
protected constructor(message: string, callerId: string, targetServiceId: string);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Raised when a caller matches the deny list of a service's access policy.
|
|
36
|
+
*/
|
|
37
|
+
export declare class BlacklistedAccessViolationError extends AccessDeniedError {
|
|
38
|
+
/** Stable, machine-readable error code. */
|
|
39
|
+
readonly code: "BLACKLISTED_ACCESS";
|
|
40
|
+
/** Explanation of why the caller was denied. */
|
|
41
|
+
readonly reason: string;
|
|
42
|
+
/**
|
|
43
|
+
* @param callerId - Identifier of the caller that attempted access.
|
|
44
|
+
* @param targetServiceId - Identifier of the service that denied access.
|
|
45
|
+
* @param reason - Explanation of why the caller was denied.
|
|
46
|
+
*/
|
|
47
|
+
constructor(callerId: string, targetServiceId: string, reason: string);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Raised when a caller is not present in a service's allow list.
|
|
51
|
+
*/
|
|
52
|
+
/**
|
|
53
|
+
* Raised when a caller inside a kernel call chain asserts a caller id that is
|
|
54
|
+
* not the identity the kernel admitted it with. Token access binds to the
|
|
55
|
+
* call chain: a participant can only ever be itself.
|
|
56
|
+
*/
|
|
57
|
+
export declare class CallerIdentityMismatchError extends AccessDeniedError {
|
|
58
|
+
/** Stable, machine-readable error code. */
|
|
59
|
+
readonly code: "CALLER_IDENTITY_MISMATCH";
|
|
60
|
+
/**
|
|
61
|
+
* @param assertedCallerId - Caller id the requester supplied.
|
|
62
|
+
* @param targetServiceId - Identifier of the service requested.
|
|
63
|
+
* @param boundCallerId - Caller id the call chain binds the requester to, if any.
|
|
64
|
+
*/
|
|
65
|
+
constructor(assertedCallerId: string, targetServiceId: string, boundCallerId: string | undefined);
|
|
66
|
+
}
|
|
67
|
+
export declare class AllowlistViolationError extends AccessDeniedError {
|
|
68
|
+
/** Stable, machine-readable error code. */
|
|
69
|
+
readonly code: "NOT_IN_ALLOWLIST";
|
|
70
|
+
/**
|
|
71
|
+
* @param callerId - Identifier of the caller that attempted access.
|
|
72
|
+
* @param targetServiceId - Identifier of the service that denied access.
|
|
73
|
+
*/
|
|
74
|
+
constructor(callerId: string, targetServiceId: string);
|
|
75
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base class for every rejection produced by a service access policy.
|
|
3
|
+
*
|
|
4
|
+
* Callers should branch on this type when they only need to know that the
|
|
5
|
+
* broker refused access; the concrete subclasses carry the finer reason.
|
|
6
|
+
*/
|
|
7
|
+
export class AccessDeniedError extends Error {
|
|
8
|
+
/** Identifier of the caller that attempted access. */
|
|
9
|
+
callerId;
|
|
10
|
+
/** Identifier of the service that denied access. */
|
|
11
|
+
targetServiceId;
|
|
12
|
+
/**
|
|
13
|
+
* @param message - Path-free, human-readable denial description.
|
|
14
|
+
* @param callerId - Identifier of the caller that attempted access.
|
|
15
|
+
* @param targetServiceId - Identifier of the service that denied access.
|
|
16
|
+
*/
|
|
17
|
+
constructor(message, callerId, targetServiceId) {
|
|
18
|
+
super(message);
|
|
19
|
+
this.name = 'AccessDeniedError';
|
|
20
|
+
this.callerId = callerId;
|
|
21
|
+
this.targetServiceId = targetServiceId;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Raised when a caller matches the deny list of a service's access policy.
|
|
26
|
+
*/
|
|
27
|
+
export class BlacklistedAccessViolationError extends AccessDeniedError {
|
|
28
|
+
/** Stable, machine-readable error code. */
|
|
29
|
+
code = 'BLACKLISTED_ACCESS';
|
|
30
|
+
/** Explanation of why the caller was denied. */
|
|
31
|
+
reason;
|
|
32
|
+
/**
|
|
33
|
+
* @param callerId - Identifier of the caller that attempted access.
|
|
34
|
+
* @param targetServiceId - Identifier of the service that denied access.
|
|
35
|
+
* @param reason - Explanation of why the caller was denied.
|
|
36
|
+
*/
|
|
37
|
+
constructor(callerId, targetServiceId, reason) {
|
|
38
|
+
super(`Caller "${callerId}" is blacklisted from service "${targetServiceId}": ${reason}`, callerId, targetServiceId);
|
|
39
|
+
this.name = 'BlacklistedAccessViolationError';
|
|
40
|
+
this.reason = reason;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Raised when a caller is not present in a service's allow list.
|
|
45
|
+
*/
|
|
46
|
+
/**
|
|
47
|
+
* Raised when a caller inside a kernel call chain asserts a caller id that is
|
|
48
|
+
* not the identity the kernel admitted it with. Token access binds to the
|
|
49
|
+
* call chain: a participant can only ever be itself.
|
|
50
|
+
*/
|
|
51
|
+
export class CallerIdentityMismatchError extends AccessDeniedError {
|
|
52
|
+
/** Stable, machine-readable error code. */
|
|
53
|
+
code = 'CALLER_IDENTITY_MISMATCH';
|
|
54
|
+
/**
|
|
55
|
+
* @param assertedCallerId - Caller id the requester supplied.
|
|
56
|
+
* @param targetServiceId - Identifier of the service requested.
|
|
57
|
+
* @param boundCallerId - Caller id the call chain binds the requester to, if any.
|
|
58
|
+
*/
|
|
59
|
+
constructor(assertedCallerId, targetServiceId, boundCallerId) {
|
|
60
|
+
super(boundCallerId === undefined
|
|
61
|
+
? `Caller "${assertedCallerId}" is not an admitted identity in this call chain (service "${targetServiceId}")`
|
|
62
|
+
: `Caller "${assertedCallerId}" does not match its call-chain identity "${boundCallerId}" (service "${targetServiceId}")`, assertedCallerId, targetServiceId);
|
|
63
|
+
this.name = 'CallerIdentityMismatchError';
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
export class AllowlistViolationError extends AccessDeniedError {
|
|
67
|
+
/** Stable, machine-readable error code. */
|
|
68
|
+
code = 'NOT_IN_ALLOWLIST';
|
|
69
|
+
/**
|
|
70
|
+
* @param callerId - Identifier of the caller that attempted access.
|
|
71
|
+
* @param targetServiceId - Identifier of the service that denied access.
|
|
72
|
+
*/
|
|
73
|
+
constructor(callerId, targetServiceId) {
|
|
74
|
+
super(`Caller "${callerId}" is not in the allowlist for service "${targetServiceId}"`, callerId, targetServiceId);
|
|
75
|
+
this.name = 'AllowlistViolationError';
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { OperationHandler } from './handler.js';
|
|
2
|
+
export interface IOperationRegistry {
|
|
3
|
+
register(handler: OperationHandler): void;
|
|
4
|
+
get<TInput = unknown, TOutput = unknown>(kind: string): OperationHandler<TInput, TOutput> | undefined;
|
|
5
|
+
has(kind: string): boolean;
|
|
6
|
+
list(): readonly OperationHandler[];
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { IKernelAccessBroker } from './accessBroker.js';
|
|
2
|
+
import type { IServiceLifecycle, ServiceContext, ServiceTier } from './lifecycle.js';
|
|
3
|
+
import type { ParticipantManifest } from './manifest.js';
|
|
4
|
+
import type { ServiceAccessPolicy } from './policy.js';
|
|
5
|
+
import type { ServiceToken } from './serviceToken.js';
|
|
6
|
+
/**
|
|
7
|
+
* Contract a service descriptor declares for its public interface.
|
|
8
|
+
*
|
|
9
|
+
* The declaration is descriptive: it names the version and the methods the
|
|
10
|
+
* service promises. The kernel only compares it against hardcore requirements;
|
|
11
|
+
* it does not interpret any method.
|
|
12
|
+
*/
|
|
13
|
+
export interface ServiceContractDeclaration {
|
|
14
|
+
/** Contract version the service implements. */
|
|
15
|
+
readonly version: string;
|
|
16
|
+
/** Method names the service implements for this contract. */
|
|
17
|
+
readonly methods: readonly string[];
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Self-describing registration record for a kernel service.
|
|
21
|
+
*
|
|
22
|
+
* The factory may build a richer internal shape `TInternal`, while `project`
|
|
23
|
+
* narrows that instance to the public `TService` interface for each caller.
|
|
24
|
+
*
|
|
25
|
+
* @typeParam TService - The public interface exposed to callers.
|
|
26
|
+
* @typeParam TInternal - The internal instance type, which must extend `TService`.
|
|
27
|
+
*/
|
|
28
|
+
export interface ServiceDescriptor<TService, TInternal extends TService = TService> {
|
|
29
|
+
/** Token identifying the service. */
|
|
30
|
+
readonly token: ServiceToken<TService>;
|
|
31
|
+
/** Privilege tier the service belongs to. */
|
|
32
|
+
readonly tier: ServiceTier;
|
|
33
|
+
/** Services that must be registered and initialized before this one. */
|
|
34
|
+
readonly dependencies: readonly ServiceToken<unknown>[];
|
|
35
|
+
/** Access control rules applied to every request. */
|
|
36
|
+
readonly accessPolicy?: ServiceAccessPolicy;
|
|
37
|
+
/**
|
|
38
|
+
* Declared contract for the public service interface.
|
|
39
|
+
*
|
|
40
|
+
* Optional for ordinary services. The kernel's fixed hardcore list requires
|
|
41
|
+
* a declared contract on the services it names.
|
|
42
|
+
*/
|
|
43
|
+
readonly contract?: ServiceContractDeclaration;
|
|
44
|
+
/**
|
|
45
|
+
* Declarative manifest: what the participant requests and which exposures
|
|
46
|
+
* it gives, with their scopes and policies.
|
|
47
|
+
*
|
|
48
|
+
* Data only. The kernel admits it at boot without invoking {@link factory}.
|
|
49
|
+
*/
|
|
50
|
+
readonly manifest?: ParticipantManifest;
|
|
51
|
+
/**
|
|
52
|
+
* Builds the service instance.
|
|
53
|
+
*
|
|
54
|
+
* @param context - Context of the service being constructed.
|
|
55
|
+
* @param broker - Mediated access broker for dependency resolution.
|
|
56
|
+
*/
|
|
57
|
+
readonly factory: (context: ServiceContext, broker: IKernelAccessBroker) => TInternal & IServiceLifecycle;
|
|
58
|
+
/**
|
|
59
|
+
* Projects the internal instance into the caller-facing interface.
|
|
60
|
+
*
|
|
61
|
+
* Defaults to returning the instance unchanged when omitted.
|
|
62
|
+
*
|
|
63
|
+
* @param instance - The internal service instance.
|
|
64
|
+
* @param caller - Context of the requesting caller.
|
|
65
|
+
*/
|
|
66
|
+
readonly project?: (instance: TInternal, caller: ServiceContext) => TService;
|
|
67
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A phantom-branded capability token identifying a service within the kernel.
|
|
3
|
+
*
|
|
4
|
+
* The brand is represented by a tuple so the wrapped service interface is
|
|
5
|
+
* preserved invariantly. Consumers must never read `_brand` at runtime; it
|
|
6
|
+
* exists purely to carry `TService` through registration and lookup.
|
|
7
|
+
*
|
|
8
|
+
* @typeParam TService - The public interface exposed by the service.
|
|
9
|
+
*/
|
|
10
|
+
export interface ServiceToken<TService> {
|
|
11
|
+
/** Stable, human-readable identifier used for diagnostics and policies. */
|
|
12
|
+
readonly id: string;
|
|
13
|
+
/** Short explanation of what the service provides. */
|
|
14
|
+
readonly description: string;
|
|
15
|
+
/** Phantom brand preserving `TService` for strict type inference. */
|
|
16
|
+
readonly _brand: readonly [TService];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Creates a service token for the given identifier and description.
|
|
20
|
+
*
|
|
21
|
+
* @typeParam TService - The public interface exposed by the service.
|
|
22
|
+
* @param id - Stable identifier for the service.
|
|
23
|
+
* @param description - Short explanation of what the service provides. When
|
|
24
|
+
* omitted, a description is derived from the identifier.
|
|
25
|
+
* @returns A phantom-branded token bound to `TService`.
|
|
26
|
+
*/
|
|
27
|
+
export declare function createServiceToken<TService>(id: string, description?: string): ServiceToken<TService>;
|
|
28
|
+
/**
|
|
29
|
+
* Extracts the public service interface carried by a service token.
|
|
30
|
+
*
|
|
31
|
+
* Planned: this is a universal type-level helper with no current consumer. It
|
|
32
|
+
* is retained deliberately as part of the token primitive.
|
|
33
|
+
*
|
|
34
|
+
* @typeParam TToken - A {@link ServiceToken} type.
|
|
35
|
+
*/
|
|
36
|
+
export type InferService<TToken> = TToken extends ServiceToken<infer TService> ? TService : never;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a service token for the given identifier and description.
|
|
3
|
+
*
|
|
4
|
+
* @typeParam TService - The public interface exposed by the service.
|
|
5
|
+
* @param id - Stable identifier for the service.
|
|
6
|
+
* @param description - Short explanation of what the service provides. When
|
|
7
|
+
* omitted, a description is derived from the identifier.
|
|
8
|
+
* @returns A phantom-branded token bound to `TService`.
|
|
9
|
+
*/
|
|
10
|
+
export function createServiceToken(id, description = `Service "${id}"`) {
|
|
11
|
+
return {
|
|
12
|
+
id,
|
|
13
|
+
description,
|
|
14
|
+
_brand: [],
|
|
15
|
+
};
|
|
16
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import type { ContextContract, ContextSchema } from '../contracts/contextContract.js';
|
|
2
|
+
import type { OperationResult, PromptDescriptor } from '../contracts/handler.js';
|
|
3
|
+
import type { IExecutionPipeline } from '../contracts/pipeline.js';
|
|
4
|
+
import type { IServiceContainer } from '../contracts/container.js';
|
|
5
|
+
import type { IOperationRegistry } from '../contracts/registry.js';
|
|
6
|
+
import type { ServiceInfo } from '../contracts/accessBroker.js';
|
|
7
|
+
import type { KernelBootOptions, IBrudKernel } from '../contracts/kernel.js';
|
|
8
|
+
import type { IServiceLifecycle, ServiceContext } from '../contracts/lifecycle.js';
|
|
9
|
+
import type { ServiceDescriptor } from '../contracts/serviceDescriptor.js';
|
|
10
|
+
import type { ServiceToken } from '../contracts/serviceToken.js';
|
|
11
|
+
import type { KernelLifecycleState } from './state.js';
|
|
12
|
+
import type { KernelCallAuthority, KernelCallLimits, KernelHostSession, KernelObservation } from '../contracts/callChain.js';
|
|
13
|
+
import { type ChainParticipant } from './callChain.js';
|
|
14
|
+
/**
|
|
15
|
+
* Runs the compiled hardcore boot calls.
|
|
16
|
+
*
|
|
17
|
+
* Called once, after the hardcore partition initializes and before any
|
|
18
|
+
* composed participant is constructed. Returns every admitted participant
|
|
19
|
+
* with the caller the kernel records for it.
|
|
20
|
+
*/
|
|
21
|
+
export type HardcoreBootCall = (instances: readonly {
|
|
22
|
+
readonly tokenId: string;
|
|
23
|
+
readonly instance: IServiceLifecycle;
|
|
24
|
+
}[], authority: KernelCallAuthority) => readonly ChainParticipant[] | void | Promise<readonly ChainParticipant[] | void>;
|
|
25
|
+
/**
|
|
26
|
+
* Planned: the operation dispatch surface is a universal kernel primitive.
|
|
27
|
+
* No production caller drives it yet; it is retained deliberately.
|
|
28
|
+
*/
|
|
29
|
+
export interface KernelExecuteOptions {
|
|
30
|
+
signal?: AbortSignal;
|
|
31
|
+
metadata?: Record<string, unknown>;
|
|
32
|
+
maxCallDepth?: number;
|
|
33
|
+
}
|
|
34
|
+
export interface PromptManifestEntry {
|
|
35
|
+
kind: string;
|
|
36
|
+
promptDescriptor: PromptDescriptor;
|
|
37
|
+
}
|
|
38
|
+
export interface PromptManifest {
|
|
39
|
+
operations: PromptManifestEntry[];
|
|
40
|
+
}
|
|
41
|
+
export declare class BrudKernel implements IBrudKernel {
|
|
42
|
+
readonly services: IServiceContainer;
|
|
43
|
+
readonly operations: IOperationRegistry;
|
|
44
|
+
readonly pipeline: IExecutionPipeline;
|
|
45
|
+
private readonly maxCallDepth;
|
|
46
|
+
private readonly registry;
|
|
47
|
+
private readonly accessBroker;
|
|
48
|
+
private readonly initializedServices;
|
|
49
|
+
private state;
|
|
50
|
+
private runningHooksPending;
|
|
51
|
+
/**
|
|
52
|
+
* The host-supplied options bag, stored once at boot.
|
|
53
|
+
*
|
|
54
|
+
* The kernel treats it as opaque: it is attached unchanged to every service
|
|
55
|
+
* and execution context and is never indexed here.
|
|
56
|
+
*/
|
|
57
|
+
private bootOptions;
|
|
58
|
+
private readonly bootPinner;
|
|
59
|
+
private readonly bootHardcore;
|
|
60
|
+
private readonly contextContract;
|
|
61
|
+
/** The kernel's call chain: origins, callers, limits, and observations. */
|
|
62
|
+
private readonly calls;
|
|
63
|
+
/**
|
|
64
|
+
* Tokens the compiled hardcore list supplies to the boot loader.
|
|
65
|
+
*
|
|
66
|
+
* The engine uses this only to partition the initialization order. It never
|
|
67
|
+
* infers hardcoredness from a descriptor's token or tier.
|
|
68
|
+
*/
|
|
69
|
+
private readonly hardcoreTokens;
|
|
70
|
+
constructor(options?: {
|
|
71
|
+
maxCallDepth?: number;
|
|
72
|
+
bootPinner?: (instances: readonly IServiceLifecycle[]) => Promise<void>;
|
|
73
|
+
bootHardcore?: HardcoreBootCall;
|
|
74
|
+
contextContract?: ContextContract;
|
|
75
|
+
hardcoreTokens?: readonly string[];
|
|
76
|
+
callLimits?: KernelCallLimits;
|
|
77
|
+
});
|
|
78
|
+
/**
|
|
79
|
+
* Runs an operation inside a host-origin call chain.
|
|
80
|
+
*
|
|
81
|
+
* @param session - The host session's declaration.
|
|
82
|
+
* @param operation - Work performed inside the chain.
|
|
83
|
+
*/
|
|
84
|
+
runHostCall<T>(session: KernelHostSession, operation: () => T): T;
|
|
85
|
+
/** Reads the kernel's observation stream. Only the kernel's holder can. */
|
|
86
|
+
readObservations(): readonly KernelObservation[];
|
|
87
|
+
/**
|
|
88
|
+
* Appends one record to the observation stream.
|
|
89
|
+
*
|
|
90
|
+
* Used by the kernel's own boot loader; participants never hold the kernel.
|
|
91
|
+
*/
|
|
92
|
+
recordObservation(source: string, event: string, detail: Readonly<Record<string, unknown>>): void;
|
|
93
|
+
/**
|
|
94
|
+
* The root origin and caller under which the kernel runs one service's
|
|
95
|
+
* lifecycle work.
|
|
96
|
+
*
|
|
97
|
+
* A hardcore service is the kernel's own root primitive and runs in a
|
|
98
|
+
* kernel-origin chain. Every other participant runs in a runtime-origin chain
|
|
99
|
+
* as itself.
|
|
100
|
+
*/
|
|
101
|
+
private frameFor;
|
|
102
|
+
/** Runs one service's lifecycle work inside its own frame. */
|
|
103
|
+
private runFor;
|
|
104
|
+
get lifecycleState(): KernelLifecycleState;
|
|
105
|
+
register<TService, TInternal extends TService = TService>(descriptor: ServiceDescriptor<TService, TInternal>): void;
|
|
106
|
+
boot(options: KernelBootOptions): Promise<void>;
|
|
107
|
+
shutdown(): Promise<void>;
|
|
108
|
+
getContextSchema(): ContextSchema;
|
|
109
|
+
validateContextOptions(options: Readonly<Record<string, unknown>>): void;
|
|
110
|
+
requestAccess<TService>(caller: ServiceContext, token: ServiceToken<TService>): TService;
|
|
111
|
+
hasService(token: ServiceToken<unknown>): boolean;
|
|
112
|
+
listServices(): readonly ServiceInfo[];
|
|
113
|
+
private descriptorMap;
|
|
114
|
+
private rollbackInitialized;
|
|
115
|
+
execute<TInput, TOutput>(kind: string, input: TInput, options?: KernelExecuteOptions): Promise<OperationResult<TOutput>>;
|
|
116
|
+
private createExecutionContext;
|
|
117
|
+
generatePromptManifest(): PromptManifest;
|
|
118
|
+
}
|
|
119
|
+
/** The token of the service whose lifecycle code threw `error`, when the kernel recorded it. */
|
|
120
|
+
export declare function failingServiceOf(error: unknown): string | undefined;
|