trustgraph/tests/unit/test_retrieval
cybermaggedon 35128ff019
Add unified explainability support and librarian storage for (#693)
Add unified explainability support and librarian storage for all retrieval engines

Implements consistent explainability/provenance tracking
across GraphRAG, DocumentRAG, and Agent retrieval
engines. All large content (answers, thoughts, observations)
is now stored in librarian rather than as inline literals in
the knowledge graph.

Explainability API:
- New explainability.py module with entity classes (Question,
  Exploration, Focus, Synthesis, Analysis, Conclusion) and
  ExplainabilityClient
- Quiescence-based eventual consistency handling for trace
  fetching
- Content fetching from librarian with retry logic

CLI updates:
- tg-invoke-graph-rag -x/--explainable flag returns
  explain_id
- tg-invoke-document-rag -x/--explainable flag returns
  explain_id
- tg-invoke-agent -x/--explainable flag returns explain_id
- tg-list-explain-traces uses new explainability API
- tg-show-explain-trace handles all three trace types

Agent provenance:
- Records session, iterations (think/act/observe), and conclusion
- Stores thoughts and observations in librarian with document
  references
- New predicates: tg:thoughtDocument, tg:observationDocument

DocumentRAG provenance:
- Records question, exploration (chunk retrieval), and synthesis
- Stores answers in librarian with document references

Schema changes:
- AgentResponse: added explain_id, explain_graph fields
- RetrievalResponse: added explain_id, explain_graph fields
- agent_iteration_triples: supports thought_document_id,
  observation_document_id

Update tests.
2026-03-12 21:40:09 +00:00
..
test_structured_diag Fix tests (#593) 2025-12-19 08:53:21 +00:00
test_document_rag.py Adding explainability to the ReACT agent (#689) 2026-03-11 15:28:15 +00:00
test_document_rag_service.py Add unified explainability support and librarian storage for (#693) 2026-03-12 21:40:09 +00:00
test_graph_rag.py Terminology Rename, and named-graphs for explainability (#682) 2026-03-10 14:35:21 +00:00
test_graph_rag_service.py GraphRAG Query-Time Explainability (#677) 2026-03-10 10:00:01 +00:00
test_nlp_query.py Fix/sys integration issues (#494) 2025-09-05 08:38:15 +01:00
test_structured_query.py Structured data 2 (#645) 2026-02-23 15:56:29 +00:00