Skip to content

fix(hooks): fall through when a launcher's impl is absent - #1066

Merged
devseunggwan merged 1 commit into
mainfrom
issue-1053-fix-launcher-fail-open
Aug 22, 2026
Merged

devseunggwan merged 1 commit into
mainfrom
issue-1053-fix-launcher-fail-open

Conversation

@devseunggwan

@devseunggwan devseunggwan commented Aug 22, 2026 •

Copy link
Copy Markdown
Owner

무엇이 바뀌나

훅 런처가 자기 impl 을 못 띄울 때, 아무도 내리지 않은 차단이 호스트에 나가던 것을 막습니다. 이 PR 이후 impl 이 없으면 그 훅은 판정하지 않고 통과시킵니다.

원인

@fail_open 은 impl 안에서 도는 장치라, impl 이 뜨지 못한 경우에는 손쓸 자리가 없습니다. 그리고 파이썬은 파일을 못 열면 exit 2 를 내는데, 이 리포에서 2 는 deny 입니다 — _dispatch.py 가 rc == 2 로 결정을 집계합니다.

$ python3 -c "import subprocess,sys; p=subprocess.run([sys.executable,'/definitely/missing.py'],capture_output=True); print('missing-file exit:',p.returncode)"
missing-file exit: 2

부분 설치, 플러그인 디렉터리 드리프트, hosts 필터가 런처만 쓰고 impl 을 안 쓴 경우가 실제 발생 경로입니다.

어떻게 고쳤나

scripts/build-plugin-manifests.py 의 템플릿 3개(python / body-as-sh / dispatch) 모두 exec 앞에 impl 존재 확인을 넣고, 런처 49개를 재생성했습니다.

IMPL="$(dirname "$0")/{role}/{name}/impl.py"
[ -f "$IMPL" ] || exit 0
exec python3 "$IMPL" {baked_args}"$@"

exec 과 shebang 존중은 그대로이고 프로세스도 늘지 않습니다.

기각한 대안 — 비0 일괄 정규화

PR #1052 의 CodeRabbit 리뷰가 제안한 python3 … || exit 0 은 비0 을 구분 없이 접습니다. 이 리포에서는 그것이 return 2 로 차단하는 훅 41개의 deny 를 함께 삼킵니다. 측정으로 확인했습니다:

$ echo '{}' | sh cr.sh          # CodeRabbit 제안 형태, impl 은 sys.exit(2)
CODERABBIT deny -> exit=0       # 2 가 나와야 하는 자리

근거와 함께 해당 스레드에 회신하고 닫았습니다.

이슈 본문의 서술도 정정합니다

#1053 은 "문법 오류가 하나 들어가면 매칭되는 모든 호출이 세션 내내 막힌다"고 적었는데, 성립하지 않습니다. Claude Code 에서 PreToolUse 를 차단하는 코드는 exit 2 하나뿐이고 exit 1 은 non-blocking 입니다 (hooks 문서). 실제 차단 경로는 impl 부재 하나이며, 이 PR 이 닫는 것도 그것입니다. 이슈 본문에 반영했습니다.

