generated from coulomb/repo-seed
first extension execution path
This commit is contained in:
@@ -9,6 +9,7 @@ from typing import Any
|
||||
|
||||
from guide_board.io import write_json
|
||||
from guide_board.planning import build_run_plan
|
||||
from guide_board.runners import run_step
|
||||
from guide_board.schema import assert_valid
|
||||
|
||||
|
||||
@@ -23,7 +24,10 @@ def run_assessment(
|
||||
run_dir = output_dir or root / "runs" / run_id
|
||||
created_at = _now()
|
||||
|
||||
evidence = [_evidence_for_step(run_id, plan, step) for step in plan["ordered_steps"]]
|
||||
evidence = [
|
||||
_evidence_for_step(root, run_dir, run_id, plan, step)
|
||||
for step in plan["ordered_steps"]
|
||||
]
|
||||
for item in evidence:
|
||||
assert_valid(item, "evidence-item")
|
||||
|
||||
@@ -53,19 +57,16 @@ def run_assessment(
|
||||
}
|
||||
|
||||
|
||||
def _evidence_for_step(run_id: str, plan: dict[str, Any], step: dict[str, Any]) -> dict[str, Any]:
|
||||
def _evidence_for_step(
|
||||
root: Path,
|
||||
run_dir: Path,
|
||||
run_id: str,
|
||||
plan: dict[str, Any],
|
||||
step: dict[str, Any],
|
||||
) -> dict[str, Any]:
|
||||
now = _now()
|
||||
runner_ref = step.get("runner_ref")
|
||||
if runner_ref is None:
|
||||
result = "manual" if step["kind"] == "check_group" else "skipped"
|
||||
observations = [
|
||||
"No runner is configured for this step in the baseline core."
|
||||
]
|
||||
else:
|
||||
result = "blocked"
|
||||
observations = [
|
||||
f"Runner {runner_ref!r} is declared but not implemented by the baseline core."
|
||||
]
|
||||
runner_result = run_step(root, run_dir, run_id, plan, step)
|
||||
|
||||
return {
|
||||
"id": f"evidence:{step['id']}",
|
||||
@@ -73,14 +74,15 @@ def _evidence_for_step(run_id: str, plan: dict[str, Any], step: dict[str, Any])
|
||||
"extension_id": step["extension_id"],
|
||||
"check_id": step["id"],
|
||||
"subject_ref": plan["target_profile_snapshot"]["id"],
|
||||
"result": result,
|
||||
"observations": observations,
|
||||
"result": runner_result["result"],
|
||||
"observations": runner_result["observations"],
|
||||
"facts": {
|
||||
"step_kind": step["kind"],
|
||||
"runner_ref": runner_ref,
|
||||
**runner_result["facts"],
|
||||
},
|
||||
"requirement_refs": _requirement_refs(plan, step),
|
||||
"artifact_refs": [],
|
||||
"artifact_refs": runner_result["artifact_refs"],
|
||||
"started_at": now,
|
||||
"completed_at": now,
|
||||
}
|
||||
@@ -95,25 +97,38 @@ def _requirement_refs(plan: dict[str, Any], step: dict[str, Any]) -> list[str]:
|
||||
def _findings_for_evidence(run_id: str, evidence: list[dict[str, Any]]) -> list[dict[str, Any]]:
|
||||
findings: list[dict[str, Any]] = []
|
||||
for item in evidence:
|
||||
if item["result"] != "blocked":
|
||||
if item["result"] not in {"blocked", "fail", "infrastructure_error"}:
|
||||
continue
|
||||
classification = {
|
||||
"blocked": "runner_not_implemented",
|
||||
"fail": "check_failed",
|
||||
"infrastructure_error": "infrastructure_error",
|
||||
}[item["result"]]
|
||||
findings.append(
|
||||
{
|
||||
"id": f"finding:{item['check_id']}",
|
||||
"run_id": run_id,
|
||||
"status": "blocked",
|
||||
"severity": "info",
|
||||
"classification": "runner_not_implemented",
|
||||
"status": item["result"],
|
||||
"severity": "info" if item["result"] == "blocked" else "medium",
|
||||
"classification": classification,
|
||||
"requirement_refs": item["requirement_refs"],
|
||||
"evidence_refs": [item["id"]],
|
||||
"expected": True,
|
||||
"expected": item["result"] == "blocked",
|
||||
"waiver_ref": None,
|
||||
"remediation": "Implement or configure the declared extension runner.",
|
||||
"remediation": _remediation_for_result(item["result"]),
|
||||
}
|
||||
)
|
||||
return findings
|
||||
|
||||
|
||||
def _remediation_for_result(result: str) -> str:
|
||||
if result == "blocked":
|
||||
return "Implement or configure the declared extension runner."
|
||||
if result == "infrastructure_error":
|
||||
return "Fix the target, network, credentials, or harness runtime and rerun the assessment."
|
||||
return "Review the failed check and target implementation."
|
||||
|
||||
|
||||
def _assessment_package(
|
||||
run_id: str,
|
||||
plan: dict[str, Any],
|
||||
@@ -198,6 +213,8 @@ def _markdown_report(run_metadata: dict[str, Any], package: dict[str, Any]) -> s
|
||||
def _run_status(evidence: list[dict[str, Any]]) -> str:
|
||||
if any(item["result"] == "fail" for item in evidence):
|
||||
return "failed"
|
||||
if any(item["result"] == "infrastructure_error" for item in evidence):
|
||||
return "infrastructure_error"
|
||||
if any(item["result"] == "blocked" for item in evidence):
|
||||
return "blocked"
|
||||
return "completed"
|
||||
|
||||
Reference in New Issue
Block a user