claude-dev-env 2.2.1 → 2.4.0
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.
- package/CLAUDE.md +3 -2
- package/_shared/advisor/advisor-protocol.md +2 -2
- package/_shared/pr-loop/scripts/CLAUDE.md +1 -0
- package/_shared/pr-loop/scripts/grant_project_claude_permissions.py +306 -284
- package/_shared/pr-loop/scripts/pr_loop_shared_constants/CLAUDE.md +1 -0
- package/_shared/pr-loop/scripts/pr_loop_shared_constants/claude_permissions_constants.py +3 -3
- package/_shared/pr-loop/scripts/pr_loop_shared_constants/stale_worktree_rule_sweep_constants.py +107 -0
- package/_shared/pr-loop/scripts/revoke_project_claude_permissions.py +5 -0
- package/_shared/pr-loop/scripts/stale_worktree_rule_sweep.py +107 -0
- package/_shared/pr-loop/scripts/tests/CLAUDE.md +2 -0
- package/_shared/pr-loop/scripts/tests/test_agent_config_carveout.py +55 -73
- package/_shared/pr-loop/scripts/tests/test_claude_permissions_constants.py +9 -15
- package/_shared/pr-loop/scripts/tests/test_grant_project_claude_permissions.py +91 -1
- package/_shared/pr-loop/scripts/tests/test_revoke_project_claude_permissions.py +88 -1
- package/_shared/pr-loop/scripts/tests/test_stale_worktree_rule_sweep.py +301 -0
- package/_shared/pr-loop/scripts/tests/test_stale_worktree_rule_sweep_constants.py +85 -0
- package/_shared/pr-loop/worker-spawn.md +1 -1
- package/agents/CLAUDE.md +1 -0
- package/agents/code-verifier.md +4 -4
- package/agents/skill-writer-agent.md +84 -0
- package/audit-rubrics/category_rubrics/category-o-docstring-vs-impl-drift.md +141 -41
- package/audit-rubrics/prompts/category-o-docstring-vs-impl-drift.md +29 -13
- package/docs/CLAUDE.md +1 -0
- package/docs/references/CLAUDE.md +1 -0
- package/docs/references/code-review-enforcement.md +97 -0
- package/docs/wsl-docker-cowork-starter-matrix.md +89 -0
- package/hooks/blocking/CLAUDE.md +8 -1
- package/hooks/blocking/code_review_enforcement_config_bootstrap.py +53 -0
- package/hooks/blocking/code_review_gate_deny.py +74 -0
- package/hooks/blocking/code_review_pr_create_gate.py +194 -0
- package/hooks/blocking/code_review_push_gate.py +140 -0
- package/hooks/blocking/code_review_stamp_directory_write_blocker.py +340 -0
- package/hooks/blocking/code_review_stamp_store.py +233 -0
- package/hooks/blocking/code_review_stamp_write_blocker_parts/__init__.py +7 -0
- package/hooks/blocking/code_review_stamp_write_blocker_parts/conftest.py +15 -0
- package/hooks/blocking/code_review_stamp_write_blocker_parts/obfuscated_stamp_path_reference.py +212 -0
- package/hooks/blocking/code_review_stamp_write_blocker_parts/split_directory_change_into_stamp.py +138 -0
- package/hooks/blocking/code_review_stamp_write_blocker_parts/test_obfuscated_stamp_path_reference.py +49 -0
- package/hooks/blocking/code_review_stamp_write_blocker_parts/test_split_directory_change_into_stamp.py +38 -0
- package/hooks/blocking/code_verifier_spawn_preflight_gate.py +39 -27
- package/hooks/blocking/config/code_review_enforcement_constants.py +110 -0
- package/hooks/blocking/config/test_code_review_enforcement_constants.py +108 -0
- package/hooks/blocking/config/verified_commit_constants.py +24 -9
- package/hooks/blocking/conftest.py +2 -0
- package/hooks/blocking/convergence_gate_blocker.py +112 -23
- package/hooks/blocking/destructive_command_blocker.py +19 -6
- package/hooks/blocking/pr_description_proof_of_work.py +52 -34
- package/hooks/blocking/test_bash_pre_tool_use_dispatcher.py +4 -1
- package/hooks/blocking/test_code_review_enforcement_config_bootstrap.py +62 -0
- package/hooks/blocking/test_code_review_gate_deny.py +54 -0
- package/hooks/blocking/test_code_review_pr_create_gate.py +185 -0
- package/hooks/blocking/test_code_review_push_gate.py +189 -0
- package/hooks/blocking/test_code_review_stamp_directory_write_blocker.py +180 -0
- package/hooks/blocking/test_code_review_stamp_store.py +205 -0
- package/hooks/blocking/test_code_verifier_spawn_preflight_gate.py +124 -2
- package/hooks/blocking/test_code_verifier_tools_contract.py +28 -0
- package/hooks/blocking/test_convergence_gate_blocker.py +153 -5
- package/hooks/blocking/test_destructive_command_blocker.py +1 -1
- package/hooks/blocking/test_destructive_command_blocker_deny_mode.py +45 -0
- package/hooks/blocking/test_pr_description_proof_of_work.py +151 -0
- package/hooks/blocking/test_pre_tool_use_dispatcher.py +8 -8
- package/hooks/blocking/test_verification_verdict_store.py +920 -810
- package/hooks/blocking/test_volatile_path_in_post_blocker.py +114 -2
- package/hooks/blocking/verification_verdict_store.py +118 -5
- package/hooks/blocking/verified_commit_gate_parts/gated_invocations.py +29 -17
- package/hooks/blocking/verified_commit_gate_parts/tests/test_gated_invocations.py +35 -0
- package/hooks/blocking/volatile_path_in_post_blocker.py +69 -8
- package/hooks/git-hooks/git_hooks_constants/__init__.py +6 -0
- package/hooks/git-hooks/pre_push.py +89 -2
- package/hooks/git-hooks/test_pre_push.py +103 -0
- package/hooks/hooks.json +16 -1
- package/hooks/hooks_constants/CLAUDE.md +1 -0
- package/hooks/hooks_constants/bash_pre_tool_use_dispatcher_constants.py +8 -0
- package/hooks/hooks_constants/code_rules_path_utils_constants.py +1 -0
- package/hooks/hooks_constants/code_verifier_spawn_preflight_gate_constants.py +26 -11
- package/hooks/hooks_constants/convergence_gate_blocker_constants.py +20 -3
- package/hooks/hooks_constants/destructive_command_segment_constants.py +3 -1
- package/hooks/hooks_constants/pr_description_proof_of_work_constants.py +0 -4
- package/hooks/hooks_constants/pre_tool_use_dispatcher_constants.py +4 -0
- package/hooks/hooks_constants/pyproject_config_discovery_constants.py +16 -0
- package/hooks/hooks_constants/test_bash_pre_tool_use_dispatcher_constants.py +24 -0
- package/hooks/hooks_constants/test_pre_tool_use_dispatcher_constants.py +6 -0
- package/hooks/hooks_constants/volatile_path_in_post_blocker_constants.py +8 -1
- package/hooks/validators/CLAUDE.md +1 -0
- package/hooks/validators/mypy_integration.py +63 -50
- package/hooks/validators/pyproject_config_discovery.py +101 -0
- package/hooks/validators/ruff_integration.py +211 -23
- package/hooks/validators/run_all_validators.py +21 -14
- package/hooks/validators/test_mypy_integration.py +32 -0
- package/hooks/validators/test_pyproject_config_discovery.py +94 -0
- package/hooks/validators/test_ruff_integration.py +68 -1
- package/hooks/validators/test_run_all_validators.py +25 -0
- package/hooks/validators/test_run_all_validators_config_discovery.py +123 -0
- package/package.json +1 -1
- package/rules/docstring-prose-matches-implementation.md +20 -43
- package/rules/durable-post-artifacts.md +7 -0
- package/scripts/CLAUDE.md +2 -1
- package/scripts/claude-chain.example.json +15 -3
- package/scripts/claude_chain_runner.py +130 -27
- package/scripts/claude_chain_usage.py +346 -0
- package/scripts/codec_forwarding_test_support.py +83 -0
- package/scripts/conftest.py +8 -0
- package/scripts/dev_env_scripts_constants/CLAUDE.md +4 -3
- package/scripts/dev_env_scripts_constants/claude_chain_constants.py +57 -2
- package/scripts/dev_env_scripts_constants/claude_chain_usage_constants.py +58 -0
- package/scripts/dev_env_scripts_constants/code_review_constants.py +129 -12
- package/scripts/dev_env_scripts_constants/test_code_review_constants.py +55 -0
- package/scripts/dev_env_scripts_constants/timing.py +1 -1
- package/scripts/invoke_code_review.py +550 -38
- package/scripts/resolve_worker_spawn.py +8 -1
- package/scripts/test_claude_chain_runner.py +412 -6
- package/scripts/test_claude_chain_usage.py +534 -0
- package/scripts/test_invoke_code_review.py +298 -4
- package/scripts/test_invoke_code_review_codec.py +77 -0
- package/scripts/test_resolve_worker_spawn_codec.py +101 -0
- package/skills/autoconverge/SKILL.md +9 -3
- package/skills/autoconverge/reference/convergence.md +2 -1
- package/skills/autoconverge/reference/multi-pr.md +6 -1
- package/skills/autoconverge/reference/stop-conditions.md +16 -10
- package/skills/autoconverge/workflow/converge.clean-audit.test.mjs +1 -1
- package/skills/autoconverge/workflow/converge.codex-gate.test.mjs +175 -3
- package/skills/autoconverge/workflow/converge.contract.test.mjs +19 -0
- package/skills/autoconverge/workflow/converge.mjs +24 -8
- package/skills/autoconverge/workflow/converge_multi.mjs +7 -3
- package/skills/autoconverge/workflow/converge_multi.run-input.test.mjs +5 -0
- package/skills/fresh-branch/CLAUDE.md +2 -0
- package/skills/fresh-branch/SKILL.md +2 -0
- package/skills/fresh-branch/scripts/create_fresh_branch.py +78 -180
- package/skills/fresh-branch/scripts/fresh_branch_git_commands.py +285 -0
- package/skills/fresh-branch/scripts/fresh_branch_scripts_constants/fresh_branch_cli_constants.py +1 -0
- package/skills/fresh-branch/scripts/pytest.ini +4 -0
- package/skills/fresh-branch/scripts/test_create_fresh_branch.py +98 -0
- package/skills/fresh-branch/scripts/test_fresh_branch_git_commands.py +310 -0
- package/skills/orchestrator/SKILL.md +1 -20
- package/skills/orchestrator-refresh/SKILL.md +1 -1
- package/skills/pr-converge/SKILL.md +3 -3
- package/skills/pr-converge/reference/examples.md +3 -3
- package/skills/pr-converge/reference/fix-protocol.md +1 -1
- package/skills/pr-converge/reference/ground-rules.md +3 -3
- package/skills/pr-converge/reference/per-tick.md +5 -5
- package/skills/pr-converge/reference/progress-checklist.md +1 -1
- package/skills/pr-converge/test_step5_host_branch.py +1 -1
- package/skills/prototype/SKILL.md +86 -0
- package/skills/prototype/reference/honest-limitations.md +23 -0
- package/skills/prototype/reference/promotion-tasks.md +23 -0
- package/skills/prototype/scripts/build_sandbox_settings.py +249 -0
- package/skills/prototype/scripts/conftest.py +15 -0
- package/skills/prototype/scripts/launch_sandbox.py +205 -0
- package/skills/prototype/scripts/probe_sandbox_safety.py +311 -0
- package/skills/prototype/scripts/prototype_scripts_constants/__init__.py +1 -0
- package/skills/prototype/scripts/prototype_scripts_constants/config/__init__.py +0 -0
- package/skills/prototype/scripts/prototype_scripts_constants/config/build_sandbox_settings_constants.py +41 -0
- package/skills/prototype/scripts/prototype_scripts_constants/config/launch_sandbox_constants.py +23 -0
- package/skills/prototype/scripts/prototype_scripts_constants/config/probe_sandbox_safety_constants.py +45 -0
- package/skills/prototype/scripts/prototype_scripts_constants/config/prototype_common_constants.py +10 -0
- package/skills/prototype/scripts/test_build_sandbox_settings.py +275 -0
- package/skills/prototype/scripts/test_launch_sandbox.py +303 -0
- package/skills/prototype/scripts/test_probe_sandbox_safety.py +284 -0
- package/skills/prototype/workflows/promotion.md +27 -0
- package/skills/prototype/workflows/sandbox.md +35 -0
- package/skills/skill-builder/CLAUDE.md +3 -3
- package/skills/skill-builder/SKILL.md +5 -5
- package/skills/skill-builder/references/CLAUDE.md +1 -1
- package/skills/skill-builder/references/delegation-map.md +3 -3
- package/skills/skill-builder/references/description-field.md +1 -1
- package/skills/skill-builder/references/skill-modularity.md +2 -3
- package/skills/skill-builder/workflows/CLAUDE.md +1 -1
- package/skills/skill-builder/workflows/improve-skill.md +1 -1
- package/skills/skill-builder/workflows/new-skill.md +2 -2
- package/skills/team-advisor/SKILL.md +5 -4
|
@@ -165,6 +165,37 @@ def test_run_mypy_check_accepts_relative_path_under_nested_root(
|
|
|
165
165
|
assert mypy_result.passed, mypy_result.output
|
|
166
166
|
|
|
167
167
|
|
|
168
|
+
def test_run_mypy_check_applies_config_resolved_from_config_source_path(
|
|
169
|
+
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
|
|
170
|
+
) -> None:
|
|
171
|
+
"""A staged file is checked under the config resolved from the original path.
|
|
172
|
+
|
|
173
|
+
A strict ``[tool.mypy]`` config flags an untyped def only when
|
|
174
|
+
``config_source_path`` resolves it; native discovery from the detached
|
|
175
|
+
file finds no config and passes.
|
|
176
|
+
"""
|
|
177
|
+
strict_repo = tmp_path / "strict_repo"
|
|
178
|
+
strict_repo.mkdir()
|
|
179
|
+
(strict_repo / "pyproject.toml").write_text(
|
|
180
|
+
"[tool.mypy]\ndisallow_untyped_defs = true\n", encoding="utf-8"
|
|
181
|
+
)
|
|
182
|
+
detached_file = tmp_path / "detached" / "untyped.py"
|
|
183
|
+
detached_file.parent.mkdir(parents=True)
|
|
184
|
+
detached_file.write_text(
|
|
185
|
+
"def annotate_nothing(value):\n return value\n", encoding="utf-8"
|
|
186
|
+
)
|
|
187
|
+
|
|
188
|
+
monkeypatch.chdir(tmp_path)
|
|
189
|
+
|
|
190
|
+
without_source = run_mypy_check([detached_file])
|
|
191
|
+
with_source = run_mypy_check(
|
|
192
|
+
[detached_file], config_source_path=strict_repo / "pyproject.toml"
|
|
193
|
+
)
|
|
194
|
+
|
|
195
|
+
assert without_source.passed, without_source.output
|
|
196
|
+
assert not with_source.passed
|
|
197
|
+
|
|
198
|
+
|
|
168
199
|
def test_mypy_result_dataclass() -> None:
|
|
169
200
|
"""Test MypyResult dataclass creation."""
|
|
170
201
|
result = MypyResult(passed=True, output="test", error_count=0)
|
|
@@ -183,6 +214,7 @@ def test_run_mypy_check_returns_passed_for_empty_files() -> None:
|
|
|
183
214
|
"""Test that run_mypy_check passes with no files."""
|
|
184
215
|
result = run_mypy_check([])
|
|
185
216
|
assert result.passed is True
|
|
217
|
+
assert result.error_count == 0
|
|
186
218
|
assert "No files" in result.output
|
|
187
219
|
|
|
188
220
|
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"""Tests for the shared pyproject config-discovery walk-up primitive.
|
|
2
|
+
|
|
3
|
+
The primitive walks up from a starting path and returns the first pyproject.toml
|
|
4
|
+
whose ``[tool.<name>]`` table exists, so each tool matches only a config that
|
|
5
|
+
actually configures it — a mypy-only pyproject is no ruff config.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
from hooks_constants.pyproject_config_discovery_constants import (
|
|
11
|
+
MYPY_TOOL_TABLE_NAME,
|
|
12
|
+
RUFF_TOOL_TABLE_NAME,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
from .pyproject_config_discovery import (
|
|
16
|
+
ancestor_directories,
|
|
17
|
+
find_pyproject_configuring_tool,
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def test_ancestor_directories_lists_directory_then_parents_nearest_first(
|
|
22
|
+
tmp_path: Path,
|
|
23
|
+
) -> None:
|
|
24
|
+
nested_directory = tmp_path / "outer" / "inner"
|
|
25
|
+
nested_directory.mkdir(parents=True)
|
|
26
|
+
nested_file = nested_directory / "module.py"
|
|
27
|
+
nested_file.write_text("sample_number: int = 1\n", encoding="utf-8")
|
|
28
|
+
|
|
29
|
+
walked = ancestor_directories(nested_file)
|
|
30
|
+
|
|
31
|
+
assert walked[0] == nested_directory.resolve()
|
|
32
|
+
assert walked[1] == (tmp_path / "outer").resolve()
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def test_find_pyproject_configuring_tool_returns_table_owning_pyproject(
|
|
36
|
+
tmp_path: Path,
|
|
37
|
+
) -> None:
|
|
38
|
+
project_root = tmp_path / "project"
|
|
39
|
+
nested_directory = project_root / "src" / "deep"
|
|
40
|
+
nested_directory.mkdir(parents=True)
|
|
41
|
+
owning_pyproject = project_root / "pyproject.toml"
|
|
42
|
+
owning_pyproject.write_text("[tool.ruff.lint]\nselect = ['B']\n", encoding="utf-8")
|
|
43
|
+
target_file = nested_directory / "module.py"
|
|
44
|
+
|
|
45
|
+
found = find_pyproject_configuring_tool(target_file, RUFF_TOOL_TABLE_NAME)
|
|
46
|
+
|
|
47
|
+
assert found == owning_pyproject
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def test_find_pyproject_configuring_tool_skips_pyproject_without_the_table(
|
|
51
|
+
tmp_path: Path,
|
|
52
|
+
) -> None:
|
|
53
|
+
outer_root = tmp_path / "outer"
|
|
54
|
+
inner_root = outer_root / "inner"
|
|
55
|
+
inner_root.mkdir(parents=True)
|
|
56
|
+
outer_pyproject = outer_root / "pyproject.toml"
|
|
57
|
+
outer_pyproject.write_text("[tool.mypy]\nignore_missing_imports = true\n", encoding="utf-8")
|
|
58
|
+
(inner_root / "pyproject.toml").write_text("[project]\nname = 'inner'\n", encoding="utf-8")
|
|
59
|
+
target_file = inner_root / "module.py"
|
|
60
|
+
|
|
61
|
+
found = find_pyproject_configuring_tool(target_file, MYPY_TOOL_TABLE_NAME)
|
|
62
|
+
|
|
63
|
+
assert found == outer_pyproject
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def test_find_pyproject_configuring_tool_is_table_specific(tmp_path: Path) -> None:
|
|
67
|
+
project_root = tmp_path / "mypy_only"
|
|
68
|
+
project_root.mkdir()
|
|
69
|
+
(project_root / "pyproject.toml").write_text(
|
|
70
|
+
"[tool.mypy]\nignore_missing_imports = true\n", encoding="utf-8"
|
|
71
|
+
)
|
|
72
|
+
target_file = project_root / "module.py"
|
|
73
|
+
|
|
74
|
+
assert find_pyproject_configuring_tool(target_file, MYPY_TOOL_TABLE_NAME) is not None
|
|
75
|
+
assert find_pyproject_configuring_tool(target_file, RUFF_TOOL_TABLE_NAME) is None
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def test_find_pyproject_configuring_tool_returns_none_when_no_match(tmp_path: Path) -> None:
|
|
79
|
+
isolated_directory = tmp_path / "isolated"
|
|
80
|
+
isolated_directory.mkdir()
|
|
81
|
+
target_file = isolated_directory / "module.py"
|
|
82
|
+
|
|
83
|
+
assert find_pyproject_configuring_tool(target_file, RUFF_TOOL_TABLE_NAME) is None
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def test_find_pyproject_configuring_tool_treats_malformed_toml_as_no_match(
|
|
87
|
+
tmp_path: Path,
|
|
88
|
+
) -> None:
|
|
89
|
+
project_root = tmp_path / "broken"
|
|
90
|
+
project_root.mkdir()
|
|
91
|
+
(project_root / "pyproject.toml").write_text("[tool.ruff\nbroken = true\n", encoding="utf-8")
|
|
92
|
+
target_file = project_root / "module.py"
|
|
93
|
+
|
|
94
|
+
assert find_pyproject_configuring_tool(target_file, RUFF_TOOL_TABLE_NAME) is None
|
|
@@ -3,7 +3,47 @@
|
|
|
3
3
|
from pathlib import Path
|
|
4
4
|
from unittest.mock import patch
|
|
5
5
|
|
|
6
|
-
from .ruff_integration import
|
|
6
|
+
from .ruff_integration import (
|
|
7
|
+
RuffResult,
|
|
8
|
+
_config_relative_stdin_filename,
|
|
9
|
+
_parse_fixed_count,
|
|
10
|
+
check_ruff_available,
|
|
11
|
+
run_ruff_check,
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def test_parse_fixed_count_reads_the_count_from_the_fixed_line() -> None:
|
|
16
|
+
"""The ``Fixed N`` summary line yields its integer count."""
|
|
17
|
+
assert _parse_fixed_count("Found 3 errors (2 fixed).\nFixed 2 errors\n") == 2
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def test_parse_fixed_count_returns_zero_without_a_fixed_line() -> None:
|
|
21
|
+
"""Output with no ``Fixed`` line yields a zero count."""
|
|
22
|
+
assert _parse_fixed_count("All checks passed!\n") == 0
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def test_config_relative_stdin_filename_returns_posix_path_under_config_directory() -> None:
|
|
26
|
+
"""A target under the config directory resolves to its config-relative path."""
|
|
27
|
+
config_directory = Path("/repo/hooks")
|
|
28
|
+
target_path = Path("/repo/hooks/validators/run_all_validators.py")
|
|
29
|
+
|
|
30
|
+
relative_filename = _config_relative_stdin_filename(target_path, config_directory)
|
|
31
|
+
|
|
32
|
+
assert relative_filename == "validators/run_all_validators.py"
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def test_config_relative_stdin_filename_falls_back_to_basename_off_tree() -> None:
|
|
36
|
+
"""A target outside the config directory falls back to the bare basename.
|
|
37
|
+
|
|
38
|
+
Path-scoped per-file-ignores cannot apply to a file that does not sit under
|
|
39
|
+
the config directory, so a ``..``-laden relative path is never handed to ruff.
|
|
40
|
+
"""
|
|
41
|
+
config_directory = Path("/repo/hooks")
|
|
42
|
+
target_path = Path("/elsewhere/run_all_validators.py")
|
|
43
|
+
|
|
44
|
+
relative_filename = _config_relative_stdin_filename(target_path, config_directory)
|
|
45
|
+
|
|
46
|
+
assert relative_filename == "run_all_validators.py"
|
|
7
47
|
|
|
8
48
|
|
|
9
49
|
def test_ruff_result_dataclass() -> None:
|
|
@@ -24,9 +64,36 @@ def test_run_ruff_check_returns_passed_for_empty_files() -> None:
|
|
|
24
64
|
"""Test that run_ruff_check passes with no files."""
|
|
25
65
|
result = run_ruff_check([])
|
|
26
66
|
assert result.passed is True
|
|
67
|
+
assert result.fixed_count == 0
|
|
27
68
|
assert "No files" in result.output
|
|
28
69
|
|
|
29
70
|
|
|
71
|
+
def test_run_ruff_check_applies_config_resolved_from_config_source_path(
|
|
72
|
+
tmp_path: Path,
|
|
73
|
+
) -> None:
|
|
74
|
+
"""A given config_source_path resolves the ruff config for a staged copy.
|
|
75
|
+
|
|
76
|
+
A ``[tool.ruff.lint]`` selecting B flags an ``assert False`` (B011) only when
|
|
77
|
+
``config_source_path`` — the original ``.py`` target — resolves it; native
|
|
78
|
+
discovery from the detached staged copy finds no ruff config and passes.
|
|
79
|
+
"""
|
|
80
|
+
ruff_repo = tmp_path / "ruff_repo"
|
|
81
|
+
ruff_repo.mkdir()
|
|
82
|
+
(ruff_repo / "pyproject.toml").write_text(
|
|
83
|
+
"[tool.ruff.lint]\nselect = ['B']\n", encoding="utf-8"
|
|
84
|
+
)
|
|
85
|
+
original_target = ruff_repo / "asserts.py"
|
|
86
|
+
staged_copy = tmp_path / "detached" / "asserts.py"
|
|
87
|
+
staged_copy.parent.mkdir(parents=True)
|
|
88
|
+
staged_copy.write_text("def probe() -> None:\n assert False\n", encoding="utf-8")
|
|
89
|
+
|
|
90
|
+
without_source = run_ruff_check([staged_copy])
|
|
91
|
+
with_source = run_ruff_check([staged_copy], config_source_path=original_target)
|
|
92
|
+
|
|
93
|
+
assert "B011" not in without_source.output
|
|
94
|
+
assert "B011" in with_source.output
|
|
95
|
+
|
|
96
|
+
|
|
30
97
|
def test_run_ruff_check_emits_location_prefixed_lines(tmp_path: Path) -> None:
|
|
31
98
|
"""Each reported violation carries a ``path:line:col:`` prefix on its own line.
|
|
32
99
|
|
|
@@ -20,8 +20,33 @@ from .run_all_validators import (
|
|
|
20
20
|
run_git_checks,
|
|
21
21
|
run_python_style_checks,
|
|
22
22
|
run_with_fallback,
|
|
23
|
+
validate_proposed_file,
|
|
23
24
|
)
|
|
24
25
|
|
|
26
|
+
_VALIDATORS_DIRECTORY = Path(__file__).parent
|
|
27
|
+
_ASSERT_FALSE_SOURCE = (
|
|
28
|
+
"def probe_condition(observed_total: int) -> None:\n"
|
|
29
|
+
" assert False, observed_total\n"
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def test_validate_proposed_file_threads_ruff_config_from_original_path() -> None:
|
|
34
|
+
"""A non-test staged file is linted under the project ruff config (B selected).
|
|
35
|
+
|
|
36
|
+
::
|
|
37
|
+
|
|
38
|
+
original path .../validators/threading_probe.py, assert False body
|
|
39
|
+
ok: config resolved from the original path -> Ruff output carries B011
|
|
40
|
+
"""
|
|
41
|
+
probe_path = _VALIDATORS_DIRECTORY / "threading_probe.py"
|
|
42
|
+
|
|
43
|
+
all_results = validate_proposed_file(str(probe_path), _ASSERT_FALSE_SOURCE)
|
|
44
|
+
|
|
45
|
+
ruff_output = next(
|
|
46
|
+
each_result.output for each_result in all_results if each_result.name == "Ruff"
|
|
47
|
+
)
|
|
48
|
+
assert "B011" in ruff_output
|
|
49
|
+
|
|
25
50
|
|
|
26
51
|
class TestFixFlag:
|
|
27
52
|
"""Test --fix flag functionality."""
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"""Regression tests: staged validation resolves ruff config from the original path.
|
|
2
|
+
|
|
3
|
+
The PreToolUse gate stages proposed content to an OS-temp file, so ruff would
|
|
4
|
+
discover its config by walking up from that temp path and never reach
|
|
5
|
+
``packages/claude-dev-env/hooks/pyproject.toml``. Its ``[tool.ruff.lint]`` selects
|
|
6
|
+
B and PL, so a dropped config leaves the staged run less strict than the project.
|
|
7
|
+
|
|
8
|
+
``validate_proposed_file`` resolves the config from the ORIGINAL target path, so
|
|
9
|
+
the project ruff config applies to the staged copy from any working directory.
|
|
10
|
+
|
|
11
|
+
::
|
|
12
|
+
|
|
13
|
+
original path .../validators/config_probe_module.py, DIRTY_SOURCE (assert False)
|
|
14
|
+
flag (defect): staged temp copy -> no [tool.ruff] up-tree -> B011 not selected
|
|
15
|
+
ok (fixed): config resolved from original path -> B011 fires
|
|
16
|
+
|
|
17
|
+
original path .../validators/test_config_probe_module.py, same DIRTY_SOURCE
|
|
18
|
+
ok: the test_*.py per-file-ignore reaches the staged copy -> B011 suppressed
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
from pathlib import Path
|
|
22
|
+
|
|
23
|
+
import pytest
|
|
24
|
+
|
|
25
|
+
from .run_all_validators import ValidatorResult, get_project_root, validate_proposed_file
|
|
26
|
+
|
|
27
|
+
VALIDATORS_DIRECTORY = Path(__file__).parent
|
|
28
|
+
NON_TEST_PROBE_PATH = VALIDATORS_DIRECTORY / "config_probe_module.py"
|
|
29
|
+
TEST_PROBE_PATH = VALIDATORS_DIRECTORY / "test_config_probe_module.py"
|
|
30
|
+
|
|
31
|
+
RUN_ALL_VALIDATORS_PATH = VALIDATORS_DIRECTORY / "run_all_validators.py"
|
|
32
|
+
EXEMPT_PATHS_PATH = VALIDATORS_DIRECTORY / "exempt_paths.py"
|
|
33
|
+
|
|
34
|
+
DIRTY_SOURCE = (
|
|
35
|
+
"def probe_condition(observed_total: int) -> None:\n assert False, observed_total\n"
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
UNCHECKED_SUBPROCESS_SOURCE = (
|
|
39
|
+
"import subprocess\n\n\ndef run_listing() -> None:\n subprocess.run([\"ls\"])\n"
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
UNUSED_IMPORT_SOURCE = "import os\n"
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def _ruff_result(all_results: list[ValidatorResult]) -> ValidatorResult:
|
|
46
|
+
"""Return the Ruff validator result from a validate_proposed_file run."""
|
|
47
|
+
for each_result in all_results:
|
|
48
|
+
if each_result.name == "Ruff":
|
|
49
|
+
return each_result
|
|
50
|
+
raise AssertionError("no Ruff validator result was produced")
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def _working_directory_for(cwd_kind: str, outside_repo_directory: Path) -> Path:
|
|
54
|
+
"""Resolve the cwd a parametrized case runs from — repo root or outside it."""
|
|
55
|
+
if cwd_kind == "repo_root":
|
|
56
|
+
project_root = get_project_root()
|
|
57
|
+
assert project_root is not None, "repo root must resolve for this test"
|
|
58
|
+
return project_root
|
|
59
|
+
return outside_repo_directory
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
@pytest.mark.parametrize("cwd_kind", ["repo_root", "outside_repo"])
|
|
63
|
+
def test_staged_non_test_file_reports_b011_from_every_cwd(
|
|
64
|
+
cwd_kind: str, tmp_path: Path, monkeypatch: pytest.MonkeyPatch
|
|
65
|
+
) -> None:
|
|
66
|
+
monkeypatch.chdir(_working_directory_for(cwd_kind, tmp_path))
|
|
67
|
+
|
|
68
|
+
ruff_result = _ruff_result(validate_proposed_file(str(NON_TEST_PROBE_PATH), DIRTY_SOURCE))
|
|
69
|
+
|
|
70
|
+
assert "B011" in ruff_result.output
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def test_staged_test_file_suppresses_b011_via_per_file_ignore(
|
|
74
|
+
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
|
|
75
|
+
) -> None:
|
|
76
|
+
monkeypatch.chdir(tmp_path)
|
|
77
|
+
|
|
78
|
+
non_test_ruff_result = _ruff_result(
|
|
79
|
+
validate_proposed_file(str(NON_TEST_PROBE_PATH), DIRTY_SOURCE)
|
|
80
|
+
)
|
|
81
|
+
test_ruff_result = _ruff_result(validate_proposed_file(str(TEST_PROBE_PATH), DIRTY_SOURCE))
|
|
82
|
+
|
|
83
|
+
assert "B011" in non_test_ruff_result.output
|
|
84
|
+
assert "B011" not in test_ruff_result.output
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
@pytest.mark.parametrize("cwd_kind", ["repo_root", "outside_repo"])
|
|
88
|
+
def test_staged_run_all_validators_suppresses_plw1510_via_path_ignore(
|
|
89
|
+
cwd_kind: str, tmp_path: Path, monkeypatch: pytest.MonkeyPatch
|
|
90
|
+
) -> None:
|
|
91
|
+
monkeypatch.chdir(_working_directory_for(cwd_kind, tmp_path))
|
|
92
|
+
|
|
93
|
+
ruff_result = _ruff_result(
|
|
94
|
+
validate_proposed_file(str(RUN_ALL_VALIDATORS_PATH), UNCHECKED_SUBPROCESS_SOURCE)
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
assert "PLW1510" not in ruff_result.output
|
|
98
|
+
assert ruff_result.passed
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def test_staged_exempt_paths_suppresses_f401_via_path_ignore(
|
|
102
|
+
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
|
|
103
|
+
) -> None:
|
|
104
|
+
monkeypatch.chdir(tmp_path)
|
|
105
|
+
|
|
106
|
+
ruff_result = _ruff_result(
|
|
107
|
+
validate_proposed_file(str(EXEMPT_PATHS_PATH), UNUSED_IMPORT_SOURCE)
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
assert "F401" not in ruff_result.output
|
|
111
|
+
assert ruff_result.passed
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def test_staged_non_carved_path_still_reports_plw1510(
|
|
115
|
+
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
|
|
116
|
+
) -> None:
|
|
117
|
+
monkeypatch.chdir(tmp_path)
|
|
118
|
+
|
|
119
|
+
ruff_result = _ruff_result(
|
|
120
|
+
validate_proposed_file(str(NON_TEST_PROBE_PATH), UNCHECKED_SUBPROCESS_SOURCE)
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
assert "PLW1510" in ruff_result.output
|
package/package.json
CHANGED
|
@@ -12,56 +12,33 @@ paths:
|
|
|
12
12
|
|
|
13
13
|
When a docstring enumerates the behaviors a body applies, the enumeration covers every behavior the body applies. A reader trusts the list to be complete: an item the code applies but the prose omits is a silent gap that misleads every future reader and reviewer.
|
|
14
14
|
|
|
15
|
-
The gate validator `check_docstring_args_match_signature` covers the `Args:` section parameter names. Eleven more gate validators each cover one deterministic slice of the free-form prose. `check_docstring_delegation_summary_enumeration_drift` covers a thin delegating wrapper's docstring summary enumerating actions that the same-named function's summary in the named sibling file omits, compared from both save directions. `check_docstring_names_absent_type_checking_gate` covers a module or function docstring that names a `TYPE_CHECKING` gate-detection step, or a `type-checking-gate` helper family, while no identifier in the module's code carries the `type_checking` marker — the drift where the prose points a reader at a gate the body never performs; drop the `TYPE_CHECKING` gate wording, or add the detection the prose describes. `check_docstring_length_constant_superlative_vs_exact_gate` covers a length-constant module whose docstring describes an integer `*_LENGTH` constant with a superlative or range word (`the longest color string the swatch accepts`) while the only code consuming the constant compares `len(...)` against it with `==`/`!=` — an exact-length gate that rejects every other length — and never with an ordered operator; the check scans the constant module's package tree (its own directory, or the parent package when the module sits in a `config/` subdirectory), so the mismatching consumer may sit in a sibling module. `check_docstring_fallback_branch_coverage` covers a summary that scopes a fallback to a single condition (`only when`, `falls back to ... when`) while the body routes to that same fallback call from two or more distinct early-return guards. `check_class_docstring_names_public_methods` covers a class whose docstring is a single summary line while the class exposes two or more public methods whose names the summary never spells out — the drift where a one-line class summary keeps naming its first feature after the class grows a second public entry point. `check_docstring_no_consumer_claim` covers a producer docstring asserting that no consumer reads its output yet (`producer-only artifact`, `no submission-run consumer reads it yet`) — a transitional claim that drifts the moment a reader lands and contradicts any companion `SKILL.md` that documents the consumer; this is the deterministic slice of the O8 companion-doc producer/consumer drift below. `check_docstring_returns_plural_cardinality` covers a `Returns:` clause that names a dict-key prefix family with a plural noun (`the sheen stops`) while the returned dict literal holds exactly one key in that family (`sheen_mid`) — the drift where a single-key family carries a plural noun, so the prose claims a cardinality of two or more that the dict does not hold. `check_docstring_args_single_line_scope_vs_span` covers an `Args:` entry whose prose scopes a finding to a single named line (`only when its block-anchor line is among the changed lines`) while the body builds a `range(...)` span over the finding's source lines and scopes it through a span-intersection scoper — the drift where the Args entry claims a narrower single-line scope than the span-intersection body applies, so an edit touching any non-anchor line of the span still blocks. `check_docstring_cardinal_count_matches_constant_family` covers a docstring that states a cardinal count of an outcome family (`Covers the four outcome branches: ...`) and lists those members, while the module references more members of the same `UPPER_SNAKE` constant family than the count names (`OUTCOME_OFFENDER_UNREADABLE` is imported and exercised, yet the summary stops at four) — the drift where a summary keeps the old count after the code grows another branch; this gate runs on test modules as well as production modules. `check_docstring_raises_unraisable_largezipfile` covers a `Raises:` clause that names `zipfile.LargeZipFile` while the function opens its `zipfile.ZipFile` writer in a write mode (`w`/`a`/`x`) with `allowZip64` left at its default of True — `zipfile` raises `LargeZipFile` only when an entry needs ZIP64 and `allowZip64` is False, so a writer that allows ZIP64 documents an exception the body cannot produce. `check_docstring_no_network_claim_with_metadata_access` covers a function docstring promising a code path returns `without touching the network` (or a sibling no-network phrase) while the body calls a path-metadata method (`is_file`, `is_dir`, `exists`, `stat`, `lstat`) — on a network share each metadata call is a round-trip over the wire, so a cache-hit path the docstring swore avoids the network still pays a stat on every call; reword the claim to state the path is stat-checked on every call, or short-circuit to the cached path before the share is touched. The remaining free-form prose — `"a field counts as read when ..."`, `"resolves to shared temp only"`, `"strip ceremony, then drop blockquotes"`, and the broader module-responsibility paragraph outside the user-facing-text-scope slice the checklist below names — has no signature, method roster, or single structural shape to compare against, so the gate cannot catch its drift. This rule is the judgment standard for that prose; the audit lane below is the enforcement for everything outside the twelve gated slices.
|
|
16
|
-
|
|
17
|
-
## What to check before you write the docstring
|
|
18
|
-
|
|
19
|
-
Read the body and the docstring side by side:
|
|
20
|
-
|
|
21
|
-
- **Read-source / match-source unions.** A body that computes `read_names = a | b | c` (or any union of "what counts") names each union member in the prose enumeration. A union member the code applies but the prose omits is a gap.
|
|
22
|
-
- **Suppressor / skip lists.** A body with several early returns that suppress the check names each suppressor in the prose.
|
|
23
|
-
- **Shared fallback routes.** A summary that scopes a fallback call to one condition names every condition that reaches that call. When the body routes to the same fallback from two or more early-return guards (`if a is None: fallback(); return` and `if random() < p: fallback(); return`), the prose enumerates both guards. The `check_docstring_fallback_branch_coverage` gate blocks the single-condition form of this drift at Write/Edit time.
|
|
24
|
-
- **Step order.** A docstring that says `A then B then C` matches the call order in the body. A step enumeration that names the body's linear steps also names every corrective step the body guards inside an `if`/`elif` branch (`if not await cancel_and_reinitiate_update(...): return`). The `check_docstring_step_enumeration_dispatch_coverage` gate blocks the branch-guarded-dispatch form of this drift — a step-enumeration docstring that omits a two-or-more-token dispatch step the body guards inside a branch — at Write/Edit time.
|
|
25
|
-
- **Delegation pointer summaries.** A thin delegating method whose docstring names its actions and points at the home of the real body (Apply Russia, review note, publication edits; full doc on `listing_edit_flow`) lists the same actions the delegated function's own summary lists. When an edit moves one action out of the delegated body, the same edit rewords both summaries. The `check_docstring_delegation_summary_enumeration_drift` gate blocks this drift as either side lands: a saved wrapper docstring gets compared against the delegated body beside it, and a saved delegated body gets compared against every neighboring wrapper docstring pointing at it. A conditional bullet in the delegated prose (`re-apply the privacy policy after the upload`) also names every exception the body honors (`unless the reopened button reads Re-register`) — that conditional-completeness slice stays a judgment call for the audit lane.
|
|
26
|
-
- **JS/`.mjs` resume-task enumerations.** A `spawn<Role>Agent` JSDoc that enumerates its sibling `resume<Role>Agent`'s resume tasks in a parenthetical `resume (repair-verify, hardening-verify)` list names every `task === '<name>'` branch the resume body dispatches on. The `check_js_resume_task_enumeration_coverage` gate blocks the JavaScript form of this drift — a spawn JSDoc whose resume enumeration omits a dispatched task — at Write/Edit time. This is the `.mjs` slice of the same Category O6 standard the Python gates carry; the Python AST docstring gates never inspect JavaScript source.
|
|
27
|
-
- **JS/`.mjs` `@returns` object with a schema-less branch.** A `function` whose JSDoc `@returns {Promise<object>}` promises a structured object names a return type every branch honors. When the body returns one agent-spawn helper both with a `schema` options object and without one, the schema-less branch resolves to a transcript string, not the object the JSDoc claims. The `check_js_returns_object_schemaless_branch` gate blocks this drift — a `Promise<object>` JSDoc whose body returns the same helper with and without a `schema` key — at Write/Edit time. This is the `.mjs` slice of the same Category O6 standard the Python gates carry; the Python AST docstring gates never inspect JavaScript source.
|
|
28
|
-
- **JS/`.mjs` sibling return-object key drift.** Every return path of a function that yields the same record carries the same keys. When an early return in a workflow body omits exactly one key its sibling tail return carries (`allDeferredPrs`), a caller reading that key off the short path gets undefined where the documented contract and the sibling return both promise it. The `check_js_sibling_return_object_key_drift` gate blocks this drift — a `return { ... }` object literal whose key set misses exactly one key of a sibling return in the same function or module scope, with discriminated-union variants and two-or-more-key exit shapes left alone — at Write/Edit time. This is the `.mjs` slice of the same Category O standard the Python gates carry; the Python AST docstring gates never inspect JavaScript source.
|
|
29
|
-
- **JS/`.mjs` bare-flag return directive vs a stated full-result contract.** A converge-workflow preamble that states a full result-object contract (`{sha, clean:false, down:true, findings:[]}`) and adds "never a bare down flag" matches any `return <flag>: true`/`false` prose directive elsewhere in the file that repeats a status flag the stated contract rules out. When a step's prose says to "return down: true" once a budget runs out, that directive repeats the bare flag the preamble rules out — a StructuredOutput run whose schema needs every field would reject a lone `{down:true}`. The `check_js_bare_flag_return_directive` gate blocks this drift — a `return <name>: true`/`false` prose directive anywhere in the file that repeats a status flag a stated contract rules out, with no proximity or ordering check between the two — at Write/Edit time. This is the `.mjs` slice of the same Category O6 standard the Python gates carry; the Python AST docstring gates never inspect JavaScript source.
|
|
30
|
-
- **Returns-clause cardinality.** A `Returns:` clause that names a dict-key prefix family with a plural noun (`the sheen stops`) matches the count of keys in that family in the returned dict literal. When the dict holds one key in the family (`sheen_mid`), the noun is singular (`the sheen stop`); a plural noun there claims two or more entries the dict does not hold. The `check_docstring_returns_plural_cardinality` gate blocks the single-key-with-plural-noun form of this drift at Write/Edit time.
|
|
31
|
-
- **Length-constant superlative vs exact gate.** A module docstring that describes an integer `*_LENGTH` constant with a superlative or range word (`the longest color string the swatch accepts`, `no longer than`) matches how the code consumes the constant. When the only consumer compares `len(...)` against the constant with `==`/`!=` — an exact-length gate where every other length is rejected, not accepted at a shorter length — the superlative prose claims a range of accepted lengths the code never allows. State the exact required length (`the exact #AARRGGBB length`), not a longest/range form. The `check_docstring_length_constant_superlative_vs_exact_gate` gate blocks this drift at Write/Edit time, scanning the constant module's package tree so it sees a consumer that lives in a sibling module; a constant genuinely used as a ceiling (`len(x) <= LIMIT`) is left alone.
|
|
32
|
-
- **Args single-line scope vs span body.** An `Args:` entry that scopes a finding to one named line (`a finding blocks only when its block-anchor line is among the changed lines`) matches the line breadth the body scopes by. When the body builds a `range(...)` span over the finding's source lines and scopes it through a span-intersection scoper that blocks when any line of the span is among the changed lines, the single-line Args wording understates the scope: an edit touching a non-anchor line of the span still blocks. State the Args entry on the same span breadth the body uses (`a finding blocks when any line of its block span is among the changed lines`). The `check_docstring_args_single_line_scope_vs_span` gate blocks the single-line-Args-over-span-body form of this drift at Write/Edit time.
|
|
33
|
-
- **Cardinal-count enumerations.** A docstring that states a count of an outcome family (`the four outcome branches`) and lists those members names every member of that family the module references. When the module imports and exercises a fifth `OUTCOME_*` constant the summary leaves out, the count and the list both under-describe the code. The `check_docstring_cardinal_count_matches_constant_family` gate blocks this drift — a cardinal-count docstring that names two or more members of a referenced `UPPER_SNAKE` constant family, leaves at least one referenced member out, and states a count that differs from the family size (a count above it and one below it both trip) — at Write/Edit time, on test modules as well as production modules.
|
|
34
|
-
- **Raises-clause reachability for `LargeZipFile`.** A `Raises:` clause that names `zipfile.LargeZipFile` matches a writer the body opens with ZIP64 forbidden. `zipfile` raises `LargeZipFile` only when an entry needs ZIP64 and `allowZip64` is False; a function that opens its `zipfile.ZipFile` writer in a write mode (`w`/`a`/`x`) with `allowZip64` at its default of True allows ZIP64 and never raises it, so the clause documents an unreachable exception. Drop the entry, or pass `allowZip64=False` when forbidding ZIP64 is the goal. The `check_docstring_raises_unraisable_largezipfile` gate blocks the default-ZIP64-writer form of this drift at Write/Edit time; a writer that forbids ZIP64 on any open, a read-only open, and a function that opens no writer are all left alone.
|
|
35
|
-
- **Module summary scope versus data-schema constants.** A module whose one-line docstring scopes its contents to user-facing text (`User-facing strings: CLI flag names, help text, and log messages`) names every category of constant the body holds. When the body also defines serialization field keys (`JSONL_FIELD_*`), run-metadata schema keys (`RUN_METADATA_CLI_ARG_KEY_*`), or runtime config (`STDOUT_ENCODING`, `MAIN_LOGGING_FORMAT_STRING`), the strings-only summary under-describes the module — the module-responsibility drift the repo flags. Broaden the summary to name the data-schema keys and runtime config. The `check_module_docstring_scope_omits_data_schema_constants` gate blocks this drift at Write/Edit time, and fires only when the summary claims a user-facing-text scope and names no data-schema or runtime-config category, so a summary that already names `field keys`, `schema`, or `runtime config` passes.
|
|
36
|
-
- **Field meaning: run mode versus per record.** A dataclass or `TypedDict` field documented in the class `Attributes:` block states what the field means for one record. When the code sets that field the same way for every record (a run-mode flag such as `is_dry_run = not is_execute` at each write site), the description states the run-mode meaning, not a per-record outcome. A field named `is_dry_run` documented as `True when no STP was written` reads as a per-record write result, but the value tracks the run mode, so a record that writes no file during an execute run still stores `False`. State the run-mode meaning the assignment gives the field. The `check_docstring_field_runmode_outcome` gate blocks the single-file shape of this drift at Write/Edit time — an `Attributes:` entry for a run-mode flag field (a name carrying `dry_run`) whose description carries a per-record write-outcome phrase and no run-mode phrase. The assignment that sets the field sits in another module, out of reach of that single-file gate, so any shape the gate cannot key on stays an O6 audit-lane judgment finding.
|
|
37
|
-
- **Predicate breadth.** A boolean helper whose prose promises a narrow check accepts only the inputs the prose names — no broader input class the name and prose do not mention.
|
|
38
|
-
- **Exclusion-clause distinguisher.** A docstring sentence that says a named category of input "are not" / "is not" the thing the function flags (`plain logging, screenshot, or method-on-local calls inside a branch are not dispatch steps`) keys the exclusion to the same axis the body's classification keys on. When the body decides on one axis (a call sits in an `If.test` guard versus a plain statement) but the prose excludes on a different axis (the call's receiver shape — a method on a local), the exclusion clause names a category the body still flags: a guarded method-on-local call is flagged even though the prose lists method-on-local calls as excluded. Read the body's actual branch condition, then state the exclusion on that same axis (`plain (unguarded) calls inside a branch body are not dispatch steps`), so every member the prose excludes is a member the body also excludes.
|
|
39
|
-
- **Companion-doc ordering and content claims.** A `SKILL.md` (or sibling `.md`) sentence that names a produced artifact and claims its order (`sorted`, `alphabetical`, `in sorted order`) or its content (`the at-risk names`, `just the current set`) matches the producer function's docstring and body for that same artifact. A producer that builds the artifact by merging stored names with new names and appending — preserving file order, not re-sorting the union — leaves a doc that still says `sorted` drifted on both counts: the order claim is wrong, and the content claim hides the merged-in prior entries. When the producer's ordering or union changes, the same change updates the companion doc. The two move together in one commit, even when the producer edit does not touch the `.md` file.
|
|
40
|
-
- **TYPE_CHECKING gate claim vs code.** A docstring that names a `TYPE_CHECKING` gate-detection step, or a `type-checking-gate` helper family, matches a module whose code handles TYPE_CHECKING. When no identifier in the body carries the `type_checking` marker — no `TYPE_CHECKING` load, import alias, attribute, or helper name — the prose points a reader at a gate the module never performs. State what the module does, or add the detection the prose describes. The `check_docstring_names_absent_type_checking_gate` gate blocks this drift at Write/Edit time, and covers hook infrastructure, where the import-scan gates that carry this drift class live.
|
|
41
|
-
|
|
42
15
|
When the body changes the set of behaviors it applies, the same edit updates the prose enumeration. The two move together in one commit.
|
|
43
16
|
|
|
44
|
-
##
|
|
17
|
+
## Write-time checks
|
|
45
18
|
|
|
46
|
-
|
|
19
|
+
Read the body and the docstring side by side. Apply each check that matches the prose:
|
|
47
20
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
)
|
|
55
|
-
|
|
21
|
+
- **Unions / match sources** — every member of a "what counts" union appears in the prose.
|
|
22
|
+
- **Suppressors / skip lists** — every early-return suppressor appears in the prose.
|
|
23
|
+
- **Step order** — named order matches call order; branch-guarded corrective steps are named too.
|
|
24
|
+
- **Shared fallbacks** — every condition that reaches a fallback call is named.
|
|
25
|
+
- **Predicate breadth** — the body accepts only the inputs the prose names.
|
|
26
|
+
- **Exclusion axis** — an exclusion clause keys on the same axis the body classifies on.
|
|
27
|
+
- **Companion docs** — a `SKILL.md` (or sibling) order/content claim matches the producer body.
|
|
28
|
+
- **Returns / Raises / Note claims** — each free-form claim matches the body.
|
|
56
29
|
|
|
57
|
-
|
|
30
|
+
Many deterministic shapes of this drift have Write/Edit gates in `packages/claude-dev-env/hooks/blocking/code_rules_docstrings.py` (and the JS/`.mjs` slices in `code_rules_imports_logging.py`). Free-form rest is judgment.
|
|
58
31
|
|
|
59
|
-
##
|
|
32
|
+
## Full standard
|
|
60
33
|
|
|
61
|
-
|
|
34
|
+
The full Category O judgment standard — sub-buckets O1–O9, the complete write-time gate inventory, free-form checklists, and worked examples — lives in:
|
|
62
35
|
|
|
63
|
-
|
|
36
|
+
`packages/claude-dev-env/audit-rubrics/category_rubrics/category-o-docstring-vs-impl-drift.md`
|
|
64
37
|
|
|
65
|
-
##
|
|
38
|
+
## Division of labor
|
|
66
39
|
|
|
67
|
-
|
|
40
|
+
| Surface | Role |
|
|
41
|
+
|---|---|
|
|
42
|
+
| **This rule** | Always-on write-time policy and the compact checklist above. |
|
|
43
|
+
| Category O rubric | Single thick source for the full standard (on demand). |
|
|
44
|
+
| Category O prompt | Audit template; points at the rubric for judgment. |
|
|
@@ -26,6 +26,13 @@ Handle the two kinds of content differently:
|
|
|
26
26
|
|
|
27
27
|
Both slash directions count.
|
|
28
28
|
|
|
29
|
+
The worktree and job-scratch entries count as a path when either:
|
|
30
|
+
|
|
31
|
+
- A `/` or `\` sits right before them — a drive-letter path (`C:\Users\me\.claude\worktrees\wt\f.py`), a home path (`~/.claude/worktrees/wt`), or a POSIX absolute path (`/home/me/.claude-editor/jobs/j/log.txt`).
|
|
32
|
+
- A path segment follows them — a relative path that names a child under that directory (`see .claude/worktrees/wt-1/notes.md`, a markdown link target, or `cd .claude/worktrees/wt-199`).
|
|
33
|
+
|
|
34
|
+
With neither anchor the text names the directory rather than something inside it, and it posts — a quoted config constant, a backticked directory name, or a placeholder form such as `.claude/worktrees/<name>`. Un-backticked prose that puts a word immediately after the marker reads the same as a relative path and is blocked; the placeholder form is the documented escape.
|
|
35
|
+
|
|
29
36
|
## Enforcement
|
|
30
37
|
|
|
31
38
|
The `volatile_path_in_post_blocker` PreToolUse hook reads the body of each `gh` post command and each GitHub MCP post call, scans it for these markers, and blocks the post when it finds one. For a `--body-file`, the hook reads the file and scans its contents, so writing the body to a temp file and passing it with `--body-file` stays allowed — what the hook rejects is a volatile path inside the text that gets posted.
|
package/scripts/CLAUDE.md
CHANGED
|
@@ -6,7 +6,8 @@ Utility scripts installed into `~/.claude/scripts/` by `bin/install.mjs`. Each s
|
|
|
6
6
|
|
|
7
7
|
| File | Purpose |
|
|
8
8
|
|---|---|
|
|
9
|
-
| `claude_chain_runner.py` | Runs a `claude` invocation through a
|
|
9
|
+
| `claude_chain_runner.py` | Runs a `claude` invocation through a usage-ranked fallback chain (`~/.claude/claude-chain.json`): probes weekly remaining once via `claude_chain_usage` / the usage-pause OAuth probe, tries the highest-remaining account first, and falls over to the next ranked binary only on a usage-limit failure; usable as an imported module (`run_claude`) or a CLI. Copy `claude-chain.example.json` to `~/.claude/claude-chain.json` and list your account binaries. Optional per-entry `credentials_path` names that account's OAuth credentials file for the usage probe |
|
|
10
|
+
| `claude_chain_usage.py` | Reports remaining weekly usage for every account in `~/.claude/claude-chain.json` via the usage-pause OAuth probe; prints JSON (`accounts` with `weekly_remaining_percent` or null plus `error`); importable `report_chain_weekly_usage` and `rank_accounts_by_weekly_remaining` (highest remaining first, ties keep config order, unmeasurable last). The chain runner consumes this ranking for try order |
|
|
10
11
|
| `gh_artifact_upload.py` | Uploads a file to a repo's durable `artifacts` prerelease under a timestamped asset name and prints the permanent download URL a GitHub post can link |
|
|
11
12
|
| `grok_headless_runner.py` | Runs one worker as headless `grok`: builds argv, mints a unique leader socket, captures streams, kills on timeout with grace, classifies ok/usage_limit/auth_failure/timeout/error; imported by `spawn_grok_batch.py` |
|
|
12
13
|
| `grok_worker_preflight.py` | Soft gate for the headless grok tier: binary on PATH, `grok models` auth, install manifest + role agents, opt-in cached live ping; non-zero exit is fallthrough, not failure |
|
|
@@ -1,8 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"chain": [
|
|
3
3
|
{ "command": "claude", "extra_args": [] },
|
|
4
|
-
{
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
{
|
|
5
|
+
"command": "claude-1",
|
|
6
|
+
"extra_args": [],
|
|
7
|
+
"credentials_path": "/path/to/account-1/.credentials.json"
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"command": "claude-2",
|
|
11
|
+
"extra_args": [],
|
|
12
|
+
"credentials_path": "/path/to/account-2/.credentials.json"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"command": "claude-3",
|
|
16
|
+
"extra_args": [],
|
|
17
|
+
"credentials_path": "/path/to/account-3/.credentials.json"
|
|
18
|
+
}
|
|
7
19
|
]
|
|
8
20
|
}
|