Repository navigation
fix(pre-commit): scope ty hook to staged files - #61
Conversation
The local ty hook ran `ty check .` with pass_filenames: false, so any commit staging a Python file type-checked the whole repository and failed on pre-existing errors in other experiments (currently 0008 and 0024). Drop the `.` target and the pass_filenames override so pre-commit passes only the staged Python files to ty. AGENTS.md recommended `pre-commit run --all-files`, which runs ruff, ruff-format, ty and bandit across every experiment and rewrites or flags code outside the contributor's change. Point contributors at `pre-commit run --files <paths>` instead and explain why --all-files should be avoided when preparing a change. Cleaning up the pre-existing ty, ruff-format and bandit findings is left out of scope, as it touches other experiments. Note: `pre-commit run` could not fetch remote hook repos in the sandbox (TLS verification failure). The pre-commit-hooks checks were run directly at rev v6.0.0 and passed; gitleaks was covered by scan-secrets. The ty hook was exercised via pre-commit with a ty-only config: it fails on a staged file with a type error, reports only that file, passes on clean files, and is skipped for Markdown-only changes. Closes #60 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
🤖 Finished Review · ✅ Success · Started 6:24 AM UTC · Completed 6:32 AM UTC Commit: Runtime: claude · Model: opus → claude-opus-5-5 · Effort: high · Cost: $2.72 |
|
Risk Assessment: moderate (2/5) DetailsSmall 7-line, 2-file bot-authored config/docs change with low churn and a well-scoped linked issue; moderate only because both changed files are protected paths. Previous runRisk Assessment: low (1/5) DetailsTiny 7-line config-only fix by a bot addressing a well-scoped issue; the only elevated signal is PROTECTED_PATH_COUNT=2 (touching AGENTS.md and .pre-commit-config.yaml), which is offset by minimal churn, no security or dependency concerns, stable file history, and complete acceptance-criteria coverage. |
ReviewFindingsMedium / Low / Info
Previous runReviewFindingsMedium / Low / Info
Next steps:
|
|
🤖 Finished Fix · ✅ Success · Started 6:33 AM UTC · Completed 6:37 AM UTC Commit: Runtime: claude · Model: opus → claude-opus-5-5 · Effort: high · Cost: $0.61 |
Address review feedback on PR #61: the AGENTS.md warning against `pre-commit run --all-files` listed only ruff, ruff-format, ty and bandit. end-of-file-fixer, trailing-whitespace and mixed-line-ending also run without file filters and rewrite files in other experiments. Reword to say every hook runs, naming the file-rewriting hooks as examples. Not changed: the protected-path finding is the merge gate requiring human approval and does not call for a content edit. Verification: `pre-commit run` could not fetch remote hook repos in the sandbox (TLS verification failure). The applicable hooks were replicated directly on AGENTS.md (trailing whitespace, EOF newline, mixed line endings, merge-conflict markers, private keys, file size) and passed; hack/lint-experiment-* scripts passed; gitleaks scan passed. Addresses #61 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🔧 Fix agent — iteration 1 (bot-triggered)Addressed the technical-accuracy finding: the AGENTS.md --all-files warning now says every hook runs repo-wide and names the hooks that rewrite files. The protected-path finding needs human approval and has no edit to make. No merge conflict was found. The project CI checks (Build Doc Site, DCO) pass. pre-commit could not fetch remote hook repos in the sandbox, so the hooks that apply to AGENTS.md were reproduced by hand and passed, along with the repo lint scripts and the secret scan. Fixed (2):
Disagreed (1):
Tests: passed CI inspections (2):
Conflict update: skipped; strategy Decision points
Next steps:
|
|
🤖 Finished Review · ✅ Success · Started 6:39 AM UTC · Completed 6:48 AM UTC Commit: Runtime: claude · Model: opus → claude-opus-5-5 · Effort: high · Cost: $3.31 |
Superseded by updated review
| - id: ty | ||
| name: ty check | ||
| entry: uvx ty check . --ignore unresolved-import --ignore unresolved-attribute | ||
| entry: uvx ty check --ignore unresolved-import --ignore unresolved-attribute |
There was a problem hiding this comment.
[medium] protected-path
This PR modifies protected paths: .pre-commit-config.yaml and AGENTS.md (both listed in REVIEW_PROTECTED_PATHS). The change is justified: it closes #60, the issue's triage recommends exactly these two edits, and the PR description explains why. Human approval is still always required for protected-path changes, whatever the justification.
Suggested fix: A maintainer with write access should review and approve the protected-path changes.
| - id: ty | ||
| name: ty check | ||
| entry: uvx ty check . --ignore unresolved-import --ignore unresolved-attribute | ||
| entry: uvx ty check --ignore unresolved-import --ignore unresolved-attribute |
There was a problem hiding this comment.
[low] edge-case
ty now type-checks only the staged Python files it is given. A staged change can break other, unstaged files, for example by changing a function signature or removing a symbol imported elsewhere in the same experiment. Those files are not checked, so the commit passes. No CI workflow runs ty or pre-commit to catch it later. Issue #60 asked for this trade-off, so it is not a defect, but contributors may not expect it.
Suggested fix: Optional: note in AGENTS.md that ty only checks the files passed to it, so contributors should include dependent files from their experiment (e.g. pre-commit run --files <experiment-dir>/**/*.py). Alternatively, add a CI job that runs ty on each changed experiment directory.
jwm4
left a comment
There was a problem hiding this comment.
I filed #60 and tested this branch (1db22ec) locally.
With the config on main, staging a one-line change to 0017-reasoning-monitor/monitor/__init__.py fails the ty hook on pre-existing errors in 0008-guardrails-eval/eval-model-armor.py, which the change does not touch. With this branch, the same change passes ty and every other hook, and no other file is modified. Staging a change to 0024-codeowners-app-matrix/run_matrix.py, which has its own ty errors, still fails as it should.
On the low-severity finding that ty now checks only staged files: I accept that trade-off. Experiments are largely independent of each other, and the scoping is what #60 asked for.
This fixes the problem from the reporter's side. It still needs a maintainer's approval for the protected-path change.
Comment from Bill Murdock with assistance from Claude Code.
waynesun09
left a comment
There was a problem hiding this comment.
Approving, including the protected-path change. I tested the hook with ty 0.0.89 and pre-commit 4.7.0: staged-only checking works, and --all-files still reports the same diagnostics as ty check ..
|
🤖 Finished Retro · ✅ Success · Started 6:58 PM UTC · Completed 7:12 PM UTC Commit: Runtime: claude · Model: opus → claude-opus-5-5 · Effort: high · Cost: $2.48 |
Retro: PR #61 (scope pre-commit
|
Summary
Makes pre-commit check only the files in a change, so contributors who touch one experiment get a passing run and a PR containing only their files.
.pre-commit-config.yaml: the localtyhook ranuvx ty check .withpass_filenames: false, so any commit that staged a Python file type-checked the entire repo and failed on pre-existing errors in other experiments. Removed the.target and thepass_filenames: falseoverride, so pre-commit now passes only the staged Python files toty.types: [python]is unchanged.AGENTS.md: replaced thepre-commit run --all-filesrecommendation withpre-commit run --files <paths>, and noted that--all-filesrunsruff,ruff-format,tyandbanditacross every experiment and rewrites or flags code outside your change.Testing
mainwith ty 0.0.87:ty check . --ignore unresolved-import --ignore unresolved-attributereports 8 diagnostics, all in0008-guardrails-eval/eval-model-armor.pyand0024-codeowners-app-matrix/run_matrix.py.tyhook throughpre-commit run -c <ty-only config> --files ...:0026-eval-statistical-significance/significance.py+ Markdown → passestyskippedty:0025-.../.fullsend/scripts/post-emit-cost.py, in a hidden directory, is checked when passed as a path, and passes.pre-commit runcould not fetch remote hook repos in the sandbox (TLS verification failure). Thepre-commit-hooksv6.0.0 checks (check-yaml, end-of-file-fixer, trailing-whitespace, detect-private-key, large files, merge conflict, mixed line endings) were run directly on the changed files and passed. Secrets were scanned with gitleaks viascan-secrets.Notes
tyerrors (e.g.0024-.../run_matrix.py), the hook still flags them. That is expected, since the file is part of the change.ty,ruff-formatandbanditfindings so that--all-filespasses again. It touches other people's experiments, so it is better as a separate change.🤖 Generated with Claude Code
Closes #60
Post-script verification
agent/60-scope-precommit-hooks)3f1614fa8adcf731c6d415b9e0af8b4a2556e9ed..HEAD)