claude-dev-env 1.90.0 → 1.92.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.
Files changed (63) hide show
  1. package/CLAUDE.md +0 -13
  2. package/agents/clean-coder.md +2 -2
  3. package/agents/code-verifier.md +0 -1
  4. package/agents/test_agent_frontmatter.py +78 -0
  5. package/audit-rubrics/category_rubrics/category-j-code-rules-compliance.md +1 -1
  6. package/audit-rubrics/prompts/category-j-code-rules-compliance.md +1 -1
  7. package/bin/install.mjs +1 -0
  8. package/docs/CODE_RULES.md +2 -2
  9. package/hooks/blocking/CLAUDE.md +5 -2
  10. package/hooks/blocking/code_rules_comments.py +2 -2
  11. package/hooks/blocking/code_verifier_spawn_preflight_gate.py +44 -0
  12. package/hooks/blocking/config/verified_commit_constants.py +2 -0
  13. package/hooks/blocking/conftest.py +115 -0
  14. package/hooks/blocking/nas_ssh_binary_enforcer.py +191 -0
  15. package/hooks/blocking/pr_description_enforcer.py +46 -22
  16. package/hooks/blocking/pr_description_pr_number.py +5 -3
  17. package/hooks/blocking/pr_description_proof_of_work.py +367 -0
  18. package/hooks/blocking/precommit_code_rules_gate.py +5 -1
  19. package/hooks/blocking/test_code_rules_enforcer_comment_string_awareness.py +8 -2
  20. package/hooks/blocking/test_code_verifier_spawn_preflight_gate.py +71 -0
  21. package/hooks/blocking/test_nas_ssh_binary_enforcer.py +168 -0
  22. package/hooks/blocking/test_pr_description_enforcer_proof_gate.py +175 -0
  23. package/hooks/blocking/test_pr_description_proof_of_work.py +162 -0
  24. package/hooks/blocking/test_precommit_code_rules_gate.py +89 -0
  25. package/hooks/blocking/test_verdict_directory_write_blocker.py +4 -0
  26. package/hooks/blocking/test_verification_verdict_store.py +11 -0
  27. package/hooks/blocking/test_verified_commit_config_bootstrap.py +49 -0
  28. package/hooks/blocking/test_verified_commit_gate.py +11 -0
  29. package/hooks/blocking/test_verifier_verdict_minter.py +11 -0
  30. package/hooks/blocking/verdict_directory_write_blocker.py +6 -0
  31. package/hooks/blocking/verification_verdict_store.py +73 -5
  32. package/hooks/blocking/verified_commit_config_bootstrap.py +51 -0
  33. package/hooks/blocking/verified_commit_gate.py +6 -0
  34. package/hooks/blocking/verifier_verdict_minter.py +6 -0
  35. package/hooks/hooks.json +7 -2
  36. package/hooks/hooks_constants/CLAUDE.md +2 -0
  37. package/hooks/hooks_constants/code_rules_path_utils_constants.py +1 -0
  38. package/hooks/hooks_constants/code_verifier_spawn_preflight_gate_constants.py +3 -0
  39. package/hooks/hooks_constants/nas_ssh_binary_enforcer_constants.py +59 -0
  40. package/hooks/hooks_constants/pr_description_enforcer_constants.py +2 -0
  41. package/hooks/hooks_constants/pr_description_proof_of_work_constants.py +111 -0
  42. package/hooks/validators/run_all_validators.py +216 -4
  43. package/hooks/validators/test_run_all_validators_pretooluse.py +102 -0
  44. package/package.json +1 -1
  45. package/rules/CLAUDE.md +2 -0
  46. package/rules/nas-ssh-invocation.md +21 -0
  47. package/rules/proof-of-work-pr-comments.md +26 -0
  48. package/scripts/CLAUDE.md +1 -0
  49. package/scripts/claude-chain.example.json +8 -0
  50. package/scripts/claude_chain_runner.py +400 -0
  51. package/scripts/dev_env_scripts_constants/CLAUDE.md +1 -0
  52. package/scripts/dev_env_scripts_constants/claude_chain_constants.py +124 -0
  53. package/scripts/sync_to_cursor/rules.py +1 -1
  54. package/scripts/test_claude_chain_runner.py +472 -0
  55. package/skills/CLAUDE.md +3 -0
  56. package/skills/team-advisor/SKILL.md +188 -0
  57. package/skills/team-advisor-refresh/SKILL.md +25 -0
  58. package/skills/usage-pause/SKILL.md +108 -0
  59. package/skills/usage-pause/scripts/resolve_usage_window.py +462 -0
  60. package/skills/usage-pause/scripts/test_resolve_usage_window.py +278 -0
  61. package/skills/usage-pause/scripts/usage_pause_constants/__init__.py +1 -0
  62. package/skills/usage-pause/scripts/usage_pause_constants/resolve_usage_window_constants.py +65 -0
  63. package/system-prompts/software-engineer.xml +3 -2
