src.dackar.RCA.synthesis.analyst_override_processor¶
analyst_override_processor — AnalystOverrideProcessor.
Accepts a completed RCA card + analyst override input, validates the override, mutates the card to reflect the analyst decision, and returns a structured AnalystOverride artifact for persistence and audit-history mining.
Override record schema: schemas/analyst_override.json
Attributes¶
Classes¶
Applies a structured analyst override to an RCA card. |
Functions¶
Module Contents¶
- class src.dackar.RCA.synthesis.analyst_override_processor.AnalystOverrideProcessor[source]¶
Applies a structured analyst override to an RCA card.
Usage:
processor = AnalystOverrideProcessor() modified_card, override_record = processor.apply( rca_card=card, override_input={ "override_type": "primary_candidate_change", "rationale": "DO elevation unambiguously supports air in-leakage", "override_primary_candidate_id": "CAND-AIR-INLEAK", "writeback_decision": "accept", }, run_context={"run_id": "run-001"}, )
The returned modified_card is a copy of the original card with the override applied in-place. The override_record conforms to
schemas/analyst_override.jsonand should be persisted by the caller.- apply(rca_card, override_input, run_context)[source]¶
Apply an analyst override and return (modified_card, override_record).
- Parameters:
rca_card (JsonDict) – The RCA card produced by the synthesis step.
override_input (JsonDict) –
Dict with the following keys:
- Required:
override_type(str) — one of the _VALID_OVERRIDE_TYPESrationale(str, non-empty) — analyst rationalewriteback_decision(str) — “accept” | “reject” | “defer”
- Optional:
analyst_id(str)override_primary_candidate_id(str) — required when override_type == “primary_candidate_change”questions_resolved(list of {question, answer, resolution_type})evidence_additions(list of {evidence_ref, support_role, added_by_analyst, notes?})caveats(list of str)
run_context (JsonDict) – Orchestrator run context (must contain
run_id).
- Returns:
(modified_rca_card, override_record)
- Return type:
- Raises:
ValueError – On invalid override_input.
- _compute_primary_diff(original, new_primary, override_type)[source]¶
Return a structured before/after delta for primary_candidate_change overrides.
Fields compared: candidate_id, cause_label, composite_score, confidence_label. Returns None for override types that don’t change the primary candidate.
- _swap_primary(card, target_id, rationale)[source]¶
Promotes the alternative with candidate_id == target_id to primary. Demotes the current primary to alternatives. Returns (override_primary_snapshot, mutated_card).
- _apply_accepted_state(card, caveats, require_gate_pass=False)[source]¶
Mark the card accepted, or hold it for review when a swap left the promoted primary without evidence.
When
require_gate_passis True (a primary_candidate_change), the card is marked writeback-ready only if the recomputed validation gates still pass; otherwise it is held for analyst review with an attention flag. For a plain accept the gates are left as the synthesizer computed them.- Parameters:
card (JsonDict)
caveats (List[str])
require_gate_pass (bool)
- Return type:
None