Section 4: a fail hook refuses a path that begins with a dash (issue #2347) #2353
<!-- codex-pull-request-review-summary -->
<!-- codex-review-state:v1 {"code_review":{"commit_sha":"57c0166cb49ca686fd514b84e459229c684bd0dd","has_any_findings":false,"has_unresolved_findings":false,"status":"completed"},"security_review":{"commit_sha":"57c0166cb49ca686fd514b84e459229c684bd0dd","has_any_findings":null,"has_unresolved_findings":null,"status":"completed"}} -->
<!-- codex-security-review:v1 {"blockingSeverityThreshold":"P0","headSha":"57c0166cb49ca686fd514b84e459229c684bd0dd","mergeGateEnabled":false,"pullRequestNumber":2353,"repository":"btclib-org/.github","status":"completed"} -->
<details>
<summary><strong>Codex Review Summary</strong>: ✅ Completed</summary>
This comment shows the latest Codex review activity on this pull request.
| Review | Status | Commit | Review trigger |
| --- | --- | --- | --- |
| 📝 Code Review | ✅ Completed <relative-time datetime="2026-11-17T00:35:34.264640Z">2026-11-17T00:35:34.264640Z</relative-time> | 57c0166 | New commits |
| 🔒 Security Review | ✅ Completed <relative-time datetime="2026-11-17T00:36:51.930210Z">2026-11-17T00:36:51.930210Z</relative-time> | 57c0166 | New commits |
<details> <summary>ℹ️ About Codex in GitHub</summary>
<br/>
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
</details>
</details>
<!-- coderabbit-ai-generated:v1 -->
<!-- This is an auto-generated comment: summarize by coderabbit.ai -->
<!-- review_stack_entry_start -->
<a href="https://app.coderabbit.ai/change-stack/btclib-org/.github/pull/2353?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&cs_source=review_comment"><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-buttons-v1/explain-change-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-buttons-v1/explain-change.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-buttons-v1/explain-change.svg" alt="Explain Change →" height="32"></picture></a>
<!-- review_stack_entry_end -->
<!-- recent_review_status_start -->
No actionable comments were generated in the recent review.
<!-- recent_review_status_end -->
<!-- walkthrough_start -->
<details>
<summary><strong>Summary</strong></summary>
<dl>
<dd>
<br>
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
Summary by CodeRabbit
New Features
Added a repository check that rejects paths beginning with a dash, including symlink paths.
Documentation
Documented the check and its required coverage.
Tests
Added automated checks for missing or altered configurations and settings that narrow the check’s coverage.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
The change adds a local pre-commit hook that rejects paths beginning with -. It documents the hook and adds checks that repositories include its expected configuration without settings that narrow its coverage.
Changes: Leading-dash path guard
|Layer / File(s)|Summary|
|:---|:---|
|Define and document the path guard <br> .pre-commit-config.yaml, README.md|The local hook rejects paths matching ^-. The README describes its scope, configuration requirements, and why pre-commit filename passing can expose leading-dash paths to hooks as options.|
|Check hook coverage across repositories <br> tests/hooks_test.py, tests/__init__.py|Tests detect a missing or altered hook stanza and top-level settings that narrow its coverage. The backlog adds issue 2347.|
<!-- change_assessment_start -->
Estimated code review effort: 2 (Simple) | ~10 minutes
<!-- change_assessment_commit:"3b6f6f541cfb8df8fa54641fd3d6ebfb371b5756" -->
<!-- change_assessment_priority:{"version":1,"urgency":"p3","manual":false} -->
Change: Bug fix · Severity of issue fixed: Low
<!-- change_assessment_end -->
Possibly related issues
</dd>
</dl>
</details>
<!-- walkthrough_end -->
<details>
<summary><strong>Merge Risk:</strong> <strong><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/risk-unassessed-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Minimal</strong> · up to <code>3b6f6</code></summary>
<dl>
<dd>
<br>
<!-- final_review_risk_start -->
<!-- final_review_risk_label
Merge Risk: ⚪ Minimal · up to 3b6f6
-->
<!-- final_review_risk_coverage:{"sourceCommitId":"3b6f6f541cfb8df8fa54641fd3d6ebfb371b5756","coveredCommitId":"3b6f6f541cfb8df8fa54641fd3d6ebfb371b5756","kind":"reviewed"} -->
The change adds a pre-commit hook that rejects paths beginning with a dash, plus documentation and checks for it. It affects repository tooling only, and no concrete merge-blocking risk was found.
<!-- final_review_risk_end -->
</dd>
</dl>
</details>
<!-- pre_merge_checks_walkthrough_start -->
<details>
<summary><strong>Pre-merge checks: <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> 4</strong></summary>
<dl>
<dd>
<br>
| Check name | Status | Explanation |
| :------------------------ | :--------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Title check | !Passed | The title names a fail hook that refuses dash-leading paths and cites issue #2347, which matches the main change (the leading-dash-path hook). It does not state the section 4 requirement, so the check… |
| Linked Issues check | !Passed | Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check | !Passed | Check skipped because no linked issues were found for this pull request. |
| Description check | !Passed | The description is specific and on-topic. It explains the bug (pre-commit passes file names without --, so a tracked file named -h silences argparse-based hooks such as pygrep). It describes the n… |
<details>
<summary><strong>Full details: Title check</strong></summary>
<dl>
<dd>
<br>
Explanation
The title names a fail hook that refuses dash-leading paths and cites issue #2347, which matches the main change (the leading-dash-path hook). It does not state the section 4 requirement, so the check against the organization's title standard cannot be fully confirmed from the supplied text. The title is specific and on topic, so it passes on relevance.
</dd>
</dl>
</details>
<details>
<summary><strong>Full details: Description check</strong></summary>
<dl>
<dd>
<br>
Explanation
The description is specific and on-topic. It explains the bug (pre-commit passes file names without --, so a tracked file named -h silences argparse-based hooks such as pygrep). It describes the new leading-dash-path hook (language: fail, files: ^-, types: []), the DASH_STANZA test, the BACKLOG row, and the reported verification runs. It relates directly to the changeset, so the check passes.
</dd>
</dl>
</details>
</dd>
</dl>
</details>
<!-- pre_merge_checks_walkthrough_end -->
<!-- finishing_touch_checkbox_start -->
<details>
<summary><strong>Finishing Touches</strong></summary>
<dl>
<dd>
<br>
<details open>
<summary><strong>Generate unit tests (beta)</strong></summary>
<dl>
<dd>
<br>
</dd>
</dl>
</details>
</dd>
</dl>
</details>
<!-- finishing_touch_checkbox_end -->
<!-- autopilot:start -->
<!-- autopilot:end -->
<!-- tips_start -->
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.
<details>
<summary><strong>Share</strong></summary>
<dl>
<dd>
<br>
</dd>
</dl>
</details>
<!-- tips_end -->
<!-- recent_review_start -->
<h6>
<details>
<summary><strong><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/info.svg" width="12" height="12" align="absmiddle" alt=""></picture> Recent review info</strong></summary>
<dl>
<dd>
<br>
<!-- review_info_content -->
<details>
<summary><strong><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog.svg" width="16" height="16" align="absmiddle" alt=""></picture> Run configuration</strong></summary>
<dl>
<dd>
<br>
2c36c246-d0fb-41fa-8e19-c57b46660676</dd>
</dl>
</details>
<details>
<summary><strong><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal.svg" width="16" height="16" align="absmiddle" alt=""></picture> Commits</strong></summary>
<dl>
<dd>
<br>
Reviewing files that changed from the base of the PR and between bfa5cb36a9d331afb44cc50824832429e9732eb2 and 3b6f6f541cfb8df8fa54641fd3d6ebfb371b5756.
</dd>
</dl>
</details>
<details>
<summary><strong><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner.svg" width="16" height="16" align="absmiddle" alt=""></picture> Files selected for processing: 4</strong></summary>
<dl>
<dd>
<br>
.pre-commit-config.yaml
README.md
tests/__init__.py
tests/hooks_test.py
</dd>
</dl>
</details>
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
</dd>
</dl>
</details>
</h6>
<!-- recent_review_end -->
Findings on 57c0166: 1 open, non-blocking.
| Round | Head | Reviewer | Verdict |
| --- | --- | --- | --- |
| 1 | e4e7b25 | dedicated reviewer | CLEARED |
| 2 | e4e7b25 | fresh reviewer (Codex) | CHANGES REQUESTED |
| 3 | 3b6f6f5 | fresh reviewer (Codex) | CLEARED |
| 4 (forge 1) | 3b6f6f5 | review bot | CHANGES REQUESTED |
| 5 | 57c0166 | dedicated reviewer | CLEARED |
| 6 | 57c0166 | fresh reviewer (Codex) | CLEARED |
| # | Raised by | On | Where | Outcome | Checked on |
| --- | --- | --- | --- | --- | --- |
| 1 | fresh reviewer (Codex) | e4e7b25 | .pre-commit-config.yaml:47, tests/hooks_test.py:1248 | accepted, 3b6f6f5 | 57c0166 |
| 2 | dedicated reviewer | e4e7b25 | .pre-commit-config.yaml:27 | declined: prose already false at the base, not made worse | 57c0166 |
| 3 | dedicated reviewer | e4e7b25 | tests/hooks_test.py:1300 | declined: nit, follows the landed bare-sourcery-skip precedent | 57c0166 |
| 4 | dedicated reviewer | e4e7b25 | tests/hooks_test.py:1254 | declined: taste, correct as written | 57c0166 |
| 5 | review bot | 3b6f6f5 | README.md:1125 | accepted, 57c0166 | 57c0166 |
| 6 | review bot | 3b6f6f5 | tests/hooks_test.py:1252 | declined: taste, as finding 4 | 57c0166 |
| 7 | dedicated reviewer | 57c0166 | README.md:1141 | open, non-blocking: fixed with the next change | 57c0166 |
<details><summary>1. The reason for the hook was restated outside section 4's bullet.</summary>
Class: a rule stated a second time.
.pre-commit-config.yaml from line 47 at e4e7b25:
# a path that begins with a dash reaches a hook's command line as an
# option, so a file named `-h` silences an argparse hook. Section 4's
Accepted: the comment and the DASH_STANZA docstring point to section 4's bullet, which gains the one condition only the docstring stated (an exclude:, a stages: or a narrower types: takes paths out of reach), in 3b6f6f5.
</details>
<details><summary>2. The config comment calls the meta hooks the only hooks with no environment to install.</summary>
Class: a false sentence older than the branch.
.pre-commit-config.yaml from line 27 at dd936a3:
# this file checking itself, and the only two hooks with no environment
# to install: a pattern that has stopped matching is a rule that has
Declined: false at the base already (pre-commit 4.7.0's pygrep declares no install), and the branch does not make it materially worse; prose is not filed.
</details>
<details><summary>3. test_this_trees_leading_dash_path_is_section_4s repeats the .github cell of the per-repository test.</summary>
Class: a redundant test.
tests/hooks_test.py from line 1300 at e4e7b25:
def test_this_trees_leading_dash_path_is_section_4s() -> None:
Declined: the landed test_this_trees_bare_sourcery_skip_is_section_4s is the same pattern.
</details>
<details><summary>4. DASH_REACHING writes out names it could derive from TOP_LEVEL.</summary>
Class: taste.
tests/hooks_test.py from line 1254 at e4e7b25:
DASH_REACHING = ("files", "exclude", "default_stages")
Declined: correct as written.
</details>
<details><summary>5. The bullet did not say why each tree carries a local stanza instead of a served hook.</summary>
Class: a setting with no alternative beside it (README's How to use this file).
The review bot's thread on README.md line 1125 at 3b6f6f5, on the bullet's first line:
- **`leading-dash-path`** — a `fail` hook refusing a path that begins
Accepted: the bullet names the served hook as an alternative set aside, and why (a tag and a rev: move before a tree runs it), in 57c0166.
</details>
<details><summary>7. "them all" in the -- clause has no plural noun to refer to.</summary>
Class: wording.
README.md line 1141 at 57c0166: "lost again by a stanza that forgets it, where this hook guards them all".
Open, non-blocking: fixed with the next change to the branch.
</details>
<!-- btclib-findings-record -->
blocking: the bullet does not say why each tree carries a local stanza instead of a hook served from this repository's .pre-commit-hooks.yaml.
check-changelog is a few lines below, and this repository serves it that way. local-link-prefix explains why it is local: a served language: python hook makes pre-commit pip-install a repository that builds no distribution. That reason does not hold for a fail hook, which installs nothing. So a reader comparing the two bullets has nothing in the README that answers "why not serve it?"
The PR body has the answer, under Decision: a served hook waits for a tag and a rev: move in each tree. But the body does not land. REVIEWING.md's last section asks for the rule to come with the reason that chose it, the rejected alternative included, and the standard's How to use this file asks for that argument beside the rule. The -- alternative already gets a paragraph here. The served-hook alternative needs one too, or the maintainer's answer to the body's Decision.
non-blocking: this tuple copies three of TOP_LEVEL's four keys. The docstring then states how the two relate ("TOP_LEVEL less default_language_version"), and nothing checks that. If a key is added to TOP_LEVEL, this copy will not follow, and the docstring will go wrong without anyone noticing. Deriving it, for example tuple(key for key in TOP_LEVEL if key != "default_language_version"), keeps one list and makes the docstring true by construction.
CHANGES REQUESTED 3b6f6f541cfb8df8fa54641fd3d6ebfb371b5756
README.md:1125: the leading-dash-path bullet does not say why each tree carries a local stanza instead of a hook served from .pre-commit-hooks.yaml. check-changelog is served that way, a few lines below. local-link-prefix's reason for staying local (pip installs the serving repository) does not apply to a fail hook. The reason exists only in the PR body's Decision, which does not land. REVIEWING.md's last section, and the standard's How to use this file, ask for the rejected alternative beside the rule.tests/hooks_test.py:1252: DASH_REACHING copies three of TOP_LEVEL's keys, and its docstring states how the two relate, which nothing checks. Deriving it from TOP_LEVEL keeps one list.Not checked: the scratch-repository pre-commit run measurement in the PR body, and the new tests, were not run (no interpreter). The new files: ^- pattern matches no tracked path here (git ls-files | grep -c '^-' prints 0). The backlog row was tried against btclib's gate: it has no leading-dash-path.
Fixed in 57c0166: the bullet now names the hook served from .pre-commit-hooks.yaml as an alternative set aside, in one clause beside the -- one.
A served hook reaches a tree only once this repository tags and the tree's rev: moves to that tag, which section 4 already requires to be a frozen tag. btclib's gate pins check-changelog at f88870c9… # frozen: v2026.11.14, the newest tag here. A local stanza needs neither. The bullet pays for the sentence by cutting a clause from its opening sentence, so README grows by the stanza's bullet alone.
Declined as taste: the tuple is correct as written, and the docstring says why it leaves out default_language_version, which a derived tuple would have to say as well.
Both local reviewers read it and found it correct; deriving it is one of two defensible spellings, so the author's stands.
ACK 57c0166cb49ca686fd514b84e459229c684bd0dd
The blocking finding from 3b6f6f5 is closed: the leading-dash-path bullet now names the served hook it sets aside, with the reason (a tag, then a rev: move in each tree), beside the rule. The non-blocking point on DASH_REACHING was declined as taste, and it stays with the author.
Not checked: the scratch-repository pre-commit run --all-files and --from-ref/--to-ref measurement in the PR body, and the new integration tests under BTCLIB_INTEGRATION=1, were not run (no interpreter).
fametrano
A tracked file named
-hsilences an argparse hook, pygrep among them, under every pre-commit run: pre-commit passes file names with no--before them, so the hook prints its help and exits 0 with the files beside it unread. This adds section 4'sleading-dash-path, alanguage: failhook withfiles: ^-andtypes: [], which refuses such a path and cannot be silenced by it, since it parses no argument.The stanza is held whole by
DASH_STANZAintests/hooks_test.py, and a BACKLOG row excuses the other trees until their ports land, so the issue stays open: Advances #2347. Upstream declined to change how it passes file names in pre-commit/pre-commit#2896.Evidence
uv.lockpins), one pygrep hook refusing a tab, a commit adding-hand a file holding a tab. Without the stanza,pre-commit run --all-filesandpre-commit run --from-ref HEAD~1 --to-ref HEADboth printPassedand exit 0. With it,leading-dash-pathfails naming-h, and both runs exit 1.-,--, a name holding a newline after-, and a symlink-lare refused;dir/-h,a<newline>-hand-xreach no hook as an option and are not. Withouttypes: []the symlink is not reached.check-hooks-applypasses over thefailhook; the same stanza as pygrep is reported as not applying, and a pygrep copy of the hook is silenced by-h.uv run --locked --only-group lint pre-commit run --all-filesexit 0; the same withmarkdownlint-cli2exit 0;pre-commit validate-config .pre-commit-config.yamlexit 0;uv run --locked --no-default-groups --group test pytestexit 0. The new tests are integration-only, run by hand withBTCLIB_INTEGRATION=1across every tree on the first head:.githubpasses, each other tree is a strict expected failure citing the issue.c1786962edc1~1..c1786962edc1, exit 1.CLEAREDon the first head. Fresh reviewer in Codex: changes requested on the first head (the reason for the hook restated outside section 4), thenCLEAREDon the next head after a prose-only fix. The review bot then asked for the served-hook alternative beside the rule; the fix, a new commit, was cleared by both local reviewers before its push. No rebase: the branch merges clean withmain.ACK 57c0166cb49ca686fd514b84e459229c684bd0dd. Codex: no findings. CodeRabbit: absent on this head, its check skipped with no reason posted (its free reviews were reported used up on PR btclib-org/.github#2354 the same hour); on 3b6f6f5 it posted no actionable comments.Decision
The issue reserved none; the design pass put one for the maintainer. Should section 4 require this hook in every tree, and in which shape? The branch takes a local
failstanza held whole by a test, which needs no tag and lets the BACKLOG row track the ports. The alternatives set aside: serving the hook from.pre-commit-hooks.yaml, which waits for a tag and arev:move in each tree; this tree only, which section 14 makes a defect; and--in every hook, which a forgotten stanza undoes. The cut-back is no check, only the upstream link, which leaves the measurement exiting 0.🤖 Generated with Claude Code