feat(awooop): close autonomous learning loop readback
Some checks failed
CD Pipeline / workflow-shape (push) Successful in 0s
CD Pipeline / cancel-stale-cd (push) Has been skipped
CD Pipeline / tests (push) Failing after 2m47s
CD Pipeline / build-and-deploy (push) Has been skipped
CD Pipeline / post-deploy-checks (push) Has been skipped
Some checks failed
CD Pipeline / workflow-shape (push) Successful in 0s
CD Pipeline / cancel-stale-cd (push) Has been skipped
CD Pipeline / tests (push) Failing after 2m47s
CD Pipeline / build-and-deploy (push) Has been skipped
CD Pipeline / post-deploy-checks (push) Has been skipped
This commit is contained in:
@@ -68,6 +68,13 @@ def test_ai_agent_autonomous_runtime_control_exposes_reports_and_executor_receip
|
||||
assert data["rollups"]["direct_bot_api_allowed_count"] == 0
|
||||
assert data["rollups"]["legacy_policy_overridden_count"] >= 4
|
||||
assert data["runtime_receipt_readback"]["db_read_status"] == "not_queried"
|
||||
assert data["runtime_receipt_readback"]["learning_loop"]["status"] == "in_progress"
|
||||
assert (
|
||||
data["runtime_receipt_readback"]["learning_loop"]["rollups"][
|
||||
"required_stage_missing_count"
|
||||
]
|
||||
== 7
|
||||
)
|
||||
|
||||
|
||||
def test_ai_agent_autonomous_runtime_control_exposes_internal_control_loop():
|
||||
@@ -161,6 +168,12 @@ def test_runtime_receipt_readback_summarizes_live_executor_closure_rows():
|
||||
"total": 1,
|
||||
"recent": 1,
|
||||
},
|
||||
{
|
||||
"operation_type": "ansible_learning_writeback_recorded",
|
||||
"status": "success",
|
||||
"total": 1,
|
||||
"recent": 1,
|
||||
},
|
||||
],
|
||||
operation_latest_rows=[
|
||||
{
|
||||
@@ -201,6 +214,18 @@ def test_runtime_receipt_readback_summarizes_live_executor_closure_rows():
|
||||
"returncode": "0",
|
||||
"duration_ms": 7727,
|
||||
},
|
||||
{
|
||||
"op_id": "learning-op",
|
||||
"parent_op_id": apply_op_id,
|
||||
"operation_type": "ansible_learning_writeback_recorded",
|
||||
"status": "success",
|
||||
"actor": "ansible_controlled_apply_worker",
|
||||
"incident_id": incident_id,
|
||||
"catalog_id": "ansible:188-momo-backup-user",
|
||||
"playbook_path": "infra/ansible/playbooks/188-momo-backup-user.yml",
|
||||
"execution_mode": "learning_writeback",
|
||||
"returncode": "0",
|
||||
},
|
||||
],
|
||||
auto_repair_count_rows=[
|
||||
{"result_status": "success", "total": 1, "recent": 1},
|
||||
@@ -416,6 +441,31 @@ def test_runtime_receipt_readback_summarizes_live_executor_closure_rows():
|
||||
assert decision_wiring["rollups"]["check_mode_total"] == 1
|
||||
assert decision_wiring["rollups"]["controlled_apply_total"] == 1
|
||||
assert decision_wiring["rollups"]["required_stage_missing_count"] == 0
|
||||
learning_loop = readback["learning_loop"]
|
||||
assert learning_loop["schema_version"] == "ai_agent_learning_loop_readback_v1"
|
||||
assert learning_loop["status"] == "completed"
|
||||
assert learning_loop["missing_required_stage_ids"] == []
|
||||
assert {
|
||||
stage["stage_id"]
|
||||
for stage in learning_loop["stages"]
|
||||
if stage["required_for_learning_loop"]
|
||||
} == {
|
||||
"verified_execution_outcome",
|
||||
"km_learning_writeback",
|
||||
"learning_repair_record",
|
||||
"playbook_trust_delta",
|
||||
"similar_case_context",
|
||||
"repair_candidate_feedback",
|
||||
"next_decision_context",
|
||||
}
|
||||
assert learning_loop["rollups"]["required_stage_present_count"] == 7
|
||||
assert learning_loop["rollups"]["required_stage_missing_count"] == 0
|
||||
assert learning_loop["rollups"]["learning_writeback_total"] == 1
|
||||
assert learning_loop["rollups"]["learning_writeback_recent"] == 1
|
||||
assert learning_loop["rollups"]["similar_case_source_total"] > 0
|
||||
assert learning_loop["rollups"]["repair_feedback_ready_count"] == 1
|
||||
assert learning_loop["public_safety"]["stores_secret_values"] is False
|
||||
assert learning_loop["public_safety"]["executes_on_read"] is False
|
||||
progress = readback["work_item_progress"]
|
||||
assert progress["schema_version"] == "ai_agent_automation_work_item_progress_v1"
|
||||
ordered_ids = [item["work_item_id"] for item in progress["ordered_items"]]
|
||||
@@ -435,10 +485,12 @@ def test_runtime_receipt_readback_summarizes_live_executor_closure_rows():
|
||||
assert progress["ordered_items"][4]["status"] == "completed"
|
||||
assert progress["ordered_items"][5]["status"] == "completed"
|
||||
assert progress["ordered_items"][6]["status"] == "completed"
|
||||
assert progress["ordered_items"][7]["status"] == "completed"
|
||||
assert progress["ordered_items"][7]["remaining_learning_loop_stage_count"] == 0
|
||||
assert progress["source_family_items"]
|
||||
assert {item["status"] for item in progress["source_family_items"]} == {"completed"}
|
||||
assert progress["rollups"]["source_family_work_item_count"] == 10
|
||||
assert progress["rollups"]["pending_count"] >= 4
|
||||
assert progress["rollups"]["pending_count"] >= 3
|
||||
|
||||
|
||||
def test_runtime_receipt_readback_classifies_closed_failed_apply_as_ai_repair():
|
||||
|
||||
@@ -21,6 +21,7 @@ from src.services.awooop_ansible_check_mode_service import (
|
||||
_post_apply_km_path_type,
|
||||
_post_apply_verification_result,
|
||||
_record_auto_repair_execution_receipt,
|
||||
_record_learning_writeback_receipt,
|
||||
_send_controlled_apply_telegram_receipt,
|
||||
build_ansible_apply_command,
|
||||
build_ansible_check_mode_claim_input,
|
||||
@@ -1613,9 +1614,20 @@ def test_ansible_apply_receipt_backfill_includes_verifier_and_km_gaps() -> None:
|
||||
assert "evidence.post_execution_state ->> 'apply_op_id' = apply.op_id::text" in source
|
||||
assert "FROM knowledge_entries km" in source
|
||||
assert "km.path_type = 'ansible_apply_receipt:' || left(apply.op_id::text, 8)" in source
|
||||
assert "ansible_learning_writeback_recorded" in source
|
||||
assert "_record_post_apply_verifier_and_learning" in source
|
||||
|
||||
|
||||
def test_ansible_learning_writeback_receipt_records_learning_service_call() -> None:
|
||||
source = inspect.getsource(_record_learning_writeback_receipt)
|
||||
|
||||
assert "record_verification_result" in source
|
||||
assert "ansible_learning_writeback_recorded" in source
|
||||
assert "learning_repository" in source
|
||||
assert "stores_raw_logs" in source
|
||||
assert "stores_secret_values" in source
|
||||
|
||||
|
||||
def test_ansible_live_controlled_apply_sends_telegram_receipt_but_backfill_does_not() -> None:
|
||||
live_source = inspect.getsource(run_controlled_apply_for_claim)
|
||||
backfill_source = inspect.getsource(backfill_missing_auto_repair_execution_receipts_once)
|
||||
|
||||
Reference in New Issue
Block a user