codedoctor 0.1.2__tar.gz → 0.1.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) hide show
  1. {codedoctor-0.1.2 → codedoctor-0.1.4}/.gitignore +0 -3
  2. {codedoctor-0.1.2 → codedoctor-0.1.4}/.pre-commit-config.yaml +384 -30
  3. codedoctor-0.1.4/.python-version +1 -0
  4. codedoctor-0.1.4/CHANGELOG.md +44 -0
  5. codedoctor-0.1.4/PKG-INFO +224 -0
  6. codedoctor-0.1.4/README.md +156 -0
  7. codedoctor-0.1.4/codedoctor/__main__.py +17 -0
  8. {codedoctor-0.1.2 → codedoctor-0.1.4}/codedoctor/affected/__main__.py +1 -1
  9. {codedoctor-0.1.2 → codedoctor-0.1.4}/codedoctor/affected/affected.py +702 -407
  10. {codedoctor-0.1.2 → codedoctor-0.1.4}/codedoctor/affected/affected_test.py +1056 -99
  11. codedoctor-0.1.4/codedoctor/affected/backbone.py +492 -0
  12. codedoctor-0.1.4/codedoctor/affected/backbone_test.py +948 -0
  13. codedoctor-0.1.4/codedoctor/affected/codegraph_sync.py +337 -0
  14. codedoctor-0.1.4/codedoctor/affected/codegraph_sync_test.py +788 -0
  15. {codedoctor-0.1.2 → codedoctor-0.1.4}/codedoctor/assert_isinstance/__main__.py +1 -1
  16. {codedoctor-0.1.2 → codedoctor-0.1.4}/codedoctor/assert_isinstance/unnecessary_assert_isinstance.py +192 -115
  17. {codedoctor-0.1.2 → codedoctor-0.1.4}/codedoctor/assert_isinstance/unnecessary_assert_isinstance_test.py +985 -24
  18. codedoctor-0.1.4/codedoctor/cli.py +74 -0
  19. codedoctor-0.1.4/codedoctor/cli_test.py +193 -0
  20. codedoctor-0.1.4/codedoctor/codegraph.py +116 -0
  21. codedoctor-0.1.4/codedoctor/codegraph_test.py +224 -0
  22. codedoctor-0.1.4/codedoctor/coverage_floor/__init__.py +1 -0
  23. {codedoctor-0.1.2 → codedoctor-0.1.4}/codedoctor/coverage_floor/__main__.py +1 -1
  24. codedoctor-0.1.4/codedoctor/coverage_floor/coverage_floor.py +318 -0
  25. codedoctor-0.1.4/codedoctor/coverage_floor/coverage_floor_test.py +831 -0
  26. codedoctor-0.1.4/codedoctor/export_leaks/__init__.py +1 -0
  27. codedoctor-0.1.4/codedoctor/export_leaks/__main__.py +17 -0
  28. codedoctor-0.1.4/codedoctor/export_leaks/check_export_leaks.py +317 -0
  29. codedoctor-0.1.4/codedoctor/export_leaks/check_export_leaks_test.py +459 -0
  30. codedoctor-0.1.4/codedoctor/export_leaks/check_pr_text.py +131 -0
  31. codedoctor-0.1.4/codedoctor/export_leaks/check_pr_text_test.py +143 -0
  32. {codedoctor-0.1.2 → codedoctor-0.1.4}/codedoctor/gate/__main__.py +1 -1
  33. {codedoctor-0.1.2 → codedoctor-0.1.4}/codedoctor/gate/fakes.py +31 -7
  34. {codedoctor-0.1.2 → codedoctor-0.1.4}/codedoctor/gate/fakes_test.py +48 -6
  35. {codedoctor-0.1.2 → codedoctor-0.1.4}/codedoctor/gate/gate.py +232 -75
  36. codedoctor-0.1.4/codedoctor/gate/gate_test.py +745 -0
  37. {codedoctor-0.1.2 → codedoctor-0.1.4}/codedoctor/gate/spool_test.py +15 -1
  38. codedoctor-0.1.4/codedoctor/install.py +346 -0
  39. codedoctor-0.1.4/codedoctor/install_hooks.yaml +822 -0
  40. codedoctor-0.1.4/codedoctor/install_test.py +626 -0
  41. {codedoctor-0.1.2 → codedoctor-0.1.4}/codedoctor/lib/files/glob.py +52 -30
  42. {codedoctor-0.1.2 → codedoctor-0.1.4}/codedoctor/lib/files/glob_test.py +121 -5
  43. {codedoctor-0.1.2 → codedoctor-0.1.4}/codedoctor/lib/files/grep.py +302 -211
  44. {codedoctor-0.1.2 → codedoctor-0.1.4}/codedoctor/lib/files/grep_test.py +734 -188
  45. codedoctor-0.1.4/codedoctor/lib/files/owner_only.py +77 -0
  46. codedoctor-0.1.4/codedoctor/lib/files/owner_only_test.py +191 -0
  47. codedoctor-0.1.4/codedoctor/lib/files/source_version.py +61 -0
  48. codedoctor-0.1.4/codedoctor/lib/files/source_version_test.py +73 -0
  49. {codedoctor-0.1.2 → codedoctor-0.1.4}/codedoctor/lib/files/tempclaim_test.py +146 -1
  50. {codedoctor-0.1.2 → codedoctor-0.1.4}/codedoctor/lib/files/walk_test.py +33 -0
  51. {codedoctor-0.1.2 → codedoctor-0.1.4}/codedoctor/lib/pyproject_flags.py +9 -6
  52. {codedoctor-0.1.2 → codedoctor-0.1.4}/codedoctor/lib/pyproject_flags_test.py +90 -0
  53. codedoctor-0.1.4/codedoctor/lib/sidecars.py +177 -0
  54. codedoctor-0.1.4/codedoctor/lib/sidecars_test.py +225 -0
  55. {codedoctor-0.1.2 → codedoctor-0.1.4}/codedoctor/lib/testing/__init__.py +1 -0
  56. codedoctor-0.1.4/codedoctor/lib/testing/basetemp.py +135 -0
  57. codedoctor-0.1.4/codedoctor/lib/testing/checks.py +134 -0
  58. codedoctor-0.1.4/codedoctor/lib/testing/checks_test.py +187 -0
  59. {codedoctor-0.1.2 → codedoctor-0.1.4}/codedoctor/lib/testing/resources.py +43 -13
  60. {codedoctor-0.1.2 → codedoctor-0.1.4}/codedoctor/lib/testing/runner.py +4 -0
  61. {codedoctor-0.1.2 → codedoctor-0.1.4}/codedoctor/lib/testing/runner_test.py +4 -0
  62. codedoctor-0.1.4/codedoctor/lib/testing/wheel.py +307 -0
  63. {codedoctor-0.1.2 → codedoctor-0.1.4}/codedoctor/lib/userdirs.py +61 -4
  64. {codedoctor-0.1.2 → codedoctor-0.1.4}/codedoctor/lib/worker_count.py +9 -4
  65. {codedoctor-0.1.2 → codedoctor-0.1.4}/codedoctor/lib/worker_count_test.py +132 -18
  66. {codedoctor-0.1.2 → codedoctor-0.1.4}/codedoctor/lint/__main__.py +1 -1
  67. {codedoctor-0.1.2 → codedoctor-0.1.4}/codedoctor/lint/house_ignore_test.py +44 -0
  68. {codedoctor-0.1.2 → codedoctor-0.1.4}/codedoctor/lint/houselint.py +9 -4
  69. {codedoctor-0.1.2 → codedoctor-0.1.4}/codedoctor/lint/houselint_rules.py +415 -141
  70. {codedoctor-0.1.2 → codedoctor-0.1.4}/codedoctor/lint/houselint_rules_test.py +813 -66
  71. {codedoctor-0.1.2 → codedoctor-0.1.4}/codedoctor/lint/houselint_test.py +115 -35
  72. {codedoctor-0.1.2 → codedoctor-0.1.4}/codedoctor/lint/houselint_types_test.py +32 -1
  73. {codedoctor-0.1.2 → codedoctor-0.1.4}/codedoctor/mutation/__main__.py +1 -1
  74. {codedoctor-0.1.2 → codedoctor-0.1.4}/codedoctor/mutation/mutated.py +968 -90
  75. codedoctor-0.1.4/codedoctor/mutation/mutated_test.py +5223 -0
  76. {codedoctor-0.1.2 → codedoctor-0.1.4}/codedoctor/mutation/mutmut_dynamo.py +12 -2
  77. {codedoctor-0.1.2 → codedoctor-0.1.4}/codedoctor/mutation/mutmut_dynamo_test.py +52 -4
  78. codedoctor-0.1.4/codedoctor/mutation/mutmut_kill_guard.py +42 -0
  79. codedoctor-0.1.4/codedoctor/mutation/mutmut_kill_guard_test.py +67 -0
  80. codedoctor-0.1.4/codedoctor/mutation/mutmut_outcome.py +68 -0
  81. codedoctor-0.1.4/codedoctor/mutation/mutmut_outcome_test.py +181 -0
  82. {codedoctor-0.1.2 → codedoctor-0.1.4}/codedoctor/mutation/mutmut_param_ids.py +26 -1
  83. codedoctor-0.1.4/codedoctor/mutation/mutmut_param_ids_test.py +143 -0
  84. {codedoctor-0.1.2 → codedoctor-0.1.4}/codedoctor/nbstripout/__main__.py +1 -1
  85. {codedoctor-0.1.2 → codedoctor-0.1.4}/codedoctor/nbstripout/nbstripout_hook_test.py +4 -2
  86. codedoctor-0.1.4/codedoctor/policy.py +254 -0
  87. codedoctor-0.1.4/codedoctor/policy_test.py +191 -0
  88. {codedoctor-0.1.2 → codedoctor-0.1.4}/codedoctor/testing/__main__.py +1 -1
  89. {codedoctor-0.1.2 → codedoctor-0.1.4}/codedoctor/testing/coverage_summary.py +5 -4
  90. {codedoctor-0.1.2 → codedoctor-0.1.4}/codedoctor/testing/coverage_summary_test.py +21 -14
  91. codedoctor-0.1.2/codedoctor/selected_nodeids/selected_nodeids_plugin.py → codedoctor-0.1.4/codedoctor/testing/listing.py +22 -18
  92. codedoctor-0.1.2/codedoctor/selected_nodeids/selected_nodeids_plugin_test.py → codedoctor-0.1.4/codedoctor/testing/listing_test.py +130 -53
  93. codedoctor-0.1.4/codedoctor/testing/outcomes.py +108 -0
  94. codedoctor-0.1.4/codedoctor/testing/outcomes_test.py +179 -0
  95. codedoctor-0.1.4/codedoctor/testing/testing.py +521 -0
  96. codedoctor-0.1.4/codedoctor/testing/testing_test.py +1622 -0
  97. {codedoctor-0.1.2 → codedoctor-0.1.4}/codedoctor/testing/tiers.py +5 -0
  98. {codedoctor-0.1.2 → codedoctor-0.1.4}/codedoctor/typecheck/__main__.py +1 -1
  99. {codedoctor-0.1.2 → codedoctor-0.1.4}/codedoctor/typecheck/scope.py +32 -5
  100. {codedoctor-0.1.2 → codedoctor-0.1.4}/codedoctor/typecheck/scope_test.py +5 -0
  101. {codedoctor-0.1.2 → codedoctor-0.1.4}/codedoctor/typecheck/typecheck.py +56 -45
  102. {codedoctor-0.1.2 → codedoctor-0.1.4}/codedoctor/typecheck/typecheck_test.py +181 -14
  103. codedoctor-0.1.4/codedoctor/yamlcheck/__init__.py +1 -0
  104. codedoctor-0.1.4/codedoctor/yamlcheck/__main__.py +17 -0
  105. codedoctor-0.1.4/codedoctor/yamlcheck/checker.py +74 -0
  106. codedoctor-0.1.4/codedoctor/yamlcheck/checker_test.py +157 -0
  107. {codedoctor-0.1.2 → codedoctor-0.1.4}/conftest.py +6 -0
  108. {codedoctor-0.1.2 → codedoctor-0.1.4}/pyproject.toml +148 -56
  109. codedoctor-0.1.4/tests/lib/testing/basetemp_test.py +220 -0
  110. {codedoctor-0.1.2 → codedoctor-0.1.4}/tests/lib/testing/resources_test.py +280 -9
  111. codedoctor-0.1.4/tests/lib/testing/wheel_test.py +482 -0
  112. {codedoctor-0.1.2 → codedoctor-0.1.4}/tests/lib/userdirs_test.py +84 -1
  113. codedoctor-0.1.4/uv.lock +2667 -0
  114. codedoctor-0.1.2/CHANGELOG.md +0 -15
  115. codedoctor-0.1.2/PKG-INFO +0 -114
  116. codedoctor-0.1.2/README.md +0 -77
  117. codedoctor-0.1.2/codedoctor/affected/codegraph_sync.py +0 -111
  118. codedoctor-0.1.2/codedoctor/affected/codegraph_sync_test.py +0 -151
  119. codedoctor-0.1.2/codedoctor/coverage_floor/__init__.py +0 -1
  120. codedoctor-0.1.2/codedoctor/coverage_floor/coverage_floor.py +0 -336
  121. codedoctor-0.1.2/codedoctor/coverage_floor/coverage_floor_test.py +0 -332
  122. codedoctor-0.1.2/codedoctor/gate/gate_test.py +0 -283
  123. codedoctor-0.1.2/codedoctor/mutation/mutated_test.py +0 -2486
  124. codedoctor-0.1.2/codedoctor/mutation/mutmut_param_ids_test.py +0 -88
  125. codedoctor-0.1.2/codedoctor/selected_nodeids/__init__.py +0 -1
  126. codedoctor-0.1.2/codedoctor/testing/testing.py +0 -296
  127. codedoctor-0.1.2/codedoctor/testing/testing_test.py +0 -549
  128. codedoctor-0.1.2/uv.lock +0 -1747
  129. {codedoctor-0.1.2 → codedoctor-0.1.4}/AI_POLICY.md +0 -0
  130. {codedoctor-0.1.2 → codedoctor-0.1.4}/CODE_OF_CONDUCT.md +0 -0
  131. {codedoctor-0.1.2 → codedoctor-0.1.4}/CONTRIBUTING.md +0 -0
  132. {codedoctor-0.1.2 → codedoctor-0.1.4}/LICENSE +0 -0
  133. {codedoctor-0.1.2 → codedoctor-0.1.4}/RELEASING.md +0 -0
  134. {codedoctor-0.1.2 → codedoctor-0.1.4}/SECURITY.md +0 -0
  135. {codedoctor-0.1.2 → codedoctor-0.1.4}/codedoctor/__init__.py +0 -0
  136. {codedoctor-0.1.2 → codedoctor-0.1.4}/codedoctor/affected/__init__.py +0 -0
  137. {codedoctor-0.1.2 → codedoctor-0.1.4}/codedoctor/assert_isinstance/__init__.py +0 -0
  138. {codedoctor-0.1.2 → codedoctor-0.1.4}/codedoctor/gate/__init__.py +0 -0
  139. {codedoctor-0.1.2 → codedoctor-0.1.4}/codedoctor/gate/spool.py +0 -0
  140. {codedoctor-0.1.2 → codedoctor-0.1.4}/codedoctor/lib/__init__.py +0 -0
  141. {codedoctor-0.1.2 → codedoctor-0.1.4}/codedoctor/lib/files/__init__.py +0 -0
  142. {codedoctor-0.1.2 → codedoctor-0.1.4}/codedoctor/lib/files/tempclaim.py +0 -0
  143. {codedoctor-0.1.2 → codedoctor-0.1.4}/codedoctor/lib/files/walk.py +0 -0
  144. {codedoctor-0.1.2 → codedoctor-0.1.4}/codedoctor/lib/kernel_pins.py +0 -0
  145. {codedoctor-0.1.2 → codedoctor-0.1.4}/codedoctor/lib/kernel_pins_test.py +0 -0
  146. {codedoctor-0.1.2 → codedoctor-0.1.4}/codedoctor/lint/__init__.py +0 -0
  147. {codedoctor-0.1.2 → codedoctor-0.1.4}/codedoctor/lint/house_ignore.py +0 -0
  148. {codedoctor-0.1.2 → codedoctor-0.1.4}/codedoctor/lint/houselint_types.py +0 -0
  149. {codedoctor-0.1.2 → codedoctor-0.1.4}/codedoctor/mutation/__init__.py +0 -0
  150. {codedoctor-0.1.2 → codedoctor-0.1.4}/codedoctor/nbstripout/__init__.py +0 -0
  151. {codedoctor-0.1.2 → codedoctor-0.1.4}/codedoctor/nbstripout/nbstripout_hook.py +0 -0
  152. {codedoctor-0.1.2 → codedoctor-0.1.4}/codedoctor/py.typed +0 -0
  153. {codedoctor-0.1.2 → codedoctor-0.1.4}/codedoctor/testing/__init__.py +0 -0
  154. {codedoctor-0.1.2 → codedoctor-0.1.4}/codedoctor/testing/tiers_test.py +0 -0
  155. {codedoctor-0.1.2 → codedoctor-0.1.4}/codedoctor/typecheck/__init__.py +0 -0
  156. {codedoctor-0.1.2 → codedoctor-0.1.4}/typings/.gitkeep +0 -0
