scopeproof 0.1.4__tar.gz

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 (55) hide show
  1. scopeproof-0.1.4/LICENSE +22 -0
  2. scopeproof-0.1.4/PKG-INFO +217 -0
  3. scopeproof-0.1.4/README.md +183 -0
  4. scopeproof-0.1.4/pyproject.toml +73 -0
  5. scopeproof-0.1.4/scopeproof/__init__.py +3 -0
  6. scopeproof-0.1.4/scopeproof/__main__.py +6 -0
  7. scopeproof-0.1.4/scopeproof/checks/__init__.py +2 -0
  8. scopeproof-0.1.4/scopeproof/checks/base.py +105 -0
  9. scopeproof-0.1.4/scopeproof/checks/changed_file_growth.py +35 -0
  10. scopeproof-0.1.4/scopeproof/checks/duplicate_symbol.py +92 -0
  11. scopeproof-0.1.4/scopeproof/checks/module_sprawl.py +163 -0
  12. scopeproof-0.1.4/scopeproof/checks/orphan_new_file.py +104 -0
  13. scopeproof-0.1.4/scopeproof/checks/parse_error.py +63 -0
  14. scopeproof-0.1.4/scopeproof/checks/public_api_growth.py +43 -0
  15. scopeproof-0.1.4/scopeproof/checks/runner.py +109 -0
  16. scopeproof-0.1.4/scopeproof/checks/scope_escape.py +66 -0
  17. scopeproof-0.1.4/scopeproof/cli.py +283 -0
  18. scopeproof-0.1.4/scopeproof/config.py +239 -0
  19. scopeproof-0.1.4/scopeproof/errors.py +26 -0
  20. scopeproof-0.1.4/scopeproof/git.py +152 -0
  21. scopeproof-0.1.4/scopeproof/indexer/__init__.py +2 -0
  22. scopeproof-0.1.4/scopeproof/indexer/python_ast.py +118 -0
  23. scopeproof-0.1.4/scopeproof/indexer/symbols.py +66 -0
  24. scopeproof-0.1.4/scopeproof/models.py +70 -0
  25. scopeproof-0.1.4/scopeproof/paths.py +33 -0
  26. scopeproof-0.1.4/scopeproof/prompt/__init__.py +2 -0
  27. scopeproof-0.1.4/scopeproof/prompt/generate.py +64 -0
  28. scopeproof-0.1.4/scopeproof/report/__init__.py +2 -0
  29. scopeproof-0.1.4/scopeproof/report/console.py +37 -0
  30. scopeproof-0.1.4/scopeproof/report/json_report.py +13 -0
  31. scopeproof-0.1.4/scopeproof/report/markdown.py +33 -0
  32. scopeproof-0.1.4/scopeproof/templates/AGENTS.md +34 -0
  33. scopeproof-0.1.4/scopeproof/templates/__init__.py +2 -0
  34. scopeproof-0.1.4/scopeproof/templates/scopeproof.yml +44 -0
  35. scopeproof-0.1.4/scopeproof/templates/task.yml +16 -0
  36. scopeproof-0.1.4/scopeproof.egg-info/PKG-INFO +217 -0
  37. scopeproof-0.1.4/scopeproof.egg-info/SOURCES.txt +53 -0
  38. scopeproof-0.1.4/scopeproof.egg-info/dependency_links.txt +1 -0
  39. scopeproof-0.1.4/scopeproof.egg-info/entry_points.txt +2 -0
  40. scopeproof-0.1.4/scopeproof.egg-info/requires.txt +8 -0
  41. scopeproof-0.1.4/scopeproof.egg-info/top_level.txt +1 -0
  42. scopeproof-0.1.4/setup.cfg +4 -0
  43. scopeproof-0.1.4/tests/test_changed_file_growth.py +38 -0
  44. scopeproof-0.1.4/tests/test_cli_check.py +159 -0
  45. scopeproof-0.1.4/tests/test_config.py +64 -0
  46. scopeproof-0.1.4/tests/test_duplicate_symbol.py +56 -0
  47. scopeproof-0.1.4/tests/test_git.py +108 -0
  48. scopeproof-0.1.4/tests/test_module_sprawl.py +92 -0
  49. scopeproof-0.1.4/tests/test_orphan_new_file.py +51 -0
  50. scopeproof-0.1.4/tests/test_parse_error.py +28 -0
  51. scopeproof-0.1.4/tests/test_paths.py +18 -0
  52. scopeproof-0.1.4/tests/test_prompt_generate.py +34 -0
  53. scopeproof-0.1.4/tests/test_public_api_growth.py +43 -0
  54. scopeproof-0.1.4/tests/test_python_ast_indexer.py +46 -0
  55. scopeproof-0.1.4/tests/test_scope_escape.py +30 -0
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ScopeProof Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
@@ -0,0 +1,217 @@
1
+ Metadata-Version: 2.4
2
+ Name: scopeproof
3
+ Version: 0.1.4
4
+ Summary: A tiny scope and architecture guardrail for AI coding agents.
5
+ Author: ScopeProof Contributors
6
+ Maintainer: SomeTimeDev
7
+ License-Expression: MIT
8
+ Project-URL: Homepage, https://github.com/SomeTimeDev/scopeproof
9
+ Project-URL: Repository, https://github.com/SomeTimeDev/scopeproof
10
+ Project-URL: Issues, https://github.com/SomeTimeDev/scopeproof/issues
11
+ Keywords: ai-agents,coding-agents,codex,guardrails,code-review,static-analysis,git,cli
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Environment :: Console
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3 :: Only
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Topic :: Software Development :: Quality Assurance
22
+ Classifier: Topic :: Software Development :: Version Control :: Git
23
+ Requires-Python: >=3.11
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE
26
+ Requires-Dist: typer>=0.12
27
+ Requires-Dist: pyyaml>=6.0
28
+ Requires-Dist: rich>=13.0
29
+ Requires-Dist: pathspec>=0.12
30
+ Provides-Extra: dev
31
+ Requires-Dist: pytest>=8.0; extra == "dev"
32
+ Requires-Dist: ruff>=0.5; extra == "dev"
33
+ Dynamic: license-file
34
+
35
+ # ScopeProof
36
+
37
+ AI coding agents start focused, then drift. ScopeProof keeps their changes inside your
38
+ project's scope.
39
+
40
+ It checks agent-generated diffs for needless modules, duplicate abstractions, scope escape,
41
+ orphan files, changed-file growth, parse errors, and public API growth.
42
+
43
+ No LLM required. No cloud. No vendor lock-in.
44
+
45
+ ## Problem
46
+
47
+ Small requested changes can quietly become new service layers, duplicate classes, unrelated file
48
+ edits, or public APIs that were never part of the task. ScopeProof is a deterministic CLI guardrail
49
+ for catching those signals before merge.
50
+
51
+ ## What ScopeProof Checks
52
+
53
+ - `scope_escape`: changed files outside task paths or inside forbidden paths
54
+ - `module_sprawl`: too many new files or suspicious new modules
55
+ - `changed_file_growth`: too many changed files for one task
56
+ - `parse_error`: changed Python files that cannot be parsed
57
+ - `duplicate_symbol`: new public symbols that resemble existing symbols
58
+ - `orphan_new_file`: new production Python files that are not imported or tested
59
+ - `public_api_growth`: excessive public class/function growth for one task
60
+
61
+ ## Installation
62
+
63
+ ScopeProof is not published to PyPI yet. Install the current GitHub version with:
64
+
65
+ ```bash
66
+ pip install git+https://github.com/SomeTimeDev/scopeproof.git
67
+ ```
68
+
69
+ For local development:
70
+
71
+ ```bash
72
+ pip install -e ".[dev]"
73
+ ```
74
+
75
+ ## Quickstart
76
+
77
+ ```bash
78
+ scopeproof init
79
+ scopeproof prompt "Add CSV export support"
80
+ scopeproof check --base HEAD
81
+ ```
82
+
83
+ To check exactly what is staged for the next commit:
84
+
85
+ ```bash
86
+ git add .
87
+ scopeproof check --staged
88
+ ```
89
+
90
+ For stricter projects, start with fail-on defaults for every drift check:
91
+
92
+ ```bash
93
+ scopeproof init --strict
94
+ ```
95
+
96
+ Local working-tree checks include untracked files by default. A new untracked Python module is
97
+ treated as an added file, so `scopeproof check --base HEAD` catches drift before you remember to
98
+ run `git add`. Use `--staged` when you want to ignore unstaged/untracked experiments and check only
99
+ the Git index.
100
+
101
+ For pull requests:
102
+
103
+ ```bash
104
+ scopeproof check --base origin/main --head HEAD
105
+ ```
106
+
107
+ ## Example `scopeproof.yml`
108
+
109
+ ```yaml
110
+ version: 1
111
+ project:
112
+ name: "demo"
113
+ mission: "CLI for exporting structured data."
114
+ rules:
115
+ max_changed_files_per_task: 8
116
+ max_new_files_per_task: 1
117
+ duplicate_symbol_similarity: 0.82
118
+ fail_on_module_sprawl: true
119
+ fail_on_changed_file_growth: false
120
+ extension_points:
121
+ - name: "Exporters"
122
+ keywords: ["export", "csv"]
123
+ prefer_existing_paths:
124
+ - "src/**/exporters/**"
125
+ allow_new_files_under:
126
+ - "src/**/exporters/**"
127
+ - "tests/**"
128
+ ```
129
+
130
+ ## Example `.scopeproof/task.yml`
131
+
132
+ ```yaml
133
+ goal: "Add CSV export support"
134
+ allowed_paths:
135
+ - "src/**/exporters/**"
136
+ - "tests/**"
137
+ forbidden_paths:
138
+ - "src/**/services/**"
139
+ prefer_modify:
140
+ - "src/demo/exporters/base.py"
141
+ expected_behavior:
142
+ - "Use the existing exporter interface."
143
+ verification:
144
+ - "pytest -q"
145
+ ```
146
+
147
+ ## Example Report
148
+
149
+ ```text
150
+ ScopeProof Report
151
+
152
+ Project: demo
153
+ Task: Add CSV export support
154
+ Diff: HEAD -> working tree
155
+
156
+ FAIL scope_escape
157
+ src/demo/services/csv_export_service.py: Changed file matches a forbidden task path.
158
+
159
+ FAIL module_sprawl
160
+ src/demo/services/csv_export_service.py: New file was added outside matched extension point paths.
161
+
162
+ Overall: FAIL
163
+ ```
164
+
165
+ ## GitHub Actions
166
+
167
+ ```yaml
168
+ name: ScopeProof
169
+
170
+ on:
171
+ pull_request:
172
+
173
+ jobs:
174
+ scopeproof:
175
+ runs-on: ubuntu-latest
176
+
177
+ steps:
178
+ - uses: actions/checkout@v4
179
+ with:
180
+ fetch-depth: 0
181
+
182
+ - uses: actions/setup-python@v5
183
+ with:
184
+ python-version: "3.11"
185
+
186
+ - run: pip install git+https://github.com/SomeTimeDev/scopeproof.git
187
+
188
+ - run: scopeproof check --base origin/main --head HEAD --format markdown --output scopeproof-report.md
189
+ ```
190
+
191
+ ScopeProof does not post PR comments yet.
192
+
193
+ ## Philosophy And Limitations
194
+
195
+ ScopeProof does not prove semantic correctness. It catches deterministic drift signals:
196
+
197
+ - changed files outside allowed paths
198
+ - too many files changed for one task
199
+ - Python syntax errors in changed files
200
+ - suspicious new modules
201
+ - duplicated-looking symbols
202
+ - orphan new files
203
+ - unexpected public API growth
204
+
205
+ It currently indexes Python with the standard library `ast` module. Non-Python files can be checked
206
+ for path scope, but not for symbol-level behavior.
207
+
208
+ ## Roadmap
209
+
210
+ - TypeScript/JavaScript indexing
211
+ - GitHub PR comments
212
+ - Layer/import violation checks
213
+ - Optional hook examples
214
+
215
+ ## License
216
+
217
+ MIT
@@ -0,0 +1,183 @@
1
+ # ScopeProof
2
+
3
+ AI coding agents start focused, then drift. ScopeProof keeps their changes inside your
4
+ project's scope.
5
+
6
+ It checks agent-generated diffs for needless modules, duplicate abstractions, scope escape,
7
+ orphan files, changed-file growth, parse errors, and public API growth.
8
+
9
+ No LLM required. No cloud. No vendor lock-in.
10
+
11
+ ## Problem
12
+
13
+ Small requested changes can quietly become new service layers, duplicate classes, unrelated file
14
+ edits, or public APIs that were never part of the task. ScopeProof is a deterministic CLI guardrail
15
+ for catching those signals before merge.
16
+
17
+ ## What ScopeProof Checks
18
+
19
+ - `scope_escape`: changed files outside task paths or inside forbidden paths
20
+ - `module_sprawl`: too many new files or suspicious new modules
21
+ - `changed_file_growth`: too many changed files for one task
22
+ - `parse_error`: changed Python files that cannot be parsed
23
+ - `duplicate_symbol`: new public symbols that resemble existing symbols
24
+ - `orphan_new_file`: new production Python files that are not imported or tested
25
+ - `public_api_growth`: excessive public class/function growth for one task
26
+
27
+ ## Installation
28
+
29
+ ScopeProof is not published to PyPI yet. Install the current GitHub version with:
30
+
31
+ ```bash
32
+ pip install git+https://github.com/SomeTimeDev/scopeproof.git
33
+ ```
34
+
35
+ For local development:
36
+
37
+ ```bash
38
+ pip install -e ".[dev]"
39
+ ```
40
+
41
+ ## Quickstart
42
+
43
+ ```bash
44
+ scopeproof init
45
+ scopeproof prompt "Add CSV export support"
46
+ scopeproof check --base HEAD
47
+ ```
48
+
49
+ To check exactly what is staged for the next commit:
50
+
51
+ ```bash
52
+ git add .
53
+ scopeproof check --staged
54
+ ```
55
+
56
+ For stricter projects, start with fail-on defaults for every drift check:
57
+
58
+ ```bash
59
+ scopeproof init --strict
60
+ ```
61
+
62
+ Local working-tree checks include untracked files by default. A new untracked Python module is
63
+ treated as an added file, so `scopeproof check --base HEAD` catches drift before you remember to
64
+ run `git add`. Use `--staged` when you want to ignore unstaged/untracked experiments and check only
65
+ the Git index.
66
+
67
+ For pull requests:
68
+
69
+ ```bash
70
+ scopeproof check --base origin/main --head HEAD
71
+ ```
72
+
73
+ ## Example `scopeproof.yml`
74
+
75
+ ```yaml
76
+ version: 1
77
+ project:
78
+ name: "demo"
79
+ mission: "CLI for exporting structured data."
80
+ rules:
81
+ max_changed_files_per_task: 8
82
+ max_new_files_per_task: 1
83
+ duplicate_symbol_similarity: 0.82
84
+ fail_on_module_sprawl: true
85
+ fail_on_changed_file_growth: false
86
+ extension_points:
87
+ - name: "Exporters"
88
+ keywords: ["export", "csv"]
89
+ prefer_existing_paths:
90
+ - "src/**/exporters/**"
91
+ allow_new_files_under:
92
+ - "src/**/exporters/**"
93
+ - "tests/**"
94
+ ```
95
+
96
+ ## Example `.scopeproof/task.yml`
97
+
98
+ ```yaml
99
+ goal: "Add CSV export support"
100
+ allowed_paths:
101
+ - "src/**/exporters/**"
102
+ - "tests/**"
103
+ forbidden_paths:
104
+ - "src/**/services/**"
105
+ prefer_modify:
106
+ - "src/demo/exporters/base.py"
107
+ expected_behavior:
108
+ - "Use the existing exporter interface."
109
+ verification:
110
+ - "pytest -q"
111
+ ```
112
+
113
+ ## Example Report
114
+
115
+ ```text
116
+ ScopeProof Report
117
+
118
+ Project: demo
119
+ Task: Add CSV export support
120
+ Diff: HEAD -> working tree
121
+
122
+ FAIL scope_escape
123
+ src/demo/services/csv_export_service.py: Changed file matches a forbidden task path.
124
+
125
+ FAIL module_sprawl
126
+ src/demo/services/csv_export_service.py: New file was added outside matched extension point paths.
127
+
128
+ Overall: FAIL
129
+ ```
130
+
131
+ ## GitHub Actions
132
+
133
+ ```yaml
134
+ name: ScopeProof
135
+
136
+ on:
137
+ pull_request:
138
+
139
+ jobs:
140
+ scopeproof:
141
+ runs-on: ubuntu-latest
142
+
143
+ steps:
144
+ - uses: actions/checkout@v4
145
+ with:
146
+ fetch-depth: 0
147
+
148
+ - uses: actions/setup-python@v5
149
+ with:
150
+ python-version: "3.11"
151
+
152
+ - run: pip install git+https://github.com/SomeTimeDev/scopeproof.git
153
+
154
+ - run: scopeproof check --base origin/main --head HEAD --format markdown --output scopeproof-report.md
155
+ ```
156
+
157
+ ScopeProof does not post PR comments yet.
158
+
159
+ ## Philosophy And Limitations
160
+
161
+ ScopeProof does not prove semantic correctness. It catches deterministic drift signals:
162
+
163
+ - changed files outside allowed paths
164
+ - too many files changed for one task
165
+ - Python syntax errors in changed files
166
+ - suspicious new modules
167
+ - duplicated-looking symbols
168
+ - orphan new files
169
+ - unexpected public API growth
170
+
171
+ It currently indexes Python with the standard library `ast` module. Non-Python files can be checked
172
+ for path scope, but not for symbol-level behavior.
173
+
174
+ ## Roadmap
175
+
176
+ - TypeScript/JavaScript indexing
177
+ - GitHub PR comments
178
+ - Layer/import violation checks
179
+ - Optional hook examples
180
+
181
+ ## License
182
+
183
+ MIT
@@ -0,0 +1,73 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "scopeproof"
7
+ version = "0.1.4"
8
+ description = "A tiny scope and architecture guardrail for AI coding agents."
9
+ readme = "README.md"
10
+ requires-python = ">=3.11"
11
+ license = "MIT"
12
+ license-files = ["LICENSE"]
13
+ authors = [{ name = "ScopeProof Contributors" }]
14
+ maintainers = [{ name = "SomeTimeDev" }]
15
+ keywords = [
16
+ "ai-agents",
17
+ "coding-agents",
18
+ "codex",
19
+ "guardrails",
20
+ "code-review",
21
+ "static-analysis",
22
+ "git",
23
+ "cli",
24
+ ]
25
+ classifiers = [
26
+ "Development Status :: 3 - Alpha",
27
+ "Environment :: Console",
28
+ "Intended Audience :: Developers",
29
+ "Operating System :: OS Independent",
30
+ "Programming Language :: Python :: 3",
31
+ "Programming Language :: Python :: 3 :: Only",
32
+ "Programming Language :: Python :: 3.11",
33
+ "Programming Language :: Python :: 3.12",
34
+ "Programming Language :: Python :: 3.13",
35
+ "Topic :: Software Development :: Quality Assurance",
36
+ "Topic :: Software Development :: Version Control :: Git",
37
+ ]
38
+ dependencies = [
39
+ "typer>=0.12",
40
+ "pyyaml>=6.0",
41
+ "rich>=13.0",
42
+ "pathspec>=0.12",
43
+ ]
44
+
45
+ [project.urls]
46
+ Homepage = "https://github.com/SomeTimeDev/scopeproof"
47
+ Repository = "https://github.com/SomeTimeDev/scopeproof"
48
+ Issues = "https://github.com/SomeTimeDev/scopeproof/issues"
49
+
50
+ [project.optional-dependencies]
51
+ dev = [
52
+ "pytest>=8.0",
53
+ "ruff>=0.5",
54
+ ]
55
+
56
+ [project.scripts]
57
+ scopeproof = "scopeproof.cli:app"
58
+
59
+ [tool.ruff]
60
+ line-length = 100
61
+ target-version = "py311"
62
+
63
+ [tool.ruff.lint]
64
+ select = ["E4", "E7", "E9", "F"]
65
+
66
+ [tool.pytest.ini_options]
67
+ testpaths = ["tests"]
68
+
69
+ [tool.setuptools.packages.find]
70
+ include = ["scopeproof*"]
71
+
72
+ [tool.setuptools.package-data]
73
+ "scopeproof.templates" = ["*.yml", "*.md"]
@@ -0,0 +1,3 @@
1
+ """ScopeProof package."""
2
+
3
+ __version__ = "0.1.4"
@@ -0,0 +1,6 @@
1
+ from scopeproof.cli import app
2
+
3
+
4
+ if __name__ == "__main__":
5
+ app()
6
+
@@ -0,0 +1,2 @@
1
+ """ScopeProof checks."""
2
+
@@ -0,0 +1,105 @@
1
+ from __future__ import annotations
2
+
3
+ from pathlib import PurePosixPath
4
+
5
+ from scopeproof.config import ProjectConfig
6
+ from scopeproof.indexer.python_ast import index_python_source
7
+ from scopeproof.models import ChangedFile, FAIL, PASS, CheckIssue, CheckResult, Symbol
8
+ from scopeproof.paths import matches_any
9
+
10
+
11
+ def result_from_issues(
12
+ *,
13
+ check_id: str,
14
+ title: str,
15
+ pass_summary: str,
16
+ issue_summary: str,
17
+ issues: list[CheckIssue],
18
+ fail_enabled: bool,
19
+ ) -> CheckResult:
20
+ if not issues:
21
+ return CheckResult(check_id, title, PASS, pass_summary, [])
22
+ severity = FAIL if fail_enabled else "WARN"
23
+ normalized = [
24
+ CheckIssue(
25
+ severity=severity,
26
+ message=issue.message,
27
+ path=issue.path,
28
+ line=issue.line,
29
+ suggestion=issue.suggestion,
30
+ evidence=issue.evidence,
31
+ )
32
+ for issue in issues
33
+ ]
34
+ return CheckResult(check_id, title, severity, issue_summary, normalized)
35
+
36
+
37
+ def is_project_excluded(path: str, config: ProjectConfig) -> bool:
38
+ return matches_any(path, config.paths.exclude)
39
+
40
+
41
+ def is_support_file(path: str) -> bool:
42
+ return (
43
+ path.startswith("tests/")
44
+ or path.startswith("docs/")
45
+ or path == "README.md"
46
+ or path.endswith(".md")
47
+ )
48
+
49
+
50
+ def is_production_python_file(path: str) -> bool:
51
+ name = PurePosixPath(path).name
52
+ return (
53
+ path.endswith(".py")
54
+ and not path.startswith("tests/")
55
+ and not path.startswith("docs/")
56
+ and name not in {"setup.py", "conftest.py", "__init__.py"}
57
+ )
58
+
59
+
60
+ def added_files(changed_files: list[ChangedFile]) -> list[ChangedFile]:
61
+ return [item for item in changed_files if item.status in {"A", "C"}]
62
+
63
+
64
+ def new_public_symbols(
65
+ *,
66
+ changed_files: list[ChangedFile],
67
+ current_symbols: list[Symbol],
68
+ base_symbols: list[Symbol],
69
+ include_tests: bool = True,
70
+ ) -> list[Symbol]:
71
+ changed_by_path = {item.path: item for item in changed_files if item.path.endswith(".py")}
72
+ base_keys = {
73
+ (symbol.path, symbol.kind, symbol.name, symbol.parent)
74
+ for symbol in base_symbols
75
+ if symbol.is_public
76
+ }
77
+ new_symbols = []
78
+ for symbol in current_symbols:
79
+ changed = changed_by_path.get(symbol.path)
80
+ if changed is None or not symbol.is_public:
81
+ continue
82
+ if not include_tests and symbol.path.startswith("tests/"):
83
+ continue
84
+ if changed.status in {"A", "C"}:
85
+ new_symbols.append(symbol)
86
+ continue
87
+ key = (symbol.path, symbol.kind, symbol.name, symbol.parent)
88
+ if key not in base_keys:
89
+ new_symbols.append(symbol)
90
+ return new_symbols
91
+
92
+
93
+ def base_symbols_for_changed_files(
94
+ changed_files: list[ChangedFile],
95
+ base_sources: dict[str, str],
96
+ ) -> list[Symbol]:
97
+ symbols: list[Symbol] = []
98
+ for changed in changed_files:
99
+ source = base_sources.get(changed.path)
100
+ if not source or not changed.path.endswith(".py"):
101
+ continue
102
+ file_symbols, _ = index_python_source(source, changed.path)
103
+ symbols.extend(file_symbols)
104
+ return symbols
105
+
@@ -0,0 +1,35 @@
1
+ from __future__ import annotations
2
+
3
+ from scopeproof.checks.base import is_project_excluded, result_from_issues
4
+ from scopeproof.config import ProjectConfig
5
+ from scopeproof.models import ChangedFile, CheckIssue
6
+
7
+
8
+ def check_changed_file_growth(
9
+ changed_files: list[ChangedFile],
10
+ config: ProjectConfig,
11
+ ) -> object:
12
+ counted_files = [
13
+ changed for changed in changed_files if not is_project_excluded(changed.path, config)
14
+ ]
15
+ limit = config.rules.max_changed_files_per_task
16
+ issues: list[CheckIssue] = []
17
+ if len(counted_files) > limit:
18
+ issues.append(
19
+ CheckIssue(
20
+ severity="WARN",
21
+ message=f"This task changed {len(counted_files)} files; configured limit is {limit}.",
22
+ suggestion="Reduce file churn, or split the task into smaller focused changes.",
23
+ evidence={"changed_files": [item.path for item in counted_files]},
24
+ )
25
+ )
26
+
27
+ return result_from_issues(
28
+ check_id="changed_file_growth",
29
+ title="Changed file growth",
30
+ pass_summary="Changed file count is within the configured limit.",
31
+ issue_summary=f"{len(issues)} changed-file growth issue(s) detected.",
32
+ issues=issues,
33
+ fail_enabled=config.rules.fail_on_changed_file_growth,
34
+ )
35
+