Keep checked execution groups and public catalog preparation cooperative

This commit is contained in:
Timothy J. Aveni
2026-10-12 19:21:34 -07:00
parent a4ba6169a6
commit 47b316180d
6 changed files with 243 additions and 228 deletions
+8 -8
View File
@@ -45,7 +45,7 @@ const prepare = async (workspace: WorkspaceRevision) => {
test("execution reuse ignores world/source/display changes and unrelated packages", async () => {
const workspace = await loadReaderWorkspace(),
original = await prepare(workspace);
const before = original.groups()[0]!.executionDigest;
const before = (await original.groups())[0]!.executionDigest;
workspace.sourceRootCommit = "f".repeat(40);
workspace.packageImports[0]!.displayName = "Renamed";
workspace.packageImports[0]!.source.commit = "e".repeat(40);
@@ -59,13 +59,13 @@ test("execution reuse ignores world/source/display changes and unrelated package
const after = await prepare(workspace);
assert.notEqual(after.plan.digest, original.plan.digest);
assert.equal(
after.groups().find((g) => g.logicalId === workspace.packageImports[0]!.packageId)!.executionDigest,
(await after.groups()).find((g) => g.logicalId === workspace.packageImports[0]!.packageId)!.executionDigest,
before,
);
original.environments[workspace.packageImports[0]!.revisionId]!.credentialGeneration = "config:2";
assert.notEqual(original.groups()[0]!.executionDigest, before);
assert.notEqual((await original.groups())[0]!.executionDigest, before);
original.environments[workspace.packageImports[0]!.revisionId]!.placement = "module";
assert.notEqual(original.groups()[0]!.executionDigest, before);
assert.notEqual((await original.groups())[0]!.executionDigest, before);
});
test("outbound provider changes invalidate consumers while caller changes preserve providers", async () => {
@@ -108,15 +108,15 @@ test("outbound provider changes invalidate consumers while caller changes preser
dependencies: [{ portId, binding: { kind: "state", slotId: id.slot("slot:document:content") } }],
};
const prepared = await prepare(workspace);
const values = () => new Map(prepared.groups().map((g) => [g.logicalId, g.executionDigest]));
const before = values();
const values = async () => new Map((await prepared.groups()).map((g) => [g.logicalId, g.executionDigest]));
const before = await values();
prepared.installation.packages.find((p) => p.revision === "package:reader-runtime@1")!.service!.contentDigest =
"c".repeat(64);
const callerChanged = values();
const callerChanged = await values();
assert.equal(callerChanged.get("provider"), before.get("provider"));
assert.notEqual(callerChanged.get("package:reader-runtime"), before.get("package:reader-runtime"));
prepared.installation.packages.find((p) => p.revision === revision)!.service!.contentDigest = "d".repeat(64);
const providerChanged = values();
const providerChanged = await values();
assert.notEqual(providerChanged.get("provider"), callerChanged.get("provider"));
assert.notEqual(providerChanged.get("package:reader-runtime"), callerChanged.get("package:reader-runtime"));
});
+16 -3
View File
@@ -7,6 +7,7 @@ import {
checkExecutionWorld,
checkedWorldDigest,
implementationDigest,
clientContractCatalog,
hexDigest,
parsePackageArtifacts,
artifactPath,
@@ -386,7 +387,13 @@ test("public reflection contains nominal contracts and callable descriptors with
routes: {},
};
const kernel = compileKernelProgram(plan) as import("../src/execution-world/inspection.js").InspectionKernel;
const snapshot = publicDefinitionSnapshot(plan, installation, kernel);
const catalog = await clientContractCatalog(
plan,
installation,
installation.packages.map((pkg) => pkg.revision),
kernel,
);
const snapshot = await publicDefinitionSnapshot(plan, kernel, catalog);
assert.ok(snapshot.rows.interfaces.length);
assert.ok(snapshot.rows.queries.length);
assert.ok(snapshot.rows.conformances.length);
@@ -401,13 +408,19 @@ test("public reflection contains nominal contracts and callable descriptors with
assert.ok(!publicText.includes('"' + privateKey + '"'), privateKey);
assert.ok(publicText.includes('"descriptor"'));
assert.ok(publicText.includes('"scope":"class"'));
assert.equal(snapshot.id, publicDefinitionSnapshot(plan, installation, kernel).id);
assert.equal(snapshot.id, (await publicDefinitionSnapshot(plan, kernel, catalog)).id);
// Historical checked availability must survive a newer host compiler. If
// reflection silently regenerates the Kernel, this evidence disappears.
const historical = structuredClone(kernel);
const installed = historical.operations.find((operation) => !operation.unsupported)!;
assert.ok(installed);
installed.unsupported = "CHECKED_HISTORICAL_UNSUPPORTED";
const historicalSnapshot = publicDefinitionSnapshot(plan, installation, historical);
const historicalCatalog = await clientContractCatalog(
plan,
installation,
installation.packages.map((pkg) => pkg.revision),
historical,
);
const historicalSnapshot = await publicDefinitionSnapshot(plan, historical, historicalCatalog);
assert.match(JSON.stringify(historicalSnapshot.rows.conformances), /CHECKED_HISTORICAL_UNSUPPORTED/);
});
+12 -10
View File
@@ -249,13 +249,13 @@ test("checked component-only artifacts install without a service and reject miss
assert.ok(installation.routes[installation.components[0]!.url]);
assert.equal(JSON.stringify(installation.components).includes(root), false);
assert.equal(JSON.stringify(installation.components).includes("slot:"), false);
const catalog = clientContractCatalog(plan, installation, [pkg.revision]);
const catalog = await clientContractCatalog(plan, installation, [pkg.revision]);
assert.equal(catalog.presentations[0]!.component, "component:card");
assert.equal(catalog.components[0]!.subject, "interface:Data@1");
assert.equal(JSON.stringify(catalog).includes(root), false);
assert.equal(JSON.stringify(catalog).includes("bindingSchema"), false);
assert.throws(() => clientContractCatalog(plan, installation, ["absent"]), /UNINSTALLED_PACKAGE/);
assert.throws(
await assert.rejects(() => clientContractCatalog(plan, installation, ["absent"]), /UNINSTALLED_PACKAGE/);
await assert.rejects(
() => clientContractCatalog(plan, { ...installation, plan: "bad" }, [pkg.revision]),
/CATALOG_PLAN_MISMATCH/,
);
@@ -268,14 +268,16 @@ test("checked component-only artifacts install without a service and reject miss
compileKernelProgram(plan) as InspectionKernel,
);
try {
assert.throws(() => prepared.select(["absent"]), /UNINSTALLED_PACKAGE/);
await assert.rejects(() => prepared.select(["absent"]), /UNINSTALLED_PACKAGE/);
assert.equal(scope.bytes, 0, "Unknown requests do not allocate compiler metadata");
assert.deepEqual(prepared.select([pkg.revision]), catalog);
const [first, coalesced] = await Promise.all([prepared.select([pkg.revision]), prepared.select([pkg.revision])]);
assert.deepEqual(first, catalog);
assert.equal(first.operations, coalesced.operations, "Concurrent preparation shares one metadata reservation");
const retained = scope.bytes;
assert.ok(retained > 0);
assert.ok(retained < 32 * 1024 * 1024, "Small catalogs retain a proportional metadata charge");
const full = prepared.select([pkg.revision]);
const empty = prepared.select([]);
const full = await prepared.select([pkg.revision]);
const empty = await prepared.select([]);
assert.deepEqual(empty.components, []);
assert.deepEqual(empty.presentations, []);
assert.deepEqual(empty.moduleBindings, []);
@@ -290,14 +292,14 @@ test("checked component-only artifacts install without a service and reject miss
},
});
try {
assert.deepEqual(prepared.select([pkg.revision]), full);
assert.deepEqual(await prepared.select([pkg.revision]), full);
assert.equal(scope.bytes, retained, "Package projections do not accumulate cache entries");
} finally {
Object.defineProperty(plan, "definition", { configurable: true, value: definition });
}
prepared.close();
assert.equal(scope.bytes, 0);
assert.throws(() => prepared.select([pkg.revision]), /CANDIDATE_METADATA_CLOSED/);
await assert.rejects(() => prepared.select([pkg.revision]), /CANDIDATE_METADATA_CLOSED/);
} finally {
prepared.close();
scope.release();
@@ -305,7 +307,7 @@ test("checked component-only artifacts install without a service and reject miss
const tight = new CandidateMetadataBudget({ bytes: 1000, ownerBytes: 1000, candidates: 1 });
const tightScope = tight.acquire("catalog-test");
const refused = createClientContractCatalog(plan, installation, tightScope);
assert.throws(() => refused.select([pkg.revision]), /CANDIDATE_METADATA_LIMIT/);
await assert.rejects(() => refused.select([pkg.revision]), /CANDIDATE_METADATA_LIMIT/);
assert.equal(tightScope.bytes, 0);
refused.close();
tightScope.release();