Repository navigation
Description
A re-ingest silently deletes triples on the document node and on every relation node of that document, including triples the pipeline never wrote. The run reports success and exits 0. The same construct fails in the opposite direction on edge annotations, where it cannot delete the thing it is supposed to — so one line is simultaneously a silent deletion and a silent leak.
The construct
retract_update (fluree-db-doc/src/graph.rs:134-146) builds:
DELETE { ?s ?p ?o }
WHERE {
{ ?s doc:sourceDocument <iri> . ?s ?p ?o }
UNION
{ VALUES ?s { <iri> } ?s ?p ?o }
}Its own doc comment says it "retracts everything a previous extraction of this document wrote". That is the right intent and it is not what the query does — a variable predicate over a subject set deletes everything on those nodes, not everything this pipeline put there. Re-ingest is retract-then-insert rather than a diff (doc.rs:694-703: retract_update, then drop_unsupported_edges at graph.rs:187-207, then insert), so the wildcard runs on every run.
Over-reach — verified live
Attach a curated weight to a document node and a reviewer's override to a relation node, both ordinary user triples:
$ fluree update -l memos --format sparql -e 'INSERT DATA {
<urn:fluree:doc:memo-a.md> ex:trust 0.9 .
<urn:fluree:doc:memo-a.md/relation/0> ex:reviewedConfidence 1.0 }'
Committed t=3, 2 flakes
$ fluree query … -> 2 rows ✓ both present
# edit memo-a.md, re-ingest
$ fluree doc ingest docs -l memos --model … --entities …
✓ memo-a.md parsed: 3 elements, 1 chunks, 2 mention(s) …
done: 1 ingested, 1 unchanged, 0 failed …
$ fluree query … -> 0 rows ✗ both gone, silently
Nothing in the output distinguishes that run from a clean one. The blast radius is at least correctly scoped per document — memo-b's relation node survived untouched and corroboration counts stayed right — so this is not a whole-ledger hazard. It is a hazard for anything a human curated on a node the pipeline also touches.
Under-reach — the same line, the opposite failure
The variable predicate is also why re-ingest cannot clean up after itself on annotations. ?p provably cannot surface f:reifies* facts: fluree-db-api/tests/it_edge_annotations.rs:1924 (variable_predicate_scan_hides_f_reifies) pins exactly that, and fluree-db-query/src/fast_count.rs:1075-1080 restates it as an invariant the fast paths have to respect — "The variable-predicate scan hides f:reifies* (and default-graph f:) facts."
So on a re-ingest of an edge that a second document also supports, step 1 strips this document's reifier body, step 2 keeps the base edge (the other document still supports it), and the attachment survives with an empty body — which is precisely the "well-formed-looking claim that describes nothing" state #1861 is about, arrived at by accident rather than by a user's delete. And because relation IRIs are positional ({doc_iri}/relation/0…n, numbered by the model's answer order, which is not stable across runs), step 3 can re-mint the same IRI onto a different (s,p,o) — at which point the net bundle has two targets and enforce_single_target_reifiers refuses the whole transaction.
One construct, a silent deletion and a silent leak, differing only in which predicates the scan can see. That is what makes it worth one issue rather than two.
Why it matters beyond the immediate loss
It closes off the obvious place to put human judgement. A curated trust weight, a reviewer's override, any human-in-the-loop signal at all — none of it can live on a document or relation node today, because the next ingest removes it without saying so. That constraint is currently invisible: nothing documents it, nothing warns, and the only way to discover it is to lose data.
Honestly: this is neither contract nor bug yet
Worth stating plainly, because it changes what the fix has to decide rather than just how it is written. The behaviour is untested in either direction — there is no test asserting that foreign triples are preserved, and none asserting they are swept. So it is not a regression against a stated contract; it is an accident nobody chose. Someone has to actually decide whether the pipeline exclusively owns the nodes it creates.
I think the answer is no, and the design work already depends on the answer being no: putting source trust on the document node and composing it at query time is the revisable shape, and it does not work at all while the wildcard stands. So I would settle it that way and make the sweep own-only.
The fix, which is in flight
Replacing the wildcard with an owned sweep — a three-way diff that retracts only what this run's own source graph owns, never a variable predicate. That is a pattern we do not have to invent: fluree/solo's fluree-lambda-identity/src/identity/evidence.rs (solo#1118, ~198 lines) runs it in production against this exact db revision, and the four pieces are a source marker on the annotation so a run can recognise what it owns, a deterministic reifier IRI so a re-run reattaches rather than re-mints, the owned-sweep diff itself, and a by-@id retract for the removals.
The same change closes both halves: own-only retraction stops deleting foreign triples, and naming the reifier explicitly makes the attachment removable, which is the thing the variable-predicate scan structurally cannot do. It is the first item in PR-C for that reason.
One thing not to copy from Solo, since it is the same defect we have: its own re-ingest mechanism is a doc-scoped ?s doc:sourceDocument ?d → delete ?s ?p ?o wipe, which is safe only for per-document island subjects and destructive on shared pre-existing entities.
Environment
main @ 3d89e8f71, release build (fluree 4.2.0), macOS.
Activity