@h-rig/kernel-seed 0.0.6-alpha.136 → 0.0.6-alpha.137
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/dist/src/index.js +71 -9
- package/dist/src/journalConformance.js +2 -2
- package/dist/src/pluginAbi.d.ts +3 -0
- package/dist/src/seed.js +71 -9
- package/package.json +2 -2
package/dist/src/index.js
CHANGED
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
class JournalConformanceError extends Error {
|
|
4
4
|
name = "JournalConformanceError";
|
|
5
5
|
}
|
|
6
|
-
var CONFORMANCE_RUN_ID = "rig.
|
|
6
|
+
var CONFORMANCE_RUN_ID = "rig.run.__journal-conformance__";
|
|
7
7
|
function sampleResolvedPipeline() {
|
|
8
8
|
return {
|
|
9
9
|
order: ["validate", "merge-gate"],
|
|
10
10
|
record: [
|
|
11
11
|
{ stageId: "validate", contributedBy: "default", isProtected: false },
|
|
12
|
-
{ stageId: "merge-gate", contributedBy: "default", isProtected:
|
|
12
|
+
{ stageId: "merge-gate", contributedBy: "default", isProtected: false }
|
|
13
13
|
],
|
|
14
14
|
cycles: [],
|
|
15
15
|
grantUses: [],
|
|
@@ -143,6 +143,42 @@ function objectAt(value, key) {
|
|
|
143
143
|
function hasFunction(value, key) {
|
|
144
144
|
return value !== null && typeof value[key] === "function";
|
|
145
145
|
}
|
|
146
|
+
function assertSatisfiesStageRunnerInterface(value) {
|
|
147
|
+
if (!isRecord(value) || typeof value.resolve !== "function" || typeof value.runPipeline !== "function") {
|
|
148
|
+
throw new BootIncoherent("stage-runner provider must expose resolve and runPipeline");
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
function assertSatisfiesJournalInterface(value) {
|
|
152
|
+
if (!isRecord(value) || typeof value.append !== "function" || typeof value.recordPipeline !== "function" || typeof value.read !== "function") {
|
|
153
|
+
throw new BootIncoherent("journal provider must expose append, recordPipeline, and read");
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
function assertSatisfiesLoaderPolicyInterface(value) {
|
|
157
|
+
if (!isRecord(value) || typeof value.resolveCapability !== "function") {
|
|
158
|
+
throw new BootIncoherent("loader-policy provider must expose resolveCapability");
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
function assertSatisfiesTransportInterface(value) {
|
|
162
|
+
if (!isRecord(value) || typeof value.dispatch !== "function") {
|
|
163
|
+
throw new BootIncoherent("transport provider must expose dispatch");
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
function resolveRequiredCapability(plugins, capability, config, assertInterface) {
|
|
167
|
+
const resolution = resolveCapability(plugins, capability, config);
|
|
168
|
+
if (!resolution) {
|
|
169
|
+
throw new BootIncoherent(`no ${capability} provider resolved`);
|
|
170
|
+
}
|
|
171
|
+
assertInterface(resolution.value);
|
|
172
|
+
return resolution;
|
|
173
|
+
}
|
|
174
|
+
function assertSatisfiesKernelStartProvider(value) {
|
|
175
|
+
if (!isRecord(value)) {
|
|
176
|
+
throw new BootIncoherent("kernel provider did not return an object");
|
|
177
|
+
}
|
|
178
|
+
if (typeof value.start !== "function") {
|
|
179
|
+
throw new BootIncoherent("kernel provider must expose start");
|
|
180
|
+
}
|
|
181
|
+
}
|
|
146
182
|
function assertSatisfiesKernelInterface(value) {
|
|
147
183
|
if (!isRecord(value)) {
|
|
148
184
|
throw new BootIncoherent("kernel provider did not return an object");
|
|
@@ -175,15 +211,41 @@ async function loadPlugins(config) {
|
|
|
175
211
|
}
|
|
176
212
|
async function boot(config) {
|
|
177
213
|
const plugins = await loadPlugins(config);
|
|
178
|
-
const
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
214
|
+
const kernelResolution = resolveRequiredCapability(plugins, "kernel", config, assertSatisfiesKernelStartProvider);
|
|
215
|
+
const stageRunnerResolution = resolveRequiredCapability(plugins, "stage-runner", config, assertSatisfiesStageRunnerInterface);
|
|
216
|
+
const journalResolution = resolveRequiredCapability(plugins, "journal", config, assertSatisfiesJournalInterface);
|
|
217
|
+
const loaderPolicyResolution = resolveRequiredCapability(plugins, "loader-policy", config, assertSatisfiesLoaderPolicyInterface);
|
|
218
|
+
const transportResolution = resolveRequiredCapability(plugins, "transport", config, assertSatisfiesTransportInterface);
|
|
219
|
+
const kernel = kernelResolution.value;
|
|
220
|
+
const stageRunner = stageRunnerResolution.value;
|
|
221
|
+
const journal = journalResolution.value;
|
|
222
|
+
const loaderPolicy = loaderPolicyResolution.value;
|
|
223
|
+
const transport = transportResolution.value;
|
|
224
|
+
const composed = {
|
|
225
|
+
...kernel,
|
|
226
|
+
stageRunner,
|
|
227
|
+
journal,
|
|
228
|
+
loaderPolicy,
|
|
229
|
+
transport,
|
|
230
|
+
start(loadedPlugins) {
|
|
231
|
+
return kernel.start.call(composed, loadedPlugins);
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
assertSatisfiesKernelInterface(composed);
|
|
183
235
|
if (config.verifyJournalConformance === true) {
|
|
184
|
-
await assertJournalConformance(
|
|
236
|
+
await assertJournalConformance(composed.journal);
|
|
185
237
|
}
|
|
186
|
-
return {
|
|
238
|
+
return {
|
|
239
|
+
kernel: composed,
|
|
240
|
+
plugins,
|
|
241
|
+
capabilityProviderIds: {
|
|
242
|
+
kernel: kernelResolution.plugin.meta.id,
|
|
243
|
+
"stage-runner": stageRunnerResolution.plugin.meta.id,
|
|
244
|
+
journal: journalResolution.plugin.meta.id,
|
|
245
|
+
"loader-policy": loaderPolicyResolution.plugin.meta.id,
|
|
246
|
+
transport: transportResolution.plugin.meta.id
|
|
247
|
+
}
|
|
248
|
+
};
|
|
187
249
|
}
|
|
188
250
|
export {
|
|
189
251
|
resolveCapability,
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
class JournalConformanceError extends Error {
|
|
4
4
|
name = "JournalConformanceError";
|
|
5
5
|
}
|
|
6
|
-
var CONFORMANCE_RUN_ID = "rig.
|
|
6
|
+
var CONFORMANCE_RUN_ID = "rig.run.__journal-conformance__";
|
|
7
7
|
function sampleResolvedPipeline() {
|
|
8
8
|
return {
|
|
9
9
|
order: ["validate", "merge-gate"],
|
|
10
10
|
record: [
|
|
11
11
|
{ stageId: "validate", contributedBy: "default", isProtected: false },
|
|
12
|
-
{ stageId: "merge-gate", contributedBy: "default", isProtected:
|
|
12
|
+
{ stageId: "merge-gate", contributedBy: "default", isProtected: false }
|
|
13
13
|
],
|
|
14
14
|
cycles: [],
|
|
15
15
|
grantUses: [],
|
package/dist/src/pluginAbi.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export type PluginContributions = Readonly<Record<string, unknown>>;
|
|
|
9
9
|
export type PluginRuntimeChannel = {
|
|
10
10
|
readonly capabilities?: Readonly<Record<string, unknown>>;
|
|
11
11
|
readonly kernel?: KernelCapability;
|
|
12
|
+
readonly [key: string]: unknown;
|
|
12
13
|
};
|
|
13
14
|
export type LoadedPlugin = {
|
|
14
15
|
readonly meta: PluginMeta;
|
|
@@ -19,6 +20,7 @@ export type LoadedPlugin = {
|
|
|
19
20
|
readonly runtime: PluginRuntimeChannel;
|
|
20
21
|
};
|
|
21
22
|
export type CapabilityPrecedence = Partial<Record<CapabilityTag, readonly string[]>>;
|
|
23
|
+
export type CapabilityProviderIds = Readonly<Record<CapabilityTag, string>>;
|
|
22
24
|
export type ResolvedBootConfig = {
|
|
23
25
|
readonly plugins?: readonly LoadedPlugin[];
|
|
24
26
|
readonly loadPlugins?: () => Promise<readonly LoadedPlugin[]> | readonly LoadedPlugin[];
|
|
@@ -35,5 +37,6 @@ export type ResolvedBootConfig = {
|
|
|
35
37
|
export type BootResult = {
|
|
36
38
|
readonly kernel: KernelCapability;
|
|
37
39
|
readonly plugins: readonly LoadedPlugin[];
|
|
40
|
+
readonly capabilityProviderIds: CapabilityProviderIds;
|
|
38
41
|
};
|
|
39
42
|
export declare function loadedPluginId(plugin: LoadedPlugin): string;
|
package/dist/src/seed.js
CHANGED
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
class JournalConformanceError extends Error {
|
|
4
4
|
name = "JournalConformanceError";
|
|
5
5
|
}
|
|
6
|
-
var CONFORMANCE_RUN_ID = "rig.
|
|
6
|
+
var CONFORMANCE_RUN_ID = "rig.run.__journal-conformance__";
|
|
7
7
|
function sampleResolvedPipeline() {
|
|
8
8
|
return {
|
|
9
9
|
order: ["validate", "merge-gate"],
|
|
10
10
|
record: [
|
|
11
11
|
{ stageId: "validate", contributedBy: "default", isProtected: false },
|
|
12
|
-
{ stageId: "merge-gate", contributedBy: "default", isProtected:
|
|
12
|
+
{ stageId: "merge-gate", contributedBy: "default", isProtected: false }
|
|
13
13
|
],
|
|
14
14
|
cycles: [],
|
|
15
15
|
grantUses: [],
|
|
@@ -140,6 +140,42 @@ function objectAt(value, key) {
|
|
|
140
140
|
function hasFunction(value, key) {
|
|
141
141
|
return value !== null && typeof value[key] === "function";
|
|
142
142
|
}
|
|
143
|
+
function assertSatisfiesStageRunnerInterface(value) {
|
|
144
|
+
if (!isRecord(value) || typeof value.resolve !== "function" || typeof value.runPipeline !== "function") {
|
|
145
|
+
throw new BootIncoherent("stage-runner provider must expose resolve and runPipeline");
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
function assertSatisfiesJournalInterface(value) {
|
|
149
|
+
if (!isRecord(value) || typeof value.append !== "function" || typeof value.recordPipeline !== "function" || typeof value.read !== "function") {
|
|
150
|
+
throw new BootIncoherent("journal provider must expose append, recordPipeline, and read");
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
function assertSatisfiesLoaderPolicyInterface(value) {
|
|
154
|
+
if (!isRecord(value) || typeof value.resolveCapability !== "function") {
|
|
155
|
+
throw new BootIncoherent("loader-policy provider must expose resolveCapability");
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
function assertSatisfiesTransportInterface(value) {
|
|
159
|
+
if (!isRecord(value) || typeof value.dispatch !== "function") {
|
|
160
|
+
throw new BootIncoherent("transport provider must expose dispatch");
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
function resolveRequiredCapability(plugins, capability, config, assertInterface) {
|
|
164
|
+
const resolution = resolveCapability(plugins, capability, config);
|
|
165
|
+
if (!resolution) {
|
|
166
|
+
throw new BootIncoherent(`no ${capability} provider resolved`);
|
|
167
|
+
}
|
|
168
|
+
assertInterface(resolution.value);
|
|
169
|
+
return resolution;
|
|
170
|
+
}
|
|
171
|
+
function assertSatisfiesKernelStartProvider(value) {
|
|
172
|
+
if (!isRecord(value)) {
|
|
173
|
+
throw new BootIncoherent("kernel provider did not return an object");
|
|
174
|
+
}
|
|
175
|
+
if (typeof value.start !== "function") {
|
|
176
|
+
throw new BootIncoherent("kernel provider must expose start");
|
|
177
|
+
}
|
|
178
|
+
}
|
|
143
179
|
function assertSatisfiesKernelInterface(value) {
|
|
144
180
|
if (!isRecord(value)) {
|
|
145
181
|
throw new BootIncoherent("kernel provider did not return an object");
|
|
@@ -172,15 +208,41 @@ async function loadPlugins(config) {
|
|
|
172
208
|
}
|
|
173
209
|
async function boot(config) {
|
|
174
210
|
const plugins = await loadPlugins(config);
|
|
175
|
-
const
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
211
|
+
const kernelResolution = resolveRequiredCapability(plugins, "kernel", config, assertSatisfiesKernelStartProvider);
|
|
212
|
+
const stageRunnerResolution = resolveRequiredCapability(plugins, "stage-runner", config, assertSatisfiesStageRunnerInterface);
|
|
213
|
+
const journalResolution = resolveRequiredCapability(plugins, "journal", config, assertSatisfiesJournalInterface);
|
|
214
|
+
const loaderPolicyResolution = resolveRequiredCapability(plugins, "loader-policy", config, assertSatisfiesLoaderPolicyInterface);
|
|
215
|
+
const transportResolution = resolveRequiredCapability(plugins, "transport", config, assertSatisfiesTransportInterface);
|
|
216
|
+
const kernel = kernelResolution.value;
|
|
217
|
+
const stageRunner = stageRunnerResolution.value;
|
|
218
|
+
const journal = journalResolution.value;
|
|
219
|
+
const loaderPolicy = loaderPolicyResolution.value;
|
|
220
|
+
const transport = transportResolution.value;
|
|
221
|
+
const composed = {
|
|
222
|
+
...kernel,
|
|
223
|
+
stageRunner,
|
|
224
|
+
journal,
|
|
225
|
+
loaderPolicy,
|
|
226
|
+
transport,
|
|
227
|
+
start(loadedPlugins) {
|
|
228
|
+
return kernel.start.call(composed, loadedPlugins);
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
assertSatisfiesKernelInterface(composed);
|
|
180
232
|
if (config.verifyJournalConformance === true) {
|
|
181
|
-
await assertJournalConformance(
|
|
233
|
+
await assertJournalConformance(composed.journal);
|
|
182
234
|
}
|
|
183
|
-
return {
|
|
235
|
+
return {
|
|
236
|
+
kernel: composed,
|
|
237
|
+
plugins,
|
|
238
|
+
capabilityProviderIds: {
|
|
239
|
+
kernel: kernelResolution.plugin.meta.id,
|
|
240
|
+
"stage-runner": stageRunnerResolution.plugin.meta.id,
|
|
241
|
+
journal: journalResolution.plugin.meta.id,
|
|
242
|
+
"loader-policy": loaderPolicyResolution.plugin.meta.id,
|
|
243
|
+
transport: transportResolution.plugin.meta.id
|
|
244
|
+
}
|
|
245
|
+
};
|
|
184
246
|
}
|
|
185
247
|
export {
|
|
186
248
|
boot,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@h-rig/kernel-seed",
|
|
3
|
-
"version": "0.0.6-alpha.
|
|
3
|
+
"version": "0.0.6-alpha.137",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Irreducible Rig bootstrap seed, plugin ABI, and capability resolver.",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -33,6 +33,6 @@
|
|
|
33
33
|
"module": "./dist/src/index.js",
|
|
34
34
|
"types": "./dist/src/index.d.ts",
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@rig/contracts": "npm:@h-rig/contracts@0.0.6-alpha.
|
|
36
|
+
"@rig/contracts": "npm:@h-rig/contracts@0.0.6-alpha.137"
|
|
37
37
|
}
|
|
38
38
|
}
|