Skip to content

fix(lists): SPARQL reads list members as values, CONSTRUCT writes lists, deleting a value takes every entry - #2217

Merged
bplatz merged 7 commits into
mainfrom
fix/sparql-lists-member-view
Oct 31, 2026
Merged

bplatz merged 7 commits into
mainfrom
fix/sparql-lists-member-view

Conversation

@bplatz

@bplatz bplatz commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

SPARQL reads a list's members as values of the property that holds it, as JSON-LD does, and CONSTRUCT and DESCRIBE write the lists they read.

Why this undoes much of #2159

#2159 made SPARQL read and write lists as RDF: a list became its owner's edge to a head cell plus a chain of rdf:first/rdf:rest cells, which queries could walk and updates could edit. #2159 has not been in a release (no tag contains it), so this reverses it before it ships rather than after.

We are changing direction on lists. Broad SPARQL list compliance cost a second reading of every list predicate, plan rules for list-view patterns, and cell-edit machinery in the write path, and most of the bugs we fixed along the way came from giving cells an identity of their own. The priority is list identity and position, with no cost to queries that don't use them. Full RDF-list compliance in SPARQL is no longer the goal; the last section says what next will support instead.

What changes

Queries

  • ex:s ex:items ?o binds each member, as before fix(sparql): read and write RDF lists as RDF #2159. A member repeated in a list is a value each time, and counts count members.
  • A compact list's cells are not triples a query can match: ex:items/rdf:rest*/rdf:first and ( ?x ?y ) patterns find nothing for it. W3C list-2 to list-4 go back on the expected-failure register.
  • CONSTRUCT and DESCRIBE write the lists they read, in order and with repeats: ( … ) in Turtle, {"@list": [...]} in JSON-LD. This applies when a template triple repeats a triple pattern of the WHERE, at the top level or in an OPTIONAL, in the default graph. A value stands for every entry holding it. A value the owner also holds outside the list is written beside the list too, so the output loads back as the same data. A template that writes the values under another subject or property writes them as plain values.
  • That list output costs a CONSTRUCT row only when its predicate can hold a list: a template triple on a constant predicate no list is held on is not wrapped at all, and a variable predicate is checked by its index id before anything is decoded.
  • The Graph Store GET keeps the RDF view internally, through an execution option only that route sets (QueryExecutionOptions::with_rdf_list_view), so it still returns lists whole and reads back unchanged. No request header or pragma can turn the view on.

Updates

  • An update's WHERE binds members, as a query's does. Cells can no longer be edited one by one; to replace a list, or change one entry, upsert the list from JSON-LD or Turtle.
  • Behaviour change: a delete naming a value with no list position deletes every entry of a list holding it, and the value stored beside the list, however the delete is written (DELETE DATA, DELETE WHERE, a WHERE with VALUES or FILTER, a JSON-LD delete). Before, it deleted the first entry unless the WHERE handed each one over. The compatibility reference notes this.
  • A list identical to one its property already holds, compact or as a chain, restates it as stored. Writing it again after a delete left a gap adds no duplicates, and ADD again changes nothing. A restated chain is re-asserted rather than skipped, so a write by an identity that cannot view it is still refused under its modify policy.
  • ADD and COPY leave the source's lists as they are.

Kept from #2159: a second list on one subject and property is stored as a chain; export writes ( … ) and @list; the JSON-LD crawl reads a chain-stored list as its members, now looking for one only on a graph that holds an rdf:first, so blank-node values cost a crawl nothing on other ledgers; OWL list axioms are read in either storage shape.

What next will support

The work moves to next, because it changes the index format:

  • List identity: widen o_i / FlakeMeta.i to 64 bits, with the list ID in the high bits and the position in the low bits. Existing positions keep their low 32 bits. A property can then hold several compact lists, so a second list is no longer stored as a chain, and output can keep lists apart.
  • A per-graph, per-predicate "has list rows" bit in the index root, so writes and list output skip predicates that never held a list.
  • Nested, shared and IRI-headed lists stay as plain triples. Cells get no identity of their own.
  • A defined SPARQL subset over list ID and position: reading a member's position, and positional edits (replace, insert, append, remove one occurrence) as ordinary updates that restate the list. An opt-in, read-only RDF view could come later if someone needs it.

Fixes #2174
Fixes #2180
Fixes #2181