@@ -72,9 +72,6 @@ target/
72
72
  profile_default/
73
73
  ipython_config.py
74
74
 
75
- # pyenv
76
- .python-version
77
-
78
75
  # pipenv
79
76
  Pipfile.lock
80
77
 
@@ -30,6 +30,21 @@
30
30
  # fires on a dirty tree) STASHES your changes -- a git mutation, and this
31
31
  # worktree is shared.
32
32
  #
33
+ # Scope. PRECOMMIT_SCOPE defaults to granular. Any other value overrides
34
+ # every applicable hook's individual setting:
35
+ #
36
+ # PRECOMMIT_SCOPE=exact Supplied files only.
37
+ # PRECOMMIT_SCOPE=sidecar Supplied files plus paired source/tests.
38
+ # PRECOMMIT_SCOPE=affected:3 Sidecars plus three reverse-dependency hops.
39
+ #
40
+ # Under granular, PRECOMMIT_SCOPE_<HOOK_ID> overrides that hook's default.
41
+ # Uppercase the hook ID and replace hyphens with underscores, for example
42
+ # PRECOMMIT_SCOPE_TY_CHECK=exact or PRECOMMIT_SCOPE_PYTEST=affected:1.
43
+ # Individual settings accept exact, sidecar, affected:N; never granular.
44
+ # Defaults: ty-check, pyrefly-check, basedpyright affected:3;
45
+ # pytest and mutation sidecar. No shell exports are required.
46
+ # Invalid scopes fail. Missing/unusable graphs warn and fall back to sidecars.
47
+ # Disable checks with SKIP, not enablement variables.
33
48
  #
