@h-rig/kernel-seed 0.0.6-alpha.155 → 0.0.6-alpha.157
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 +19 -21
- package/dist/src/pluginAbi.d.ts +10 -22
- package/dist/src/pluginAbi.js +1 -1
- package/dist/src/resolveCapability.d.ts +4 -4
- package/dist/src/resolveCapability.js +14 -16
- package/dist/src/seed.js +18 -17
- package/package.json +2 -2
package/dist/src/index.js
CHANGED
|
@@ -30,9 +30,15 @@ async function assertJournalConformance(journal, runId = CONFORMANCE_RUN_ID) {
|
|
|
30
30
|
}
|
|
31
31
|
// packages/kernel-seed/src/pluginAbi.ts
|
|
32
32
|
function loadedPluginId(plugin) {
|
|
33
|
-
return plugin.
|
|
33
|
+
return plugin.name;
|
|
34
34
|
}
|
|
35
35
|
// packages/kernel-seed/src/resolveCapability.ts
|
|
36
|
+
function replacementMatches(spec, capability, providerId) {
|
|
37
|
+
if (typeof spec === "string")
|
|
38
|
+
return spec === `${capability}@${providerId}`;
|
|
39
|
+
return spec.capability === capability && spec.providerPluginId === providerId;
|
|
40
|
+
}
|
|
41
|
+
|
|
36
42
|
class AmbiguousCapabilityError extends Error {
|
|
37
43
|
capability;
|
|
38
44
|
providers;
|
|
@@ -53,15 +59,10 @@ class CapabilityProviderMissingError extends Error {
|
|
|
53
59
|
}
|
|
54
60
|
}
|
|
55
61
|
function capabilityValue(plugin, capability) {
|
|
56
|
-
|
|
57
|
-
const value = direct ?? (capability === "kernel" ? plugin.runtime.kernel : undefined) ?? plugin.runtime;
|
|
58
|
-
return value;
|
|
59
|
-
}
|
|
60
|
-
function replacementTarget(capability, providerId) {
|
|
61
|
-
return `${capability}@${providerId}`;
|
|
62
|
+
return plugin.capabilityProviders?.[capability];
|
|
62
63
|
}
|
|
63
64
|
function capabilityProviders(plugins, capability) {
|
|
64
|
-
return plugins.filter((plugin) => plugin.provides.
|
|
65
|
+
return plugins.filter((plugin) => (plugin.provides ?? []).includes(capability));
|
|
65
66
|
}
|
|
66
67
|
function byPrecedence(providers, precedence) {
|
|
67
68
|
if (!precedence || precedence.length === 0)
|
|
@@ -79,13 +80,10 @@ function providersAfterReplacement(capability, providers) {
|
|
|
79
80
|
const replaced = new Set;
|
|
80
81
|
for (const provider of providers) {
|
|
81
82
|
for (const replacement of provider.replaces ?? []) {
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
const replacementProviderId = replacement.slice(separator + 1);
|
|
87
|
-
if (replacementCapability === capability && providerIds.has(replacementProviderId)) {
|
|
88
|
-
replaced.add(replacementProviderId);
|
|
83
|
+
for (const candidateId of providerIds) {
|
|
84
|
+
if (replacementMatches(replacement, capability, candidateId)) {
|
|
85
|
+
replaced.add(candidateId);
|
|
86
|
+
}
|
|
89
87
|
}
|
|
90
88
|
}
|
|
91
89
|
}
|
|
@@ -124,7 +122,7 @@ function resolveCapability(plugins, capability, config = {}) {
|
|
|
124
122
|
throw new AmbiguousCapabilityError(capability, afterReplacement.providers.map(loadedPluginId).sort());
|
|
125
123
|
}
|
|
126
124
|
function declaresReplacement(plugin, capability, providerId) {
|
|
127
|
-
return (plugin.replaces ?? []).
|
|
125
|
+
return (plugin.replaces ?? []).some((spec) => replacementMatches(spec, capability, providerId));
|
|
128
126
|
}
|
|
129
127
|
// packages/kernel-seed/src/seed.ts
|
|
130
128
|
class BootIncoherent extends Error {
|
|
@@ -239,11 +237,11 @@ async function boot(config) {
|
|
|
239
237
|
kernel: composed,
|
|
240
238
|
plugins,
|
|
241
239
|
capabilityProviderIds: {
|
|
242
|
-
kernel: kernelResolution.plugin.
|
|
243
|
-
"stage-runner": stageRunnerResolution.plugin.
|
|
244
|
-
journal: journalResolution.plugin.
|
|
245
|
-
"loader-policy": loaderPolicyResolution.plugin.
|
|
246
|
-
transport: transportResolution.plugin.
|
|
240
|
+
kernel: kernelResolution.plugin.name,
|
|
241
|
+
"stage-runner": stageRunnerResolution.plugin.name,
|
|
242
|
+
journal: journalResolution.plugin.name,
|
|
243
|
+
"loader-policy": loaderPolicyResolution.plugin.name,
|
|
244
|
+
transport: transportResolution.plugin.name
|
|
247
245
|
}
|
|
248
246
|
};
|
|
249
247
|
}
|
package/dist/src/pluginAbi.d.ts
CHANGED
|
@@ -1,29 +1,17 @@
|
|
|
1
|
-
import type { CapabilityTag, KernelCapability } from "@rig/contracts";
|
|
2
|
-
export type
|
|
3
|
-
readonly
|
|
4
|
-
readonly name?: string;
|
|
1
|
+
import type { CapabilityReplacementSpec, CapabilityTag, KernelCapability } from "@rig/contracts";
|
|
2
|
+
export type CapabilityProviderPlugin = {
|
|
3
|
+
readonly name: string;
|
|
5
4
|
readonly version?: string;
|
|
6
|
-
|
|
7
|
-
export type CapabilityReplacement = `${CapabilityTag}@${string}`;
|
|
8
|
-
export type PluginContributions = Readonly<Record<string, unknown>>;
|
|
9
|
-
export type PluginRuntimeChannel = {
|
|
10
|
-
readonly capabilities?: Readonly<Record<string, unknown>>;
|
|
11
|
-
readonly kernel?: KernelCapability;
|
|
12
|
-
readonly [key: string]: unknown;
|
|
13
|
-
};
|
|
14
|
-
export type LoadedPlugin = {
|
|
15
|
-
readonly meta: PluginMeta;
|
|
16
|
-
readonly provides: ReadonlySet<CapabilityTag>;
|
|
5
|
+
readonly provides?: readonly CapabilityTag[];
|
|
17
6
|
readonly requires?: readonly CapabilityTag[];
|
|
18
|
-
readonly replaces?: readonly
|
|
19
|
-
readonly
|
|
20
|
-
readonly runtime: PluginRuntimeChannel;
|
|
7
|
+
readonly replaces?: readonly CapabilityReplacementSpec[];
|
|
8
|
+
readonly capabilityProviders?: Partial<Record<CapabilityTag, unknown>>;
|
|
21
9
|
};
|
|
22
10
|
export type CapabilityPrecedence = Partial<Record<CapabilityTag, readonly string[]>>;
|
|
23
11
|
export type CapabilityProviderIds = Readonly<Record<CapabilityTag, string>>;
|
|
24
12
|
export type ResolvedBootConfig = {
|
|
25
|
-
readonly plugins?: readonly
|
|
26
|
-
readonly loadPlugins?: () => Promise<readonly
|
|
13
|
+
readonly plugins?: readonly CapabilityProviderPlugin[];
|
|
14
|
+
readonly loadPlugins?: () => Promise<readonly CapabilityProviderPlugin[]> | readonly CapabilityProviderPlugin[];
|
|
27
15
|
readonly capabilityPrecedence?: CapabilityPrecedence;
|
|
28
16
|
/**
|
|
29
17
|
* When true, boot runs the behavioral journal-append conformance probe
|
|
@@ -36,7 +24,7 @@ export type ResolvedBootConfig = {
|
|
|
36
24
|
};
|
|
37
25
|
export type BootResult = {
|
|
38
26
|
readonly kernel: KernelCapability;
|
|
39
|
-
readonly plugins: readonly
|
|
27
|
+
readonly plugins: readonly CapabilityProviderPlugin[];
|
|
40
28
|
readonly capabilityProviderIds: CapabilityProviderIds;
|
|
41
29
|
};
|
|
42
|
-
export declare function loadedPluginId(plugin:
|
|
30
|
+
export declare function loadedPluginId(plugin: CapabilityProviderPlugin): string;
|
package/dist/src/pluginAbi.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { CapabilityTag } from "@rig/contracts";
|
|
2
|
-
import type { CapabilityPrecedence,
|
|
2
|
+
import type { CapabilityPrecedence, CapabilityProviderPlugin } from "./pluginAbi";
|
|
3
3
|
export type CapabilityResolution<T> = {
|
|
4
4
|
readonly capability: CapabilityTag;
|
|
5
|
-
readonly plugin:
|
|
5
|
+
readonly plugin: CapabilityProviderPlugin;
|
|
6
6
|
readonly value: T;
|
|
7
7
|
readonly selectedBy: "sole-provider" | "precedence" | "replaces";
|
|
8
8
|
readonly replacedProviders: readonly string[];
|
|
@@ -18,7 +18,7 @@ export declare class CapabilityProviderMissingError extends Error {
|
|
|
18
18
|
readonly name = "CapabilityProviderMissingError";
|
|
19
19
|
constructor(capability: CapabilityTag);
|
|
20
20
|
}
|
|
21
|
-
export declare function resolveCapability<T>(plugins: readonly
|
|
21
|
+
export declare function resolveCapability<T>(plugins: readonly CapabilityProviderPlugin[], capability: CapabilityTag, config?: {
|
|
22
22
|
readonly capabilityPrecedence?: CapabilityPrecedence;
|
|
23
23
|
}): CapabilityResolution<T> | null;
|
|
24
|
-
export declare function declaresReplacement(plugin:
|
|
24
|
+
export declare function declaresReplacement(plugin: CapabilityProviderPlugin, capability: CapabilityTag, providerId: string): boolean;
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
// packages/kernel-seed/src/pluginAbi.ts
|
|
3
3
|
function loadedPluginId(plugin) {
|
|
4
|
-
return plugin.
|
|
4
|
+
return plugin.name;
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
// packages/kernel-seed/src/resolveCapability.ts
|
|
8
|
+
function replacementMatches(spec, capability, providerId) {
|
|
9
|
+
if (typeof spec === "string")
|
|
10
|
+
return spec === `${capability}@${providerId}`;
|
|
11
|
+
return spec.capability === capability && spec.providerPluginId === providerId;
|
|
12
|
+
}
|
|
13
|
+
|
|
8
14
|
class AmbiguousCapabilityError extends Error {
|
|
9
15
|
capability;
|
|
10
16
|
providers;
|
|
@@ -25,15 +31,10 @@ class CapabilityProviderMissingError extends Error {
|
|
|
25
31
|
}
|
|
26
32
|
}
|
|
27
33
|
function capabilityValue(plugin, capability) {
|
|
28
|
-
|
|
29
|
-
const value = direct ?? (capability === "kernel" ? plugin.runtime.kernel : undefined) ?? plugin.runtime;
|
|
30
|
-
return value;
|
|
31
|
-
}
|
|
32
|
-
function replacementTarget(capability, providerId) {
|
|
33
|
-
return `${capability}@${providerId}`;
|
|
34
|
+
return plugin.capabilityProviders?.[capability];
|
|
34
35
|
}
|
|
35
36
|
function capabilityProviders(plugins, capability) {
|
|
36
|
-
return plugins.filter((plugin) => plugin.provides.
|
|
37
|
+
return plugins.filter((plugin) => (plugin.provides ?? []).includes(capability));
|
|
37
38
|
}
|
|
38
39
|
function byPrecedence(providers, precedence) {
|
|
39
40
|
if (!precedence || precedence.length === 0)
|
|
@@ -51,13 +52,10 @@ function providersAfterReplacement(capability, providers) {
|
|
|
51
52
|
const replaced = new Set;
|
|
52
53
|
for (const provider of providers) {
|
|
53
54
|
for (const replacement of provider.replaces ?? []) {
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const replacementProviderId = replacement.slice(separator + 1);
|
|
59
|
-
if (replacementCapability === capability && providerIds.has(replacementProviderId)) {
|
|
60
|
-
replaced.add(replacementProviderId);
|
|
55
|
+
for (const candidateId of providerIds) {
|
|
56
|
+
if (replacementMatches(replacement, capability, candidateId)) {
|
|
57
|
+
replaced.add(candidateId);
|
|
58
|
+
}
|
|
61
59
|
}
|
|
62
60
|
}
|
|
63
61
|
}
|
|
@@ -96,7 +94,7 @@ function resolveCapability(plugins, capability, config = {}) {
|
|
|
96
94
|
throw new AmbiguousCapabilityError(capability, afterReplacement.providers.map(loadedPluginId).sort());
|
|
97
95
|
}
|
|
98
96
|
function declaresReplacement(plugin, capability, providerId) {
|
|
99
|
-
return (plugin.replaces ?? []).
|
|
97
|
+
return (plugin.replaces ?? []).some((spec) => replacementMatches(spec, capability, providerId));
|
|
100
98
|
}
|
|
101
99
|
export {
|
|
102
100
|
resolveCapability,
|
package/dist/src/seed.js
CHANGED
|
@@ -31,10 +31,16 @@ async function assertJournalConformance(journal, runId = CONFORMANCE_RUN_ID) {
|
|
|
31
31
|
|
|
32
32
|
// packages/kernel-seed/src/pluginAbi.ts
|
|
33
33
|
function loadedPluginId(plugin) {
|
|
34
|
-
return plugin.
|
|
34
|
+
return plugin.name;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
// packages/kernel-seed/src/resolveCapability.ts
|
|
38
|
+
function replacementMatches(spec, capability, providerId) {
|
|
39
|
+
if (typeof spec === "string")
|
|
40
|
+
return spec === `${capability}@${providerId}`;
|
|
41
|
+
return spec.capability === capability && spec.providerPluginId === providerId;
|
|
42
|
+
}
|
|
43
|
+
|
|
38
44
|
class AmbiguousCapabilityError extends Error {
|
|
39
45
|
capability;
|
|
40
46
|
providers;
|
|
@@ -55,12 +61,10 @@ class CapabilityProviderMissingError extends Error {
|
|
|
55
61
|
}
|
|
56
62
|
}
|
|
57
63
|
function capabilityValue(plugin, capability) {
|
|
58
|
-
|
|
59
|
-
const value = direct ?? (capability === "kernel" ? plugin.runtime.kernel : undefined) ?? plugin.runtime;
|
|
60
|
-
return value;
|
|
64
|
+
return plugin.capabilityProviders?.[capability];
|
|
61
65
|
}
|
|
62
66
|
function capabilityProviders(plugins, capability) {
|
|
63
|
-
return plugins.filter((plugin) => plugin.provides.
|
|
67
|
+
return plugins.filter((plugin) => (plugin.provides ?? []).includes(capability));
|
|
64
68
|
}
|
|
65
69
|
function byPrecedence(providers, precedence) {
|
|
66
70
|
if (!precedence || precedence.length === 0)
|
|
@@ -78,13 +82,10 @@ function providersAfterReplacement(capability, providers) {
|
|
|
78
82
|
const replaced = new Set;
|
|
79
83
|
for (const provider of providers) {
|
|
80
84
|
for (const replacement of provider.replaces ?? []) {
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
const replacementProviderId = replacement.slice(separator + 1);
|
|
86
|
-
if (replacementCapability === capability && providerIds.has(replacementProviderId)) {
|
|
87
|
-
replaced.add(replacementProviderId);
|
|
85
|
+
for (const candidateId of providerIds) {
|
|
86
|
+
if (replacementMatches(replacement, capability, candidateId)) {
|
|
87
|
+
replaced.add(candidateId);
|
|
88
|
+
}
|
|
88
89
|
}
|
|
89
90
|
}
|
|
90
91
|
}
|
|
@@ -236,11 +237,11 @@ async function boot(config) {
|
|
|
236
237
|
kernel: composed,
|
|
237
238
|
plugins,
|
|
238
239
|
capabilityProviderIds: {
|
|
239
|
-
kernel: kernelResolution.plugin.
|
|
240
|
-
"stage-runner": stageRunnerResolution.plugin.
|
|
241
|
-
journal: journalResolution.plugin.
|
|
242
|
-
"loader-policy": loaderPolicyResolution.plugin.
|
|
243
|
-
transport: transportResolution.plugin.
|
|
240
|
+
kernel: kernelResolution.plugin.name,
|
|
241
|
+
"stage-runner": stageRunnerResolution.plugin.name,
|
|
242
|
+
journal: journalResolution.plugin.name,
|
|
243
|
+
"loader-policy": loaderPolicyResolution.plugin.name,
|
|
244
|
+
transport: transportResolution.plugin.name
|
|
244
245
|
}
|
|
245
246
|
};
|
|
246
247
|
}
|
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.157",
|
|
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.157"
|
|
37
37
|
}
|
|
38
38
|
}
|