Files
FusionAGI/fusionagi/maa/audit.py
defiQUG c052b07662
Some checks failed
Tests / test (3.10) (push) Has been cancelled
Tests / test (3.11) (push) Has been cancelled
Tests / test (3.12) (push) Has been cancelled
Tests / lint (push) Has been cancelled
Tests / docker (push) Has been cancelled
Initial commit: add .gitignore and README
2026-02-09 21:51:42 -08:00

36 lines
1.6 KiB
Python

"""Audit and reporting: export MPC and root-cause report format."""
from typing import Any
from fusionagi.maa.schemas.mpc import ManufacturingProofCertificate
from fusionagi.maa.gap_detection import GapReport
def export_mpc_for_audit(cert: ManufacturingProofCertificate) -> dict[str, Any]:
"""Export MPC in audit-friendly format."""
out: dict[str, Any] = {
"mpc_id": cert.mpc_id.value,
"mpc_version": cert.mpc_id.version,
"decision_lineage": [{"node_id": e.node_id, "family": e.family, "outcome": e.outcome} for e in cert.decision_lineage],
"risk_register": [{"risk_id": r.risk_id, "severity": r.severity} for r in cert.risk_register],
"metadata": cert.metadata,
}
if cert.simulation_proof:
out["simulation_proof"] = {"proof_id": cert.simulation_proof.proof_id}
if cert.process_justification:
out["process_justification"] = {"process_type": cert.process_justification.process_type, "eligible": cert.process_justification.eligible}
if cert.machine_declaration:
out["machine_declaration"] = {"machine_id": cert.machine_declaration.machine_id}
return out
def format_root_cause_report(gaps: list[GapReport], tool_name: str = "", context_ref: str = "") -> dict[str, Any]:
"""Human-readable root-cause report for gap/tool rejections."""
return {
"report_type": "maa_root_cause",
"tool_name": tool_name,
"context_ref": context_ref,
"gaps": [{"gap_class": g.gap_class.value, "description": g.description, "required_resolution": g.required_resolution} for g in gaps],
"summary": f"{len(gaps)} gap(s) triggered halt.",
}