Skip to content

Commit 13a47fb

Browse files
committed
Fix cancel allowlist regex and move methodology handler before git-clean
The cancel-rlcr-loop.sh allowlist in the bash validator matched when the script name appeared as an argument to another command (e.g. cp). Anchor the regex to the start of the command string so only direct invocations are allowed. Move the methodology analysis completion handler in the stop hook to run before the git-clean check. Writing methodology artifacts can make the working tree appear dirty when .humanize is tracked, which would block exit before the handler ever ran.
1 parent 0edbe3f commit 13a47fb

File tree

2 files changed

+25
-22
lines changed

2 files changed

+25
-22
lines changed

hooks/loop-bash-validator.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@ ACTIVE_PR_LOOP_DIR=$(find_active_pr_loop "$PR_LOOP_BASE_DIR")
8585
_MA_BASH_DIR="$ACTIVE_LOOP_DIR"
8686

8787
if [[ -n "$_MA_BASH_DIR" ]] && [[ -f "$_MA_BASH_DIR/methodology-analysis-state.md" ]]; then
88-
# Allow cancel-rlcr-loop.sh (user must be able to cancel during this phase)
89-
# Only allow standalone invocation -- reject if chained with shell operators
90-
if echo "$COMMAND_LOWER" | grep -qE '(^|[[:space:]])([^[:space:]]*/)?cancel-rlcr-loop\.sh' && \
88+
# Allow cancel-rlcr-loop.sh only as the leading command (not as an argument
89+
# to another command like cp/mv). Reject if chained with shell operators.
90+
if echo "$COMMAND_LOWER" | grep -qE '^[[:space:]]*("?[^"]*/?)?cancel-rlcr-loop\.sh' && \
9191
! echo "$COMMAND_LOWER" | grep -qE '[;|&]'; then
9292
exit 0
9393
fi

hooks/loop-codex-stop-hook.sh

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,28 @@ Split these into smaller modules before continuing."
582582
fi
583583
fi
584584

585+
# ========================================
586+
# Methodology Analysis Phase Completion Handler
587+
# ========================================
588+
# When in methodology analysis phase, check if the analysis is done.
589+
# If done, rename state to the original exit reason's terminal state.
590+
# If not done, block and ask Claude to complete the analysis.
591+
# All other checks (summary, bitlesson, goal tracker, max iterations) are skipped.
592+
# IMPORTANT: This MUST run before the git-clean check, because methodology
593+
# artifacts (.humanize/rlcr/...) may make the working tree appear dirty
594+
# if .humanize is tracked, which would block exit before reaching this handler.
595+
596+
if [[ "$IS_METHODOLOGY_ANALYSIS_PHASE" == "true" ]]; then
597+
if complete_methodology_analysis; then
598+
# Analysis complete, allow exit
599+
exit 0
600+
else
601+
# Analysis not yet complete, block
602+
block_methodology_analysis_incomplete
603+
exit 0
604+
fi
605+
fi
606+
585607
# ========================================
586608
# Quick Check: Git Clean and Pushed?
587609
# ========================================
@@ -682,25 +704,6 @@ Please push before exiting."
682704
fi
683705
fi
684706

685-
# ========================================
686-
# Methodology Analysis Phase Completion Handler
687-
# ========================================
688-
# When in methodology analysis phase, check if the analysis is done.
689-
# If done, rename state to the original exit reason's terminal state.
690-
# If not done, block and ask Claude to complete the analysis.
691-
# All other checks (summary, bitlesson, goal tracker, max iterations) are skipped.
692-
693-
if [[ "$IS_METHODOLOGY_ANALYSIS_PHASE" == "true" ]]; then
694-
if complete_methodology_analysis; then
695-
# Analysis complete, allow exit
696-
exit 0
697-
else
698-
# Analysis not yet complete, block
699-
block_methodology_analysis_incomplete
700-
exit 0
701-
fi
702-
fi
703-
704707
# ========================================
705708
# Check Summary File Exists
706709
# ========================================

0 commit comments

Comments
 (0)