34
49
  # NUL-delimited, per AGENTS.md: a path containing a space becomes two
35
50
  # arguments under `$(...)` or a bare `xargs`, and a rename record yields the
@@ -108,6 +123,10 @@
108
123
  fail_fast: false
109
124
  default_stages: [pre-commit]
110
125
 
126
+ # ``commit-msg`` for the Copybarista-PR guard below: declared here, one
127
+ # ``pre-commit install`` wires both hook types.
128
+ default_install_hook_types: [pre-commit, commit-msg]
129
+
111
130
  repos:
112
131
 
113
132
  # === Pre-Commit Gates =======================================================
@@ -140,7 +159,12 @@ repos:
140
159
  (?x)^(
141
160
  uv\.lock
142
161
  |typings/
162
+ |(.*/)?typings/stubs/
163
+ |(.*/)?\.export/typings/
143
164
  |(.*/)?chrome/chrome_(desktop|android)_useragents\.txt
165
+ |(.*/)?uv\.public\.lock
166
+ |(.*/)?\.export/uv\.lock
167
+ |\.(claude|sagent)/sessions/
144
168
  )
145
169
 
146
170
  - id: check-merge-conflict
@@ -151,6 +175,8 @@ repos:
151
175
  - id: check-yaml
152
176
  name: check-yaml
