fix: feat: active-state files — per-cron guard with self-off semantics (#622)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
openhands 2026-03-23 21:46:59 +00:00
parent e041b20823
commit e535ed776f
10 changed files with 47 additions and 1 deletions

21
lib/guard.sh Normal file
View file

@ -0,0 +1,21 @@
#!/usr/bin/env bash
# guard.sh — Active-state guard for cron entry points
#
# Each agent checks for a state file before running. If the file
# doesn't exist, the agent logs a skip and exits cleanly.
#
# State files live in $FACTORY_ROOT/state/:
# .dev-active, .reviewer-active, .planner-active, etc.
#
# Presence = permission to run. Absence = skip (factory off by default).
# check_active <agent_name>
# Exit 0 (skip) if the state file is absent.
check_active() {
local agent_name="$1"
local state_file="${FACTORY_ROOT}/state/.${agent_name}-active"
if [ ! -f "$state_file" ]; then
log "${agent_name} not active — skipping"
exit 0
fi
}