gitrelevance 0.1.0__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 (60) hide show
  1. gitrelevance-0.1.0/.github/workflows/ci.yml +37 -0
  2. gitrelevance-0.1.0/LICENSE +21 -0
  3. gitrelevance-0.1.0/PKG-INFO +269 -0
  4. gitrelevance-0.1.0/README.md +234 -0
  5. gitrelevance-0.1.0/pyproject.toml +58 -0
  6. gitrelevance-0.1.0/pytest +0 -0
  7. gitrelevance-0.1.0/src/gitrelevance/__init__.py +6 -0
  8. gitrelevance-0.1.0/src/gitrelevance/analysis/__init__.py +20 -0
  9. gitrelevance-0.1.0/src/gitrelevance/analysis/classifier.py +59 -0
  10. gitrelevance-0.1.0/src/gitrelevance/analysis/confidence.py +41 -0
  11. gitrelevance-0.1.0/src/gitrelevance/analysis/current_state.py +98 -0
  12. gitrelevance-0.1.0/src/gitrelevance/analysis/engine.py +181 -0
  13. gitrelevance-0.1.0/src/gitrelevance/analysis/evidence.py +187 -0
  14. gitrelevance-0.1.0/src/gitrelevance/analysis/matcher.py +200 -0
  15. gitrelevance-0.1.0/src/gitrelevance/cli/__init__.py +7 -0
  16. gitrelevance-0.1.0/src/gitrelevance/cli/commands.py +262 -0
  17. gitrelevance-0.1.0/src/gitrelevance/config.py +27 -0
  18. gitrelevance-0.1.0/src/gitrelevance/git/__init__.py +23 -0
  19. gitrelevance-0.1.0/src/gitrelevance/git/commits.py +62 -0
  20. gitrelevance-0.1.0/src/gitrelevance/git/files.py +185 -0
  21. gitrelevance-0.1.0/src/gitrelevance/git/history.py +217 -0
  22. gitrelevance-0.1.0/src/gitrelevance/git/repository.py +161 -0
  23. gitrelevance-0.1.0/src/gitrelevance/issues/__init__.py +5 -0
  24. gitrelevance-0.1.0/src/gitrelevance/issues/models.py +53 -0
  25. gitrelevance-0.1.0/src/gitrelevance/models.py +60 -0
  26. gitrelevance-0.1.0/src/gitrelevance/output/__init__.py +8 -0
  27. gitrelevance-0.1.0/src/gitrelevance/output/json.py +83 -0
  28. gitrelevance-0.1.0/src/gitrelevance/output/terminal.py +202 -0
  29. gitrelevance-0.1.0/src/gitrelevance/providers/__init__.py +11 -0
  30. gitrelevance-0.1.0/src/gitrelevance/providers/base.py +75 -0
  31. gitrelevance-0.1.0/src/gitrelevance/providers/github.py +419 -0
  32. gitrelevance-0.1.0/tests/__init__.py +0 -0
  33. gitrelevance-0.1.0/tests/analysis/__init__.py +1 -0
  34. gitrelevance-0.1.0/tests/analysis/test_classifier.py +71 -0
  35. gitrelevance-0.1.0/tests/analysis/test_confidence.py +43 -0
  36. gitrelevance-0.1.0/tests/analysis/test_current_state.py +172 -0
  37. gitrelevance-0.1.0/tests/analysis/test_evidence.py +209 -0
  38. gitrelevance-0.1.0/tests/analysis/test_explainability.py +238 -0
  39. gitrelevance-0.1.0/tests/analysis/test_matcher.py +309 -0
  40. gitrelevance-0.1.0/tests/cli/test_commands.py +164 -0
  41. gitrelevance-0.1.0/tests/fixtures/__init__.py +0 -0
  42. gitrelevance-0.1.0/tests/fixtures/repo_builder.py +191 -0
  43. gitrelevance-0.1.0/tests/git/__init__.py +0 -0
  44. gitrelevance-0.1.0/tests/git/test_files.py +135 -0
  45. gitrelevance-0.1.0/tests/git/test_history.py +262 -0
  46. gitrelevance-0.1.0/tests/git/test_repository.py +220 -0
  47. gitrelevance-0.1.0/tests/output/test_json.py +78 -0
  48. gitrelevance-0.1.0/tests/output/test_terminal.py +100 -0
  49. gitrelevance-0.1.0/tests/providers/test_github.py +285 -0
  50. gitrelevance-0.1.0/tests/scenarios/__init__.py +1 -0
  51. gitrelevance-0.1.0/tests/scenarios/conftest.py +108 -0
  52. gitrelevance-0.1.0/tests/scenarios/test_scenario_cross_contamination.py +156 -0
  53. gitrelevance-0.1.0/tests/scenarios/test_scenario_multiple_prs.py +121 -0
  54. gitrelevance-0.1.0/tests/scenarios/test_scenario_obsolete.py +96 -0
  55. gitrelevance-0.1.0/tests/scenarios/test_scenario_renamed_not_deleted.py +92 -0
  56. gitrelevance-0.1.0/tests/scenarios/test_scenario_resolved.py +100 -0
  57. gitrelevance-0.1.0/tests/scenarios/test_scenario_reverted.py +119 -0
  58. gitrelevance-0.1.0/tests/scenarios/test_scenario_still_relevant.py +110 -0
  59. gitrelevance-0.1.0/tests/scenarios/test_scenario_unknown.py +77 -0
  60. gitrelevance-0.1.0/tests/scenarios/test_scenarios.py +202 -0
