run evidence script
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
1 changed file +13 −0
added
scripts/run-evidence.sh
+13 −0
@@ -0,0 +1,13 @@ | ||
| 1 | +#!/bin/bash | |
| 2 | +# Prints an evidence summary for a run (status, attempts, stages with cost, latest quality gates, publication). Run on the control plane. | |
| 3 | +set -euo pipefail | |
| 4 | +RUN="${1:?run id}"; export PATH=/opt/homebrew/opt/postgresql@17/bin:$PATH; DB="${DB:-autoscholar}" | |
| 5 | +q(){ psql -d "$DB" -Atc "$1"; } | |
| 6 | +echo "== run"; q "select status, research_mode, discipline, current_attempt_no||'/'||max_attempts as attempts, total_cost_usd, max_budget_usd, to_char(started_at,'HH24:MI')||'→'||coalesce(to_char(finished_at,'HH24:MI'),'…') as span, coalesce(failure_reason,'') from research_runs where id='$RUN'" | |
| 7 | +echo "== attempts"; q "select attempt_no, status, cost_usd, coalesce(left(error,120),'') from run_attempts where run_id='$RUN' order by attempt_no" | |
| 8 | +echo "== stages (latest attempt)"; q "select s.stage, s.status, s.cost_usd, s.turns, to_char(s.started_at,'HH24:MI:SS')||'→'||coalesce(to_char(s.ended_at,'HH24:MI:SS'),'…') from stage_executions s join run_attempts a on a.id=s.attempt_id where s.run_id='$RUN' and a.attempt_no=(select max(attempt_no) from run_attempts where run_id='$RUN') order by s.started_at" | |
| 9 | +echo "== artifacts"; q "select count(*), sum(bytes) from (select distinct on (path) path, bytes from artifacts where run_id='$RUN' order by path, version desc) t" | |
| 10 | +echo "== policy denials"; q "select count(*) from stage_events where run_id='$RUN' and kind='policy.denied'" | |
| 11 | +echo "== quality gates (latest evaluation)"; q "select gate||' | '||severity||' | '||status||' | '||left(message,110) from quality_gate_results where run_id='$RUN' and evaluation_id=(select evaluation_id from quality_gate_results where run_id='$RUN' order by created_at desc limit 1) order by severity, gate" | |
| 12 | +echo "== decisions"; q "select decision||' | '||decided_by||' | '||left(rationale,140) from publication_decisions where run_id='$RUN' order by created_at" | |
| 13 | +echo "== paper"; q "select p.public_id||' | '||p.slug||' | v'||v.version_no||' | '||p.status from papers p join paper_versions v on v.paper_id=p.id where v.run_id='$RUN'" | |
| 14 | ||