153
177
  stages: [pre-commit]
178
+ language: system
179
+ entry: uv --quiet run --frozen --group pre-commit python -m codedoctor.yamlcheck
154
180
 
155
181
  - id: check-toml
156
182
  name: check-toml
@@ -166,11 +192,11 @@ repos:
166
192
  # binary -- both fail closed on a fresh checkout, which is how the tool went
167
193
  # uninstalled while the docs cited it.
168
194
  #
169
- # SC2016 only: the export workflows single-quote
170
- # `--validation-command 'wheel="$wheel" ...'` deliberately -- those `$` belong
171
- # to the inner shell, so "expressions don't expand" inverts the intent. Every
172
- # other shellcheck rule stays live, and shellcheck runs only where installed,
173
- # so this is stricter on CI than on a dev box.
195
+ # SC2016 only: `mutation.yml` single-quotes a printf format holding markdown
196
+ # backticks deliberately -- they are literal text, so "expressions don't
197
+ # expand" inverts the intent. Every other shellcheck rule stays live, and
198
+ # shellcheck runs only where installed, so this is stricter on CI than on a
199
+ # dev box.
174
200
  - repo: https://github.com/rhysd/actionlint
175
201
  rev: v1.7.12
176
202
  hooks:
@@ -182,7 +208,7 @@ repos:
182
208
  # Validates uv.lock matches pyproject.toml (no network needed).
183
209
  # Run `uv lock` manually when changing dependencies.
184
210
  - repo: https://github.com/astral-sh/uv-pre-commit
185
- rev: 0.12.17
211
+ rev: 0.13.7
186
212
  hooks:
187
213
 
188
214
  - id: uv-lock
@@ -194,13 +220,101 @@ repos:
194
220
  hooks:
195
221
  # Worker counts. Every heavy hook below sizes its own pool with
196
222
  # `gate.workers`, which falls back to
197
- # `codedoctor.lib.worker_count.default_workers`, whose docstring derives the
223
+ # `worker_count.default_workers`, whose docstring derives the
198
224
  # formula, and runs below interactive priority. Overrides, most specific
199
225
  # first: `WORKERS_<HOOK_ID>` (`WORKERS_PYTEST_GLOBAL=1`),
200
226
  # then `WORKERS_DEFAULT`. Per hook is what CI needs: the integration tier
201
227
  # holds ~1.8 GB of torch/jax per worker and OOM-killed a 2-vCPU runner at
202
228
  # two, while a type checker on the same box wants more.
203
229
  #
