Skip to content

Commit 5990827

Browse files
committed
Gate methodology completion on a clean git tree
When methodology-analysis-state.md is active, the stop hook returned exit 0 as soon as complete_methodology_analysis succeeded, short- circuiting past the main git-clean gate. Tracked source edits made during the analysis phase (for example, post-Codex-signoff modifications) could slip through unreviewed the moment the completion marker appeared. Re-run the existing git-clean validation inside the methodology completion branch before allowing the terminal exit. Reuse the HUMANIZE_UNTRACKED_PATTERN filter from the main gate so legitimate .humanize/rlcr/... methodology artifacts are not themselves treated as dirty. If the filtered status is non-empty, block with the same git-not-clean template the main gate uses.
1 parent d09a282 commit 5990827

1 file changed

Lines changed: 39 additions & 1 deletion

File tree

hooks/loop-codex-stop-hook.sh

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,45 @@ fi
616616

617617
if [[ "$IS_METHODOLOGY_ANALYSIS_PHASE" == "true" ]]; then
618618
if complete_methodology_analysis; then
619-
# Analysis complete, allow exit
619+
# Before allowing the terminal state transition, re-verify the
620+
# working tree is clean. The main git-clean gate below is skipped
621+
# in the methodology branch, so without this check, tracked edits
622+
# made during the analysis phase (e.g. post-signoff source
623+
# modifications) could slip through unreviewed as soon as the
624+
# completion marker appears.
625+
#
626+
# Apply the same .humanize/ untracked exclusion the main gate uses
627+
# so methodology-artifact writes under .humanize/rlcr/... do not
628+
# themselves trip the check.
629+
if [[ "$GIT_IS_REPO" == "true" ]]; then
630+
HUMANIZE_UNTRACKED_PATTERN='^\?\? \.humanize[-/]'
631+
GIT_STATUS_FOR_BLOCK=$(echo "$GIT_STATUS_CACHED" | grep -vE "$HUMANIZE_UNTRACKED_PATTERN" || true)
632+
if [[ -n "$GIT_STATUS_FOR_BLOCK" ]]; then
633+
cleanup_stale_index_lock
634+
FALLBACK="# Git Not Clean
635+
636+
Methodology analysis is complete, but the working tree still has uncommitted changes:
637+
638+
{{GIT_ISSUES}}
639+
640+
Please commit all changes before allowing the loop to exit.
641+
{{SPECIAL_NOTES}}"
642+
REASON=$(load_and_render_safe "$TEMPLATE_DIR" "block/git-not-clean.md" "$FALLBACK" \
643+
"GIT_ISSUES=uncommitted changes after methodology analysis" \
644+
"SPECIAL_NOTES=")
645+
646+
jq -n \
647+
--arg reason "$REASON" \
648+
--arg msg "Loop: Blocked - uncommitted changes detected after methodology analysis, please commit first" \
649+
'{
650+
"decision": "block",
651+
"reason": $reason,
652+
"systemMessage": $msg
653+
}'
654+
exit 0
655+
fi
656+
fi
657+
# Analysis complete and tree clean, allow exit
620658
exit 0
621659
else
622660
# Analysis not yet complete, block

0 commit comments

Comments
 (0)