#!/bin/bash set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" . "$SCRIPT_DIR/verify_common.sh" . "$SCRIPT_DIR/report_utils.sh" TODAY="$(report_date_value)" TODAY_MARKDOWN_PATH="$(report_markdown_path "$TODAY")" TODAY_HTML_PATH="$(report_html_path "$TODAY")" TODAY_ARCHIVE_MARKDOWN_PATH="$(report_archive_markdown_path "$TODAY")" TODAY_ARCHIVE_HTML_PATH="$(report_archive_html_path "$TODAY")" echo "=== Phase 3 验收检查 ===" check_executable "scripts/run_daily.sh" "日报流水线脚本可执行" check_executable "scripts/feishu_alert.sh" "飞书告警脚本可执行" check_shell "日报生成器可独立构建" "go build -o /dev/null ./scripts/generate_daily_report.go ./scripts/official_import_signature_audit_query_lib.go" check_shell "日报脚本包含降级逻辑" "grep -q 'fallback_report' scripts/run_daily.sh" check_shell "日报脚本包含飞书告警逻辑" "grep -q 'send_alert' scripts/run_daily.sh" check_shell "正式调度链启用严格真实采集" "grep -q -- '-strict-real' scripts/run_daily.sh && grep -q -- '-strict-real' scripts/run_real_pipeline.sh" check_shell "正式调度链校验本次采集结果数量" "grep -q '本次采集结果异常' scripts/run_daily.sh && grep -q 'total=' scripts/run_real_pipeline.sh" check_shell "每日流水线已纳入多源补充同步" "grep -q 'fetch_multi_source.go --sources moonshot,deepseek,openai' scripts/run_daily.sh && grep -q 'import_zhipu_data.go' scripts/run_daily.sh && grep -q 'import_phase2_data.go' scripts/run_daily.sh && grep -q 'import_bytedance_data.go' scripts/run_daily.sh" check_shell "每日流水线会把来源级运行审计写入正式日报上下文" "grep -q 'REPORT_RUNTIME_AUDIT' scripts/run_daily.sh && grep -q 'selected_source_keys=' scripts/run_daily.sh && grep -q 'failed_source_keys=' scripts/run_daily.sh" check_shell "今日日报 Markdown 主产物存在且包含数据质量摘要" "test -f ${TODAY_MARKDOWN_PATH} && grep -q '数据质量摘要' ${TODAY_MARKDOWN_PATH}" check_shell "今日日报 HTML 主产物存在" "test -f ${TODAY_HTML_PATH}" check_shell "今日日报归档副本存在(Markdown + HTML)" "test -f ${TODAY_ARCHIVE_MARKDOWN_PATH} && test -f ${TODAY_ARCHIVE_HTML_PATH}" check_shell "日报归档约定已统一收敛到公共工具" "grep -q 'report_utils.sh' scripts/run_daily.sh && grep -q 'report_utils.sh' scripts/run_real_pipeline.sh && grep -q 'report_utils.sh' scripts/verify_phase3.sh" check_sql_int_ge "daily_report 已写入至少 1 条 generated 记录" \ "select count(*) from daily_report where status='generated';" \ 1 check_sql_int_ge "report_runs 已写入至少 1 条 generated 记录" \ "select count(*) from report_runs where status='generated';" \ 1 check_shell "crontab 已配置每日调度" "crontab -l 2>/dev/null | grep -q 'scripts/run_daily.sh'" check_shell "真实采集 API Key 已配置" "([ -n \"${OPENROUTER_API_KEY:-}\" ] || ([ -f .env.local ] && grep -Eq '^OPENROUTER_API_KEY=.+' .env.local) || ([ -f .env ] && grep -Eq '^OPENROUTER_API_KEY=.+' .env))" finish_phase