feat(ai): automate agent integration truth and RAG canary
Some checks failed
CD Pipeline / deploy (push) Has been cancelled

This commit is contained in:
ogt
2026-07-17 02:00:35 +08:00
parent b51449b96c
commit 81b99f12b3
16 changed files with 1977 additions and 10 deletions

View File

@@ -215,6 +215,7 @@ def test_v2_cron_blind_spot_list_has_failure_notifications(monkeypatch):
"run_ppt_vision_audit",
"run_embed_consistency_check",
"run_ollama_111_usage_guard_check",
"run_internal_rag_candidate_canary_task",
]:
source = inspect.getsource(getattr(run_scheduler, fn_name))
assert "_notify_scheduler_failure(" in source
@@ -236,6 +237,50 @@ def test_roi_ai_smoke_and_daily_report_schedules_stay_staggered():
assert "start_revenue_automation_watchdog()" in source
assert "schedule.every(6).hours.do(run_action_plan_hygiene_task)" in source
assert "schedule.every(15).minutes.do(run_ollama_111_usage_guard_check)" in source
assert 'schedule.every().day.at("04:45").do(run_internal_rag_candidate_canary_task)' in source
def test_scheduled_internal_rag_canary_is_bounded_and_acknowledged(monkeypatch):
run_scheduler = _load_run_scheduler(monkeypatch)
import services.internal_rag_candidate_canary_service as canary_service
import services.telegram_templates as telegram_templates
calls = []
saved = []
monkeypatch.setattr(
canary_service,
"run_internal_rag_candidate_canary",
lambda **kwargs: calls.append(kwargs) or {
"success": True,
"status": "canary_passed_activation_blocked",
"run_identity": {
"trace_id": "trace-test",
"run_id": "run-test",
"work_item_id": "RAG-P0-001",
},
"summary": {
"source_receipt_count": 1,
"executed_count": 1,
"canary_passed_count": 1,
},
"closure_receipt": {},
"next_machine_action": "pin_embedding_model_then_enable_rag_controlled_canary",
},
)
monkeypatch.setattr(
telegram_templates,
"send_telegram_with_result",
lambda *_args, **_kwargs: {"ok": True, "sent": 1, "failed": 0},
)
monkeypatch.setattr(run_scheduler, "_save_stats", lambda name, data: saved.append((name, data)))
payload = run_scheduler.run_internal_rag_candidate_canary_task()
assert calls == [{"limit": 1, "execute": True, "write_receipt": True}]
assert payload["terminal_status"] == "verified_with_activation_blocker"
assert payload["acknowledgements"]["telegram"]["status"] == "acknowledged"
assert payload["acknowledgements"]["rag"] == "rag_canary_receipt_written"
assert saved[0][0] == "internal_rag_candidate_canary"
def test_pchome_growth_backfill_catchup_uses_runtime_receipt_cooldown(monkeypatch, tmp_path):