Repository navigation
fix(hooks): disqualify a title quoted both ways - #1069
Conversation
같은 텍스트가 한 명령 안에서 작은따옴표와 큰따옴표로 모두 등장하면, 토큰 스트림에는 제목이 어느 쪽에서 왔는지 말해주는 것이 없다. 값 대조만으로는 앞 세그먼트의 작은따옴표 구간이 제목을 리터럴로 만들어 버려서, 셸이 실제로 확장하는 제목을 format·length 게이트가 채점했다. 정상 커밋이 막히는 경로다. `_single_quoted_runs` 를 `_quoted_runs` 로 넓혀 큰따옴표 구간도 수집하고, 제목이 양쪽 모두에 나타나면 리터럴 판정을 무효화한다. `safe_tokenize` 와 `iter_command_starts` 는 건드리지 않으므로 84개 소비자는 정의상 무영향이다. 이슈가 제안한 source span 확장 대신 값 무효화를 택했다. span 은 두 방향을 모두 정확히 가르지만 공용 토크나이저의 반환 형태를 바꾼다. 값 무효화는 거울 케이스(`git commit -m '$(x)' && echo "$(x)"`, 제목이 진짜 리터럴인데 침묵)를 새로 만든다 — 방향이 오차단이 아니라 침묵이라 게이트의 fail-open 자세와 맞고, 잔여는 테스트로 고정했다. Confidence: high Not-tested: 실제 Claude Code 세션에서의 게이트 발화는 미검증 — 합성 입력 기반 단위 테스트로만 확인 Constraint: source span 방식은 공용 토크나이저 반환 형태 변경을 요구해 기각
|
Warning Review limit reached
Next review available in: 42 minutes Limit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?Wait for the limit to reset, then comment An organization admin can change what happens after included review limits in Billing. How do review limits work?CodeRabbit enforces per-developer PR review limits within each organization. For paid Pro and Pro+ reviews, CodeRabbit uses a developer's included PR review attempts over the past 7 days to set the current hourly allowance. At typical activity levels, the full plan allowance applies. Higher sustained activity can lower the allowance until earlier attempts leave the 7-day window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
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. Comment |
`_quoted_runs` scanned the whole raw command, including a trailing comment and a heredoc body — regions the shell never executes. A double-quoted run living in either one disqualified a genuine single-quoted literal title by value, silencing the format/length gates on a title they should have graded. Blank heredoc bodies via the shared `strip_heredoc_bodies` (same pass `safe_tokenize` uses) and skip unquoted `#…` comments using the shared `_starts_unquoted_comment` boundary rule, extended with an explicit newline check since this scanner walks the whole multi-line command rather than one line at a time. The documented residual (a double-quoted run in a sibling EXECUTED segment, e.g. `'$(x)' && echo "$(x)"`) is unaffected — closing that needs source spans this PR does not add, and a pinning test confirms it still stays silent. Confidence: high Not-tested: hook-level PreToolUse integration (only the module's own unit/shell suites ran; no live Bash-tool commit was fired through the actual hooks)
무엇이 바뀌나
셸이 실제로 확장하는 커밋 제목을 리터럴로 오판해 format·length 게이트가 채점하던 것을 막습니다. 이 PR 이후 그런 제목에서는 두 게이트가 침묵하고, 정상 커밋이 막히지 않습니다.
원인
_title_is_single_quoted_literal(command, title)은 제목 토큰이 어떤 작은따옴표 구간의 내용과 같은 값인가로 판정합니다. 값 대조라 세그먼트 경계를 볼 수 없습니다.제목
$(x)는 런타임에 셸이 확장하므로 훅 시점에 값을 알 수 없어야 하는데, 앞 세그먼트의'$(x)'때문에 리터럴로 판정됐습니다. 방향이 채점 쪽이라 게이트가 침묵이 아니라 발화하고, 그래서 정상 커밋이 차단됩니다.이 결함의 앞선 판본(
_opener_is_quoted_literal이 명령 전체를 훑던 것)은 #987 / PR #1014 에서 값 대조로 좁혔고, 이 PR 은 그 잔여를 닫습니다.어떻게 고쳤나 — 이슈 제안과 다른 접근
이슈는
iter_command_starts가 소스 span 을 함께 내도록 additive 확장하자고 했습니다. 대신_single_quoted_runs를_quoted_runs로 넓혀 큰따옴표 구간도 수집하고, 제목이 양쪽 모두에 나타나면 리터럴 판정을 무효화합니다.safe_tokenize와iter_command_starts를 아예 건드리지 않으므로, 이슈가 "반환 형태를 추가만 하니 무영향" 이라고 논증해야 했던 소비자들은 정의상 무영향입니다.(이슈 본문은 그 소비자를 84개로 적었는데 제 측정과 맞지 않습니다 —
grep -rl safe_tokenize기준으로--include='*.py'52개,hooks/이하 86개, 리포 전체 100개입니다. 어느 쪽이든 이 PR 은 그 파일들을 건드리지 않습니다.)대가 — 거울 케이스가 새로 침묵합니다
값 대조를 유지하는 대가를 실측했습니다.
3행에서 제목은 진짜 작은따옴표 리터럴인데 게이트가 채점하지 않습니다. 두 방향을 정확히 가르려면 토크나이저가 버리는 소스 span 이 필요합니다. 방향이 오차단이 아니라 침묵이고 그것이 이 리포가 게이트에 대해 택한 fail-open 자세이므로, 잔여를 닫지 않고 테스트로 고정하고 docstring 에 명시했습니다.
검증
양성 대조군이 포함돼 있습니다 — 제목이 진짜 작은따옴표 리터럴인 경우는 수정 전후 모두 채점됩니다. 이것이 없으면 "전부 리터럴 아님으로 읽는" 회귀와 구분되지 않습니다.
Pre-commit verified:
python3 -m pytest tests/test_git_commit_titles.py -q→ 47 passed,bash tests/test_hook_utils.sh→ PASS 102 / FAIL 0,python3 scripts/check-plugin-manifests.py→plugin-manifest check OKCaller chain verified:
_title_is_single_quoted_literal과_quoted_runs는git_commit_titles.py모듈 내부 심볼이고, 공개 진입점extract_git_titles의 소비자는hooks/preflight-gate/commit-title-format-check/impl.py와commit-title-length-check/impl.py2곳뿐입니다. 두 곳 모두 시그니처 변경이 없습니다.safe_tokenize/iter_command_starts는 미변경이라 그 소비자 전체가 무접촉입니다 (grep -rl safe_tokenize: .py 52 / hooks/ 86 / 전체 100).Closes #1036