Define plugin sidecar ABI contract

This commit is contained in:
Meta Vens 2026-07-09 02:24:29 +01:00
commit f505b7e86c
16 changed files with 304 additions and 23 deletions

View file

@ -24,6 +24,7 @@ if (!exportDirectory) {
" --expect-plugin-runtime <pluginId:invocationModel>",
" --expect-plugin-runtime-transport <pluginId:transport>",
" --expect-plugin-runtime-authority <pluginId:authority>",
" --expect-plugin-runtime-field <pluginId:field.path:value>",
" --expect-plugin-handoff <pluginId>",
" --expect-provider-surface <providerId:surfaceId>",
" --expect-provider-surface-kind <providerId:surfaceId:surfaceKind>",
@ -189,6 +190,17 @@ function validateIndex(index, directory, expectations, errors) {
errors.push(`plugins:${expectation.pluginId}:runtime.authority:${expectation.authority}:missing`);
}
}
for (const expectation of expectations.pluginRuntimeFields) {
const plugin = plugins.find(candidate => candidate.pluginId === expectation.pluginId);
if (!plugin) {
errors.push(`plugins:${expectation.pluginId}:missing`);
continue;
}
const actual = readNestedField(plugin.runtimeBoundary, expectation.fieldPath);
if (actual !== expectation.value) {
errors.push(`plugins:${expectation.pluginId}:runtime.${expectation.fieldPath}:expected ${expectation.value} got ${actual || ""}`);
}
}
for (const expectedPlugin of expectations.pluginHandoffs) {
const plugin = plugins.find(candidate => candidate.pluginId === expectedPlugin);
if (!plugin) {
@ -497,6 +509,7 @@ function parseArguments(args) {
pluginRuntimes: [],
pluginRuntimeTransports: [],
pluginRuntimeAuthorities: [],
pluginRuntimeFields: [],
pluginHandoffs: [],
providers: [],
providerSurfaces: [],
@ -535,6 +548,7 @@ function parseArguments(args) {
["--expect-plugin-runtime", expectations.pluginRuntimes],
["--expect-plugin-runtime-transport", expectations.pluginRuntimeTransports],
["--expect-plugin-runtime-authority", expectations.pluginRuntimeAuthorities],
["--expect-plugin-runtime-field", expectations.pluginRuntimeFields],
["--expect-plugin-handoff", expectations.pluginHandoffs],
["--expect-provider-surface", expectations.providerSurfaces],
["--expect-provider-surface-kind", expectations.providerSurfaceKinds],
@ -585,6 +599,8 @@ function parseArguments(args) {
target.push(parsePluginExpectation(value, "transport"));
} else if (option === "--expect-plugin-runtime-authority") {
target.push(parsePluginExpectation(value, "authority"));
} else if (option === "--expect-plugin-runtime-field") {
target.push(parsePluginRuntimeFieldExpectation(value));
} else if (option === "--expect-plugin-handoff") {
target.push(value);
} else if (option === "--expect-provider-surface") {
@ -640,6 +656,19 @@ function parsePluginExpectation(value, field) {
};
}
function parsePluginRuntimeFieldExpectation(value) {
const parts = value.split(":");
if (parts.length < 3 || !parts[0] || !parts[1] || !parts.slice(2).join(":")) {
console.error(`Expected plugin runtime field in <pluginId:field.path:value> form, got: ${value}`);
process.exit(2);
}
return {
pluginId: parts[0],
fieldPath: parts[1],
value: parts.slice(2).join(":"),
};
}
function parseProviderExpectation(value, field) {
const separator = value.indexOf(":");
if (separator <= 0 || separator === value.length - 1) {