#!/usr/bin/env bash # founder-wire-tooling.sh — FOUNDER-RUN as root. # Wire the tooling repo (agent-stack @ current HEAD) into all four TSG # verticals: canonical pmo-loop.sh (metrics-ledgered), dispatch-turn.sh, # semaphore.sh, agent-metrics.sh into ~/.coordinate/scripts/. RCEO already # wired itself. Supervisor units (tsg-supervisor.*) already org-wide. # Stamped copies per provenance rule; fix forward in the repo, reinstall. set -uo pipefail [ "$(id -un)" = root ] || { echo "run as: sudo bash $0" >&2; exit 1; } TOOLING=/home/_crossfeed/tooling SRC=$TOOLING/agent-stack SHA=$(git -C "$SRC" rev-parse --short HEAD) FILES="pmo-loop.sh dispatch-turn.sh semaphore.sh agent-metrics.sh" echo "== preflight ==" for f in $FILES; do [ -f "$SRC/$f" ] || { echo "missing $SRC/$f" >&2; exit 1; }; done echo "ok: source files present @ $SHA" for acct in TSGBOD TSGCCO TSGCTO TSGCOO; do home=$(getent passwd "$acct" | cut -d: -f6) echo "== $acct ==" mkdir -p "$home/.coordinate/scripts" "$home/.coordinate/logs" for f in $FILES; do install -o "$acct" -g "$acct" -m755 "$SRC/$f" "$home/.coordinate/scripts/$f" done sed -i "1a # installed: agent-stack @ $SHA ($(date -I))" "$home/.coordinate/scripts/pmo-loop.sh" cat > "$home/.coordinate/inbox-pmo/NOTICE-tooling-wiring.md" < ~/.coordinate/scripts/dispatch-turn.sh (semaphore-gated, fresh session, doorbell back to your PMO screen; see GOVERNANCE.md in the repo: capture free, execution metered; founder gate on every TASK still applies). Wrapper now logs launches to metrics. Fix bugs IN THE REPO (commit as your uid via tooling/commit.sh), then rerun this installer. Archive this notice after reading. EOF chown "$acct:$acct" "$home/.coordinate/inbox-pmo/NOTICE-tooling-wiring.md" echo " wired + NOTICE" done echo "== verify ==" for acct in TSGBOD TSGCCO TSGCTO TSGCOO; do home=$(getent passwd "$acct" | cut -d: -f6) echo " $acct: $(ls "$home/.coordinate/scripts/" 2>/dev/null | tr '\n' ' ')" done