feat: GraphScopedDataset — read from many graphs, write to one - #95
Draft
jeswr wants to merge 1 commit into
Draft
Conversation
Generalizes NamedGraphDataset (which stays untouched) into a view that reads a configurable set of graphs — or every graph when the read scope is undefined — projected onto the default graph with per-triple deduplication, while directing all writes to a single configured graph. - src/GraphScopedDataset.ts: reads union the read graphs and project to the default graph; add/delete/has enforce default-graph input via ensureDefaultGraph; match mirrors NamedGraphDataset's self-wrapping pattern and rejects non-default graph arguments with TermTypeError. - DatasetWrapper.scoped(writeGraph, readGraphs, klass) beside named(). - IGraphScopedDatasetConstructor in src/type/, both exported from mod. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This was referenced Jul 6, 2026
Draft
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this does
Adds
GraphScopedDataset: a dataset view that reads from a configurable set of graphs and writes to a single graph, generalizingNamedGraphDataset(which is the special case of reading from and writing to the same one graph, and stays untouched for back-compat).readGraphs, projected onto the default graph, with per-triple deduplication (a triple appearing in several read graphs is exposed once).readGraphs === undefinedreads every graph — a deduplicated union view.add/delete) are rewritten into the configuredwriteGraph;deleteleaves copies of the triple in other graphs untouched. Non-default-graph input quads throwNamedGraphError(via the existingensureDefaultGraph).hasanswers from the read scope, consistent with iteration.match(s, p, o[, defaultGraph])mirrorsNamedGraphDataset's self-wrapping pattern and throwsTermTypeErrorfor non-default graph arguments.DatasetWrappergains aprotected scoped(writeGraph, readGraphs, klass)helper besidenamed(), accepting IRIs or terms;IGraphScopedDatasetConstructoris added tosrc/type/. Both new symbols are exported frommod.ts.Because the projection rewrites every read quad to the default graph, existing
TermWrapper/DatasetWrappermodels work unchanged against quads that live in named graphs — including the common read-many/write-one asymmetry (e.g. read the union of a document's graphs, write changes to one designated graph).Why
Addresses the graph-scoping follow-up from #43 (@jaxoncreed): LDO-style control over which graph writes land in, independent of which graphs are read.
Relation to #73
Supersedes the
GraphScopedDatasetread-write graph-scoping slice of the #73 omnibus, including itsunion_graph/projected_datasetread-write test slices. It deliberately excludes the rest of that omnibus: no events plumbing (NotifyingDatasetCore), noLazyMaterialize, and no breaking default-graph-onlyDatasetWrapperrework — this is a purely additive change.Notes
termType/value(plus language/direction/datatype for literals, recursion for quoted triples), the same keying used in fix: DatasetWrapper helpers yield distinct terms #88; if both land, the helper can be shared in a follow-up.test/unit/graph_scoped.test.ts(explicit read scope + union view) andtest/unit/graph_scoped_integration.test.ts(TermWrappermodels reading across graphs and writing into the scoped graph). New code is at 100% line coverage;npm testandnpx typedocare green.