claude-dev-env 7.0.0 → 7.1.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 (210) hide show
  1. package/.agents/skills/pull-request/scripts/pull_request.py +2 -0
  2. package/.agents/skills/pull-request/scripts/test_pull_request.py +34 -0
  3. package/.agents/skills/session-continuity/AGENTS.md +1 -0
  4. package/.agents/skills/session-continuity/CLAUDE.md +1 -0
  5. package/.agents/skills/session-continuity/README.md +189 -0
  6. package/.agents/skills/session-continuity/SKILL.md +114 -0
  7. package/.agents/skills/session-continuity/continuity.mjs +375 -0
  8. package/.agents/skills/session-continuity/continuity.test.mjs +303 -0
  9. package/.agents/skills/syncing-submodules/scripts/test_sync_parent_pointer.py +0 -7
  10. package/.agents/skills/windows-scheduled-task/SKILL.md +153 -0
  11. package/bin/cde.mjs +36 -8
  12. package/bin/cde.test.mjs +48 -0
  13. package/bin/ever-shipped-skills.mjs +2 -20
  14. package/bin/ever-shipped-skills.test.mjs +8 -0
  15. package/bin/expand_home_directory_tokens.mjs +4 -5
  16. package/bin/expand_home_directory_tokens.test.mjs +128 -0
  17. package/bin/git_hooks_installer.mjs +22 -3
  18. package/bin/git_hooks_installer.test.mjs +159 -5
  19. package/bin/install-session-continuity.mjs +78 -0
  20. package/bin/install-session-continuity.test.mjs +42 -0
  21. package/bin/install.codex-rules.test.mjs +5 -2
  22. package/bin/install.cursor-rules.test.mjs +5 -2
  23. package/bin/install.mjs +478 -63
  24. package/bin/install.policy-lint.test.mjs +56 -4
  25. package/bin/install.profiles.test.mjs +10 -0
  26. package/bin/install.prune.test.mjs +227 -17
  27. package/bin/install.test.mjs +500 -120
  28. package/bin/install.transaction.test.mjs +3 -3
  29. package/docs/CODE_RULES.md +1 -1
  30. package/hooks/blocking/code_rules_banned_identifiers.py +3 -0
  31. package/hooks/blocking/precommit_code_rules_gate.py +5 -8
  32. package/hooks/blocking/test_bash_dispatcher_interpreter_starts.py +7 -52
  33. package/hooks/blocking/test_bash_pre_tool_use_dispatcher.py +0 -69
  34. package/hooks/blocking/test_code_rules_banned_identifiers.py +64 -0
  35. package/hooks/blocking/test_pre_tool_use_dispatcher.py +10 -244
  36. package/hooks/blocking/test_shared_stdin_adoption.py +1 -47
  37. package/hooks/git-hooks/git_hooks_constants/verification_notice_constants.py +116 -0
  38. package/hooks/git-hooks/post_commit.py +33 -0
  39. package/hooks/git-hooks/pre_commit.py +18 -90
  40. package/hooks/git-hooks/pre_push.py +45 -541
  41. package/hooks/git-hooks/test_installed_policy_lint.py +55 -6
  42. package/hooks/git-hooks/test_native_hook_support.py +129 -0
  43. package/hooks/git-hooks/test_native_policy_commit.py +39 -6
  44. package/hooks/git-hooks/test_post_commit.py +43 -0
  45. package/hooks/git-hooks/test_pre_commit.py +36 -392
  46. package/hooks/git-hooks/test_pre_push.py +48 -1631
  47. package/hooks/git-hooks/test_verification_notice.py +60 -0
  48. package/hooks/git-hooks/test_verification_start.py +173 -0
  49. package/hooks/git-hooks/verification_notice.py +192 -0
  50. package/hooks/git-hooks/verification_notice_context.py +253 -0
  51. package/hooks/git-hooks/verification_notice_state.py +237 -0
  52. package/hooks/git-hooks/verification_start.py +100 -0
  53. package/hooks/hooks.json +0 -119
  54. package/hooks/hooks_constants/banned_identifiers_constants.py +4 -0
  55. package/hooks/hooks_constants/bash_pre_tool_use_dispatcher_constants.py +1 -15
  56. package/hooks/hooks_constants/post_tool_use_dispatcher_constants.py +0 -4
  57. package/hooks/hooks_constants/pre_tool_use_dispatcher_constants.py +0 -50
  58. package/hooks/hooks_constants/stop_dispatcher_constants.py +1 -4
  59. package/hooks/hooks_constants/test_bash_pre_tool_use_dispatcher_constants.py +3 -66
  60. package/hooks/hooks_constants/test_pre_tool_use_dispatcher_constants.py +42 -185
  61. package/hooks/hooks_constants/test_stop_dispatcher_constants.py +3 -25
  62. package/hooks/validation/test_post_tool_use_dispatcher.py +35 -298
  63. package/hooks/validators/run_all_validators.py +5 -1
  64. package/hooks/validators/security_checks.py +57 -2
  65. package/hooks/validators/test_hook_timing_harness.py +2 -5
  66. package/hooks/validators/test_run_all_validators_mutation_tool_parity.py +3 -11
  67. package/hooks/validators/test_run_all_validators_policy_lint.py +36 -0
  68. package/hooks/validators/test_security_checks.py +57 -0
  69. package/package.json +1 -1
  70. package/rules/confirm-implementation-forks.md +2 -0
  71. package/rules/git-workflow.md +12 -0
  72. package/rules/pstack-host-mapping.md +48 -0
  73. package/rules/vault-context.md +3 -5
  74. package/rules/verify-runtime-state.md +7 -0
  75. package/scripts/audit-hooks-cli.mjs +5 -0
  76. package/scripts/audit-hooks.mjs +72 -16
  77. package/scripts/automatic_advisory/__init__.py +1 -0
  78. package/scripts/automatic_advisory/checkout.py +51 -0
  79. package/scripts/automatic_advisory/cli.py +334 -0
  80. package/scripts/automatic_advisory/config/__init__.py +1 -0
  81. package/scripts/automatic_advisory/config/constants.py +93 -0
  82. package/scripts/automatic_advisory/config/timing.py +4 -0
  83. package/scripts/automatic_advisory/configuration.py +197 -0
  84. package/scripts/automatic_advisory/execution.py +350 -0
  85. package/scripts/automatic_advisory/git.py +69 -0
  86. package/scripts/automatic_advisory/model.py +107 -0
  87. package/scripts/automatic_advisory/process_host.py +32 -0
  88. package/scripts/automatic_advisory/publisher.py +84 -0
  89. package/scripts/automatic_advisory/runner.py +399 -0
  90. package/scripts/automatic_advisory/state.py +116 -0
  91. package/scripts/automatic_advisory/window_flags.py +41 -0
  92. package/scripts/automatic_advisory/windows_job.py +122 -0
  93. package/scripts/codex_compat_materializer.py +99 -13
  94. package/scripts/durable_post_lint.py +30 -2
  95. package/scripts/durable_post_lint_config/config/constants.py +10 -0
  96. package/scripts/durable_post_lint_config/config/test_constants.py +13 -0
  97. package/scripts/local_report_cli.py +184 -0
  98. package/scripts/local_report_core.py +247 -0
  99. package/scripts/local_report_publisher.py +12 -0
  100. package/scripts/local_report_validation.py +357 -0
  101. package/scripts/local_verification/__init__.py +23 -0
  102. package/scripts/local_verification/check_runner.py +364 -0
  103. package/scripts/local_verification/check_support.py +99 -0
  104. package/scripts/local_verification/cli.py +158 -0
  105. package/scripts/local_verification/command_runner.py +84 -0
  106. package/scripts/local_verification/config/__init__.py +1 -0
  107. package/scripts/local_verification/config/constants.py +89 -0
  108. package/scripts/local_verification/config/timing.py +1 -0
  109. package/scripts/local_verification/git_state.py +146 -0
  110. package/scripts/local_verification/manifest.py +224 -0
  111. package/scripts/local_verification/model.py +174 -0
  112. package/scripts/local_verification/runner.py +234 -0
  113. package/scripts/policy_lint/adapter_pairing.py +58 -3
  114. package/scripts/policy_lint/config/approved_test_pairs.py +323 -0
  115. package/scripts/pr_verification/__init__.py +1 -0
  116. package/scripts/pr_verification/branch_refs.py +114 -0
  117. package/scripts/pr_verification/config/__init__.py +1 -0
  118. package/scripts/pr_verification/config/constants.py +84 -0
  119. package/scripts/pr_verification/config/timing.py +5 -0
  120. package/scripts/pr_verification/github.py +137 -0
  121. package/scripts/pr_verification/github_api.py +376 -0
  122. package/scripts/pr_verification/github_labels.py +88 -0
  123. package/scripts/pr_verification/github_parsing.py +182 -0
  124. package/scripts/pr_verification/github_transport.py +91 -0
  125. package/scripts/pr_verification/lock.py +122 -0
  126. package/scripts/pr_verification/model.py +43 -0
  127. package/scripts/pr_verification/requirements.txt +1 -0
  128. package/scripts/test_durable_post_lint.py +97 -0
  129. package/scripts/tests/test-audit-hooks-cli.mjs +150 -0
  130. package/scripts/tests/test-audit-hooks.mjs +94 -2
  131. package/scripts/tests/test_automatic_advisory.py +376 -0
  132. package/scripts/tests/test_automatic_advisory_job_cleanup.py +71 -0
  133. package/scripts/tests/test_automatic_advisory_polling.py +216 -0
  134. package/scripts/tests/test_automatic_advisory_recovery.py +320 -0
  135. package/scripts/tests/test_automatic_advisory_repairs.py +400 -0
  136. package/scripts/tests/test_automatic_advisory_settings.py +48 -0
  137. package/scripts/tests/test_automatic_advisory_window_flags.py +163 -0
  138. package/scripts/tests/test_closed_pr_label.py +157 -0
  139. package/scripts/tests/test_codex_compat_materializer.py +189 -6
  140. package/scripts/tests/test_github_labels.py +101 -0
  141. package/scripts/tests/test_github_transport.py +125 -0
  142. package/scripts/tests/test_local_report_publisher.py +396 -0
  143. package/scripts/tests/test_local_report_publisher_cli.py +85 -0
  144. package/scripts/tests/test_local_verification.py +348 -0
  145. package/scripts/tests/test_local_verification_cli.py +98 -0
  146. package/scripts/tests/test_policy_lint_rules_pairing.py +163 -0
  147. package/scripts/tests/test_pr_verification_github.py +392 -0
  148. package/scripts/tests/test_pr_verification_lock.py +168 -0
  149. package/scripts/tests/test_verification_notice.py +347 -0
  150. package/hooks/blocking/ask_user_question_shape_blocker.py +0 -83
  151. package/hooks/blocking/bot_mention_comment_blocker.py +0 -76
  152. package/hooks/blocking/claude_md_orphan_file_blocker.py +0 -129
  153. package/hooks/blocking/cursor_cli_python_misfire_blocker.py +0 -108
  154. package/hooks/blocking/destructive_command_blocker.py +0 -2073
  155. package/hooks/blocking/fable_spawn_gate.py +0 -187
  156. package/hooks/blocking/luna_fast_mode_gate.py +0 -160
  157. package/hooks/blocking/nas_ssh_binary_enforcer.py +0 -163
  158. package/hooks/blocking/orchestrator_refresh_reschedule_gate.py +0 -260
  159. package/hooks/blocking/package_inventory_stale_blocker.py +0 -107
  160. package/hooks/blocking/pii_prevention_blocker.py +0 -365
  161. package/hooks/blocking/piped_pytest_blocker.py +0 -1223
  162. package/hooks/blocking/question_to_user_enforcer.py +0 -130
  163. package/hooks/blocking/send_user_file_open_locally_blocker.py +0 -71
  164. package/hooks/blocking/sensitive_file_protector.py +0 -167
  165. package/hooks/blocking/session_edit_stage_gate.py +0 -684
  166. package/hooks/blocking/session_handoff_blocker.py +0 -182
  167. package/hooks/blocking/shell_substitution_blocker.py +0 -350
  168. package/hooks/blocking/test_ask_user_question_shape.py +0 -69
  169. package/hooks/blocking/test_bot_mention_comment_blocker.py +0 -131
  170. package/hooks/blocking/test_claude_md_orphan_file_blocker.py +0 -1277
  171. package/hooks/blocking/test_cursor_cli_python_misfire_blocker.py +0 -208
  172. package/hooks/blocking/test_destructive_command_blocker.py +0 -2024
  173. package/hooks/blocking/test_destructive_command_blocker_deny_mode.py +0 -105
  174. package/hooks/blocking/test_destructive_command_blocker_no_verify.py +0 -122
  175. package/hooks/blocking/test_destructive_command_blocker_patterns.py +0 -133
  176. package/hooks/blocking/test_fable_spawn_gate.py +0 -381
  177. package/hooks/blocking/test_inventory_deadlock_resolution.py +0 -154
  178. package/hooks/blocking/test_luna_fast_mode_gate.py +0 -211
  179. package/hooks/blocking/test_nas_ssh_binary_enforcer.py +0 -225
  180. package/hooks/blocking/test_orchestrator_refresh_reschedule_gate.py +0 -231
  181. package/hooks/blocking/test_package_inventory_stale_blocker.py +0 -382
  182. package/hooks/blocking/test_pii_prevention_blocker.py +0 -1222
  183. package/hooks/blocking/test_pii_prevention_windows_git_path.py +0 -41
  184. package/hooks/blocking/test_pii_write_surface_ephemeral.py +0 -221
  185. package/hooks/blocking/test_piped_pytest_blocker.py +0 -587
  186. package/hooks/blocking/test_precommit_code_rules_gate_native_owner.py +0 -233
  187. package/hooks/blocking/test_question_to_user_enforcer.py +0 -169
  188. package/hooks/blocking/test_send_user_file_open_locally_blocker.py +0 -118
  189. package/hooks/blocking/test_sensitive_file_protector.py +0 -365
  190. package/hooks/blocking/test_session_edit_stage_gate.py +0 -537
  191. package/hooks/blocking/test_session_edit_stage_gate_staging.py +0 -64
  192. package/hooks/blocking/test_session_edit_stage_gate_support.py +0 -204
  193. package/hooks/blocking/test_session_edit_stage_gate_tracker.py +0 -116
  194. package/hooks/blocking/test_session_handoff_blocker.py +0 -318
  195. package/hooks/blocking/test_shell_substitution_blocker.py +0 -298
  196. package/hooks/blocking/test_unscoped_search_blocker.py +0 -102
  197. package/hooks/blocking/test_write_existing_file_blocker.py +0 -122
  198. package/hooks/blocking/tests/test_pii_prevention_blocker.py +0 -259
  199. package/hooks/blocking/unscoped_search_blocker.py +0 -391
  200. package/hooks/blocking/write_existing_file_blocker.py +0 -124
  201. package/hooks/hooks_constants/bot_mention_comment_blocker_constants.py +0 -19
  202. package/hooks/hooks_constants/cursor_cli_python_misfire_blocker_constants.py +0 -79
  203. package/hooks/hooks_constants/fable_spawn_gate_constants.py +0 -61
  204. package/hooks/hooks_constants/luna_fast_mode_gate_constants.py +0 -45
  205. package/hooks/hooks_constants/nas_ssh_binary_enforcer_constants.py +0 -20
  206. package/hooks/hooks_constants/orchestrator_refresh_reschedule_gate_constants.py +0 -57
  207. package/hooks/hooks_constants/send_user_file_open_locally_blocker_constants.py +0 -17
  208. package/hooks/hooks_constants/sensitive_file_protector_constants.py +0 -40
  209. package/hooks/hooks_constants/session_handoff_blocker_constants.py +0 -10
  210. package/hooks/hooks_constants/shell_substitution_blocker_constants.py +0 -80
