Repository navigation
Description
A ledger-scoped streaming query only sees named graphs when it runs unscoped at head. With a policy in play, GRAPH <g> and GRAPH ?g stream 0 rows, while the buffered /query/{ledger} returns them. "A policy" here includes an identity header, a policy class, or just the ledger's own configured f:policyDefaults. A time pin isn't supported at all. I think the root of it is that there's no streaming entry point that takes a prepared GraphDb, and I'd love for us to add one.
Where (main @ e4793617f)
Fluree::run_stream_querytakes aLedgerStateand rebuildsGraphDb::from_ledger_state(&ledger)inside (fluree-db-api/src/view/stream_query.rs:153). That's head, with no policy. So a policy-wrapped view, or a view at an earliert, can't go down the single-view streaming path.- The route therefore sends any policy-scoped query down the dataset path, with a spec holding only the ledger's default graph (
fluree-db-server/src/routes/stream_query.rs:321-343).plan_with_ledger_defaultsdoes the same when the ledger's configured policy isn't root:DataSetDb::single(graph)(:455-480). A dataset with no named members has no named graphs, soGRAPHmatches nothing, and nothing says so. - The route already refuses a time pin in the ledger path for exactly this reason, per its own comment: "The streaming dataset path does not enumerate a ledger's named graphs under
GRAPH ?g, so a pinned read here would silently drop them" (:266-273). - The buffered path doesn't have the problem.
query_tracked_with_optionstakes a&GraphDb(fluree-db-api/src/view/query.rs), so a wrapped or historical view keeps its named graphs and builds a within-ledger dataset forFROM/FROM NAMED.
Who hits it
- fluree/solo's
/v1/fluree/stream/query/{ledger}(the CLI's--stream). Solo always carries policy, since the gate forces the bearer's identity in, soGRAPH ?gstreams 0 rows there on every signed-in request. Live on solo's fix build:GRAPH ?gstreamed 0 rows, while the default-graph query streamed its 1 row. fluree/solo#1302 fixed the buffered route by querying the prepared ledger view directly, the wayexecute_sparql_ledgerdoes. Streaming is the piece it couldn't fix. - db's own server, for any identity-scoped or config-governed streaming query. That part is from code; I didn't run it live on db.
Direction (more of a proposal than a spec; happy to be told there's a better seam)
-
A streaming run over an owned, prepared view, e.g.
run_stream_query_view(view: GraphDb, plan: StreamQueryPlan, tracker, options, tx).plan_stream_query_with_options(&GraphDb, …)already exists.GraphDbis Arc-backed, andDataSetDbalready carries them into the producer task, so owning one there seems fine. -
The streaming route could then do what the buffered one does:
- open the view, at the pin if there is one;
- apply
wrap_policy, orwrap_policy_defaultswhen there are no policy inputs; - plan and run it.
Named graphs would be visible, pins would work, and
plan_with_ledger_defaultswould no longer need the dataset fallback. -
A dataset clause naming only the ledger's own graphs could go the same way, if the view-based planner builds the within-ledger dataset as the buffered path does.
FROMnaming another ledger would stay on the dataset path. -
Same caveat as today's
run_stream_query: not wrapped by the residency retry loop.
The alternative I looked at and would rather avoid: have the dataset path enumerate every registered named graph as a member (graph_registry.iter_entries()), each loaded and policy-wrapped. It works with today's API, and a caller like solo could even do it from outside. But it costs a view load and a policy wrap per named graph on every streaming query, and one-graph-per-document ledgers can have thousands.
Related: #1279 / #1292 (the buffered ledger route's version of this, fixed), fluree/solo#1272 / #1302.
Activity
FROM, streaming on the view lane, and the remaining readers of dataset text #2079