docs+test(client): correct the phantom-graph claim, verify graph behavior in e2e

The lib e2e harness now characterizes all three SPARQL graph shapes against the real
broker (24/24): (a) no-GRAPH anchored write round-trips; (b) an explicit anchored
GRAPH <plainNuri> ALSO resolves to the same repo (no phantom graph) — the earlier
'targets a phantom graph, does NOT round-trip' claim is FALSE on @ng-org/web
0.1.2-alpha.13; (c) an anchorless GRAPH ?g scan spans every named graph (O(wallet)
union, 32 graphs) — TRUE, re-verified.

Reconcile the comments accordingly: inbox.ts / store-registry.ts drop the false
phantom-graph justification (no-GRAPH stays as the canonical, always-safe shape — a
simplicity choice, not a round-trip necessity; re-verify via e2e if the broker
version changes). read-model.md keeps the anchorless-O(wallet) rationale (the real
reason reads are per-doc anchored) and appends a note distinguishing the variable
GRAPH ?g SCAN from a constant GRAPH <D> WRITE. No new absolute introduced.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Sylvain Duchesne
2026-07-07 09:38:59 +02:00
parent 1c475d8c9f
commit 4a2569e243
4 changed files with 97 additions and 39 deletions
+27 -14
View File
@@ -89,31 +89,44 @@ async function main(): Promise<void> {
const nuri = await sdk<string>(frame, "docCreate");
check("docCreate returns a usable NURI", typeof nuri === "string" && nuri.length > 0, nuri);
});
await step("SPARQL anchored default-graph round-trip", async () => {
await step("SPARQL graph-behavior characterization (a/b/c)", async () => {
const rt = await sdk<any>(frame, "docRoundTrip");
// THE load-bearing assertion fake-ng cannot verify: the anchored default-
// (a) THE load-bearing assertion fake-ng cannot verify: the anchored default-
// graph write (no GRAPH clause) round-trips through the real broker's
// repo_graph_name overlay. This is what read-model / inbox / store-registry
// all rely on.
// repo_graph_name overlay. This is the canonical shape the lib writes, and
// what read-model / inbox / store-registry all rely on.
check(
"anchored default-graph write ROUND-TRIPS (the shape the lib writes)",
"(a) anchored default-graph write (no GRAPH) ROUND-TRIPS",
rt.anchoredPresent === true,
`predicates=${JSON.stringify(rt.predicates)}`,
);
// FINDING (reported, not asserted): on this broker version, an explicit
// (b) FINDING (reported, not gating): on THIS broker version an explicit
// `INSERT DATA { GRAPH <plainNuri> {…} }` ANCHORED to the same doc ALSO
// round-trips via the anchored default-graph read (explicitGraphPresent),
// AND is reachable via an explicit `GRAPH <plainNuri>` read
// (explicitViaNamedGraph). i.e. when anchored, the plain NURI resolves to
// the same repo graph — it is NOT a phantom graph here. The lib still writes
// the no-GRAPH default-graph shape (the always-safe one); this records what
// the broker actually does, so the lib's "phantom graph" comments can be
// re-checked against this broker version.
// round-trips — readable both via the anchored default-graph read
// (explicitGraphPresent) AND via an explicit `GRAPH <plainNuri>` read
// (explicitViaNamedGraph). i.e. when anchored, the plain NURI resolves to the
// SAME repo graph — there is NO "phantom graph" here. The lib still writes the
// no-GRAPH default-graph shape as the always-safe canonical convention; this
// records what the broker actually does so the "phantom graph" comments can be
// re-checked against this broker version by re-running this harness.
record(
"[finding] explicit GRAPH <plainNuri> when anchored resolves to the same repo",
"(b) [finding] explicit GRAPH <plainNuri> ANCHORED resolves to the same repo (no phantom graph)",
true,
`defaultGraphRead=${rt.explicitGraphPresent} namedGraphRead=${rt.explicitViaNamedGraph} (informational)`,
);
// (c) FINDING: the ANCHORLESS `GRAPH ?g { … }` union scan spans EVERY named
// graph in the session store (it saw BOTH doc A's and doc B's graphs). This is
// the O(wallet-size) cost the read path avoids by reading each doc with its own
// anchored default-graph query. Reported, not gating (it is a perf property of
// the union, not a correctness assertion of the lib's write/read shape).
const us = rt.unionSpan ?? {};
record(
"(c) [finding] anchorless GRAPH ?g scan spans ALL named graphs (O(wallet) union)",
true,
us.graphCount === -1
? `anchorless scan errored: ${us.error} (union claim NOT re-verified here)`
: `sawDocA=${us.sawDocA} sawDocB=${us.sawDocB} graphCount=${us.graphCount} (both ⇒ union spans all graphs)`,
);
});
// ── read-model ──────────────────────────────────────────────────────────