@@ -0,0 +1,234 @@
1
+ from __future__ import annotations
2
+
3
+ import json
4
+ from collections.abc import Callable
5
+ from pathlib import Path
6
+ from typing import TypeAlias
7
+
8
+ from .check_runner import _execute_check
9
+ from .config import (
10
+ JSON_INDENT_SPACES,
11
+ LOGS_DIRECTORY_SUFFIX,
12
+ PASSED_STATUS,
13
+ REPORT_NEWLINE,
14
+ RUN_CHECK_LOG_TEMPLATE,
15
+ RUN_LOG_FILENAME,
16
+ UTF8_ENCODING,
17
+ )
18
+ from .git_state import CandidateSnapshot, capture_candidate_snapshot
19
+ from .manifest import compute_manifest_digest
20
+ from .model import (
21
+ CheckRecord,
22
+ VerificationManifest,
23
+ VerificationReport,
24
+ )
25
+
26
+ ProgressCallback: TypeAlias = Callable[[str], None]
27
+
28
+
29
+ def run_verification(
30
+ manifest: VerificationManifest,
31
+ repository_path: Path,
32
+ base_revision: str,
33
+ report_path: Path,
34
+ progress_callback: ProgressCallback | None = None,
35
+ ) -> VerificationReport:
36
+ """Execute checks and write the verification report.
37
+
38
+ Args:
39
+ manifest: Verification manifest.
40
+ repository_path: Repository checkout to verify.
41
+ base_revision: Base revision for selection and Git identity.
42
+ report_path: Output path for the verification report.
43
+ progress_callback: Optional receiver for progress lines.
44
+
45
+ Returns:
46
+ The written verification report.
47
+ """
48
+ resolved_repository_path = _require_repository_directory(repository_path)
49
+ logs_directory = _prepare_logs_directory(report_path)
50
+ verification_report = _verify_resolved_repository(
51
+ manifest,
52
+ resolved_repository_path,
53
+ base_revision,
54
+ logs_directory,
55
+ progress_callback,
56
+ )
57
+ _write_report_files(verification_report, logs_directory, report_path)
58
+ return verification_report
59
+
60
+
61
+ def _verify_resolved_repository(
62
+ manifest: VerificationManifest,
63
+ resolved_repository_path: Path,
64
+ base_revision: str,
65
+ logs_directory: Path,
66
+ progress_callback: ProgressCallback | None,
67
+ ) -> VerificationReport:
68
+ before_snapshot = capture_candidate_snapshot(
69
+ resolved_repository_path, base_revision
70
+ )
71
+ all_records = _execute_manifest_checks(
72
+ manifest,
73
+ resolved_repository_path,
74
+ base_revision,
75
+ before_snapshot,
76
+ logs_directory,
77
+ progress_callback,
78
+ )
79
+ after_snapshot = capture_candidate_snapshot(resolved_repository_path, base_revision)
80
+ return _build_verification_report(
81
+ manifest, resolved_repository_path, before_snapshot, after_snapshot, all_records
82
+ )
83
+
84
+
85
+ def _require_repository_directory(repository_path: Path) -> Path:
86
+ resolved_repository_path = repository_path.resolve()
87
+ if resolved_repository_path.is_dir():
88
+ return resolved_repository_path
89
+ raise ValueError("Repository path must name a directory")
90
+
91
+
92
+ def _execute_manifest_checks(
93
+ manifest: VerificationManifest,
94
+ repository_path: Path,
95
+ base_revision: str,
96
+ before_snapshot: CandidateSnapshot,
97
+ logs_directory: Path,
98
+ progress_callback: ProgressCallback | None,
99
+ ) -> tuple[CheckRecord, ...]:
100
+ execution_base_revision = before_snapshot.base_revision or base_revision
101
+ return _execute_all_checks(
102
+ manifest,
103
+ repository_path,
104
+ execution_base_revision,
105
+ logs_directory,
106
+ progress_callback,
107
+ )
108
+
109
+
110
+ def _write_report_files(
111
+ report: VerificationReport, logs_directory: Path, report_path: Path
112
+ ) -> None:
113
+ _write_run_log(report, logs_directory / RUN_LOG_FILENAME)
114
+ _write_report(report, report_path)
115
+
116
+
117
+ def _prepare_logs_directory(report_path: Path) -> Path:
118
+ logs_directory = report_path.resolve().parent / (
119
+ report_path.stem + LOGS_DIRECTORY_SUFFIX
120
+ )
121
+ logs_directory.mkdir(parents=True, exist_ok=True)
122
+ return logs_directory
123
+
124
+
125
+ def _build_verification_report(
126
+ manifest: VerificationManifest,
127
+ repository_path: Path,
128
+ before_snapshot: CandidateSnapshot,
129
+ after_snapshot: CandidateSnapshot,
130
+ all_records: tuple[CheckRecord, ...],
131
+ ) -> VerificationReport:
132
+ is_worktree_clean = before_snapshot.worktree_clean and after_snapshot.worktree_clean
133
+ is_inputs_unchanged = _inputs_unchanged(before_snapshot, after_snapshot)
134
+ return VerificationReport(
135
+ manifest.version,
136
+ repository_path,
137
+ before_snapshot.base_revision,
138
+ all_records,
139
+ manifest.exclusions,
140
+ before_snapshot.head_revision,
141
+ compute_manifest_digest(manifest),
142
+ is_worktree_clean,
143
+ is_inputs_unchanged,
144
+ _is_publishable(
145
+ all_records,
146
+ before_snapshot,
147
+ after_snapshot,
148
+ is_worktree_clean,
149
+ is_inputs_unchanged,
150
+ ),
151
+ )
152
+
153
+
154
+ def _execute_all_checks(
155
+ manifest: VerificationManifest,
156
+ repository_path: Path,
157
+ base_revision: str,
158
+ logs_directory: Path,
159
+ progress_callback: ProgressCallback | None,
160
+ ) -> tuple[CheckRecord, ...]:
161
+ return tuple(
162
+ _execute_check(
163
+ each_check,
164
+ repository_path,
165
+ base_revision,
166
+ logs_directory,
167
+ progress_callback,
168
+ )
169
+ for each_check in manifest.checks
170
+ )
171
+
172
+
173
+ def _inputs_unchanged(
174
+ before_snapshot: CandidateSnapshot, after_snapshot: CandidateSnapshot
175
+ ) -> bool:
176
+ return (
177
+ before_snapshot.input_digest is not None
178
+ and before_snapshot.input_digest == after_snapshot.input_digest
179
+ )
180
+
181
+
182
+ def _is_publishable(
183
+ all_records: tuple[CheckRecord, ...],
184
+ before_snapshot: CandidateSnapshot,
185
+ after_snapshot: CandidateSnapshot,
186
+ is_worktree_clean: bool,
187
+ is_inputs_unchanged: bool,
188
+ ) -> bool:
189
+ if not all(each_record.status == PASSED_STATUS for each_record in all_records):
190
+ return False
191
+ return (
192
+ before_snapshot.is_git_repository
193
+ and after_snapshot.is_git_repository
194
+ and before_snapshot.head_revision is not None
195
+ and before_snapshot.head_revision == after_snapshot.head_revision
196
+ and before_snapshot.base_revision is not None
197
+ and before_snapshot.base_revision == after_snapshot.base_revision
198
+ and is_worktree_clean
199
+ and is_inputs_unchanged
200
+ )
201
+
202
+
203
+ def _write_report(report: VerificationReport, report_path: Path) -> None:
204
+ report_mapping = report.as_dict()
205
+ report_path.parent.mkdir(parents=True, exist_ok=True)
206
+ report_path.write_text(
207
+ json.dumps(report_mapping, indent=JSON_INDENT_SPACES, sort_keys=True)
208
+ + REPORT_NEWLINE,
209
+ encoding=UTF8_ENCODING,
210
+ )
211
+
212
+
213
+ def _write_run_log(report: VerificationReport, run_log_path: Path) -> None:
214
+ all_log_lines = [
215
+ RUN_CHECK_LOG_TEMPLATE.format(
216
+ check_id=each_record.check_id,
217
+ status=each_record.status,
218
+ )
219
+ for each_record in report.checks
220
+ ]
221
+ all_log_lines.extend(
222
+ (
223
+ f"aggregate: {report.aggregate_status}",
224
+ f"head: {report.head_revision}",
225
+ f"base: {report.base_revision}",
226
+ f"worktree_clean: {report.worktree_clean}",
227
+ f"inputs_unchanged: {report.inputs_unchanged}",
228
+ f"publishable: {report.publishable}",
229
+ )
230
+ )
231
+ run_log_path.write_text(
232
+ REPORT_NEWLINE.join(all_log_lines) + REPORT_NEWLINE,
233
+ encoding=UTF8_ENCODING,
234
+ )
@@ -1,9 +1,11 @@
1
1
  from __future__ import annotations
