devtime-ei 0.6.0__tar.gz → 0.8.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.
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/PKG-INFO +29 -8
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/README.md +27 -6
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/pyproject.toml +2 -2
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/src/devtime/__init__.py +1 -1
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/src/devtime/cli.py +49 -0
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/src/devtime/intelligence/concepts.py +11 -1
- devtime_ei-0.8.0/src/devtime/intelligence/review.py +179 -0
- devtime_ei-0.8.0/src/devtime/intelligence/routes.py +638 -0
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/src/devtime/intelligence/verification.py +422 -207
- devtime_ei-0.8.0/src/devtime/output/review.py +154 -0
- devtime_ei-0.8.0/src/devtime/review_flow.py +171 -0
- devtime_ei-0.8.0/src/devtime/scanner/extractors/base.py +244 -0
- devtime_ei-0.8.0/src/devtime/scanner/extractors/python.py +405 -0
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/src/devtime/scanner/extractors/tests.py +15 -2
- devtime_ei-0.8.0/src/devtime/scanner/extractors/typescript.py +612 -0
- devtime_ei-0.8.0/src/devtime/snapshots.py +226 -0
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/src/devtime_ei.egg-info/PKG-INFO +29 -8
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/src/devtime_ei.egg-info/SOURCES.txt +5 -0
- devtime_ei-0.6.0/src/devtime/scanner/extractors/base.py +0 -83
- devtime_ei-0.6.0/src/devtime/scanner/extractors/python.py +0 -81
- devtime_ei-0.6.0/src/devtime/scanner/extractors/typescript.py +0 -144
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/LICENSE +0 -0
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/setup.cfg +0 -0
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/src/devtime/ai/__init__.py +0 -0
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/src/devtime/ai/local.py +0 -0
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/src/devtime/ai/prompts.py +0 -0
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/src/devtime/ai/providers.py +0 -0
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/src/devtime/assets/devtimeignore.starter +0 -0
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/src/devtime/config.py +0 -0
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/src/devtime/db/__init__.py +0 -0
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/src/devtime/db/connection.py +0 -0
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/src/devtime/db/migrations.py +0 -0
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/src/devtime/db/repository.py +0 -0
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/src/devtime/db/schema.sql +0 -0
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/src/devtime/demo.py +0 -0
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/src/devtime/fixtures/__init__.py +0 -0
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/src/devtime/fixtures/assertions.py +0 -0
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/src/devtime/fixtures/loader.py +0 -0
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/src/devtime/fixtures/runner.py +0 -0
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/src/devtime/intelligence/__init__.py +0 -0
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/src/devtime/intelligence/claims.py +0 -0
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/src/devtime/intelligence/context_pack.py +0 -0
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/src/devtime/intelligence/evidence.py +0 -0
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/src/devtime/intelligence/lineage.py +0 -0
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/src/devtime/intelligence/risk.py +0 -0
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/src/devtime/intelligence/scoring.py +0 -0
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/src/devtime/mcp/__init__.py +0 -0
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/src/devtime/mcp/schemas.py +0 -0
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/src/devtime/mcp/server.py +0 -0
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/src/devtime/mcp/tools.py +0 -0
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/src/devtime/mcp/transport.py +0 -0
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/src/devtime/output/__init__.py +0 -0
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/src/devtime/output/json_export.py +0 -0
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/src/devtime/output/markdown.py +0 -0
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/src/devtime/output/terminal.py +0 -0
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/src/devtime/paths.py +0 -0
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/src/devtime/privacy.py +0 -0
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/src/devtime/resources/demo-saas/.devtimeignore +0 -0
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/src/devtime/resources/demo-saas/README.md +0 -0
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/src/devtime/resources/demo-saas/docs/decisions/0001-use-jwt.md +0 -0
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/src/devtime/resources/demo-saas/package.json +0 -0
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/src/devtime/resources/demo-saas/src/admin/permissions.ts +0 -0
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/src/devtime/resources/demo-saas/src/auth/login.ts +0 -0
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/src/devtime/resources/demo-saas/src/auth/middleware.ts +0 -0
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/src/devtime/resources/demo-saas/src/auth/tokens.ts +0 -0
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/src/devtime/resources/demo-saas/src/billing/stripe-webhook.ts +0 -0
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/src/devtime/resources/demo-saas/src/billing/subscription-service.ts +0 -0
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/src/devtime/resources/demo-saas/src/export/export-csv.ts +0 -0
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/src/devtime/resources/demo-saas/src/jobs/email-worker.ts +0 -0
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/src/devtime/resources/demo-saas/src/jobs/queues.ts +0 -0
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/src/devtime/resources/demo-saas/tests/auth-login.test.ts +0 -0
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/src/devtime/resources/demo-saas/tests/stripe-signature.test.ts +0 -0
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/src/devtime/scanner/__init__.py +0 -0
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/src/devtime/scanner/extractors/__init__.py +0 -0
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/src/devtime/scanner/extractors/config_files.py +0 -0
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/src/devtime/scanner/extractors/docs.py +0 -0
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/src/devtime/scanner/extractors/nextjs.py +0 -0
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/src/devtime/scanner/file_walker.py +0 -0
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/src/devtime/scanner/ignore.py +0 -0
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/src/devtime/scanner/language.py +0 -0
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/src/devtime/scanner/signals.py +0 -0
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/src/devtime_ei.egg-info/dependency_links.txt +0 -0
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/src/devtime_ei.egg-info/entry_points.txt +0 -0
- {devtime_ei-0.6.0 → devtime_ei-0.8.0}/src/devtime_ei.egg-info/requires.txt +0 -0
- {devtime_ei-0.6.0 → devtime_ei-0.8.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.
|
|
3
|
+
Version: 0.8.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.
|
|
11
|
+
Project-URL: Release Notes, https://github.com/Shakargy/devtime/releases/tag/v0.8.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
|
|
@@ -146,14 +146,34 @@ Contradictions:
|
|
|
146
146
|
- **UNKNOWN** - the surface exists but coverage cannot responsibly decide
|
|
147
147
|
- **NOT_APPLICABLE** - the repository has no surface this claim is about
|
|
148
148
|
|
|
149
|
-
|
|
150
|
-
webhook signatures, and JWT authentication.
|
|
151
|
-
actually verify in your repository, and when
|
|
152
|
-
make a claim verifiable instead of
|
|
149
|
+
Five built-in claims ship: write route authentication, admin authorization,
|
|
150
|
+
route test association, billing webhook signatures, and JWT authentication.
|
|
151
|
+
`dtc verify` leads with what it can actually verify in your repository, and when
|
|
152
|
+
nothing applies it says what would make a claim verifiable instead of
|
|
153
|
+
dead-ending.
|
|
154
|
+
|
|
155
|
+
Route claims see routes the way your app serves them. A router mounted with
|
|
156
|
+
`app.use("/admin", requireAdmin, adminRouter)` or FastAPI's
|
|
157
|
+
`include_router(..., dependencies=[Depends(get_current_user)])` is resolved to
|
|
158
|
+
its full path and every guard that runs before it:
|
|
159
|
+
|
|
160
|
+
```text
|
|
161
|
+
DELETE /admin/users/:id is guarded by requireAdmin (where its router is mounted, src/server.ts:14).
|
|
162
|
+
```
|
|
153
163
|
|
|
154
164
|
Truth and freshness are separate: when a file behind a verified claim changes,
|
|
155
|
-
the claim goes STALE and names the file.
|
|
156
|
-
|
|
165
|
+
the claim goes STALE and names the file.
|
|
166
|
+
|
|
167
|
+
To review a change, compare claims at two commits:
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
dtc review --base origin/main
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
It reports what the change did to each claim (a regression, a claim that newly
|
|
174
|
+
applies, evidence that changed under a claim that held) from isolated snapshots
|
|
175
|
+
of both commits, without touching your working tree. It runs in GitHub Actions
|
|
176
|
+
as an advisory job summary.
|
|
157
177
|
|
|
158
178
|
See **[VERIFICATION.md](VERIFICATION.md)** for the full model and its limits.
|
|
159
179
|
|
|
@@ -256,6 +276,7 @@ Anything outside these six is out of scope for now. See [LIMITATIONS.md](LIMITAT
|
|
|
256
276
|
| `dtc risk --diff` | Review a git diff for risky changes using local evidence (advisory). |
|
|
257
277
|
| `dtc decision add` | Add a local decision record that can reduce uncertainty. |
|
|
258
278
|
| `dtc verify [claim]` | Verify repository claims against evidence: status, contradictions, freshness (experimental). |
|
|
279
|
+
| `dtc review --base <ref>` | Compare claims at two commits and report what the change did to them (advisory). |
|
|
259
280
|
|
|
260
281
|
(Also available: `dtc evidence`, `dtc debt`, `dtc status`, `dtc doctor --privacy`,
|
|
261
282
|
`dtc export`, `dtc reset`, `dtc mcp start`.)
|
|
@@ -107,14 +107,34 @@ Contradictions:
|
|
|
107
107
|
- **UNKNOWN** - the surface exists but coverage cannot responsibly decide
|
|
108
108
|
- **NOT_APPLICABLE** - the repository has no surface this claim is about
|
|
109
109
|
|
|
110
|
-
|
|
111
|
-
webhook signatures, and JWT authentication.
|
|
112
|
-
actually verify in your repository, and when
|
|
113
|
-
make a claim verifiable instead of
|
|
110
|
+
Five built-in claims ship: write route authentication, admin authorization,
|
|
111
|
+
route test association, billing webhook signatures, and JWT authentication.
|
|
112
|
+
`dtc verify` leads with what it can actually verify in your repository, and when
|
|
113
|
+
nothing applies it says what would make a claim verifiable instead of
|
|
114
|
+
dead-ending.
|
|
115
|
+
|
|
116
|
+
Route claims see routes the way your app serves them. A router mounted with
|
|
117
|
+
`app.use("/admin", requireAdmin, adminRouter)` or FastAPI's
|
|
118
|
+
`include_router(..., dependencies=[Depends(get_current_user)])` is resolved to
|
|
119
|
+
its full path and every guard that runs before it:
|
|
120
|
+
|
|
121
|
+
```text
|
|
122
|
+
DELETE /admin/users/:id is guarded by requireAdmin (where its router is mounted, src/server.ts:14).
|
|
123
|
+
```
|
|
114
124
|
|
|
115
125
|
Truth and freshness are separate: when a file behind a verified claim changes,
|
|
116
|
-
the claim goes STALE and names the file.
|
|
117
|
-
|
|
126
|
+
the claim goes STALE and names the file.
|
|
127
|
+
|
|
128
|
+
To review a change, compare claims at two commits:
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
dtc review --base origin/main
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
It reports what the change did to each claim (a regression, a claim that newly
|
|
135
|
+
applies, evidence that changed under a claim that held) from isolated snapshots
|
|
136
|
+
of both commits, without touching your working tree. It runs in GitHub Actions
|
|
137
|
+
as an advisory job summary.
|
|
118
138
|
|
|
119
139
|
See **[VERIFICATION.md](VERIFICATION.md)** for the full model and its limits.
|
|
120
140
|
|
|
@@ -217,6 +237,7 @@ Anything outside these six is out of scope for now. See [LIMITATIONS.md](LIMITAT
|
|
|
217
237
|
| `dtc risk --diff` | Review a git diff for risky changes using local evidence (advisory). |
|
|
218
238
|
| `dtc decision add` | Add a local decision record that can reduce uncertainty. |
|
|
219
239
|
| `dtc verify [claim]` | Verify repository claims against evidence: status, contradictions, freshness (experimental). |
|
|
240
|
+
| `dtc review --base <ref>` | Compare claims at two commits and report what the change did to them (advisory). |
|
|
220
241
|
|
|
221
242
|
(Also available: `dtc evidence`, `dtc debt`, `dtc status`, `dtc doctor --privacy`,
|
|
222
243
|
`dtc export`, `dtc reset`, `dtc mcp start`.)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "devtime-ei"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.8.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.
|
|
53
|
+
"Release Notes" = "https://github.com/Shakargy/devtime/releases/tag/v0.8.0"
|
|
54
54
|
Demo = "https://youtu.be/1Hiu3Y9J_SI"
|
|
55
55
|
|
|
56
56
|
[project.scripts]
|
|
@@ -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
|
|
@@ -273,6 +277,9 @@ def _print_nothing_verifiable() -> None:
|
|
|
273
277
|
console.print("Built-in claims become verifiable when a repository has:")
|
|
274
278
|
console.print(" - HTTP routes and tests (route-test-coverage)")
|
|
275
279
|
console.print(" - admin, staff, or back-office routes (admin-authorization)")
|
|
280
|
+
console.print(
|
|
281
|
+
" - POST, PUT, PATCH, or DELETE routes (mutating-routes-authenticated)"
|
|
282
|
+
)
|
|
276
283
|
console.print(" - JWT usage or a JWT dependency (jwt-authentication)")
|
|
277
284
|
console.print(" - billing webhooks or a payment provider (billing-webhook-signature)")
|
|
278
285
|
console.print("")
|
|
@@ -509,6 +516,48 @@ def risk(
|
|
|
509
516
|
raise typer.Exit(code=1)
|
|
510
517
|
|
|
511
518
|
|
|
519
|
+
@app.command()
|
|
520
|
+
def review(
|
|
521
|
+
base: str = typer.Option(..., "--base", help="Base ref, e.g. origin/main."),
|
|
522
|
+
head: str = typer.Option("HEAD", "--head", help="Head ref to review."),
|
|
523
|
+
fmt: str = typer.Option("text", "--format", help="text, json, or markdown."),
|
|
524
|
+
json_out: Path = typer.Option(
|
|
525
|
+
None, "--json-out", help="Also write the JSON report to this file."
|
|
526
|
+
),
|
|
527
|
+
fail_on_regression: bool = typer.Option(
|
|
528
|
+
False,
|
|
529
|
+
"--fail-on-regression",
|
|
530
|
+
help="Exit 7 when a claim regresses. Off by default: reviews are advisory.",
|
|
531
|
+
),
|
|
532
|
+
) -> None:
|
|
533
|
+
"""Compare claims at two commits and report what the change did to them."""
|
|
534
|
+
import json as _json
|
|
535
|
+
|
|
536
|
+
from devtime.output.review import render_markdown, render_text
|
|
537
|
+
from devtime.review_flow import has_regression, run_review
|
|
538
|
+
|
|
539
|
+
if fmt not in ("text", "json", "markdown"):
|
|
540
|
+
console.print("[red]--format must be text, json, or markdown.[/red]")
|
|
541
|
+
raise typer.Exit(code=1)
|
|
542
|
+
|
|
543
|
+
report = run_review(Path.cwd(), base, head)
|
|
544
|
+
|
|
545
|
+
if json_out is not None:
|
|
546
|
+
json_out.write_text(_json.dumps(report, indent=2) + "\n", encoding="utf-8")
|
|
547
|
+
|
|
548
|
+
if fmt == "json":
|
|
549
|
+
typer.echo(_json.dumps(report, indent=2))
|
|
550
|
+
elif fmt == "markdown":
|
|
551
|
+
typer.echo(render_markdown(report))
|
|
552
|
+
else:
|
|
553
|
+
typer.echo(render_text(report))
|
|
554
|
+
|
|
555
|
+
if report["status"] != "completed":
|
|
556
|
+
raise typer.Exit(code=1)
|
|
557
|
+
if fail_on_regression and has_regression(report):
|
|
558
|
+
raise typer.Exit(code=7)
|
|
559
|
+
|
|
560
|
+
|
|
512
561
|
# --------------------------------------------------------------------------- #
|
|
513
562
|
# AI workflow
|
|
514
563
|
# --------------------------------------------------------------------------- #
|
|
@@ -145,10 +145,20 @@ def _slugify(name: str) -> str:
|
|
|
145
145
|
return re.sub(r"[^a-z0-9]+", "-", name.lower()).strip("-")
|
|
146
146
|
|
|
147
147
|
|
|
148
|
+
# Route-resolution metadata (v0.8.0) describes routing structure, not behavior.
|
|
149
|
+
# Keeping it out of concept matching means a router variable named adminRouter
|
|
150
|
+
# or a Depends() call does not change which concepts a repository has.
|
|
151
|
+
_RESOLUTION_KEYS = frozenset({
|
|
152
|
+
"router", "offset", "guards", "inline_handler", "deps", "decorators",
|
|
153
|
+
"annotations",
|
|
154
|
+
})
|
|
155
|
+
|
|
156
|
+
|
|
148
157
|
def _signal_haystack(s: Signal) -> str:
|
|
158
|
+
values = [v for k, v in s.metadata.items() if k not in _RESOLUTION_KEYS]
|
|
149
159
|
return " ".join(
|
|
150
160
|
str(x).lower()
|
|
151
|
-
for x in (s.name, s.value, s.file_rel_path, *
|
|
161
|
+
for x in (s.name, s.value, s.file_rel_path, *values)
|
|
152
162
|
if x is not None
|
|
153
163
|
)
|
|
154
164
|
|
|
@@ -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]
|