/** * The namespace this library reserves for its OWN triples, and the one predicate a * read path needs about it: *is this subject machinery, or is it the consumer's data?* * * ── Why this exists ──────────────────────────────────────────────────────── * The polyfill has no branches, so it emulates each of a repo's compartments with a * distinct SUBJECT inside a document (`shim:index` for the store's Main branch, * `shim:storeBranch`, `shim:userBranch`, `shim:headerBranch` — see `store-registry.ts`). * That was invisible as long as those subjects only ever appeared in documents the * consumer never reads through the data path — store documents and the doc-shim. * * The Header branch broke that: it lives in an ENTITY document, the one the consumer * reads with `SELECT ?s ?p ?o`. Without a filter, the address of a document's inbox * would surface as one of that entity's properties — machinery leaking into domain * data. Filtering by SUBJECT rather than by predicate is what makes this hold for * every compartment, present and future: a new emulated branch needs no new filter. * * Upstream this problem does not exist, because there the separation is real — a * branch is a different CRDT with its own topic, not a subject in the same graph. This * module is the seam where our emulation pays for that. */ /** * The URN namespace every triple this library writes for itself lives under — * `urn:ng-eventually:shim:…` (store-registry's compartments) and * `urn:ng-eventually:inbox:…` (inbox deposits). * * A consumer that writes its own data under this prefix would have it filtered out of * its reads. That is a deliberate reservation, not a hazard to guard against: the * namespace names this library. */ // @provenance MACHINERY_NS kind=invention level=none ref=none — upstream a branch is a distinct CRDT with its own topic; a reserved subject prefix exists only because this library has no branches export const MACHINERY_NS = "urn:ng-eventually:"; /** * Is `subject` one of this library's own, rather than consumer data? * * Tolerant of `undefined` so a read path can hand it a possibly-absent binding * without a preliminary check — an absent subject is not machinery. */ // @provenance isMachinerySubject kind=invention level=none ref=none — same — upstream nothing has to be filtered out of a document's own graph export function isMachinerySubject(subject: string | undefined): boolean { return subject !== undefined && subject.startsWith(MACHINERY_NS); }