Files

66 lines
2.2 KiB
Bash

#!/usr/bin/env bash
# sol_lane_status_check.sh — verdict for the daily-ledger lane triage artifact.
#
# Recomputes the lane status live from the filesystem and diffs it against the
# committed machine record sol_lane_status_2026-10-27.json. Exit code IS the
# verdict: 0 = committed artifact matches an independent recompute; nonzero = wrong.
set -u
cd "$(dirname "${BASH_SOURCE[0]}")" || exit 1
JSON="sol_lane_status_2026-10-27.json"
OUT="/root/.hermes/wizard-outputs"
LANE_LIST="forge ledger null quill sphinx sol spark"
python3 - "$JSON" "$OUT" "$LANE_LIST" <<'PY'
import json, os, sys, glob, time
json_path, out, lane_list = sys.argv[1:4]
lanes = lane_list.split()
now = time.time()
recomputed = {}
for L in lanes:
files = sorted(glob.glob(os.path.join(out, L + "-*.txt")))
latest = max(files, key=os.path.getmtime)
age = (now - os.path.getmtime(latest)) / 3600.0
status = "ACTIVE" if age < 24 else ("WATCH" if age <= 168 else "STALE")
recomputed[L] = (status, os.path.basename(latest))
with open(json_path) as f:
rec = json.load(f)
ok = True
for L in lanes:
if not any(x.get("id") == L for x in rec.get("lanes", [])):
print("FAIL: lane %s missing from JSON" % L); ok = False; continue
jl = next(x for x in rec["lanes"] if x["id"] == L)
exp = recomputed[L][0]
if jl.get("status") != exp or jl.get("latest_log") != recomputed[L][1]:
print("FAIL: lane %s status/log mismatch (json=%s/%s recomputed=%s/%s)"
% (L, jl.get("status"), jl.get("latest_log"), exp, recomputed[L][1]))
ok = False
exp_counts = {}
for status, _ in recomputed.values():
exp_counts[status] = exp_counts.get(status, 0) + 1
if rec.get("status_counts") != exp_counts:
print("FAIL: status_counts mismatch json=%s recomputed=%s" % (rec.get("status_counts"), exp_counts))
ok = False
if not ok:
print("RECOMPUTE %s" % json_path)
sys.exit(1)
print("OK: lanes=%d statuses=%s counts=%s ids_match=yes" % (
len(lanes), ",".join("%s=%s" % (k, v) for k, v in sorted(recomputed.items())),
rec.get("status_counts")))
sys.exit(0)
PY
rc=$?
if [ $rc -ne 0 ]; then
echo "FAIL: independent recompute disagrees with committed artifact" >&2
exit 1
fi
echo "PASS: lane triage artifact verified against live filesystem"
exit 0