feat: factory supervisor with priorities, auto-fix, and claude -p escalation

- P0: memory crisis (auto-kill stale claude, drop caches, restart Anvil)
- P1: disk pressure (docker prune, log truncate, worktree cleanup, WP log trim)
- P2: factory stopped (CI stuck, dev-agent dead, git broken — auto-fix where possible)
- P3: factory degraded (derailed PRs, auto-trigger reviews)
- P4: housekeeping (stale processes, log rotation)

Calls claude -p only for P0/P1 issues that auto-fix couldn't resolve.
PROMPT.md contains distilled operational knowledge + self-update mechanism.
This commit is contained in:
openhands 2026-03-12 13:00:17 +00:00
parent cb24968d9b
commit cb7dd398c7
3 changed files with 347 additions and 102 deletions

34
factory/update-prompt.sh Executable file
View file

@ -0,0 +1,34 @@
#!/usr/bin/env bash
# update-prompt.sh — Append a lesson learned to PROMPT.md
#
# Usage:
# ./factory/update-prompt.sh "### Title" "Body text describing the lesson"
# ./factory/update-prompt.sh --from-file /tmp/lesson.md
#
# Called by claude -p when it learns something new during a fix.
# Commits and pushes the update to the dark-factory repo.
source "$(dirname "$0")/../lib/env.sh"
PROMPT_FILE="${FACTORY_ROOT}/factory/PROMPT.md"
if [ "$1" = "--from-file" ] && [ -f "$2" ]; then
LESSON=$(cat "$2")
elif [ -n "$1" ] && [ -n "$2" ]; then
LESSON="$1
$2"
else
echo "Usage: update-prompt.sh 'Title' 'Body' OR update-prompt.sh --from-file path" >&2
exit 1
fi
# Append to PROMPT.md under Best Practices
echo "" >> "$PROMPT_FILE"
echo "$LESSON" >> "$PROMPT_FILE"
cd "$FACTORY_ROOT"
git add factory/PROMPT.md
git commit -m "factory: update supervisor best practices" --no-verify 2>/dev/null
git push origin main 2>/dev/null
log "PROMPT.md updated with new lesson"