@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
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createCapabilitySet } from '../contracts/capabilitySet.js';
|
|
1
2
|
import { existsSync, readFileSync } from 'node:fs';
|
|
2
3
|
import { readFile } from 'node:fs/promises';
|
|
3
4
|
import { dirname, isAbsolute, relative as relativePath, resolve as resolvePath } from 'node:path';
|
|
@@ -5,7 +6,11 @@ import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
|
5
6
|
import { ContextContract, ContextContractError, } from '../contracts/contextContract.js';
|
|
6
7
|
import { admitParticipantManifest } from '../contracts/manifest.js';
|
|
7
8
|
import { BrudKernel } from '../engine/BrudKernel.js';
|
|
8
|
-
import {
|
|
9
|
+
import { LifecycleStateError } from '../engine/errors.js';
|
|
10
|
+
import { checkSeal } from './seal.js';
|
|
11
|
+
import { abandonment, culpritOf, LoadedParticipantFailure } from './loaded.js';
|
|
12
|
+
import { KernelReloadError, refuseFrozenChange } from './reload.js';
|
|
13
|
+
import { acceptConfigChange, protectConfigFile, recordConfigRead, releaseConfigProtection, verifyConfigIntegrity, } from './config/integrity.js';
|
|
9
14
|
import { lineOf, parseBrudConfig } from './config/parse.js';
|
|
10
15
|
import { PackageRequirementsError, readPackageRequirements } from './packageRequirements.js';
|
|
11
16
|
import { buildHardcoreBootEntries, invokeHardcoreBootHooks, verifyHardcoreServices, } from './hardcore.js';
|
|
@@ -40,12 +45,10 @@ function registerBootRegistrantsHook(moduleValue) {
|
|
|
40
45
|
* @param options - Generic options bag and logger.
|
|
41
46
|
*/
|
|
42
47
|
export async function bootKernel(configPath, options) {
|
|
43
|
-
|
|
44
|
-
await kernel.boot({
|
|
48
|
+
return startTolerant(configPath, options, {
|
|
45
49
|
...(options.options === undefined ? {} : { options: options.options }),
|
|
46
50
|
...(options.logger === undefined ? {} : { logger: options.logger }),
|
|
47
|
-
});
|
|
48
|
-
return kernel;
|
|
51
|
+
}, undefined);
|
|
49
52
|
}
|
|
50
53
|
/**
|
|
51
54
|
* Builds a kernel whose config is composed lazily on the first `boot()`.
|
|
@@ -56,6 +59,115 @@ export async function bootKernel(configPath, options) {
|
|
|
56
59
|
* `require`.
|
|
57
60
|
*/
|
|
58
61
|
export function createDeferredKernel(configPath, options) {
|
|
62
|
+
return assembleKernel(configPath, options, undefined).kernel;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Boots a kernel, leaving out loaded participants that cannot start.
|
|
66
|
+
*
|
|
67
|
+
* A loaded participant is any config entry not declared official. One that
|
|
68
|
+
* fails to load, to be admitted, or to start is left out and the boot is tried
|
|
69
|
+
* again without it, so a bad loaded participant never stops the kernel. A
|
|
70
|
+
* failure in a hardcore or composed participant still refuses the boot.
|
|
71
|
+
*
|
|
72
|
+
* A failure while composing names its loaded participants itself. A failure
|
|
73
|
+
* while booting is traced to the participant it names, or to the service that
|
|
74
|
+
* threw it. When it cannot be traced to a loaded participant, every loaded
|
|
75
|
+
* participant is left out once and the boot is tried again; if that fails
|
|
76
|
+
* too, the failure was in the build and is thrown.
|
|
77
|
+
*
|
|
78
|
+
* @param baseline - The booted config this one replaces, for a reload.
|
|
79
|
+
* @param beforeFirstBoot - Runs once, after the new composition is checked and
|
|
80
|
+
* before anything boots: a reload stops the running kernel here.
|
|
81
|
+
* @param wrap - Turns a failure after `beforeFirstBoot` into the error thrown.
|
|
82
|
+
*/
|
|
83
|
+
async function startTolerant(configPath, options, bootOptions, baseline, beforeFirstBoot, wrap) {
|
|
84
|
+
const left = new Map();
|
|
85
|
+
let stopped = false;
|
|
86
|
+
let sweptAll = false;
|
|
87
|
+
for (;;) {
|
|
88
|
+
const attempt = assembleKernel(configPath, options, baseline, new Set(left.keys()));
|
|
89
|
+
let phase = 'compose';
|
|
90
|
+
try {
|
|
91
|
+
await attempt.validate(bootOptions);
|
|
92
|
+
if (!stopped) {
|
|
93
|
+
stopped = true;
|
|
94
|
+
try {
|
|
95
|
+
await beforeFirstBoot?.();
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
attempt.abandon();
|
|
99
|
+
throw error;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
phase = 'boot';
|
|
103
|
+
await attempt.kernel.boot(bootOptions);
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
const fresh = blamedLoaded(attempt, error, phase, left, sweptAll);
|
|
107
|
+
if (fresh === undefined) {
|
|
108
|
+
throw stopped && wrap !== undefined ? wrap(error) : error;
|
|
109
|
+
}
|
|
110
|
+
sweptAll ||= fresh.swept;
|
|
111
|
+
for (const entry of fresh.entries) {
|
|
112
|
+
left.set(entry.path, entry);
|
|
113
|
+
}
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
attempt.setAbandoned([...left.values()]);
|
|
117
|
+
reportAbandoned(bootOptions.logger ?? options.logger ?? DEFAULT_KERNEL_LOGGER, left);
|
|
118
|
+
return attempt.kernel;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
/** The loaded participants to leave out after a failed attempt, or `undefined` when the failure is not theirs. */
|
|
122
|
+
function blamedLoaded(attempt, error, phase, left, sweptAll) {
|
|
123
|
+
if (error instanceof LoadedParticipantFailure) {
|
|
124
|
+
const entries = error.participants.filter((entry) => !left.has(entry.path));
|
|
125
|
+
return entries.length === 0 ? undefined : { entries, swept: false };
|
|
126
|
+
}
|
|
127
|
+
if (phase === 'compose') {
|
|
128
|
+
return undefined;
|
|
129
|
+
}
|
|
130
|
+
const token = culpritOf(error);
|
|
131
|
+
const path = token === undefined ? undefined : attempt.loadedPathOf(token);
|
|
132
|
+
if (path !== undefined && !left.has(path)) {
|
|
133
|
+
return { entries: [abandonment(path, error, token)], swept: false };
|
|
134
|
+
}
|
|
135
|
+
if (sweptAll) {
|
|
136
|
+
return undefined;
|
|
137
|
+
}
|
|
138
|
+
const remaining = attempt.config().services.filter((entry) => entry.official !== true && !left.has(entry.path));
|
|
139
|
+
if (remaining.length === 0) {
|
|
140
|
+
return undefined;
|
|
141
|
+
}
|
|
142
|
+
const why = error instanceof Error ? error.message : String(error);
|
|
143
|
+
return {
|
|
144
|
+
swept: true,
|
|
145
|
+
entries: remaining.map((entry) => ({
|
|
146
|
+
path: entry.path,
|
|
147
|
+
reason: `the kernel could not start with the loaded participants and the cause could not be traced to one of them (${why})`,
|
|
148
|
+
})),
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
function reportAbandoned(logger, left) {
|
|
152
|
+
if (left.size === 0) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
const lines = [...left.values()].map((entry) => `${entry.path}: ${entry.reason}`);
|
|
156
|
+
logger.warn(`Left out ${String(left.size)} loaded participant(s); the kernel started without them:\n${lines.join('\n')}`, {
|
|
157
|
+
abandoned: [...left.values()],
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Builds a kernel and the handles a reload needs.
|
|
162
|
+
*
|
|
163
|
+
* @param baseline - The booted config this one replaces, when it is a reload's
|
|
164
|
+
* successor: its read supersedes the recorded config digest, and its frozen
|
|
165
|
+
* part must match the baseline.
|
|
166
|
+
*/
|
|
167
|
+
function assembleKernel(configPath, options, baseline, skip = new Set()) {
|
|
168
|
+
let lastBootOptions = {};
|
|
169
|
+
let abandonedList = [];
|
|
170
|
+
const loadedTokens = new Map();
|
|
59
171
|
let loadedServices = [];
|
|
60
172
|
let serviceContext;
|
|
61
173
|
let hardcoreBootEntries = [];
|
|
@@ -79,7 +191,7 @@ export function createDeferredKernel(configPath, options) {
|
|
|
79
191
|
callerClass: 'participant',
|
|
80
192
|
identity: identities.get(entry.token) ?? null,
|
|
81
193
|
official: entry.official,
|
|
82
|
-
capabilities:
|
|
194
|
+
capabilities: createCapabilitySet(entry.manifest.capabilities),
|
|
83
195
|
...(entry.parentIdentity === undefined
|
|
84
196
|
? {}
|
|
85
197
|
: { parentIdentity: entry.parentIdentity }),
|
|
@@ -113,12 +225,29 @@ export function createDeferredKernel(configPath, options) {
|
|
|
113
225
|
const compose = (bootOptions) => {
|
|
114
226
|
composition ??= (async () => {
|
|
115
227
|
const raw = await readConfig(configPath);
|
|
228
|
+
const config = parseBrudConfig(raw, configPath);
|
|
229
|
+
// With a build seal, the official participants must be exactly those the
|
|
230
|
+
// builder sealed. One that declares itself official without being sealed
|
|
231
|
+
// is not part of the build, so it is left out and named.
|
|
232
|
+
const sealCheck = options.seal === undefined ? undefined : checkSeal(options.seal, config, configPath);
|
|
233
|
+
if (baseline !== undefined) {
|
|
234
|
+
refuseFrozenChange(baseline, config, configPath, sealCheck?.sealed);
|
|
235
|
+
acceptConfigChange(configPath);
|
|
236
|
+
}
|
|
237
|
+
const unsealed = sealCheck?.unsealed ?? new Set();
|
|
238
|
+
const newlyUnsealed = [...unsealed].filter((path) => !skip.has(path));
|
|
239
|
+
if (newlyUnsealed.length > 0) {
|
|
240
|
+
throw new LoadedParticipantFailure(newlyUnsealed.map((path) => ({
|
|
241
|
+
path,
|
|
242
|
+
code: 'PARTICIPANT_NOT_SEALED',
|
|
243
|
+
reason: 'it declares itself official, but the build did not seal it; only a rebuild can make a participant official',
|
|
244
|
+
})));
|
|
245
|
+
}
|
|
116
246
|
recordConfigRead(configPath, raw);
|
|
117
247
|
protectConfigFile(configPath);
|
|
118
248
|
protectedThisKernel = true;
|
|
119
|
-
const config = parseBrudConfig(raw, configPath);
|
|
120
249
|
composedConfig = config;
|
|
121
|
-
const services = await loadServiceModules(config.services, configPath, raw);
|
|
250
|
+
const services = await loadServiceModules(config.services.filter((entry) => !(skip.has(entry.path) && (entry.official !== true || unsealed.has(entry.path)))), configPath, raw);
|
|
122
251
|
const contextOptions = {
|
|
123
252
|
...(options.options ?? {}),
|
|
124
253
|
...(bootOptions.options ?? {}),
|
|
@@ -134,28 +263,57 @@ export function createDeferredKernel(configPath, options) {
|
|
|
134
263
|
loadedServices = services;
|
|
135
264
|
serviceContext = context;
|
|
136
265
|
const owned = [];
|
|
266
|
+
const failedLoaded = [];
|
|
137
267
|
for (const loaded of services) {
|
|
138
268
|
activeServiceOwner = `${String(loaded.index)}:${loaded.entry.path}`;
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
269
|
+
try {
|
|
270
|
+
const own = [];
|
|
271
|
+
for (const descriptor of await descriptorsFromModule(loaded.module, loaded.entry, loaded.index, context, configPath, raw)) {
|
|
272
|
+
own.push({
|
|
273
|
+
ownerId: activeServiceOwner,
|
|
274
|
+
service: {
|
|
275
|
+
descriptor,
|
|
276
|
+
path: loaded.entry.path,
|
|
277
|
+
...(loaded.entry.official === undefined ? {} : { official: loaded.entry.official }),
|
|
278
|
+
resolvedPath: loaded.resolvedId,
|
|
279
|
+
// The manifest is admitted from declared data only; the
|
|
280
|
+
// participant's factory is not invoked.
|
|
281
|
+
manifest: admitParticipantManifest(descriptor.token.id, descriptor.manifest),
|
|
282
|
+
},
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
owned.push(...own);
|
|
286
|
+
}
|
|
287
|
+
catch (error) {
|
|
288
|
+
if (loaded.entry.official === true) {
|
|
289
|
+
throw error;
|
|
290
|
+
}
|
|
291
|
+
failedLoaded.push(abandonment(loaded.entry.path, error));
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
if (failedLoaded.length > 0) {
|
|
295
|
+
throw new LoadedParticipantFailure(failedLoaded);
|
|
296
|
+
}
|
|
297
|
+
// A loaded participant that lacks a required boot option is left out. If
|
|
298
|
+
// any hardcore or composed participant lacks one, the boot is refused as
|
|
299
|
+
// before, naming every missing field.
|
|
300
|
+
contextContract.assertNamespaced(contextOptions);
|
|
301
|
+
const missing = contextContract.missingRequiredByOwner(contextOptions);
|
|
302
|
+
const pathOf = (ownerId) => ownerId.slice(ownerId.indexOf(':') + 1);
|
|
303
|
+
const loadedPaths = new Set(owned.filter((entry) => entry.service.official !== true).map((entry) => entry.service.path));
|
|
304
|
+
if (missing.size > 0 && [...missing.keys()].every((ownerId) => loadedPaths.has(pathOf(ownerId)))) {
|
|
305
|
+
throw new LoadedParticipantFailure([...missing].map(([ownerId, fields]) => ({
|
|
306
|
+
path: pathOf(ownerId),
|
|
307
|
+
code: 'CONTEXT_FIELD_MISSING',
|
|
308
|
+
reason: `required boot option(s) not supplied: ${fields.join(', ')}`,
|
|
309
|
+
})));
|
|
310
|
+
}
|
|
311
|
+
const composed = refuseMissingContext(owned, contextContract, contextOptions);
|
|
312
|
+
for (const entry of owned) {
|
|
313
|
+
if (entry.service.official !== true) {
|
|
314
|
+
loadedTokens.set(entry.service.descriptor.token.id, entry.service.path);
|
|
152
315
|
}
|
|
153
316
|
}
|
|
154
|
-
const composed = pruneForMissingContext(owned, contextContract, contextOptions, (participants, path, fields) => {
|
|
155
|
-
const detail = { participants, path, missingFields: fields };
|
|
156
|
-
(contextLogger ?? DEFAULT_KERNEL_LOGGER).warn(`Participant pruned before boot: required context field(s) ${fields.join(', ')} missing and nothing depends on it`, detail);
|
|
157
|
-
kernel.recordObservation('kernel.admission', 'participant-pruned', detail);
|
|
158
|
-
});
|
|
159
317
|
// The hardcore gate runs after descriptors exist and before any service
|
|
160
318
|
// is registered or initialized. A failure here never reaches the
|
|
161
319
|
// service initialization phase.
|
|
@@ -170,6 +328,7 @@ export function createDeferredKernel(configPath, options) {
|
|
|
170
328
|
};
|
|
171
329
|
const boot = kernel.boot.bind(kernel);
|
|
172
330
|
kernel.boot = async (bootOptions) => {
|
|
331
|
+
lastBootOptions = bootOptions;
|
|
173
332
|
try {
|
|
174
333
|
await compose(bootOptions);
|
|
175
334
|
// Store the bag the composition built: the host's options. Service
|
|
@@ -206,49 +365,72 @@ export function createDeferredKernel(configPath, options) {
|
|
|
206
365
|
releaseConfigProtection(configPath);
|
|
207
366
|
}
|
|
208
367
|
};
|
|
209
|
-
|
|
368
|
+
const abandon = () => {
|
|
369
|
+
if (protectedThisKernel) {
|
|
370
|
+
protectedThisKernel = false;
|
|
371
|
+
releaseConfigProtection(configPath);
|
|
372
|
+
}
|
|
373
|
+
};
|
|
374
|
+
const validate = async (bootOptions) => {
|
|
375
|
+
try {
|
|
376
|
+
await compose(bootOptions);
|
|
377
|
+
}
|
|
378
|
+
catch (error) {
|
|
379
|
+
abandon();
|
|
380
|
+
throw error;
|
|
381
|
+
}
|
|
382
|
+
};
|
|
383
|
+
kernel.reload = (reloadOptions = {}) => {
|
|
384
|
+
if (kernel.lifecycleState !== 'RUNNING') {
|
|
385
|
+
return Promise.reject(new LifecycleStateError('reload', kernel.lifecycleState, 'RUNNING'));
|
|
386
|
+
}
|
|
387
|
+
const target = reloadOptions.configPath ?? configPath;
|
|
388
|
+
// The new composition is read, checked against the frozen part and
|
|
389
|
+
// composed while this kernel still runs; a refusal changes nothing. Only
|
|
390
|
+
// then is this kernel stopped and the new one booted.
|
|
391
|
+
return startTolerant(target, options, lastBootOptions, composedConfig, () => kernel.shutdown(), (error) => new KernelReloadError(target, error));
|
|
392
|
+
};
|
|
393
|
+
Object.defineProperty(kernel, 'abandoned', { get: () => abandonedList, enumerable: true });
|
|
394
|
+
return {
|
|
395
|
+
kernel,
|
|
396
|
+
validate,
|
|
397
|
+
abandon,
|
|
398
|
+
config: () => composedConfig,
|
|
399
|
+
loadedPathOf: (token) => loadedTokens.get(token),
|
|
400
|
+
setAbandoned: (list) => {
|
|
401
|
+
abandonedList = list;
|
|
402
|
+
},
|
|
403
|
+
};
|
|
210
404
|
}
|
|
211
405
|
/**
|
|
212
|
-
*
|
|
406
|
+
* Refuses the boot when any required context field is missing.
|
|
213
407
|
*
|
|
214
|
-
*
|
|
215
|
-
*
|
|
216
|
-
*
|
|
217
|
-
*
|
|
408
|
+
* The rule is the same for every participant, official or not, hardcore or
|
|
409
|
+
* not, depended on or not: a participant that declared a field as required
|
|
410
|
+
* cannot run without it, and leaving it out would give a composition whose
|
|
411
|
+
* exposures disappear without a reason. The error names every missing field,
|
|
412
|
+
* the declaring owner, the participants it covers and the module path, so one
|
|
413
|
+
* failed boot tells the host everything it must supply.
|
|
218
414
|
*
|
|
219
|
-
* @returns The composed descriptors
|
|
415
|
+
* @returns The composed descriptors, unchanged.
|
|
220
416
|
*/
|
|
221
|
-
function
|
|
417
|
+
function refuseMissingContext(owned, contextContract, options) {
|
|
418
|
+
// A value in the wrong shape or under a flat alias is reported as that, before
|
|
419
|
+
// the field it was meant for is reported as missing.
|
|
420
|
+
contextContract.assertNamespaced(options);
|
|
222
421
|
const missing = contextContract.missingRequiredByOwner(options);
|
|
223
|
-
if (missing.size
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
const
|
|
232
|
-
|
|
233
|
-
&& entry.service.descriptor.dependencies.some((dependency) => tokens.has(dependency.id)));
|
|
234
|
-
if (services.length === 0 || isHardcore || dependedOn) {
|
|
235
|
-
const reason = isHardcore
|
|
236
|
-
? 'it is hardcore'
|
|
237
|
-
: dependedOn
|
|
238
|
-
? 'another participant depends on it'
|
|
239
|
-
: 'it declared no participant';
|
|
240
|
-
throw new ContextContractError(`Required context field(s) ${fields.join(', ')} declared by "${ownerId}" are missing and ${reason}; boot refused.`, { field: fields[0], service: ownerId, actualType: 'missing' });
|
|
241
|
-
}
|
|
242
|
-
pruned.add(ownerId);
|
|
422
|
+
if (missing.size > 0) {
|
|
423
|
+
const scopeOf = new Map(contextContract.schema().fields.map((field) => [field.name, field.service]));
|
|
424
|
+
const parts = [...missing].map(([ownerId, fields]) => {
|
|
425
|
+
const services = owned.filter((entry) => entry.ownerId === ownerId);
|
|
426
|
+
const participants = services.map((entry) => entry.service.descriptor.token.id);
|
|
427
|
+
const path = services[0]?.service.path;
|
|
428
|
+
return `${fields.join(', ')} (scope "${scopeOf.get(fields[0] ?? '') ?? ownerId}"${participants.length === 0 ? '' : `, participant ${participants.join(', ')}`}${path === undefined ? '' : `, module ${path}`})`;
|
|
429
|
+
});
|
|
430
|
+
const first = [...missing][0];
|
|
431
|
+
throw new ContextContractError(`Boot refused: required context field(s) missing: ${parts.join('; ')}. Supply them in the boot options.`, { field: first[1][0], service: first[0], actualType: 'missing' });
|
|
243
432
|
}
|
|
244
|
-
|
|
245
|
-
const services = owned.filter((entry) => entry.ownerId === ownerId);
|
|
246
|
-
contextContract.withdraw(ownerId);
|
|
247
|
-
onPruned(services.map((entry) => entry.service.descriptor.token.id), services[0]?.service.path ?? ownerId, missing.get(ownerId) ?? []);
|
|
248
|
-
}
|
|
249
|
-
return owned
|
|
250
|
-
.filter((entry) => !pruned.has(entry.ownerId))
|
|
251
|
-
.map((entry) => entry.service);
|
|
433
|
+
return owned.map((entry) => entry.service);
|
|
252
434
|
}
|
|
253
435
|
function descriptorsFromModule(moduleValue, entry, index, context, configPath, raw) {
|
|
254
436
|
return descriptorsFromModuleAsync(moduleValue, entry, index, context, configPath, raw);
|
|
@@ -316,13 +498,27 @@ function nativeEntryOf(manifestPath, configPath, label, line) {
|
|
|
316
498
|
* refused at boot.
|
|
317
499
|
*/
|
|
318
500
|
async function loadServiceModules(entries, configPath, raw) {
|
|
319
|
-
const
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
501
|
+
const unresolvable = [];
|
|
502
|
+
const resolved = entries.flatMap((entry, index) => {
|
|
503
|
+
try {
|
|
504
|
+
return [{
|
|
505
|
+
index,
|
|
506
|
+
entry,
|
|
507
|
+
resolvedId: resolveModuleId(entry.path, configPath),
|
|
508
|
+
label: `services[${String(index)}]`,
|
|
509
|
+
line: lineOf(raw, entry.path),
|
|
510
|
+
}];
|
|
511
|
+
}
|
|
512
|
+
catch (error) {
|
|
513
|
+
// A loaded participant whose path does not resolve is left out; the same
|
|
514
|
+
// failure in a hardcore or composed entry refuses the boot.
|
|
515
|
+
if (entry.official === true) {
|
|
516
|
+
throw error;
|
|
517
|
+
}
|
|
518
|
+
unresolvable.push(abandonment(entry.path, error));
|
|
519
|
+
return [];
|
|
520
|
+
}
|
|
521
|
+
});
|
|
326
522
|
const official = new Map();
|
|
327
523
|
await Promise.all(resolved.map(async (item) => {
|
|
328
524
|
if (item.entry.official === true && !isParticipantPackage(item.resolvedId)) {
|
|
@@ -333,7 +529,7 @@ async function loadServiceModules(entries, configPath, raw) {
|
|
|
333
529
|
const loader = module?.loadParticipantPackage;
|
|
334
530
|
return typeof loader === 'function' ? [loader] : [];
|
|
335
531
|
});
|
|
336
|
-
|
|
532
|
+
const outcomes = await Promise.allSettled(resolved.map(async (item) => {
|
|
337
533
|
const { index, entry, resolvedId, label, line } = item;
|
|
338
534
|
if (official.has(index)) {
|
|
339
535
|
return { index, entry, resolvedId, module: official.get(index) };
|
|
@@ -363,6 +559,23 @@ async function loadServiceModules(entries, configPath, raw) {
|
|
|
363
559
|
throw new BrudConfigError('MODULE_RESOLVE', `Cannot load participant package "${entry.path}" (${label}): ${error instanceof Error ? error.message : String(error)}`, configPath, line);
|
|
364
560
|
}
|
|
365
561
|
}));
|
|
562
|
+
const loaded = [];
|
|
563
|
+
const left = [...unresolvable];
|
|
564
|
+
for (const [position, outcome] of outcomes.entries()) {
|
|
565
|
+
if (outcome.status === 'fulfilled') {
|
|
566
|
+
loaded.push(outcome.value);
|
|
567
|
+
continue;
|
|
568
|
+
}
|
|
569
|
+
const entry = resolved[position].entry;
|
|
570
|
+
if (entry.official === true) {
|
|
571
|
+
throw outcome.reason;
|
|
572
|
+
}
|
|
573
|
+
left.push(abandonment(entry.path, outcome.reason));
|
|
574
|
+
}
|
|
575
|
+
if (left.length > 0) {
|
|
576
|
+
throw new LoadedParticipantFailure(left);
|
|
577
|
+
}
|
|
578
|
+
return loaded;
|
|
366
579
|
}
|
|
367
580
|
async function importModule(id, configPath, declaredPath, label, line) {
|
|
368
581
|
try {
|
|
@@ -372,7 +585,7 @@ async function importModule(id, configPath, declaredPath, label, line) {
|
|
|
372
585
|
throw new BrudConfigError('MODULE_RESOLVE', `Cannot resolve module "${declaredPath}" (${label}): ${error instanceof Error ? error.message : String(error)}`, configPath, line);
|
|
373
586
|
}
|
|
374
587
|
}
|
|
375
|
-
function resolveModuleId(declaredPath, configPath) {
|
|
588
|
+
export function resolveModuleId(declaredPath, configPath) {
|
|
376
589
|
if (declaredPath.startsWith('kernel:')) {
|
|
377
590
|
return resolveExisting(fileURLToPath(new URL(declaredPath.slice('kernel:'.length), KERNEL_PACKAGE_ROOT)));
|
|
378
591
|
}
|
|
@@ -1,9 +1,23 @@
|
|
|
1
1
|
import type { ContextFieldDeclaration, ContextSchema, ContextScopeDeclaration } from '../contracts/contextContract.js';
|
|
2
2
|
import type { IServiceLifecycle, KernelLogger } from '../contracts/lifecycle.js';
|
|
3
|
+
/**
|
|
4
|
+
* The build seal: what a composition's builder shipped, fixed once per build.
|
|
5
|
+
*
|
|
6
|
+
* It lists every official participant in the order the build declared them,
|
|
7
|
+
* each with a content hash. The builder generates it at release time and the
|
|
8
|
+
* built product hands the kernel the seal file and its digest at boot, so the
|
|
9
|
+
* kernel can tell what the build shipped from anything added afterwards.
|
|
10
|
+
*/
|
|
11
|
+
export interface SealReference {
|
|
12
|
+
/** Path of the seal file. */
|
|
13
|
+
readonly path: string;
|
|
14
|
+
/** SHA-256 hex digest of the seal file, held by the built product, not next to the file. */
|
|
15
|
+
readonly digest: string;
|
|
16
|
+
}
|
|
3
17
|
/**
|
|
4
18
|
* Generic options accepted by {@link bootKernel}.
|
|
5
19
|
*
|
|
6
|
-
* The core names
|
|
20
|
+
* The core names three fields: an open options bag, a logger, and the build seal the host's product carries. Every
|
|
7
21
|
* service-specific option lives inside {@link BootKernelOptions.options} and
|
|
8
22
|
* is interpreted by the service module that owns it. The core never sees those
|
|
9
23
|
* names or types.
|
|
@@ -13,6 +27,14 @@ export interface BootKernelOptions {
|
|
|
13
27
|
readonly options?: Readonly<Record<string, unknown>>;
|
|
14
28
|
/** Kernel diagnostic sink. Defaults to a console-backed sink. */
|
|
15
29
|
readonly logger?: KernelLogger;
|
|
30
|
+
/**
|
|
31
|
+
* The build seal: the file the builder generated at release time and its
|
|
32
|
+
* digest, which the built product holds. When given, the official
|
|
33
|
+
* participants must be exactly those the seal lists, and an entry that
|
|
34
|
+
* declares itself official without being sealed is left out. When absent,
|
|
35
|
+
* the config's own `official` flags stand, which suits development.
|
|
36
|
+
*/
|
|
37
|
+
readonly seal?: SealReference;
|
|
16
38
|
}
|
|
17
39
|
/** Options accepted by {@link createDeferredKernel}. */
|
|
18
40
|
export interface ComposeKernelOptions {
|
|
@@ -20,6 +42,8 @@ export interface ComposeKernelOptions {
|
|
|
20
42
|
readonly options?: Readonly<Record<string, unknown>>;
|
|
21
43
|
/** Kernel diagnostic sink. Defaults to a console-backed sink. */
|
|
22
44
|
readonly logger?: KernelLogger;
|
|
45
|
+
/** The build seal, as for {@link BootKernelOptions.seal}. */
|
|
46
|
+
readonly seal?: SealReference;
|
|
23
47
|
}
|
|
24
48
|
/**
|
|
25
49
|
* Context handed to a config-selected service module.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -8,6 +8,17 @@
|
|
|
8
8
|
* @param raw - Exact file contents.
|
|
9
9
|
*/
|
|
10
10
|
export declare function recordConfigRead(configPath: string, raw: string): void;
|
|
11
|
+
/**
|
|
12
|
+
* Forgets the recorded digest of a config path, so the next read is recorded
|
|
13
|
+
* as the new baseline.
|
|
14
|
+
*
|
|
15
|
+
* Only a reload the host asked for calls this: it is the host's explicit
|
|
16
|
+
* decision to run a changed composition. An ordinary boot never does, so a
|
|
17
|
+
* config that changed outside a reload is still refused.
|
|
18
|
+
*
|
|
19
|
+
* @param configPath - Path whose digest is forgotten.
|
|
20
|
+
*/
|
|
21
|
+
export declare function acceptConfigChange(configPath: string): void;
|
|
11
22
|
/**
|
|
12
23
|
* Marks the root config read-only for the lifetime of one kernel.
|
|
13
24
|
*
|
|
@@ -36,6 +36,19 @@ export function recordConfigRead(configPath, raw) {
|
|
|
36
36
|
}
|
|
37
37
|
CONFIG_DIGESTS.set(key, digest);
|
|
38
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Forgets the recorded digest of a config path, so the next read is recorded
|
|
41
|
+
* as the new baseline.
|
|
42
|
+
*
|
|
43
|
+
* Only a reload the host asked for calls this: it is the host's explicit
|
|
44
|
+
* decision to run a changed composition. An ordinary boot never does, so a
|
|
45
|
+
* config that changed outside a reload is still refused.
|
|
46
|
+
*
|
|
47
|
+
* @param configPath - Path whose digest is forgotten.
|
|
48
|
+
*/
|
|
49
|
+
export function acceptConfigChange(configPath) {
|
|
50
|
+
CONFIG_DIGESTS.delete(resolvePath(configPath));
|
|
51
|
+
}
|
|
39
52
|
/**
|
|
40
53
|
* Marks the root config read-only for the lifetime of one kernel.
|
|
41
54
|
*
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -31,7 +31,7 @@ export interface BrudConfig {
|
|
|
31
31
|
readonly exposureOwners?: Readonly<Record<string, string>>;
|
|
32
32
|
}
|
|
33
33
|
/** Stable config failure codes. */
|
|
34
|
-
export type BrudConfigErrorCode = 'CONFIG_READ' | 'CONFIG_PARSE' | 'CONFIG_SCHEMA' | 'CONFIG_INTEGRITY' | 'MODULE_RESOLVE' | 'MODULE_CONTRACT' | 'PARTICIPANT_TIER' | 'PARTICIPANT_REQUIRES_OFFICIAL' | 'HARDCORE_VERIFICATION';
|
|
34
|
+
export type BrudConfigErrorCode = 'CONFIG_READ' | 'CONFIG_PARSE' | 'CONFIG_SCHEMA' | 'CONFIG_INTEGRITY' | 'CONFIG_RELOAD_FROZEN' | 'SEAL_MISMATCH' | 'SEAL_VIOLATION' | 'MODULE_RESOLVE' | 'MODULE_CONTRACT' | 'PARTICIPANT_TIER' | 'PARTICIPANT_REQUIRES_OFFICIAL' | 'HARDCORE_VERIFICATION';
|
|
35
35
|
/** Config or module-resolution failure with optional source line. */
|
|
36
36
|
export declare class BrudConfigError extends Error {
|
|
37
37
|
readonly code: BrudConfigErrorCode;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -17,17 +17,17 @@
|
|
|
17
17
|
* an entry's package graph requires a kernel rebuild with new pinned digests.
|
|
18
18
|
*/
|
|
19
19
|
/** Pinned digests of the identity registry package. */
|
|
20
|
-
const IDENTITY_REGISTRY_SOURCE_HASH = '
|
|
21
|
-
const IDENTITY_REGISTRY_BUILT_HASH = '
|
|
20
|
+
const IDENTITY_REGISTRY_SOURCE_HASH = '9b1b73ed6ad48cb910f5f584bf51984561455fe998f93790a06359fd69aa11c2';
|
|
21
|
+
const IDENTITY_REGISTRY_BUILT_HASH = 'd30ee7fecfca06ad1f661a9125bb0eafa1d7750467c369ea59bd553bfe107fa1';
|
|
22
22
|
/** Pinned digests of the exposed API registry package. */
|
|
23
|
-
const EXPOSED_API_REGISTRY_SOURCE_HASH = '
|
|
24
|
-
const EXPOSED_API_REGISTRY_BUILT_HASH = '
|
|
23
|
+
const EXPOSED_API_REGISTRY_SOURCE_HASH = 'e025e0c9dad2b1471527ace37d102abe9366a6bd9f14014a29e1b11410a77240';
|
|
24
|
+
const EXPOSED_API_REGISTRY_BUILT_HASH = '1611d0706c145878d644f0549cab89856423c07351ebef5b209c26874677f8b0';
|
|
25
25
|
/** Pinned digests of the parser package. */
|
|
26
|
-
const PARSER_SOURCE_HASH = '
|
|
26
|
+
const PARSER_SOURCE_HASH = '0c7310dae93d06b08cfc34dfd275f09fb50a97a07338b635be52d8594e940431';
|
|
27
27
|
const PARSER_BUILT_HASH = '2b2520552e7652a0992677bd8607cbe0d4b798e4e629963a4a27727a851e3c37';
|
|
28
28
|
/** Pinned digests of the router package. */
|
|
29
|
-
const ROUTER_SOURCE_HASH = '
|
|
30
|
-
const ROUTER_BUILT_HASH = '
|
|
29
|
+
const ROUTER_SOURCE_HASH = '32af5d7bb8cb4211a088fc1e33e0946a81d40377c40b5181b67f5ff36ddd7ee6';
|
|
30
|
+
const ROUTER_BUILT_HASH = '1235a251dfddcf3c336341b15e5016c6d46f560c98f0f65f3c64bd285db3fc84';
|
|
31
31
|
/**
|
|
32
32
|
* Pinned digests of the WASM cage package.
|
|
33
33
|
*
|
|
@@ -37,8 +37,8 @@ const ROUTER_BUILT_HASH = '502d309405265145cfb2cf39e28f044b088e36e6ac917ffa477a2
|
|
|
37
37
|
* produced since the cage was added, so the value below is a placeholder that
|
|
38
38
|
* a kernel build replaces.
|
|
39
39
|
*/
|
|
40
|
-
const WASM_CAGE_SOURCE_HASH = '
|
|
41
|
-
const WASM_CAGE_BUILT_HASH = '
|
|
40
|
+
const WASM_CAGE_SOURCE_HASH = '61feeb908475d4efaeb38f61f573c95c62401b72b443c232da0b08ed5d393109';
|
|
41
|
+
const WASM_CAGE_BUILT_HASH = '1702e4bccf7e7e8e3f24d243c05c01cb9fa974c59257bc7307a5660779a1c142';
|
|
42
42
|
/**
|
|
43
43
|
* Pinned digests of the events hardcore package.
|
|
44
44
|
*
|
|
@@ -48,9 +48,9 @@ const WASM_CAGE_BUILT_HASH = '579ec2449e6a73e28ea9c88095d7750f01b1eb787e729c5ef7
|
|
|
48
48
|
* placeholder that a kernel build replaces.
|
|
49
49
|
*/
|
|
50
50
|
/** Pinned digests of the interception package (recomputed with computePackageContentHash). */
|
|
51
|
-
const INTERCEPTION_SOURCE_HASH = '
|
|
52
|
-
const INTERCEPTION_BUILT_HASH = '
|
|
53
|
-
const EVENTS_SOURCE_HASH = '
|
|
51
|
+
const INTERCEPTION_SOURCE_HASH = '000cdceb69078df0b99eda3af34e7e25b96c48fd8295b76397bb8a70f4916a38';
|
|
52
|
+
const INTERCEPTION_BUILT_HASH = '1b50d79c2ff245a73dd01e6b834c690e5063271f072cecd9f91e2c0521729f36';
|
|
53
|
+
const EVENTS_SOURCE_HASH = 'd6966a6682b886c732002142d9d2446d96da5e47a370e20648c0130118a6312d';
|
|
54
54
|
const EVENTS_BUILT_HASH = 'b91fc7107e7c7ba65304262ffd6daf35dd7d5e2f64c6d8ec707db74348a41cfa';
|
|
55
55
|
/** Narrows an instance to the identity registry's boot surface. */
|
|
56
56
|
function asIdentityBootSurface(instance, token) {
|
|
@@ -105,7 +105,7 @@ export const HARDCORE_SERVICES = [
|
|
|
105
105
|
expectedContentHash: EXPOSED_API_REGISTRY_SOURCE_HASH,
|
|
106
106
|
expectedBuiltContentHash: EXPOSED_API_REGISTRY_BUILT_HASH,
|
|
107
107
|
contractVersion: '1.0.0',
|
|
108
|
-
contractInterface: ['register', 'resolve'],
|
|
108
|
+
contractInterface: ['lastRefusal', 'register', 'resolve'],
|
|
109
109
|
// Admission. Attaches the kernel's call authority and the composition's
|
|
110
110
|
// name pins, registers every exposure each participant's manifest declares
|
|
111
111
|
// under that participant's kernel identity, and seals the window before
|
|
@@ -231,7 +231,7 @@ export const HARDCORE_SERVICES = [
|
|
|
231
231
|
expectedContentHash: INTERCEPTION_SOURCE_HASH,
|
|
232
232
|
expectedBuiltContentHash: INTERCEPTION_BUILT_HASH,
|
|
233
233
|
contractVersion: '1.0.0',
|
|
234
|
-
contractInterface: ['evaluate', 'list'],
|
|
234
|
+
contractInterface: ['evaluate', 'evaluateResult', 'list'],
|
|
235
235
|
// Interception is a mechanism: the giver of an interception point and the
|
|
236
236
|
// admitted interceptors are the participants; the hardcore only pairs them
|
|
237
237
|
// at boot and runs the verdicts.
|