Partially addresses #2173: default queries no longer use the list view, so its fast-path and batched-join gaps don't apply to them. Remaining: carrying list-predicate discovery forward across index builds, now needed only by CONSTRUCT/DESCRIBE list output and the Graph Store GET.

Follow-up: #2171, #2172 (to be rescoped to the list-ID plan above)

Commits

  1. fix(sparql): member view for SPARQL; Graph Store GET view as an internal option; delete, restate and ADD/COPY rules; CONSTRUCT/DESCRIBE list output; docs.
  2. fix(transact): restate a list held as a chain by its members, not by a hash of its cells; one-pass sibling lookup for big-integer deletes.
  3. fix(query): CONSTRUCT binds each value's list entries once; its hidden variables are fresh.
  4. perf(query): CONSTRUCT asks a row about lists only on a predicate that holds them; query_hot_list_view re-aimed at what a list costs now, with CONSTRUCT scenarios.
  5. perf(api): the JSON-LD crawl looks for a chain-stored list only on a graph holding rdf:first; a blank-node crawl scenario.
  6. test(sparql): an edit of a chain-stored list's cells is judged as its owner's, tested again.
  7. refactor(transact): the unreachable list-view half of a SPARQL update's list edits removed.

SPARQL reads a list's members as values of the subject and property that
hold it, as a JSON-LD query does, in queries and updates alike. A compact
list's rdf:first/rdf:rest cells are not triples a query can match, so W3C
list-2 to list-4 go back on the register. The Graph Store GET keeps the RDF
view through an execution option only that route sets
(QueryExecutionOptions::with_rdf_list_view, never from a request), so it
still returns each list as ( ... ) and reads back unchanged. Txn no longer
carries a list view, and cells can no longer be edited one by one.

Writes reach a list through its members:

- A delete naming a value without a list position deletes every entry of
  a list holding it, and the value stored beside the list, however it is
  written: DELETE DATA, DELETE WHERE, a WHERE with VALUES or FILTER, and a
  JSON-LD delete (SlotFacts::named_all). Identical intents expand once
  (DeleteResolver::expanded); a slot holding no list keeps its one lookup.
- A list restated is restated at the positions it is stored at
  (lists::encode), so writing it again after a delete left a gap adds no
  duplicates.
- ADD and COPY leave the source's lists as they are. A list ADD lands
  beside another is stored as a chain whose cells are named by what it
  holds (chain_cells_for), so ADD again restates it.

CONSTRUCT and DESCRIBE write the lists they read. A template triple that
restates a triple of the WHERE (ConstructTemplate::mark_list_entries) has
the positions of the entries holding its object bound by
ListEntriesOperator, which reads each owner's list from the query's default
graph under its policy, and the formatter writes those entries as the list:
( ... ) in Turtle, @list in JSON-LD. A value stands for every entry holding
it; a value the owner also holds beside the list is written beside it; an
owner with lists in two of the default graph's graphs is written as values.
The operator runs only for such a template on a ledger that may hold lists.

Tests: it_sparql_list_members (reads, deletes, restates, ADD/COPY,
CONSTRUCT/DESCRIBE, round trip, JSON-LD twins), with it_sparql_lists on the
Graph Store's view and the delete expectations in it_delete_point_reads and
it_filtered_delete_list_meta updated to the new rule.
…ms in one pass

A list ADD puts beside the destination's own list is stored as a chain.
Its cells were named by a hash of the members' Debug text, which rounds a
GeoPoint to six places (two lists of nearby points shared cells) and
changes when an index build stores -0.0 as 0.0 (ADD again wrote a second
chain). The cells now take the transaction's names, like any chain's, and
a list identical to one its owner holds as a chain restates that chain:
lists_held walks the owner's chains, and encode re-asserts the chain's
stored triples, as it re-asserts a compact list's members. Restating, not
skipping, keeps the modify check on a chain the identity cannot view, so
ADD is refused alike whether or not the destination holds the list.

A delete naming a value with no position names every entry holding it.
The other terms of each entry that novelty holds apart (a big integer under
two subtypes) were found per entry, each a scan of the value's terms;
same_facts now finds them all in one pass.

Tests: adding_a_list_held_as_a_chain_restates_it (policy),
adding_again_after_an_index_build_changes_nothing,
lists_added_beside_another_stay_apart,
a_value_named_once_retracts_every_term_of_every_entry.
…of its own