2
2
 
3
+ import ast
3
4
  from pathlib import PurePosixPath
4
5
 
5
6
  from . import adapter_support
6
7
  from .config import constants
8
+ from .config.approved_test_pairs import APPROVED_TEST_PATHS_BY_PRODUCTION_PATH
7
9
  from .model import Diagnostic, Document, DocumentSet, Location, SelectionKind, Severity
8
10
 
9
11
 
@@ -28,6 +30,47 @@ def _is_constants_only_python_document(
28
30
  return analysis_module._is_constants_only_python_content(document.text)
29
31
 
30
32
 
33
+ def _is_docstring_statement(statement: ast.stmt) -> bool:
34
+ return (
35
+ isinstance(statement, ast.Expr)
36
+ and isinstance(statement.value, ast.Constant)
37
+ and isinstance(statement.value.value, str)
38
+ )
39
+
40
+
41
+ def _remove_docstrings(parsed_tree: ast.AST) -> None:
42
+ if (
43
+ isinstance(
44
+ parsed_tree,
45
+ (ast.Module, ast.ClassDef, ast.FunctionDef, ast.AsyncFunctionDef),
46
+ )
47
+ and parsed_tree.body
48
+ and _is_docstring_statement(parsed_tree.body[0])
49
+ ):
50
+ parsed_tree.body.pop(0)
51
+ for each_child in ast.iter_child_nodes(parsed_tree):
52
+ _remove_docstrings(each_child)
53
+
54
+
55
+ def _ast_without_docstrings(source_text: str) -> str | None:
56
+ try:
57
+ parsed_tree = ast.parse(source_text)
58
+ except SyntaxError:
59
+ return None
60
+ _remove_docstrings(parsed_tree)
61
+ return ast.dump(parsed_tree, include_attributes=False)
62
+
63
+
64
+ def _is_docstring_only_python_document(document: Document) -> bool:
65
+ if document.path.suffix.lower() != constants.PYTHON_SUFFIX:
66
+ return False
67
+ if document.prior_text is None:
68
+ return False
69
+ current_ast = _ast_without_docstrings(document.text)
70
+ prior_ast = _ast_without_docstrings(document.prior_text)
71
+ return current_ast is not None and current_ast == prior_ast
72
+
73
+
31
74
  def _candidate_test_names(path: PurePosixPath) -> frozenset[str]:
32
75
  stem = path.stem
33
76
  suffix = path.suffix.lower()
@@ -76,10 +119,22 @@ def _is_grouped_test_match(
76
119
  return _family_tokens(production_path) == _family_tokens(test_path)
77
120
 
78
121
 
122
+ def _has_changed_approved_test(
123
+ production_path: PurePosixPath,
124
+ all_changed_test_paths: frozenset[PurePosixPath],
125
+ ) -> bool:
126
+ all_approved_test_paths = APPROVED_TEST_PATHS_BY_PRODUCTION_PATH.get(
127
+ production_path, frozenset()
128
+ )
129
+ return not all_approved_test_paths.isdisjoint(all_changed_test_paths)
130
+
131
+
79
132
  def _has_changed_test(
80
133
  production_path: PurePosixPath,
81
134
  all_changed_test_paths: frozenset[PurePosixPath],
82
135
  ) -> bool:
136
+ if _has_changed_approved_test(production_path, all_changed_test_paths):
137
+ return True
83
138
  all_candidate_names = _candidate_test_names(production_path)
84
139
  return any(
85
140
  each_test_path.name.lower() in all_candidate_names
@@ -100,6 +155,8 @@ def _is_unpaired_production(
100
155
  return False
101
156
  if _is_constants_only_python_document(production_document, load_module):
102
157
  return False
158
+ if _is_docstring_only_python_document(production_document):
159
+ return False
103
160
  return not _has_changed_test(production_path, all_changed_test_paths)
104
161
 
105
162
 
@@ -139,7 +196,5 @@ def test_pairing_diagnostics(
139
196
  return tuple(
140
197
  _pairing_diagnostic(each_document)
141
198
  for each_document in document_set.documents
142
- if _is_unpaired_production(
143
- each_document, all_changed_test_paths, load_module
144
- )
199
+ if _is_unpaired_production(each_document, all_changed_test_paths, load_module)
145
200
  )
@@ -0,0 +1,323 @@
1
+ from __future__ import annotations
2
+
3
+ from pathlib import PurePosixPath
4
+
5
+ APPROVED_TEST_PATHS_BY_PRODUCTION_PATH: dict[
6
+ PurePosixPath, frozenset[PurePosixPath]
7
+ ] = {
8
+ PurePosixPath(
9
+ "packages/claude-dev-env/hooks/git-hooks/verification_notice_context.py"
10
+ ): frozenset(
11
+ {
12
+ PurePosixPath(
13
+ "packages/claude-dev-env/scripts/tests/test_verification_notice.py"
14
+ ),
15
+ }
16
+ ),
17
+ PurePosixPath(
18
+ "packages/claude-dev-env/hooks/git-hooks/verification_notice_state.py"
19
+ ): frozenset(
20
+ {
21
+ PurePosixPath(
22
+ "packages/claude-dev-env/scripts/tests/test_verification_notice.py"
23
+ ),
24
+ }
25
+ ),
26
+ PurePosixPath(
27
+ "packages/claude-dev-env/hooks/hooks_constants/post_tool_use_dispatcher_constants.py"
28
+ ): frozenset(
29
+ {
30
+ PurePosixPath(
31
+ "packages/claude-dev-env/hooks/validation/test_post_tool_use_dispatcher.py"
32
+ ),
33
+ }
34
+ ),
35
+ PurePosixPath(
36
+ "packages/claude-dev-env/scripts/automatic_advisory/checkout.py"
37
+ ): frozenset(
38
+ {
39
+ PurePosixPath(
40
+ "packages/claude-dev-env/scripts/tests/test_automatic_advisory_window_flags.py"
41
+ ),
42
+ PurePosixPath(
43
+ "packages/claude-dev-env/scripts/tests/test_automatic_advisory.py"
44
+ ),
45
+ }
46
+ ),
47
+ PurePosixPath(
48
+ "packages/claude-dev-env/scripts/automatic_advisory/cli.py"
49
+ ): frozenset(
50
+ {
51
+ PurePosixPath(
52
+ "packages/claude-dev-env/scripts/tests/test_automatic_advisory_window_flags.py"
53
+ ),
54
+ PurePosixPath(
55
+ "packages/claude-dev-env/scripts/tests/test_automatic_advisory_recovery.py"
56
+ ),
57
+ PurePosixPath(
58
+ "packages/claude-dev-env/scripts/tests/test_automatic_advisory_repairs.py"
59
+ ),
60
+ }
61
+ ),
62
+ PurePosixPath(
63
+ "packages/claude-dev-env/scripts/automatic_advisory/configuration.py"
64
+ ): frozenset(
65
+ {
66
+ PurePosixPath(
67
+ "packages/claude-dev-env/scripts/tests/test_automatic_advisory_recovery.py"
68
+ ),
69
+ }
70
+ ),
71
+ PurePosixPath(
72
+ "packages/claude-dev-env/scripts/automatic_advisory/execution.py"
73
+ ): frozenset(
74
+ {
75
+ PurePosixPath(
76
+ "packages/claude-dev-env/scripts/tests/test_automatic_advisory_window_flags.py"
77
+ ),
78
+ PurePosixPath(
79
+ "packages/claude-dev-env/scripts/tests/test_automatic_advisory.py"
80
+ ),
81
+ PurePosixPath(
82
+ "packages/claude-dev-env/scripts/tests/test_automatic_advisory_recovery.py"
83
+ ),
84
+ PurePosixPath(
85
+ "packages/claude-dev-env/scripts/tests/test_automatic_advisory_repairs.py"
86
+ ),
87
+ }
88
+ ),
89
+ PurePosixPath(
90
+ "packages/claude-dev-env/scripts/automatic_advisory/git.py"
91
+ ): frozenset(
92
+ {
93
+ PurePosixPath(
94
+ "packages/claude-dev-env/scripts/tests/test_automatic_advisory_window_flags.py"
95
+ ),
96
+ PurePosixPath(
97
+ "packages/claude-dev-env/scripts/tests/test_automatic_advisory_repairs.py"
98
+ ),
99
+ }
100
+ ),
101
+ PurePosixPath(
102
+ "packages/claude-dev-env/scripts/automatic_advisory/model.py"
103
+ ): frozenset(
104
+ {
105
+ PurePosixPath(
106
+ "packages/claude-dev-env/scripts/tests/test_automatic_advisory.py"
107
+ ),
108
+ PurePosixPath(
109
+ "packages/claude-dev-env/scripts/tests/test_closed_pr_label.py"
110
+ ),
111
+ }
112
+ ),
113
+ PurePosixPath(
114
+ "packages/claude-dev-env/scripts/automatic_advisory/process_host.py"
115
+ ): frozenset(
116
+ {
117
+ PurePosixPath(
118
+ "packages/claude-dev-env/scripts/tests/test_automatic_advisory_repairs.py"
119
+ ),
120
+ }
121
+ ),
122
+ PurePosixPath(
123
+ "packages/claude-dev-env/scripts/automatic_advisory/publisher.py"
124
+ ): frozenset(
125
+ {
126
+ PurePosixPath(
127
+ "packages/claude-dev-env/scripts/tests/test_automatic_advisory_repairs.py"
128
+ ),
129
+ }
130
+ ),
131
+ PurePosixPath(
132
+ "packages/claude-dev-env/scripts/automatic_advisory/runner.py"
133
+ ): frozenset(
134
+ {
135
+ PurePosixPath(
136
+ "packages/claude-dev-env/scripts/tests/test_automatic_advisory.py"
137
+ ),
138
+ PurePosixPath(
139
+ "packages/claude-dev-env/scripts/tests/test_automatic_advisory_recovery.py"
140
+ ),
141
+ PurePosixPath(
142
+ "packages/claude-dev-env/scripts/tests/test_closed_pr_label.py"
143
+ ),
144
+ }
145
+ ),
146
+ PurePosixPath(
147
+ "packages/claude-dev-env/scripts/automatic_advisory/state.py"
148
+ ): frozenset(
149
+ {
150
+ PurePosixPath(
151
+ "packages/claude-dev-env/scripts/tests/test_closed_pr_label.py"
152
+ ),
153
+ }
154
+ ),
155
+ PurePosixPath(
156
+ "packages/claude-dev-env/scripts/automatic_advisory/window_flags.py"
157
+ ): frozenset(
158
+ {
159
+ PurePosixPath(
160
+ "packages/claude-dev-env/scripts/tests/test_automatic_advisory_window_flags.py"
161
+ ),
162
+ }
163
+ ),
164
+ PurePosixPath(
165
+ "packages/claude-dev-env/scripts/automatic_advisory/windows_job.py"
166
+ ): frozenset(
167
+ {
168
+ PurePosixPath(
169
+ "packages/claude-dev-env/scripts/tests/test_automatic_advisory_job_cleanup.py"
170
+ ),
171
+ }
172
+ ),
173
+ PurePosixPath("packages/claude-dev-env/scripts/local_report_cli.py"): frozenset(
174
+ {
175
+ PurePosixPath(
176
+ "packages/claude-dev-env/scripts/tests/test_local_report_publisher_cli.py"
177
+ ),
178
+ }
179
+ ),
180
+ PurePosixPath("packages/claude-dev-env/scripts/local_report_core.py"): frozenset(
181
+ {
182
+ PurePosixPath(
183
+ "packages/claude-dev-env/scripts/tests/test_local_report_publisher.py"
184
+ ),
185
+ }
186
+ ),
187
+ PurePosixPath(
188
+ "packages/claude-dev-env/scripts/local_report_validation.py"
189
+ ): frozenset(
190
+ {
191
+ PurePosixPath(
192
+ "packages/claude-dev-env/scripts/tests/test_local_report_publisher.py"
193
+ ),
194
+ }
195
+ ),
196
+ PurePosixPath(
197
+ "packages/claude-dev-env/scripts/local_verification/check_runner.py"
198
+ ): frozenset(
199
+ {
200
+ PurePosixPath(
201
+ "packages/claude-dev-env/scripts/tests/test_local_verification.py"
202
+ ),
203
+ }
204
+ ),
205
+ PurePosixPath(
206
+ "packages/claude-dev-env/scripts/local_verification/check_support.py"
207
+ ): frozenset(
208
+ {
209
+ PurePosixPath(
210
+ "packages/claude-dev-env/scripts/tests/test_local_verification.py"
211
+ ),
212
+ }
213
+ ),
214
+ PurePosixPath(
215
+ "packages/claude-dev-env/scripts/local_verification/cli.py"
216
+ ): frozenset(
217
+ {
218
+ PurePosixPath(
219
+ "packages/claude-dev-env/scripts/tests/test_local_verification_cli.py"
220
+ ),
221
+ }
222
+ ),
223
+ PurePosixPath(
224
+ "packages/claude-dev-env/scripts/local_verification/command_runner.py"
225
+ ): frozenset(
226
+ {
227
+ PurePosixPath(
228
+ "packages/claude-dev-env/scripts/tests/test_local_verification.py"
229
+ ),
230
+ }
231
+ ),
232
+ PurePosixPath(
233
+ "packages/claude-dev-env/scripts/local_verification/git_state.py"
234
+ ): frozenset(
235
+ {
236
+ PurePosixPath(
237
+ "packages/claude-dev-env/scripts/tests/test_local_verification.py"
238
+ ),
239
+ }
240
+ ),
241
+ PurePosixPath(
242
+ "packages/claude-dev-env/scripts/local_verification/manifest.py"
243
+ ): frozenset(
244
+ {
245
+ PurePosixPath(
246
+ "packages/claude-dev-env/scripts/tests/test_local_verification.py"
247
+ ),
248
+ }
249
+ ),
250
+ PurePosixPath(
251
+ "packages/claude-dev-env/scripts/local_verification/model.py"
252
+ ): frozenset(
253
+ {
254
+ PurePosixPath(
255
+ "packages/claude-dev-env/scripts/tests/test_local_verification.py"
256
+ ),
257
+ }
258
+ ),
259
+ PurePosixPath(
260
+ "packages/claude-dev-env/scripts/local_verification/runner.py"
261
+ ): frozenset(
262
+ {
263
+ PurePosixPath(
264
+ "packages/claude-dev-env/scripts/tests/test_local_verification.py"
265
+ ),
266
+ PurePosixPath(
267
+ "packages/claude-dev-env/scripts/tests/test_local_verification_cli.py"
268
+ ),
269
+ }
270
+ ),
271
+ PurePosixPath(
272
+ "packages/claude-dev-env/scripts/pr_verification/branch_refs.py"
273
+ ): frozenset(
274
+ {
275
+ PurePosixPath(
276
+ "packages/claude-dev-env/scripts/tests/test_pr_verification_github.py"
277
+ ),
278
+ }
279
+ ),
280
+ PurePosixPath(
281
+ "packages/claude-dev-env/scripts/pr_verification/github_api.py"
282
+ ): frozenset(
283
+ {
284
+ PurePosixPath(
285
+ "packages/claude-dev-env/scripts/tests/test_pr_verification_github.py"
286
+ ),
287
+ }
288
+ ),
289
+ PurePosixPath(
290
+ "packages/claude-dev-env/scripts/pr_verification/github_parsing.py"
291
+ ): frozenset(
292
+ {
293
+ PurePosixPath(
294
+ "packages/claude-dev-env/scripts/tests/test_pr_verification_github.py"
295
+ ),
296
+ }
297
+ ),
298
+ PurePosixPath(
299
+ "packages/claude-dev-env/scripts/pr_verification/github.py"
300
+ ): frozenset(
301
+ {
302
+ PurePosixPath(
303
+ "packages/claude-dev-env/scripts/tests/test_pr_verification_github.py"
304
+ ),
305
+ }
306
+ ),
307
+ PurePosixPath("packages/claude-dev-env/scripts/pr_verification/lock.py"): frozenset(
308
+ {
309
+ PurePosixPath(
310
+ "packages/claude-dev-env/scripts/tests/test_pr_verification_lock.py"
311
+ ),
312
+ }
313
+ ),
314
+ PurePosixPath(
315
+ "packages/claude-dev-env/scripts/pr_verification/model.py"
316
+ ): frozenset(
317
+ {
318
+ PurePosixPath(
319
+ "packages/claude-dev-env/scripts/tests/test_pr_verification_github.py"
320
+ ),
321
+ }
322
+ ),
323
+ }
@@ -0,0 +1 @@
1
+ """Trusted host supervisor for local pull request verification."""