fix: harden review and verifier governance

This commit is contained in:
phamnazage-jpg
2026-05-29 18:48:48 +08:00
parent 88833fac8b
commit e999d31b25
133 changed files with 2538 additions and 159 deletions

View File

@@ -27,6 +27,40 @@ PIPELINE_FAILED_SOURCE_SET="none"
MULTI_SOURCE_AUDIT="multi_source_audit=unavailable"
PIPELINE_AUDIT_SUMMARY=""
report_cron_status() {
local status="$1"
local topic="$2"
local evidence_line="${3:-}"
local next_line="${4:-none}"
if [[ -x "$PROJECT_DIR/scripts/cron_status_report.sh" ]]; then
REPORT_DATE="$REPORT_DATE" "$PROJECT_DIR/scripts/cron_status_report.sh" cron "$status" "$topic" "$evidence_line" "$next_line" >> "$LOG_FILE" 2>&1 || true
fi
}
capture_worktree_status() {
if [[ -x "$PROJECT_DIR/scripts/git_commit_status_report.sh" ]]; then
"$PROJECT_DIR/scripts/git_commit_status_report.sh" cron
else
printf '%s\n' "WORKTREE_STATUS label=cron state=unknown tracked_modified=0 untracked=0 commit_hint=unknown"
fi
}
classify_cron_failure_status() {
local message="${1:-}"
local normalized
normalized="$(printf '%s' "$message" | tr '[:upper:]' '[:lower:]')"
case "$normalized" in
*"api key"*|*"database_url"*|*"must provide"*|*"未设置"*|*"permission denied"*|*"role does not exist"*|*"relation does not exist"*)
printf '%s\n' "precondition_missing"
;;
*)
printf '%s\n' "failed"
;;
esac
}
# 日志函数
log() {
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $1" | tee -a "$LOG_FILE"
@@ -64,14 +98,17 @@ refresh_pipeline_audit() {
# 错误处理
error_exit() {
local output_path=""
local cron_status="failed"
log "❌ 错误: $1"
refresh_pipeline_audit
cron_status="$(classify_cron_failure_status "$1")"
# 降级:复制昨日报告
fallback_report
if [ -f "$(report_markdown_path "$REPORT_DATE")" ]; then
output_path="$(report_markdown_path "$REPORT_DATE")"
fi
track_report_state "$DB_URL" "$REPORT_DATE" "failed" "${MODEL_COUNT:-}" "$PIPELINE_AUDIT_SUMMARY" "$output_path" "$1" "scheduled" "cron" "true" >> "$LOG_FILE" 2>&1 || true
report_cron_status "$cron_status" "run_daily.sh failed" "$1" "inspect ${LOG_FILE}"
# 发送告警
if [ -n "$FEISHU_WEBHOOK" ]; then
send_alert "$1"
@@ -461,7 +498,8 @@ if ! go run -tags llm_script \
error_exit "目录级官方入口核验失败"
fi
if ! SIGNAL_SOURCE_AUDIT="$PIPELINE_AUDIT_SUMMARY" go run -tags llm_script \
scripts/materialize_daily_signals.go >> "$LOG_FILE" 2>&1; then
scripts/materialize_daily_signals.go \
scripts/official_import_signature_audit_query_lib.go >> "$LOG_FILE" 2>&1; then
merge_failed_source_keys "daily_signal_snapshot"
error_exit "每日关键信号物化失败"
fi
@@ -499,7 +537,9 @@ fi
if ! psql "$DB_URL" -Atqc "select count(*) from report_runs where report_date = DATE '${REPORT_DATE}' and status = 'generated';" | awk '{ exit !($1 >= 1) }'; then
error_exit "report_runs 未写入 generated 记录"
fi
WORKTREE_STATUS_LINE="$(capture_worktree_status)"
log "✅ 日报记录更新完成"
report_cron_status "success" "run_daily.sh completed" "verify_phase3/phase5/phase6-ready chain green for ${REPORT_DATE}; ${WORKTREE_STATUS_LINE}" "next=none"
log "🎉 每日流水线全部完成!"
log "📄 Markdown: $(report_markdown_path "$REPORT_DATE")"