The vault 146 files

Demo / the vault

scripts/guides-watch.sh

#!/usr/bin/env bash
# Weekly get-current step: diff chiefofstaff.io's guide feed against what we've
# seen. State lives in the vault and is committed. (ADR-16)
#
# 2026-09-20: repointed from http://localhost:8788/guides.json to the public
# origin. Rowan deployed the site; the feed now answers from anywhere, which is
# what hobbs-hab was open on. Three things this version does that the localhost
# one did not, and each one is a failure mode that was actually observed:
#   -L        the apex 301s to www. Without it curl -sf exits 0 on the redirect
#             stub and hands 167 bytes of HTML to python, which is a crash
#             wearing the costume of a fetch.
#   --max-time  a hang is not a diff.
#   json gate  a 200 that is not JSON is UNREACHABLE, not "nothing new".
# The one honest signal is unchanged and is the point of the script: it reports
# UNREACHABLE and exits non-zero rather than ever report an empty diff it has
# not earned.
set -uo pipefail
cd "$(dirname "$0")/.."
FEED="https://chiefofstaff.io/guides.json"
SEEN="Efforts/cos-guides-seen.json"
TMP=$(mktemp)
trap 'rm -f "$TMP"' EXIT

unreachable() { echo "GUIDES FEED UNREACHABLE ($1) — say so in the review; do not report 'nothing new'"; exit 1; }

HTTP=$(curl -sfL --max-time 30 -w '%{http_code}' "$FEED" -o "$TMP") || unreachable "curl failed against $FEED"
[ "$HTTP" = "200" ] || unreachable "HTTP $HTTP"
python3 -c 'import json,sys; json.load(open(sys.argv[1]))["guides"]' "$TMP" 2>/dev/null \
  || unreachable "HTTP 200 but the body is not the guides feed"

[ -f "$SEEN" ] || echo '{"seen":{}}' > "$SEEN"

python3 - "$TMP" "$SEEN" <<'PY'
import json,sys
feed=json.load(open(sys.argv[1])); seen=json.load(open(sys.argv[2]))
s=seen.get("seen",{})
new=[]; upd=[]
for g in feed["guides"]:
    slug=g["slug"]
    if slug not in s: new.append(g)
    elif g["updated"] > s[slug]: upd.append(g)
print(f"Feed: {feed['count']} guides, generated {feed.get('generated','?')}. Seen: {len(s)}. New: {len(new)}. Updated: {len(upd)}.")
if not new and not upd:
    print("\nNothing new. The 'New from chiefofstaff.io' section does not render this week.")
for label,items in (("NEW",new),("UPDATED",upd)):
    for g in items:
        print(f"\n[{label}] {g['title']}  ({g['trackLabel']})")
        print(f"  {g['description']}")
        print(f"  outcome: {g['outcome']}")
        print(f"  markdown: {g['markdown']}")
        if g.get("prerequisites"): print(f"  prerequisites: {', '.join(g['prerequisites'])}")
        if g.get("contributor"): print(f"  contributor: {g['contributor']}")
        print("  → WRITE ONE SENTENCE: does this apply to Rowan's system? Be specific.")
PY
echo
echo "If Rowan says 'yes, that one': fetch the .md twin, report unmet prerequisites,"
echo "propose an ADR BEFORE touching anything, then implement and commit with"
echo "provenance pointing at the guide."
echo
echo "Then write the seen-file back and commit it. State lives in the vault."