230
+ # The formula's terms were fitted to these measured optima (`optimal` is
231
+ # the best `pytest -n`):
232
+ #
233
+ # host nproc phys perf optimal imputed
234
+ # laptop (Core Ultra 7 255H) 16 16 6 5 5
235
+ # server (EPYC 9555) 128 64 64 24 24
236
+ #
237
+ # laptop: 5 -> 216s vs 6 -> 256s (653 slow tests, idle box); its 16 cores
238
+ # span three clock domains (6x5.1GHz, 8x4.4GHz, 2x2.5GHz), only the first
239
+ # counting as perf. server: 24 -> 105s vs 20 -> 113s (651 slow tests);
240
+ # uniform 3.25GHz, so perf == phys and `perf - 1` never binds. The floor
241
+ # of 2 binds only on a 2-vCPU runner, where xdist still beats serial
242
+ # (5.4s vs 6.4s). The server keeps its 24 unless under 48 GiB is free; the
243
+ # laptop keeps 5 unless under 10 GiB. Measured on a 24 GB M5 Pro (2026-10-01):
244
+ # with swap 92% full, inactive was 6.2 GiB but file-backed only 2.5 GiB;
245
+ # counting inactive allowed 3 workers, and a pre-commit run drove free
246
+ # memory to 53 MB.
247
+
248
+
249
+ - id: nbstripout
250
+ name: nbstripout
251
+ language: system
252
+ stages: [pre-commit]
253
+ types: [jupyter]
254
+ entry: uv --quiet run --frozen --group pre-commit python -m codedoctor.nbstripout
255
+ args:
256
+ - --drop-empty-cells
257
+ - --extra-keys
258
+ - >-
259
+ cell.metadata.heading_collapsed
260
+ metadata.accelerator
261
+ metadata.colab
262
+ metadata.interpreter
263
+ metadata.kernelspec
264
+ metadata.language_info.version
265
+ metadata.name
266
+ metadata.nbconvert_exporter
267
+ metadata.version
268
+ exclude: |
269
+ (?x)^(
270
+ typings/
271
+ |(.*/)?typings/stubs/
272
+ |(.*/)?\.export/typings/
273
+ |(.*/)?third_party/
274
+ )
275
+
276
+ # Writes each notebook's paired `.py`, so it runs before houselint and
277
+ # ruff, which then lint and format that output in the same pass.
278
+ - id: jupytext-sync
279
+ name: jupytext-sync
280
+ language: system
281
+ stages: [pre-commit]
282
+ files: \.ipynb$
283
+ entry: uv --quiet run --frozen --group pre-commit jupytext --sync --pre-commit-mode
284
+ exclude: |
285
+ (?x)^(
286
+ typings/
287
+ |(.*/)?typings/stubs/
288
+ |(.*/)?\.export/typings/
289
+ |(.*/)?third_party/
290
+ )
291
+
292
+ # Must precede ruff-check and ruff-format: `digits` and `staticmethod`
293
+ # rewrite, and either fix can change how the formatter wraps a line.
294
+ #
295
+ # One process for every rule. They read, decode, and parse each file
296
+ # exactly once between them, so a hook per rule buys nothing and costs
297
+ # an interpreter startup each (measured, 120 files, 3 rules: 0.81s ->
298
+ # 0.45s). Which rules run, fix, and skip which paths lives in
299
+ # `[tool.houselint]` of pyproject.toml, so a bare `houselint.py
300
+ # FILES` behaves exactly as this hook does.
301
+ #
302
+ # `require_serial: true`: pre-commit's own partitioning would fork
303
+ # cpu_count interpreters that each import the rules and re-read
304
+ # nothing in common, and it cannot size itself to the commit. The
305
+ # script pools internally instead, capped at the machine's worker count
306
+ # and sized to the file count (one worker per ~10 files) so a small
307
+ # commit stays serial. Measured on the 128-thread server, best of 3: 5 files 0.16s
308
+ # serial vs 0.30s pooled; 50 files 0.92s vs 0.50s; the full tree (4094
309
+ # files) 21.8s serial vs 1.46s at 24 workers.
310
+ - id: houselint
311
+ name: houselint
312
+ language: system
313
+ stages: [pre-commit]
314
+ require_serial: true
315
+ types_or: [python, jupyter]
316
+ entry: uv --quiet run --frozen --group pre-commit python -m codedoctor.lint
317
+
204
318
  - id: codespell
205
319
  name: codespell
206
320
  language: system
@@ -211,12 +325,15 @@ repos:
211
325
  exclude: |
212
326
  (?x)^(
213
327
  typings/
328
+ |(.*/)?typings/stubs/
329
+ |(.*/)?\.export/typings/
214
330
  |(.*/)?third_party/
331
+ |\.(claude|sagent)/sessions/
215
332
  |docs/symbols\.md
216
333
  )
217
334
 
218
335
  - repo: https://github.com/astral-sh/ruff-pre-commit
219
- rev: v0.16.8
336
+ rev: v0.17.4
220
337
  hooks:
221
338
  # Exclusions defined in pyproject.toml.
222
339
  #
@@ -239,12 +356,14 @@ repos:
239
356
  stages: [pre-commit]
240
357
  require_serial: true
241
358
  types_or: [python, pyi, jupyter]
359
+
242
360
  - id: ruff-check
243
361
  name: ruff-check
244
362
  stages: [pre-commit]
245
363
  require_serial: true
246
364
  types_or: [python, pyi, jupyter]
247
365
  args: [--fix, --extend-select, COM812]
366
+
248
367
  - id: ruff-format
249
368
  name: ruff-format
250
369
  stages: [pre-commit]
@@ -253,6 +372,115 @@ repos:
253
372
 
254
373
  - repo: local
255
374
  hooks:
375
+ # The Copybarista-PR-Title/Body trailer is replayed into the PUBLIC export
376
+ # PR, which hard-fails on monorepo references (loop./loop/ ...) AFTER the
377
+ # commit is pushed and unrewritable. Runs that same forbidden-term check
378
+ # at commit-msg time, so a leak never reaches main.
379
+ - id: check-copybarista-pr-text
380
+ name: check-copybarista-pr-text
381
+ language: system
382
+ stages: [commit-msg]
383
+ always_run: true
384
+ entry: uv --quiet run --frozen --group pre-commit python -m codedoctor.export_leaks.check_pr_text
385
+
386
+ - repo: local
387
+ hooks:
388
+ # The CodeGraph indexes live in this host's `/opt/scratch/caches/codegraph`.
389
+ #
390
+ # Sole writer of the indexes `ty-check`, `pyrefly-check` and `pytest` below
391
+ # read: one backbone of origin/main shared by every worktree
392
+ # (`backbone/`, ~826 MB), and this worktree's overlay of only its own
393
+ # changes (`overlays/<name>-<hash>/`). Must stay ABOVE them: pre-commit
394
+ # runs hooks in file order.
395
+ #
396
+ # Indexes whatever is on disk, which is the tree being gated either way --
397
+ # the staged tree under the stashing `pre-commit run`, the working tree
398
+ # under `--files`/`--all-files`.
399
+ #
400
+ # Bootstraps the CLI, and starts a missing or stale backbone's build in
401
+ # the background, because both consumers degrade silently without the
402
+ # graph (no tests selected, no dependents checked). It is meant never to
403
+ # fail -- no network, no npm, and a locked index must not block a commit
404
+ # -- but an error raised while building the overlay still escapes it.
405
+ # Costs 0.13s no-op, 0.56s for one changed file.
406
+ #
407
+ # It makes no `.codegraph` in the worktree: that per-worktree copy of the
408
+ # backbone serves only the codegraph CLI and MCP server, and
409
+ # `codegraph_sync --cli` makes it on request (README).
410
+ #
411
+ # Sync only when an enabled consumer resolves to affected:N. Global
412
+ # exact/sidecar scopes never need an index. Graph failures retain sidecars.
413
+ #
414
+ # TWO SKIP TOKENS, because "don't re-index" and "don't use
415
+ # the index" differ and the wrong one is a silent downgrade:
416
+ #
417
+ # SKIP=harvest-affected the alias. Skips this hook AND makes both
418
+ # consumers ignore the index -- `affected.py`
419
+ # reads `$SKIP` and drops to depth 0, which
420
+ # reaches no edge, so each projection falls to its
421
+ # floor: the changed files for pyrefly, their
422
+ # paired sidecar tests for pytest.
423
+ # SKIP=codegraph-sync the id. Skips only the sync. The consumers keep
424
+ # querying whatever the last sync left, so a
425
+ # symbol added since has no `nodes` row and its
426
+ # own file falls back to the sidecar. For when the
427
+ # index is current and you want the 0.4s back.
428
+ #
429
+ # Reading `$SKIP` inside a hook is the only route to this: a hook cannot
430
+ # ask pre-commit whether a sibling ran, but the variable reaches every
431
+ # hook's environment.
432
+ #
433
+ # RE-MEASURING THE DEPTH. The table below is why `1` is the recommended
434
+ # value; re-derive it after a layout change, or when pre-push starts
435
+ # catching what this tier should have.
436
+ #
437
+ # Ground truth is the test files a commit edited ALONGSIDE its source --
438
+ # the author's own statement of what the change affected. Seed
439
+ # `affected.py` with each commit's source files and score its output
440
+ # against that commit's test files. Report PER-COMMIT MEDIANS, never
441
+ # pooled totals: five of sixty commits contributed 43% of all false
442
+ # positives, and micro-averaging let them set the headline.
443
+ #
444
+ # 2026-08-27, 60 commits of at most 10 source files, graph only:
445
+ #
446
+ # depth med prec med recall commits fully covered med files
447
+ # 1 26.9% 100.0% 67% 8
448
+ # 2 12.7% 100.0% 67% 12
449
+ # 3 9.4% 100.0% 68% 14
450
+ #
451
+ # Median recall is already 100% at depth 1; deeper only adds files. The
452
+ # precision column is a FLOOR, not a measurement -- 65% of the false
453
+ # positives do import a changed file, so they are real dependents the
454
+ # author simply did not need to edit. The other 35% are CodeGraph
455
+ # resolving a callee by name to a same-named symbol in an unimported
456
+ # module.
457
+ #
458
+ # Do NOT score with line-level seeding against a HEAD-built index: the
459
+ # `start_line` columns describe today's files, so rolling an old commit's
460
+ # hunks through them lands on whatever now occupies those offsets. That
461
+ # error is what made an earlier version of this table read 6% precision.
462
+ #
463
+ # Consumer wall time, median over 12 commits, is flat in depth (pytest
464
+ # 2.54/2.23/2.56s, basedpyright 1.99/2.53/2.57s for depths 1/2/3): process
465
+ # startup dominates and the query itself is 0.02-0.04s. Depth only bites
466
+ # when a changeset reaches a slow test, which the median hides -- seeded
467
+ # on one widely imported module alone, pytest went 0.84s/9.81s/7.70s.
468
+ #
469
+ # Unbounded depth is not an option: 59s for one file against 0.10s at
470
+ # depth 10, for 8% more coverage.
471
+ - id: codegraph-sync
472
+ name: codegraph-sync
473
+ # Two skip tokens, different blast radius. See the note above.
474
+ alias: harvest-affected
475
+ language: system
476
+ stages: [pre-commit]
477
+ require_serial: true
478
+ types: [python]
479
+ pass_filenames: false
480
+ entry: >-
481
+ uv --quiet run --frozen --group pre-commit python -m codedoctor.affected.codegraph_sync
482
+ --caches /opt/scratch/caches/codegraph
483
+
256
484
  # No official ty hook yet (https://github.com/astral-sh/ty/issues/269).
257
485
  # The `typecheck` module holds these gates: each runs once over the
258
486
  # files its `-spool` twin collected, sizes its own workers, and drops
@@ -273,36 +501,74 @@ repos:
273
501
  require_serial: true
274
502
  types_or: [python, pyi]
275
503
  entry: uv --quiet run --frozen --group pre-commit python -m codedoctor.gate spool ty-check
504
+
276
505
  - id: ty-check
277
506
  name: ty-check
278
507
  language: system
279
508
  stages: [pre-commit]
509
+ verbose: true
280
510
  require_serial: true
281
511
  pass_filenames: false
282
512
  # See `superseded-at-pre-push` at the head of the Pre-Push Gates section.
283
513
  alias: superseded-at-pre-push
284
514
  types_or: [python, pyi]
285
515
  entry: uv --quiet run --frozen --group pre-commit python -m codedoctor.typecheck ty-check
286
- # Off: `pyrefly-check` is the checker. Run with `--hook-stage manual`.
516
+ # Resolved affected:N scopes read the index maintained above.
517
+ args: [--dependents, codedoctor.affected]
518
+
519
+ # Each checker resolves its own scope independently.
520
+ - id: pyrefly-check-spool
521
+ name: pyrefly-check-spool
522
+ alias: pyrefly-check
523
+ language: system
524
+ stages: [pre-commit]
525
+ require_serial: true
526
+ types_or: [python, pyi]
527
+ entry: uv --quiet run --frozen --group pre-commit python -m codedoctor.gate spool pyrefly-check
528
+
529
+ - id: pyrefly-check
530
+ name: pyrefly-check
531
+ language: system
532
+ stages: [pre-commit]
533
+ verbose: true
534
+ require_serial: true
535
+ pass_filenames: false
536
+ # See `superseded-at-pre-push` at the head of the Pre-Push Gates section.
537
+ alias: superseded-at-pre-push
538
+ types_or: [python, pyi]
539
+ entry: uv --quiet run --frozen --group pre-commit python -m codedoctor.typecheck pyrefly-check
540
+ # Widens on its own only when `ty-check` was skipped. The fixer is one
541
+ # pyrefly run that also deletes each unnecessary `assert isinstance`.
542
+ args:
543
+ - --dependents
544
+ - codedoctor.affected
545
+ - --fixer
546
+ - codedoctor.assert_isinstance
547
+
548
+ # Disable with SKIP=basedpyright.
287
549
  # Named files bypass pyproject's `[tool.basedpyright] exclude`, so the
