Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0443992dd4 | |||
| 9248332da6 | |||
| b633a91a41 | |||
| 192a22c936 |
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"version": 1,
|
"version": 1,
|
||||||
"sourceRepo": "https://gitea-external.egads.tutti.syntaxblitz.net/quixos/quixos",
|
"sourceRepo": "https://gitea-external.egads.tutti.syntaxblitz.net/quixos/quixos",
|
||||||
"sourceCommit": "6e51f796de7af0da8c053f770b89d243f74c5d61",
|
"sourceCommit": "452f3c48aadceaf08e56ae9c226e98a7f9df4900",
|
||||||
"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://gitea-external.egads.tutti.syntaxblitz.net/quixos/quixos-protocol.git"
|
||||||
|
|||||||
@@ -167,11 +167,12 @@ export const planStructure = async (rootPath: string, request: StructuralRequest
|
|||||||
resolveResource,
|
resolveResource,
|
||||||
});
|
});
|
||||||
if (compiled.resource.kind === "package") {
|
if (compiled.resource.kind === "package") {
|
||||||
const configuration = JSON.parse(await fs.readFile(path.join(resourceRoot, "quixos.check.json"), "utf8"));
|
const configurationSource = await read(resourceRoot, "quixos.check.json");
|
||||||
|
const configuration = configurationSource === null ? undefined : JSON.parse(configurationSource);
|
||||||
// Execution bindings are immutable build outputs owned by checkedArtifacts,
|
// Execution bindings are immutable build outputs owned by checkedArtifacts,
|
||||||
// not source edits produced by a structural preview.
|
// not source edits produced by a structural preview.
|
||||||
const artifacts =
|
const artifacts =
|
||||||
configuration.backend === "execution"
|
!configuration || configuration.backend === "execution"
|
||||||
? []
|
? []
|
||||||
: [
|
: [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1526,7 +1526,6 @@ const validateBoundDependencies = (
|
|||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
validateAttachmentAccess(issues, attachment, params.conformance, `${path}.binding.edgeTypeId`);
|
|
||||||
const projection = edgeProjection(attachment.attachment, edgeBinding.projectionId);
|
const projection = edgeProjection(attachment.attachment, edgeBinding.projectionId);
|
||||||
if (!projection) {
|
if (!projection) {
|
||||||
issue(
|
issue(
|
||||||
@@ -1537,6 +1536,12 @@ const validateBoundDependencies = (
|
|||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
// Exporting traversal never exports writes or subscription ownership.
|
||||||
|
const publicRead =
|
||||||
|
projection.endpoint.publicTraversal &&
|
||||||
|
requirement.primitives.length > 0 &&
|
||||||
|
requirement.primitives.every((primitive) => primitive === "resolve");
|
||||||
|
if (!publicRead) validateAttachmentAccess(issues, attachment, params.conformance, `${path}.binding.edgeTypeId`);
|
||||||
if (projection.target.keyType && requirement.primitives.includes("connect"))
|
if (projection.target.keyType && requirement.primitives.includes("connect"))
|
||||||
issue(
|
issue(
|
||||||
issues,
|
issues,
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import assert from "node:assert/strict";
|
|||||||
import { test } from "node:test";
|
import { test } from "node:test";
|
||||||
import {
|
import {
|
||||||
compileWorkspaceRevision,
|
compileWorkspaceRevision,
|
||||||
|
capabilityId,
|
||||||
computeCapabilityClosure,
|
computeCapabilityClosure,
|
||||||
resolveOperationPlan,
|
resolveOperationPlan,
|
||||||
validateWorkspaceRevision,
|
validateWorkspaceRevision,
|
||||||
@@ -197,6 +198,62 @@ test("public traversal permits a native inverse read without exporting mutation
|
|||||||
expectIssue(workspace, "private-attachment-access");
|
expectIssue(workspace, "private-attachment-access");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("public traversal exports only the selected read-only package edge port", () => {
|
||||||
|
const workspace = makeValidCapabilityWorkspace();
|
||||||
|
const exportDefinition = workspace.packageImports
|
||||||
|
.flatMap((pkg) => pkg.exports)
|
||||||
|
.find((entry) => entry.id === fixtureId.summaryGetExport)!;
|
||||||
|
const port = {
|
||||||
|
id: capabilityId.dependencyPort("port:summary:owner"),
|
||||||
|
displayName: "owner",
|
||||||
|
requirement: {
|
||||||
|
kind: "edge" as const,
|
||||||
|
target: { kind: "interface" as const, interfaceRevisionId: fixtureId.namedV1 },
|
||||||
|
cardinality: "exactly-one" as const,
|
||||||
|
primitives: ["resolve" as const],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
exportDefinition.dependencyPorts.push(port);
|
||||||
|
const binding = conformance(workspace, fixtureId.projectSummaryConformance).operationBindings[0].binding;
|
||||||
|
assert.ok(binding.kind === "package");
|
||||||
|
binding.dependencies.push({
|
||||||
|
portId: port.id,
|
||||||
|
binding: {
|
||||||
|
kind: "edge",
|
||||||
|
edgeTypeId: fixtureId.projectOwner,
|
||||||
|
projectionId: fixtureId.projectOwnerProjection,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const edge = conformance(workspace, fixtureId.projectOwnedConformance).privateAttachments.find(
|
||||||
|
(entry) => entry.id === fixtureId.projectOwner,
|
||||||
|
);
|
||||||
|
assert.ok(edge?.kind === "edge");
|
||||||
|
const endpoint = edge.endpoints.find((entry) => entry.projectionId === fixtureId.projectOwnerProjection)!;
|
||||||
|
expectIssue(workspace, "private-attachment-access");
|
||||||
|
|
||||||
|
// Publicity of the opposite projection does not grant this receiver access.
|
||||||
|
edge.endpoints.find((entry) => entry !== endpoint)!.publicTraversal = true;
|
||||||
|
expectIssue(workspace, "private-attachment-access");
|
||||||
|
endpoint.publicTraversal = true;
|
||||||
|
assert.deepEqual(validateWorkspaceRevision(workspace), []);
|
||||||
|
const compiled = compileWorkspaceRevision(workspace);
|
||||||
|
assert.ok(compiled.ok);
|
||||||
|
const plan = resolveOperationPlan(compiled.plan, fixtureId.project, fixtureId.summaryV1, fixtureId.summaryGet);
|
||||||
|
assert.ok(plan?.kind === "package");
|
||||||
|
assert.deepEqual(plan.dependencies.find((entry) => entry.port.id === port.id)?.port.requirement, port.requirement);
|
||||||
|
|
||||||
|
for (const primitive of ["connect", "disconnect", "watch-start", "watch-stop"] as const) {
|
||||||
|
const mutated = structuredClone(workspace);
|
||||||
|
const requirement = mutated.packageImports
|
||||||
|
.flatMap((pkg) => pkg.exports)
|
||||||
|
.find((entry) => entry.id === fixtureId.summaryGetExport)!
|
||||||
|
.dependencyPorts.find((entry) => entry.id === port.id)!.requirement;
|
||||||
|
assert.ok(requirement.kind === "edge");
|
||||||
|
requirement.primitives.push(primitive);
|
||||||
|
expectIssue(mutated, "private-attachment-access");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
test("native state and edge providers must match operation shape", () => {
|
test("native state and edge providers must match operation shape", () => {
|
||||||
const stateWorkspace = makeValidCapabilityWorkspace();
|
const stateWorkspace = makeValidCapabilityWorkspace();
|
||||||
const state = conformance(stateWorkspace, fixtureId.projectNamedConformance).operationBindings[0]!.binding;
|
const state = conformance(stateWorkspace, fixtureId.projectNamedConformance).operationBindings[0]!.binding;
|
||||||
|
|||||||
@@ -13,6 +13,37 @@ import {
|
|||||||
} from "../src/capability-language/structural-plan.js";
|
} from "../src/capability-language/structural-plan.js";
|
||||||
const execFile = promisify(callback);
|
const execFile = promisify(callback);
|
||||||
|
|
||||||
|
test("package structural validation does not require source-generated bindings", async (context) => {
|
||||||
|
const root = await fs.mkdtemp(path.join(os.tmpdir(), "qx-structural-package-test-"));
|
||||||
|
context.after(() => fs.rm(root, { recursive: true, force: true }));
|
||||||
|
await execFile("git", ["-C", root, "init"]);
|
||||||
|
await fs.writeFile(path.join(root, ".gitignore"), ".quixos/\n");
|
||||||
|
await fs.writeFile(
|
||||||
|
path.join(root, "quixos.lock"),
|
||||||
|
`quixos-lock version 1 { quixos source { repository "https://example.test/quixos.git"; commit "${"a".repeat(40)}"; } }`,
|
||||||
|
);
|
||||||
|
const before = 'package Test id "package:test" revision "package:test@1" {}';
|
||||||
|
await fs.writeFile(path.join(root, "package.qx"), before);
|
||||||
|
const request: StructuralRequest = {
|
||||||
|
kind: "package",
|
||||||
|
source: { repository: "https://example.test/package.git", commit: "b".repeat(40) },
|
||||||
|
files: [{ file: "package.qx", expected: before, replace: `${before}\n// updated` }],
|
||||||
|
};
|
||||||
|
const plan = await planStructure(root, request);
|
||||||
|
assert.deepEqual(
|
||||||
|
plan.changes.map((change) => change.file),
|
||||||
|
["package.qx"],
|
||||||
|
);
|
||||||
|
assert.equal(plan.validation, "resource-graph");
|
||||||
|
await fs.writeFile(path.join(root, "quixos.check.json"), "not valid json");
|
||||||
|
await assert.rejects(() => planStructure(root, request), SyntaxError);
|
||||||
|
await fs.writeFile(path.join(root, "quixos.check.json"), '{"backend":"execution"}');
|
||||||
|
assert.deepEqual(
|
||||||
|
(await planStructure(root, request)).changes.map((change) => change.file),
|
||||||
|
["package.qx"],
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
test("structural plans validate the graph, journal originals, and reject stale edits", async (context) => {
|
test("structural plans validate the graph, journal originals, and reject stale edits", async (context) => {
|
||||||
const root = await fs.mkdtemp(path.join(os.tmpdir(), "qx-structural-test-"));
|
const root = await fs.mkdtemp(path.join(os.tmpdir(), "qx-structural-test-"));
|
||||||
context.after(() => fs.rm(root, { recursive: true, force: true }));
|
context.after(() => fs.rm(root, { recursive: true, force: true }));
|
||||||
|
|||||||
Reference in New Issue
Block a user