src.dackar.RCA.cross_pattern.linker¶
Attributes¶
Classes¶
Links historical signal episodes to doc extractions for each RCA candidate. |
Functions¶
|
Recursively convert dataclasses (and nested structures) to plain dicts. |
Module Contents¶
- src.dackar.RCA.cross_pattern.linker._dataclass_to_dict(obj)[source]¶
Recursively convert dataclasses (and nested structures) to plain dicts.
- Parameters:
obj (Any)
- Return type:
Any
- class src.dackar.RCA.cross_pattern.linker.CrossPatternLinker(config)[source]¶
Links historical signal episodes to doc extractions for each RCA candidate.
Usage¶
linker = CrossPatternLinker(config) result = linker.run(episodes, doc_extractions, candidates)
The returned dict is JSON-serializable and contains: - “candidate_evidence”: list of CandidateCrossPatternEvidence as dicts - “all_links”: all CrossPatternLink as dicts - “summary”: top-level counts and distribution
- run(episodes, doc_extractions, candidates)[source]¶
Build cross-pattern evidence.
Algorithm per candidate¶
Check index_status on all episodes. If all are “no_episodes_indexed” or no doc_extractions exist → outcome = “no_data”.
Filter episodes by signal_similarity_floor.
For each surviving episode × doc_extraction pair: a. Check asset compatibility (same asset_id). b. Determine precedence level. c. Compute temporal overlap (level ≤ 2) or skip (level 3). d. Apply temporal gate if mode == “gate”. e. Compute fm_alignment_score: 1.0 when fm_id_candidate matches
candidate.fm_id, else None.
Compute document_similarity_score: None (Phase 2 placeholder).
Compute temporal_compatibility_score from overlap hours.
Compute link_confidence.
Apply stale cap when episode.index_status == “stale”.
Redundancy suppression: for each (episode_id, doc_id) pair keep only the highest-precedence link.
Filter links by link_confidence_threshold.
Build CandidateCrossPatternEvidence.
This method does NOT mutate its inputs. Episode↔doc linkage is reported entirely in the returned dict (per-candidate
linked_episode_ids/linked_doc_idsand the flatall_links), so callers can safely reuse the sameepisodes/doc_extractionslists across calls.- Parameters:
episodes (List[Any])
doc_extractions (List[src.dackar.RCA.cross_pattern.models.HistoricalDocExtraction])
candidates (List[Dict[str, Any]])
- Return type:
Dict[str, Any]
- Parameters:
config (src.dackar.RCA.cross_pattern.config.CrossPatternConfig)