288
550
  # twin's exclude mirrors it.
289
551
  - id: basedpyright-spool
290
552
  name: basedpyright-spool
291
553
  alias: basedpyright
292
554
  language: system
293
- stages: [manual]
555
+ stages: [pre-commit]
294
556
  require_serial: true
295
557
  types_or: [python, pyi]
296
558
  entry: uv --quiet run --frozen --group pre-commit python -m codedoctor.gate spool basedpyright
297
559
  exclude: |
298
560
  (?x)^(
299
561
  typings/
562
+ |(.*/)?typings/stubs/
563
+ |(.*/)?\.export/typings/
300
564
  |(.*/)?third_party/
565
+ |website/rekursiv-ai\.github\.io/_site/
301
566
  )
567
+
302
568
  - id: basedpyright
303
569
  name: basedpyright
304
570
  language: system
305
- stages: [manual]
571
+ stages: [pre-commit]
306
572
  # Pre-commit discards a PASSING hook's output (see the Pre-Push Gates
307
573
  # note on `verbose`); this keeps basedpyright's summary line visible.
308
574
  verbose: true
@@ -313,32 +579,43 @@ repos:
313
579
  env NODE_OPTIONS=--max-old-space-size=2048
314
580
  uv --quiet run --frozen --group pre-commit python -m codedoctor.typecheck
315
581
  basedpyright
316
- # Default type checker; `basedpyright` above runs only under
317
- # `--hook-stage manual`.
318
- - id: pyrefly-check-spool
319
- name: pyrefly-check-spool
320
- alias: pyrefly-check
582
+ # Widens as `ty-check` does; the fixer is one basedpyright run that
583
+ # also deletes each unnecessary `assert isinstance`.
584
+ args:
585
+ - --dependents
586
+ - codedoctor.affected
587
+ - --fixer
588
+ - codedoctor.assert_isinstance
589
+
590
+ - repo: local
591
+ hooks:
592
+ # Each heavy hook below is a `-spool` twin, which collects pre-commit's
593
+ # file chunks, then the hook, which runs once over all of them through
594
+ # the `gate` or `testing` module at this machine's worker count.
595
+ #
596
+ # One export is ~4.5s of mostly-subprocess work, so the pool scales on the
597
+ # children, not on Python: 8 packages went 27.2s serial -> 5.3s.
598
+ #
599
+ # No `files` filter: `touched_configs` picks the packages a change
600
+ # reaches. A `^loop/` filter skipped the website and every shared file a
601
+ # package copies (`ops/github/shared/`, this config, `.codespell-ignore`).
602
+ - id: check-export-leaks-spool
603
+ name: check-export-leaks-spool
604
+ # `run check-export-leaks` selects this twin too, so its spool exists.
605
+ alias: check-export-leaks
321
606
  language: system
322
607
  stages: [pre-commit]
323
608
  require_serial: true
324
- types_or: [python, pyi]
325
- entry: uv --quiet run --frozen --group pre-commit python -m codedoctor.gate spool pyrefly-check
326
- - id: pyrefly-check
327
- name: pyrefly-check
609
+ entry: uv --quiet run --frozen --group pre-commit python -m codedoctor.gate spool check-export-leaks
610
+
611
+ - id: check-export-leaks
612
+ name: check-export-leaks
328
613
  language: system
329
614
  stages: [pre-commit]
330
615
  require_serial: true
331
616
  pass_filenames: false
332
- # See `superseded-at-pre-push` at the head of the Pre-Push Gates section.
333
- alias: superseded-at-pre-push
334
- types_or: [python, pyi]
335
- entry: uv --quiet run --frozen --group pre-commit python -m codedoctor.typecheck pyrefly-check
336
- - repo: local
337
- hooks:
338
- # Each heavy hook below is a `-spool` twin, which collects pre-commit's
339
- # file chunks, then the hook, which runs once over all of them through
340
- # the `gate` or `testing` module at this machine's worker count.
341
- #
617
+ entry: uv --quiet run --frozen --group pre-commit python -m codedoctor.gate run check-export-leaks -- codedoctor.export_leaks
618
+
342
619
  # Runs the tests PAIRED with each changed file (`x_test.py`, `test_x.py`,
343
620
  # beside it or under `tests/`), then applies `fail_under` to the changed
344
621
  # sources alone. ~1s, versus the whole suite at pre-push. Green with no
@@ -346,6 +623,9 @@ repos:
346
623
  # gate. Exit 5 (nothing collected) passes: a selection whose every test
347
624
  # carries a deselected marker is not a failure.
348
625
  #
626
+ # Under affected:N, `--dependents` adds graph-selected tests to the pairs.
627
+ # Exact runs only supplied tests; sidecar is the default. `coverage-floor`
628
+ # reads this run's per-test coverage, so each selection runs once.
349
629
  #
350
630
  # `-n` only from 16 test files (SIDECAR_XDIST_MIN overrides): xdist's ~5s
351
631
  # startup lost below that on the 16-thread workstation at 5 workers.
@@ -366,6 +646,7 @@ repos:
366
646
  require_serial: true
367
647
  types: [python]
368
648
  entry: uv --quiet run --frozen --group pre-commit python -m codedoctor.gate spool pytest
649
+
369
650
  - id: pytest
370
651
  name: pytest
371
652
  language: system
@@ -379,6 +660,70 @@ repos:
379
660
  alias: superseded-at-pre-push
380
661
  types: [python]
381
662
  entry: uv --quiet run --frozen --group pre-commit python -m codedoctor.testing pytest
