teqo-backup/scripts/auto-unblock.sh
Francisco Solla 37b338a700 feat(OPS106): falha do verify dispara agente autônomo de desbloqueio (single-flight)
Workflow separado auto-unblock.yml (workflow_run no Deploy, push/main + job verify vermelho pela jobs API), launcher com flock próprio + Issue token auto-unblock como single-flight, e wrapper destacado que provisiona worktree fix/* via worktree.mjs fix --headless, aplica guard de banco local teqo_wt* fail-closed e roda opencode run --command bug-fix (cap 4h). deploy.yml/verify intocados; sem auto-retry e produção segue com approval humano.
2026-09-14 05:51:39 -03:00

25 lines
1 KiB
Bash
Executable file

#!/usr/bin/env bash
#
# OPS106 auto-unblock — entrypoint of `.github/workflows/auto-unblock.yml` on
# the homeserver. Holds `/tmp/teqo-unblock.lock` (flock) for the read of the
# single-flight state and hands the open fd 9 to the detached agent wrapper, so
# the lock is held for the agent's whole lifetime while this job exits in ~1
# minute (the runner slot is not blocked). A second failure finds the lock busy
# and only comments on the open token — never queues an agent.
#
# The lock is intentionally NOT the deploy lock: the agent must never block a
# deploy and a deploy must never be mistaken for the agent.
set -euo pipefail
UNBLOCK_HOME="${TEQO_UNBLOCK_HOME:-$HOME/teqo-unblock}"
LOCK_FILE="${TEQO_UNBLOCK_LOCK:-/tmp/teqo-unblock.lock}"
mkdir -p "$UNBLOCK_HOME/logs" "$UNBLOCK_HOME/state" "$UNBLOCK_HOME/worktrees"
exec 9>"$LOCK_FILE"
LOCK_BUSY=0
flock -n 9 || LOCK_BUSY=1
# Hand the exact lock path to the orchestrator (its lock probe uses it).
export TEQO_UNBLOCK_LOCK="$LOCK_FILE"
exec node scripts/auto-unblock.mjs "--lock-busy=$LOCK_BUSY"