adre-cli 0.1.0__tar.gz → 0.3.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.
- {adre_cli-0.1.0 → adre_cli-0.3.0}/PKG-INFO +66 -25
- {adre_cli-0.1.0 → adre_cli-0.3.0}/README.md +63 -22
- {adre_cli-0.1.0 → adre_cli-0.3.0}/adre/__init__.py +1 -1
- {adre_cli-0.1.0 → adre_cli-0.3.0}/adre/analyzers/architecture.py +3 -0
- {adre_cli-0.1.0 → adre_cli-0.3.0}/adre/cli.py +255 -20
- {adre_cli-0.1.0 → adre_cli-0.3.0}/adre/core/accepted.py +74 -0
- {adre_cli-0.1.0 → adre_cli-0.3.0}/adre/core/config.py +16 -0
- {adre_cli-0.1.0 → adre_cli-0.3.0}/adre/core/declared.py +120 -0
- {adre_cli-0.1.0 → adre_cli-0.3.0}/adre/core/github_check.py +81 -7
- {adre_cli-0.1.0 → adre_cli-0.3.0}/adre/core/incremental.py +22 -1
- adre_cli-0.3.0/adre/core/pr_comment.py +294 -0
- {adre_cli-0.1.0 → adre_cli-0.3.0}/adre/core/pr_review.py +118 -21
- {adre_cli-0.1.0 → adre_cli-0.3.0}/adre/core/repositories.py +38 -5
- {adre_cli-0.1.0 → adre_cli-0.3.0}/adre/core/review.py +29 -1
- {adre_cli-0.1.0 → adre_cli-0.3.0}/adre/core/sarif.py +22 -2
- {adre_cli-0.1.0 → adre_cli-0.3.0}/adre/core/scope.py +28 -0
- adre_cli-0.3.0/adre/core/setup.py +79 -0
- adre_cli-0.3.0/adre/core/severity.py +57 -0
- {adre_cli-0.1.0 → adre_cli-0.3.0}/adre/parsers/__init__.py +30 -4
- {adre_cli-0.1.0 → adre_cli-0.3.0}/adre/web.py +632 -11
- {adre_cli-0.1.0 → adre_cli-0.3.0}/adre_cli.egg-info/PKG-INFO +66 -25
- {adre_cli-0.1.0 → adre_cli-0.3.0}/adre_cli.egg-info/SOURCES.txt +7 -0
- {adre_cli-0.1.0 → adre_cli-0.3.0}/pyproject.toml +5 -2
- {adre_cli-0.1.0 → adre_cli-0.3.0}/tests/test_accepted.py +68 -1
- {adre_cli-0.1.0 → adre_cli-0.3.0}/tests/test_baseline.py +12 -4
- adre_cli-0.3.0/tests/test_fail_on.py +151 -0
- adre_cli-0.3.0/tests/test_file_limit.py +164 -0
- {adre_cli-0.1.0 → adre_cli-0.3.0}/tests/test_gaps.py +76 -5
- adre_cli-0.3.0/tests/test_onboarding.py +242 -0
- {adre_cli-0.1.0 → adre_cli-0.3.0}/tests/test_packaging.py +5 -3
- adre_cli-0.3.0/tests/test_pr_comment.py +215 -0
- {adre_cli-0.1.0 → adre_cli-0.3.0}/tests/test_pr_review.py +6 -0
- {adre_cli-0.1.0 → adre_cli-0.3.0}/tests/test_recall.py +6 -0
- {adre_cli-0.1.0 → adre_cli-0.3.0}/tests/test_web.py +235 -0
- {adre_cli-0.1.0 → adre_cli-0.3.0}/LICENSE +0 -0
- {adre_cli-0.1.0 → adre_cli-0.3.0}/adre/analyzers/__init__.py +0 -0
- {adre_cli-0.1.0 → adre_cli-0.3.0}/adre/analyzers/findings.py +0 -0
- {adre_cli-0.1.0 → adre_cli-0.3.0}/adre/analyzers/inference.py +0 -0
- {adre_cli-0.1.0 → adre_cli-0.3.0}/adre/core/__init__.py +0 -0
- {adre_cli-0.1.0 → adre_cli-0.3.0}/adre/core/adaptive.py +0 -0
- {adre_cli-0.1.0 → adre_cli-0.3.0}/adre/core/baseline.py +0 -0
- {adre_cli-0.1.0 → adre_cli-0.3.0}/adre/core/decision_engine.py +0 -0
- {adre_cli-0.1.0 → adre_cli-0.3.0}/adre/core/evolution_intelligence.py +0 -0
- {adre_cli-0.1.0 → adre_cli-0.3.0}/adre/core/explainer.py +0 -0
- {adre_cli-0.1.0 → adre_cli-0.3.0}/adre/core/git_intelligence.py +0 -0
- {adre_cli-0.1.0 → adre_cli-0.3.0}/adre/core/layers.py +0 -0
- {adre_cli-0.1.0 → adre_cli-0.3.0}/adre/core/pr_intelligence.py +0 -0
- {adre_cli-0.1.0 → adre_cli-0.3.0}/adre/core/prioritization.py +0 -0
- {adre_cli-0.1.0 → adre_cli-0.3.0}/adre/core/project.py +0 -0
- {adre_cli-0.1.0 → adre_cli-0.3.0}/adre/core/refactor_intelligence.py +0 -0
- {adre_cli-0.1.0 → adre_cli-0.3.0}/adre/core/rules_shared.py +0 -0
- {adre_cli-0.1.0 → adre_cli-0.3.0}/adre/core/snapshots.py +0 -0
- {adre_cli-0.1.0 → adre_cli-0.3.0}/adre/core/stability_intelligence.py +0 -0
- {adre_cli-0.1.0 → adre_cli-0.3.0}/adre/graph/__init__.py +0 -0
- {adre_cli-0.1.0 → adre_cli-0.3.0}/adre/graph/dependencies.py +0 -0
- {adre_cli-0.1.0 → adre_cli-0.3.0}/adre/parsers/go.py +0 -0
- {adre_cli-0.1.0 → adre_cli-0.3.0}/adre/parsers/javascript.py +0 -0
- {adre_cli-0.1.0 → adre_cli-0.3.0}/adre/parsers/jvm.py +0 -0
- {adre_cli-0.1.0 → adre_cli-0.3.0}/adre/parsers/python.py +0 -0
- {adre_cli-0.1.0 → adre_cli-0.3.0}/adre/reports/__init__.py +0 -0
- {adre_cli-0.1.0 → adre_cli-0.3.0}/adre/reports/architecture.py +0 -0
- {adre_cli-0.1.0 → adre_cli-0.3.0}/adre/rules.py +0 -0
- {adre_cli-0.1.0 → adre_cli-0.3.0}/adre_cli.egg-info/dependency_links.txt +0 -0
- {adre_cli-0.1.0 → adre_cli-0.3.0}/adre_cli.egg-info/entry_points.txt +0 -0
- {adre_cli-0.1.0 → adre_cli-0.3.0}/adre_cli.egg-info/requires.txt +2 -2
- {adre_cli-0.1.0 → adre_cli-0.3.0}/adre_cli.egg-info/top_level.txt +0 -0
- {adre_cli-0.1.0 → adre_cli-0.3.0}/setup.cfg +0 -0
- {adre_cli-0.1.0 → adre_cli-0.3.0}/tests/test_architecture.py +0 -0
- {adre_cli-0.1.0 → adre_cli-0.3.0}/tests/test_ci_outputs.py +0 -0
- {adre_cli-0.1.0 → adre_cli-0.3.0}/tests/test_cycles.py +0 -0
- {adre_cli-0.1.0 → adre_cli-0.3.0}/tests/test_incremental.py +0 -0
- {adre_cli-0.1.0 → adre_cli-0.3.0}/tests/test_realistic.py +0 -0
- {adre_cli-0.1.0 → adre_cli-0.3.0}/tests/test_relationships.py +0 -0
- {adre_cli-0.1.0 → adre_cli-0.3.0}/tests/test_resolution.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: adre-cli
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: Architecture Drift Review Engine: learn a repository's architecture and flag pull requests that drift from it.
|
|
5
5
|
License: Apache-2.0
|
|
6
6
|
Project-URL: Homepage, https://github.com/christiangebru/architect-reviewer
|
|
@@ -14,21 +14,41 @@ Classifier: Topic :: Software Development :: Quality Assurance
|
|
|
14
14
|
Requires-Python: >=3.9
|
|
15
15
|
Description-Content-Type: text/markdown
|
|
16
16
|
License-File: LICENSE
|
|
17
|
+
Requires-Dist: fastapi>=0.110
|
|
18
|
+
Requires-Dist: uvicorn>=0.27
|
|
17
19
|
Provides-Extra: web
|
|
18
|
-
Requires-Dist: fastapi>=0.110; extra == "web"
|
|
19
|
-
Requires-Dist: uvicorn>=0.27; extra == "web"
|
|
20
20
|
Dynamic: license-file
|
|
21
21
|
|
|
22
22
|
# ADRE — Architecture Drift Review Engine
|
|
23
23
|
|
|
24
24
|
**Zero-config architecture guardrails for pull requests.** ADRE learns the architecture your repository already follows, then fails a pull request only when *that pull request* breaks it: a controller reaching past the service layer into a repository, a reversed dependency, direct database access outside the persistence layer, a new import cycle.
|
|
25
25
|
|
|
26
|
-
- **No rules to write.** Layers and dependency directions are
|
|
26
|
+
- **No rules to write, nothing to save.** Layers and dependency directions are learned from your main branch on every pull request. You can commit a baseline to pin them, but you don't have to. If you do want rules, declare them in `.adre/architecture.json`, and they are enforced even where inference finds nothing.
|
|
27
27
|
- **Only new drift.** The PR head is compared with its base commit, renames included, so existing debt and unrelated files never fail a PR.
|
|
28
28
|
- **Deterministic and explained.** Every finding names the changed import, the established path it breaks, the evidence and a confidence. No LLM in the loop.
|
|
29
29
|
- **Built for CI.** One GitHub Action step, annotations on the offending line, SARIF for code scanning, JSON for everything else. The CLI has no dependencies.
|
|
30
30
|
- **Python, JavaScript/TypeScript, Java, Kotlin and Go.**
|
|
31
31
|
|
|
32
|
+
## Quick start
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
pip install adre-cli
|
|
36
|
+
cd your-project
|
|
37
|
+
adre init # shows the architecture ADRE sees and adds the pull-request check
|
|
38
|
+
git add .github/workflows/architecture.yml && git commit -m "Add ADRE" && git push
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
That's all. Every pull request now gets a check that fails on new architecture drift and one comment explaining each finding and how to fix it.
|
|
42
|
+
|
|
43
|
+
To look around on your own machine:
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
adre ui # opens the web UI in your browser, on this project
|
|
47
|
+
adre review # checks your uncommitted changes
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
On macOS with Homebrew's Python, `pip install` refuses to install into the system Python. Use a virtual environment: `python3 -m venv ~/.adre && ~/.adre/bin/pip install adre-cli`, then add `~/.adre/bin` to your `PATH`.
|
|
51
|
+
|
|
32
52
|
### How it compares
|
|
33
53
|
|
|
34
54
|
| | Rules required | Gates PRs on new drift only | Indirect (chain) violations | Languages |
|
|
@@ -83,11 +103,12 @@ Unsupported languages are counted and skipped. Repository source is never execut
|
|
|
83
103
|
## Install
|
|
84
104
|
|
|
85
105
|
```
|
|
86
|
-
pip install adre-cli
|
|
87
|
-
pip install "adre-cli[web]" # plus the local web UI
|
|
106
|
+
pip install adre-cli
|
|
88
107
|
```
|
|
89
108
|
|
|
90
|
-
|
|
109
|
+
This includes the web UI. The analysis engine itself uses only the Python standard library, which is why the GitHub Action needs no install step.
|
|
110
|
+
|
|
111
|
+
To install an unreleased version from GitHub: `pip install "git+https://github.com/christiangebru/architect-reviewer@main"`.
|
|
91
112
|
|
|
92
113
|
This installs the `adre` command (the package is `adre-cli` because `adre` is taken on PyPI). From a source checkout, `./bin/adre` runs the same CLI without installing anything.
|
|
93
114
|
|
|
@@ -100,28 +121,37 @@ adre analyze ./my-repository
|
|
|
100
121
|
adre analyze ./my-repository --select src/controllers
|
|
101
122
|
```
|
|
102
123
|
|
|
103
|
-
|
|
124
|
+
Set up a repository (prints the architecture, writes `.github/workflows/architecture.yml`; `--baseline` also pins today's architecture):
|
|
104
125
|
|
|
105
126
|
```
|
|
106
|
-
adre
|
|
127
|
+
adre init
|
|
107
128
|
```
|
|
108
129
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
Compare the current tree against a saved baseline:
|
|
130
|
+
Check your uncommitted changes. Without a saved baseline, ADRE learns the architecture from the last commit; with one, it compares against the baseline:
|
|
112
131
|
|
|
113
132
|
```
|
|
114
|
-
adre review
|
|
133
|
+
adre review
|
|
115
134
|
adre review ./my-repository --against .adre/baseline.json
|
|
116
135
|
```
|
|
117
136
|
|
|
118
|
-
|
|
137
|
+
Optionally pin today's architecture, so that drift merged later cannot quietly become the new normal:
|
|
138
|
+
|
|
139
|
+
```
|
|
140
|
+
adre baseline
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
This writes `.adre/baseline.json`. Commit that file on the default branch. A committed baseline is also required outside git.
|
|
144
|
+
|
|
145
|
+
Open the web UI (opens your browser on this project's dashboard; picks a free port if 8000 is taken; binds to 127.0.0.1):
|
|
119
146
|
|
|
120
147
|
```
|
|
121
|
-
adre
|
|
148
|
+
adre ui
|
|
149
|
+
adre ui ./my-repository --port 9000 --no-browser
|
|
122
150
|
```
|
|
123
151
|
|
|
124
|
-
|
|
152
|
+
`adre web` is the same command.
|
|
153
|
+
|
|
154
|
+
The web UI gives the same answers as the CLI: **Review against baseline** runs exactly what `adre review` runs (baseline, declared rules, accepted and stale exceptions), and **Review a branch** runs the same pull-request review as the GitHub Action for the checked-out branch against a base you choose. On either page, **Accept with reason** records an intentional crossing in `.adre/accepted.json` (commit it so CI accepts it too). New repositories get a **Get started** checklist on the dashboard: review your changes, review a branch, add the GitHub check, and optionally pin the architecture with a baseline. The **Rules** page edits `.adre/architecture.json` visually: it starts from the layers ADRE found, lets you reorder, rename and add layers, turn on strict layering and add forbidden dependencies, and previews which files each layer claims and which current dependencies would break the rules before you save.
|
|
125
155
|
|
|
126
156
|
It only answers on localhost. Requests with another `Host` header or that the browser marks as cross-site are refused, and every action that changes something (saving a baseline, cloning or registering a repository, pinning, opening your editor) is a POST carrying a per-process token, so other websites cannot trigger them. Binding to another interface with `--host` prints a warning.
|
|
127
157
|
|
|
@@ -134,13 +164,18 @@ adre pr-check origin/main HEAD
|
|
|
134
164
|
|
|
135
165
|
Statuses:
|
|
136
166
|
|
|
137
|
-
- `PASS` (exit 0) — no new drift
|
|
167
|
+
- `PASS` (exit 0) — no new drift
|
|
138
168
|
- `DRIFT` (exit 2) — new architectural drift in the PR
|
|
139
|
-
- `
|
|
169
|
+
- `INCOMPLETE` (exit 4) — the PR changes a source file that was not analyzed because the project has more source files than the file limit (see below)
|
|
170
|
+
- `BASELINE_REQUIRED` (exit 3) — the `--against` baseline file does not exist, or there is no saved baseline and the base branch could not be analyzed
|
|
140
171
|
- `BASELINE_INVALID` (exit 1) — baseline could not be loaded
|
|
141
172
|
- `ERROR` (exit 1) — git or analysis failure
|
|
142
173
|
|
|
143
|
-
`pr-review`
|
|
174
|
+
**Which findings fail.** By default every finding fails the review. Set a threshold with `--fail-on critical|high|medium|low|none` (on `review`, `pr-review`, `pr-check` and `web`), the `ADRE_FAIL_ON` environment variable, or the action's `fail-on` input. Findings below it are still reported, as warnings (job summary, `::warning` annotations, SARIF level `note`, `warnings` in JSON), but do not fail. Severities: a new cycle is `critical`; layer skips, reversed layer dependencies, repository bypasses and declared-rule violations are `high`; an unexpected (inferred) dependency is `medium`. `--fail-on high` therefore keeps every proven violation blocking and turns inferred findings into warnings; `none` is an advisory mode for the first weeks of adoption.
|
|
175
|
+
|
|
176
|
+
**File limit.** ADRE analyzes at most 5,000 source files by default, in a stable (sorted) order. When a project has more, every output says how many files were left out, and a pull request that changes one of them gets `INCOMPLETE` instead of `PASS`. Raise the limit with `--max-files N` (any command), the `ADRE_MAX_FILES` environment variable, or the action's `max-files` input; `0` means no limit.
|
|
177
|
+
|
|
178
|
+
`pr-review` uses `.adre/baseline.json` from the base commit as the accepted architecture model (layers, directions, established paths) when one is committed, and otherwise learns that model from the base commit itself. It always analyzes the base commit in a throwaway clone to decide what is new. Only dependencies, cycles, and database imports that the PR adds relative to the base tree are reported. As a result:
|
|
144
179
|
|
|
145
180
|
- problems that already exist on the base branch are not blamed on the PR, even if they were merged after the baseline was saved
|
|
146
181
|
- renamed or moved files (detected by `git diff -M`) do not count as new dependencies
|
|
@@ -160,6 +195,7 @@ on:
|
|
|
160
195
|
|
|
161
196
|
permissions:
|
|
162
197
|
contents: read
|
|
198
|
+
pull-requests: write # lets ADRE keep one explanatory comment on the PR
|
|
163
199
|
|
|
164
200
|
jobs:
|
|
165
201
|
drift:
|
|
@@ -168,12 +204,12 @@ jobs:
|
|
|
168
204
|
- uses: actions/checkout@v4
|
|
169
205
|
with:
|
|
170
206
|
fetch-depth: 0 # the base commit and merge base must exist
|
|
171
|
-
- uses: christiangebru/architect-reviewer@v0.
|
|
207
|
+
- uses: christiangebru/architect-reviewer@v0.3.0 # or @v0 for the latest 0.x, or a commit SHA
|
|
172
208
|
with:
|
|
173
209
|
path: . # project directory inside the repository
|
|
174
210
|
```
|
|
175
211
|
|
|
176
|
-
The action compares the checked-out PR tree with the base commit, using `.adre/baseline.json` from the base commit as the accepted architecture, and fails the job on new drift. It writes the check summary to the job summary, adds an inline annotation on each finding (repository-relative paths, so projects in subdirectories work), and sets outputs `status`, `drift-count`, `accepted-count` and `sarif-file`.
|
|
212
|
+
The action compares the checked-out PR tree with the base commit, using `.adre/baseline.json` from the base commit as the accepted architecture if one is committed (otherwise the architecture learned from the base commit), and fails the job on new drift. It writes the check summary to the job summary, adds an inline annotation on each finding (repository-relative paths, so projects in subdirectories work), and sets outputs `status`, `drift-count`, `warning-count`, `accepted-count` and `sarif-file`.
|
|
177
213
|
|
|
178
214
|
| Input | Default | |
|
|
179
215
|
|---|---|---|
|
|
@@ -182,13 +218,18 @@ The action compares the checked-out PR tree with the base commit, using `.adre/b
|
|
|
182
218
|
| `head` | `github.sha` | Checked-out commit |
|
|
183
219
|
| `baseline` | base commit's `.adre/baseline.json` | Baseline file |
|
|
184
220
|
| `sarif-file` | (none) | Also write SARIF 2.1.0 here |
|
|
221
|
+
| `max-files` | `5000` | Most source files to analyze; `0` = no limit |
|
|
222
|
+
| `comment` | `true` | Keep one ADRE comment on the PR, updated on every push; `false` to turn off |
|
|
223
|
+
| `fail-on` | `low` | Lowest severity that fails: `critical`, `high`, `medium`, `low`, or `none` (report only) |
|
|
185
224
|
| `python-version` | `3.12` | Python used to run ADRE |
|
|
186
225
|
| `setup-python` | `true` | `false` uses the runner's Python |
|
|
187
226
|
|
|
227
|
+
**PR comment.** With `pull-requests: write`, the action keeps a single comment on the pull request and edits it on every push instead of adding new ones. Each finding is explained in plain language (what happened, why it matters, how to fix it) with a ready-to-paste `.adre/accepted.json` entry for intentional crossings; warnings, accepted and stale exceptions are folded away. A clean PR gets no comment; a PR whose findings were fixed sees the comment flip to passed. Without the permission, or on pull requests from forks (read-only token), the comment is skipped with a warning and the check result is unchanged. Outside the action: `adre pr-review … --comment` (uses `GITHUB_TOKEN`) or `--comment-file comment.md` to get the markdown.
|
|
228
|
+
|
|
188
229
|
To show findings in GitHub code scanning, write SARIF and upload it even when the check fails (needs `security-events: write`; private repositories need GitHub Advanced Security):
|
|
189
230
|
|
|
190
231
|
```yaml
|
|
191
|
-
- uses: christiangebru/architect-reviewer@v0.
|
|
232
|
+
- uses: christiangebru/architect-reviewer@v0.3.0
|
|
192
233
|
id: adre
|
|
193
234
|
with:
|
|
194
235
|
sarif-file: adre.sarif
|
|
@@ -199,10 +240,10 @@ To show findings in GitHub code scanning, write SARIF and upload it even when th
|
|
|
199
240
|
category: adre
|
|
200
241
|
```
|
|
201
242
|
|
|
202
|
-
|
|
243
|
+
No baseline is needed: without one, the action learns the architecture from the base branch of each pull request. To pin today's architecture instead, commit a baseline on the default branch:
|
|
203
244
|
|
|
204
245
|
```
|
|
205
|
-
adre baseline
|
|
246
|
+
adre baseline
|
|
206
247
|
git add .adre/baseline.json
|
|
207
248
|
git commit -m "Save architecture baseline"
|
|
208
249
|
```
|
|
@@ -324,7 +365,7 @@ Unchanged files are reused from `.adre/parse-cache.json` by content hash. Change
|
|
|
324
365
|
The CLI and engine use only the Python standard library (3.9+). All code lives in the `adre` package; FastAPI and Uvicorn are only needed for the optional web UI (`adre/web.py`, extra `web`).
|
|
325
366
|
|
|
326
367
|
```
|
|
327
|
-
pip install -e
|
|
368
|
+
pip install -e . # same as: pip install -r requirements.txt
|
|
328
369
|
python3 -m unittest discover
|
|
329
370
|
```
|
|
330
371
|
|
|
@@ -2,12 +2,32 @@
|
|
|
2
2
|
|
|
3
3
|
**Zero-config architecture guardrails for pull requests.** ADRE learns the architecture your repository already follows, then fails a pull request only when *that pull request* breaks it: a controller reaching past the service layer into a repository, a reversed dependency, direct database access outside the persistence layer, a new import cycle.
|
|
4
4
|
|
|
5
|
-
- **No rules to write.** Layers and dependency directions are
|
|
5
|
+
- **No rules to write, nothing to save.** Layers and dependency directions are learned from your main branch on every pull request. You can commit a baseline to pin them, but you don't have to. If you do want rules, declare them in `.adre/architecture.json`, and they are enforced even where inference finds nothing.
|
|
6
6
|
- **Only new drift.** The PR head is compared with its base commit, renames included, so existing debt and unrelated files never fail a PR.
|
|
7
7
|
- **Deterministic and explained.** Every finding names the changed import, the established path it breaks, the evidence and a confidence. No LLM in the loop.
|
|
8
8
|
- **Built for CI.** One GitHub Action step, annotations on the offending line, SARIF for code scanning, JSON for everything else. The CLI has no dependencies.
|
|
9
9
|
- **Python, JavaScript/TypeScript, Java, Kotlin and Go.**
|
|
10
10
|
|
|
11
|
+
## Quick start
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
pip install adre-cli
|
|
15
|
+
cd your-project
|
|
16
|
+
adre init # shows the architecture ADRE sees and adds the pull-request check
|
|
17
|
+
git add .github/workflows/architecture.yml && git commit -m "Add ADRE" && git push
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
That's all. Every pull request now gets a check that fails on new architecture drift and one comment explaining each finding and how to fix it.
|
|
21
|
+
|
|
22
|
+
To look around on your own machine:
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
adre ui # opens the web UI in your browser, on this project
|
|
26
|
+
adre review # checks your uncommitted changes
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
On macOS with Homebrew's Python, `pip install` refuses to install into the system Python. Use a virtual environment: `python3 -m venv ~/.adre && ~/.adre/bin/pip install adre-cli`, then add `~/.adre/bin` to your `PATH`.
|
|
30
|
+
|
|
11
31
|
### How it compares
|
|
12
32
|
|
|
13
33
|
| | Rules required | Gates PRs on new drift only | Indirect (chain) violations | Languages |
|
|
@@ -62,11 +82,12 @@ Unsupported languages are counted and skipped. Repository source is never execut
|
|
|
62
82
|
## Install
|
|
63
83
|
|
|
64
84
|
```
|
|
65
|
-
pip install adre-cli
|
|
66
|
-
pip install "adre-cli[web]" # plus the local web UI
|
|
85
|
+
pip install adre-cli
|
|
67
86
|
```
|
|
68
87
|
|
|
69
|
-
|
|
88
|
+
This includes the web UI. The analysis engine itself uses only the Python standard library, which is why the GitHub Action needs no install step.
|
|
89
|
+
|
|
90
|
+
To install an unreleased version from GitHub: `pip install "git+https://github.com/christiangebru/architect-reviewer@main"`.
|
|
70
91
|
|
|
71
92
|
This installs the `adre` command (the package is `adre-cli` because `adre` is taken on PyPI). From a source checkout, `./bin/adre` runs the same CLI without installing anything.
|
|
72
93
|
|
|
@@ -79,28 +100,37 @@ adre analyze ./my-repository
|
|
|
79
100
|
adre analyze ./my-repository --select src/controllers
|
|
80
101
|
```
|
|
81
102
|
|
|
82
|
-
|
|
103
|
+
Set up a repository (prints the architecture, writes `.github/workflows/architecture.yml`; `--baseline` also pins today's architecture):
|
|
83
104
|
|
|
84
105
|
```
|
|
85
|
-
adre
|
|
106
|
+
adre init
|
|
86
107
|
```
|
|
87
108
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
Compare the current tree against a saved baseline:
|
|
109
|
+
Check your uncommitted changes. Without a saved baseline, ADRE learns the architecture from the last commit; with one, it compares against the baseline:
|
|
91
110
|
|
|
92
111
|
```
|
|
93
|
-
adre review
|
|
112
|
+
adre review
|
|
94
113
|
adre review ./my-repository --against .adre/baseline.json
|
|
95
114
|
```
|
|
96
115
|
|
|
97
|
-
|
|
116
|
+
Optionally pin today's architecture, so that drift merged later cannot quietly become the new normal:
|
|
117
|
+
|
|
118
|
+
```
|
|
119
|
+
adre baseline
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
This writes `.adre/baseline.json`. Commit that file on the default branch. A committed baseline is also required outside git.
|
|
123
|
+
|
|
124
|
+
Open the web UI (opens your browser on this project's dashboard; picks a free port if 8000 is taken; binds to 127.0.0.1):
|
|
98
125
|
|
|
99
126
|
```
|
|
100
|
-
adre
|
|
127
|
+
adre ui
|
|
128
|
+
adre ui ./my-repository --port 9000 --no-browser
|
|
101
129
|
```
|
|
102
130
|
|
|
103
|
-
|
|
131
|
+
`adre web` is the same command.
|
|
132
|
+
|
|
133
|
+
The web UI gives the same answers as the CLI: **Review against baseline** runs exactly what `adre review` runs (baseline, declared rules, accepted and stale exceptions), and **Review a branch** runs the same pull-request review as the GitHub Action for the checked-out branch against a base you choose. On either page, **Accept with reason** records an intentional crossing in `.adre/accepted.json` (commit it so CI accepts it too). New repositories get a **Get started** checklist on the dashboard: review your changes, review a branch, add the GitHub check, and optionally pin the architecture with a baseline. The **Rules** page edits `.adre/architecture.json` visually: it starts from the layers ADRE found, lets you reorder, rename and add layers, turn on strict layering and add forbidden dependencies, and previews which files each layer claims and which current dependencies would break the rules before you save.
|
|
104
134
|
|
|
105
135
|
It only answers on localhost. Requests with another `Host` header or that the browser marks as cross-site are refused, and every action that changes something (saving a baseline, cloning or registering a repository, pinning, opening your editor) is a POST carrying a per-process token, so other websites cannot trigger them. Binding to another interface with `--host` prints a warning.
|
|
106
136
|
|
|
@@ -113,13 +143,18 @@ adre pr-check origin/main HEAD
|
|
|
113
143
|
|
|
114
144
|
Statuses:
|
|
115
145
|
|
|
116
|
-
- `PASS` (exit 0) — no new drift
|
|
146
|
+
- `PASS` (exit 0) — no new drift
|
|
117
147
|
- `DRIFT` (exit 2) — new architectural drift in the PR
|
|
118
|
-
- `
|
|
148
|
+
- `INCOMPLETE` (exit 4) — the PR changes a source file that was not analyzed because the project has more source files than the file limit (see below)
|
|
149
|
+
- `BASELINE_REQUIRED` (exit 3) — the `--against` baseline file does not exist, or there is no saved baseline and the base branch could not be analyzed
|
|
119
150
|
- `BASELINE_INVALID` (exit 1) — baseline could not be loaded
|
|
120
151
|
- `ERROR` (exit 1) — git or analysis failure
|
|
121
152
|
|
|
122
|
-
`pr-review`
|
|
153
|
+
**Which findings fail.** By default every finding fails the review. Set a threshold with `--fail-on critical|high|medium|low|none` (on `review`, `pr-review`, `pr-check` and `web`), the `ADRE_FAIL_ON` environment variable, or the action's `fail-on` input. Findings below it are still reported, as warnings (job summary, `::warning` annotations, SARIF level `note`, `warnings` in JSON), but do not fail. Severities: a new cycle is `critical`; layer skips, reversed layer dependencies, repository bypasses and declared-rule violations are `high`; an unexpected (inferred) dependency is `medium`. `--fail-on high` therefore keeps every proven violation blocking and turns inferred findings into warnings; `none` is an advisory mode for the first weeks of adoption.
|
|
154
|
+
|
|
155
|
+
**File limit.** ADRE analyzes at most 5,000 source files by default, in a stable (sorted) order. When a project has more, every output says how many files were left out, and a pull request that changes one of them gets `INCOMPLETE` instead of `PASS`. Raise the limit with `--max-files N` (any command), the `ADRE_MAX_FILES` environment variable, or the action's `max-files` input; `0` means no limit.
|
|
156
|
+
|
|
157
|
+
`pr-review` uses `.adre/baseline.json` from the base commit as the accepted architecture model (layers, directions, established paths) when one is committed, and otherwise learns that model from the base commit itself. It always analyzes the base commit in a throwaway clone to decide what is new. Only dependencies, cycles, and database imports that the PR adds relative to the base tree are reported. As a result:
|
|
123
158
|
|
|
124
159
|
- problems that already exist on the base branch are not blamed on the PR, even if they were merged after the baseline was saved
|
|
125
160
|
- renamed or moved files (detected by `git diff -M`) do not count as new dependencies
|
|
@@ -139,6 +174,7 @@ on:
|
|
|
139
174
|
|
|
140
175
|
permissions:
|
|
141
176
|
contents: read
|
|
177
|
+
pull-requests: write # lets ADRE keep one explanatory comment on the PR
|
|
142
178
|
|
|
143
179
|
jobs:
|
|
144
180
|
drift:
|
|
@@ -147,12 +183,12 @@ jobs:
|
|
|
147
183
|
- uses: actions/checkout@v4
|
|
148
184
|
with:
|
|
149
185
|
fetch-depth: 0 # the base commit and merge base must exist
|
|
150
|
-
- uses: christiangebru/architect-reviewer@v0.
|
|
186
|
+
- uses: christiangebru/architect-reviewer@v0.3.0 # or @v0 for the latest 0.x, or a commit SHA
|
|
151
187
|
with:
|
|
152
188
|
path: . # project directory inside the repository
|
|
153
189
|
```
|
|
154
190
|
|
|
155
|
-
The action compares the checked-out PR tree with the base commit, using `.adre/baseline.json` from the base commit as the accepted architecture, and fails the job on new drift. It writes the check summary to the job summary, adds an inline annotation on each finding (repository-relative paths, so projects in subdirectories work), and sets outputs `status`, `drift-count`, `accepted-count` and `sarif-file`.
|
|
191
|
+
The action compares the checked-out PR tree with the base commit, using `.adre/baseline.json` from the base commit as the accepted architecture if one is committed (otherwise the architecture learned from the base commit), and fails the job on new drift. It writes the check summary to the job summary, adds an inline annotation on each finding (repository-relative paths, so projects in subdirectories work), and sets outputs `status`, `drift-count`, `warning-count`, `accepted-count` and `sarif-file`.
|
|
156
192
|
|
|
157
193
|
| Input | Default | |
|
|
158
194
|
|---|---|---|
|
|
@@ -161,13 +197,18 @@ The action compares the checked-out PR tree with the base commit, using `.adre/b
|
|
|
161
197
|
| `head` | `github.sha` | Checked-out commit |
|
|
162
198
|
| `baseline` | base commit's `.adre/baseline.json` | Baseline file |
|
|
163
199
|
| `sarif-file` | (none) | Also write SARIF 2.1.0 here |
|
|
200
|
+
| `max-files` | `5000` | Most source files to analyze; `0` = no limit |
|
|
201
|
+
| `comment` | `true` | Keep one ADRE comment on the PR, updated on every push; `false` to turn off |
|
|
202
|
+
| `fail-on` | `low` | Lowest severity that fails: `critical`, `high`, `medium`, `low`, or `none` (report only) |
|
|
164
203
|
| `python-version` | `3.12` | Python used to run ADRE |
|
|
165
204
|
| `setup-python` | `true` | `false` uses the runner's Python |
|
|
166
205
|
|
|
206
|
+
**PR comment.** With `pull-requests: write`, the action keeps a single comment on the pull request and edits it on every push instead of adding new ones. Each finding is explained in plain language (what happened, why it matters, how to fix it) with a ready-to-paste `.adre/accepted.json` entry for intentional crossings; warnings, accepted and stale exceptions are folded away. A clean PR gets no comment; a PR whose findings were fixed sees the comment flip to passed. Without the permission, or on pull requests from forks (read-only token), the comment is skipped with a warning and the check result is unchanged. Outside the action: `adre pr-review … --comment` (uses `GITHUB_TOKEN`) or `--comment-file comment.md` to get the markdown.
|
|
207
|
+
|
|
167
208
|
To show findings in GitHub code scanning, write SARIF and upload it even when the check fails (needs `security-events: write`; private repositories need GitHub Advanced Security):
|
|
168
209
|
|
|
169
210
|
```yaml
|
|
170
|
-
- uses: christiangebru/architect-reviewer@v0.
|
|
211
|
+
- uses: christiangebru/architect-reviewer@v0.3.0
|
|
171
212
|
id: adre
|
|
172
213
|
with:
|
|
173
214
|
sarif-file: adre.sarif
|
|
@@ -178,10 +219,10 @@ To show findings in GitHub code scanning, write SARIF and upload it even when th
|
|
|
178
219
|
category: adre
|
|
179
220
|
```
|
|
180
221
|
|
|
181
|
-
|
|
222
|
+
No baseline is needed: without one, the action learns the architecture from the base branch of each pull request. To pin today's architecture instead, commit a baseline on the default branch:
|
|
182
223
|
|
|
183
224
|
```
|
|
184
|
-
adre baseline
|
|
225
|
+
adre baseline
|
|
185
226
|
git add .adre/baseline.json
|
|
186
227
|
git commit -m "Save architecture baseline"
|
|
187
228
|
```
|
|
@@ -303,7 +344,7 @@ Unchanged files are reused from `.adre/parse-cache.json` by content hash. Change
|
|
|
303
344
|
The CLI and engine use only the Python standard library (3.9+). All code lives in the `adre` package; FastAPI and Uvicorn are only needed for the optional web UI (`adre/web.py`, extra `web`).
|
|
304
345
|
|
|
305
346
|
```
|
|
306
|
-
pip install -e
|
|
347
|
+
pip install -e . # same as: pip install -r requirements.txt
|
|
307
348
|
python3 -m unittest discover
|
|
308
349
|
```
|
|
309
350
|
|
|
@@ -121,6 +121,9 @@ def analyze_project_architecture(
|
|
|
121
121
|
)
|
|
122
122
|
scope["excluded_directories"] = sorted(SKIP_DIRS)
|
|
123
123
|
scope["incremental"] = incremental
|
|
124
|
+
scope["max_files"] = index_meta.get("max_files")
|
|
125
|
+
scope["total_source_files"] = index_meta.get("total_files", scope.get("indexed_file_count", 0))
|
|
126
|
+
scope["skipped_files"] = index_meta.get("skipped_files", 0)
|
|
124
127
|
|
|
125
128
|
analyzed_files = scope["analyzed_files"]
|
|
126
129
|
analyzed_graph = {path: dependency_graph[path] for path in analyzed_files if path in dependency_graph}
|