@@ -0,0 +1,168 @@
1
+ """Unit tests for nas-ssh-binary-enforcer PreToolUse hook."""
2
+
3
+ import importlib.util
4
+ import pathlib
5
+ import sys
6
+
7
+ _HOOK_DIR = pathlib.Path(__file__).parent
8
+ if str(_HOOK_DIR) not in sys.path:
9
+ sys.path.insert(0, str(_HOOK_DIR))
10
+
11
+ hook_spec = importlib.util.spec_from_file_location(
12
+ "nas_ssh_binary_enforcer",
13
+ _HOOK_DIR / "nas_ssh_binary_enforcer.py",
14
+ )
15
+ assert hook_spec is not None
16
+ assert hook_spec.loader is not None
17
+ hook_module = importlib.util.module_from_spec(hook_spec)
18
+ hook_spec.loader.exec_module(hook_module)
19
+ _find_nas_ssh_violation = hook_module._find_nas_ssh_violation
20
+
21
+ from hooks_constants.nas_ssh_binary_enforcer_constants import (
22
+ BARE_SSH_BINARY_MESSAGE as _BARE_SSH_BINARY_MESSAGE,
23
+ MISSING_BATCH_MODE_MESSAGE as _MISSING_BATCH_MODE_MESSAGE,
24
+ )
25
+
26
+
27
+ def test_bare_ssh_to_nas_is_denied_with_binary_message() -> None:
28
+ assert (
29
+ _find_nas_ssh_violation('ssh -p 9222 jon@192.168.1.100 "ls /volume1"')
30
+ == _BARE_SSH_BINARY_MESSAGE
31
+ )
32
+
33
+
34
+ def test_bare_scp_to_nas_is_denied() -> None:
35
+ assert (
36
+ _find_nas_ssh_violation("scp -P 9222 file.txt jon@192.168.1.100:/volume1/")
37
+ == _BARE_SSH_BINARY_MESSAGE
38
+ )
39
+
40
+
41
+ def test_bare_sftp_to_nas_is_denied() -> None:
42
+ assert _find_nas_ssh_violation("sftp -P 9222 jon@192.168.1.100") == _BARE_SSH_BINARY_MESSAGE
43
+
44
+
45
+ def test_bare_ssh_to_nas_behind_launcher_wrapper_is_denied() -> None:
46
+ assert (
47
+ _find_nas_ssh_violation('timeout 10 ssh -p 9222 jon@192.168.1.100 "uptime"')
48
+ == _BARE_SSH_BINARY_MESSAGE
49
+ )
50
+
51
+
52
+ def test_bare_ssh_to_nas_after_shell_operator_is_denied() -> None:
53
+ assert (
54
+ _find_nas_ssh_violation('cd /tmp && ssh -p 9222 jon@192.168.1.100 "uptime"')
55
+ == _BARE_SSH_BINARY_MESSAGE
56
+ )
57
+
58
+
59
+ def test_bare_ssh_to_nas_after_glued_operator_is_denied() -> None:
60
+ assert (
61
+ _find_nas_ssh_violation('true;ssh -p 9222 jon@192.168.1.100 "uptime"')
62
+ == _BARE_SSH_BINARY_MESSAGE
63
+ )
64
+
65
+
66
+ def test_bare_ssh_to_nas_after_pipe_ampersand_operator_is_denied() -> None:
67
+ assert (
68
+ _find_nas_ssh_violation('echo start |& ssh -p 9222 jon@192.168.1.100 "echo hi"')
69
+ == _BARE_SSH_BINARY_MESSAGE
70
+ )
71
+
72
+
73
+ def test_full_openssh_binary_to_nas_without_batchmode_is_denied() -> None:
74
+ assert (
75
+ _find_nas_ssh_violation(
76
+ '"/c/Windows/System32/OpenSSH/ssh.exe" -o ConnectTimeout=10 '
77
+ '-p 9222 jon@192.168.1.100 "uptime"'
78
+ )
79
+ == _MISSING_BATCH_MODE_MESSAGE
80
+ )
81
+
82
+
83
+ def test_full_openssh_scp_to_nas_without_batchmode_is_denied() -> None:
84
+ assert (
85
+ _find_nas_ssh_violation(
86
+ '"/c/Windows/System32/OpenSSH/scp.exe" -P 9222 file.txt jon@192.168.1.100:/volume1/'
87
+ )
88
+ == _MISSING_BATCH_MODE_MESSAGE
89
+ )
90
+
91
+
92
+ def test_full_openssh_binary_to_nas_with_batchmode_is_allowed() -> None:
93
+ assert (
94
+ _find_nas_ssh_violation(
95
+ '"/c/Windows/System32/OpenSSH/ssh.exe" -o BatchMode=yes '
96
+ '-o ConnectTimeout=10 -p 9222 jon@192.168.1.100 "uptime"'
97
+ )
98
+ is None
99
+ )
100
+
101
+
102
+ def test_full_openssh_binary_glued_batchmode_flag_is_allowed() -> None:
103
+ assert (
104
+ _find_nas_ssh_violation(
105
+ '"/c/Windows/System32/OpenSSH/ssh.exe" -oBatchMode=yes '
106
+ '-p 9222 jon@192.168.1.100 "uptime"'
107
+ )
108
+ is None
109
+ )
110
+
111
+
112
+ def test_bare_ssh_to_other_host_is_allowed() -> None:
113
+ assert _find_nas_ssh_violation('ssh -p 22 jon@example.com "uptime"') is None
114
+
115
+
116
+ def test_full_openssh_binary_to_other_host_without_batchmode_is_allowed() -> None:
117
+ assert (
118
+ _find_nas_ssh_violation(
119
+ '"/c/Windows/System32/OpenSSH/ssh.exe" -p 22 jon@example.com "uptime"'
120
+ )
121
+ is None
122
+ )
123
+
124
+
125
+ def test_nas_ip_as_echoed_data_is_allowed() -> None:
126
+ assert _find_nas_ssh_violation('echo "connect via ssh to 192.168.1.100"') is None
127
+
128
+
129
+ def test_nas_ip_mentioned_without_ssh_command_word_is_allowed() -> None:
130
+ assert _find_nas_ssh_violation("ping -c 1 192.168.1.100") is None
131
+
132
+
133
+ def test_ssh_family_word_only_in_remote_command_argument_is_allowed() -> None:
134
+ assert (
135
+ _find_nas_ssh_violation(
136
+ '"/c/Windows/System32/OpenSSH/ssh.exe" -o BatchMode=yes '
137
+ '-p 9222 jon@192.168.1.100 "grep ssh /etc/config"'
138
+ )
139
+ is None
140
+ )
141
+
142
+
143
+ def test_nas_ip_in_different_segment_than_ssh_is_allowed() -> None:
144
+ assert _find_nas_ssh_violation('echo 192.168.1.100 && ssh -p 22 jon@example.com "id"') is None
145
+
146
+
147
+ def test_ssh_to_other_host_with_nas_ip_in_remote_command_is_allowed() -> None:
148
+ assert (
149
+ _find_nas_ssh_violation('ssh -p 22 jon@example.com "ping -c1 192.168.1.100"') is None
150
+ )
151
+
152
+
153
+ def test_scp_to_other_host_with_nas_ip_in_remote_path_is_allowed() -> None:
154
+ assert (
155
+ _find_nas_ssh_violation("scp -P 22 f.txt jon@example.com:/backup/192.168.1.100/") is None
156
+ )
157
+
158
+
159
+ def test_similar_ip_prefix_is_not_matched() -> None:
160
+ assert _find_nas_ssh_violation('ssh -p 22 jon@192.168.1.1000 "id"') is None
161
+
162
+
163
+ def test_empty_command_is_allowed() -> None:
164
+ assert _find_nas_ssh_violation("") is None
165
+
166
+
167
+ def test_unbalanced_quotes_command_is_allowed() -> None:
168
+ assert _find_nas_ssh_violation("ssh 'unterminated 192.168.1.100") is None
@@ -0,0 +1,175 @@
1
+ """Entry-flow tests for the proof-of-work gates in pr_description_enforcer.
2
+
3
+ Each test drives hook main() with a real Bash PreToolUse payload on stdin,
4
+ mirroring test_pr_description_enforcer.py. The single gh subprocess boundary
5
+ in pr_description_proof_of_work is patched with a fake runner, so command
6
+ recognition, body extraction, and the proof audit run the production paths.
7
+ """
8
+
9
+ import contextlib
10
+ import importlib.util
11
+ import io
12
+ import json
13
+ import pathlib
14
+ import sys
15
+ from unittest.mock import patch
16
+
17
+ import pytest
18
+
19
+ _HOOK_DIR = pathlib.Path(__file__).parent
20
+ _HOOKS_ROOT = _HOOK_DIR.parent
21
+ if str(_HOOKS_ROOT) not in sys.path:
22
+ sys.path.insert(0, str(_HOOKS_ROOT))
23
+ if str(_HOOK_DIR) not in sys.path:
24
+ sys.path.insert(0, str(_HOOK_DIR))
25
+
26
+ from blocking import pr_description_proof_of_work as proof_module # noqa: E402
27
+ from blocking import pr_description_readability as readability_module # noqa: E402
28
+
29
+ hook_spec = importlib.util.spec_from_file_location(
30
+ "pr_description_enforcer_proof_gate",
31
+ _HOOK_DIR / "pr_description_enforcer.py",
32
+ )
33
+ assert hook_spec is not None
34
+ assert hook_spec.loader is not None
35
+ hook_module = importlib.util.module_from_spec(hook_spec)
36
+ hook_spec.loader.exec_module(hook_module)
37
+
38
+
39
+ @pytest.fixture(autouse=True)
40
+ def _isolate_readability_state(
41
+ tmp_path_factory: pytest.TempPathFactory, monkeypatch: pytest.MonkeyPatch
42
+ ) -> None:
43
+ """Redirect the three readability state files to per-test temp paths.
44
+
45
+ The enabled file is written with enabled=False so readability scoring
46
+ stays out of these entry-flow tests and the live state directory is
47
+ never touched.
48
+ """
49
+ per_test_state_dir = tmp_path_factory.mktemp("proof_gate_readability_state")
50
+ monkeypatch.setattr(
51
+ readability_module, "READABILITY_STATE_FILE", per_test_state_dir / "strikes.json"
52
+ )
53
+ monkeypatch.setattr(
54
+ readability_module,
55
+ "READABILITY_THRESHOLD_OVERRIDE_FILE",
56
+ per_test_state_dir / "overrides.json",
57
+ )
58
+ enabled_path = per_test_state_dir / "enabled.json"
59
+ enabled_path.write_text(json.dumps({"enabled": False}))
60
+ monkeypatch.setattr(readability_module, "READABILITY_ENABLED_STATE_FILE", enabled_path)
61
+
62
+
63
+ PASSING_PROOF_COMMENT_BODY = (
64
+ "## Summary\n\n"
65
+ "Recolored the launcher icons and checked every produced asset by hand "
66
+ "against the palette the plan names.\n\n"
67
+ "## Verification\n\n"
68
+ "```\n"
69
+ "C:\\Python313\\python.exe scripts/recolor.py --input themes/dawn\n"
70
+ "```\n\n"
71
+ "| Artifact | Measured |\n"
72
+ "| --- | --- |\n"
73
+ "| icons.zip | 48 files, 412,993 bytes |\n\n"
74
+ "This advances phase 2 of issue #12.\n\n"
75
+ "Known gap: the offline proof cannot show the on-device rendering; the "
76
+ "store preview covers that.\n"
77
+ )
78
+
79
+ ORDINARY_COMMENT_BODY = (
80
+ "The retry logic here mirrors what the uploader does for chunked "
81
+ "transfers, so the two stay in step."
82
+ )
83
+
84
+
85
+ def _run_hook_main_with_command(command: str) -> str:
86
+ hook_input_json = json.dumps({"tool_name": "Bash", "tool_input": {"command": command}})
87
+ captured_stdout = io.StringIO()
88
+ with (
89
+ patch("sys.stdin", io.StringIO(hook_input_json)),
90
+ patch("sys.stdout", captured_stdout),
91
+ contextlib.suppress(SystemExit),
92
+ ):
93
+ hook_module.main()
94
+ return captured_stdout.getvalue()
95
+
96
+
97
+ def _install_fake_gh_responses(monkeypatch, all_comment_bodies, all_diff_names):
98
+ all_comment_records = [{"body": each_body} for each_body in all_comment_bodies]
99
+
100
+ def _fake_run_gh_command(all_gh_arguments):
101
+ if all_gh_arguments and all_gh_arguments[0] == "api":
102
+ return json.dumps([all_comment_records])
103
+ if "--name-only" in all_gh_arguments:
104
+ return "\n".join(all_diff_names)
105
+ if list(all_gh_arguments[:2]) == ["pr", "view"]:
106
+ return json.dumps({"number": 123})
107
+ if list(all_gh_arguments[:2]) == ["pr", "diff"]:
108
+ return ""
109
+ return None
110
+
111
+ monkeypatch.setattr(proof_module, "_run_gh_command", _fake_run_gh_command)
112
+
113
+
114
+ def test_main_blocks_gh_pr_ready_without_proof_comment(monkeypatch: pytest.MonkeyPatch) -> None:
115
+ _install_fake_gh_responses(monkeypatch, [], ["src/parser.py"])
116
+ decision_output = _run_hook_main_with_command("gh pr ready 123")
117
+ assert "deny" in decision_output
118
+ assert "proof" in decision_output.lower()
119
+
120
+
121
+ def test_main_allows_gh_pr_ready_with_passing_proof_comment(
122
+ monkeypatch: pytest.MonkeyPatch,
123
+ ) -> None:
124
+ _install_fake_gh_responses(monkeypatch, [PASSING_PROOF_COMMENT_BODY], ["src/parser.py"])
125
+ decision_output = _run_hook_main_with_command("gh pr ready 123")
126
+ assert "deny" not in decision_output
127
+
128
+
129
+ def test_main_allows_complete_proof_comment_post(
130
+ tmp_path: pathlib.Path, monkeypatch: pytest.MonkeyPatch
131
+ ) -> None:
132
+ _install_fake_gh_responses(monkeypatch, [], ["src/parser.py"])
133
+ body_file = tmp_path / "proof.md"
134
+ body_file.write_text(PASSING_PROOF_COMMENT_BODY)
135
+ decision_output = _run_hook_main_with_command(f"gh pr comment 123 --body-file {body_file}")
136
+ assert "deny" not in decision_output
137
+
138
+
139
+ def test_main_blocks_proof_comment_missing_visual_on_visual_change(
140
+ tmp_path: pathlib.Path, monkeypatch: pytest.MonkeyPatch
141
+ ) -> None:
142
+ _install_fake_gh_responses(monkeypatch, [], ["assets/icon.png"])
143
+ body_file = tmp_path / "proof.md"
144
+ body_file.write_text(PASSING_PROOF_COMMENT_BODY)
145
+ decision_output = _run_hook_main_with_command(f"gh pr comment 123 --body-file {body_file}")
146
+ assert "deny" in decision_output
147
+ assert "visual" in decision_output
148
+
149
+
150
+ def test_main_leaves_ordinary_comment_untouched(
151
+ tmp_path: pathlib.Path, monkeypatch: pytest.MonkeyPatch
152
+ ) -> None:
153
+ all_recorded_calls: list[list[str]] = []
154
+
155
+ def _recording_run_gh_command(all_gh_arguments):
156
+ all_recorded_calls.append(list(all_gh_arguments))
157
+
158
+ monkeypatch.setattr(proof_module, "_run_gh_command", _recording_run_gh_command)
159
+ body_file = tmp_path / "comment.md"
160
+ body_file.write_text(ORDINARY_COMMENT_BODY)
161
+ decision_output = _run_hook_main_with_command(f"gh pr comment 123 --body-file {body_file}")
162
+ assert "deny" not in decision_output
163
+ assert all_recorded_calls == []
164
+
165
+
166
+ def test_main_allows_gh_pr_ready_undo_without_queries(monkeypatch: pytest.MonkeyPatch) -> None:
167
+ all_recorded_calls: list[list[str]] = []
168
+
169
+ def _recording_run_gh_command(all_gh_arguments):
170
+ all_recorded_calls.append(list(all_gh_arguments))
171
+
172
+ monkeypatch.setattr(proof_module, "_run_gh_command", _recording_run_gh_command)
173
+ decision_output = _run_hook_main_with_command("gh pr ready 123 --undo")
174
+ assert "deny" not in decision_output
175
+ assert all_recorded_calls == []
@@ -0,0 +1,162 @@
1
+ """Behavior tests for the proof-of-work comment audit and gh pr ready gate.
2
+
3
+ Each test drives the public audit surface of pr_description_proof_of_work
4
+ with real comment bodies. The single gh subprocess boundary is patched with
5
+ a fake runner, so parsing, part detection, and gate decisions all run the
6
+ production code paths.
7
+ """
8
+
9
+ import json
10
+ import pathlib
11
+ import sys
12
+
13
+ import pytest
14
+
15
+ _HOOK_DIR = pathlib.Path(__file__).parent
16
+ _HOOKS_ROOT = _HOOK_DIR.parent
17
+ if str(_HOOKS_ROOT) not in sys.path:
18
+ sys.path.insert(0, str(_HOOKS_ROOT))
19
+
20
+ from blocking import pr_description_proof_of_work as proof_module # noqa: E402
21
+ from blocking.pr_description_proof_of_work import ( # noqa: E402
22
+ audit_proof_comment_body,
23
+ evaluate_pr_ready_gate,
24
+ is_pr_ready_command,
25
+ is_proof_shaped_body,
26
+ )
27
+
28
+ PASSING_PROOF_COMMENT_BODY = (
29
+ "## Summary\n\n"
30
+ "Recolored the launcher icons and checked every produced asset by hand "
31
+ "against the palette the plan names.\n\n"
32
+ "## Verification\n\n"
33
+ "```\n"
34
+ "C:\\Python313\\python.exe scripts/recolor.py --input themes/dawn\n"
35
+ "```\n\n"
36
+ "| Artifact | Measured |\n"
37
+ "| --- | --- |\n"
38
+ "| icons.zip | 48 files, 412,993 bytes |\n\n"
39
+ "This advances phase 2 of issue #12.\n\n"
40
+ "Known gap: the offline proof cannot show the on-device rendering; the "
41
+ "store preview covers that.\n"
42
+ )
43
+
44
+ VISUAL_PROOF_COMMENT_BODY = (
45
+ PASSING_PROOF_COMMENT_BODY + "\n![](https://placehold.co/20x20/AABBCC/AABBCC.png)\n"
46
+ )
47
+
48
+ BARE_PROOF_COMMENT_BODY = "## Verification\n\nLooks good overall to me.\n"
49
+
50
+ ORDINARY_COMMENT_BODY = (
51
+ "The retry logic here mirrors what the uploader does for chunked "
52
+ "transfers, so the two stay in step."
53
+ )
54
+
55
+
56
+ def _install_fake_gh(monkeypatch, all_comment_bodies, all_diff_names, diff_text):
57
+ all_comment_records = [{"body": each_body} for each_body in all_comment_bodies]
58
+
59
+ def _fake_run_gh_command(all_gh_arguments):
60
+ if all_gh_arguments and all_gh_arguments[0] == "api":
61
+ return json.dumps([all_comment_records])
62
+ if list(all_gh_arguments[:2]) == ["pr", "view"]:
63
+ return json.dumps({"number": 77})
64
+ if "--name-only" in all_gh_arguments:
65
+ return "\n".join(all_diff_names)
66
+ if list(all_gh_arguments[:2]) == ["pr", "diff"]:
67
+ return diff_text
68
+ return None
69
+
70
+ monkeypatch.setattr(proof_module, "_run_gh_command", _fake_run_gh_command)
71
+
72
+
73
+ def test_is_proof_shaped_body_detects_verification_heading() -> None:
74
+ assert is_proof_shaped_body(PASSING_PROOF_COMMENT_BODY)
75
+
76
+
77
+ def test_is_proof_shaped_body_skips_ordinary_comment() -> None:
78
+ assert not is_proof_shaped_body(ORDINARY_COMMENT_BODY)
79
+
80
+
81
+ def test_is_pr_ready_command_matches_ready() -> None:
82
+ assert is_pr_ready_command("gh pr ready 123")
83
+
84
+
85
+ def test_is_pr_ready_command_skips_undo() -> None:
86
+ assert not is_pr_ready_command("gh pr ready 123 --undo")
87
+
88
+
89
+ def test_is_pr_ready_command_matches_after_shell_operator() -> None:
90
+ assert is_pr_ready_command("git fetch && gh pr ready 5")
91
+
92
+
93
+ def test_is_pr_ready_command_ignores_phrase_inside_commit_message() -> None:
94
+ assert not is_pr_ready_command(
95
+ 'git commit -m "block gh pr ready without a proof comment"'
96
+ )
97
+
98
+
99
+ def test_is_pr_ready_command_ignores_phrase_inside_search_argument() -> None:
100
+ assert not is_pr_ready_command('grep -r "gh pr ready" packages/')
101
+
102
+
103
+ def test_audit_passes_complete_proof_on_non_visual_change(monkeypatch: pytest.MonkeyPatch) -> None:
104
+ _install_fake_gh(monkeypatch, [], ["src/parser.py"], "+ plain code line")
105
+ assert audit_proof_comment_body(PASSING_PROOF_COMMENT_BODY, 123) == []
106
+
107
+
108
+ def test_audit_flags_missing_visual_on_image_diff(monkeypatch: pytest.MonkeyPatch) -> None:
109
+ _install_fake_gh(monkeypatch, [], ["assets/icon.png"], "")
110
+ all_missing_parts = audit_proof_comment_body(PASSING_PROOF_COMMENT_BODY, 123)
111
+ assert any("visual" in each_part for each_part in all_missing_parts)
112
+
113
+
114
+ def test_audit_accepts_image_embed_on_image_diff(monkeypatch: pytest.MonkeyPatch) -> None:
115
+ _install_fake_gh(monkeypatch, [], ["assets/icon.png"], "")
116
+ assert audit_proof_comment_body(VISUAL_PROOF_COMMENT_BODY, 123) == []
117
+
118
+
119
+ def test_audit_detects_visual_change_from_hex_colors(monkeypatch: pytest.MonkeyPatch) -> None:
120
+ _install_fake_gh(monkeypatch, [], ["src/theme.py"], '+ accent = "#AABBCC"')
121
+ all_missing_parts = audit_proof_comment_body(PASSING_PROOF_COMMENT_BODY, 123)
122
+ assert any("visual" in each_part for each_part in all_missing_parts)
123
+
124
+
125
+ def test_audit_names_every_missing_part_of_bare_proof(monkeypatch: pytest.MonkeyPatch) -> None:
126
+ _install_fake_gh(monkeypatch, [], ["src/parser.py"], "")
127
+ all_missing_parts = audit_proof_comment_body(BARE_PROOF_COMMENT_BODY, 123)
128
+ assert len(all_missing_parts) == 4
129
+
130
+
131
+ def test_ready_gate_blocks_when_no_proof_comment_exists(monkeypatch: pytest.MonkeyPatch) -> None:
132
+ _install_fake_gh(monkeypatch, [ORDINARY_COMMENT_BODY], ["src/parser.py"], "")
133
+ denial_reason = evaluate_pr_ready_gate("gh pr ready 123")
134
+ assert denial_reason is not None
135
+ assert "proof" in denial_reason.lower()
136
+
137
+
138
+ def test_ready_gate_allows_with_passing_proof_comment(monkeypatch: pytest.MonkeyPatch) -> None:
139
+ _install_fake_gh(monkeypatch, [PASSING_PROOF_COMMENT_BODY], ["src/parser.py"], "")
140
+ assert evaluate_pr_ready_gate("gh pr ready 123") is None
141
+
142
+
143
+ def test_ready_gate_blocks_when_proof_comment_is_incomplete(
144
+ monkeypatch: pytest.MonkeyPatch,
145
+ ) -> None:
146
+ _install_fake_gh(monkeypatch, [BARE_PROOF_COMMENT_BODY], ["src/parser.py"], "")
147
+ denial_reason = evaluate_pr_ready_gate("gh pr ready 123")
148
+ assert denial_reason is not None
149
+ assert "123" in denial_reason
150
+ assert "proof" in denial_reason.lower()
151
+
152
+
153
+ def test_ready_gate_fails_open_when_gh_is_unavailable(monkeypatch: pytest.MonkeyPatch) -> None:
154
+ monkeypatch.setattr(proof_module, "_run_gh_command", lambda all_gh_arguments: None)
155
+ assert evaluate_pr_ready_gate("gh pr ready 123") is None
156
+
157
+
158
+ def test_ready_gate_resolves_pr_number_from_current_branch(
159
+ monkeypatch: pytest.MonkeyPatch,
160
+ ) -> None:
161
+ _install_fake_gh(monkeypatch, [PASSING_PROOF_COMMENT_BODY], ["src/parser.py"], "")
162
+ assert evaluate_pr_ready_gate("gh pr ready") is None
@@ -40,6 +40,73 @@ def compute_total() -> int:
40
40
  return result
