src.dackar.RCA.orchestrators.evidence_retriever¶
Attributes¶
Classes¶
Duck-typed protocol for anything that can embed a list of strings. |
|
Abstract retrieval backend, e.g. Chroma via LangChain. |
|
Deterministic KG-guided evidence retriever. |
|
Development stub that mimics Chroma-style retrieval. |
Functions¶
|
|
|
|
|
|
|
|
|
Return True when a negation trigger is adjacent, within a short window, to a |
|
Cosine similarity between two pre-normalised numpy vectors. |
Module Contents¶
- src.dackar.RCA.orchestrators.evidence_retriever._norm_text(value)[source]¶
- Parameters:
value (Any)
- Return type:
str
- src.dackar.RCA.orchestrators.evidence_retriever._tokenize(value)[source]¶
- Parameters:
value (Any)
- Return type:
List[str]
- src.dackar.RCA.orchestrators.evidence_retriever._overlap_score(query_terms, text_terms)[source]¶
- Parameters:
query_terms (List[str])
text_terms (List[str])
- Return type:
float
- src.dackar.RCA.orchestrators.evidence_retriever._contains_any(text, phrases)[source]¶
- Parameters:
text (str)
phrases (List[str])
- Return type:
bool
- src.dackar.RCA.orchestrators.evidence_retriever._NEGATION_MULTIWORD_TRIGGERS = ('no evidence of', 'no sign of', 'no signs of', 'no indication of', 'no indications of', 'did...[source]¶
- src.dackar.RCA.orchestrators.evidence_retriever._negation_refutation_hit(snippet, target_terms)[source]¶
Return True when a negation trigger is adjacent, within a short window, to a degradation/failure-state term — i.e. the snippet refutes a degradation claim.
Deterministic and high-precision by design (short scope window; state-term targets only).
snippetmust already be normalised (lowercased, whitespace-collapsed).- Parameters:
snippet (str)
target_terms (frozenset)
- Return type:
bool
- src.dackar.RCA.orchestrators.evidence_retriever._cosine_sim(a, b)[source]¶
Cosine similarity between two pre-normalised numpy vectors.
Both a and b must already be unit-norm. Returns a float in [0, 1] (clipped to exclude numeric noise below zero).
- Parameters:
a (Any)
b (Any)
- Return type:
float
- class src.dackar.RCA.orchestrators.evidence_retriever._EmbeddingEncoder[source]¶
Bases:
ProtocolDuck-typed protocol for anything that can embed a list of strings.
Compatible with
SentenceTransformer,langchainembedders, and any object whoseencodemethod acceptsList[str]and returns an array-like of shape(N, D).
- class src.dackar.RCA.orchestrators.evidence_retriever.EvidenceStore[source]¶
Bases:
ProtocolAbstract retrieval backend, e.g. Chroma via LangChain.
- class src.dackar.RCA.orchestrators.evidence_retriever.ChromaEvidenceRetriever(store, config=None, annotator=None, encoder=None)[source]¶
Deterministic KG-guided evidence retriever.
- Parameters:
store (EvidenceStore)
config (Optional[EvidenceRetrieverConfig])
encoder (Optional[_EmbeddingEncoder])
- _embed(text)[source]¶
Return a unit-norm embedding vector for text, or
Noneif no encoder.Results are cached in
self._emb_cache(reset at the start of eachretrieve()call) so each unique text is encoded at most once per retrieval session.- Parameters:
text (str)
- Return type:
Optional[Any]
- retrieve(event, kg_context, causality_candidates, operational_context, run_context)[source]¶
Retrieve and rank documentary evidence for the causal candidates.
Builds per-candidate queries from the KG context, runs them against the Chroma store, normalizes and de-duplicates the hits, assesses each hit’s support role against its candidate, and summarizes the evidence per candidate.
- Parameters:
event (JsonDict) – Target abnormal event (supplies
asset_idand query terms).kg_context (JsonDict) – KG neighbourhood providing documents and components to query over.
causality_candidates (JsonDict) – Candidate hypotheses whose cause labels seed the queries.
operational_context (Optional[JsonDict]) – Optional operating-state input influencing query planning, or None.
run_context (JsonDict) – Orchestrator run context.
- Returns:
Evidence bundle conforming to
schemas/evidence_bundle.json. Each entry inresultscarries top-levelsnippet_id/support_scoreand, undermetadata,support_roleand thelinked_candidate_idused by downstream stages.- Return type:
- static _component_filter_mode(*, merged_hits, component_ids_requested)[source]¶
- Parameters:
merged_hits (Sequence[JsonDict])
component_ids_requested (bool)
- Return type:
str
- class src.dackar.RCA.orchestrators.evidence_retriever.InMemoryEvidenceStore(rows=None)[source]¶
Development stub that mimics Chroma-style retrieval.
- Parameters:
rows (Optional[List[JsonDict]])