devtime-ei 0.5.1__tar.gz → 0.7.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 (81) hide show
  1. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/PKG-INFO +15 -4
  2. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/README.md +13 -2
  3. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/pyproject.toml +2 -2
  4. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/src/devtime/__init__.py +1 -1
  5. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/src/devtime/cli.py +77 -0
  6. devtime_ei-0.7.0/src/devtime/intelligence/review.py +179 -0
  7. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/src/devtime/intelligence/verification.py +341 -45
  8. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/src/devtime/mcp/transport.py +14 -1
  9. devtime_ei-0.7.0/src/devtime/output/review.py +154 -0
  10. devtime_ei-0.7.0/src/devtime/review_flow.py +171 -0
  11. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/src/devtime/scanner/extractors/base.py +64 -0
  12. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/src/devtime/scanner/extractors/python.py +9 -1
  13. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/src/devtime/scanner/extractors/tests.py +20 -1
  14. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/src/devtime/scanner/extractors/typescript.py +7 -1
  15. devtime_ei-0.7.0/src/devtime/snapshots.py +226 -0
  16. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/src/devtime_ei.egg-info/PKG-INFO +15 -4
  17. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/src/devtime_ei.egg-info/SOURCES.txt +4 -0
  18. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/LICENSE +0 -0
  19. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/setup.cfg +0 -0
  20. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/src/devtime/ai/__init__.py +0 -0
  21. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/src/devtime/ai/local.py +0 -0
  22. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/src/devtime/ai/prompts.py +0 -0
  23. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/src/devtime/ai/providers.py +0 -0
  24. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/src/devtime/assets/devtimeignore.starter +0 -0
  25. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/src/devtime/config.py +0 -0
  26. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/src/devtime/db/__init__.py +0 -0
  27. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/src/devtime/db/connection.py +0 -0
  28. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/src/devtime/db/migrations.py +0 -0
  29. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/src/devtime/db/repository.py +0 -0
  30. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/src/devtime/db/schema.sql +0 -0
  31. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/src/devtime/demo.py +0 -0
  32. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/src/devtime/fixtures/__init__.py +0 -0
  33. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/src/devtime/fixtures/assertions.py +0 -0
  34. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/src/devtime/fixtures/loader.py +0 -0
  35. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/src/devtime/fixtures/runner.py +0 -0
  36. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/src/devtime/intelligence/__init__.py +0 -0
  37. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/src/devtime/intelligence/claims.py +0 -0
  38. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/src/devtime/intelligence/concepts.py +0 -0
  39. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/src/devtime/intelligence/context_pack.py +0 -0
  40. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/src/devtime/intelligence/evidence.py +0 -0
  41. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/src/devtime/intelligence/lineage.py +0 -0
  42. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/src/devtime/intelligence/risk.py +0 -0
  43. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/src/devtime/intelligence/scoring.py +0 -0
  44. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/src/devtime/mcp/__init__.py +0 -0
  45. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/src/devtime/mcp/schemas.py +0 -0
  46. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/src/devtime/mcp/server.py +0 -0
  47. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/src/devtime/mcp/tools.py +0 -0
  48. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/src/devtime/output/__init__.py +0 -0
  49. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/src/devtime/output/json_export.py +0 -0
  50. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/src/devtime/output/markdown.py +0 -0
  51. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/src/devtime/output/terminal.py +0 -0
  52. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/src/devtime/paths.py +0 -0
  53. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/src/devtime/privacy.py +0 -0
  54. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/src/devtime/resources/demo-saas/.devtimeignore +0 -0
  55. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/src/devtime/resources/demo-saas/README.md +0 -0
  56. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/src/devtime/resources/demo-saas/docs/decisions/0001-use-jwt.md +0 -0
  57. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/src/devtime/resources/demo-saas/package.json +0 -0
  58. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/src/devtime/resources/demo-saas/src/admin/permissions.ts +0 -0
  59. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/src/devtime/resources/demo-saas/src/auth/login.ts +0 -0
  60. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/src/devtime/resources/demo-saas/src/auth/middleware.ts +0 -0
  61. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/src/devtime/resources/demo-saas/src/auth/tokens.ts +0 -0
  62. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/src/devtime/resources/demo-saas/src/billing/stripe-webhook.ts +0 -0
  63. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/src/devtime/resources/demo-saas/src/billing/subscription-service.ts +0 -0
  64. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/src/devtime/resources/demo-saas/src/export/export-csv.ts +0 -0
  65. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/src/devtime/resources/demo-saas/src/jobs/email-worker.ts +0 -0
  66. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/src/devtime/resources/demo-saas/src/jobs/queues.ts +0 -0
  67. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/src/devtime/resources/demo-saas/tests/auth-login.test.ts +0 -0
  68. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/src/devtime/resources/demo-saas/tests/stripe-signature.test.ts +0 -0
  69. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/src/devtime/scanner/__init__.py +0 -0
  70. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/src/devtime/scanner/extractors/__init__.py +0 -0
  71. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/src/devtime/scanner/extractors/config_files.py +0 -0
  72. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/src/devtime/scanner/extractors/docs.py +0 -0
  73. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/src/devtime/scanner/extractors/nextjs.py +0 -0
  74. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/src/devtime/scanner/file_walker.py +0 -0
  75. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/src/devtime/scanner/ignore.py +0 -0
  76. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/src/devtime/scanner/language.py +0 -0
  77. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/src/devtime/scanner/signals.py +0 -0
  78. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/src/devtime_ei.egg-info/dependency_links.txt +0 -0
  79. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/src/devtime_ei.egg-info/entry_points.txt +0 -0
  80. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/src/devtime_ei.egg-info/requires.txt +0 -0
  81. {devtime_ei-0.5.1 → devtime_ei-0.7.0}/src/devtime_ei.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: devtime-ei
