Some checks failed
check agents / check (push) Failing after 14s
- Report (cp1-assessment-report-agent 0.2.0, step s7): a model writes the Assessment report from facts worked out in code (register, gaps, scorecard, rule traces, checks, and what each application is from the Discovery package); code sets the verdict and renders the pages. The disposition_signoff review point moves from the critic to the report. - Package (cp1-assessment-package-agent 0.1.1, step s8): after sign-off, every step's output in one package, with a register, a gaps register, the sign-off record, lineage and a sha256 per part, in code. Page step s9. - scripts/kab_register_agents.py: registers deployed agents in KAB's agent catalog (an in-place workflow update doesn't). - Runs exec_1b1257380df7 (014) and exec_374d5d577077 (015) completed on crucible-kab-dev: critic pass, report figures all in its facts, package complete with every digest recomputing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
84 lines
5.1 KiB
Python
84 lines
5.1 KiB
Python
"""The facts the report is written from (F02 ADR 0015), worked out in code from the Assessment step outputs.
|
|
|
|
The register, gaps and scorecard come from `app/package.py`, a copy of the package agent's own module (the two images
|
|
are separate; tests/test_report.py keeps the copies identical), so the report and the package can't disagree. The model
|
|
receives these facts instead of the raw step outputs and writes the report from them.
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
from typing import Any, Dict, List
|
|
|
|
from app import discovery as discovery_records, package
|
|
|
|
TOP_FINDINGS = 10
|
|
SHORT = 400 # characters kept of a long basis or description
|
|
|
|
|
|
def _short(text: Any) -> Any:
|
|
return text if not isinstance(text, str) or len(text) <= SHORT else text[:SHORT].rstrip() + " …"
|
|
|
|
|
|
def build(payload: dict) -> Dict[str, Any]:
|
|
parts = package.parts_from(payload)
|
|
reg = package.register(parts)
|
|
gap = package.gaps(parts)
|
|
critic = parts["critic"] or {}
|
|
security = parts["security"] or {}
|
|
plan = parts["plan"] or {}
|
|
discovery = parts["discovery"] or {}
|
|
dispositions: List[dict] = []
|
|
for d in (parts["dispositions"] or {}).get("dispositions") or []:
|
|
tco = d.get("tco_model") or {}
|
|
dispositions.append({
|
|
"application_id": d.get("application_id"), "disposition": d.get("disposition"),
|
|
"confidence": d.get("confidence"), "interim_rule": d.get("interim_rule"),
|
|
"rule_trace": [{"category": t.get("category"), "matched": t.get("matched"), "basis": _short(t.get("basis"))}
|
|
for t in d.get("rule_trace") or []],
|
|
"confidence_workings": d.get("confidence_workings"),
|
|
"tco": {k: tco.get(k) for k in ("currency", "current_annual", "target_annual", "annual_delta", "indicative")},
|
|
"tco_line_items": tco.get("line_items") or [],
|
|
"licensing_note": _short(d.get("licensing_note")), "scoring_note": _short(d.get("scoring_note")),
|
|
})
|
|
findings = sorted((f for f in security.get("findings") or [] if isinstance(f, dict)),
|
|
key=lambda f: -(f.get("rank_score") or 0))
|
|
controls: Dict[str, int] = {}
|
|
for c in security.get("controls") or []:
|
|
if isinstance(c, dict):
|
|
controls[c.get("result") or "unknown"] = controls.get(c.get("result") or "unknown", 0) + 1
|
|
return {
|
|
"engagement_id": payload.get("engagement_id"), "run_id": payload.get("run_id"),
|
|
"lineage": {"discovery_execution_id": payload.get("discovery_execution_id"),
|
|
"discovery_run_id": discovery.get("discovery_run_id"),
|
|
"discovery_package_verified": discovery.get("verified"),
|
|
"discovery_approval_ref": payload.get("discovery_approval_ref"),
|
|
"discovery_source_gaps": discovery.get("source_gaps") or [],
|
|
"rate_card_id": plan.get("rate_card_id"),
|
|
"critic_model": critic.get("critic_model"), "executor_models": critic.get("executor_models"),
|
|
"agent_versions": payload.get("agent_versions") or {}},
|
|
"verdict": critic.get("verdict"),
|
|
"critic": {"summary": critic.get("summary"),
|
|
"checks": [{"check_id": c.get("check_id"), "result": c.get("result"),
|
|
"details": [_short(x.get("reason")) for x in c.get("details") or [] if isinstance(x, dict)]}
|
|
for c in critic.get("checks") or [] if isinstance(c, dict)],
|
|
"rejected_dispositions": critic.get("rejected_dispositions") or [],
|
|
"signoff_queue": critic.get("signoff_queue") or [],
|
|
"unverified_claims": critic.get("unverified_claims") or [],
|
|
"checked_in_code": ["K-02 citation lookup", "K-04", "K-05", "K-06", "K-07", "K-11", "the verdict"]},
|
|
# What each application is, from the Discovery package (ADR 0015 addendum): its assets, owner and links.
|
|
"applications": discovery_records.applications(payload.get("discovery_documents")),
|
|
"plan": {"preconditions": plan.get("preconditions"), "summary": plan.get("summary"),
|
|
"coverage_gaps": plan.get("coverage_gaps") or [], "in_cloud_estate": plan.get("in_cloud_estate")},
|
|
"register": reg["applications"],
|
|
"dispositions": dispositions,
|
|
"risk": {"high_risk_tail": (parts["risk"] or {}).get("high_risk_tail") or [],
|
|
"note": _short((parts["risk"] or {}).get("findings_note"))},
|
|
"security": {"status": security.get("status"), "posture_score": security.get("posture_score"),
|
|
"findings_total": len(findings), "controls_by_result": controls,
|
|
"top_findings": [{"finding_id": f.get("finding_id"), "application_id": f.get("application_id"),
|
|
"control_id": f.get("control_id"), "rank_score": f.get("rank_score"),
|
|
"description": _short(f.get("description"))} for f in findings[:TOP_FINDINGS]],
|
|
"advisory": reg["security_note"]},
|
|
"gaps": gap,
|
|
"scorecard": package.scorecard(parts, reg, gap),
|
|
}
|