Files
rune/scripts/factory_status.sh

80 lines
4.0 KiB
Bash
Executable File

#!/bin/bash
# factory_status.sh — the factory at a glance. Run directly, or in a
# second terminal: watch -n 30 --color bash /mnt/workdrive/rune/scripts/factory_status.sh
# Everything here is READ-ONLY (git + file mtimes + claims + audit).
REPO=/mnt/workdrive/rune
cd "$REPO" || exit 1
B='\033[1m'; D='\033[2m'; G='\033[32m'; Y='\033[33m'; R='\033[31m'; C='\033[36m'; N='\033[0m'
now_epoch=$(date +%s)
echo -e "${B}═════════════════ RUNE FACTORY — LIVE STATUS ═════════════════${N} $(date '+%H:%M:%S')"
# ── headline ────────────────────────────────────────────────────────────
git fetch gitea -q 2>/dev/null
HEADLINE=$(python3 scripts/dichotomy_audit.py 2>/dev/null | head -1)
GATE=$(bash scripts/factory_spawn_gate.sh 2>/dev/null | head -1)
ACTIVE=$(echo "$GATE" | grep -oE 'active=[0-9]+' | cut -d= -f2)
UNVER=$(echo "$GATE" | grep -oE 'unverified=[0-9]+' | cut -d= -f2)
LAND=$(python3 -c "import json; c=json.load(open('docs/factory-claims.json')); print(len(c['landed']))")
INFL=$(python3 -c "import json; c=json.load(open('docs/factory-claims.json')); print(len(c['in_flight']))")
LAST_CLOSE=$(git log gitea/master --format='%cr — %s' --grep='chore(store): close' -1 2>/dev/null | head -c 100)
echo -e " ${C}$HEADLINE${N}"
echo -e " ${GATE} claims: ${G}${LAND} landed${N} / ${Y}${INFL} in-flight${N}"
echo -e " last landing: ${D}${LAST_CLOSE}${N}"
# ── lanes: one line per worktree ────────────────────────────────────────
echo -e "\n${B}── LANES ──${N}"
printf " ${B}%-16s %-24s %-10s %-9s %-8s %s${N}\n" "WORKTREE" "MODULE" "ACTIVITY" "DIRTY" "AHEAD" "HEAD"
for wt in /mnt/workdrive/rune-wave-*; do
[ -d "$wt" ] || continue
name=$(basename "$wt" | sed 's/rune-wave-//')
wname=$(basename "$wt")
mod=$(python3 -c "
import json
c = json.load(open('docs/factory-claims.json'))
for m, w in c['in_flight'].items():
if w.split()[0] in ('$wt', '$wname'): print(m); break
" 2>/dev/null)
[ -z "$mod" ] && mod="-"
# newest file mtime = work signal
newest=$(find "$wt/src" "$wt/scripts" -type f -newer "$wt/go.mod" -printf '%T@\n' 2>/dev/null | sort -rn | head -1 | cut -d. -f1)
if [ -n "$newest" ] && [ "$((now_epoch - newest))" -lt 300 ]; then
act="${G}● writing${N}"
elif [ -n "$newest" ] && [ "$((now_epoch - newest))" -lt 3600 ]; then
act="${Y}● $(( (now_epoch - newest) / 60 ))m ago${N}"
else
act="${D}○ idle${N}"
fi
dirty=$(git -C "$wt" status --porcelain 2>/dev/null | wc -l | tr -d ' ')
ahead=$(git -C "$wt" rev-list --count gitea/master..HEAD 2>/dev/null)
hsha=$(git -C "$wt" log --oneline -1 --format='%h' 2>/dev/null)
printf " %-16s %-24s %-20b %-9s %-8s %s\n" "$name" "$mod" "$act" "$dirty" "$ahead" "$hsha"
done
# ── recent master movement ─────────────────────────────────────────────
echo -e "\n${B}── MASTER (last 5) ──${N}"
git log gitea/master --oneline -5 2>/dev/null | while read -r line; do echo -e " ${D}${line}${N}"; done
# ── landings awaiting verification ──────────────────────────────────────
PENDING=$(python3 - <<'EOF' 2>/dev/null
import json, subprocess
c = json.load(open('docs/factory-claims.json'))
landed = set(c['landed'])
out = subprocess.run(['git','log','gitea/master','--format','%s','-200'],capture_output=True,text=True).stdout
import re
pend = []
for line in out.splitlines():
m = re.search(r'chore\(store\): close ([a-z_]+) dichotomy contract', line)
if m and m.group(1) not in landed:
pend.append(m.group(1))
print(', '.join(dict.fromkeys(pend)) if pend else '')
EOF
)
if [ -n "$PENDING" ]; then
echo -e "\n${Y}── CLOSES AWAITING VERIFICATION: $PENDING ──${N}"
fi
echo