Evaluate coherent local queries over explicit replica scopes

This commit is contained in:
Timothy J. Aveni
2026-09-20 04:04:35 -07:00
parent 3f1976815f
commit c75888833b
5 changed files with 39 additions and 8 deletions
+9
View File
@@ -173,6 +173,15 @@ test("local queries cannot silently expand the replica relationship traversal",
assert.throws(() => compileExecutionPlan(workspace), /REPLICA_TRAVERSAL_MISSING/);
});
test("local relationships require complete source candidates even when a filter initially matches", async () => {
for (const selection of ["highlights(first: 10)", 'highlights(all: 1000, where: {color: {eq: "yellow"}})']) {
const workspace = await loadReaderWorkspace((name, text) =>
name === "queries/replica-inputs.graphql" ? text.replace("highlights(all: 1000)", selection) : text,
);
assert.throws(() => compileExecutionPlan(workspace), /REPLICA_RELATION_INCOMPLETE/);
}
});
test("closed generic applications retain distinct identities and codec shapes", async () => {
const { compileCapabilityResourceSource, compileCapabilitySource } =
await import("../src/capability-language/index.js");
+1
View File
@@ -79,6 +79,7 @@ revision "package:reader-runtime@1" {
query HighlightScope id "reader:highlight-scope" root workspace HighlightData document "queries/highlight-scope.graphql" operation "HighlightScope" { view Comment as CommentData; replica; max rows 200; }
query HighlightWindow id "reader:highlight-window" root workspace HighlightData document "queries/highlight-window.graphql" operation "HighlightWindow" { view Comment as CommentData; replica; max rows 200; }
query HighlightList id "reader:highlight-list" root workspace HighlightData document "queries/highlight-list.graphql" operation "HighlightList" { view Comment as CommentData; local from HighlightScope; max rows 200; watch; }
query HighlightWindowList id "reader:highlight-window-list" root workspace HighlightData document "queries/highlight-list.graphql" operation "HighlightList" { view Comment as CommentData; local from HighlightWindow; max rows 200; watch; }
query HighlightEditorInputs id "reader:editor-inputs" root HighlightData document "queries/editor-inputs.graphql" operation "HighlightEditorInputs" { view Comment as CommentData; replica; max rows 1; }
query HighlightEditorView id "reader:editor-view" root HighlightData document "queries/editor-view.graphql" operation "HighlightEditorView" { view Comment as CommentData; local from HighlightEditorInputs; max rows 1; watch; }
}
+3 -3
View File
@@ -3,13 +3,13 @@ import { test } from "node:test";
import { compileQuery } from "../src/query/compile.js";
import { linkQueries } from "../src/query/link.js";
import { loadReaderWorkspace as load, readReaderFixture as read } from "./reader-fixture.js";
test("complete reader contracts compose factories, portable selectors, CRDT edits, and six query scopes", async () => {
test("complete reader contracts compose factories, portable selectors, CRDT edits, and bounded query scopes", async () => {
const workspace = await load();
assert.equal(workspace.constructors.length, 0);
assert.equal(workspace.atoms.length, 3);
const linked = linkQueries(workspace);
assert.equal(linked.length, 7);
assert.equal(linked.filter((q) => q.checked.declaration.placement?.kind === "local").length, 3);
assert.equal(linked.length, 8);
assert.equal(linked.filter((q) => q.checked.declaration.placement?.kind === "local").length, 4);
const screen = linked.find((q) => q.checked.declaration.displayName === "ReaderScreen")!;
assert.ok(screen.fields.some((f) => f.memberId === "highlight:excerpt" && f.binding.kind === "package"));
assert.ok(screen.fields.some((f) => f.memberId === "comment:content" && f.binding.kind === "state"));