41
41
  '''
42
42
 
43
+ WIDGET_MODULE_BASE_SOURCE = '''"""Arithmetic helpers used by the precommit gate worktree tests."""
44
+
45
+
46
+ def add_one(number: int) -> int:
47
+ """Return *number* plus one.
48
+
49
+ Args:
50
+ number: The integer to increment.
51
+
52
+ Returns:
53
+ The incremented integer.
54
+ """
55
+ return number + 1
56
+ '''
57
+
58
+ WIDGET_MODULE_EXPANDED_SOURCE = '''"""Arithmetic helpers used by the precommit gate worktree tests."""
59
+
60
+
61
+ def add_one(number: int) -> int:
62
+ """Return *number* plus one.
63
+
64
+ Args:
65
+ number: The integer to increment.
66
+
67
+ Returns:
68
+ The incremented integer.
69
+ """
70
+ return number + 1
71
+
72
+
73
+ def subtract_one(number: int) -> int:
74
+ """Return *number* minus one.
75
+
76
+ Args:
77
+ number: The integer to decrement.
78
+
79
+ Returns:
80
+ The decremented integer.
81
+ """
82
+ return number - 1
83
+ '''
84
+
85
+ WIDGET_TEST_BASE_SOURCE = '''"""Behavior tests for the widget arithmetic helpers."""
86
+
87
+ from widget import add_one
88
+
89
+
90
+ def test_add_one_increments() -> None:
91
+ """add_one returns its argument plus one."""
92
+ assert add_one(1) == 2
93
+ '''
94
+
95
+ WIDGET_TEST_EXPANDED_SOURCE = '''"""Behavior tests for the widget arithmetic helpers."""
96
+
97
+ from widget import add_one, subtract_one
98
+
99
+
100
+ def test_add_one_increments() -> None:
101
+ """add_one returns its argument plus one."""
102
+ assert add_one(1) == 2
103
+
104
+
105
+ def test_subtract_one_decrements() -> None:
106
+ """subtract_one returns its argument minus one."""
107
+ assert subtract_one(2) == 1
108
+ '''
109
+
43
110
 
44
111
  def run_git(repository_root: Path, *git_arguments: str) -> None:
45
112
  subprocess.run(
@@ -124,3 +191,25 @@ def test_commit_with_no_staged_python_files_is_allowed(tmp_path: Path) -> None:
124
191
  completed_hook = run_hook("git commit -m docs", tmp_path)
125
192
  assert completed_hook.returncode == 0
126
193
  assert completed_hook.stdout.strip() == ""
194
+
195
+
196
+ def test_worktree_commit_reads_worktree_paired_tests_not_sibling_checkout(
197
+ tmp_path: Path,
198
+ ) -> None:
199
+ main_checkout = tmp_path / "main_checkout"
200
+ main_checkout.mkdir()
201
+ initialize_repository(main_checkout)
202
+ (main_checkout / "widget.py").write_text(WIDGET_MODULE_BASE_SOURCE, encoding="utf-8")
203
+ (main_checkout / "test_widget.py").write_text(WIDGET_TEST_BASE_SOURCE, encoding="utf-8")
204
+ run_git(main_checkout, "add", "widget.py", "test_widget.py")
205
+ run_git(main_checkout, "commit", "-m", "base")
206
+ worktree_root = tmp_path / "sibling_worktree"
207
+ run_git(main_checkout, "worktree", "add", str(worktree_root), "-b", "feature")
208
+ stage_file(worktree_root, "widget.py", WIDGET_MODULE_EXPANDED_SOURCE)
209
+ stage_file(worktree_root, "test_widget.py", WIDGET_TEST_EXPANDED_SOURCE)
210
+ quoted_worktree = str(worktree_root)
211
+ completed_hook = run_hook(
212
+ f'git -C "{quoted_worktree}" commit -m expand', main_checkout
213
+ )
214
+ assert completed_hook.returncode == 0
215
+ assert completed_hook.stdout.strip() == ""
@@ -736,6 +736,10 @@ def test_hook_subprocess_imports_real_config_when_parent_holds_shadowing_config(
736
736
  real_blocking_directory / "verdict_directory_write_blocker.py",
737
737
  staged_blocking_directory / "verdict_directory_write_blocker.py",
738
738
  )
739
+ shutil.copy(
740
+ real_blocking_directory / "verified_commit_config_bootstrap.py",
741
+ staged_blocking_directory / "verified_commit_config_bootstrap.py",
742
+ )
739
743
  shutil.copytree(
740
744
  real_blocking_directory / "config",
741
745
  staged_blocking_directory / "config",
@@ -10,6 +10,7 @@ import json
10
10
  import pathlib
11
11
  import subprocess
12
12
  import sys
13
+ from collections.abc import Callable
13
14
 
14
15
  import pytest
15
16
 
@@ -785,3 +786,13 @@ def test_manifest_hash_for_branch_cli_returns_nonzero_when_branch_absent(
785
786
  )
786
787
  assert completed_process.returncode != 0
787
788
  assert completed_process.stdout.strip() == ""
789
+
790
+
791
+ def test_store_imports_under_foreign_config_shadow(
792
+ run_under_config_shadow: Callable[[str], subprocess.CompletedProcess[str]],
793
+ ) -> None:
794
+ completed_probe = run_under_config_shadow(
795
+ "import verification_verdict_store\nprint('IMPORT_OK')\n"
796
+ )
797
+ assert completed_probe.returncode == 0, completed_probe.stderr
798
+ assert "IMPORT_OK" in completed_probe.stdout
@@ -0,0 +1,49 @@
1
+ """Regression tests for the verified-commit constants bootstrap.
2
+
3
+ These prove the shared constants module resolves to the sibling
4
+ ``config/verified_commit_constants.py`` file even when a foreign ``config``
5
+ package sits ahead of ``blocking`` on ``sys.path``, and that a registration a
6
+ caller placed first is left untouched.
7
+ """
8
+
9
+ import subprocess
10
+ from collections.abc import Callable
11
+
12
+ RunUnderConfigShadow = Callable[[str], subprocess.CompletedProcess[str]]
13
+
14
+
15
+ def test_register_binds_dotted_name_to_sibling_constants_file(
16
+ run_under_config_shadow: RunUnderConfigShadow,
17
+ ) -> None:
18
+ completed_probe = run_under_config_shadow(
19
+ "import verified_commit_config_bootstrap as bootstrap\n"
20
+ "bootstrap.register_verified_commit_constants()\n"
21
+ "import config.verified_commit_constants as loaded\n"
22
+ "print(loaded.__file__)\n"
23
+ "print(loaded.DETACHED_HEAD_LABEL)\n"
24
+ )
25
+ assert completed_probe.returncode == 0, completed_probe.stderr
26
+ assert "IS_DECOY_CONFIG" not in completed_probe.stdout
27
+ resolved_file_line, detached_head_line = completed_probe.stdout.splitlines()[:2]
28
+ assert resolved_file_line.replace("\\", "/").endswith(
29
+ "blocking/config/verified_commit_constants.py"
30
+ )
31
+ assert detached_head_line == "HEAD"
32
+
33
+
34
+ def test_register_leaves_an_already_cached_module_untouched(
35
+ run_under_config_shadow: RunUnderConfigShadow,
36
+ ) -> None:
37
+ completed_probe = run_under_config_shadow(
38
+ "import sys\n"
39
+ "import types\n"
40
+ "sentinel = types.ModuleType('config.verified_commit_constants')\n"
41
+ "sentinel.ORIGIN = 'caller-seeded'\n"
42
+ "sys.modules['config.verified_commit_constants'] = sentinel\n"
43
+ "import verified_commit_config_bootstrap as bootstrap\n"
44
+ "bootstrap.register_verified_commit_constants()\n"
45
+ "import config.verified_commit_constants as loaded\n"
46
+ "print(getattr(loaded, 'ORIGIN', 'displaced'))\n"
47
+ )
48
+ assert completed_probe.returncode == 0, completed_probe.stderr
49
+ assert completed_probe.stdout.strip().splitlines()[-1] == "caller-seeded"