88from pathlib import Path
99
1010
11- HUMAN_TESTED_TEXT = "A human has tested these changes."
1211# Reject placeholders while allowing a concise human-written sentence.
1312MIN_HUMAN_NOTE_CHARS = 20
1413# These are the only PR-template sections that must remain and contain content.
2019AGENT_HEADING_RE = re .compile (r"(?im)^\s*AGENT:\s*$" )
2120
2221
23- def checkbox_re (label : str ) -> re .Pattern [str ]:
24- return re .compile (rf"(?im)^\s*[-*]\s+\[(?P<mark>[ xX])]\s+{ re .escape (label )} \s*$" )
25-
26-
27- def checkbox_is_checked (pattern : re .Pattern [str ], text : str ) -> bool :
28- match = pattern .search (text )
29- return match is not None and match .group ("mark" ).lower () == "x"
30-
31-
32- HUMAN_TESTED_RE = checkbox_re (HUMAN_TESTED_TEXT )
33-
34-
3522def visible_text (text : str ) -> str :
3623 """Return PR body content that should count as author-provided text."""
3724 lines = []
@@ -61,16 +48,16 @@ def extract_sections(body: str) -> dict[str, str]:
6148
6249
6350def extract_human_note (body : str ) -> str :
64- """Return human-written text in the required location before the checkbox ."""
51+ """Return human-written text in the required location before AGENT ."""
6552 human_match = HUMAN_HEADING_RE .search (body )
6653 if human_match is None :
6754 return ""
6855
69- checkbox_match = HUMAN_TESTED_RE .search (body , human_match .end ())
70- if checkbox_match is None :
56+ agent_match = AGENT_HEADING_RE .search (body , human_match .end ())
57+ if agent_match is None :
7158 return ""
7259
73- return visible_text (body [human_match .end () : checkbox_match .start ()])
60+ return visible_text (body [human_match .end () : agent_match .start ()])
7461
7562
7663def validate_pr_body (body : str ) -> list [str ]:
@@ -81,20 +68,7 @@ def validate_pr_body(body: str) -> list[str]:
8168
8269 human_note = extract_human_note (body )
8370 if len (human_note ) < MIN_HUMAN_NOTE_CHARS :
84- errors .append (
85- "Add a short human-written note between `HUMAN:` and "
86- "the human-tested checkbox."
87- )
88-
89- human_tested = HUMAN_TESTED_RE .search (body )
90- if human_tested is None :
91- errors .append (
92- f"Keep the `- [ ] { HUMAN_TESTED_TEXT } ` checkbox in the PR description."
93- )
94- elif not checkbox_is_checked (HUMAN_TESTED_RE , body ):
95- errors .append (
96- "A human must check `A human has tested these changes.` before review."
97- )
71+ errors .append ("Add a short human-written note between `HUMAN:` and `AGENT:`." )
9872
9973 if AGENT_HEADING_RE .search (body ) is None :
10074 errors .append ("Keep the `AGENT:` marker from the PR template." )
0 commit comments