Publish quixos-protocol from ca5b05584b89e90cb259b4596b1bc01d3d692136
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"version": 1,
|
"version": 1,
|
||||||
"sourceRepo": "https://gitea.internal.quixos.org/quixos/quixos.git",
|
"sourceRepo": "https://gitea.internal.quixos.org/quixos/quixos.git",
|
||||||
"sourceCommit": "6b91014ff1d6c9c54d0782f586935e694f9ee72f",
|
"sourceCommit": "ca5b05584b89e90cb259b4596b1bc01d3d692136",
|
||||||
"sourcePath": "quixos-protocol",
|
"sourcePath": "quixos-protocol",
|
||||||
"exportName": "quixos-protocol",
|
"exportName": "quixos-protocol",
|
||||||
"mirrorRemote": "https://gitea-external.egads.tutti.syntaxblitz.net/quixos/quixos-protocol.git"
|
"mirrorRemote": "https://repos.quixos.org/quixos-toolchain/quixos-protocol.git"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -407,12 +407,19 @@ pkgs.runCommand (if contractOnly then "qx-contract" else "qx-checked-candidate")
|
|||||||
${pkgs.nodejs_24}/bin/node ${./check-execution.mjs} \
|
${pkgs.nodejs_24}/bin/node ${./check-execution.mjs} \
|
||||||
${protocol}/libexec/quixos-protocol/execution-world.mjs \
|
${protocol}/libexec/quixos-protocol/execution-world.mjs \
|
||||||
"$out/execution-plan.json" "$out/checks.json" "$out"
|
"$out/execution-plan.json" "$out/checks.json" "$out"
|
||||||
mkdir -p "$out/bin"
|
# The optional development host is acquired only when explicitly run.
|
||||||
cat > "$out/bin/run-isolated" <<EOF
|
# Embedding its executable here made every source check build Web Studio
|
||||||
#!${pkgs.runtimeShell}
|
# and a full host even when only checked Package outputs were consumed.
|
||||||
exec ${runtimePackages.camino-isolated-workspace}/bin/camino-isolated-workspace "$out" "\$@"
|
cp ${
|
||||||
EOF
|
pkgs.writeText "qx-isolated-runtime.json" (
|
||||||
chmod +x "$out/bin/run-isolated"
|
builtins.toJSON {
|
||||||
|
codec = "quixos-isolated-runtime/1";
|
||||||
|
source = {
|
||||||
|
inherit (root.lock.quixos) repository commit;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
)
|
||||||
|
} "$out/isolated-runtime.json"
|
||||||
''}
|
''}
|
||||||
''}
|
''}
|
||||||
${pkgs.lib.optionalString (
|
${pkgs.lib.optionalString (
|
||||||
|
|||||||
@@ -41,15 +41,19 @@ export function presentationQueries(pkg: PackageRevision, interfaces: readonly I
|
|||||||
];
|
];
|
||||||
});
|
});
|
||||||
const stem = `PresentationNavigation${createHash("sha256").update(id).digest("hex").slice(0, 12)}`;
|
const stem = `PresentationNavigation${createHash("sha256").update(id).digest("hex").slice(0, 12)}`;
|
||||||
const inputs = `presentation:navigation:${id}:inputs`;
|
// Retain full state for operations and hidden occurrences, independently
|
||||||
for (const local of [false, true]) {
|
// from the identity projection used to prepare a rendering occurrence.
|
||||||
const name = `${stem}${local ? "View" : "Inputs"}`;
|
for (const identity of [false, true]) {
|
||||||
const document = `generated/${name}.graphql`;
|
const prefix = `presentation:navigation:${id}:${identity ? "identity-" : ""}`;
|
||||||
documents.set(
|
const inputs = prefix + "inputs";
|
||||||
document,
|
for (const local of [false, true]) {
|
||||||
`query ${name}($presentationMount: QxRef_PresentationMount!) {
|
const name = `${stem}${identity ? "Identity" : ""}${local ? "View" : "Inputs"}`;
|
||||||
|
const document = `generated/${name}.graphql`;
|
||||||
|
documents.set(
|
||||||
|
document,
|
||||||
|
`query ${name}($presentationMount: QxRef_PresentationMount!) {
|
||||||
root { ${local ? "availableObjects" : "objects"}(all:512, where:{_camino:{as:{PresentationState:{presentationMount:{eq:$presentationMount}}}}}) {
|
root { ${local ? "availableObjects" : "objects"}(all:512, where:{_camino:{as:{PresentationState:{presentationMount:{eq:$presentationMount}}}}}) {
|
||||||
entries { node { ${fields.join("\n")}
|
entries { node { ${identity ? "" : fields.join("\n")}
|
||||||
... on PresentationState {
|
... on PresentationState {
|
||||||
_presentationOccurrence: occurrence
|
_presentationOccurrence: occurrence
|
||||||
_presentationSource: source {_camino {ref}}
|
_presentationSource: source {_camino {ref}}
|
||||||
@@ -59,20 +63,21 @@ export function presentationQueries(pkg: PackageRevision, interfaces: readonly I
|
|||||||
} }
|
} }
|
||||||
} }
|
} }
|
||||||
}`,
|
}`,
|
||||||
);
|
);
|
||||||
generated.push({
|
generated.push({
|
||||||
id: local ? `presentation:navigation:${id}:view` : inputs,
|
id: local ? prefix + "view" : inputs,
|
||||||
displayName: name,
|
displayName: name,
|
||||||
root: { kind: "workspace-interface", interface: contract.revisionId },
|
root: { kind: "workspace-interface", interface: contract.revisionId },
|
||||||
document,
|
document,
|
||||||
operation: name,
|
operation: name,
|
||||||
fragments: [],
|
fragments: [],
|
||||||
views: [],
|
views: [],
|
||||||
allowances: [],
|
allowances: [],
|
||||||
budgets: { ...defaultQueryBudgets, rows: 5000, candidates: 5000, resultBytes: 8388608 },
|
budgets: { ...defaultQueryBudgets, rows: 5000, candidates: 5000, resultBytes: 8388608 },
|
||||||
watch: local,
|
watch: local,
|
||||||
placement: local ? { kind: "local", sourceQueryId: inputs } : { kind: "replica" },
|
placement: local ? { kind: "local", sourceQueryId: inputs } : { kind: "replica" },
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (const query of generated)
|
for (const query of generated)
|
||||||
|
|||||||
@@ -258,17 +258,7 @@ export function generatePackageComponentBindings(
|
|||||||
target.kind === "atom"
|
target.kind === "atom"
|
||||||
? `ManagedReference<"atom", ${JSON.stringify(target.atomId)}>`
|
? `ManagedReference<"atom", ${JSON.stringify(target.atomId)}>`
|
||||||
: `ManagedReference<"interface", ${JSON.stringify(target.interfaceRevisionId)}>`;
|
: `ManagedReference<"interface", ${JSON.stringify(target.interfaceRevisionId)}>`;
|
||||||
const fields =
|
return `{readonly reference: ${reference}}`;
|
||||||
target.kind === "interface"
|
|
||||||
? find(target.interfaceRevisionId).members.flatMap((member) => {
|
|
||||||
if ((member.kind !== "value" && member.kind !== "relationship") || !member.queryRead) return [];
|
|
||||||
const getter = member.operations.find(
|
|
||||||
(operation) => operation.displayName === (member.kind === "value" ? "get" : "resolve"),
|
|
||||||
);
|
|
||||||
return getter ? [`readonly ${JSON.stringify(member.displayName)}: ${tsType(getter.outputType)}`] : [];
|
|
||||||
})
|
|
||||||
: [];
|
|
||||||
return `{readonly reference: ${reference}; readonly values: {${fields.join(";")}}}`;
|
|
||||||
})
|
})
|
||||||
.join(",")}]`;
|
.join(",")}]`;
|
||||||
const interfaces = generateInterfaceClientBindings(imports, "@quixos/camino-react", props);
|
const interfaces = generateInterfaceClientBindings(imports, "@quixos/camino-react", props);
|
||||||
|
|||||||
+27
-5
@@ -113,6 +113,13 @@ export function lowerQueryTree(
|
|||||||
if (!root || selection.some((field) => field !== root))
|
if (!root || selection.some((field) => field !== root))
|
||||||
throw new QueryCompileError("QUERY_TREE_ROOT", "A Query Tree requires one unaliased root selection");
|
throw new QueryCompileError("QUERY_TREE_ROOT", "A Query Tree requires one unaliased root selection");
|
||||||
const plan: QueryTreePlan = { root: "root", nodes: [], projections: [], maxOccurrences: 0 };
|
const plan: QueryTreePlan = { root: "root", nodes: [], projections: [], maxOccurrences: 0 };
|
||||||
|
const collectionBound = (field: QuerySelection): number | undefined => {
|
||||||
|
const limit = field.arguments.first ?? field.arguments.all;
|
||||||
|
// Checked GraphQL Int literals retain their decimal spelling in the IR.
|
||||||
|
if (limit?.kind !== "literal" || !["string", "number"].includes(typeof limit.value)) return;
|
||||||
|
const value = Number(limit.value);
|
||||||
|
return Number.isSafeInteger(value) && value > 0 ? Math.min(value, declaration.budgets.rows) : undefined;
|
||||||
|
};
|
||||||
const project = (id: string, subject: InterfaceRevisionId, fields: QuerySelection[], shape: ValueType) => {
|
const project = (id: string, subject: InterfaceRevisionId, fields: QuerySelection[], shape: ValueType) => {
|
||||||
if (plan.projections.length >= 256)
|
if (plan.projections.length >= 256)
|
||||||
throw new QueryCompileError("QUERY_TREE_LIMIT", "Query Tree exceeds 256 projections");
|
throw new QueryCompileError("QUERY_TREE_LIMIT", "Query Tree exceeds 256 projections");
|
||||||
@@ -153,9 +160,15 @@ export function lowerQueryTree(
|
|||||||
for (const field of fields) {
|
for (const field of fields) {
|
||||||
if (field.boundary || !containsBoundary(field.selection)) continue;
|
if (field.boundary || !containsBoundary(field.selection)) continue;
|
||||||
const targets: { path: string[]; node: string }[] = [];
|
const targets: { path: string[]; node: string }[] = [];
|
||||||
const prune = (fields: QuerySelection[], shape: ValueType, path: string[], bound: number): QuerySelection[] => {
|
const prune = (
|
||||||
if (shape.kind === "optional") return prune(fields, shape.value, path, bound);
|
fields: QuerySelection[],
|
||||||
if (shape.kind === "list") return prune(fields, shape.value, [...path, "[]"], bound * declaration.budgets.rows);
|
shape: ValueType,
|
||||||
|
path: string[],
|
||||||
|
bound: number,
|
||||||
|
listLimit = declaration.budgets.rows,
|
||||||
|
): QuerySelection[] => {
|
||||||
|
if (shape.kind === "optional") return prune(fields, shape.value, path, bound, listLimit);
|
||||||
|
if (shape.kind === "list") return prune(fields, shape.value, [...path, "[]"], bound * listLimit);
|
||||||
const target = objectInterface(fields);
|
const target = objectInterface(fields);
|
||||||
if (target) {
|
if (target) {
|
||||||
targets.push({
|
targets.push({
|
||||||
@@ -168,7 +181,13 @@ export function lowerQueryTree(
|
|||||||
.filter((field) => containsBoundary(field.selection))
|
.filter((field) => containsBoundary(field.selection))
|
||||||
.map((field) => ({
|
.map((field) => ({
|
||||||
...field,
|
...field,
|
||||||
selection: prune(field.selection, fieldType(shape, field.key), [...path, field.key], bound),
|
selection: prune(
|
||||||
|
field.selection,
|
||||||
|
fieldType(shape, field.key),
|
||||||
|
[...path, field.key],
|
||||||
|
bound,
|
||||||
|
collectionBound(field) ?? listLimit,
|
||||||
|
),
|
||||||
}));
|
}));
|
||||||
// Relationship occurrence identity is its entry key, including duplicate
|
// Relationship occurrence identity is its entry key, including duplicate
|
||||||
// target Objects. Never substitute list position or Object identity.
|
// target Objects. Never substitute list position or Object identity.
|
||||||
@@ -177,7 +196,10 @@ export function lowerQueryTree(
|
|||||||
return minimal;
|
return minimal;
|
||||||
};
|
};
|
||||||
const type = fieldType(shape, field.key);
|
const type = fieldType(shape, field.key);
|
||||||
const minimal = { ...field, selection: prune(field.selection, type, [field.key], occurrences) };
|
const minimal = {
|
||||||
|
...field,
|
||||||
|
selection: prune(field.selection, type, [field.key], occurrences, collectionBound(field)),
|
||||||
|
};
|
||||||
const selected = [...identity(fields), minimal];
|
const selected = [...identity(fields), minimal];
|
||||||
current.bindings.push({
|
current.bindings.push({
|
||||||
name: field.key,
|
name: field.key,
|
||||||
|
|||||||
@@ -364,6 +364,9 @@ export async function expandPresentationQueries(workspace: WorkspaceRevision): P
|
|||||||
for (const pkg of workspace.packageImports) {
|
for (const pkg of workspace.packageImports) {
|
||||||
for (const original of [...(pkg.checkedQueries ?? [])]) {
|
for (const original of [...(pkg.checkedQueries ?? [])]) {
|
||||||
if (!original.declaration.id.startsWith("presentation:navigation:")) continue;
|
if (!original.declaration.id.startsWith("presentation:navigation:")) continue;
|
||||||
|
// Identity must remain independent of every occurrence's data projection.
|
||||||
|
// Full retained acquisition may include those requirements together.
|
||||||
|
if (/:identity-(inputs|view)$/.test(original.declaration.id)) continue;
|
||||||
const inputs = (stateInputs.get(original.declaration.root.interface) ?? []).map((input) => ({
|
const inputs = (stateInputs.get(original.declaration.root.interface) ?? []).map((input) => ({
|
||||||
...input,
|
...input,
|
||||||
query:
|
query:
|
||||||
|
|||||||
@@ -520,7 +520,7 @@ test("React tooling generates checked owner queries from imported closed navigat
|
|||||||
if (parsed.resource.kind !== "package") throw Error("package required");
|
if (parsed.resource.kind !== "package") throw Error("package required");
|
||||||
const contracts = [...dependencies, ...(parsed.resource.specializations ?? [])];
|
const contracts = [...dependencies, ...(parsed.resource.specializations ?? [])];
|
||||||
const documents = presentationQueries(parsed.resource.revision, contracts);
|
const documents = presentationQueries(parsed.resource.revision, contracts);
|
||||||
assert.equal(documents.size, 2);
|
assert.equal(documents.size, 4);
|
||||||
const checked = await Promise.all(
|
const checked = await Promise.all(
|
||||||
parsed.resource.revision.queries!.map((query) =>
|
parsed.resource.revision.queries!.map((query) =>
|
||||||
compileQuery(query, contracts, async (name) => documents.get(name)!),
|
compileQuery(query, contracts, async (name) => documents.get(name)!),
|
||||||
@@ -528,10 +528,16 @@ test("React tooling generates checked owner queries from imported closed navigat
|
|||||||
);
|
);
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
checked.map((query) => query.declaration.placement?.kind),
|
checked.map((query) => query.declaration.placement?.kind),
|
||||||
["replica", "local"],
|
["replica", "local", "replica", "local"],
|
||||||
);
|
);
|
||||||
assert.match(JSON.stringify(checked[0]!.output), /"custom":\{"kind":"record","fields":\{"label"/);
|
assert.match(JSON.stringify(checked[0]!.output), /"custom":\{"kind":"record","fields":\{"label"/);
|
||||||
assert.match(JSON.stringify(checked[0]!.selection), /"kind":"as"/);
|
assert.match(JSON.stringify(checked[0]!.selection), /"kind":"as"/);
|
||||||
|
for (const identity of checked.slice(2)) {
|
||||||
|
assert.match(identity.declaration.id, /:identity-(inputs|view)$/);
|
||||||
|
assert.doesNotMatch(JSON.stringify(identity.output), /"custom"/);
|
||||||
|
assert.match(JSON.stringify(identity.output), /_presentationOccurrence/);
|
||||||
|
assert.match(JSON.stringify(identity.output), /_presentationSource/);
|
||||||
|
}
|
||||||
assert(
|
assert(
|
||||||
checked.every((query) =>
|
checked.every((query) =>
|
||||||
query.effects.some((effect) => effect.memberId === "mount" && effect.uses.includes("predicate")),
|
query.effects.some((effect) => effect.memberId === "mount" && effect.uses.includes("predicate")),
|
||||||
|
|||||||
+43
-2
@@ -29,12 +29,15 @@ const navigation = iface(
|
|||||||
}`,
|
}`,
|
||||||
[item],
|
[item],
|
||||||
);
|
);
|
||||||
function declaration(root: InterfaceRevision = item) {
|
function declaration(root: InterfaceRevision = item, dependencies: InterfaceRevision[] = []) {
|
||||||
const result = compileCapabilityResourceSource(
|
const result = compileCapabilityResourceSource(
|
||||||
`import interface ${root.displayName}; package Views id "views" revision "views@1" {
|
`import interface ${root.displayName}; package Views id "views" revision "views@1" {
|
||||||
query Open id "open" root ${root.displayName} document "open.graphql" operation "Open" {replica; max rows 10;}
|
query Open id "open" root ${root.displayName} document "open.graphql" operation "Open" {replica; max rows 10;}
|
||||||
}`,
|
}`,
|
||||||
{ source, environment: { interfaces: new Map([[root.displayName, root]]), interfaceClosure: [root, item] } },
|
{
|
||||||
|
source,
|
||||||
|
environment: { interfaces: new Map([[root.displayName, root]]), interfaceClosure: [root, item, ...dependencies] },
|
||||||
|
},
|
||||||
);
|
);
|
||||||
assert.ok(result.ok, JSON.stringify(result.diagnostics));
|
assert.ok(result.ok, JSON.stringify(result.diagnostics));
|
||||||
if (result.resource.kind !== "package") throw Error("Expected Package");
|
if (result.resource.kind !== "package") throw Error("Expected Package");
|
||||||
@@ -103,6 +106,44 @@ test("bounded list bindings preserve entry identity without requesting details",
|
|||||||
assert(!JSON.stringify(projection.selection).includes('"name":"body"'));
|
assert(!JSON.stringify(projection.selection).includes('"name":"body"'));
|
||||||
assert(tree.maxOccurrences <= 256);
|
assert(tree.maxOccurrences <= 256);
|
||||||
});
|
});
|
||||||
|
test("literal collection windows bound handles independently of detail row budgets", async () => {
|
||||||
|
const source = { ...declaration(navigation), budgets: { ...declaration(navigation).budgets, rows: 20000 } };
|
||||||
|
const query = (limit: string, variables = "") => `query Open${variables} {root {
|
||||||
|
items(first: ${limit}) {entries {node {...Body @boundary(name:"body")}}}
|
||||||
|
}} fragment Body on Item {body}`;
|
||||||
|
const checked = await compileQuery(source, [item, navigation], async () => query("3"));
|
||||||
|
assert.equal(checked.tree!.maxOccurrences, 7);
|
||||||
|
await assert.rejects(
|
||||||
|
compileQuery(source, [item, navigation], async () => query("200")),
|
||||||
|
/QUERY_TREE_LIMIT/,
|
||||||
|
);
|
||||||
|
await assert.rejects(
|
||||||
|
compileQuery(source, [item, navigation], async () => query("$first", "($first:Int!)")),
|
||||||
|
/QUERY_TREE_LIMIT/,
|
||||||
|
);
|
||||||
|
const group = iface(
|
||||||
|
`import interface Item; interface Group id "group" revision "group@1" {
|
||||||
|
queryable relation items id "group:items" : many interface Item ordered {resolve id "group:items:resolve" execution snapshot;}
|
||||||
|
}`,
|
||||||
|
[item],
|
||||||
|
);
|
||||||
|
const groups = iface(
|
||||||
|
`import interface Group; interface Groups id "groups" revision "groups@1" {
|
||||||
|
queryable relation groups id "groups:groups" : many interface Group ordered {resolve id "groups:groups:resolve" execution snapshot;}
|
||||||
|
}`,
|
||||||
|
[item, group],
|
||||||
|
);
|
||||||
|
const nested = { ...declaration(groups, [group]), budgets: source.budgets };
|
||||||
|
const nestedQuery = (outer: number, inner: number) => `query Open {root {
|
||||||
|
groups(first:${outer}) {entries {node {items(first:${inner}) {entries {node {...Body @boundary(name:"body")}}}}}}
|
||||||
|
}} fragment Body on Item {body}`;
|
||||||
|
const bounded = await compileQuery(nested, [item, group, groups], async () => nestedQuery(2, 3));
|
||||||
|
assert.equal(bounded.tree!.maxOccurrences, 15, "Nested windows multiply instead of reusing the outer bound");
|
||||||
|
await assert.rejects(
|
||||||
|
compileQuery(nested, [item, group, groups], async () => nestedQuery(20, 20)),
|
||||||
|
/QUERY_TREE_LIMIT/,
|
||||||
|
);
|
||||||
|
});
|
||||||
test("guards control boundary participation and invalid syntax fails checking", async () => {
|
test("guards control boundary participation and invalid syntax fails checking", async () => {
|
||||||
const checked = await compileQuery(
|
const checked = await compileQuery(
|
||||||
declaration(),
|
declaration(),
|
||||||
|
|||||||
Reference in New Issue
Block a user