@brud/kernel 0.0.1 → 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 +0 -0
- package/README.md +0 -0
- package/dist/index.d.ts +0 -0
- package/dist/index.js +0 -0
- package/dist/serviceModules/events.d.ts +0 -0
- package/dist/serviceModules/events.js +0 -0
- package/dist/serviceModules/exposedApiRegistry.d.ts +0 -0
- package/dist/serviceModules/exposedApiRegistry.js +0 -0
- package/dist/serviceModules/identityRegistry.d.ts +0 -0
- package/dist/serviceModules/identityRegistry.js +0 -0
- package/dist/serviceModules/interception.d.ts +0 -0
- package/dist/serviceModules/interception.js +0 -0
- package/dist/serviceModules/parser.d.ts +0 -0
- package/dist/serviceModules/parser.js +0 -0
- package/dist/serviceModules/router.d.ts +0 -0
- package/dist/serviceModules/router.js +0 -0
- package/dist/serviceModules/wasmCage.d.ts +0 -0
- package/dist/serviceModules/wasmCage.js +0 -0
- package/dist/services/Events/contracts/IEventsService.d.ts +0 -0
- package/dist/services/Events/contracts/IEventsService.js +0 -0
- package/dist/services/Events/contracts/errors.d.ts +0 -0
- package/dist/services/Events/contracts/errors.js +0 -0
- package/dist/services/Events/contracts/index.d.ts +0 -0
- package/dist/services/Events/contracts/index.js +0 -0
- package/dist/services/Events/contracts/tokens.d.ts +0 -0
- package/dist/services/Events/contracts/tokens.js +0 -0
- package/dist/services/Events/descriptor/EventsDescriptor.d.ts +0 -0
- package/dist/services/Events/descriptor/EventsDescriptor.js +0 -0
- package/dist/services/Events/descriptor/tokens.d.ts +0 -0
- package/dist/services/Events/descriptor/tokens.js +0 -0
- package/dist/services/Events/index.d.ts +0 -0
- package/dist/services/Events/index.js +0 -0
- package/dist/services/Events/orchestrator/EventsService.d.ts +0 -0
- package/dist/services/Events/orchestrator/EventsService.js +0 -0
- package/dist/services/Events/orchestrator/index.d.ts +0 -0
- package/dist/services/Events/orchestrator/index.js +0 -0
- package/dist/services/Events/orchestrator/limits.d.ts +0 -0
- package/dist/services/Events/orchestrator/limits.js +0 -0
- package/dist/services/Events/serviceModule.d.ts +0 -0
- package/dist/services/Events/serviceModule.js +0 -0
- package/dist/services/ExposedApiRegistry/contracts/IExposedApiRegistry.d.ts +13 -1
- package/dist/services/ExposedApiRegistry/contracts/IExposedApiRegistry.js +0 -0
- package/dist/services/ExposedApiRegistry/contracts/errors.d.ts +0 -0
- package/dist/services/ExposedApiRegistry/contracts/errors.js +0 -0
- package/dist/services/ExposedApiRegistry/contracts/index.d.ts +1 -1
- package/dist/services/ExposedApiRegistry/contracts/index.js +0 -0
- package/dist/services/ExposedApiRegistry/contracts/policy.d.ts +0 -0
- package/dist/services/ExposedApiRegistry/contracts/policy.js +0 -0
- package/dist/services/ExposedApiRegistry/contracts/registrant.d.ts +0 -0
- package/dist/services/ExposedApiRegistry/contracts/registrant.js +0 -0
- package/dist/services/ExposedApiRegistry/contracts/types.d.ts +21 -0
- package/dist/services/ExposedApiRegistry/contracts/types.js +0 -0
- package/dist/services/ExposedApiRegistry/descriptor/ExposedApiRegistryDescriptor.d.ts +2 -2
- package/dist/services/ExposedApiRegistry/descriptor/ExposedApiRegistryDescriptor.js +2 -2
- package/dist/services/ExposedApiRegistry/descriptor/tokens.d.ts +0 -0
- package/dist/services/ExposedApiRegistry/descriptor/tokens.js +0 -0
- package/dist/services/ExposedApiRegistry/index.d.ts +0 -0
- package/dist/services/ExposedApiRegistry/index.js +0 -0
- package/dist/services/ExposedApiRegistry/orchestrator/ExposedApiRegistryService.d.ts +9 -2
- package/dist/services/ExposedApiRegistry/orchestrator/ExposedApiRegistryService.js +50 -5
- package/dist/services/ExposedApiRegistry/orchestrator/index.d.ts +0 -0
- package/dist/services/ExposedApiRegistry/orchestrator/index.js +0 -0
- package/dist/services/ExposedApiRegistry/serviceModule.d.ts +0 -0
- package/dist/services/ExposedApiRegistry/serviceModule.js +0 -0
- package/dist/services/ExposedApiRegistry/storage/protection.d.ts +0 -0
- package/dist/services/ExposedApiRegistry/storage/protection.js +0 -0
- package/dist/services/ExposedApiRegistry/storage/scopeRecord.d.ts +0 -0
- package/dist/services/ExposedApiRegistry/storage/scopeRecord.js +0 -0
- package/dist/services/IdentityRegistry/contracts/errors.d.ts +0 -0
- package/dist/services/IdentityRegistry/contracts/errors.js +0 -0
- package/dist/services/IdentityRegistry/contracts/index.d.ts +0 -0
- package/dist/services/IdentityRegistry/contracts/index.js +0 -0
- package/dist/services/IdentityRegistry/contracts/types.d.ts +0 -0
- package/dist/services/IdentityRegistry/contracts/types.js +0 -0
- package/dist/services/IdentityRegistry/descriptor/descriptor.d.ts +0 -0
- package/dist/services/IdentityRegistry/descriptor/descriptor.js +0 -0
- package/dist/services/IdentityRegistry/descriptor/tokens.d.ts +0 -0
- package/dist/services/IdentityRegistry/descriptor/tokens.js +0 -0
- package/dist/services/IdentityRegistry/index.d.ts +0 -0
- package/dist/services/IdentityRegistry/index.js +0 -0
- package/dist/services/IdentityRegistry/orchestrator/IdentityRegistryService.d.ts +0 -0
- package/dist/services/IdentityRegistry/orchestrator/IdentityRegistryService.js +0 -0
- package/dist/services/IdentityRegistry/serviceModule.d.ts +0 -0
- package/dist/services/IdentityRegistry/serviceModule.js +0 -0
- package/dist/services/IdentityRegistry/storage/registryDocument.d.ts +0 -0
- package/dist/services/IdentityRegistry/storage/registryDocument.js +0 -0
- package/dist/services/Interception/contracts/IInterceptionService.d.ts +91 -1
- package/dist/services/Interception/contracts/IInterceptionService.js +12 -1
- package/dist/services/Interception/contracts/errors.d.ts +0 -0
- package/dist/services/Interception/contracts/errors.js +0 -0
- package/dist/services/Interception/contracts/index.d.ts +0 -0
- package/dist/services/Interception/contracts/index.js +0 -0
- package/dist/services/Interception/contracts/tokens.d.ts +0 -0
- package/dist/services/Interception/contracts/tokens.js +0 -0
- package/dist/services/Interception/descriptor/InterceptionDescriptor.d.ts +1 -1
- package/dist/services/Interception/descriptor/InterceptionDescriptor.js +2 -1
- package/dist/services/Interception/descriptor/tokens.d.ts +0 -0
- package/dist/services/Interception/descriptor/tokens.js +0 -0
- package/dist/services/Interception/index.d.ts +0 -0
- package/dist/services/Interception/index.js +0 -0
- package/dist/services/Interception/orchestrator/InterceptionService.d.ts +9 -1
- package/dist/services/Interception/orchestrator/InterceptionService.js +167 -4
- package/dist/services/Interception/orchestrator/index.d.ts +0 -0
- package/dist/services/Interception/orchestrator/index.js +0 -0
- package/dist/services/Interception/serviceModule.d.ts +0 -0
- package/dist/services/Interception/serviceModule.js +0 -0
- package/dist/services/Parser/contracts/IParserService.d.ts +0 -0
- package/dist/services/Parser/contracts/IParserService.js +0 -0
- package/dist/services/Parser/contracts/errors.d.ts +0 -0
- package/dist/services/Parser/contracts/errors.js +0 -0
- package/dist/services/Parser/contracts/index.d.ts +0 -0
- package/dist/services/Parser/contracts/index.js +0 -0
- package/dist/services/Parser/contracts/types.d.ts +0 -0
- package/dist/services/Parser/contracts/types.js +0 -0
- package/dist/services/Parser/descriptor/ParserDescriptor.d.ts +0 -0
- package/dist/services/Parser/descriptor/ParserDescriptor.js +0 -0
- package/dist/services/Parser/descriptor/tokens.d.ts +0 -0
- package/dist/services/Parser/descriptor/tokens.js +0 -0
- package/dist/services/Parser/index.d.ts +0 -0
- package/dist/services/Parser/index.js +0 -0
- package/dist/services/Parser/orchestrator/ParserService.d.ts +0 -0
- package/dist/services/Parser/orchestrator/ParserService.js +0 -0
- package/dist/services/Parser/orchestrator/index.d.ts +0 -0
- package/dist/services/Parser/orchestrator/index.js +0 -0
- package/dist/services/Parser/parser/indexSynthesis.d.ts +0 -0
- package/dist/services/Parser/parser/indexSynthesis.js +0 -0
- package/dist/services/Parser/parser/parameters.d.ts +0 -0
- package/dist/services/Parser/parser/parameters.js +0 -0
- package/dist/services/Parser/parser/scanner.d.ts +0 -0
- package/dist/services/Parser/parser/scanner.js +0 -0
- package/dist/services/Parser/parser/syntax.d.ts +0 -0
- package/dist/services/Parser/parser/syntax.js +0 -0
- package/dist/services/Parser/serviceModule.d.ts +0 -0
- package/dist/services/Parser/serviceModule.js +0 -0
- package/dist/services/Router/bootOptions.d.ts +0 -0
- package/dist/services/Router/bootOptions.js +0 -0
- package/dist/services/Router/contracts/IRouterService.d.ts +1 -1
- package/dist/services/Router/contracts/IRouterService.js +0 -0
- package/dist/services/Router/contracts/caller.d.ts +0 -0
- package/dist/services/Router/contracts/caller.js +0 -0
- package/dist/services/Router/contracts/errors.d.ts +12 -1
- package/dist/services/Router/contracts/errors.js +15 -0
- package/dist/services/Router/contracts/index.d.ts +2 -2
- package/dist/services/Router/contracts/index.js +1 -1
- package/dist/services/Router/contracts/kind.d.ts +0 -0
- package/dist/services/Router/contracts/kind.js +0 -0
- package/dist/services/Router/contracts/registrant.d.ts +0 -0
- package/dist/services/Router/contracts/registrant.js +0 -0
- package/dist/services/Router/contracts/types.d.ts +28 -8
- package/dist/services/Router/contracts/types.js +0 -0
- package/dist/services/Router/descriptor/RouterDescriptor.d.ts +0 -0
- package/dist/services/Router/descriptor/RouterDescriptor.js +1 -1
- package/dist/services/Router/descriptor/tokens.d.ts +0 -0
- package/dist/services/Router/descriptor/tokens.js +0 -0
- package/dist/services/Router/index.d.ts +0 -0
- package/dist/services/Router/index.js +0 -0
- package/dist/services/Router/orchestrator/RouterService.d.ts +22 -3
- package/dist/services/Router/orchestrator/RouterService.js +131 -6
- package/dist/services/Router/orchestrator/index.d.ts +0 -0
- package/dist/services/Router/orchestrator/index.js +0 -0
- package/dist/services/Router/serviceModule.d.ts +0 -0
- package/dist/services/Router/serviceModule.js +0 -0
- package/dist/services/WasmCage/index.d.ts +0 -0
- package/dist/services/WasmCage/index.js +0 -0
- package/dist/services/WasmCage/scripts/prepin.d.ts +0 -0
- package/dist/services/WasmCage/scripts/prepin.js +0 -0
- package/dist/services/WasmCage/serviceModule.d.ts +0 -0
- package/dist/services/WasmCage/serviceModule.js +0 -0
- package/dist/services/WasmCage/src/caged.d.ts +19 -2
- package/dist/services/WasmCage/src/caged.js +85 -6
- package/dist/services/WasmCage/src/descriptor.d.ts +0 -0
- package/dist/services/WasmCage/src/descriptor.js +0 -0
- package/dist/services/WasmCage/src/native.d.ts +0 -0
- package/dist/services/WasmCage/src/native.js +0 -0
- package/dist/services/WasmCage/src/nativeDigests.d.ts +0 -0
- package/dist/services/WasmCage/src/nativeDigests.js +5 -5
- package/dist/services/WasmCage/src/package.d.ts +0 -0
- package/dist/services/WasmCage/src/package.js +0 -0
- package/dist/services/shared/canonicalJson.d.ts +0 -0
- package/dist/services/shared/canonicalJson.js +0 -0
- package/dist/services/shared/documentStore.d.ts +0 -0
- package/dist/services/shared/documentStore.js +0 -0
- package/dist/src/bootstrap/bootKernelInternal.d.ts +4 -3
- package/dist/src/bootstrap/bootKernelInternal.js +284 -71
- package/dist/src/bootstrap/bootTypes.d.ts +25 -1
- package/dist/src/bootstrap/bootTypes.js +0 -0
- package/dist/src/bootstrap/config/index.d.ts +0 -0
- package/dist/src/bootstrap/config/index.js +0 -0
- package/dist/src/bootstrap/config/integrity.d.ts +11 -0
- package/dist/src/bootstrap/config/integrity.js +13 -0
- package/dist/src/bootstrap/config/parse.d.ts +0 -0
- package/dist/src/bootstrap/config/parse.js +0 -0
- package/dist/src/bootstrap/config/pathWriteGuard.d.ts +0 -0
- package/dist/src/bootstrap/config/pathWriteGuard.js +0 -0
- package/dist/src/bootstrap/config/types.d.ts +1 -1
- package/dist/src/bootstrap/config/types.js +0 -0
- package/dist/src/bootstrap/hardcore.d.ts +0 -0
- package/dist/src/bootstrap/hardcore.js +0 -0
- package/dist/src/bootstrap/hardcoreServices.d.ts +0 -0
- package/dist/src/bootstrap/hardcoreServices.js +14 -14
- package/dist/src/bootstrap/index.d.ts +6 -1
- package/dist/src/bootstrap/index.js +2 -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 +0 -0
- package/dist/src/bootstrap/packageRequirements.js +0 -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 +0 -0
- package/dist/src/contracts/accessBroker.js +0 -0
- package/dist/src/contracts/brudOperation.d.ts +0 -0
- package/dist/src/contracts/brudOperation.js +0 -0
- package/dist/src/contracts/callChain.d.ts +0 -0
- package/dist/src/contracts/callChain.js +0 -0
- package/dist/src/contracts/capability.d.ts +0 -0
- package/dist/src/contracts/capability.js +0 -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 +0 -0
- package/dist/src/contracts/container.js +0 -0
- package/dist/src/contracts/context.d.ts +0 -0
- package/dist/src/contracts/context.js +0 -0
- package/dist/src/contracts/contextContract.d.ts +11 -8
- package/dist/src/contracts/contextContract.js +21 -32
- package/dist/src/contracts/dispatchView.d.ts +3 -3
- package/dist/src/contracts/dispatchView.js +0 -0
- package/dist/src/contracts/handler.d.ts +0 -7
- package/dist/src/contracts/handler.js +0 -0
- package/dist/src/contracts/index.d.ts +2 -1
- package/dist/src/contracts/index.js +1 -0
- package/dist/src/contracts/kernel.d.ts +0 -0
- package/dist/src/contracts/kernel.js +0 -0
- package/dist/src/contracts/lifecycle.d.ts +0 -0
- package/dist/src/contracts/lifecycle.js +0 -0
- package/dist/src/contracts/manifest.d.ts +35 -0
- package/dist/src/contracts/manifest.js +62 -23
- package/dist/src/contracts/pipeline.d.ts +0 -0
- package/dist/src/contracts/pipeline.js +0 -0
- package/dist/src/contracts/policy.d.ts +0 -0
- package/dist/src/contracts/policy.js +0 -0
- package/dist/src/contracts/registry.d.ts +0 -0
- package/dist/src/contracts/registry.js +0 -0
- package/dist/src/contracts/serviceDescriptor.d.ts +0 -0
- package/dist/src/contracts/serviceDescriptor.js +0 -0
- package/dist/src/contracts/serviceToken.d.ts +0 -0
- package/dist/src/contracts/serviceToken.js +0 -0
- package/dist/src/engine/BrudKernel.d.ts +2 -0
- package/dist/src/engine/BrudKernel.js +35 -6
- package/dist/src/engine/ExecutionPipeline.d.ts +0 -0
- package/dist/src/engine/ExecutionPipeline.js +0 -0
- package/dist/src/engine/KernelAccessBroker.d.ts +0 -0
- package/dist/src/engine/KernelAccessBroker.js +0 -0
- package/dist/src/engine/KernelRegistry.d.ts +0 -0
- package/dist/src/engine/KernelRegistry.js +0 -0
- package/dist/src/engine/OperationRegistry.d.ts +0 -0
- package/dist/src/engine/OperationRegistry.js +0 -0
- package/dist/src/engine/ServiceContainer.d.ts +0 -0
- package/dist/src/engine/ServiceContainer.js +0 -0
- package/dist/src/engine/callChain.d.ts +0 -0
- package/dist/src/engine/callChain.js +5 -10
- package/dist/src/engine/dag.d.ts +0 -0
- package/dist/src/engine/dag.js +0 -0
- package/dist/src/engine/errors.d.ts +0 -0
- package/dist/src/engine/errors.js +0 -0
- package/dist/src/engine/index.d.ts +0 -0
- package/dist/src/engine/index.js +0 -0
- package/dist/src/engine/state.d.ts +0 -0
- package/dist/src/engine/state.js +0 -0
- package/dist/src/validation/jsonSchema/compile.d.ts +0 -0
- package/dist/src/validation/jsonSchema/compile.js +0 -0
- package/dist/src/validation/jsonSchema/index.d.ts +0 -0
- package/dist/src/validation/jsonSchema/index.js +0 -0
- package/dist/src/validation/jsonSchema/jsonValue.d.ts +0 -0
- package/dist/src/validation/jsonSchema/jsonValue.js +0 -0
- package/dist/src/validation/jsonSchema/pattern.d.ts +0 -0
- package/dist/src/validation/jsonSchema/pattern.js +0 -0
- package/dist/src/validation/jsonSchema/types.d.ts +0 -0
- package/dist/src/validation/jsonSchema/types.js +0 -0
- package/package.json +1 -1
- 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
|
@@ -2,7 +2,12 @@ export { bootKernel, createDeferredKernel, } from './bootKernelInternal.js';
|
|
|
2
2
|
export { HardcoreIdentityError, HardcoreServiceError, buildHardcoreBootEntries, computePackageContentHash, hashPackageFile, invokeHardcoreBootHooks, verifyHardcoreServices, } from './hardcore.js';
|
|
3
3
|
export type { ComposedServiceDescriptor, HardcoreBootContext, HardcoreBootEntry, HardcoreBootHook, HardcoreCheck, HardcoreContract, HardcoreInitializedInstance, HardcoreService, } from './hardcore.js';
|
|
4
4
|
export { HARDCORE_SERVICES, isHardcoreToken, } from './hardcoreServices.js';
|
|
5
|
-
export
|
|
5
|
+
export { KernelReloadError } from './reload.js';
|
|
6
|
+
export { checkSeal, createSeal } from './seal.js';
|
|
7
|
+
export type { CreatedSeal, SealCheck } from './seal.js';
|
|
8
|
+
export type { AbandonedParticipant } from './loaded.js';
|
|
9
|
+
export type { ReloadOptions, ReloadableKernel } from './reload.js';
|
|
10
|
+
export type { BootKernelOptions, ComposeKernelOptions, KernelServiceModuleContext, SealReference, ServiceModule, } from './bootTypes.js';
|
|
6
11
|
export type { BrudConfig, BrudConfigEntry, BrudConfigErrorCode, } from './config/types.js';
|
|
7
12
|
export { BrudConfigError } from './config/types.js';
|
|
8
13
|
export { parseBrudConfig } from './config/parse.js';
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export { bootKernel, createDeferredKernel, } from './bootKernelInternal.js';
|
|
2
2
|
export { HardcoreIdentityError, HardcoreServiceError, buildHardcoreBootEntries, computePackageContentHash, hashPackageFile, invokeHardcoreBootHooks, verifyHardcoreServices, } from './hardcore.js';
|
|
3
3
|
export { HARDCORE_SERVICES, isHardcoreToken, } from './hardcoreServices.js';
|
|
4
|
+
export { KernelReloadError } from './reload.js';
|
|
5
|
+
export { checkSeal, createSeal } from './seal.js';
|
|
4
6
|
export { BrudConfigError } from './config/types.js';
|
|
5
7
|
export { parseBrudConfig } from './config/parse.js';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/** A loaded participant the kernel left out, and why. */
|
|
2
|
+
export interface AbandonedParticipant {
|
|
3
|
+
/** The path the config declared for it. */
|
|
4
|
+
readonly path: string;
|
|
5
|
+
/** Its service token, when it got far enough to have one. */
|
|
6
|
+
readonly participant?: string;
|
|
7
|
+
/** The error code that left it out, when the failure had one. */
|
|
8
|
+
readonly code?: string;
|
|
9
|
+
/** What was wrong, in plain words. */
|
|
10
|
+
readonly reason: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* One or more loaded participants cannot be part of this boot.
|
|
14
|
+
*
|
|
15
|
+
* The boot driver catches it, leaves them out, and tries again. It is thrown
|
|
16
|
+
* only for loaded participants: a failure in a hardcore or composed
|
|
17
|
+
* participant is never wrapped in it.
|
|
18
|
+
*/
|
|
19
|
+
export declare class LoadedParticipantFailure extends Error {
|
|
20
|
+
readonly participants: readonly AbandonedParticipant[];
|
|
21
|
+
constructor(participants: readonly AbandonedParticipant[]);
|
|
22
|
+
}
|
|
23
|
+
/** Describes a failure as an abandoned loaded participant. */
|
|
24
|
+
export declare function abandonment(path: string, error: unknown, participant?: string): AbandonedParticipant;
|
|
25
|
+
/**
|
|
26
|
+
* The service token an error blames: the participant the error itself names
|
|
27
|
+
* (a check one participant's declaration failed), else the service whose
|
|
28
|
+
* lifecycle code threw it. Looks through `cause`.
|
|
29
|
+
*/
|
|
30
|
+
export declare function culpritOf(error: unknown): string | undefined;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { failingServiceOf } from '../engine/BrudKernel.js';
|
|
2
|
+
/**
|
|
3
|
+
* One or more loaded participants cannot be part of this boot.
|
|
4
|
+
*
|
|
5
|
+
* The boot driver catches it, leaves them out, and tries again. It is thrown
|
|
6
|
+
* only for loaded participants: a failure in a hardcore or composed
|
|
7
|
+
* participant is never wrapped in it.
|
|
8
|
+
*/
|
|
9
|
+
export class LoadedParticipantFailure extends Error {
|
|
10
|
+
participants;
|
|
11
|
+
constructor(participants) {
|
|
12
|
+
super(`Loaded participant(s) cannot start: ${participants.map((entry) => `${entry.path} (${entry.reason})`).join('; ')}`);
|
|
13
|
+
this.name = 'LoadedParticipantFailure';
|
|
14
|
+
this.participants = participants;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
/** Describes a failure as an abandoned loaded participant. */
|
|
18
|
+
export function abandonment(path, error, participant) {
|
|
19
|
+
const code = error !== null && typeof error === 'object' ? error.code : undefined;
|
|
20
|
+
return {
|
|
21
|
+
path,
|
|
22
|
+
...(participant === undefined ? {} : { participant }),
|
|
23
|
+
...(typeof code === 'string' ? { code } : {}),
|
|
24
|
+
reason: error instanceof Error ? error.message : String(error),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The service token an error blames: the participant the error itself names
|
|
29
|
+
* (a check one participant's declaration failed), else the service whose
|
|
30
|
+
* lifecycle code threw it. Looks through `cause`.
|
|
31
|
+
*/
|
|
32
|
+
export function culpritOf(error) {
|
|
33
|
+
for (let current = error, depth = 0; current !== null && typeof current === 'object' && depth < 5; depth += 1) {
|
|
34
|
+
const named = current.participant;
|
|
35
|
+
if (typeof named === 'string') {
|
|
36
|
+
return named;
|
|
37
|
+
}
|
|
38
|
+
const failing = failingServiceOf(current);
|
|
39
|
+
if (failing !== undefined) {
|
|
40
|
+
return failing;
|
|
41
|
+
}
|
|
42
|
+
current = current.cause;
|
|
43
|
+
}
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { BrudKernel } from '../engine/BrudKernel.js';
|
|
2
|
+
import { type BrudConfig } from './config/types.js';
|
|
3
|
+
import type { AbandonedParticipant } from './loaded.js';
|
|
4
|
+
/** Options for {@link ReloadableKernel.reload}. */
|
|
5
|
+
export interface ReloadOptions {
|
|
6
|
+
/** Config to load. Defaults to the path the running kernel booted from. */
|
|
7
|
+
readonly configPath?: string;
|
|
8
|
+
}
|
|
9
|
+
/** A kernel the host can reload. Only the host holds it; no participant receives it. */
|
|
10
|
+
export type ReloadableKernel = BrudKernel & {
|
|
11
|
+
/** The loaded participants this kernel left out when it booted, each with the reason. Empty when none. */
|
|
12
|
+
readonly abandoned: readonly AbandonedParticipant[];
|
|
13
|
+
/**
|
|
14
|
+
* Replaces the running composition with the one in a config file: it
|
|
15
|
+
* checks the new config against the frozen part, composes it, shuts this
|
|
16
|
+
* kernel down, and boots the new one with the same options.
|
|
17
|
+
*
|
|
18
|
+
* Everything outside the frozen part may change: which loaded participants
|
|
19
|
+
* exist, their packages and their options. The frozen part is every official
|
|
20
|
+
* entry in order, and the exposure owners; changing it needs a rebuild. A
|
|
21
|
+
* loaded participant that cannot start is left out and named in
|
|
22
|
+
* `abandoned` of the returned kernel; it never stops the reload.
|
|
23
|
+
*
|
|
24
|
+
* @returns The new running kernel. This one is disposed.
|
|
25
|
+
* @throws {BrudConfigError} `CONFIG_RELOAD_FROZEN` when the frozen part
|
|
26
|
+
* differs, or any config error the new composition raises. Nothing has
|
|
27
|
+
* been stopped in either case.
|
|
28
|
+
* @throws {KernelReloadError} When the new kernel failed to boot for a reason
|
|
29
|
+
* in the build, not in a loaded participant, after this one was stopped.
|
|
30
|
+
* @throws {LifecycleStateError} When this kernel is not running.
|
|
31
|
+
*/
|
|
32
|
+
reload(options?: ReloadOptions): Promise<ReloadableKernel>;
|
|
33
|
+
};
|
|
34
|
+
/** The new composition failed to boot after the running kernel was stopped. */
|
|
35
|
+
export declare class KernelReloadError extends Error {
|
|
36
|
+
readonly code: "KERNEL_RELOAD_FAILED";
|
|
37
|
+
constructor(configPath: string, cause: unknown);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Refuses a config whose frozen part differs from the booted one.
|
|
41
|
+
*
|
|
42
|
+
* @throws {BrudConfigError} `CONFIG_RELOAD_FROZEN`, naming every difference.
|
|
43
|
+
*/
|
|
44
|
+
export declare function refuseFrozenChange(booted: BrudConfig, next: BrudConfig, configPath: string, sealed?: ReadonlySet<string>): void;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { BrudConfigError } from './config/types.js';
|
|
2
|
+
/** The new composition failed to boot after the running kernel was stopped. */
|
|
3
|
+
export class KernelReloadError extends Error {
|
|
4
|
+
code = 'KERNEL_RELOAD_FAILED';
|
|
5
|
+
constructor(configPath, cause) {
|
|
6
|
+
super(`Reload failed: the previous kernel was stopped and the composition in "${configPath}" did not boot: ${cause instanceof Error ? cause.message : String(cause)}`, { cause });
|
|
7
|
+
this.name = 'KernelReloadError';
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
/** What a reload may not change: official entries in order, and exposure owners. */
|
|
11
|
+
function frozenPart(config, sealed) {
|
|
12
|
+
return {
|
|
13
|
+
official: config.services.filter((entry) => entry.official === true && (sealed === undefined || sealed.has(entry.path))).map((entry) => entry.path),
|
|
14
|
+
owners: Object.fromEntries(Object.entries(config.exposureOwners ?? {}).sort(([a], [b]) => a.localeCompare(b))),
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Refuses a config whose frozen part differs from the booted one.
|
|
19
|
+
*
|
|
20
|
+
* @throws {BrudConfigError} `CONFIG_RELOAD_FROZEN`, naming every difference.
|
|
21
|
+
*/
|
|
22
|
+
export function refuseFrozenChange(booted, next, configPath, sealed) {
|
|
23
|
+
const before = frozenPart(booted, sealed);
|
|
24
|
+
const after = frozenPart(next, sealed);
|
|
25
|
+
const problems = [];
|
|
26
|
+
for (const path of before.official) {
|
|
27
|
+
if (!after.official.includes(path)) {
|
|
28
|
+
problems.push(`official participant "${path}" was removed or is no longer official`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
for (const path of after.official) {
|
|
32
|
+
if (!before.official.includes(path)) {
|
|
33
|
+
problems.push(`"${path}" is declared official but was not official at boot`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (problems.length === 0 && before.official.join('\n') !== after.official.join('\n')) {
|
|
37
|
+
problems.push('the order of the official participants changed');
|
|
38
|
+
}
|
|
39
|
+
if (JSON.stringify(before.owners) !== JSON.stringify(after.owners)) {
|
|
40
|
+
problems.push('the exposure owners changed');
|
|
41
|
+
}
|
|
42
|
+
if (problems.length > 0) {
|
|
43
|
+
throw new BrudConfigError('CONFIG_RELOAD_FROZEN', `A reload cannot change what the build froze (${problems.join('; ')}). Rebuild to change official participants or exposure owners.`, configPath);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { SealReference } from './bootTypes.js';
|
|
2
|
+
import { type BrudConfig } from './config/types.js';
|
|
3
|
+
/** A generated seal and its digest. */
|
|
4
|
+
export interface CreatedSeal {
|
|
5
|
+
/** The text to write to the seal file. */
|
|
6
|
+
readonly text: string;
|
|
7
|
+
/** SHA-256 hex digest of `text`: the value the built product passes at boot. */
|
|
8
|
+
readonly digest: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Generates the seal for the official participants a config declares.
|
|
12
|
+
*
|
|
13
|
+
* A builder runs this once per release, after the build is final.
|
|
14
|
+
*
|
|
15
|
+
* @param configPath - The composition's config.
|
|
16
|
+
*/
|
|
17
|
+
export declare function createSeal(configPath: string): CreatedSeal;
|
|
18
|
+
/** What a seal says about a config. */
|
|
19
|
+
export interface SealCheck {
|
|
20
|
+
/** Official entries the build did not seal. They are not part of the build and are left out. */
|
|
21
|
+
readonly unsealed: ReadonlySet<string>;
|
|
22
|
+
/** Paths the build sealed. */
|
|
23
|
+
readonly sealed: ReadonlySet<string>;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Checks a config against the build seal.
|
|
27
|
+
*
|
|
28
|
+
* @throws {BrudConfigError} `SEAL_MISMATCH` when the seal file is not the one
|
|
29
|
+
* the built product holds the digest of; `SEAL_VIOLATION` when a sealed
|
|
30
|
+
* participant is missing, out of order, or its content changed.
|
|
31
|
+
*/
|
|
32
|
+
export declare function checkSeal(seal: SealReference, config: BrudConfig, configPath: string): SealCheck;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
3
|
+
import { createRequire } from 'node:module';
|
|
4
|
+
import { dirname, join, parse as parsePath } from 'node:path';
|
|
5
|
+
import { resolveModuleId } from './bootKernelInternal.js';
|
|
6
|
+
import { computePackageContentHash, hashPackageFile } from './hardcore.js';
|
|
7
|
+
import { parseBrudConfig } from './config/parse.js';
|
|
8
|
+
import { BrudConfigError } from './config/types.js';
|
|
9
|
+
const digestOf = (text) => createHash('sha256').update(text, 'utf8').digest('hex');
|
|
10
|
+
/** Finds the file a bare package specifier names, looking through `node_modules` folders above the config. */
|
|
11
|
+
function resolveSpecifier(specifier, configPath) {
|
|
12
|
+
try {
|
|
13
|
+
return createRequire(configPath).resolve(specifier);
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
for (let dir = dirname(configPath);; dir = dirname(dir)) {
|
|
17
|
+
const candidate = join(dir, 'node_modules', specifier);
|
|
18
|
+
if (existsSync(candidate) && parsePath(candidate).ext !== '') {
|
|
19
|
+
return candidate;
|
|
20
|
+
}
|
|
21
|
+
if (dirname(dir) === dir) {
|
|
22
|
+
throw new BrudConfigError('MODULE_RESOLVE', `Cannot seal "${specifier}": it does not resolve to a file. Declare the file path.`, configPath);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/** The content hash a seal records for one participant. */
|
|
28
|
+
function sealHash(declared, configPath) {
|
|
29
|
+
const resolved = declared.startsWith('.') || declared.startsWith('/') || declared.startsWith('file:') || declared.startsWith('kernel:')
|
|
30
|
+
? resolveModuleId(declared, configPath)
|
|
31
|
+
: resolveSpecifier(declared, configPath);
|
|
32
|
+
if (!resolved.endsWith('.json')) {
|
|
33
|
+
return computePackageContentHash(resolved);
|
|
34
|
+
}
|
|
35
|
+
// A participant package: the package file, its module, and the native build it may ship.
|
|
36
|
+
const dir = dirname(resolved);
|
|
37
|
+
const manifest = JSON.parse(readFileSync(resolved, 'utf8'));
|
|
38
|
+
const parts = [hashPackageFile(resolved)];
|
|
39
|
+
if (typeof manifest.cage?.module === 'string') {
|
|
40
|
+
parts.push(hashPackageFile(join(dir, manifest.cage.module)));
|
|
41
|
+
}
|
|
42
|
+
if (typeof manifest.native === 'string') {
|
|
43
|
+
parts.push(computePackageContentHash(join(dir, manifest.native)));
|
|
44
|
+
}
|
|
45
|
+
return digestOf(parts.join('\n'));
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Generates the seal for the official participants a config declares.
|
|
49
|
+
*
|
|
50
|
+
* A builder runs this once per release, after the build is final.
|
|
51
|
+
*
|
|
52
|
+
* @param configPath - The composition's config.
|
|
53
|
+
*/
|
|
54
|
+
export function createSeal(configPath) {
|
|
55
|
+
const config = parseBrudConfig(readFileSync(configPath, 'utf8'), configPath);
|
|
56
|
+
const participants = config.services
|
|
57
|
+
.filter((entry) => entry.official === true)
|
|
58
|
+
.map((entry) => (entry.path.startsWith('kernel:') ? { path: entry.path } : { path: entry.path, sha256: sealHash(entry.path, configPath) }));
|
|
59
|
+
const text = `${JSON.stringify({ format: 1, participants }, null, 2)}\n`;
|
|
60
|
+
return { text, digest: digestOf(text) };
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Checks a config against the build seal.
|
|
64
|
+
*
|
|
65
|
+
* @throws {BrudConfigError} `SEAL_MISMATCH` when the seal file is not the one
|
|
66
|
+
* the built product holds the digest of; `SEAL_VIOLATION` when a sealed
|
|
67
|
+
* participant is missing, out of order, or its content changed.
|
|
68
|
+
*/
|
|
69
|
+
export function checkSeal(seal, config, configPath) {
|
|
70
|
+
let text;
|
|
71
|
+
try {
|
|
72
|
+
text = readFileSync(seal.path, 'utf8');
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
throw new BrudConfigError('SEAL_MISMATCH', `Cannot read the build seal "${seal.path}": ${error instanceof Error ? error.message : String(error)}`, configPath);
|
|
76
|
+
}
|
|
77
|
+
if (digestOf(text) !== seal.digest) {
|
|
78
|
+
throw new BrudConfigError('SEAL_MISMATCH', `The build seal "${seal.path}" is not the one this build was sealed with. Rebuild to change what the build ships.`, configPath);
|
|
79
|
+
}
|
|
80
|
+
const document = JSON.parse(text);
|
|
81
|
+
const sealed = new Set(document.participants.map((entry) => entry.path));
|
|
82
|
+
const official = config.services.filter((entry) => entry.official === true && sealed.has(entry.path));
|
|
83
|
+
const problems = [];
|
|
84
|
+
if (official.map((entry) => entry.path).join('\n') !== document.participants.map((entry) => entry.path).join('\n')) {
|
|
85
|
+
problems.push('the sealed participants are missing, repeated or out of order in the config');
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
for (const entry of document.participants) {
|
|
89
|
+
if (entry.sha256 !== undefined && sealHash(entry.path, configPath) !== entry.sha256) {
|
|
90
|
+
problems.push(`"${entry.path}" no longer matches the content the build sealed`);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if (problems.length > 0) {
|
|
95
|
+
throw new BrudConfigError('SEAL_VIOLATION', `The composition does not match its build seal: ${problems.join('; ')}.`, configPath);
|
|
96
|
+
}
|
|
97
|
+
return {
|
|
98
|
+
sealed,
|
|
99
|
+
unsealed: new Set(config.services.filter((entry) => entry.official === true && !sealed.has(entry.path)).map((entry) => entry.path)),
|
|
100
|
+
};
|
|
101
|
+
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one shape in which a caller's capabilities reach a participant.
|
|
3
|
+
*
|
|
4
|
+
* A caller record is created once and passed by reference to every giver that
|
|
5
|
+
* is shown the caller. A plain `Set` cannot be that shape: freezing a Set does
|
|
6
|
+
* not stop `add`, `delete` or `clear`, and `Set.prototype.add.call(set, x)`
|
|
7
|
+
* works on any Set. A giver could then grant any caller it can see
|
|
8
|
+
* capabilities the kernel never granted. This view holds a private copy,
|
|
9
|
+
* offers only the read side of a Set, and has no mutator to reach.
|
|
10
|
+
*/
|
|
11
|
+
export declare function createCapabilitySet(values: Iterable<string>): ReadonlySet<string>;
|
|
12
|
+
/** Reports whether a value is a capability view made by {@link createCapabilitySet}. */
|
|
13
|
+
export declare function isCapabilitySet(value: unknown): value is ReadonlySet<string>;
|
|
14
|
+
/**
|
|
15
|
+
* Copies a value for a boundary that carries only plain JSON, replacing every
|
|
16
|
+
* capability view in it with its sorted array. Everything else is left as it
|
|
17
|
+
* is, so a boundary's own plain-value check still refuses what is not plain.
|
|
18
|
+
*
|
|
19
|
+
* @param value - The value to carry across.
|
|
20
|
+
*/
|
|
21
|
+
export declare function withPlainCapabilities(value: unknown, depth?: number): unknown;
|
|
22
|
+
/** The capability view of a caller that holds none. */
|
|
23
|
+
export declare const NO_CAPABILITIES: ReadonlySet<string>;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one shape in which a caller's capabilities reach a participant.
|
|
3
|
+
*
|
|
4
|
+
* A caller record is created once and passed by reference to every giver that
|
|
5
|
+
* is shown the caller. A plain `Set` cannot be that shape: freezing a Set does
|
|
6
|
+
* not stop `add`, `delete` or `clear`, and `Set.prototype.add.call(set, x)`
|
|
7
|
+
* works on any Set. A giver could then grant any caller it can see
|
|
8
|
+
* capabilities the kernel never granted. This view holds a private copy,
|
|
9
|
+
* offers only the read side of a Set, and has no mutator to reach.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Creates a read-only view of a set of capability tokens.
|
|
13
|
+
*
|
|
14
|
+
* It satisfies `ReadonlySet<string>`: `has`, `size`, `forEach`, `keys`,
|
|
15
|
+
* `values`, `entries` and iteration. Iteration order is sorted, so it is the
|
|
16
|
+
* same for the same capabilities. `toJSON` returns the sorted array, so any
|
|
17
|
+
* JSON boundary carries the capabilities instead of losing them.
|
|
18
|
+
*
|
|
19
|
+
* @param values - The capabilities. Copied; later changes to the source do not show.
|
|
20
|
+
*/
|
|
21
|
+
const VIEWS = new WeakSet();
|
|
22
|
+
export function createCapabilitySet(values) {
|
|
23
|
+
const sorted = Object.freeze([...new Set(values)].sort());
|
|
24
|
+
const members = new Set(sorted);
|
|
25
|
+
const view = {
|
|
26
|
+
has: (value) => members.has(value),
|
|
27
|
+
get size() {
|
|
28
|
+
return sorted.length;
|
|
29
|
+
},
|
|
30
|
+
forEach(callback, thisArg) {
|
|
31
|
+
for (const value of sorted) {
|
|
32
|
+
callback.call(thisArg, value, value, view);
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
keys: () => sorted.values(),
|
|
36
|
+
values: () => sorted.values(),
|
|
37
|
+
entries: () => sorted.map((value) => [value, value]).values(),
|
|
38
|
+
[Symbol.iterator]: () => sorted.values(),
|
|
39
|
+
toJSON: () => sorted,
|
|
40
|
+
};
|
|
41
|
+
VIEWS.add(view);
|
|
42
|
+
return Object.freeze(view);
|
|
43
|
+
}
|
|
44
|
+
/** Reports whether a value is a capability view made by {@link createCapabilitySet}. */
|
|
45
|
+
export function isCapabilitySet(value) {
|
|
46
|
+
return typeof value === 'object' && value !== null && VIEWS.has(value);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Copies a value for a boundary that carries only plain JSON, replacing every
|
|
50
|
+
* capability view in it with its sorted array. Everything else is left as it
|
|
51
|
+
* is, so a boundary's own plain-value check still refuses what is not plain.
|
|
52
|
+
*
|
|
53
|
+
* @param value - The value to carry across.
|
|
54
|
+
*/
|
|
55
|
+
export function withPlainCapabilities(value, depth = 0) {
|
|
56
|
+
if (isCapabilitySet(value)) {
|
|
57
|
+
return [...value];
|
|
58
|
+
}
|
|
59
|
+
if (depth >= 16 || typeof value !== 'object' || value === null) {
|
|
60
|
+
return value;
|
|
61
|
+
}
|
|
62
|
+
if (Array.isArray(value)) {
|
|
63
|
+
return value.map((item) => withPlainCapabilities(item, depth + 1));
|
|
64
|
+
}
|
|
65
|
+
const prototype = Object.getPrototypeOf(value);
|
|
66
|
+
if (prototype !== Object.prototype && prototype !== null) {
|
|
67
|
+
return value;
|
|
68
|
+
}
|
|
69
|
+
return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, withPlainCapabilities(item, depth + 1)]));
|
|
70
|
+
}
|
|
71
|
+
/** The capability view of a caller that holds none. */
|
|
72
|
+
export const NO_CAPABILITIES = createCapabilitySet([]);
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -108,20 +108,23 @@ export declare class ContextContract {
|
|
|
108
108
|
*/
|
|
109
109
|
validate(options: Readonly<Record<string, unknown>>): void;
|
|
110
110
|
/**
|
|
111
|
-
*
|
|
111
|
+
* Refuses a string option that is not a dotted namespace path.
|
|
112
|
+
*
|
|
113
|
+
* String-valued options are contract fields. Flat aliases have no service
|
|
114
|
+
* owner and cannot be read, so one is reported as that, not as a missing
|
|
115
|
+
* field.
|
|
112
116
|
*
|
|
113
117
|
* @param options - Host-supplied values.
|
|
114
|
-
* @
|
|
118
|
+
* @throws {ContextContractError} When a flat string option is present.
|
|
115
119
|
*/
|
|
116
|
-
|
|
120
|
+
assertNamespaced(options: Readonly<Record<string, unknown>>): void;
|
|
117
121
|
/**
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
* Used when admission prunes an optional participant before boot.
|
|
122
|
+
* Lists, per declaring owner, the required fields the bag does not carry.
|
|
121
123
|
*
|
|
122
|
-
* @param
|
|
124
|
+
* @param options - Host-supplied values.
|
|
125
|
+
* @returns Owner id mapped to its missing required field names.
|
|
123
126
|
*/
|
|
124
|
-
|
|
127
|
+
missingRequiredByOwner(options: Readonly<Record<string, unknown>>): ReadonlyMap<string, readonly string[]>;
|
|
125
128
|
/** Prevents any further declaration. */
|
|
126
129
|
lock(): void;
|
|
127
130
|
/** Returns an immutable snapshot of the current schema. */
|
|
@@ -192,16 +192,7 @@ export class ContextContract {
|
|
|
192
192
|
* has the wrong type.
|
|
193
193
|
*/
|
|
194
194
|
validate(options) {
|
|
195
|
-
|
|
196
|
-
if (this.fields.has(key)) {
|
|
197
|
-
continue;
|
|
198
|
-
}
|
|
199
|
-
// String-valued options are contract fields. Every one must be a dotted
|
|
200
|
-
// namespace path; flat aliases have no service owner and cannot be read.
|
|
201
|
-
if (typeof value === 'string' && !key.includes('.')) {
|
|
202
|
-
throw new ContextContractError(`Un-namespaced string context option "${key}" is forbidden; use a dotted service namespace.`, { field: key, actualType: 'string' });
|
|
203
|
-
}
|
|
204
|
-
}
|
|
195
|
+
this.assertNamespaced(options);
|
|
205
196
|
for (const field of this.fields.values()) {
|
|
206
197
|
const value = options[field.name];
|
|
207
198
|
if (value === undefined) {
|
|
@@ -225,6 +216,26 @@ export class ContextContract {
|
|
|
225
216
|
}
|
|
226
217
|
}
|
|
227
218
|
}
|
|
219
|
+
/**
|
|
220
|
+
* Refuses a string option that is not a dotted namespace path.
|
|
221
|
+
*
|
|
222
|
+
* String-valued options are contract fields. Flat aliases have no service
|
|
223
|
+
* owner and cannot be read, so one is reported as that, not as a missing
|
|
224
|
+
* field.
|
|
225
|
+
*
|
|
226
|
+
* @param options - Host-supplied values.
|
|
227
|
+
* @throws {ContextContractError} When a flat string option is present.
|
|
228
|
+
*/
|
|
229
|
+
assertNamespaced(options) {
|
|
230
|
+
for (const [key, value] of Object.entries(options)) {
|
|
231
|
+
if (this.fields.has(key)) {
|
|
232
|
+
continue;
|
|
233
|
+
}
|
|
234
|
+
if (typeof value === 'string' && !key.includes('.')) {
|
|
235
|
+
throw new ContextContractError(`Un-namespaced string context option "${key}" is forbidden; use a dotted service namespace.`, { field: key, actualType: 'string' });
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
228
239
|
/**
|
|
229
240
|
* Lists, per declaring owner, the required fields the bag does not carry.
|
|
230
241
|
*
|
|
@@ -242,28 +253,6 @@ export class ContextContract {
|
|
|
242
253
|
}
|
|
243
254
|
return missing;
|
|
244
255
|
}
|
|
245
|
-
/**
|
|
246
|
-
* Withdraws every declaration one owner made.
|
|
247
|
-
*
|
|
248
|
-
* Used when admission prunes an optional participant before boot.
|
|
249
|
-
*
|
|
250
|
-
* @param ownerId - Stable identity of the declaring module.
|
|
251
|
-
*/
|
|
252
|
-
withdraw(ownerId) {
|
|
253
|
-
if (this.locked) {
|
|
254
|
-
throw new ContextContractError('Context contract is locked; declarations cannot be withdrawn after the kernel reached RUNNING.');
|
|
255
|
-
}
|
|
256
|
-
for (const [name, field] of [...this.fields]) {
|
|
257
|
-
if (field.ownerId === ownerId) {
|
|
258
|
-
this.fields.delete(name);
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
for (const [scope, owner] of [...this.owners]) {
|
|
262
|
-
if (owner === ownerId) {
|
|
263
|
-
this.owners.delete(scope);
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
256
|
/** Prevents any further declaration. */
|
|
268
257
|
lock() {
|
|
269
258
|
this.locked = true;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The caller of a routed operation, as recorded on the kernel call chain.
|
|
3
|
-
* It is never taken from the request. `capabilities` is
|
|
4
|
-
*
|
|
3
|
+
* It is never taken from the request. `capabilities` is the same read-only
|
|
4
|
+
* view every participant sees for a caller.
|
|
5
5
|
*/
|
|
6
6
|
export interface DispatchCallerView {
|
|
7
7
|
readonly identity: string | null;
|
|
8
8
|
readonly callerClass: string;
|
|
9
9
|
readonly official: boolean;
|
|
10
|
-
readonly capabilities:
|
|
10
|
+
readonly capabilities: ReadonlySet<string>;
|
|
11
11
|
readonly origin: string;
|
|
12
12
|
}
|
|
13
13
|
/** What a kind's dispatch exposure receives for one operation. */
|
|
File without changes
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import type { Token } from './container.js';
|
|
2
2
|
import type { ExecutionContext } from './context.js';
|
|
3
|
-
export interface PluginMetadata {
|
|
4
|
-
readonly isOfficial?: boolean;
|
|
5
|
-
readonly version?: string;
|
|
6
|
-
readonly author?: string;
|
|
7
|
-
readonly permissions?: readonly string[];
|
|
8
|
-
}
|
|
9
3
|
export interface OperationResult<TData = unknown> {
|
|
10
4
|
status: "success" | "failed" | "aborted" | "skipped";
|
|
11
5
|
data?: TData;
|
|
@@ -23,6 +17,5 @@ export interface OperationHandler<TInput = unknown, TOutput = unknown> {
|
|
|
23
17
|
readonly kind: string;
|
|
24
18
|
readonly requiredCapabilities?: readonly Token<unknown>[];
|
|
25
19
|
readonly promptDescriptor?: PromptDescriptor;
|
|
26
|
-
readonly metadata?: PluginMetadata;
|
|
27
20
|
execute(context: ExecutionContext, input: TInput): Promise<OperationResult<TOutput>>;
|
|
28
21
|
}
|
|
File without changes
|
|
@@ -16,10 +16,11 @@ export type { IServiceContainer } from './container.js';
|
|
|
16
16
|
export type { ExecutionContext } from './context.js';
|
|
17
17
|
export type { ContextContractErrorCode, ContextFieldDeclaration, ContextFieldSchema, ContextFieldType, ContextSchema, ContextScopeDeclaration, } from './contextContract.js';
|
|
18
18
|
export { CONTEXT_FIELD_TYPES, ContextContract, ContextContractError, requireContextString, } from './contextContract.js';
|
|
19
|
-
export type { OperationResult, OperationHandler, PromptDescriptor
|
|
19
|
+
export type { OperationResult, OperationHandler, PromptDescriptor } from './handler.js';
|
|
20
20
|
export type { CapabilityToken } from './capability.js';
|
|
21
21
|
export { CAPABILITY_TOKEN_PATTERN, isCapabilityToken, } from './capability.js';
|
|
22
22
|
export type { BrudOperationKind } from './brudOperation.js';
|
|
23
23
|
export { BRUD_KIND_PATTERN, isValidBrudKind, } from './brudOperation.js';
|
|
24
24
|
export type { MiddlewareNext, Middleware, IExecutionPipeline } from './pipeline.js';
|
|
25
25
|
export type { IOperationRegistry } from './registry.js';
|
|
26
|
+
export { NO_CAPABILITIES, createCapabilitySet, isCapabilitySet, withPlainCapabilities } from './capabilitySet.js';
|
|
@@ -6,3 +6,4 @@ export { createToken } from './container.js';
|
|
|
6
6
|
export { CONTEXT_FIELD_TYPES, ContextContract, ContextContractError, requireContextString, } from './contextContract.js';
|
|
7
7
|
export { CAPABILITY_TOKEN_PATTERN, isCapabilityToken, } from './capability.js';
|
|
8
8
|
export { BRUD_KIND_PATTERN, isValidBrudKind, } from './brudOperation.js';
|
|
9
|
+
export { NO_CAPABILITIES, createCapabilitySet, isCapabilitySet, withPlainCapabilities } from './capabilitySet.js';
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|