diff --git a/.claude/hooks/watchdog_gate.py b/.claude/hooks/watchdog_gate.py index 61e5c1f..3c3c3d5 100644 --- a/.claude/hooks/watchdog_gate.py +++ b/.claude/hooks/watchdog_gate.py @@ -41,16 +41,20 @@ def verdict(text): # 판정은 결과의 마지막 비어 있지 않은 줄이 정확히 "WATCHDOG: PASS" 일 때만 인정한다 (본문 중간 인용·FIX 혼재 차단) # 백그라운드 알림은 뒤에 · 이 붙으므로 본문만 본다 text = text.replace("\\n", "\n") - m = re.search(r"(.*?)", text, re.S) - if m: - text = m.group(1) - # 동기 결과는 판정 뒤에 하네스 꼬리(agentId: … 줄, …)가 붙는다. 꼬리만 떼고 마지막 줄 규칙은 그대로 둔다 - text = re.sub(r".*?", "", text, flags=re.S) - lines = [l.strip() for l in text.splitlines() if l.strip() and not l.strip().startswith("agentId:")] + # FIX 가 원문 어디에든 있으면 통과시키지 않는다 (꼬리 제거· 추출 전에 검사) + if "WATCHDOG: FIX" in text: + return False + # 백그라운드 알림은 마지막 블록만 본다 + blocks = re.findall(r"(.*?)", text, re.S) + if blocks: + text = blocks[-1] + # 동기 결과는 판정 뒤에 하네스 꼬리(agentId: … 줄 + …)가 붙는다. 문자열 끝에 붙은 꼬리만 뗀다 + text = re.sub(r"\n\s*agentId:[^\n]*\s*(.*?)?\s*$", "", text, flags=re.S) + lines = [l.strip() for l in text.splitlines() if l.strip()] if not lines: return False last = re.sub(r"[`*_<>/]|result", "", lines[-1]).strip() - return last == "WATCHDOG: PASS" and "WATCHDOG: FIX" not in text + return last == "WATCHDOG: PASS" def main():