claude-dev-env 8.116.1 → 8.116.2
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/docs/rule-guides/proof-before-pull-request.md +4 -2
- package/hooks/blocking/followup_pr_dedupe.py +118 -33
- package/hooks/blocking/gate_run_reads.py +284 -0
- package/hooks/blocking/pr_lifecycle_skill_gate.py +33 -33
- package/hooks/blocking/pull_request_proof.py +60 -63
- package/hooks/blocking/test_followup_pr_dedupe.py +59 -0
- package/hooks/blocking/test_gate_run_reads.py +241 -0
- package/hooks/blocking/test_pr_lifecycle_skill_gate.py +89 -1
- package/hooks/blocking/test_pull_request_proof.py +63 -2
- package/hooks/features/conduct-gates.md +1 -1
- package/hooks/hooks.json +1 -1
- package/hooks/hooks_constants/gate_run_reads_constants.py +10 -0
- package/hooks/hooks_constants/test_followup_pr_dedupe_constants.py +0 -4
- package/package.json +1 -1
|
@@ -12,6 +12,7 @@ if str(HOOKS_DIRECTORY) not in sys.path:
|
|
|
12
12
|
sys.path.insert(0, str(HOOKS_DIRECTORY))
|
|
13
13
|
|
|
14
14
|
from blocking import pull_request_proof as gate
|
|
15
|
+
from blocking.pr_lifecycle_skill_gate import decision_for
|
|
15
16
|
from hooks_constants.pull_request_proof_constants import (
|
|
16
17
|
COMPARE_FILE_LIST_LIMIT,
|
|
17
18
|
COMPARE_FILE_STATUS_QUERY,
|
|
@@ -764,7 +765,7 @@ def test_should_deny_a_visible_file_on_a_full_compare_page(
|
|
|
764
765
|
assert "module_0.py" not in reason
|
|
765
766
|
|
|
766
767
|
|
|
767
|
-
def
|
|
768
|
+
def test_should_allow_a_page_whose_proof_links_an_artifact_without_a_read(
|
|
768
769
|
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
|
|
769
770
|
) -> None:
|
|
770
771
|
all_endpoints: list[str] = []
|
|
@@ -777,7 +778,7 @@ def test_should_allow_a_page_the_compare_api_lists_when_the_proof_links_an_artif
|
|
|
777
778
|
tmp_path,
|
|
778
779
|
)
|
|
779
780
|
assert gate.missing_look_reason(payload) is None
|
|
780
|
-
assert all_endpoints == [
|
|
781
|
+
assert all_endpoints == []
|
|
781
782
|
|
|
782
783
|
|
|
783
784
|
def test_should_skip_the_compare_api_without_a_named_repository(
|
|
@@ -1112,6 +1113,66 @@ def test_remote_added_workflow_files_should_report_none_when_a_full_page_lists_n
|
|
|
1112
1113
|
assert gate.remote_added_workflow_files(None, "main", "feature") is None
|
|
1113
1114
|
|
|
1114
1115
|
|
|
1116
|
+
WAIVER_BODY = (
|
|
1117
|
+
"## What this does\nAdds a guard to the tool.\n\n"
|
|
1118
|
+
"```mermaid\nflowchart LR\n A[call] --> B[guard]\n```\n\n"
|
|
1119
|
+
"## Existing work\nNothing found; I searched `hooks/` and open pull requests.\n\n"
|
|
1120
|
+
"## Proof in practice\nRan `python3 tool.py --check` and it printed `ok`.\n"
|
|
1121
|
+
"Not run: the first GitHub Actions workflow run.\n\n"
|
|
1122
|
+
"## After merge\nThe session records the run link for `new.yml`.\n"
|
|
1123
|
+
)
|
|
1124
|
+
|
|
1125
|
+
|
|
1126
|
+
def test_quoted_shell_create_should_look_up_the_added_workflows_once(
|
|
1127
|
+
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
|
|
1128
|
+
) -> None:
|
|
1129
|
+
all_endpoints: list[str] = []
|
|
1130
|
+
compare_endpoint = "repos/owner/name/compare/main...some-branch"
|
|
1131
|
+
all_responses = {compare_endpoint: _workflow_compare_lines(1, [f"{WORKFLOW_DIRECTORY}/new.yml"])}
|
|
1132
|
+
monkeypatch.setattr(gate, "_gh_api_lines", _fake_gh_api(all_responses, all_endpoints))
|
|
1133
|
+
(tmp_path / "body.md").write_text(WAIVER_BODY, encoding="utf-8")
|
|
1134
|
+
payload = _shell(
|
|
1135
|
+
'gh pr create --title "fix: quoted title" --body-file body.md'
|
|
1136
|
+
" --head some-branch --base main --repo owner/name",
|
|
1137
|
+
tmp_path,
|
|
1138
|
+
)
|
|
1139
|
+
assert gate.missing_proof_reason(payload) is None
|
|
1140
|
+
assert all_endpoints.count(compare_endpoint) == 1
|
|
1141
|
+
|
|
1142
|
+
|
|
1143
|
+
def test_look_check_should_read_nothing_when_every_body_shows_a_picture(
|
|
1144
|
+
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
|
|
1145
|
+
) -> None:
|
|
1146
|
+
all_endpoints: list[str] = []
|
|
1147
|
+
monkeypatch.setattr(gate, "_gh_api_lines", _fake_gh_api({}, all_endpoints))
|
|
1148
|
+
body = PROVEN_BODY + "\n"
|
|
1149
|
+
payload = _shell_create_elsewhere(tmp_path, "--repo o/r --base main --head feature", body)
|
|
1150
|
+
assert gate.missing_look_reason(payload) is None
|
|
1151
|
+
assert all_endpoints == []
|
|
1152
|
+
no_picture_payload = _shell_create_elsewhere(tmp_path, "--repo o/r --base main --head feature")
|
|
1153
|
+
assert gate.missing_look_reason(no_picture_payload) == UNREADABLE_CHANGES_REASON
|
|
1154
|
+
assert all_endpoints == ["repos/o/r/compare/main...feature"]
|
|
1155
|
+
|
|
1156
|
+
|
|
1157
|
+
def test_one_gate_run_should_resolve_the_merge_base_once_for_the_waiver_and_look_checks(
|
|
1158
|
+
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
|
|
1159
|
+
) -> None:
|
|
1160
|
+
clone_path = _repository_with_workflow_change(tmp_path, "new.yml")
|
|
1161
|
+
all_head_references: list[str] = []
|
|
1162
|
+
original_first_merge_base = gate._first_merge_base
|
|
1163
|
+
|
|
1164
|
+
def counted_first_merge_base(working_directory: str, head_reference: str) -> str | None:
|
|
1165
|
+
all_head_references.append(head_reference)
|
|
1166
|
+
return original_first_merge_base(working_directory, head_reference)
|
|
1167
|
+
|
|
1168
|
+
monkeypatch.setattr(gate, "_first_merge_base", counted_first_merge_base)
|
|
1169
|
+
payload = _mcp_create_on_branch(WAIVER_BODY, clone_path)
|
|
1170
|
+
assert decision_for(payload) is None
|
|
1171
|
+
assert all_head_references == ["HEAD"]
|
|
1172
|
+
assert decision_for(payload) is None
|
|
1173
|
+
assert all_head_references == ["HEAD", "HEAD"]
|
|
1174
|
+
|
|
1175
|
+
|
|
1115
1176
|
def test_unproven_line_should_stay_denied_when_it_is_about_something_other_than_a_run(tmp_path: Path) -> None:
|
|
1116
1177
|
clone_path = _repository_with_workflow_change(tmp_path, NEW_WORKFLOW_NAME)
|
|
1117
1178
|
unrelated_line = "Untested on Windows."
|
|
@@ -39,7 +39,7 @@ This family stops a chat reply, edited message, or tool call when its payload br
|
|
|
39
39
|
- `blocking/step_note_gate.py` runs on `PreToolUse`, matcher `*`, timeout `15` seconds in `hooks.json`.
|
|
40
40
|
- `blocking/wakeup_cap_gate.py` runs on `PreToolUse`, matcher `ScheduleWakeup|CronCreate|mcp__.*__(send_later|create_trigger|update_trigger)`, timeout `10` seconds in `hooks.json`.
|
|
41
41
|
- `blocking/verify_before_acting.py` runs on `PostToolUse`, matcher `Write|Edit|MultiEdit|NotebookEdit|Agent|Task|apply_patch|Bash|PowerShell|mcp__.*`, timeout `10` seconds in `hooks.json`.
|
|
42
|
-
- `blocking/pr_lifecycle_skill_gate.py` runs on `PreToolUse`, matcher `Bash|PowerShell|mcp__.*__(create_pull_request|merge_pull_request|enable_pr_auto_merge|update_pull_request|actions_run_trigger)`, timeout `
|
|
42
|
+
- `blocking/pr_lifecycle_skill_gate.py` runs on `PreToolUse`, matcher `Bash|PowerShell|mcp__.*__(create_pull_request|merge_pull_request|enable_pr_auto_merge|update_pull_request|actions_run_trigger)`, timeout `30` seconds in `hooks.json`. The gate's git and GitHub reads end by 21 s after its read clock starts (a 20 s deadline and a 1 s grace for a stopped child).
|
|
43
43
|
- `blocking/resolve_thread_reply_gate.py` runs on `PreToolUse`, matcher `Bash|PowerShell|mcp__.*__resolve_review_thread|mcp__.*__pull_request_review_write`, timeout `10` seconds in `hooks.json`.
|
|
44
44
|
- `blocking/verify_before_commit_gate.py` runs on `PreToolUse`, matcher `Bash|PowerShell`, timeout `30` seconds in `hooks.json`.
|
|
45
45
|
- `blocking/build_eval_before_eval_write_gate.py` runs on `PreToolUse`, matcher `Write|Edit|MultiEdit|NotebookEdit|apply_patch`, timeout `10` seconds in `hooks.json`.
|
package/hooks/hooks.json
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"""Constants for the read deadlines of one pull request lifecycle gate run."""
|
|
2
|
+
|
|
3
|
+
PROOF_AND_LOOK_READS_SECONDS = 12
|
|
4
|
+
FOLLOWUP_READS_SECONDS = 8
|
|
5
|
+
KILL_GRACE_SECONDS = 1
|
|
6
|
+
MOST_CUT_READS_PER_RUN = 2
|
|
7
|
+
STARTUP_AND_SCAN_MARGIN_SECONDS = 5
|
|
8
|
+
READS_RAN_OUT_SENTENCE = (
|
|
9
|
+
" The gate's git and GitHub reads ran out of time on this run, so a second run may pass."
|
|
10
|
+
)
|
|
@@ -6,7 +6,3 @@ from hooks_constants import followup_pr_dedupe_constants as constants
|
|
|
6
6
|
def test_parent_pattern_reads_both_spellings_and_stops_at_the_number() -> None:
|
|
7
7
|
assert re.search(constants.FOLLOWUP_PARENT_PATTERN, "followup to #12", re.IGNORECASE)
|
|
8
8
|
assert re.search(constants.FOLLOWUP_PARENT_PATTERN, "Follow-up to #1731", re.IGNORECASE).group(1) == "1731"
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
def test_read_timeout_fits_inside_the_hook_timeout() -> None:
|
|
12
|
-
assert constants.READ_TIMEOUT_SECONDS * 2 < 10
|