Merge remote-tracking branch 'gitea/main' into codex/p0-006-ai-log-triage-20260709
This commit is contained in:
@@ -31,7 +31,46 @@ def _source_contract() -> dict[str, bool]:
|
||||
}
|
||||
|
||||
|
||||
def _payload() -> dict:
|
||||
def _payload(
|
||||
*,
|
||||
post_apply_verifier: dict | None = None,
|
||||
ai_alert_card_delivery_readback: dict | None = None,
|
||||
runtime_log_readback: dict | None = None,
|
||||
log_controlled_writeback_consumer: dict | None = None,
|
||||
) -> dict:
|
||||
default_post_apply_verifier = {
|
||||
"schema_version": "telegram_alert_learning_context_post_apply_verifier_v1",
|
||||
"status": "telegram_alert_learning_context_post_apply_verified",
|
||||
"rollups": {
|
||||
"telegram_alert_learning_context_post_apply_verifier_ready": True,
|
||||
"verified_context_receipt_count": 36,
|
||||
"verified_target_count": 6,
|
||||
"verified_ai_agent_context_receipt_count": 6,
|
||||
},
|
||||
}
|
||||
default_ai_alert_card_delivery_readback = {
|
||||
"status": "ok",
|
||||
"summary": {
|
||||
"total": 36,
|
||||
"learning_writeback_ready_total": 36,
|
||||
},
|
||||
}
|
||||
default_runtime_log_readback = {
|
||||
"status": "ok",
|
||||
"summary": {
|
||||
"alert_operation_log_total_7d": 41,
|
||||
"telegram_sent_event_count_7d": 8,
|
||||
"km_converted_event_count_7d": 4,
|
||||
"playbook_draft_event_count_7d": 3,
|
||||
"outbound_telegram_total_7d": 8,
|
||||
},
|
||||
"event_type_counts_7d": {
|
||||
"ALERT_RECEIVED": 15,
|
||||
"TELEGRAM_SENT": 8,
|
||||
"KM_CONVERTED": 4,
|
||||
"PLAYBOOK_DRAFT_CREATED": 3,
|
||||
},
|
||||
}
|
||||
return build_telegram_alert_monitoring_coverage_readback(
|
||||
project_id="awoooi",
|
||||
monitoring_inventory={
|
||||
@@ -112,43 +151,48 @@ def _payload() -> dict:
|
||||
"learning_writeback_ready_surface_count": 9,
|
||||
},
|
||||
},
|
||||
post_apply_verifier={
|
||||
"schema_version": "telegram_alert_learning_context_post_apply_verifier_v1",
|
||||
"status": "telegram_alert_learning_context_post_apply_verified",
|
||||
"rollups": {
|
||||
"telegram_alert_learning_context_post_apply_verifier_ready": True,
|
||||
"verified_context_receipt_count": 36,
|
||||
"verified_target_count": 6,
|
||||
"verified_ai_agent_context_receipt_count": 6,
|
||||
},
|
||||
},
|
||||
ai_alert_card_delivery_readback={
|
||||
"status": "ok",
|
||||
"summary": {
|
||||
"total": 36,
|
||||
"learning_writeback_ready_total": 36,
|
||||
},
|
||||
},
|
||||
runtime_log_readback={
|
||||
"status": "ok",
|
||||
"summary": {
|
||||
"alert_operation_log_total_7d": 41,
|
||||
"telegram_sent_event_count_7d": 8,
|
||||
"km_converted_event_count_7d": 4,
|
||||
"playbook_draft_event_count_7d": 3,
|
||||
"outbound_telegram_total_7d": 8,
|
||||
},
|
||||
"event_type_counts_7d": {
|
||||
"ALERT_RECEIVED": 15,
|
||||
"TELEGRAM_SENT": 8,
|
||||
"KM_CONVERTED": 4,
|
||||
"PLAYBOOK_DRAFT_CREATED": 3,
|
||||
},
|
||||
},
|
||||
post_apply_verifier=post_apply_verifier or default_post_apply_verifier,
|
||||
ai_alert_card_delivery_readback=(
|
||||
ai_alert_card_delivery_readback
|
||||
or default_ai_alert_card_delivery_readback
|
||||
),
|
||||
runtime_log_readback=runtime_log_readback or default_runtime_log_readback,
|
||||
log_controlled_writeback_consumer=log_controlled_writeback_consumer,
|
||||
source_contract=_source_contract(),
|
||||
)
|
||||
|
||||
|
||||
def _consumer_context_readback() -> dict:
|
||||
return {
|
||||
"schema_version": "ai_agent_log_controlled_writeback_consumer_readback_v1",
|
||||
"status": "controlled_writeback_consumer_readback_ready",
|
||||
"rollups": {
|
||||
"controlled_consumer_readback_ready": True,
|
||||
"ready_target_count": 6,
|
||||
"telegram_alert_learning_context_readback_ready": True,
|
||||
"telegram_alert_learning_context_receipt_count": 6,
|
||||
"telegram_alert_learning_ai_agent_context_receipt_count": 1,
|
||||
"telegram_alert_learning_ready_target_count": 6,
|
||||
"telegram_alert_learning_target_count": 6,
|
||||
},
|
||||
"telegram_alert_learning_context": {
|
||||
"schema_version": "telegram_alert_ai_loop_consumer_context_readback_v1",
|
||||
"status": "ai_loop_agent_context_receipt_ready",
|
||||
"source_registry_status": (
|
||||
"fallback_log_controlled_writeback_consumer_context"
|
||||
),
|
||||
"fallback_source_endpoint": (
|
||||
"/api/v1/agents/agent-log-controlled-writeback-consumer-readback"
|
||||
),
|
||||
"target_count": 6,
|
||||
"ready_target_count": 6,
|
||||
"context_receipt_count": 6,
|
||||
"ai_agent_context_receipt_count": 1,
|
||||
"active_blockers": [],
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
def test_telegram_alert_monitoring_coverage_readback_surfaces_live_gaps():
|
||||
payload = _payload()
|
||||
|
||||
@@ -277,6 +321,72 @@ def test_telegram_alert_monitoring_coverage_readback_surfaces_live_gaps():
|
||||
assert marker not in serialized
|
||||
|
||||
|
||||
def test_telegram_alert_monitoring_coverage_uses_consumer_context_fallback():
|
||||
payload = _payload(
|
||||
post_apply_verifier={
|
||||
"schema_version": "telegram_alert_learning_context_post_apply_verifier_v1",
|
||||
"status": "telegram_alert_learning_context_post_apply_verifier_unavailable",
|
||||
"rollups": {
|
||||
"telegram_alert_learning_context_post_apply_verifier_ready": False,
|
||||
"verified_context_receipt_count": 0,
|
||||
"verified_target_count": 0,
|
||||
"verified_ai_agent_context_receipt_count": 0,
|
||||
},
|
||||
},
|
||||
ai_alert_card_delivery_readback={
|
||||
"status": "unavailable",
|
||||
"summary": {
|
||||
"total": 0,
|
||||
"learning_writeback_ready_total": 0,
|
||||
"db_read_status": "unavailable",
|
||||
},
|
||||
},
|
||||
log_controlled_writeback_consumer=_consumer_context_readback(),
|
||||
)
|
||||
|
||||
summary = payload["summary"]
|
||||
assert summary["ai_alert_card_db_readback_ok"] is False
|
||||
assert summary["ai_loop_context_ready"] is True
|
||||
assert summary["ai_loop_context_source"] == "log_controlled_writeback_consumer"
|
||||
assert summary["ai_loop_context_fallback_used"] is True
|
||||
assert summary["ai_loop_context_receipt_count"] == 6
|
||||
assert summary["ai_loop_ai_agent_context_receipt_count"] == 1
|
||||
assert summary["effective_ai_alert_context_receipt_total"] == 6
|
||||
assert summary["effective_ai_alert_context_ready_total"] == 6
|
||||
assert summary["log_controlled_consumer_readback_ready"] is True
|
||||
assert summary["telegram_monitoring_audit_completion_percent"] == 77.8
|
||||
|
||||
assert (
|
||||
payload["operator_answer"][
|
||||
"all_verified_ai_alert_context_receipts_reusable_by_ai_agent"
|
||||
]
|
||||
is True
|
||||
)
|
||||
assert (
|
||||
"awooop_ai_alert_card_delivery_db_readback_unavailable"
|
||||
in payload["active_blockers"]
|
||||
)
|
||||
assert "awooop_ai_alert_card_delivery_receipts_missing" not in payload[
|
||||
"active_blockers"
|
||||
]
|
||||
assert "awooop_ai_alert_card_learning_writeback_refs_missing" not in payload[
|
||||
"active_blockers"
|
||||
]
|
||||
assert "telegram_alert_ai_loop_post_apply_verifier_not_ready" not in payload[
|
||||
"active_blockers"
|
||||
]
|
||||
|
||||
pipeline = {stage["stage_id"]: stage for stage in payload["alert_receipt_pipeline"]}
|
||||
assert pipeline["km_rag_mcp_playbook_ai_agent_learning_refs"]["ready"] is True
|
||||
matrix = {item["surface_id"]: item for item in payload["coverage_matrix"]}
|
||||
assert matrix["telegram_alert_ai_loop_context_verifier"]["status"] == (
|
||||
"consumer_context_fallback_ready"
|
||||
)
|
||||
assert matrix["telegram_alert_ai_loop_context_verifier"][
|
||||
"ai_loop_context_source"
|
||||
] == "log_controlled_writeback_consumer"
|
||||
|
||||
|
||||
def test_telegram_alert_monitoring_coverage_endpoint(monkeypatch):
|
||||
async def fake_loader():
|
||||
return _payload()
|
||||
|
||||
Reference in New Issue
Block a user