Add local-first execution contracts to the capability language

This commit is contained in:
Timothy J. Aveni
2026-09-19 22:09:40 -07:00
parent 757531bb63
commit 03ac7f8557
24 changed files with 3872 additions and 2760 deletions
+17
View File
@@ -128,6 +128,23 @@ export async function compileQuery(
const member = contract.members.find((entry) => entry.displayName === name);
if (!member || member.kind === "operation" || !member.queryRead)
return fail("QUERY_FIELD_NOT_QUERYABLE", `${contract.displayName}.${name} is not queryable`, node);
if (declaration.placement?.kind === "local") {
const getter = member.operations.find(
(operation) => operation.displayName === (member.kind === "value" ? "get" : "resolve"),
);
if (getter?.execution?.kind !== "snapshot" || !getter.execution.targets.includes("browser"))
fail(
"QUERY_LOCAL_DEPENDENCY",
`Local query requires a browser snapshot getter for ${contract.displayName}.${name}; split the remote field or move the query to the server`,
node,
);
if (member.queryRead.execution === "rpc-permitted")
fail(
"QUERY_LOCAL_DEPENDENCY",
`Local query cannot include remote-compute field ${contract.displayName}.${name}`,
node,
);
}
const key = `${id}\0${member.id}`;
const effect = effects.get(key) ?? {
interfaceRevisionId: id,