Pre-commit verified: python3 scripts/check-plugin-manifests.py → plugin-manifest check OK, bash tests/test_launcher_fail_open.sh → 9 passed / 0 failed
Caller chain verified: 런처 49개는 전부 이 생성기의 산출물이며(grep -c "^# AUTO-GENERATED by scripts/build-plugin-manifests.py" hooks/*.sh → 49), 재생성 후 check-plugin-manifests.py 의 wrapper-drift 규칙이 전량 일치를 확인합니다. 템플릿 문자열의 다른 소비자는 없습니다.

Closes #1053

Summary by CodeRabbit

  • Bug Fixes

    • Missing hook implementations now fail open instead of being treated as blocking denials.
    • Intentional denial results and other implementation errors continue to pass through unchanged.
  • Tests

    • Added coverage for missing implementations, deliberate denials, successful execution, and runtime failures.
  • Documentation

    • Documented launcher behavior when an implementation is unavailable.

런처가 impl 을 못 띄우면 그 종료 코드가 그대로 호스트에 나간다. `@fail_open`
은 impl 안에서 도는 장치라 impl 이 뜨지 못한 경우에는 손쓸 자리가 없다.

파이썬은 파일을 못 열면 exit 2 를 내는데, 이 리포에서 2 는 deny 다
(`_dispatch.py` 가 `rc == 2` 로 집계). 부분 설치나 플러그인 디렉터리 드리프트로
impl.py 가 없으면, 아무도 내리지 않은 차단이 매칭되는 모든 호출에 걸린다.

    $ python3 -c "...subprocess.run([sys.executable,'/missing.py'])..."
    missing-file exit: 2

세 템플릿(python / body-as-sh / dispatch) 모두 exec 앞에 impl 존재 확인을
넣고 런처 49개를 재생성한다. `exec` 과 shebang 존중은 그대로이고 프로세스도
늘지 않는다.

비0 을 일괄 0 으로 접는 형태(`… || exit 0`)는 기각했다. 그것은 `return 2` 로
차단하는 훅 41개의 deny 를 함께 삼킨다 — 측정으로 확인했고 PR #1052 스레드에
근거와 함께 회신했다.

이슈 본문의 피해 서술("문법 오류 하나로 모든 호출이 막힌다")도 과장이었다.
Claude Code 에서 PreToolUse 를 차단하는 코드는 exit 2 뿐이고 exit 1 은
non-blocking 이다. 실제 차단 경로는 impl 부재 하나이며, 이 커밋이 닫는 것도
그것이다.

Closes #1053

Confidence: high
Not-tested: codex / cursor / opencode 호스트의 종료코드 규약은 미확인 — Claude
  Code 문서 1개 표면만 확인했다. 실세션에서 impl 을 지운 상태의 훅 동작은
  미검증이며, 런처를 스크래치 트리에 복제한 스텁 실행으로만 확인했다.
Constraint: 비0 일괄 정규화는 deny(exit 2) 를 삼켜 기각
@devseunggwan devseunggwan self-assigned this Aug 22, 2026
@coderabbitai

coderabbitai Bot commented Aug 22, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 9e7759a1-923b-4ed7-80aa-1a2e6bfbbb78

📥 Commits

Reviewing files that changed from the base of the PR and between 53edd02 and a53359c.

📒 Files selected for processing (52)
  • DESIGN.md
  • hooks/_dispatch.sh
  • hooks/advisory-wrapper-signature-verify.sh
  • hooks/anchor-comment-gate.sh
  • hooks/approval-premise-reread-gate.sh
  • hooks/artifact-verdict-evidence-gate.sh
  • hooks/askuserquestion-loop-signal.sh
  • hooks/block-ask-end-option.sh
  • hooks/block-manufactured-action-menu.sh
  • hooks/block-personal-asset-leak.sh
  • hooks/builtin-task-postuse.sh
  • hooks/bulk-write-memory-checkpoint.sh
  • hooks/bypass-telemetry.sh
  • hooks/caller-probe-gate.sh
  • hooks/codex-review-route.sh
  • hooks/completion-signal-gate.sh
  • hooks/completion-verify.sh
  • hooks/exclusion-probe-gate.sh
  • hooks/external-api-literal-trigger.sh
  • hooks/external-write-falsify-check.sh
  • hooks/memory-hint.sh
  • hooks/menu-mutation-tier-advisory.sh
  • hooks/merge-menu-review-options-advisory.sh
  • hooks/merge-state-claim-gate.sh
  • hooks/negative-existence-verdict-gate.sh
  • hooks/output-block-falsify-advisory.sh
  • hooks/path-probe-gate.sh
  • hooks/postcompact-context.sh
  • hooks/pr-claim-mutation-gate.sh
  • hooks/pr-report-destination-gate.sh
  • hooks/pr-state-refetch-gate.sh
  • hooks/pr-thread-resolve-advisory.sh
  • hooks/pre-edit-md-escape-advisory-post.sh
  • hooks/pre-edit-md-escape-advisory-pre.sh
  • hooks/pre-edit-protected-branch-guard.sh
  • hooks/pre-output-falsification-gate.sh
  • hooks/proposal-premise-gate.sh
  • hooks/protected-paths-guard.sh
  • hooks/push-remote-ref-verify.sh
  • hooks/readonly-verify-deferral-gate.sh
  • hooks/retrospect-active-marker.sh
  • hooks/retrospect-mix-check.sh
  • hooks/runtime-state-claim-gate.sh
  • hooks/second-failure-advisory.sh
  • hooks/secret-print-redaction-advisory.sh
  • hooks/session-intent.sh
  • hooks/source-citation-probe-gate.sh
  • hooks/strike-counter.sh
  • hooks/worktree-edit-gate.sh
  • hooks/write-decision-consistency-gate.sh
  • scripts/build-plugin-manifests.py
  • tests/test_launcher_fail_open.sh

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

Launchers now check for their implementation files before execution. Missing implementations return exit code 0. Existing implementations still receive their arguments and preserve deliberate exit codes. Templates, generated hooks, documentation, and regression tests were updated.

Changes

Launcher fail-open behavior

Layer / File(s) Summary
Launcher template guards
scripts/build-plugin-manifests.py
Python, shell, and dispatch wrapper templates now skip missing implementations with exit code 0 before execution.
Generated hook guards
hooks/*.sh
Generated launchers now resolve implementation paths, check file existence, and preserve execution arguments and nonzero implementation statuses.
Fail-open validation and contract
tests/test_launcher_fail_open.sh, DESIGN.md
Added coverage for missing implementations, forwarded exit codes, successful exits, and Python failures. Documented the launcher behavior.

Estimated code review effort: 2 (Simple) | ~15 minutes

Merge Risk: ⚪ Minimal · up to a5335

This change makes missing hook implementations fall through instead of incorrectly blocking, with the reported manifest and launcher checks passing; no actionable merge-blocking risk remains beyond normal review.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the primary change: launchers now fall through when their implementation is absent.
Linked Issues check ✅ Passed The changes satisfy issue #1053 by updating both templates, regenerating launchers, preserving exec and intentional exit codes, and adding regression coverage.
Out of Scope Changes check ✅ Passed All changes support fail-open launcher behavior, generated-file synchronization, documentation, or launcher-level regression coverage.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 50 files. (2 skipped: 1 unsupported, 1 over the file limit.)
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch issue-1053-fix-launcher-fail-open

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@devseunggwan
devseunggwan merged commit 96436fb into main Aug 22, 2026
10 checks passed
@devseunggwan
devseunggwan deleted the issue-1053-fix-launcher-fail-open branch August 22, 2026 09:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(hooks): launcher is not fail-open when the impl cannot start

1 participant