Expose closed module types and define stable presentation occurrences

This commit is contained in:
Timothy J. Aveni
2026-09-25 11:37:27 -07:00
parent a83239892c
commit e0e8563224
5 changed files with 54 additions and 1 deletions
+25
View File
@@ -211,3 +211,28 @@ test("unrecognized module consumers fail before artifact execution, not during i
/No artifact consumer.*example.device.firmware/,
);
});
test("artifact consumers receive checked closed role arguments and prerequisites", async () => {
const { moduleTypeContext } = await import("../src/execution-world/module-contracts.js");
const { generateInterfaceClientBindings } = await import("../src/execution-world/client-contracts.js");
const result = compile();
assert.ok(result.ok, JSON.stringify(result.diagnostics));
const role = result.workspace.interfaceImports.find((iface) => iface.application)!;
const expected = [{ kind: "object", target: { kind: "interface", interfaceRevisionId: "interface:data@1" } }];
assert.deepEqual(moduleTypeContext(role), { typeArguments: expected });
const plan = compileExecutionPlan(result.workspace);
assert.deepEqual(
plan.definition.packages[0]!.modules!.find((module) => module.displayName === "Editor")!.typeArguments,
expected,
);
assert.match(generateInterfaceClientBindings({ Editor: role }), /"typeArguments":\[/);
assert.deepEqual(moduleTypeContext(interfaces.get("Row")!), {});
// Prerequisites are public nominal contracts, never private storage inventory.
assert.deepEqual(
moduleTypeContext({
...role,
requiredInterfaces: [capabilityId.interfaceRevision("z"), capabilityId.interfaceRevision("a")],
}).requiredInterfaces,
["a", "z"],
);
});