SPB Git

spb/autoscholar

Public
2.0 KB · 14 lines shellscript
1#!/bin/bash2# Prints an evidence summary for a run (status, attempts, stages with cost, latest quality gates, publication). Run on the control plane.3set -euo pipefail4RUN="${1:?run id}"; export PATH=/opt/homebrew/opt/postgresql@17/bin:$PATH; DB="${DB:-autoscholar}"5q(){ psql -d "$DB" -Atc "$1"; }6echo "== 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'"7echo "== attempts"; q "select attempt_no, status, cost_usd, coalesce(left(error,120),'') from run_attempts where run_id='$RUN' order by attempt_no"8echo "== 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"9echo "== 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"10echo "== policy denials"; q "select count(*) from stage_events where run_id='$RUN' and kind='policy.denied'"11echo "== 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"12echo "== decisions"; q "select decision||' | '||decided_by||' | '||left(rationale,140) from publication_decisions where run_id='$RUN' order by created_at"13echo "== 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
Files · 4ee0eb55785162e74bf5de92a13ac2a30a1c4528
Menu

Theme