feat: add architecture support validation for backport judgment#11
Conversation
There was a problem hiding this comment.
Pull request overview
Adds an architecture-specific change filter to the pre-judging flow so backport decisions can be rejected when a commit modifies unsupported arch/* code.
Changes:
- Introduce
ArchAnalyzerto detectarch/<arch>/...modifications and verify they’re within an allowlist of supported downstream architectures. - Integrate a new “architecture supported” gate into
PrejudgeController.analyze_and_report()after config enablement checks.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/prejudge/prejudge.py |
Adds judge_arch() and wires an additional architecture-support validation step into the final true/false output. |
src/prejudge/judge_arch.py |
New analyzer that lists files changed by a commit and determines whether any arch/* changes target unsupported architectures. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| def get_patch_files(self, commit_id: str) -> List[str]: | ||
| """ | ||
| Get list of files modified by a commit | ||
| Returns list of file paths | ||
| """ | ||
| try: | ||
| result = subprocess.run( | ||
| ['git', 'show', '--name-only', '--pretty=format:', commit_id], | ||
| cwd=self.kernel_dir, | ||
| capture_output=True, | ||
| text=True, | ||
| timeout=10 | ||
| ) | ||
|
|
||
| if result.returncode != 0: | ||
| return [] | ||
|
|
||
| # Filter out empty lines | ||
| files = [f.strip() for f in result.stdout.splitlines() if f.strip()] | ||
| return files |
There was a problem hiding this comment.
get_patch_files() passes commit_id directly to git show. Since commit_id is user-provided (CLI arg via prejudge.py), a value starting with - (or a crafted revspec) can be interpreted as a git option/revspec and produce unexpected behavior. Consider validating commit_id up-front (e.g., only allow SHA-1/short SHA patterns, or resolve with git rev-parse --verify <id>^{commit}) and fail the analysis explicitly when validation fails.
| def get_arch_from_path(self, file_path: str) -> str: | ||
| """ | ||
| Extract architecture name from file path | ||
| Returns the architecture name if the file is under arch/, None otherwise | ||
| """ | ||
| # Check if file is under arch/ directory | ||
| if file_path.startswith('arch/'): | ||
| # Extract architecture name | ||
| # Format: arch/<arch_name>/... | ||
| match = re.match(r'arch/([^/]+)', file_path) | ||
| if match: | ||
| return match.group(1) | ||
|
|
||
| return None |
There was a problem hiding this comment.
get_arch_from_path() is annotated to return str but it returns None when the path is not under arch/. Please update the return type to Optional[str] (or str | None on Python 3.10+) to match actual behavior and avoid type-checking/runtime confusion.
| import subprocess | ||
| from pathlib import Path | ||
| from typing import Set, List |
There was a problem hiding this comment.
Set is imported from typing but not used in this module. Please remove the unused import to keep linting clean.
No description provided.