feat(awooop): summarize gateway usage in truth chain
All checks were successful
Code Review / ai-code-review (push) Successful in 10s
CD Pipeline / tests (push) Successful in 1m8s
CD Pipeline / build-and-deploy (push) Successful in 3m45s
CD Pipeline / post-deploy-checks (push) Successful in 1m14s

This commit is contained in:
Your Name
2026-05-13 11:30:08 +08:00
parent 90603ad9bb
commit a99dccfc73
3 changed files with 193 additions and 2 deletions

View File

@@ -10,6 +10,7 @@ from src.services.awooop_ansible_audit_service import (
from src.services.awooop_truth_chain_service import (
build_incident_reconciliation,
_clean_row,
_summarize_gateway_mcp,
_truth_status,
)
from src.services.drift_repeat_state import (
@@ -78,6 +79,38 @@ def test_truth_status_marks_repeated_pending_drift_as_human_needed() -> None:
assert "drift_ai_confidence_zero" in status["blockers"]
def test_gateway_summary_surfaces_first_class_approval_execution() -> None:
summary = _summarize_gateway_mcp([
{
"agent_id": "approval_executor",
"tool_name": "ssh_docker_restart",
"result_status": "failed",
"block_gate": None,
"gate_result": {
"schema_version": "awooop_mcp_gateway_audit_v1",
"gateway_path": "awooop_mcp_gateway",
"policy_enforced": True,
"required_scope": "write",
"is_shadow": False,
"gate5_approval": True,
},
}
])
assert summary["total"] == 1
assert summary["first_class_total"] == 1
assert summary["legacy_bridge_total"] == 0
assert summary["policy_enforced_total"] == 1
assert summary["approval_executor_total"] == 1
assert summary["stage"] == "provider_failed_after_gateway"
assert summary["stage_status"] == "failed"
assert summary["needs_human"] is True
assert summary["by_agent"][0]["agent_id"] == "approval_executor"
assert summary["by_tool"][0]["tool_name"] == "ssh_docker_restart"
assert summary["by_scope"][0]["required_scope"] == "write"
assert summary["by_scope"][0]["failed"] == 1
def _drift_item(
*,
resource_name: str = "awoooi-api",