generated from coulomb/repo-seed
individual run evidence, retained summaries, and trend comparison
This commit is contained in:
@@ -14,7 +14,8 @@ from guide_board.planning import (
|
||||
validate_assessment_profile,
|
||||
validate_target_profile,
|
||||
)
|
||||
from guide_board.retention import list_retained_runs
|
||||
from guide_board.retention import build_trend_summary, list_retained_runs
|
||||
from guide_board.schema import assert_valid
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
@@ -106,6 +107,44 @@ class CoreArchitectureTests(unittest.TestCase):
|
||||
self.assertEqual(len(mappings), 1)
|
||||
self.assertEqual(mappings[0]["target_id"], "profile-readiness")
|
||||
|
||||
def test_builds_retained_run_trends(self) -> None:
|
||||
with TemporaryDirectory() as temporary_directory:
|
||||
runs_dir = Path(temporary_directory)
|
||||
_write_retention_summary(
|
||||
runs_dir / "run-old",
|
||||
"run-old",
|
||||
"2026-05-07T10:00:00+00:00",
|
||||
"blocked",
|
||||
{"blocked": 1},
|
||||
1,
|
||||
1,
|
||||
)
|
||||
_write_retention_summary(
|
||||
runs_dir / "run-new",
|
||||
"run-new",
|
||||
"2026-05-07T11:00:00+00:00",
|
||||
"completed",
|
||||
{"manual": 1, "skipped": 1},
|
||||
0,
|
||||
2,
|
||||
)
|
||||
|
||||
trend = build_trend_summary(runs_dir)
|
||||
assert_valid(trend, "trend-summary")
|
||||
|
||||
self.assertEqual(trend["run_count"], 2)
|
||||
self.assertEqual(len(trend["groups"]), 1)
|
||||
group = trend["groups"][0]
|
||||
self.assertEqual(group["latest_run"]["run_id"], "run-new")
|
||||
self.assertEqual(group["previous_run"]["run_id"], "run-old")
|
||||
self.assertEqual(group["trend"]["direction"], "improved")
|
||||
self.assertTrue(group["trend"]["status_changed"])
|
||||
self.assertEqual(group["trend"]["unexpected_findings_delta"], -1)
|
||||
self.assertEqual(
|
||||
group["trend"]["evidence_result_deltas"],
|
||||
{"blocked": -1, "manual": 1, "skipped": 1},
|
||||
)
|
||||
|
||||
def test_runs_cmis_preflight_against_local_endpoint(self) -> None:
|
||||
server = HTTPServer(("127.0.0.1", 0), _CmisHandler)
|
||||
thread = threading.Thread(target=server.serve_forever)
|
||||
@@ -469,5 +508,49 @@ class _CmisHandler(BaseHTTPRequestHandler):
|
||||
return
|
||||
|
||||
|
||||
def _write_retention_summary(
|
||||
run_dir: Path,
|
||||
run_id: str,
|
||||
created_at: str,
|
||||
status: str,
|
||||
evidence_results: dict[str, int],
|
||||
unexpected_findings: int,
|
||||
artifact_count: int,
|
||||
) -> None:
|
||||
run_dir.mkdir(parents=True, exist_ok=True)
|
||||
(run_dir / "retention-summary.json").write_text(
|
||||
json.dumps(
|
||||
{
|
||||
"id": f"retention-summary:{run_id}",
|
||||
"run_id": run_id,
|
||||
"target_profile_ref": "sample-repository",
|
||||
"assessment_profile_ref": "sample-noop-assessment",
|
||||
"created_at": created_at,
|
||||
"summary": {
|
||||
"status": status,
|
||||
"evidence_results": evidence_results,
|
||||
"finding_count": unexpected_findings,
|
||||
"unexpected_findings": unexpected_findings,
|
||||
"expected_findings": 0,
|
||||
"waived_findings": 0,
|
||||
"mapping_target_count": 1,
|
||||
"artifact_count": artifact_count,
|
||||
},
|
||||
"report_refs": [
|
||||
"reports/assessment-package.json",
|
||||
"reports/report.md",
|
||||
],
|
||||
"artifact_retention": {
|
||||
"policy": {"raw_artifact_days": 0, "summary_days": 365},
|
||||
"output_artifact_retention": "summary-only",
|
||||
"retention_class_counts": {"raw": artifact_count},
|
||||
"raw_artifact_count": artifact_count,
|
||||
},
|
||||
}
|
||||
),
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user