adre-cli 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 (67) hide show
  1. adre_cli-0.1.0/LICENSE +202 -0
  2. adre_cli-0.1.0/PKG-INFO +343 -0
  3. adre_cli-0.1.0/README.md +322 -0
  4. adre_cli-0.1.0/adre/__init__.py +5 -0
  5. adre_cli-0.1.0/adre/analyzers/__init__.py +1 -0
  6. adre_cli-0.1.0/adre/analyzers/architecture.py +253 -0
  7. adre_cli-0.1.0/adre/analyzers/findings.py +457 -0
  8. adre_cli-0.1.0/adre/analyzers/inference.py +163 -0
  9. adre_cli-0.1.0/adre/cli.py +923 -0
  10. adre_cli-0.1.0/adre/core/__init__.py +1 -0
  11. adre_cli-0.1.0/adre/core/accepted.py +225 -0
  12. adre_cli-0.1.0/adre/core/adaptive.py +221 -0
  13. adre_cli-0.1.0/adre/core/baseline.py +1165 -0
  14. adre_cli-0.1.0/adre/core/config.py +60 -0
  15. adre_cli-0.1.0/adre/core/decision_engine.py +361 -0
  16. adre_cli-0.1.0/adre/core/declared.py +313 -0
  17. adre_cli-0.1.0/adre/core/evolution_intelligence.py +390 -0
  18. adre_cli-0.1.0/adre/core/explainer.py +413 -0
  19. adre_cli-0.1.0/adre/core/git_intelligence.py +392 -0
  20. adre_cli-0.1.0/adre/core/github_check.py +212 -0
  21. adre_cli-0.1.0/adre/core/incremental.py +288 -0
  22. adre_cli-0.1.0/adre/core/layers.py +306 -0
  23. adre_cli-0.1.0/adre/core/pr_intelligence.py +261 -0
  24. adre_cli-0.1.0/adre/core/pr_review.py +454 -0
  25. adre_cli-0.1.0/adre/core/prioritization.py +196 -0
  26. adre_cli-0.1.0/adre/core/project.py +41 -0
  27. adre_cli-0.1.0/adre/core/refactor_intelligence.py +201 -0
  28. adre_cli-0.1.0/adre/core/repositories.py +312 -0
  29. adre_cli-0.1.0/adre/core/review.py +96 -0
  30. adre_cli-0.1.0/adre/core/rules_shared.py +75 -0
  31. adre_cli-0.1.0/adre/core/sarif.py +141 -0
  32. adre_cli-0.1.0/adre/core/scope.py +141 -0
  33. adre_cli-0.1.0/adre/core/snapshots.py +242 -0
  34. adre_cli-0.1.0/adre/core/stability_intelligence.py +361 -0
  35. adre_cli-0.1.0/adre/graph/__init__.py +0 -0
  36. adre_cli-0.1.0/adre/graph/dependencies.py +379 -0
  37. adre_cli-0.1.0/adre/parsers/__init__.py +87 -0
  38. adre_cli-0.1.0/adre/parsers/go.py +140 -0
  39. adre_cli-0.1.0/adre/parsers/javascript.py +364 -0
  40. adre_cli-0.1.0/adre/parsers/jvm.py +127 -0
  41. adre_cli-0.1.0/adre/parsers/python.py +153 -0
  42. adre_cli-0.1.0/adre/reports/__init__.py +1 -0
  43. adre_cli-0.1.0/adre/reports/architecture.py +349 -0
  44. adre_cli-0.1.0/adre/rules.py +12 -0
  45. adre_cli-0.1.0/adre/web.py +3731 -0
  46. adre_cli-0.1.0/adre_cli.egg-info/PKG-INFO +343 -0
  47. adre_cli-0.1.0/adre_cli.egg-info/SOURCES.txt +65 -0
  48. adre_cli-0.1.0/adre_cli.egg-info/dependency_links.txt +1 -0
  49. adre_cli-0.1.0/adre_cli.egg-info/entry_points.txt +2 -0
  50. adre_cli-0.1.0/adre_cli.egg-info/requires.txt +4 -0
  51. adre_cli-0.1.0/adre_cli.egg-info/top_level.txt +1 -0
  52. adre_cli-0.1.0/pyproject.toml +36 -0
  53. adre_cli-0.1.0/setup.cfg +4 -0
  54. adre_cli-0.1.0/tests/test_accepted.py +209 -0
  55. adre_cli-0.1.0/tests/test_architecture.py +180 -0
  56. adre_cli-0.1.0/tests/test_baseline.py +369 -0
  57. adre_cli-0.1.0/tests/test_ci_outputs.py +167 -0
  58. adre_cli-0.1.0/tests/test_cycles.py +219 -0
  59. adre_cli-0.1.0/tests/test_gaps.py +315 -0
  60. adre_cli-0.1.0/tests/test_incremental.py +247 -0
  61. adre_cli-0.1.0/tests/test_packaging.py +64 -0
  62. adre_cli-0.1.0/tests/test_pr_review.py +481 -0
  63. adre_cli-0.1.0/tests/test_realistic.py +304 -0
  64. adre_cli-0.1.0/tests/test_recall.py +587 -0
  65. adre_cli-0.1.0/tests/test_relationships.py +404 -0
  66. adre_cli-0.1.0/tests/test_resolution.py +310 -0
  67. adre_cli-0.1.0/tests/test_web.py +279 -0
