Repository navigation
Description
#2010 routes every single-graph lane through one predicate (reads_exactly_one_graph) and fixes the sites that read one member's index in a scope of several graphs (the union default graph, FROM naming several of a ledger's graphs, FROM NAMED alone, a dataset spanning ledgers). What it doesn't do is make that mistake hard to write again, and a few readers still read one graph, as on main. The class, as #2010 puts it: a site that runs in every scope used an accessor that is None across several graphs and read None as nothing to do (fulltext(), BM25, S2), or read binary_g_id directly.
- A one-graph witness in place of
graph_view()and the rawbinary_g_id.ExecutionContext::one_graph() -> Option<OneGraph<'_>>, built only byreads_exactly_one_graph();graph_view()andbinary_g_idmove behind it (OneGraph::view(),OneGraph::g_id()), and the field becomes private tocontext.rs. Code that runs in every scope is then left withdecode_view(), and a single-graph lane has to nameone_graph(), which is its gate. Member contexts andGRAPHscopes read one graph, so their scans don't change. The legitimate any-scope readers of the id (the thread-local predicate cache key ineval/helpers.rs, the vector arena slice ineval/vector.rs) get named accessors. fix(query): compare terms by what they are, not how they're encoded #2010's estimate is roughly 600–1,000 changed lines, mostly mechanical; the option is taken once at open, so the perf check is single-graph instruction parity. (An index-onlygraph_view()looks like the obvious version but isn't: every remaining use decodes, legitimately, on one graph, and sending them all todecode_view()would have the arena crossing inspect every binding for a handle that can't be there.) -
fulltext()scores every document against the scope's graph's arena statistics (the default graph's under the union). Scoring each against its own graph's would be better than whatmaindoes today. - The Cypher metadata functions
labels,keysandpropertiesread the scope's graph only. Property access,type,startNodeandendNodealready answer right. - A k-way merge for the partitioned GROUP BY, so it keeps its lane over several graphs instead of falling back to hashing.
- Datalog rules over a default graph of several graphs see the primary graph's facts only. Whether they should see every member is more a scope decision than a bug, so this one wants a call before code.
The witness gives the fulltext() and Cypher-metadata fixes a natural home (each gets a named accessor), so I'd do those three together.
From #2010 (Not changed here: the one-graph witness; the two readers that read one graph; the k-way merge; rules over several graphs).
Activity
aaj3f commentedon Nov 19, 2026
A note on the last item ("Datalog rules over a default graph of several graphs see the primary graph's facts only"), since it turned out to be less of a pure scope call than I made it sound. With a stored or query-time rule that negates, the primary-only view isn't just narrower, it's wrong in a way that looks right: over
"from": ["data:main", "other:main"], a rule derivingex:Candidatefor any account with noex:excludedfact marks everyone a candidate when the exclusions live inother, while a plain query over the samefromjoins across both and finds them. Swap the order and the same rule derives nothing. A bodyGRAPH <iri>naming another ledger, a graph source or a typo'd graph does the same thing.I've filed that as #2459 and suggested a loud refusal there first (heads are already refused that way), so the "should rules see every member" decision can stay here and doesn't have to happen before the silent part is fixed.