c13cfd2bd0
Duenner, zustandsloser Proxy (nur stdlib) zwischen Aider und llama-swap :8080. Schiebt an einer Token-Schwelle "SAVEPOINT.md finalisieren + stoppen" ein (weich) bzw. antwortet oberhalb eines optionalen Hart-Deckels selbst. Beweist Session- Hygiene per hartem Schnitt statt Auto-Compaction -- ohne eine Zeile Lucy-Code. Alle 4 Akzeptanzkriterien gruen: feuert im Log; SAVEPOINT.md gepflegt; ehrlicher Grenz-Savepoint am ersten Feuern; frische Sitzung liest Savepoint -> baut Tests, 9 unittest gruen, keine Fassade. CPT 3.5 kalibriert (est ~= echte prompt_tokens). Hart-Deckel nachgeruestet (weicher Schnitt allein erzeugt Fassade bei Weiterarbeit ueber die Grenze). Streaming-read1-Fix + 4 kleinere aus adversarialer Review. Laeuft deployt auf der Box unter ~/governor-p0/ (gov-ctl.sh start <soft> <hart>). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
53 lines
1.5 KiB
Bash
53 lines
1.5 KiB
Bash
#!/usr/bin/env bash
|
|
# gov-ctl.sh — Governor sauber starten/stoppen (Phase-0-Helfer).
|
|
# Nutzung:
|
|
# gov-ctl.sh start [SCHWELLE] # startet detached, Default-Schwelle 25000
|
|
# gov-ctl.sh stop
|
|
# gov-ctl.sh status
|
|
set -u
|
|
DIR="$HOME/governor-p0"
|
|
PIDF="$DIR/governor.pid"
|
|
LOG="$DIR/governor.log"
|
|
OUT="$DIR/governor.stdout"
|
|
|
|
start() {
|
|
stop
|
|
local thr="${1:-25000}"
|
|
local hard="${2:-${GOV_HARD_CEILING:-0}}"
|
|
cd "$DIR"
|
|
: > "$LOG"
|
|
# Voll detachen: eigene Session, alle FDs weg vom Aufrufer.
|
|
# CPT (Zeichen/Token) aus der Umgebung durchreichen, Default 3.5 (kalibriert 24.07.).
|
|
setsid env GOV_THRESHOLD="$thr" GOV_HARD_CEILING="$hard" \
|
|
GOV_CHARS_PER_TOKEN="${GOV_CHARS_PER_TOKEN:-3.5}" \
|
|
GOV_LOG="$LOG" GOV_PORT=8100 \
|
|
python3 "$DIR/governor.py" </dev/null >>"$OUT" 2>&1 &
|
|
echo $! > "$PIDF"
|
|
sleep 1.2
|
|
echo "started pid=$(cat "$PIDF") threshold=$thr hard=$hard"
|
|
ss -tlnp 2>/dev/null | grep ":8100" >/dev/null && echo "listening :8100 OK" || echo "WARN: not listening"
|
|
}
|
|
|
|
stop() {
|
|
pkill -f "$DIR/governor.py" 2>/dev/null || true
|
|
[ -f "$PIDF" ] && kill "$(cat "$PIDF")" 2>/dev/null || true
|
|
sleep 0.6
|
|
rm -f "$PIDF"
|
|
}
|
|
|
|
status() {
|
|
if pgrep -f "$DIR/governor.py" >/dev/null; then
|
|
echo "running pid=$(pgrep -f "$DIR/governor.py" | tr '\n' ' ')"
|
|
ss -tlnp 2>/dev/null | grep ":8100" || true
|
|
else
|
|
echo "not running"
|
|
fi
|
|
}
|
|
|
|
case "${1:-status}" in
|
|
start) shift; start "${1:-25000}" "${2:-}" ;;
|
|
stop) stop; echo stopped ;;
|
|
status) status ;;
|
|
*) echo "usage: gov-ctl.sh {start [soft] [hart]|stop|status}"; exit 2 ;;
|
|
esac
|