adre_cli-0.1.0/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "{}"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright {yyyy} {name of copyright owner}
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
202
+
@@ -0,0 +1,343 @@
1
+ Metadata-Version: 2.4
2
+ Name: adre-cli
3
+ Version: 0.1.0
4
+ Summary: Architecture Drift Review Engine: learn a repository's architecture and flag pull requests that drift from it.
5
+ License: Apache-2.0
6
+ Project-URL: Homepage, https://github.com/christiangebru/architect-reviewer
7
+ Project-URL: Issues, https://github.com/christiangebru/architect-reviewer/issues
8
+ Project-URL: Changelog, https://github.com/christiangebru/architect-reviewer/blob/main/CHANGELOG.md
9
+ Classifier: License :: OSI Approved :: Apache Software License
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Environment :: Console
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Topic :: Software Development :: Quality Assurance
14
+ Requires-Python: >=3.9
15
+ Description-Content-Type: text/markdown
16
+ License-File: LICENSE
17
+ Provides-Extra: web
18
+ Requires-Dist: fastapi>=0.110; extra == "web"
19
+ Requires-Dist: uvicorn>=0.27; extra == "web"
20
+ Dynamic: license-file
21
+
22
+ # ADRE — Architecture Drift Review Engine
23
+
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
+
26
+ - **No rules to write.** Layers and dependency directions are inferred from the code and saved as a reviewable baseline. If you do want rules, declare them in `.adre/architecture.json`, and they are enforced even where inference finds nothing.
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
+ - **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
+ - **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
+ - **Python, JavaScript/TypeScript, Java, Kotlin and Go.**
31
+
32
+ ### How it compares
33
+
34
+ | | Rules required | Gates PRs on new drift only | Indirect (chain) violations | Languages |
35
+ |---|---|---|---|---|
36
+ | **ADRE** | No (optional declared rules) | Yes, against the base commit | Yes, for declared layers | Python, JS/TS, Java, Kotlin, Go |
37
+ | SonarQube architecture (2025+) | Yes, intended architecture | Through quality gates | Not documented | Java, C#, JS/TS, Python |
38
+ | import-linter | Yes, contracts | No (whole-repo check, ignore list) | Yes | Python |
39
+ | Tach | Yes, module config | No (whole-repo check) | Not documented | Python |
40
+ | dependency-cruiser | Yes, rules | With a known-violations baseline | Via rules | JS/TS |
41
+ | ArchUnit | Yes, tests in code | With frozen violation stores | Via rules | Java/JVM |
42
+
43
+ ADRE is the option for teams that want guardrails on day one without writing an architecture spec first, and that review many AI-assisted pull requests. See [ROADMAP.md](ROADMAP.md) for what is next.
44
+
45
+ ---
46
+
47
+ ## Core workflow
48
+
49
+ ```
50
+ Repository
51
+ → parse and graph
52
+ → ArchitectureBaseline
53
+ → save accepted baseline
54
+ → review later changes / pull requests
55
+ → evidence-backed drift
56
+ ```
57
+
58
+ If a repository establishes:
59
+
60
+ `Controller → Service → Repository → Database`
61
+
62
+ and a change introduces:
63
+
64
+ `Controller → Database`
65
+
66
+ the reviewer reports architectural drift with the changed edge, the established path, evidence, and confidence.
67
+
68
+ ---
69
+
70
+ ## Supported languages
71
+
72
+ - Python (AST)
73
+ - JavaScript / TypeScript (import analysis, including multi-line imports, `tsconfig.json` / `jsconfig.json` `baseUrl` and `paths` aliases, and ESM `./x.js` imports of `x.ts` sources)
74
+ - Java and Kotlin (`package`/`import` analysis: fully qualified, static and wildcard imports, Kotlin aliases and top-level functions; JPA, Hibernate, JDBC, Spring Data and similar imports count as database access)
75
+ - Go (import paths inside the module from the nearest `go.mod`; an import depends on every non-test file of that package; `database/sql`, GORM, pgx, sqlx and similar count as database access)
76
+
77
+ Python `from package import module` resolves to the submodule file, including namespace packages without `__init__.py`.
78
+
79
+ Unsupported languages are counted and skipped. Repository source is never executed.
80
+
81
+ ---
82
+
83
+ ## Install
84
+
85
+ ```
86
+ pip install adre-cli # CLI only, no dependencies
87
+ pip install "adre-cli[web]" # plus the local web UI
88
+ ```
89
+
90
+ Until the first PyPI release is published, install from GitHub instead: `pip install "git+https://github.com/christiangebru/architect-reviewer@v0.1.0"`.
91
+
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.
93
+
94
+ ## CLI
95
+
96
+ Analyze current code (does not save a baseline):
97
+
98
+ ```
99
+ adre analyze ./my-repository
100
+ adre analyze ./my-repository --select src/controllers
101
+ ```
102
+
103
+ Save the accepted architecture:
104
+
105
+ ```
106
+ adre baseline ./my-repository
107
+ ```
108
+
109
+ This writes `.adre/baseline.json`. Commit that file on the default branch.
110
+
111
+ Compare the current tree against a saved baseline:
112
+
113
+ ```
114
+ adre review ./my-repository
115
+ adre review ./my-repository --against .adre/baseline.json
116
+ ```
117
+
118
+ Start the local web UI (needs the `web` extra; binds to 127.0.0.1 by default):
119
+
120
+ ```
121
+ adre web --port 8000
122
+ ```
123
+
124
+ 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.
125
+
126
+ 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
+
128
+ Review a pull request (current checkout is HEAD):
129
+
130
+ ```
131
+ adre pr-review <base-sha-or-branch> HEAD
132
+ adre pr-check origin/main HEAD
133
+ ```
134
+
135
+ Statuses:
136
+
137
+ - `PASS` (exit 0) — no new drift versus the accepted baseline
138
+ - `DRIFT` (exit 2) — new architectural drift in the PR
139
+ - `BASELINE_REQUIRED` (exit 3) — no `.adre/baseline.json` on the base ref
140
+ - `BASELINE_INVALID` (exit 1) — baseline could not be loaded
141
+ - `ERROR` (exit 1) — git or analysis failure
142
+
143
+ `pr-review` uses the baseline for the accepted architecture model (layers, directions, established paths), and 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
+
145
+ - 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
+ - renamed or moved files (detected by `git diff -M`) do not count as new dependencies
147
+
148
+ If the base tree cannot be analyzed, the review falls back to comparing against the saved baseline's own edges and says so in the output.
149
+
150
+ ---
151
+
152
+ ## GitHub Actions
153
+
154
+ ADRE ships as a GitHub Action. Add it to any repository:
155
+
156
+ ```yaml
157
+ name: Architecture
158
+ on:
159
+ pull_request:
160
+
161
+ permissions:
162
+ contents: read
163
+
164
+ jobs:
165
+ drift:
166
+ runs-on: ubuntu-latest
167
+ steps:
168
+ - uses: actions/checkout@v4
169
+ with:
170
+ fetch-depth: 0 # the base commit and merge base must exist
171
+ - uses: christiangebru/architect-reviewer@v0.1.0 # or @v0 for the latest 0.x, or a commit SHA
172
+ with:
173
+ path: . # project directory inside the repository
174
+ ```
175
+
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`.
177
+
178
+ | Input | Default | |
179
+ |---|---|---|
180
+ | `path` | `.` | Project directory to analyze |
181
+ | `base` | PR base SHA | Base commit or ref |
182
+ | `head` | `github.sha` | Checked-out commit |
183
+ | `baseline` | base commit's `.adre/baseline.json` | Baseline file |
184
+ | `sarif-file` | (none) | Also write SARIF 2.1.0 here |
185
+ | `python-version` | `3.12` | Python used to run ADRE |
186
+ | `setup-python` | `true` | `false` uses the runner's Python |
187
+
188
+ 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
+
190
+ ```yaml
191
+ - uses: christiangebru/architect-reviewer@v0.1.0
192
+ id: adre
193
+ with:
194
+ sarif-file: adre.sarif
195
+ - uses: github/codeql-action/upload-sarif@v3
196
+ if: always() && steps.adre.outputs.sarif-file != ''
197
+ with:
198
+ sarif_file: adre.sarif
199
+ category: adre
200
+ ```
201
+
202
+ Commit a baseline on the default branch before relying on CI:
203
+
204
+ ```
205
+ adre baseline .
206
+ git add .adre/baseline.json
207
+ git commit -m "Save architecture baseline"
208
+ ```
209
+
210
+ `.adre/baseline.json` and `.adre/accepted.json` are meant to be committed. `.adre/parse-cache.json` stays local and is gitignored.
211
+
212
+ `pr-review` analyzes the current checkout. In CI that is the pull request merge commit (`github.sha`). Locally, check out the PR head first.
213
+
214
+ Machine-readable output for other CI systems:
215
+
216
+ ```
217
+ adre pr-review origin/main HEAD --format json
218
+ adre pr-review origin/main HEAD --sarif adre.sarif
219
+ ```
220
+
221
+ ---
222
+
223
+ ## What counts as drift
224
+
225
+ Drift is a **new** relationship that contradicts the accepted ArchitectureBaseline.
226
+
227
+ Typical drift:
228
+
229
+ - a presentation module skipping an established service/repository path
230
+ - a module reversing an established dependency direction
231
+ - a new circular dependency: a file joining a group of files that import each other at load time, or two such groups merging
232
+ - direct database access after a repository/persistence boundary was established
233
+
234
+ Not drift:
235
+
236
+ - problems that already exist in the saved baseline
237
+ - documentation, config, or test-only changes
238
+ - imports of standard library or third-party packages
239
+ - utility/shared imports that are not established layer boundaries
240
+ - a repository that never demonstrated a layered architecture in the first place
241
+
242
+ ---
243
+
244
+ ## Accepting an intentional crossing
245
+
246
+ Record intentional exceptions in `.adre/accepted.json` instead of re-saving the whole baseline:
247
+
248
+ ```json
249
+ {
250
+ "accepted": [
251
+ {
252
+ "from": "controllers/admin_controller.py",
253
+ "to": "repositories/*",
254
+ "type": "layer_skip",
255
+ "reason": "Admin bulk export reads repositories directly (ARCH-12)."
256
+ }
257
+ ]
258
+ }
259
+ ```
260
+
261
+ - `from` and `to` are glob patterns over project-relative paths (`*` also matches `/`). `to` defaults to `*`.
262
+ - For `repository_bypass`, `to` matches the database module, e.g. `sqlite3`. For `cycle`, `from` must match every file that joined the cycle group and `to` matches any file in it.
263
+ - `type` is optional: one of `layer_skip`, `layer_violation`, `unexpected_dependency`, `repository_bypass`, `cycle`, or a list.
264
+ - `reason` is required.
265
+ - Entries that no longer match any dependency, database import or cycle group are listed as **stale** in `review` and in the PR check. Add `"fail_on_stale": true` next to `"accepted"` to make stale entries fail the check, so old exceptions cannot quietly hide a future regression.
266
+
267
+ `review` and `pr-review` read the file from the checked-out tree, so a pull request can accept its own crossing. That change is part of the PR diff, the check summary lists every accepted finding with its reason, and it calls out PRs that edit `accepted.json`. Protect `.adre/` with CODEOWNERS if exceptions need a specific reviewer. An invalid file fails the check rather than being ignored.
268
+
269
+ ## Declaring the intended architecture
270
+
271
+ Inference needs repeated structure to work. To state the architecture you want, add `.adre/architecture.json`:
272
+
273
+ ```json
274
+ {
275
+ "layers": [
276
+ {"name": "presentation", "paths": ["src/controllers/*", "src/routes/*"]},
277
+ {"name": "application", "paths": ["src/services/*"]},
278
+ {"name": "data", "paths": ["src/repositories/*"]}
279
+ ],
280
+ "strict": false,
281
+ "forbidden": [
282
+ {"from": "src/services/*", "to": "src/vendor_sdk/*", "reason": "Call vendors through the gateway."}
283
+ ]
284
+ }
285
+ ```
286
+
287
+ - Layers are listed top to bottom. A layer may import layers below it, never one above it, **directly or through a chain of other modules** (`indirect_violation`). With `"strict": true` a layer may only import the next layer down.
288
+ - `forbidden` rules ban specific dependencies. Paths are glob patterns over project-relative paths; a file belongs to the first layer that matches it.
289
+ - Declared rules work with or without a saved baseline. Without one, `review` checks every current dependency and `pr-review` checks what the PR adds.
290
+ - `pr-review` reads the rules from the **base commit**, so a pull request cannot loosen the rules it is checked against; a PR that edits them gets a note that the change applies after merge. Exceptions for a single PR still go in `accepted.json`.
291
+ - Declared findings replace inferred findings for the same import.
292
+
293
+ ---
294
+
295
+ ## Incremental analysis
296
+
297
+ Unchanged files are reused from `.adre/parse-cache.json` by content hash. Changed and added files are reparsed. The accepted baseline and the parse cache are separate files. `analyze` never overwrites the accepted baseline.
298
+
299
+ ---
300
+
301
+ ## Limitations
302
+
303
+ - Architecture is inferred from observed structure, not from preferred styles such as MVC or DDD.
304
+ - Framework apps that use an ORM from routes/views are not assumed to have a repository boundary.
305
+ - Generic folder names such as `core`, `lib`, `app`, and `src` are not treated as architecture layers by themselves.
306
+ - Test, example, vendor, generated, migration, and docs directories are skipped so they do not distort the baseline.
307
+ - Layer roles come from folder and file names. An ambiguous folder (`queries`, `commands`, `models`, `schemas`, `entities`, `handlers`, `interfaces`) inside a layer folder with a different role takes that outer role: `app/db/queries/` is data, `app/api/schemas/` is presentation. On its own, `queries/` is still application.
308
+ - Database access means importing a driver or ORM package. Relative imports and imports that resolve to a project file (a local `pg.py`) are not database access.
309
+ - GitHub annotations include a line number only when the parser recorded one. Missing lines are not invented.
310
+ - Incremental reuse is parse-level; the graph and findings are still rebuilt from the mixed index.
311
+ - C#, Ruby, PHP, Rust and Swift are not parsed yet. Java same-package references need no import, so they are not visible. Go `replace` directives are not followed.
312
+ - Indirect violations are checked for declared layers only, and are skipped when a single comparison adds more than 500 new dependencies.
313
+ - Only relative `extends` in `tsconfig.json` are followed; aliases defined in an npm-package base config are not resolved. Workspace package names (`@org/pkg` resolved through `node_modules` symlinks) are not resolved either.
314
+ - Changing the analyzer version changes which edges are detected. `pr-review` analyzes both trees with the same version, so this is safe there; re-save the baseline before using `review` against an older baseline.
315
+ - There is no LLM layer. Findings are deterministic and evidence-backed.
316
+ - Cycles are detected on the import-time graph only. Imports inside `if TYPE_CHECKING:`, TypeScript `import type` / all-`type` named imports, function-local imports, and dynamic `import()` still count as dependencies for layer drift, but cannot form a cycle.
317
+ - Cycles are tracked as groups of files that import each other (strongly connected components). A new import between files already in the same group is not new drift; a file joining a group is.
318
+ - Intentional load-time cycles, such as the Flask pattern of importing routes at the bottom of a package `__init__.py`, are still reported. If they already exist in the baseline or on the base branch they are not new PR drift.
319
+
320
+ ---
321
+
322
+ ## Development
323
+
324
+ 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
+
326
+ ```
327
+ pip install -e ".[web]" # same as: pip install -r requirements.txt
328
+ python3 -m unittest discover
329
+ ```
330
+
331
+ Web UI tests are skipped when FastAPI is not installed. CI runs the suite on Python 3.9 and 3.12, and this repository checks its own pull requests with its own action against its committed baseline.
332
+
333
+ ---
334
+
335
+ ## Status
336
+
337
+ Active product. The architecture baseline and PR review path are the source of truth for drift.
338
+
339
+ ---
340
+
341
+ ## License
342
+
343
+ Apache License 2.0. See [LICENSE](LICENSE).