663
+ args: [--dependents, codedoctor.affected]
664
+
665
+ # Disable with SKIP=mutation. Findings fail the hook. Over 741 commits,
666
+ # the 5% rate and cap of 4 mutate p50 3 / p90 4 functions (~29s / ~39s).
667
+ - id: mutation-spool
668
+ name: mutation-spool
669
+ # `run mutation` selects this twin too, so its spool exists.
670
+ alias: mutation
671
+ language: system
672
+ stages: [pre-commit]
673
+ require_serial: true
674
+ types: [python]
675
+ exclude: &mutation-exclude |
676
+ (?x)^(
677
+ typings/
678
+ |(.*/)?typings/stubs/
679
+ |(.*/)?\.export/typings/
680
+ |(.*/)?third_party/
681
+ )
682
+ entry: uv --quiet run --frozen --group pre-commit python -m codedoctor.gate spool mutation
683
+
684
+ - id: mutation
685
+ name: mutation
686
+ language: system
687
+ # Local runs get the staged files; CI supplies the committed range.
688
+ stages: [pre-commit]
689
+ require_serial: true
690
+ pass_filenames: false
691
+ # Pre-commit otherwise hides successful-run diagnostics.
692
+ verbose: true
693
+ types: [python]
694
+ exclude: *mutation-exclude
695
+ entry: >-
696
+ uv --quiet run --frozen --group pre-commit python -m codedoctor.gate
697
+ run mutation -- codedoctor.mutation
698
+ --function-sample-rate 0.05 --max-functions-sampled 4 --timeout-sec 900
699
+ --explain --prefer-changed-in-pre-commit
700
+
701
+ # Each changed source under a floored package must be covered to 100% by
702
+ # its OWN sidecar tests -- the per-file form of the floor its exported
703
+ # package enforces; see the `coverage_floor` module. It runs no tests: it
704
+ # reads the coverage the `pytest` hook above recorded per test, so
705
+ # skipping `pytest` floors nothing. The package-wide total is still
706
+ # enforced at pre-push.
707
+ - id: coverage-floor-spool
708
+ name: coverage-floor-spool
709
+ # `run coverage-floor` selects this twin too, so its spool exists.
710
+ alias: coverage-floor
711
+ language: system
712
+ stages: [pre-commit]
713
+ require_serial: true
714
+ types: [python]
715
+ entry: uv --quiet run --frozen --group pre-commit python -m codedoctor.gate spool coverage-floor
716
+
717
+ - id: coverage-floor
718
+ name: coverage-floor
719
+ language: system
720
+ stages: [pre-commit]
721
+ verbose: true
722
+ types: [python]
723
+ require_serial: true
724
+ pass_filenames: false
725
+ entry: uv --quiet run --frozen --group pre-commit python -m codedoctor.testing coverage-floor
726
+
382
727
  # === Pre-Push Gates =========================================================
383
728
  #
384
729
  # To enable: uv run pre-commit install --hook-type pre-push
@@ -441,6 +786,8 @@ repos:
441
786
  stages: [pre-push]
442
787
  verbose: true
443
788
  entry: uv --quiet run --frozen --group pre-commit python -m codedoctor.testing tier pytest-global
789
+ args: [--plugin, codedoctor.testing.listing]
790
+
444
791
  - id: pytest-slow-global
445
792
  name: pytest-slow-global
446
793
  language: system
@@ -449,6 +796,8 @@ repos:
449
796
  stages: [pre-push]
450
797
  verbose: true
451
798
  entry: uv --quiet run --frozen --group pre-commit python -m codedoctor.testing tier pytest-slow-global
799
+ args: [--plugin, codedoctor.testing.listing]
800
+
452
801
  - id: pytest-ci-smoke-global
453
802
  name: pytest-ci-smoke-global
454
803
  language: system
@@ -457,6 +806,8 @@ repos:
457
806
  stages: [pre-push]
458
807
  verbose: true
459
808
  entry: uv --quiet run --frozen --group pre-commit python -m codedoctor.testing tier pytest-ci-smoke-global
809
+ args: [--plugin, codedoctor.testing.listing]
810
+
460
811
  - id: pytest-integration-global
461
812
  name: pytest-integration-global
462
813
  language: system
@@ -465,4 +816,7 @@ repos:
465
816
  stages: [pre-push]
466
817
  verbose: true
467
818
  entry: uv --quiet run --frozen --group pre-commit python -m codedoctor.testing tier pytest-integration-global
819
+ args: [--plugin, codedoctor.testing.listing]
820
+
821
+
468
822
  # NEVER EDIT THIS FILE!
@@ -0,0 +1 @@
1
+ 3.14
@@ -0,0 +1,44 @@
1
+ # Changelog
2
+
3
+ All notable codedoctor changes are documented here. This project follows
4
+ [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
5
+
6
+ ## 0.1.4 - 2026-11-07
7
+
8
+ ### Changed
9
+
10
+ - Provision pinned, checksummed CodeGraph and skip indexing when unavailable.
11
+ - Generate checker policy from packaged defaults, preserving project overrides.
12
+ - Check for stale generated configuration.
13
+ - Require explicit project settings for user-directory lint rules.
14
+ - Apply coverage floors to sources owned by changed tests.
15
+
16
+ ### Fixed
17
+
18
+ - Preserve leading whitespace in hook configuration.
19
+ - Prove integer bounds for NumPy `arange` defaults.
20
+ - Restrict mutation's vendored-tree filter to stub directories.
21
+ - Fix mutant import shadowing.
22
+
23
+ ## 0.1.3 - 2026-11-07
24
+
25
+ ### Changed
26
+
27
+ - `mutation` findings are advisory: they print and the run exits 0. `--blocking`,
28
+ or `PRECOMMIT_MUTATION_BLOCKING` set to a positive integer, makes any finding
29
+ exit 1 as before. A run that cannot start still exits 1.
30
+ - houselint's `cli-shape` wants a polyglot launcher to run `python3 -P "$0"` (or
31
+ `python3 -P -m MODULE`), and its fix adds the `-P`. Without it Python puts the
32
+ launcher's folder first on `sys.path`, where a module beside it, such as a
33
+ `types.py`, shadows the standard library's.
34
+
35
+ ## 0.1.2 - 2026-10-22
36
+
37
+ ### Added
38
+
39
+ - The pre-commit gates: `gate` (spool, `run`, `threaded`), `typecheck`
40
+ (ty, pyrefly, basedpyright), `testing` (paired tests and pytest tiers),
41
+ `coverage_floor`, `mutation`, `lint` (houselint), `assert_isinstance`,
42
+ `affected`, `nbstripout` and `selected_nodeids`.
43
+ - A `coverage` extra for the `coverage_floor` gate, which imports `coverage`.
44
+ - The `mutation` extra requires `pytest`, which its pytest plugins import.