3
- Version: 0.5.1
3
+ Version: 0.7.0
4
4
  Summary: Local-first Engineering Intelligence for software repositories
5
5
  Author-email: Aviad Shakargi <aviad94@gmail.com>
6
6
  Maintainer-email: Aviad Shakargi <aviad94@gmail.com>
@@ -8,7 +8,7 @@ License: Apache-2.0
8
8
  Project-URL: Homepage, https://github.com/Shakargy/devtime
9
9
  Project-URL: Repository, https://github.com/Shakargy/devtime
10
10
  Project-URL: Issues, https://github.com/Shakargy/devtime/issues
11
- Project-URL: Release Notes, https://github.com/Shakargy/devtime/releases/tag/v0.5.1
11
+ Project-URL: Release Notes, https://github.com/Shakargy/devtime/releases/tag/v0.7.0
12
12
  Project-URL: Demo, https://youtu.be/1Hiu3Y9J_SI
13
13
  Keywords: devtools,cli,static-analysis,repository-analysis,engineering-intelligence,local-first
14
14
  Classifier: Development Status :: 3 - Alpha
@@ -152,8 +152,18 @@ actually verify in your repository, and when nothing applies it says what would
152
152
  make a claim verifiable instead of dead-ending.
153
153
 
154
154
  Truth and freshness are separate: when a file behind a verified claim changes,
155
- the claim goes STALE and names the file. `dtc risk --diff` reports which verified
156
- claims a diff destabilizes.
155
+ the claim goes STALE and names the file.
156
+
157
+ To review a change, compare claims at two commits:
158
+
159
+ ```bash
160
+ dtc review --base origin/main
161
+ ```
162
+
163
+ It reports what the change did to each claim (a regression, a claim that newly
164
+ applies, evidence that changed under a claim that held) from isolated snapshots
165
+ of both commits, without touching your working tree. It runs in GitHub Actions
166
+ as an advisory job summary.
157
167
 
158
168
  See **[VERIFICATION.md](VERIFICATION.md)** for the full model and its limits.
159
169
 
