chore(ci): PR gate no longer limits a PR to 400 changed lines
- Only a feat PR still needs an accepted issue - AGENTS.md and CONTRIBUTING.md follow Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@@ -30,9 +30,7 @@ PLANNING_FOLDERS = ("openspec", ".specify", ".kiro")
30
30
FORBIDDEN_PATH_PATTERN = re.compile(rf"^({'|'.join(re.escape(folder) for folder in PLANNING_FOLDERS)})/")
31
31
WINDOWS_CODE_PATTERN = re.compile(r"^\+.*(cfg\((all\()?windows|target_os\s*=\s*\"windows\")", re.MULTILINE)
32
32
WINDOWS_PATH_PATTERN = re.compile(r"(^|/)(win32|windows)(/|_[a-z]+\.rs$)|_win(dows)?\.rs$")
33
LOCKFILE_NAMES = ("Cargo.lock", "package-lock.json", "pnpm-lock.yaml", "yarn.lock")
34
33
35
MAX_CHANGED_LINES = 400
36
34
MIN_PROBLEM_CHARACTERS = 80
37
35
MIN_REVIEW_LINES = 2
38
36
REQUIRED_SECTIONS = ("Summary", "AI model", "Tests", "Review")
@@ -102,10 +100,6 @@ def linked_issue_numbers(body: str) -> list[int]:
102
100
return sorted({int(number) for number in ISSUE_REFERENCE_PATTERN.findall(strip_comments(body))})
103
101
104
102
105
def changed_lines(files: list[ChangedFile]) -> int:
106
return sum(changed.additions + changed.deletions for changed in files if changed.path.rsplit("/", 1)[-1] not in LOCKFILE_NAMES)
107
108
109
103
def title_type(title: str) -> str:
110
104
return title.split("(", 1)[0].split(":", 1)[0].split("!", 1)[0].strip()
111
105
@@ -137,15 +131,11 @@ def check(pull_request: PullRequest) -> list[str]:
137
131
"a linked issue (`Closes #123`) replaces this section."
138
132
)
139
133
140
size = changed_lines(pull_request.files)
141
needs_accepted_issue = title_type(pull_request.title) == "feat" or size > MAX_CHANGED_LINES
142
if needs_accepted_issue:
134
if title_type(pull_request.title) == "feat":
143
135
accepted = any(LABEL_ACCEPTED in pull_request.linked_issue_labels.get(number, []) for number in issue_numbers)
144
136
if not accepted:
145
reason = "a feature" if title_type(pull_request.title) == "feat" else f"{size} changed lines (over {MAX_CHANGED_LINES})"
146
137
missing.append(
147
f"**Issue first**: this PR is {reason}. Link an issue that a maintainer marked `{LABEL_ACCEPTED}`, "
148
"or split the change into smaller PRs."
138
f"**Issue first**: this PR is a feature. Link an issue that a maintainer marked `{LABEL_ACCEPTED}`."
149
139
)
150
140
151
141
if any(UI_PATH_PATTERN.search(path) for path in paths) and LABEL_NO_VISUAL not in pull_request.labels:
@@ -30,9 +30,7 @@ PLANNING_FOLDERS = ("openspec", ".specify", ".kiro")30
FORBIDDEN_PATH_PATTERN = re.compile(rf"^({'|'.join(re.escape(folder) for folder in PLANNING_FOLDERS)})/")30
FORBIDDEN_PATH_PATTERN = re.compile(rf"^({'|'.join(re.escape(folder) for folder in PLANNING_FOLDERS)})/")31
WINDOWS_CODE_PATTERN = re.compile(r"^\+.*(cfg\((all\()?windows|target_os\s*=\s*\"windows\")", re.MULTILINE)31
WINDOWS_CODE_PATTERN = re.compile(r"^\+.*(cfg\((all\()?windows|target_os\s*=\s*\"windows\")", re.MULTILINE)32
WINDOWS_PATH_PATTERN = re.compile(r"(^|/)(win32|windows)(/|_[a-z]+\.rs$)|_win(dows)?\.rs$")32
WINDOWS_PATH_PATTERN = re.compile(r"(^|/)(win32|windows)(/|_[a-z]+\.rs$)|_win(dows)?\.rs$")33
LOCKFILE_NAMES = ("Cargo.lock", "package-lock.json", "pnpm-lock.yaml", "yarn.lock")34
33
35
MAX_CHANGED_LINES = 40036
MIN_PROBLEM_CHARACTERS = 8034
MIN_PROBLEM_CHARACTERS = 8037
MIN_REVIEW_LINES = 235
MIN_REVIEW_LINES = 238
REQUIRED_SECTIONS = ("Summary", "AI model", "Tests", "Review")36
REQUIRED_SECTIONS = ("Summary", "AI model", "Tests", "Review")@@ -102,10 +100,6 @@ def linked_issue_numbers(body: str) -> list[int]:102
return sorted({int(number) for number in ISSUE_REFERENCE_PATTERN.findall(strip_comments(body))})100
return sorted({int(number) for number in ISSUE_REFERENCE_PATTERN.findall(strip_comments(body))})103
101
104
102
105
def changed_lines(files: list[ChangedFile]) -> int:106
return sum(changed.additions + changed.deletions for changed in files if changed.path.rsplit("/", 1)[-1] not in LOCKFILE_NAMES)107
108
109
def title_type(title: str) -> str:103
def title_type(title: str) -> str:110
return title.split("(", 1)[0].split(":", 1)[0].split("!", 1)[0].strip()104
return title.split("(", 1)[0].split(":", 1)[0].split("!", 1)[0].strip()111
105
@@ -137,15 +131,11 @@ def check(pull_request: PullRequest) -> list[str]:137
"a linked issue (`Closes #123`) replaces this section."131
"a linked issue (`Closes #123`) replaces this section."138
)132
)139
133
140
size = changed_lines(pull_request.files)134
if title_type(pull_request.title) == "feat":141
needs_accepted_issue = title_type(pull_request.title) == "feat" or size > MAX_CHANGED_LINES142
if needs_accepted_issue:143
accepted = any(LABEL_ACCEPTED in pull_request.linked_issue_labels.get(number, []) for number in issue_numbers)135
accepted = any(LABEL_ACCEPTED in pull_request.linked_issue_labels.get(number, []) for number in issue_numbers)144
if not accepted:136
if not accepted:145
reason = "a feature" if title_type(pull_request.title) == "feat" else f"{size} changed lines (over {MAX_CHANGED_LINES})"146
missing.append(137
missing.append(147
f"**Issue first**: this PR is {reason}. Link an issue that a maintainer marked `{LABEL_ACCEPTED}`, "138
f"**Issue first**: this PR is a feature. Link an issue that a maintainer marked `{LABEL_ACCEPTED}`."148
"or split the change into smaller PRs."149
)139
)150
140
151
if any(UI_PATH_PATTERN.search(path) for path in paths) and LABEL_NO_VISUAL not in pull_request.labels:141
if any(UI_PATH_PATTERN.search(path) for path in paths) and LABEL_NO_VISUAL not in pull_request.labels:@@ -79,11 +79,9 @@ class GateTests(unittest.TestCase):
79
79
self.assertIn("Issue first", missing_keys(make(title=title, body=body, issue_labels={7: ["enhancement"]})))
80
80
self.assertEqual(check(make(title=title, body=body, issue_labels={7: [LABEL_ACCEPTED]})), [])
81
81
82
def test_large_fix_needs_accepted_issue_but_lockfile_does_not_count(self):
83
large = [ChangedFile("crates/chatsvc/src/window.rs", 350, 100)]
84
self.assertIn("Issue first", missing_keys(make(files=large)))
85
lock = [BACKEND_FILE, ChangedFile("Cargo.lock", 900, 900)]
86
self.assertEqual(check(make(files=lock)), [])
82
def test_large_fix_needs_no_issue(self):
83
large = [ChangedFile("crates/chatsvc/src/window.rs", 3500, 1000)]
84
self.assertEqual(check(make(files=large)), [])
87
85
88
86
def test_ui_change_needs_screenshot(self):
89
87
self.assertIn("Screenshot", missing_keys(make(files=[UI_FILE])))
@@ -126,7 +124,6 @@ class DocumentationTests(unittest.TestCase):
126
124
127
125
def shared_values(self):
128
126
return (
129
f"more than {pr_gate.MAX_CHANGED_LINES} changed lines",
130
127
pr_gate.LABEL_ACCEPTED,
131
128
pr_gate.LABEL_NO_VISUAL,
132
129
pr_gate.LABEL_SKIP,
@@ -79,11 +79,9 @@ class GateTests(unittest.TestCase):79
self.assertIn("Issue first", missing_keys(make(title=title, body=body, issue_labels={7: ["enhancement"]})))79
self.assertIn("Issue first", missing_keys(make(title=title, body=body, issue_labels={7: ["enhancement"]})))80
self.assertEqual(check(make(title=title, body=body, issue_labels={7: [LABEL_ACCEPTED]})), [])80
self.assertEqual(check(make(title=title, body=body, issue_labels={7: [LABEL_ACCEPTED]})), [])81
81
82
def test_large_fix_needs_accepted_issue_but_lockfile_does_not_count(self):82
def test_large_fix_needs_no_issue(self):83
large = [ChangedFile("crates/chatsvc/src/window.rs", 350, 100)]83
large = [ChangedFile("crates/chatsvc/src/window.rs", 3500, 1000)]84
self.assertIn("Issue first", missing_keys(make(files=large)))84
self.assertEqual(check(make(files=large)), [])85
lock = [BACKEND_FILE, ChangedFile("Cargo.lock", 900, 900)]86
self.assertEqual(check(make(files=lock)), [])87
85
88
def test_ui_change_needs_screenshot(self):86
def test_ui_change_needs_screenshot(self):89
self.assertIn("Screenshot", missing_keys(make(files=[UI_FILE])))87
self.assertIn("Screenshot", missing_keys(make(files=[UI_FILE])))@@ -126,7 +124,6 @@ class DocumentationTests(unittest.TestCase):126
124
127
def shared_values(self):125
def shared_values(self):128
return (126
return (129
f"more than {pr_gate.MAX_CHANGED_LINES} changed lines",130
pr_gate.LABEL_ACCEPTED,127
pr_gate.LABEL_ACCEPTED,131
pr_gate.LABEL_NO_VISUAL,128
pr_gate.LABEL_NO_VISUAL,132
pr_gate.LABEL_SKIP,129
pr_gate.LABEL_SKIP,@@ -36,7 +36,7 @@ The body has `## Summary`, `## AI model`, `## Tests` and `## Review`, plus `## P
36
36
2. A reviewer must not have written the change. Use a fresh agent session, a subagent, or a review command such as `/code-review` or `/review`. On Copilot, a Copilot code review on the draft PR counts as one.
37
37
3. Fix or answer every valid finding. In `## Review`, write at least two non-empty lines: one line per review (what ran it), then one line per finding: fixed, or not fixed and why.
38
38
4. No `Closes` / `Fixes` / `Resolves` plus `#n` or an issue URL on this repo: write `## Problem` (at least 80 characters). Say what is wrong or missing, when a user hits it (steps or when/then), and what should happen instead. Write `Closes #123` only when that issue exists.
39
5. A `feat` PR, or more than 400 changed lines (lockfiles do not count), needs an issue labelled `status: accepted`. A maintainer sets that label. Do not add it yourself. Without it, do not mark the PR ready: say so, or split the change.
39
5. A `feat` PR needs an issue labelled `status: accepted`. A maintainer sets that label. Do not add it yourself. Without it, do not mark the PR ready: say so.
40
40
6. A change under `crates/app/src/views/`, `settings/`, `components/`, `widgets/`, a `crates/app/src/*_view.rs` file, or `locales/` needs a screenshot in the body, taken with `cargo run -p app -- --demo` or `scripts/headless-shot.sh`. No visible change: tick `- [x] No visible change` and say why. Never a real account.
41
41
7. In `## Tests`, say what ran and what did not. If the diff touches Windows-only code, say whether you built it on Windows.
42
42
8. No planning folders in the diff (`openspec/`, `.specify/`, `.kiro/`). A `vendor/` change says why in the summary. At most 5 open PRs, drafts included.
@@ -36,7 +36,7 @@ The body has `## Summary`, `## AI model`, `## Tests` and `## Review`, plus `## P36
2. A reviewer must not have written the change. Use a fresh agent session, a subagent, or a review command such as `/code-review` or `/review`. On Copilot, a Copilot code review on the draft PR counts as one.36
2. A reviewer must not have written the change. Use a fresh agent session, a subagent, or a review command such as `/code-review` or `/review`. On Copilot, a Copilot code review on the draft PR counts as one.37
3. Fix or answer every valid finding. In `## Review`, write at least two non-empty lines: one line per review (what ran it), then one line per finding: fixed, or not fixed and why.37
3. Fix or answer every valid finding. In `## Review`, write at least two non-empty lines: one line per review (what ran it), then one line per finding: fixed, or not fixed and why.38
4. No `Closes` / `Fixes` / `Resolves` plus `#n` or an issue URL on this repo: write `## Problem` (at least 80 characters). Say what is wrong or missing, when a user hits it (steps or when/then), and what should happen instead. Write `Closes #123` only when that issue exists.38
4. No `Closes` / `Fixes` / `Resolves` plus `#n` or an issue URL on this repo: write `## Problem` (at least 80 characters). Say what is wrong or missing, when a user hits it (steps or when/then), and what should happen instead. Write `Closes #123` only when that issue exists.39
5. A `feat` PR, or more than 400 changed lines (lockfiles do not count), needs an issue labelled `status: accepted`. A maintainer sets that label. Do not add it yourself. Without it, do not mark the PR ready: say so, or split the change.39
5. A `feat` PR needs an issue labelled `status: accepted`. A maintainer sets that label. Do not add it yourself. Without it, do not mark the PR ready: say so.40
6. A change under `crates/app/src/views/`, `settings/`, `components/`, `widgets/`, a `crates/app/src/*_view.rs` file, or `locales/` needs a screenshot in the body, taken with `cargo run -p app -- --demo` or `scripts/headless-shot.sh`. No visible change: tick `- [x] No visible change` and say why. Never a real account.40
6. A change under `crates/app/src/views/`, `settings/`, `components/`, `widgets/`, a `crates/app/src/*_view.rs` file, or `locales/` needs a screenshot in the body, taken with `cargo run -p app -- --demo` or `scripts/headless-shot.sh`. No visible change: tick `- [x] No visible change` and say why. Never a real account.41
7. In `## Tests`, say what ran and what did not. If the diff touches Windows-only code, say whether you built it on Windows.41
7. In `## Tests`, say what ran and what did not. If the diff touches Windows-only code, say whether you built it on Windows.42
8. No planning folders in the diff (`openspec/`, `.specify/`, `.kiro/`). A `vendor/` change says why in the summary. At most 5 open PRs, drafts included.42
8. No planning folders in the diff (`openspec/`, `.specify/`, `.kiro/`). A `vendor/` change says why in the summary. At most 5 open PRs, drafts included.@@ -8,7 +8,7 @@ Most of this code is written with AI agents, and that is welcome here. Just say
8
8
|---|---|
9
9
| 1 | Read [GUARDRAILS.md](GUARDRAILS.md): where the app must match Teams and where it may differ. It wins over any habit. |
10
10
| 2 | Check [ROADMAP.md](ROADMAP.md), mainly "Out of scope". Features listed there are not merged. |
11
| 3 | Search open pull requests and issues for the same topic. For a feature or anything over 400 changed lines, open an issue first and wait for the `status: accepted` label. |
11
| 3 | Search open pull requests and issues for the same topic. For a feature, open an issue first and wait for the `status: accepted` label. |
12
12
| 4 | Read the notes under [docs/decisions/](docs/decisions/README.md) for the area you touch. |
13
13
14
14
## AI use
@@ -39,7 +39,7 @@ A bot check (`PR gate`) runs on every PR that is not a draft. Until it passes, t
39
39
| Title | `type(scope): message`, from the user's view |
40
40
| Template | Summary, AI model, Tests and Review filled in, not just the hints |
41
41
| Problem | No `Closes #123`: a Problem section says what is wrong or missing, when a user hits it (steps or when/then) and what should happen instead |
42
| Issue first | A `feat` PR or more than 400 changed lines (lockfiles do not count) links an issue labelled `status: accepted` |
42
| Issue first | A `feat` PR links an issue labelled `status: accepted` |
43
43
| Screenshot | A change to UI code (`crates/app/src/views/`, `settings/`, `components/`, `widgets/`, `*_view.rs`, `locales/`) shows the changed area with demo data, or ticks "No visible change" with a reason |
44
44
| Tests | What ran and what did not. A change to Windows-only code says whether it was built on Windows |
45
45
| Review | At least two independent reviews, each finding fixed or answered |
@@ -8,7 +8,7 @@ Most of this code is written with AI agents, and that is welcome here. Just say8
|---|---|8
|---|---|9
| 1 | Read [GUARDRAILS.md](GUARDRAILS.md): where the app must match Teams and where it may differ. It wins over any habit. |9
| 1 | Read [GUARDRAILS.md](GUARDRAILS.md): where the app must match Teams and where it may differ. It wins over any habit. |10
| 2 | Check [ROADMAP.md](ROADMAP.md), mainly "Out of scope". Features listed there are not merged. |10
| 2 | Check [ROADMAP.md](ROADMAP.md), mainly "Out of scope". Features listed there are not merged. |11
| 3 | Search open pull requests and issues for the same topic. For a feature or anything over 400 changed lines, open an issue first and wait for the `status: accepted` label. |11
| 3 | Search open pull requests and issues for the same topic. For a feature, open an issue first and wait for the `status: accepted` label. |12
| 4 | Read the notes under [docs/decisions/](docs/decisions/README.md) for the area you touch. |12
| 4 | Read the notes under [docs/decisions/](docs/decisions/README.md) for the area you touch. |13
13
14
## AI use14
## AI use@@ -39,7 +39,7 @@ A bot check (`PR gate`) runs on every PR that is not a draft. Until it passes, t39
| Title | `type(scope): message`, from the user's view |39
| Title | `type(scope): message`, from the user's view |40
| Template | Summary, AI model, Tests and Review filled in, not just the hints |40
| Template | Summary, AI model, Tests and Review filled in, not just the hints |41
| Problem | No `Closes #123`: a Problem section says what is wrong or missing, when a user hits it (steps or when/then) and what should happen instead |41
| Problem | No `Closes #123`: a Problem section says what is wrong or missing, when a user hits it (steps or when/then) and what should happen instead |42
| Issue first | A `feat` PR or more than 400 changed lines (lockfiles do not count) links an issue labelled `status: accepted` |42
| Issue first | A `feat` PR links an issue labelled `status: accepted` |43
| Screenshot | A change to UI code (`crates/app/src/views/`, `settings/`, `components/`, `widgets/`, `*_view.rs`, `locales/`) shows the changed area with demo data, or ticks "No visible change" with a reason |43
| Screenshot | A change to UI code (`crates/app/src/views/`, `settings/`, `components/`, `widgets/`, `*_view.rs`, `locales/`) shows the changed area with demo data, or ticks "No visible change" with a reason |44
| Tests | What ran and what did not. A change to Windows-only code says whether it was built on Windows |44
| Tests | What ran and what did not. A change to Windows-only code says whether it was built on Windows |45
| Review | At least two independent reviews, each finding fixed or answered |45
| Review | At least two independent reviews, each finding fixed or answered |