#!/usr/bin/env bash # teardown-stack.sh — the last PMO action. Run when: (a) no work-* lane # screens remain, (b) loop is idle-scan or mid-turn on non-critical work. # Self-hosting completes here: loop container is the only worker. set -u LOG=/home/reachableceo/.coordinate/log.md MRED_DIR=/home/reachableceo/projects/meta/MOPAC/redmine-go ts() { date -Is | cut -c1-19; } # 1. Final ticket writes (523 gate closes = criteria 3 satisfied NOW). cd "$MRED_DIR" || exit 1 set -a; . ~/.creds/redmine.env; set +a export MRED_URL=https://projects.knownelement.com MRED_KEY="$REDMINE_API_KEY" bin/mred issue update 523 --status Resolved --done-ratio 100 \ --note "EXIT GATE CLOSED $(ts): container driving (restart=unless-stopped, healthy all day), dev.sh screen dead since 07:49, autonomy proven (20+ autonomous turns), ALL crush screens retired by this teardown. Alpha complete. Self-hosted." || true bin/mred issue update 528 --status Rejected \ --note "Duplicate of 529 (PMO heredoc double-file). Work tracked on 529." || true # 2. Closing SMS attempt (queues offline until postfix is wired). bash /home/reachableceo/.coordinate/scripts/ping-charles.sh \ "MOPAC self-hosted: crush stack retired $(date %%H:%%M). Loop container is sole worker. First brief 0630. Iterate via Redmine. Ops manual: harness/docs/OPERATIONS.md" || true # 3. Final state + push. echo "$(ts) | PMO | TEARDOWN: self-hosted. crush stack retired (PMO, heartbeat, lanes). Loop sole worker. Fleet boot tomorrow AM w/ Charles (TSGCOO first). Snapshot 7 = STATE-SNAPSHOT-20260829-teardown.md" >> "$LOG" cp /home/reachableceo/.coordinate/STATE-SNAPSHOT-20260829-0530.md /home/reachableceo/.coordinate/STATE-SNAPSHOT-20260829-teardown.md 2>/dev/null || true cd /home/reachableceo/.coordinate && git add -A && git commit -q -m "pmo: TEARDOWN — self-hosted; loop is sole worker" && git push -q origin main || true # 4. Kill the stack: heartbeat first, then PMO last (this script's parent screen). screen -S pmo-heartbeat -X quit 2>/dev/null for s in $(screen -ls | grep -oE '[0-9]+\.[A-Za-z0-9_-]+' | grep -vE 'teardown'); do case "$s" in *RCEO-PMO) continue ;; esac screen -S "${s#*.}" -X quit 2>/dev/null done screen -S RCEO-PMO -X quit 2>/dev/null echo "stack down $(ts)"