@@ -0,0 +1,37 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [ "main" ]
6
+ pull_request:
7
+ branches: [ "main" ]
8
+
9
+ jobs:
10
+ test:
11
+ name: Test on Python ${{ matrix.python-version }} (${{ matrix.os }})
12
+ runs-on: ${{ matrix.os }}
13
+ strategy:
14
+ fail-fast: false
15
+ matrix:
16
+ os: [ubuntu-latest, windows-latest]
17
+ python-version: ["3.10", "3.11", "3.12"]
18
+
19
+ steps:
20
+ - uses: actions/checkout@v4
21
+ with:
22
+ fetch-depth: 0
23
+
24
+ - name: Set up Python ${{ matrix.python-version }}
25
+ uses: actions/setup-python@v5
26
+ with:
27
+ python-version: ${{ matrix.python-version }}
28
+ cache: "pip"
29
+
30
+ - name: Install dependencies
31
+ run: |
32
+ python -m pip install --upgrade pip
33
+ python -m pip install -e ".[dev]"
34
+
35
+ - name: Run test suite
36
+ run: |
37
+ python -m pytest tests/ -v
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 GitRelevance 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.
@@ -0,0 +1,269 @@
1
+ Metadata-Version: 2.5
2
+ Name: gitrelevance
3
+ Version: 0.1.0
4
+ Summary: Analyze whether historical GitHub issues are still relevant to a codebase, using Git history as evidence
5
+ Project-URL: Homepage, https://github.com/gitrelevance/gitrelevance
6
+ Project-URL: Repository, https://github.com/gitrelevance/gitrelevance
7
+ Project-URL: Issues, https://github.com/gitrelevance/gitrelevance/issues
8
+ Author: GitRelevance Contributors
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Environment :: Console
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Topic :: Software Development :: Version Control :: Git
21
+ Requires-Python: >=3.10
22
+ Requires-Dist: diskcache>=5.6.0
23
+ Requires-Dist: gitpython>=3.1.0
24
+ Requires-Dist: pygithub>=2.0.0
25
+ Requires-Dist: python-dotenv>=1.0.0
26
+ Requires-Dist: rich>=13.0.0
27
+ Requires-Dist: typer>=0.9.0
28
+ Requires-Dist: typing-extensions; python_version < '3.11'
29
+ Provides-Extra: dev
30
+ Requires-Dist: build>=1.0.0; extra == 'dev'
31
+ Requires-Dist: pytest>=7.0; extra == 'dev'
32
+ Requires-Dist: responses>=0.23.0; extra == 'dev'
33
+ Requires-Dist: twine>=5.0.0; extra == 'dev'
34
+ Description-Content-Type: text/markdown
35
+
36
+ # GitRelevance
37
+
38
+ > Analyze whether historical GitHub issues are still relevant to a codebase, using Git history as evidence.
39
+
40
+ [![CI](https://github.com/gitrelevance/gitrelevance/actions/workflows/ci.yml/badge.svg)](https://github.com/gitrelevance/gitrelevance/actions/workflows/ci.yml)
41
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
42
+ [![Python: >=3.10](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
43
+
44
+ ---
45
+
46
+ ## What is GitRelevance?
47
+
48
+ In long-lived repositories, issue trackers often accumulate hundreds of historical bug reports and feature requests. Over time, code is refactored, features are deprecated, or fixes are merged without closing the original issue.
49
+
50
+ **GitRelevance** audits your open and closed GitHub issues against your local Git history. It automatically correlates commit messages, pull request merges, file renames, deletions, and reverts to determine whether an issue is:
51
+ - **`RESOLVED`** — A fix commit exists in `HEAD` history and was not reverted.
52
+ - **`PROBABLY_RESOLVED`** — A fixing PR was merged or substantial fix evidence was detected.
53
+ - **`STILL_RELEVANT`** — The issue is open and related code still actively exists in the tree.
54
+ - **`OBSOLETE`** — The files or feature referenced by the issue were deleted without replacement.
55
+ - **`UNKNOWN`** — No correlating commits or evidence exist in local Git history.
56
+
57
+ Every classification is backed by an explicit, human-readable list of evidence items and a confidence score.
58
+
59
+ ---
60
+
61
+ ## Installation
62
+
63
+ ```bash
64
+ pip install gitrelevance
65
+ ```
66
+
67
+ For development:
68
+ ```bash
69
+ git clone https://github.com/gitrelevance/gitrelevance.git
70
+ cd gitrelevance
71
+ pip install -e ".[dev]"
72
+ ```
73
+
74
+ Requires Python ≥ 3.10.
75
+
76
+ ---
77
+
78
+ ## Quick Start (CLI)
79
+
80
+ Run `gitrelevance analyze` from inside any local Git clone of a GitHub repository:
81
+
82
+ ```bash
83
+ # Analyze all repository issues
84
+ gitrelevance analyze
85
+
86
+ # Filter by state (open, closed, all)
87
+ gitrelevance analyze --state open
88
+
89
+ # Filter by issue creation date
90
+ gitrelevance analyze --since 2024-01-01
91
+
92
+ # Output structured JSON for automation or CI pipelines
93
+ gitrelevance analyze --json
94
+ ```
95
+
96
+ ### Example Terminal Output
97
+
98
+ ```
99
+ GitRelevance
100
+
101
+ Repository: github.com/owner/my-repo
102
+ Branch: main
103
+ HEAD: a81f23c
104
+
105
+ Analyzing 24 issues...
106
+
107
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
108
+
109
+ RESOLVED
110
+
111
+ #21 Login crashes after token expiration
112
+ Confidence: 96%
113
+
114
+ Evidence:
115
+ ✓ Fix commit is present in HEAD history (a81f23c)
116
+ ✓ Issue referenced in commit message (a81f23c)
117
+ ✓ All related files exist at HEAD
118
+ ✓ No revert of fix commit detected (a81f23c)
119
+
120
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
121
+
122
+ * Confidence is a heuristic evidence-strength score (0–100%), not a statistical probability.
123
+ ```
124
+
125
+ ---
126
+
127
+ ## How Classification Works
128
+
129
+ GitRelevance evaluates evidence through a multi-stage deterministic pipeline:
130
+
131
+ ```
132
+ ┌─────────────────┐ ┌─────────────────────┐
133
+ │ Local Git Repo │ │ GitHub API Provider │
134
+ └────────┬────────┘ └──────────┬──────────┘
135
+ │ │
136
+ ▼ ▼
137
+ ┌───────────────────────────────────────┐
138
+ │ Matcher (Correlates commits & PRs) │
139
+ └──────────────────┬────────────────────┘
140
+
141
+
142
+ ┌───────────────────────────────────────┐
143
+ │ Current-State Analysis (HEAD status) │
144
+ └──────────────────┬────────────────────┘
145
+
146
+
147
+ ┌───────────────────────────────────────┐
148
+ │ Evidence Collection (Signed weights) │
149
+ └──────────────────┬────────────────────┘
150
+
151
+
152
+ ┌───────────────────────────────────────┐
153
+ │ Confidence & Classifier Decision Tree │
154
+ └──────────────────┬────────────────────┘
155
+
156
+
157
+ ┌───────────────────────────────────────┐
158
+ │ Output (Terminal with Rich or JSON) │
159
+ └───────────────────────────────────────┘
160
+ ```
161
+
162
+ ### Evidence Rules & Signed Weights
163
+ - **Fix commit in HEAD history** (`+3`): A commit referencing `#N` or `GH-N` is an ancestor of `HEAD`.
164
+ - **Linked PR merged** (`+2`): A pull request linked to or closing issue `#N` was merged into the repository.
165
+ - **Related files exist at HEAD** (`+2`): All files modified by the issue's commits/PRs still exist.
166
+ - **No revert detected** (`+1`): The fix commit was not undone by a subsequent `git revert`.
167
+ - **Related files deleted without replacement** (`-3`): Referenced files were deleted in git history and not renamed.
168
+ - **Fix commit later reverted** (`-3`): Git's native revert trailer (`This reverts commit <sha>.`) indicates the fix was undone.
169
+
170
+ ### Confidence Score (Evidence Strength)
171
+
172
+ Confidence is computed as an **evidence-strength heuristic** normalized and clamped to `[0.05, 0.98]`.
173
+
174
+ ```text
175
+ Confidence = 0.50 + (sum(Weights) / (2 × MAX_ABS_WEIGHT))
176
+ ```
177
+ > **Important Note:** Confidence is **NOT** a calibrated Bayesian probability. A confidence of 95% indicates an overwhelming accumulation of strong supporting evidence in the Git tree, not that the classification is statistically 95% likely to be correct.
178
+
179
+ ---
180
+
181
+ ## GitHub Authentication & Rate Limits
182
+
183
+ GitRelevance works unauthenticated for public repositories out of the box.
184
+
185
+ To analyze private repositories or avoid GitHub's unauthenticated API rate limits (60 requests/hour), supply a personal access token via the `GITHUB_TOKEN` environment variable or a local `.env` file:
186
+
187
+ ```bash
188
+ export GITHUB_TOKEN="ghp_yourPersonalAccessTokenHere"
189
+ gitrelevance analyze
190
+ ```
191
+
192
+ ---
193
+
194
+ ## Python API Usage
195
+
196
+ GitRelevance can also be integrated directly into Python scripts:
197
+
198
+ ```python
199
+ from gitrelevance.git.repository import GitRepository
200
+ from gitrelevance.providers.github import GitHubProvider
201
+ from gitrelevance.analysis.engine import AnalysisEngine
202
+ from gitrelevance.output.terminal import TerminalRenderer
203
+ from gitrelevance.output.json import to_json
204
+
205
+ # 1. Initialize Git repository and GitHub provider
206
+ repo = GitRepository(".")
207
+ owner, repo_name = GitHubProvider.parse_remote(repo.remote_url("origin"))
208
+ provider = GitHubProvider(owner=owner, repo=repo_name)
209
+
210
+ # 2. Run analysis
211
+ engine = AnalysisEngine(repo, provider)
212
+ results = engine.analyze(state="open")
213
+
214
+ # 3. Render results
215
+ for result in results:
216
+ print(f"#{result.issue.number} {result.issue.title} -> {result.classification.value} ({result.confidence:.0%})")
217
+ ```
218
+
219
+ ---
220
+
221
+ ## Running Tests
222
+
223
+ ```bash
224
+ # Run complete test suite
225
+ pytest -v
226
+
227
+ # Run individual test layers
228
+ pytest tests/git/ # Git abstraction layer
229
+ pytest tests/providers/ # Provider layer
230
+ pytest tests/analysis/ # Evidence & classification unit tests
231
+ pytest tests/output/ # Terminal & JSON rendering tests
232
+ pytest tests/cli/ # Typer CLI tests
233
+ pytest tests/scenarios/ # End-to-end repository scenarios
234
+ ```
235
+
236
+ ---
237
+
238
+ ## Adding a Scenario Test
239
+
240
+ To add a new end-to-end scenario test:
241
+ 1. Create `tests/scenarios/test_scenario_<name>.py`.
242
+ 2. Import `FakeProvider`, `make_issue`, `make_pr`, and assertion helpers from `tests.scenarios.conftest`.
243
+ 3. Use `RepoBuilder` to construct a real temporary Git repository.
244
+ 4. Execute `AnalysisEngine(repo, provider).analyze()` and assert on the `AnalysisResult` fields.
245
+
246
+ ```python
247
+ from gitrelevance.analysis.engine import AnalysisEngine
248
+ from gitrelevance.git.repository import GitRepository
249
+ from gitrelevance.models import Classification
250
+ from tests.fixtures.repo_builder import RepoBuilder
251
+ from tests.scenarios.conftest import FakeProvider, make_issue
252
+
253
+ def test_my_custom_scenario():
254
+ builder = RepoBuilder().commit("Initial", files={"app.py": "code"})
255
+ path = builder.build()
256
+ try:
257
+ repo = GitRepository(path)
258
+ issue = make_issue(number=99, title="Custom issue", state="closed")
259
+ results = AnalysisEngine(repo, FakeProvider(issues=[issue])).analyze()
260
+ assert results[0].classification == Classification.UNKNOWN
261
+ finally:
262
+ builder.cleanup()
263
+ ```
264
+
265
+ ---
266
+
267
+ ## License
268
+
269
+ This project is licensed under the [MIT License](LICENSE).
@@ -0,0 +1,234 @@
1
+ # GitRelevance
2
+
3
+ > Analyze whether historical GitHub issues are still relevant to a codebase, using Git history as evidence.
4
+
5
+ [![CI](https://github.com/gitrelevance/gitrelevance/actions/workflows/ci.yml/badge.svg)](https://github.com/gitrelevance/gitrelevance/actions/workflows/ci.yml)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
+ [![Python: >=3.10](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
8
+
9
+ ---
10
+
11
+ ## What is GitRelevance?
12
+
13
+ In long-lived repositories, issue trackers often accumulate hundreds of historical bug reports and feature requests. Over time, code is refactored, features are deprecated, or fixes are merged without closing the original issue.
14
+
15
+ **GitRelevance** audits your open and closed GitHub issues against your local Git history. It automatically correlates commit messages, pull request merges, file renames, deletions, and reverts to determine whether an issue is:
16
+ - **`RESOLVED`** — A fix commit exists in `HEAD` history and was not reverted.
17
+ - **`PROBABLY_RESOLVED`** — A fixing PR was merged or substantial fix evidence was detected.
18
+ - **`STILL_RELEVANT`** — The issue is open and related code still actively exists in the tree.
19
+ - **`OBSOLETE`** — The files or feature referenced by the issue were deleted without replacement.
20
+ - **`UNKNOWN`** — No correlating commits or evidence exist in local Git history.
21
+
22
+ Every classification is backed by an explicit, human-readable list of evidence items and a confidence score.
23
+
24
+ ---
25
+
26
+ ## Installation
27
+
28
+ ```bash
29
+ pip install gitrelevance
30
+ ```
31
+
32
+ For development:
33
+ ```bash
34
+ git clone https://github.com/gitrelevance/gitrelevance.git
35
+ cd gitrelevance
36
+ pip install -e ".[dev]"
37
+ ```
38
+
39
+ Requires Python ≥ 3.10.
40
+
41
+ ---
42
+
43
+ ## Quick Start (CLI)
44
+
45
+ Run `gitrelevance analyze` from inside any local Git clone of a GitHub repository:
46
+
47
+ ```bash
48
+ # Analyze all repository issues
49
+ gitrelevance analyze
50
+
51
+ # Filter by state (open, closed, all)
52
+ gitrelevance analyze --state open
53
+
54
+ # Filter by issue creation date
55
+ gitrelevance analyze --since 2024-01-01
56
+
57
+ # Output structured JSON for automation or CI pipelines
58
+ gitrelevance analyze --json
59
+ ```
60
+
61
+ ### Example Terminal Output
62
+
63
+ ```
64
+ GitRelevance
65
+
66
+ Repository: github.com/owner/my-repo
67
+ Branch: main
68
+ HEAD: a81f23c
69
+
70
+ Analyzing 24 issues...
71
+
72
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
73
+
74
+ RESOLVED
75
+
76
+ #21 Login crashes after token expiration
77
+ Confidence: 96%
78
+
79
+ Evidence:
80
+ ✓ Fix commit is present in HEAD history (a81f23c)
81
+ ✓ Issue referenced in commit message (a81f23c)
82
+ ✓ All related files exist at HEAD
83
+ ✓ No revert of fix commit detected (a81f23c)
84
+
85
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
86
+
87
+ * Confidence is a heuristic evidence-strength score (0–100%), not a statistical probability.
88
+ ```
89
+
90
+ ---
91
+
92
+ ## How Classification Works
93
+
94
+ GitRelevance evaluates evidence through a multi-stage deterministic pipeline:
95
+
96
+ ```
97
+ ┌─────────────────┐ ┌─────────────────────┐
98
+ │ Local Git Repo │ │ GitHub API Provider │
99
+ └────────┬────────┘ └──────────┬──────────┘
100
+ │ │
101
+ ▼ ▼
102
+ ┌───────────────────────────────────────┐
103
+ │ Matcher (Correlates commits & PRs) │
104
+ └──────────────────┬────────────────────┘
105
+
106
+
107
+ ┌───────────────────────────────────────┐
108
+ │ Current-State Analysis (HEAD status) │
109
+ └──────────────────┬────────────────────┘
110
+
111
+
112
+ ┌───────────────────────────────────────┐
113
+ │ Evidence Collection (Signed weights) │
114
+ └──────────────────┬────────────────────┘
115
+
116
+
117
+ ┌───────────────────────────────────────┐
118
+ │ Confidence & Classifier Decision Tree │
119
+ └──────────────────┬────────────────────┘
120
+
121
+
122
+ ┌───────────────────────────────────────┐
123
+ │ Output (Terminal with Rich or JSON) │
124
+ └───────────────────────────────────────┘
125
+ ```
126
+
127
+ ### Evidence Rules & Signed Weights
128
+ - **Fix commit in HEAD history** (`+3`): A commit referencing `#N` or `GH-N` is an ancestor of `HEAD`.
129
+ - **Linked PR merged** (`+2`): A pull request linked to or closing issue `#N` was merged into the repository.
130
+ - **Related files exist at HEAD** (`+2`): All files modified by the issue's commits/PRs still exist.
131
+ - **No revert detected** (`+1`): The fix commit was not undone by a subsequent `git revert`.
132
+ - **Related files deleted without replacement** (`-3`): Referenced files were deleted in git history and not renamed.
133
+ - **Fix commit later reverted** (`-3`): Git's native revert trailer (`This reverts commit <sha>.`) indicates the fix was undone.
134
+
135
+ ### Confidence Score (Evidence Strength)
136
+
137
+ Confidence is computed as an **evidence-strength heuristic** normalized and clamped to `[0.05, 0.98]`.
138
+
139
+ ```text
140
+ Confidence = 0.50 + (sum(Weights) / (2 × MAX_ABS_WEIGHT))
141
+ ```
142
+ > **Important Note:** Confidence is **NOT** a calibrated Bayesian probability. A confidence of 95% indicates an overwhelming accumulation of strong supporting evidence in the Git tree, not that the classification is statistically 95% likely to be correct.
143
+
144
+ ---
145
+
146
+ ## GitHub Authentication & Rate Limits
147
+
148
+ GitRelevance works unauthenticated for public repositories out of the box.
149
+
150
+ To analyze private repositories or avoid GitHub's unauthenticated API rate limits (60 requests/hour), supply a personal access token via the `GITHUB_TOKEN` environment variable or a local `.env` file:
151
+
152
+ ```bash
153
+ export GITHUB_TOKEN="ghp_yourPersonalAccessTokenHere"
154
+ gitrelevance analyze
155
+ ```
156
+
157
+ ---
158
+
159
+ ## Python API Usage
160
+
161
+ GitRelevance can also be integrated directly into Python scripts:
162
+
163
+ ```python
164
+ from gitrelevance.git.repository import GitRepository
165
+ from gitrelevance.providers.github import GitHubProvider
166
+ from gitrelevance.analysis.engine import AnalysisEngine
167
+ from gitrelevance.output.terminal import TerminalRenderer
168
+ from gitrelevance.output.json import to_json
169
+
170
+ # 1. Initialize Git repository and GitHub provider
171
+ repo = GitRepository(".")
172
+ owner, repo_name = GitHubProvider.parse_remote(repo.remote_url("origin"))
173
+ provider = GitHubProvider(owner=owner, repo=repo_name)
174
+
175
+ # 2. Run analysis
176
+ engine = AnalysisEngine(repo, provider)
177
+ results = engine.analyze(state="open")
178
+
179
+ # 3. Render results
180
+ for result in results:
181
+ print(f"#{result.issue.number} {result.issue.title} -> {result.classification.value} ({result.confidence:.0%})")
182
+ ```
183
+
184
+ ---
185
+
186
+ ## Running Tests
187
+
188
+ ```bash
189
+ # Run complete test suite
190
+ pytest -v
191
+
192
+ # Run individual test layers
193
+ pytest tests/git/ # Git abstraction layer
194
+ pytest tests/providers/ # Provider layer
195
+ pytest tests/analysis/ # Evidence & classification unit tests
196
+ pytest tests/output/ # Terminal & JSON rendering tests
197
+ pytest tests/cli/ # Typer CLI tests
198
+ pytest tests/scenarios/ # End-to-end repository scenarios
199
+ ```
200
+
201
+ ---
202
+
203
+ ## Adding a Scenario Test
204
+
205
+ To add a new end-to-end scenario test:
206
+ 1. Create `tests/scenarios/test_scenario_<name>.py`.
207
+ 2. Import `FakeProvider`, `make_issue`, `make_pr`, and assertion helpers from `tests.scenarios.conftest`.
208
+ 3. Use `RepoBuilder` to construct a real temporary Git repository.
209
+ 4. Execute `AnalysisEngine(repo, provider).analyze()` and assert on the `AnalysisResult` fields.
210
+
211
+ ```python
212
+ from gitrelevance.analysis.engine import AnalysisEngine
213
+ from gitrelevance.git.repository import GitRepository
214
+ from gitrelevance.models import Classification
215
+ from tests.fixtures.repo_builder import RepoBuilder
216
+ from tests.scenarios.conftest import FakeProvider, make_issue
217
+
218
+ def test_my_custom_scenario():
219
+ builder = RepoBuilder().commit("Initial", files={"app.py": "code"})
220
+ path = builder.build()
221
+ try:
222
+ repo = GitRepository(path)
223
+ issue = make_issue(number=99, title="Custom issue", state="closed")
224
+ results = AnalysisEngine(repo, FakeProvider(issues=[issue])).analyze()
225
+ assert results[0].classification == Classification.UNKNOWN
226
+ finally:
227
+ builder.cleanup()
228
+ ```
229
+
230
+ ---
231
+
232
+ ## License
233
+
234
+ This project is licensed under the [MIT License](LICENSE).
@@ -0,0 +1,58 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "gitrelevance"
7
+ version = "0.1.0"
8
+ description = "Analyze whether historical GitHub issues are still relevant to a codebase, using Git history as evidence"
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ requires-python = ">=3.10"
12
+ authors = [
13
+ { name = "GitRelevance Contributors" },
14
+ ]
15
+ classifiers = [
16
+ "Development Status :: 4 - Beta",
17
+ "Environment :: Console",
18
+ "Intended Audience :: Developers",
19
+ "License :: OSI Approved :: MIT License",
20
+ "Operating System :: OS Independent",
21
+ "Programming Language :: Python :: 3",
22
+ "Programming Language :: Python :: 3.10",
23
+ "Programming Language :: Python :: 3.11",
24
+ "Programming Language :: Python :: 3.12",
25
+ "Topic :: Software Development :: Version Control :: Git",
26
+ ]
27
+ dependencies = [
28
+ "gitpython>=3.1.0",
29
+ "PyGithub>=2.0.0",
30
+ "diskcache>=5.6.0",
31
+ "python-dotenv>=1.0.0",
32
+ "typer>=0.9.0",
33
+ "rich>=13.0.0",
34
+ "typing_extensions; python_version < '3.11'",
35
+ ]
36
+
37
+ [project.optional-dependencies]
38
+ dev = [
39
+ "pytest>=7.0",
40
+ "responses>=0.23.0",
41
+ "build>=1.0.0",
42
+ "twine>=5.0.0",
43
+ ]
44
+
45
+ [project.scripts]
46
+ gitrelevance = "gitrelevance.cli.commands:app"
47
+
48
+ [project.urls]
49
+ Homepage = "https://github.com/gitrelevance/gitrelevance"
50
+ Repository = "https://github.com/gitrelevance/gitrelevance"
51
+ Issues = "https://github.com/gitrelevance/gitrelevance/issues"
52
+
53
+ [tool.hatch.build.targets.wheel]
54
+ packages = ["src/gitrelevance"]
55
+
56
+ [tool.pytest.ini_options]
57
+ testpaths = ["tests"]
58
+ pythonpath = ["src"]
File without changes
@@ -0,0 +1,6 @@
1
+ from gitrelevance.models import AnalysisResult, Classification, EvidenceItem
2
+
3
+ __version__ = "0.1.0"
4
+
5
+ __all__ = ["Classification", "EvidenceItem", "AnalysisResult"]
6
+
@@ -0,0 +1,20 @@
1
+ from gitrelevance.analysis.classifier import classify
2
+ from gitrelevance.analysis.confidence import compute_confidence
3
+ from gitrelevance.analysis.current_state import CurrentStateFacts, analyze_current_state
4
+ from gitrelevance.analysis.engine import AnalysisEngine
5
+ from gitrelevance.analysis.evidence import collect_evidence
6
+ from gitrelevance.analysis.matcher import MatchSet, build_all_match_sets, build_match_set
7
+
8
+ __all__ = [
9
+ "MatchSet",
10
+ "build_match_set",
11
+ "build_all_match_sets",
12
+ "CurrentStateFacts",
13
+ "analyze_current_state",
14
+ "collect_evidence",
15
+ "compute_confidence",
16
+ "classify",
17
+ "AnalysisEngine",
18
+ ]
19
+
20
+