ops(tickets): redmine 490-499 fleshed; session artifacts tracked

This commit is contained in:
2026-08-29 05:24:34 -05:00
parent c01b3d6295
commit fab1f48fb8
44 changed files with 846 additions and 2 deletions
@@ -0,0 +1,43 @@
#!/usr/bin/env bash
# source: /home/_crossfeed/tooling/agent-stack @ HEAD
# dispatch-turn.sh <slug> <prompt-file> — headless work-turn launcher.
# Semaphore-gated (org concurrency cap), FRESH session by default (small
# context = quota-friendly; the turn self-bootstraps from the prompt file),
# success/fail doorbell to the vertical PMO screen. PMO usage:
# screen -dmS work-turn-<slug> \
# ~/.coordinate/scripts/dispatch-turn.sh <slug> <prompt-file>
set -uo pipefail
SLUG=${1:?slug}; PROMPT=${2:?prompt-file}
TOOLING=${TOOLING:-/home/_crossfeed/tooling}
SEMI="$TOOLING/agent-stack/semaphore.sh"
LOG="$HOME/.coordinate/logs/$SLUG.log"
TAG="$USER-$SLUG"
WAIT=${WAIT_SECS:-300}
[ -f "$PROMPT" ] || { echo "no prompt file: $PROMPT" >&2; exit 1; }
semirc=0
bash "$SEMI" try "$TAG" "$WAIT" >/dev/null 2>&1 || semirc=$?
if [ "$semirc" = 99 ]; then
echo "$(date -Is) semaphore gate unavailable - proceeding UNGATED (install metrics dirs)" >> "$LOG"
elif [ "$semirc" != 0 ]; then
echo "$(date -Is) semaphore rc=$semirc after ${WAIT}s budget - not launched" >> "$LOG"
screen -S "${USER}-PMO" -X stuff "$(printf 'Work turn DEFERRED (concurrency cap) - rerun later: %s.\r' "$SLUG")" || true
exit 3
fi
GATED=1; [ "$semirc" = 0 ] || GATED=0
cd "$HOME"
rc=0
env HOME="$HOME" TERM=xterm-256color \
crush run --quiet "$(cat "$PROMPT")" >> "$LOG" 2>&1 || rc=$?
bash "$SEMI" release "$TAG" >/dev/null 2>&1 || true
if [ "$rc" = 0 ]; then
screen -S "${USER}-PMO" -X stuff "$(printf 'Work turn done OK - read inbox-pmo + logs/%s.\r' "$SLUG")" || true
else
screen -S "${USER}-PMO" -X stuff "$(printf 'Work turn FAILED (rc=%s) - read logs/%s.\r' "$rc" "$SLUG")" || true
fi
exit "$rc"
@@ -0,0 +1,2 @@
#!/usr/bin/env bash
screen -S TSGCTO-PMO -X stuff "$(printf 'Work turn done - read inbox-pmo + log.\r')"
+41
View File
@@ -0,0 +1,41 @@
#!/usr/bin/env bash
# pmo-loop.sh [pmo|work] — keep a crush session alive inside its screen.
ROLE="${1:-pmo}"
case "$ROLE" in
pmo) FRESH="$HOME/.coordinate/RELAUNCH-FRESH"; PIN="$HOME/.coordinate/PMO-SESSION-ID" ;;
work) FRESH="$HOME/.coordinate/RELAUNCH-FRESH-WORK"; PIN="$HOME/.coordinate/WORK-SESSION-ID" ;;
*) echo "usage: $0 [pmo|work]" >&2; exit 1 ;;
esac
LOG="$HOME/.coordinate/logs/${ROLE}-relaunch.log"
LEDGER=/home/_crossfeed/metrics/launches.jsonl
ledger() { printf '%s\n' "$1" >> "$LEDGER" 2>/dev/null || true; }
cd "$HOME"
export TERM="${TERM:-xterm-256color}"
export PATH="$HOME/.local/bin:/usr/local/bin:/usr/bin:/bin:$PATH"
while true; do
started=$(date +%s)
mode=continue
if [ -f "$FRESH" ]; then
rm -f "$FRESH"
mode=fresh
echo "$(date -Is) relaunch FRESH" >> "$LOG"
crush --yolo
elif [ -s "$PIN" ]; then
sid=$(cat "$PIN")
mode=pinned:$sid
echo "$(date -Is) relaunch PINNED $sid" >> "$LOG"
crush --yolo --session "$sid"
else
echo "$(date -Is) relaunch CONTINUE" >> "$LOG"
crush --yolo --continue
fi
rc=$?
rt=$(( $(date +%s) - started ))
ledger "{\"ts\":\"$(date -Is)\",\"user\":\"$USER\",\"role\":\"$ROLE\",\"mode\":\"$mode\",\"rc\":$rc,\"runtime_s\":$rt}"
if [ "$rt" -lt 60 ]; then
echo "$(date -Is) short run (${rt}s rc=$rc) - backoff 60s" >> "$LOG"
sleep 60
else
sleep 2
fi
done