Repository navigation
Description
Replacing a source retires relations supported by manually added evidence when the manual evidence has the same source_id. The relation then disappears from current lookups, although its history remains stored.
docs/inserting.md says: "Evidence added by hand always counts."
Reproduced on main at 8124bee74334e9a5555afa52ce2d05ffc93b89d4, using Python 3.13, Kuzu, and a deterministic extractor. No LLM is involved.
Install the checkout with python -m pip install -e '.[kuzu]', then run:
import asyncio
import tempfile
from selfgraph import Extraction, KuzuStore, SelfGraph
class EmptyExtractor:
async def extract(self, document):
return Extraction()
async def main():
with tempfile.TemporaryDirectory() as tmp:
store = KuzuStore(tmp + "/graph", buffer_pool_size=128 * 1024 * 1024)
async with SelfGraph(store=store, extractor=EmptyExtractor()) as graph:
ann = await graph.entities.create("Ann", "Person")
acme = await graph.entities.create("Acme", "Company")
rel = await graph.relations.create(
ann.id, "WORKS_AT", acme.id, evidence=[{"source_id": "hr"}]
)
print("before:", await graph.relations.get(rel.id) is not None)
result = await graph.insert.text(
"The updated source contains no employment fact.",
source_id="hr",
replace_source=True,
)
print("after:", await graph.relations.get(rel.id) is not None)
print("retired:", result.source_diff.retired)
print("warnings:", [warning.code for warning in result.warnings])
asyncio.run(main())Actual output:
before: True
after: False
retired: ['relation:a4b698967fceb2c72cc81f83']
warnings: ['fact_retired_by_source']
Expected: the relation stays current and source_diff.retired is empty. A manual assertion should not be withdrawn just because a document with the same source ID is ingested or replaced.
The Python and TypeScript implementations encode manual evidence as <source_id>:manual, but replace_source only accepts the incoming generated version for evidence sharing the replaced source ID. The same predicate appears in both SDKs:
I can send a small fix in both SDKs, with regressions for manual-only and mixed manual/generated support, while preserving generated-only retirement and removal of replaced passages. Please approve this issue if that approach fits.
Activity
PRADDZY commentedon Nov 15, 2026
The mirrored fix is ready at 583f4d5.
Both new regressions fail before the fix in each SDK. With the fix, Kuzu checks pass:
The four-file patch only adds the manual-evidence guard and mirrored regressions. Generated-only retirement, certification, and replacement of other supporting sources keep their existing behavior. The mixed-support test also checks that replaced passages stay hidden from current retrieval but remain available historically.
I am holding the PR until this issue is approved, per CONTRIBUTING.md.
arrry-hydraDB commentedon Nov 15, 2026
/approved
Reproduced on 0.2.1, go ahead.
github-actions commentedon Nov 15, 2026
Approved by @arrry-hydraDB. @PRADDZY or an assignee of this issue can now open a PR that links it with
Closes #30(max 3 open PRs at a time).arrry-hydraDB commentedon Nov 20, 2026
@IronicRayquaza assigned you, continuing in #276.