ListEntriesOperator bound every solution naming a value to the positions
of all the entries holding it, so a list repeating a value N times bound
N² positions. The first solution naming an owner's value now carries them;
later ones carry an empty list, which still writes the value as entries.

The variables those positions are bound to took fixed names, so a query
naming its own variable ?__list_positions_0 aliased one and failed with a
duplicate column. VarRegistry::fresh names a variable no registered name
has; mark_list_entries and unbind_outside_group_row take theirs from it.

Tests: construct_binds_each_values_entries_once,
construct_variables_alias_none_of_the_querys.
@bplatz bplatz added the bug Something isn't working as expected label Oct 30, 2026

@aaj3f aaj3f left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bplatz this is a big reversal and a careful one. Taking the direction as given, the implementation choices are the ones I'd have picked: one operator over the plan for CONSTRUCT's lists, the delete rule as an extension of DeleteResolver's existing lookup rather than a second notion of equality, and the RDF view as an execution option only the Graph Store GET can set.

This PR also makes two product calls, and I'm happy for it to make them, but I want to name them so they're made on purpose rather than coming along with the fix: (1) SPARQL stops reading lists as RDF and reads a list's members as values, with only the Graph Store GET keeping the RDF view, which is a step back from RDF-list compliance (W3C list-2..list-4); and (2) a delete that names a value with no position now takes every list entry holding it, plus the value beside the list, on JSON-LD as well as SPARQL. I've laid out the options I see for each, with the history and the trade-offs as I understand them, just above the adherence checklist below. Both are your call, and I'm fine with whichever way you land. For merge order: my #2202 optimizes the list view this takes off default queries, so if this lands as written, its one-pass path is reachable only through with_rdf_list_view with a bound predicate, which the Graph Store GET never sends, and #2202 shouldn't go in ahead of this.

One more headline note: the CONSTRUCT list output is the third instance of something we keep doing with lists, which is gating list work at the ledger level ("this ledger may hold lists"), so one list anywhere puts per-row list work on queries that never touch one:

#2181 (the JSON-LD crawl probes every blank-node value for an rdf:first; still live at this head); #2159's list view on every SPARQL pattern a list could match on a list-bearing ledger, every variable predicate included (#2173, and what query_hot_list_view was written to measure); and here, ListEntriesOperator decoding every CONSTRUCT row's subject before it asks whether the predicate can hold a list