@@ -256,6 +266,7 @@ Anything outside these six is out of scope for now. See [LIMITATIONS.md](LIMITAT
256
266
  | `dtc risk --diff` | Review a git diff for risky changes using local evidence (advisory). |
257
267
  | `dtc decision add` | Add a local decision record that can reduce uncertainty. |
258
268
  | `dtc verify [claim]` | Verify repository claims against evidence: status, contradictions, freshness (experimental). |
269
+ | `dtc review --base <ref>` | Compare claims at two commits and report what the change did to them (advisory). |
259
270
 
260
271
  (Also available: `dtc evidence`, `dtc debt`, `dtc status`, `dtc doctor --privacy`,
261
272
  `dtc export`, `dtc reset`, `dtc mcp start`.)
@@ -113,8 +113,18 @@ actually verify in your repository, and when nothing applies it says what would
113
113
  make a claim verifiable instead of dead-ending.
114
114
 
115
115
  Truth and freshness are separate: when a file behind a verified claim changes,
116
- the claim goes STALE and names the file. `dtc risk --diff` reports which verified
117
- claims a diff destabilizes.
116
+ the claim goes STALE and names the file.
117
+
118
+ To review a change, compare claims at two commits:
119
+
120
+ ```bash
121
+ dtc review --base origin/main
122
+ ```
123
+
124
+ It reports what the change did to each claim (a regression, a claim that newly
125
+ applies, evidence that changed under a claim that held) from isolated snapshots
126
+ of both commits, without touching your working tree. It runs in GitHub Actions
127
+ as an advisory job summary.
118
128
 
119
129
  See **[VERIFICATION.md](VERIFICATION.md)** for the full model and its limits.
120
130
 
@@ -217,6 +227,7 @@ Anything outside these six is out of scope for now. See [LIMITATIONS.md](LIMITAT
217
227
  | `dtc risk --diff` | Review a git diff for risky changes using local evidence (advisory). |
218
228
  | `dtc decision add` | Add a local decision record that can reduce uncertainty. |
219
229
  | `dtc verify [claim]` | Verify repository claims against evidence: status, contradictions, freshness (experimental). |
230
+ | `dtc review --base <ref>` | Compare claims at two commits and report what the change did to them (advisory). |
220
231
 
221
232
  (Also available: `dtc evidence`, `dtc debt`, `dtc status`, `dtc doctor --privacy`,
222
233
  `dtc export`, `dtc reset`, `dtc mcp start`.)
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "devtime-ei"
3
- version = "0.5.1"
3
+ version = "0.7.0"
4
4
  description = "Local-first Engineering Intelligence for software repositories"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.11"
@@ -50,7 +50,7 @@ dev = [
50
50
  Homepage = "https://github.com/Shakargy/devtime"
51
51
  Repository = "https://github.com/Shakargy/devtime"
52
52
  Issues = "https://github.com/Shakargy/devtime/issues"
53
- "Release Notes" = "https://github.com/Shakargy/devtime/releases/tag/v0.5.1"
53
+ "Release Notes" = "https://github.com/Shakargy/devtime/releases/tag/v0.7.0"
54
54
  Demo = "https://youtu.be/1Hiu3Y9J_SI"
55
55
 
56
56
  [project.scripts]
@@ -1,6 +1,6 @@
1
1
  """DevTime - local-first Engineering Intelligence for repository memory."""
2
2
 
3
- __version__ = "0.5.1"
3
+ __version__ = "0.7.0"
4
4
 
5
5
  # Version metadata (Builder Edition, Chapter 20).
6
6
  EVIDENCE_MODEL = "2026.06.1"
@@ -5,6 +5,10 @@ The CLI is the first product surface. It must make trust visible.
5
5
  Exit codes (Appendix A):
6
6
  0 success | 1 general error | 2 not initialized | 3 scan failed
7
7
  4 migration failed | 5 privacy boundary violation | 6 fixture assertion failed
8
+ 7 review found a regression (only with `dtc review --fail-on-regression`)
9
+
10
+ `dtc review` exits 1 when the review could not run (bad ref, shallow clone,
11
+ failed snapshot scan). A review that could not run is never reported as clean.
8
12
  """
9
13
 
10
14
  from __future__ import annotations
@@ -157,23 +161,54 @@ def verify(
157
161
  if result.status in ver.APPLICABLE_STATUSES:
158
162
  ver.save_verification(conn, result)
159
163
 
164
+ state = ver.scan_state(conn)
165
+
160
166
  if as_json:
161
167
  console.print_json(
162
168
  _json.dumps(
163
169
  {
164
170
  "schema_version": "2",
165
171
  "command": "verify",
172
+ "evidence_snapshot": state,
166
173
  "results": [r.to_dict() for r in results],
167
174
  }
168
175
  )
169
176
  )
170
177
  return
171
178
 
179
+ _print_scan_state(state)
172
180
  _print_report(results, single=bool(claim))
173
181
  finally:
174
182
  conn.close()
175
183
 
176
184
 
185
+ def _print_scan_state(state: dict) -> None:
186
+ """Say plainly which snapshot these conclusions came from.
187
+
188
+ Verification reads the last persisted scan, not the working tree. When the
189
+ two disagree, that must be the first thing a reader sees.
190
+ """
191
+ tree = state.get("working_tree")
192
+ if tree == "changed_since_scan":
193
+ changed = state.get("changed_paths") or []
194
+ console.print(
195
+ "[yellow]These results were computed from a scan that no longer "
196
+ "matches your working tree.[/yellow]"
197
+ )
198
+ for p in changed[:5]:
199
+ console.print(f" changed since the scan: {p}", markup=False)
200
+ if len(changed) > 5:
201
+ console.print(f" ... and {len(changed) - 5} more", markup=False)
202
+ console.print("Run [bold]dtc scan[/bold] to verify against current code.")
203
+ console.print("")
204
+ elif tree == "partially_checked":
205
+ console.print(
206
+ "[dim]Working-tree comparison was capped; some files were not "
207
+ "re-checked against the scan.[/dim]"
208
+ )
209
+ console.print("")
210
+
211
+
177
212
  def _print_report(results: list, single: bool) -> None:
178
213
  """Report card: what DevTime can and cannot verify about this repository."""
179
214
  from devtime.intelligence import verification as ver
@@ -478,6 +513,48 @@ def risk(
478
513
  raise typer.Exit(code=1)
479
514
 
480
515
 
516
+ @app.command()
517
+ def review(
518
+ base: str = typer.Option(..., "--base", help="Base ref, e.g. origin/main."),
519
+ head: str = typer.Option("HEAD", "--head", help="Head ref to review."),
520
+ fmt: str = typer.Option("text", "--format", help="text, json, or markdown."),
521
+ json_out: Path = typer.Option(
522
+ None, "--json-out", help="Also write the JSON report to this file."
523
+ ),
524
+ fail_on_regression: bool = typer.Option(
525
+ False,
526
+ "--fail-on-regression",
527
+ help="Exit 7 when a claim regresses. Off by default: reviews are advisory.",
528
+ ),
529
+ ) -> None:
530
+ """Compare claims at two commits and report what the change did to them."""
531
+ import json as _json
532
+
533
+ from devtime.output.review import render_markdown, render_text
534
+ from devtime.review_flow import has_regression, run_review
535
+
536
+ if fmt not in ("text", "json", "markdown"):
537
+ console.print("[red]--format must be text, json, or markdown.[/red]")
538
+ raise typer.Exit(code=1)
539
+
540
+ report = run_review(Path.cwd(), base, head)
541
+
542
+ if json_out is not None:
543
+ json_out.write_text(_json.dumps(report, indent=2) + "\n", encoding="utf-8")
544
+
545
+ if fmt == "json":
546
+ typer.echo(_json.dumps(report, indent=2))
547
+ elif fmt == "markdown":
548
+ typer.echo(render_markdown(report))
549
+ else:
550
+ typer.echo(render_text(report))
551
+
552
+ if report["status"] != "completed":
553
+ raise typer.Exit(code=1)
554
+ if fail_on_regression and has_regression(report):
555
+ raise typer.Exit(code=7)
556
+
557
+
481
558
  # --------------------------------------------------------------------------- #
482
559
  # AI workflow
483
560
  # --------------------------------------------------------------------------- #
@@ -0,0 +1,179 @@
1
+ """Claim transitions between two snapshots (v0.7.0).
2
+
3
+ A change is not interesting because it touched files. It is interesting when it
4
+ moves what the repository can support: a claim that was supported and no
5
+ longer is, a claim that newly applies, or a claim whose evidence changed even
6
+ though its conclusion held.
7
+
8
+ This module is pure: it takes two lists of verification results and the set of
9
+ changed paths, and returns transitions. It does no git, filesystem, or database
10
+ work, so its behavior is fully determined by its inputs.
11
+ """
12
+
13
+ from __future__ import annotations
14
+
15
+ from dataclasses import dataclass, field
16
+
17
+ from devtime.intelligence import verification as ver
18
+
19
+ # Transition kinds, in reporting order (most important first).
20
+ REGRESSION = "regression"
21
+ NEWLY_APPLICABLE = "newly_applicable"
22
+ NO_LONGER_APPLICABLE = "no_longer_applicable"
23
+ IMPROVEMENT = "improvement"
24
+ EVIDENCE_CHANGED = "evidence_changed"
25
+ UNCHANGED = "unchanged"
26
+
27
+ _ORDER = {
28
+ REGRESSION: 0,
29
+ NEWLY_APPLICABLE: 1,
30
+ NO_LONGER_APPLICABLE: 2,
31
+ IMPROVEMENT: 3,
32
+ EVIDENCE_CHANGED: 4,
33
+ UNCHANGED: 5,
34
+ }
35
+
36
+ # How strongly a status supports its claim. Used only to tell a regression from
37
+ # an improvement; NOT_APPLICABLE is handled separately because it is not a
38
+ # weaker form of support, it is the absence of a surface.
39
+ _RANK = {
40
+ ver.CONTRADICTED: 0,
41
+ ver.UNKNOWN: 1,
42
+ ver.WEAK: 1,
43
+ ver.SUPPORTED: 2,
44
+ }
45
+
46
+ _NOTES = {
47
+ REGRESSION: "The change reduced what the repository can support for this claim.",
48
+ NEWLY_APPLICABLE: "The change introduced a surface this claim now applies to.",
49
+ NO_LONGER_APPLICABLE: (
50
+ "The surface this claim applied to is no longer detected. It may have "
51
+ "been removed, renamed, or moved outside scanner coverage."
52
+ ),
53
+ IMPROVEMENT: "The change added evidence for this claim.",
54
+ EVIDENCE_CHANGED: (
55
+ "Files this claim depends on changed. The status held, but the evidence "
56
+ "behind it is different and may be worth a look."
57
+ ),
58
+ UNCHANGED: "",
59
+ }
60
+
61
+
62
+ @dataclass
63
+ class Transition:
64
+ claim_id: str
65
+ claim_name: str
66
+ kind: str
67
+ base_status: str
68
+ head_status: str
69
+ base_summary: str
70
+ head_summary: str
71
+ changed_evidence: list[str] = field(default_factory=list)
72
+ head_missing: list[str] = field(default_factory=list)
73
+ note: str = ""
74
+
75
+ def to_dict(self) -> dict:
76
+ return {
77
+ "claim_id": self.claim_id,
78
+ "claim_name": self.claim_name,
79
+ "kind": self.kind,
80
+ "base_status": self.base_status,
81
+ "head_status": self.head_status,
82
+ "base_summary": self.base_summary,
83
+ "head_summary": self.head_summary,
84
+ "changed_evidence": self.changed_evidence,
85
+ "head_missing_evidence": self.head_missing,
86
+ "note": self.note,
87
+ }
88
+
89
+
90
+ def _summary(result) -> str:
91
+ return result.why[0] if result.why else ""
92
+
93
+
94
+ def _classify(base_status: str, head_status: str) -> str | None:
95
+ """Kind for a status change, or None when the status did not change."""
96
+ if base_status == head_status:
97
+ return None
98
+ if base_status == ver.NOT_APPLICABLE:
99
+ return NEWLY_APPLICABLE
100
+ if head_status == ver.NOT_APPLICABLE:
101
+ return NO_LONGER_APPLICABLE
102
+ if head_status == ver.CONTRADICTED:
103
+ return REGRESSION
104
+ if _RANK.get(head_status, 1) < _RANK.get(base_status, 1):
105
+ return REGRESSION
106
+ if _RANK.get(head_status, 1) > _RANK.get(base_status, 1):
107
+ return IMPROVEMENT
108
+ # WEAK <-> UNKNOWN: same strength, different reason. Report it as a change
109
+ # of evidence rather than inventing a direction.
110
+ return EVIDENCE_CHANGED
111
+
112
+
113
+ def compute_transitions(
114
+ base_results: list, head_results: list, changed_paths: set[str]
115
+ ) -> list[Transition]:
116
+ """Every claim's transition from base to head, most important first.
117
+
118
+ `changed_paths` must contain both the new and the old path of a rename, so a
119
+ claim that depended on a renamed file is recognized as affected.
120
+ """
121
+ base_by_id = {r.claim_slug: r for r in base_results}
122
+ head_by_id = {r.claim_slug: r for r in head_results}
123
+ transitions: list[Transition] = []
124
+
125
+ for claim_id in sorted(set(base_by_id) | set(head_by_id)):
126
+ base = base_by_id.get(claim_id)
127
+ head = head_by_id.get(claim_id)
128
+ base_status = base.status if base else ver.NOT_APPLICABLE
129
+ head_status = head.status if head else ver.NOT_APPLICABLE
130
+
131
+ deps: set[str] = set()
132
+ for r in (base, head):
133
+ if r is None:
134
+ continue
135
+ deps |= set(r.dependencies)
136
+ deps |= {e.path for e in r.supporting}
137
+ touched = sorted(deps & changed_paths)
138
+
139
+ kind = _classify(base_status, head_status)
140
+ base_summary = _summary(base) if base else ""
141
+ head_summary = _summary(head) if head else ""
142
+ if kind is None:
143
+ both_not_applicable = base_status == ver.NOT_APPLICABLE
144
+ if not both_not_applicable and (touched or base_summary != head_summary):
145
+ kind = EVIDENCE_CHANGED
146
+ else:
147
+ kind = UNCHANGED
148
+
149
+ ref = head or base
150
+ transitions.append(
151
+ Transition(
152
+ claim_id=claim_id,
153
+ claim_name=ref.claim_name if ref else claim_id,
154
+ kind=kind,
155
+ base_status=base_status,
156
+ head_status=head_status,
157
+ base_summary=base_summary,
158
+ head_summary=head_summary,
159
+ changed_evidence=touched[:20],
160
+ head_missing=list(head.missing) if head else [],
161
+ note=_NOTES[kind],
162
+ )
163
+ )
164
+
165
+ transitions.sort(key=lambda t: (_ORDER[t.kind], t.claim_id))
166
+ return transitions
167
+
168
+
169
+ def summarize(transitions: list[Transition]) -> dict:
170
+ counts = {kind: 0 for kind in _ORDER}
171
+ for t in transitions:
172
+ counts[t.kind] += 1
173
+ return counts
174
+
175
+
176
+ def reportable(transitions: list[Transition]) -> list[Transition]:
177
+ """Transitions worth showing. Unchanged, unaffected claims are only counted,
178
+ so a review does not repeat low-value observations on every run."""
179
+ return [t for t in transitions if t.kind != UNCHANGED]