Prove cross-package application composition through public capabilities (WI-15)

This commit is contained in:
Timothy J. Aveni
2026-09-21 19:07:32 -07:00
parent d824634859
commit e5544dde21
6 changed files with 70 additions and 11 deletions
+41 -1
View File
@@ -56,7 +56,7 @@ test("reference-selected dependencies round trip and do not require a recursive
assert.ok(generated.includes('ManagedReference<"interface", "data@1">'));
assert.ok(generated.includes('"receiver"'));
});
test("both sides explicitly grant reference selection and only object snapshots are permitted", () => {
test("both sides explicitly grant reference selection and remote execution is excluded", () => {
assert.equal(compile(pkg, workspace.replace("Data from input", "Data")).ok, false);
assert.equal(compile(pkg.replace(" from input", ""), workspace).ok, false);
assert.equal(compile(pkg.replace("execution snapshot targets [server]", "execution remote"), workspace).ok, false);
@@ -88,3 +88,43 @@ test("portable input-selected reads require the dependency's declared target sup
const result = compile(portable, workspace, iface.replaceAll("targets [server]", "targets [browser, server]"));
assert.ok(result.ok, JSON.stringify(result.diagnostics));
});
test("input-selected transactions compose only within a compatible transaction contract", () => {
const txInterface = iface
.replace('get id "content:get" execution snapshot', 'get id "content:get" execution transaction')
.replace('call id "peek:call" execution snapshot', 'call id "peek:call" execution transaction');
const txPackage = pkg.replace("execution snapshot targets [server]", "execution transaction targets [server]");
// Use an operation for the selected write; value getters themselves must remain snapshots.
const contract = txInterface.replace(
'value content id "content" : string { get id "content:get" execution transaction targets [server]; }',
'operation update id "content" : unit -> string { call id "content:get" execution transaction targets [server]; }',
);
const implementation = txPackage.replace("using [content.get]", "using [update.call]");
const model = workspace.replace(
"bind content.get to state Content.read;",
"bind update.call to package Runtime.update with { data to state Content; };",
);
const sourcePackage = implementation.replace(
/\n}$/,
'\n operation update id "runtime:update" : unit -> string mode call execution transaction targets [server] receiver atom Item requires {state data id "data" : string [read,write];};\n}',
);
const result = compile(sourcePackage, model, contract);
assert.ok(result.ok, JSON.stringify(result.diagnostics));
const plan = compileExecutionPlan(result.workspace);
const generated = generatePortableTypeScriptBindings(plan.definition.bindingSchema, "runtime@1", {
target: "server",
});
assert.ok(generated.includes('"receiver"'));
assert.ok(generated.includes('"update.call"'));
assert.equal(
compile(
sourcePackage.replace(
'operation peek id "runtime:peek" : interface-ref<Data> -> string mode call execution transaction',
'operation peek id "runtime:peek" : interface-ref<Data> -> string mode call execution snapshot',
),
model,
contract,
).ok,
false,
);
});