dodil/erp-brick-consolidation

DODIL ERP brick: consolidation

src/brick_consolidation/domain/ai_finding.py

"""The AiFinding aggregate — the rules, and nothing else.

an AI explanation of an elimination difference and the person's decision

No database, no HTTP, no identity: a rule here is true whoever calls it and however it is stored.
Generated by `erp-compose scaffold` from module.yaml; the TODO lines are the work left.
"""
from dataclasses import dataclass, field
from datetime import datetime
from typing import Optional


@dataclass
class AiFinding:
    """an AI explanation of an elimination difference and the person's decision"""
    finding_id: str
    group_id: str = ""
    period_id: str = ""
    pair: str = ""
    model: str = ""
    inputs_digest: str = ""
    finding: str = ""
    evidence: str = ""
    decision: str = ""
    decided_by: str = ""
    decided_at: Optional[datetime] = None
    events: list = field(default_factory=list, repr=False, compare=False)

    def _record(self, event):
        self.events.append(event)
        return event