The per-graph, per-predicate "has list rows" bit in your next plan is the class fix, so not for this PR. I do think the point fix for the CONSTRUCT case belongs here, though (it's small, details below), since the PR's own stated priority is "no cost to queries that don't use them".

Claude recommended "Request Changes" (and I think re: the performance items if nothing else, that's technically true) but I also know there's some urgency towards this and other PRs so I'll approve so as to unblock you.

Full review below:


🔄 Request changes.

The commit bodies on this one are really good, @bplatz: each says exactly what changed and why, which made a reversal this size easy to check. I probed the delete and restate rules pretty hard and they held up. Deleting 1 from a list holding 1, 1.0, "1", "1"^^xsd:long and 1.0e0 takes only the xsd:integer one; a delete of "a"@en takes both entries, the one written @EN included; a delete in the default graph leaves a named graph's list alone; and #2180's repro now reads [1, 3] where 42bb9646c reads [1, 3, 3]. The CONSTRUCT shapes I tried (a FILTER, OFFSET/LIMIT, ORDER BY, two template triples over one list, an OPTIONAL, an owner holding a compact list and a chain, and a round trip of that through Turtle) all wrote what the new docs say. So the request for changes is about performance, one CI gate and one lost test, not semantics:

  1. CONSTRUCT pays per row on any ledger holding a list (list_entries.rs:126, inline). In a debug scratch test with one unrelated two-member list on a 20k-subject ledger, CONSTRUCT { ?s ex:name ?o } WHERE { ?s ex:name ?o } is +26% vs main, though no list touches ex:name, and { ?s ?p ?o } is +25% vs main. The fix is small: decide constant predicates once, check the predicate before decoding the subject, and test variable predicates by their encoded id.

  2. query_hot_list_view panics at its sanity check (lower/mod.rs:118, inline). The nightly bench-gate smoke-runs every bench and fails on a panic, so this goes red the first night after merge. It's also the natural home for a CONSTRUCT plain-vs-listed scenario, since query_hot_construct_formats holds no list.

  3. The policy check on a chain-stored list's cells lost its only test (it_sparql_lists.rs:643, inline). The guard still works, but when I disabled list_owner_checks a policy-denied edit of a chain cell went through and nothing went red.

Two smaller ones inline: the list-view half of ListEdits is now unreachable, and this fixes #2180, so Fixes #2180 would close it. On #2181: it's pre-existing from #2159 (hydration.rs isn't touched here), so not this PR's regression, but it's the same class as item 1, and a gate on whether the graph has ever stored an rdf:first (an index predicate lookup plus a look at novelty, once per request) is about PR-sized. Since this PR restates the priority #2181 breaks, I'd lean toward folding that gate in here too, but I wouldn't hold the merge on it.

On the two product calls from the top, here's how I'd lay them out, in case it's useful (your call on both):

SPARQL reading list members as values. v4.2.4 read members as values; #2159 moved SPARQL to the RDF view on main, but no tag contains it (the v4.2.5 release branch doesn't either), so as written this returns SPARQL to what released users already have rather than changing it on them. The options I see:

  • As written (members as values, the view only for the Graph Store GET): SPARQL and JSON-LD give one answer for the same pattern, and queries that never ask about a list stop paying for the view (#2173). The cost is that RDF tooling walking rdf:rest*/rdf:first finds nothing for a compact list, and the W3C list tests stay on the register until the list-ID work on next.
  • As written, plus a read-only opt-in view now (one pragma or header): the view stays in the tree for the Graph Store GET anyway, so RDF tooling would have a way in today. The cost is reopening the request-level surface this deliberately closes (no_pragma_reads_a_lists_cells), plus a precedence rule for the switch.
  • Keeping #2159's view as SPARQL's default and taking its cost on directly (#2173): compliant list reads, at the price of the second read of every list predicate and the cell-edit write path, which is where most of #2159's bugs came from.

A value delete taking every entry. On v4.2.4 and main, a JSON-LD delete took the first entry holding the value unless the WHERE handed each entry over (a FILTER), which took them all, so the result depended on how the delete was spelled; main's SPARQL DELETE DATA left members alone. The options I see:

  • As written (every entry, and the value beside the list, on every surface): one answer however the delete is spelled, and the only reading that matches what a member-view query shows. The cost is a silent change for a 4.2.4 JSON-LD caller who deleted one occurrence of a repeated value and now loses all of them (upserting the list is the documented way to remove one).
  • Refusing an ambiguous value delete (the value occurs more than once in a list, or in a list and beside it) with an error that points to upsert, until next has positional edits: no silent loss, and easy to relax later, but a FILTER-witnessed delete still takes them all, so the outcome depends on spelling again.
  • Every entry for SPARQL only, keeping JSON-LD's 4.2.4 rule until next: nothing changes for existing JSON-LD callers, but it breaks SPARQL/JSON-LD parity and keeps the spelling-dependent rule.

If the delete rule stays as written, it may be worth the PR title naming the JSON-LD change, since the release notes come from the title.

Adherence to repo commitments:

  • Patterns/abstractions: ✔ ListEntriesOperator is an ordinary operator over the plan reusing list_view::view_for and member_binding, and named_all extends DeleteResolver's existing lookup rather than adding a second equality; the view-only half of ListEdits is left behind as dead code (inline).
  • Performance (speed first, memory second): ✖ CRITICAL: CONSTRUCT and DESCRIBE on any ledger holding a list pay a per-row decode even for predicates no list touches (+25-26% vs main in my debug measurements, inline). On the other side, default SELECTs on such a ledger lose the list view's cost, and deletes add no read on slots that hold no list entry (has_entries comes from facts already read).
  • Deployment targets: ⚠️ shared fluree-db-query / fluree-db-api code. list_predicate_ids is memoized per store, so on a host that runs short-lived processes, each process's first restating CONSTRUCT on a list-bearing ledger walks every POST leaf directory. That's pre-existing from #2159 for every SPARQL query, and this narrows it (#2173 tracks carrying it forward). Nothing new reaches for threads, files or clocks for wasm32; the evidence is in-process tests plus the server's HTTP suite.
  • Testing: ⚠️ it_sparql_list_members is wired into grp_query_sparql and goes red under mutation; W3C list-2..list-4 are registered and CI's stale-register check is green; but the chain-cell policy check lost its only test, and query_hot_list_view now panics (inline).
  • Conventions: ⚠️ thorough commit bodies and compatibility.md entries; Fixes #2180 is missing, the title (which feeds the release notes) doesn't mention the JSON-LD delete change, and the sparql.md line about policy on a list's cells went away while the code that enforces it stayed.

Verified locally at branch HEAD: grp_query_sparql it_sparql_list* (42 passed), the grp_transact/grp_misc list files (53 + 4), it_filtered_delete_list_meta (9) and the fluree-db-transact list unit tests (24), all green. Mutations went red and were restored: the restate at stored positions (restating_a_list_keeps_its_positions), the every-entry delete branch (deleting_a_repeated_member_deletes_each_entry), and the CONSTRUCT wrap (7 construct* tests). Scratch probes covered delete equality, other graphs, #2180, CONSTRUCT shapes and round trips, chain-cell policy, and CONSTRUCT cost against 42bb9646c. query_hot_list_view in test mode panics. CI at a59dcd537: test (15,023 passed, including graph_store_http::lists_round_trip), testsuite-sparql, clippy, fmt and wasm32 are green.

Please do get the CONSTRUCT fix and the bench repair in before this merges. The rest are small, and if you agree with them I'd rather see them folded in now than lost in the backlog.

Comment thread fluree-db-query/src/list_entries.rs Outdated
row: usize,
t: &TriplePattern,
) -> Result<Option<(Vec<Binding>, bool)>> {
let (Some(s), Some(p)) = (node(ctx, batch, row, &t.s), node(ctx, batch, row, &t.p)) else {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Must address before merge (CRITICAL, performance): on a ledger holding any list, every CONSTRUCT row decodes its subject and predicate here before may_hold_lists can say the predicate holds none.

ListEntriesOperator wraps the plan whenever a template triple restates a WHERE triple (runner.rs:547-563), which is nearly every CONSTRUCT ({ ?s ?p ?o } WHERE { ?s ?p ?o }, the CONSTRUCT WHERE shorthand, and both of DESCRIBE's template triples). view_for returns None only when the ledger has never held a list. So once one list exists anywhere, entries runs for every row and every marked triple, and it materializes ?s (a dictionary decode and a Sid) before it looks at the predicate. For a constant predicate that holds no list, that answer could have been worked out once, at build time.

I measured it with a scratch test in one debug binary: 20k indexed subjects (ex:name, ex:knows), against the same data plus one unrelated ex:config ex:order (ex:a ex:b), best of 5, run twice. For CONSTRUCT { ?s ex:name ?o } WHERE { ?s ex:name ?o }, plain vs listed is 178 vs 223 ms here, and 177 vs 177 ms on main (42bb9646c), so +26% vs main for a predicate no list touches. For CONSTRUCT { ?s ?p ?o } WHERE { ?s ?p ?o } it's 351 vs 512 ms here and 349 vs 411 ms on main (+25% vs main). With the wrap disabled at runner.rs:551, both listed numbers fall back to plain (360 and 182 ms), so the cost is all this operator. Just checking t.p and may_hold_lists before decoding t.s brought the ex:name case to 185 ms (+3%) and the ?s ?p ?o case to 440 ms.

I think the fix is: (1) in ListEntriesOperator::new, drop marks whose predicate is a constant may_hold_lists rejects, and skip the wrap in runner.rs when none are left; (2) in entries, check the predicate before touching the subject; (3) for a variable predicate, test the encoded predicate id against the list predicates' ids (list_predicate_ids() already holds them as u32) before decoding anything. A CONSTRUCT scenario in query_hot_list_view (plain vs listed) would keep this from coming back, since query_hot_construct_formats holds no list and never reaches this operator.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 1f22191

@@ -116,7 +116,6 @@ pub fn lower_sparql_with_source<E: IriEncoder>(
if let Ok(query) = &mut result {
query.include_system_facts = ast.pragmas.include_system_facts.unwrap_or(false);
query.union_default_graph = ast.pragmas.union_default_graph;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 Should address: query_hot_list_view panics at its sanity check after this change, which turns the nightly bench gate red.

With query.rdf_list_view = true gone from here, SPARQL's COUNT(*) over ?s ?p ?o counts list members as values, but fluree-db-api/benches/query_hot_list_view.rs:146 still asserts that the listed ledger counts the owner edge plus two triples per cell. Running cargo test -p fluree-db-api --bench query_hot_list_view at this head gives left: [[20002]], right: [[20005]], and a panic. bench.yml's nightly bench-gate smoke-runs every bench with -- --test and fails on a panic (bench.yml:46-47, :101), so it goes red the first night after merge.

The bench's premise moved too: its module doc describes the RDF view on every SPARQL pattern, and scenario 7 (ex:order/rdf:rest*/rdf:first) now finds nothing on either ledger. I think the natural repair is to re-aim it at what a list costs now: fix the count, drop or repoint the walk, and add the CONSTRUCT scenario from the list_entries.rs comment, keeping its regression-budget.json entry.

Commenting here because fluree-db-api/benches/query_hot_list_view.rs is not in this diff.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 1f22191

Comment thread fluree-db-api/tests/it_sparql_lists.rs Outdated

// ---------------------------------------------------------------------------
// Policy judges a list's changes as its owner's.
// A post-state policy condition reads a list stored as its triples.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 Should address: the policy check on a chain-stored list's cells lost its only test, and its docs line.

a_list_change_is_judged_as_its_owners went out with the cell-edit tests, but half of it was about lists stored as their triples, which this PR keeps (a second list on one subject and property, or a list whose cells something else names). Their cells are plain triples a SPARQL update can still edit, and list_owner_checks (fluree-db-transact/src/stage.rs:2586) is what judges such an edit as a change to the owner's property.

I wrote a scratch test with ex:s ex:items (1 2) and then (3 4) (stored as a chain), under a policy denying modify on ex:items. At this head, DELETE { ?h rdf:first 3 } INSERT { ?h rdf:first 99 } WHERE { ex:s ex:items ?h . ?h rdf:first 3 } is refused. With list_owner_checks returning nothing it's permitted, and it_sparql*, it_delete_stored_facts and it_list_identity all stay green.

So the guard works, but nothing would notice it going away. I'd restore the stored-as-triples half of the old test here (the helpers it needs are still in this file), plus the sparql.md line "Under a policy, a change to a list's cells is judged as a change to its owner's property", scoped to lists stored as their triples. It's a small change, but since it's a policy guarantee I'd rather see it folded in now.

Commenting here because fluree-db-transact/src/stage.rs:2586 is not in this diff.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in a6c3a0d

Comment thread fluree-db-transact/src/stage.rs Outdated
// A write can state a list as a chain of the blank nodes it mints,
// which is stored as the list it spells (`crate::list_edits`).
let mut list_edits = crate::list_edits::ListEdits::writes_chain(&txn.insert_templates)
.then(|| crate::list_edits::ListEdits::new(None, &txn_id));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Optional: with None here on every path, the list-view half of ListEdits can no longer run.

ListEdits::new is only ever given None now, so view, view(), view_cell, read_lists, the if let Some(view) block in store (list_edits.rs:188-212) and the rewrite_patterns branch in stream_where_into_accumulator (stage.rs:3026-3031) are dead, and the module doc of list_edits.rs (lines 4-5) still describes WHERE rows naming cells. The compiler can't flag any of it, because the Option is only None at runtime. Dropping the field would also drop fluree-db-transact's import of list_view::{ListView, Owner}.

This is minor and non-blocking, but if you agree it's right I'd rather see it folded in now than lost in the backlog.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in fd80fc8

let here = held.entry(owner.clone()).or_default();
// The list held is restated as stored: a compact list at its own
// positions, which a delete can leave apart, a chain with its cells.
let stored = if !here.compact.is_empty() && same_members(&here.compact, &list.members) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Restating the held list at its stored positions is exactly the mechanism #2180 named, so this fixes it.

I ran #2180's repro at this head and at 42bb9646c. JSON-LD (filter-delete 2, then insert [1, 3]) and the one-update variant both read [1, 3] here and [1, 3, 3] on main, and a Turtle re-insert after DELETE DATA reads [1, 3] too. Reverting this line to restate list.members turns restating_a_list_keeps_its_positions red, so the test pins it.

If you agree, adding Fixes #2180 to the body would close the issue when this merges.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added Fixes #2180 to the PR body.

… holds them

On a ledger holding any list, ListEntriesOperator decoded every CONSTRUCT
row's subject and predicate, and awaited a lookup that built its whole
read future, before asking whether the predicate could hold a list. A
predicate no list touches paid that on every row.

ListEntriesOperator::over now drops the marked template triples whose
constant predicate holds no list, and returns the plan unwrapped when none
are left. For a variable predicate, a row bound to an index predicate id
is checked against the list predicates' ids (ListView::may_hold_lists_id)
before anything is decoded, and a synchronous check (`named`) settles
every row that names no list entry before the async read is reached.

In a debug build, on 20k indexed subjects plus one unrelated list,
execution only: `CONSTRUCT { ?s ex:name ?o } WHERE { ?s ex:name ?o }` goes
from 45 ms to 5 ms (5 ms without the list), and
`CONSTRUCT { ?s ?p ?o } WHERE { ?s ?p ?o }` from 240 ms to 31 ms (27 ms).

query_hot_list_view asserted the RDF view's whole-graph count, which
SPARQL no longer reads, and panicked at its sanity check. It now measures
what a list costs: the count reads the members as values, the property
path walk becomes a read of the members, and two CONSTRUCT scenarios
cover a fixed and a variable predicate. The sanity check confirms the
listed ledger's CONSTRUCT writes its list.
…h holding rdf:first

A JSON-LD crawl reads a list stored as rdf:first/rdf:rest triples as its
members. To find one it walked the chain from every blank-node value of
every crawled predicate, at least one SPOT read each, on any ledger.

HydrationFormatter::holds_cells asks once per response, when the crawl
first meets a blank-node value, whether the graph holds any rdf:first: a
one-row PSOT read through the index and novelty. Without one, no blank
node heads such a list and the walk is skipped. A compact list stores no
rdf:first, so it leaves the walk off too.

In a debug build, crawling 20k indexed subjects that each hold a
blank-node value goes from 850 ms to 740 ms. query_hot_list_view gains a
crawl/blank_nodes scenario, and its ring subjects each hold an ex:addr
blank node.

Test: a_crawl_reads_a_list_stored_as_triples_from_the_index_or_novelty
(a chain only in the index; a chain only in novelty over an index that
holds no rdf:first).
…er's

A list stored as its triples, like a second list on one subject and
property, keeps cells a SPARQL update can edit, and list_owner_checks
judges such an edit as a change to the owner's property. Its only test
went out with the cell-edit tests, so nothing noticed the guard going.

a_change_to_a_stored_cell_is_judged_as_its_owners edits a chain's head
and second cell under a policy denying modify on the owner's property,
and is refused each time; the same edit of a list on another property
goes through. The SPARQL guide says so again, scoped to lists stored as
their triples.
ListEdits was only ever built without a view, so the half that edited
the cells a WHERE row named could not run: reading the named lists,
restating their cells, the unjudged facts kept from the modify check,
and diverting retractions. What is left is what runs: the assertions
naming a cell the transaction mints are chained into lists and stored
compactly where they can be.

With no unjudged facts, enforce_modify_policies takes the one slice
every caller already passed twice. ListView::cell_of and members_of,
and RetractIntent::into_flake, lose their last callers and go too.
@bplatz

bplatz commented Oct 31, 2026

Copy link
Copy Markdown
Contributor Author

On the two product calls: both stay as written.

  1. SPARQL reads a list's members as values, and only the Graph Store GET keeps the RDF view. List positions come back with the list-ID work on next.
  2. A delete naming a value with no position takes every list entry holding it, and the value beside the list, on SPARQL and JSON-LD alike. Upserting the list is how to remove a single entry.

@bplatz bplatz added the breaking-change Backwards-incompatible change; drives the Breaking Changes release-notes section label Oct 31, 2026
@bplatz bplatz changed the title fix(sparql): read a list's members as values; CONSTRUCT writes the lists it reads fix(lists): SPARQL reads list members as values, CONSTRUCT writes lists, deleting a value takes every entry Oct 31, 2026
@bplatz
bplatz merged commit 238c991 into main Oct 31, 2026
19 checks passed
@bplatz
bplatz deleted the fix/sparql-lists-member-view branch October 31, 2026 12:03
bplatz added a commit that referenced this pull request Oct 31, 2026
Brings #2217 (SPARQL reads list members as values; CONSTRUCT writes lists),
#2218 (schema writes judged by modify policy), #2208, #2169, #2168, #2153,
#2149 and #2148 into next.

Resolutions:
- Nameservice: branch_records is the one branch listing (strict, retracted
  branches kept for GC) on every backend, resolved through next's bindings;
  Fluree::list_branches filters retracted ones. The lifecycle conformance
  suite reads live branches through a helper. DynamoDB's narrow listing is
  wired into its trait impl.
- JSON-LD adapter: main's graph scoping (Walk, Scope, node_graph, selectors)
  with next's triple terms, @annotation, @reifies, blank-label and number
  datatype handling. to_graph_events writes a JSON-LD named graph under its
  @id and refuses a graph selector. main's f:reifiesGraph anchor is dropped:
  next writes an annotation as an rdf:reifies link in its graph.
  emit_quad_list_item takes (graph, index).
- Bulk import: an annotation's link is written to the graph its slots name,
  and a triple-term statement in a named graph is spooled under that graph
  (both landed in the default graph); emit_quad_reified_triple is
  implemented. resolve_object_value keeps main's vector refusals and next's
  term-table path.
- Ledger manager: a store that fails to load fails the load or keeps the
  reloaded ledger's state (main), over next's load_decoding_root and
  activation swap rule.
- Novelty keeps main's KeptEffects without the retired arena's reifies
  capture. The pool's resolve_events_at and compaction's split_lifecycles
  follow fluree_db_core::same_t.
- Retired annotation arena files stay deleted.
- Tests from main adapted to next: one Fluree per storage directory, async
  genesis_ledger, storage-namespace content stores, u32 graph ids, a store
  broken by hiding a dictionary branch (next has no disk cache), a refused
  import leaving no ledger. next's tests that pinned bulk import refusing
  @graph and SPARQL's RDF list view now check what main changed them to.
bplatz added a commit that referenced this pull request Nov 1, 2026
SPARQL reads a list's members as values again (#2217), so
`VALUES ?s { ex:a ex:a } ?s ?p ?o` returns the name and the three members
for each driving row, through the batched wildcard lane, as the JSON-LD
twin does. The test expected the RDF list view's name and head cell, with
the lane not firing. It now expects the members and the lane, and checks
the SPARQL rows against the JSON-LD rows.
bplatz added a commit that referenced this pull request Nov 5, 2026
…N-LD does

The test was written when SPARQL read only an RDF list's head, so it
expected one list row per driving row and the batched wildcard lane to
decline. #2217 has SPARQL read a list's members as values, as a JSON-LD
query does: the query now reads the name and every member, takes the lane,
and agrees with the generic lane and with the JSON-LD rows.
bplatz added a commit that referenced this pull request Nov 5, 2026
The test read a list through ex:list/rdf:rest*/rdf:first, which SPARQL
matched before #2217. A list's cells are not triples SPARQL matches now:
it reads the members as values of the property, as JSON-LD does, and the
path finds nothing, as docs/query/sparql.md says.
aaj3f added a commit that referenced this pull request Nov 13, 2026
#2217 has SPARQL read a list's members as values, as JSON-LD does, and
keeps the RDF view of lists only for the Graph Store GET. The lane tests
still expected SPARQL to read a list's cells, and the union lanes to stand
down for it with fallback:list_view.

- The list fixtures check hand-written answers on both surfaces, with
  fast paths on and off: each member is a fact by its list position, so a
  repeated member is a row each time. SPARQL must route as JSON-LD does,
  and over lists two indexed members hold, every union site must answer.
- The grouped count, per-predicate count, object count, EXISTS cache,
  cyclic join and union probe cases take the values reading for SPARQL,
  the answers their JSON-LD twins already had.
- One case keeps the RDF view covered: the per-predicate count under the
  Graph Store GET's execution option stands down with fallback:list_view
  and answers the cells.
- The union probes' per-member novelty checks run on both surfaces.
- Comments that said SPARQL reads lists as RDF now name the Graph Store
  GET.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking-change Backwards-incompatible change; drives the Breaking Changes release-notes section bug Something isn't working as expected

Projects

None yet

2 participants