disinto/lib/guard.sh
openhands e535ed776f 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>
2026-03-23 21:46:59 +00:00

21 lines
661 B
Bash

#!/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
}