From ab358d4bb728362281698e19d7124ab59483cd76 Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 2 Jul 2026 22:00:37 +0800 Subject: [PATCH] feat(telegram): mark verifier receipts surfaced --- .../telegram_alert_ai_automation_matrix.py | 85 +++++++++++++++++-- ...telegram_alert_ai_automation_matrix_api.py | 18 +++- 2 files changed, 95 insertions(+), 8 deletions(-) diff --git a/apps/api/src/services/telegram_alert_ai_automation_matrix.py b/apps/api/src/services/telegram_alert_ai_automation_matrix.py index 5157483a7..65331d0b2 100644 --- a/apps/api/src/services/telegram_alert_ai_automation_matrix.py +++ b/apps/api/src/services/telegram_alert_ai_automation_matrix.py @@ -93,6 +93,9 @@ def load_latest_telegram_alert_ai_automation_matrix( post_apply_verifier_present = bool( source_proof["telegram_alert_post_apply_verifier_readback_present"] ) + post_apply_verifier_surface_present = bool( + source_proof["telegram_alert_post_apply_verifier_awooop_surface_present"] + ) direct_gap_count = int(egress_summary["direct_bot_api_call_count"]) direct_gap_file_count = int(egress_summary["direct_bot_api_file_count"]) @@ -359,6 +362,44 @@ def load_latest_telegram_alert_ai_automation_matrix( "/api/v1/agents/telegram-alert-learning-context-post-apply-verifier", ], }, + { + "surface_id": "telegram_verified_context_awooop_operator_surface", + "priority_work_item_id": "CIR-P0-TG-001", + "surface_kind": "awooop_operator_surface", + "status": ( + "verified_context_receipt_surface_present" + if post_apply_verifier_surface_present + else "verified_context_receipt_surface_missing" + ), + "known_item_count": source_proof[ + "telegram_alert_post_apply_verifier_awooop_surface_count" + ], + "db_or_log_receipt": "ready_consumes_post_apply_verifier_readback", + "ai_route": ( + "ready_operator_visible_ai_loop_receipts" + if post_apply_verifier_surface_present + else "missing_operator_visible_ai_loop_receipts" + ), + "controlled_queue": "ready_read_only_ui_surface_no_send_no_apply", + "post_verifier": ( + "ready_awooop_surface_source_contract_present" + if post_apply_verifier_surface_present + else "missing_awooop_surface_source_contract" + ), + "learning_writeback": ( + "ready_human_observable_ai_agent_learning_receipts" + if post_apply_verifier_surface_present + else "missing_human_observable_ai_agent_learning_receipts" + ), + "manual_default_gap_count": 0, + "direct_send_gap_count": 0, + "evidence_refs": [ + "apps/web/src/components/awooop/autonomous-runtime-receipt-panel.tsx", + "/zh-TW/awooop/runs", + "/zh-TW/awooop/work-items", + "/zh-TW/awooop/alerts", + ], + }, ] next_priority_action = _next_priority_action( @@ -369,6 +410,7 @@ def load_latest_telegram_alert_ai_automation_matrix( learning_registry_present=learning_registry_present, ai_loop_context_present=ai_loop_context_present, post_apply_verifier_present=post_apply_verifier_present, + post_apply_verifier_surface_present=post_apply_verifier_surface_present, ) next_controlled_actions = _ordered_controlled_actions(next_priority_action) summary = _build_summary( @@ -428,8 +470,17 @@ def load_latest_telegram_alert_ai_automation_matrix( ( ( "Manual/default semantics are only acceptable for critical/break-glass or historical evidence; " - "Telegram alert AI Loop context has a post-apply verifier readback, " - "so the next P0 step is surfacing verified receipts in Runs / Work Items / Alerts." + + ( + ( + "Telegram alert AI Loop context receipts are visible in AwoooP operator surfaces; " + "the next P0 step is full monitoring alert DB/log coverage audit." + ) + if post_apply_verifier_surface_present + else ( + "Telegram alert AI Loop context has a post-apply verifier readback, " + "so the next P0 step is surfacing verified receipts in Runs / Work Items / Alerts." + ) + ) ) if post_apply_verifier_present else ( @@ -599,6 +650,10 @@ def _inspect_source_contract(repo_root: Path) -> dict[str, int | bool]: "apps/api/src/services/telegram_alert_learning_context_post_apply_verifier.py", "telegram_alert_learning_context_post_apply_verifier_v1", ), + "telegram_alert_post_apply_verifier_awooop_surface_present": ( + "apps/web/src/components/awooop/autonomous-runtime-receipt-panel.tsx", + "telegram-alert-post-apply-verifier-readback", + ), } result: dict[str, int | bool] = {} for key, (relative_path, marker) in source_checks.items(): @@ -621,6 +676,10 @@ def _inspect_source_contract(repo_root: Path) -> dict[str, int | bool]: result["telegram_alert_post_apply_verifier_readback_count"] = ( 1 if present else 0 ) + if key == "telegram_alert_post_apply_verifier_awooop_surface_present": + result["telegram_alert_post_apply_verifier_awooop_surface_count"] = ( + 1 if present else 0 + ) required = [key for key, value in result.items() if key.endswith("_present") and value is not True] if required: @@ -649,6 +708,7 @@ def _next_priority_action( learning_registry_present: bool, ai_loop_context_present: bool, post_apply_verifier_present: bool, + post_apply_verifier_surface_present: bool, ) -> dict[str, Any]: if api_direct_gap_count > 0: return { @@ -720,14 +780,24 @@ def _next_priority_action( "requires_runtime_send": False, "post_verifier": "AI Loop post-apply verifier reads Telegram alert context receipts and reports reusable decision context.", } + if not post_apply_verifier_surface_present: + return { + "action_id": "surface_verified_telegram_alert_context_receipts_in_awooop_runs_work_items_alerts", + "scope": "Verified Telegram alert context receipts -> AwoooP Runs / Work Items / Alerts", + "priority": "P0", + "why": "Post-apply verifier is source-controlled; the next closure is visible AI automation proof across operator surfaces.", + "requires_secret": False, + "requires_runtime_send": False, + "post_verifier": "Runs, Work Items, and Alerts surfaces show verified Telegram alert AI Loop receipts without manual-default terminal states.", + } return { - "action_id": "surface_verified_telegram_alert_context_receipts_in_awooop_runs_work_items_alerts", - "scope": "Verified Telegram alert context receipts -> AwoooP Runs / Work Items / Alerts", + "action_id": "audit_all_telegram_monitoring_alerts_db_log_ai_automation_coverage", + "scope": "Telegram monitoring alerts -> DB/log ledger, KM/RAG/MCP/PlayBook, and AI Agent context coverage", "priority": "P0", - "why": "Post-apply verifier is source-controlled; the next closure is visible AI automation proof across operator surfaces.", + "why": "Verified Telegram alert AI Loop receipts are now visible in AwoooP; the next closure is proving every monitoring alert path is persisted and reusable by AI Agent automation.", "requires_secret": False, "requires_runtime_send": False, - "post_verifier": "Runs, Work Items, and Alerts surfaces show verified Telegram alert AI Loop receipts without manual-default terminal states.", + "post_verifier": "Telegram alert matrix shows every monitoring alert surface has DB/log receipt, AI route, controlled queue, and no manual-default terminal state.", } @@ -799,6 +869,9 @@ def _build_summary( "telegram_alert_post_apply_verifier_readback_count": source_proof[ "telegram_alert_post_apply_verifier_readback_count" ], + "telegram_alert_post_apply_verifier_awooop_surface_count": source_proof[ + "telegram_alert_post_apply_verifier_awooop_surface_count" + ], "next_priority_action_id": next_priority_action["action_id"], "next_priority_work_item_id": "CIR-P0-TG-001", } diff --git a/apps/api/tests/test_telegram_alert_ai_automation_matrix_api.py b/apps/api/tests/test_telegram_alert_ai_automation_matrix_api.py index 538f93fc7..ebe1b563b 100644 --- a/apps/api/tests/test_telegram_alert_ai_automation_matrix_api.py +++ b/apps/api/tests/test_telegram_alert_ai_automation_matrix_api.py @@ -32,7 +32,7 @@ def test_telegram_alert_ai_automation_matrix_loader_returns_gap_matrix(): } summary = payload["summary"] - assert summary["telegram_alert_surface_count"] == 8 + assert summary["telegram_alert_surface_count"] == 9 assert summary["known_direct_send_gap_count"] == 0 assert summary["known_direct_send_gap_file_count"] == 0 assert summary["workflow_direct_send_gap_count"] == 0 @@ -56,8 +56,9 @@ def test_telegram_alert_ai_automation_matrix_loader_returns_gap_matrix(): assert summary["ai_alert_card_learning_registry_readback_count"] == 1 assert summary["telegram_alert_ai_loop_consumer_context_readback_count"] == 1 assert summary["telegram_alert_post_apply_verifier_readback_count"] == 1 + assert summary["telegram_alert_post_apply_verifier_awooop_surface_count"] == 1 assert summary["next_priority_action_id"] == ( - "surface_verified_telegram_alert_context_receipts_in_awooop_runs_work_items_alerts" + "audit_all_telegram_monitoring_alerts_db_log_ai_automation_coverage" ) matrix = {item["surface_id"]: item for item in payload["matrix"]} @@ -102,6 +103,12 @@ def test_telegram_alert_ai_automation_matrix_loader_returns_gap_matrix(): assert matrix["telegram_ai_loop_post_apply_verifier"]["post_verifier"] == ( "ready_context_receipt_post_apply_verifier" ) + assert matrix["telegram_verified_context_awooop_operator_surface"]["status"] == ( + "verified_context_receipt_surface_present" + ) + assert matrix["telegram_verified_context_awooop_operator_surface"]["ai_route"] == ( + "ready_operator_visible_ai_loop_receipts" + ) assert payload["direct_send_gap_refs"] == [] assert not any( @@ -124,6 +131,7 @@ def test_telegram_matrix_source_contract_supports_container_layout(tmp_path): (tmp_path / "src/services").mkdir(parents=True) (tmp_path / "src/db").mkdir(parents=True) (tmp_path / "src/api/v1/platform").mkdir(parents=True) + (tmp_path / "apps/web/src/components/awooop").mkdir(parents=True) (tmp_path / "src/services/telegram_gateway.py").write_text( "_mirror_outbound_message\n" "record_outbound_message\n" @@ -153,6 +161,10 @@ def test_telegram_matrix_source_contract_supports_container_layout(tmp_path): "telegram_alert_learning_context_post_apply_verifier_v1\n", encoding="utf-8", ) + (tmp_path / "apps/web/src/components/awooop/autonomous-runtime-receipt-panel.tsx").write_text( + 'data-testid="telegram-alert-post-apply-verifier-readback"\n', + encoding="utf-8", + ) proof = _inspect_source_contract(tmp_path) @@ -171,6 +183,8 @@ def test_telegram_matrix_source_contract_supports_container_layout(tmp_path): assert proof["telegram_alert_ai_loop_consumer_context_readback_count"] == 1 assert proof["telegram_alert_post_apply_verifier_readback_present"] is True assert proof["telegram_alert_post_apply_verifier_readback_count"] == 1 + assert proof["telegram_alert_post_apply_verifier_awooop_surface_present"] is True + assert proof["telegram_alert_post_apply_verifier_awooop_surface_count"] == 1 def test_telegram_alert_ai_automation_matrix_endpoint_returns_readback():