From 61f3038794d4e776c767525ab6053cf150a4ad38 Mon Sep 17 00:00:00 2001 From: Alexey <1556417+alex-solovyev@users.noreply.github.com> Date: Sat, 14 Mar 2026 09:49:04 +0100 Subject: [PATCH] fix(supervisor): guard cooldown file write against unset SUPERVISOR_STATE_DIR and move timestamp after success - Use ${SUPERVISOR_STATE_DIR:-/var/lib/supervisor} instead of SUPERVISOR_DIR for task_creation_cooldown_file to guard against unset variable under set -u/-e - Add mkdir -p before writing the cooldown timestamp to ensure directory exists - Move date +%s write to AFTER confirming TODO.md exists and task creation runs, preventing the cooldown from throttling retries when prerequisites are missing Addresses PR #1170 review feedback (issue #3526). --- .agents/scripts/supervisor-archived/pulse.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.agents/scripts/supervisor-archived/pulse.sh b/.agents/scripts/supervisor-archived/pulse.sh index 995c5f62b..86a17491e 100755 --- a/.agents/scripts/supervisor-archived/pulse.sh +++ b/.agents/scripts/supervisor-archived/pulse.sh @@ -2949,7 +2949,7 @@ cmd_pulse() { elif [[ -x "$legacy_task_creator" ]]; then task_creator_script="$legacy_task_creator" fi - local task_creation_cooldown_file="${SUPERVISOR_DIR}/task-creation-last-run" + local task_creation_cooldown_file="${SUPERVISOR_STATE_DIR:-/var/lib/supervisor}/task-creation-last-run" local task_creation_cooldown=86400 # 24 hours if [[ -n "$task_creator_script" ]]; then local should_run_task_creation=true @@ -2973,7 +2973,6 @@ cmd_pulse() { if [[ "$should_run_task_creation" == "true" ]]; then log_info " Phase 10b: Auto-creating tasks from quality findings" - date +%s >"$task_creation_cooldown_file" # Determine repo for TODO.md local task_repo="" @@ -3104,6 +3103,10 @@ cmd_pulse() { log_verbose " Phase 10b: No new tasks to create" fi routine_record_run "task_creation" "$tasks_added" 2>/dev/null || true + # Write cooldown timestamp only after TODO.md confirmed present and + # task creation has run (prevents throttling retries on failures). + mkdir -p "$(dirname "$task_creation_cooldown_file")" 2>/dev/null || true + date +%s >"$task_creation_cooldown_file" fi fi fi