adra 0.4.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 (73) hide show
  1. adra-0.4.0/LICENSE +201 -0
  2. adra-0.4.0/PKG-INFO +217 -0
  3. adra-0.4.0/README.md +174 -0
  4. adra-0.4.0/adra/__init__.py +36 -0
  5. adra-0.4.0/adra/clients/synthetic/northwind/README.md +44 -0
  6. adra-0.4.0/adra/clients/synthetic/northwind/adr/ADR-0001-deterministic-grounding.md +21 -0
  7. adra-0.4.0/adra/clients/synthetic/northwind/adr/ADR-0002-no-stale-base-merges.md +20 -0
  8. adra-0.4.0/adra/clients/synthetic/northwind/adr/ADR-0003-bundle-resources-stay-yml.md +19 -0
  9. adra-0.4.0/adra/clients/synthetic/northwind/adr/ADR-0004-test-discovery.md +20 -0
  10. adra-0.4.0/adra/clients/synthetic/northwind/adr/ADR-0005-experiments-on-warehouse.md +29 -0
  11. adra-0.4.0/adra/clients/synthetic/northwind/adr/ADR-0006-docs-from-provenance.md +19 -0
  12. adra-0.4.0/adra/clients/synthetic/northwind/adr/ADR-0007-decision-support-framing.md +19 -0
  13. adra-0.4.0/adra/clients/synthetic/northwind/adr/ADR-0008-minimum-functional.md +19 -0
  14. adra-0.4.0/adra/clients/synthetic/northwind/cases/CASE-2024-031-stale-base-destructive-merge.md +19 -0
  15. adra-0.4.0/adra/clients/synthetic/northwind/cases/CASE-2024-047-coverage-no-data.md +19 -0
  16. adra-0.4.0/adra/clients/synthetic/northwind/cases/CASE-2024-052-premature-no-access.md +16 -0
  17. adra-0.4.0/adra/clients/synthetic/northwind/cases/CASE-2024-058-anomaly-verified-live.md +17 -0
  18. adra-0.4.0/adra/clients/synthetic/northwind/cases/CASE-2024-061-route-blast-radius.md +18 -0
  19. adra-0.4.0/adra/clients/synthetic/northwind/ci-standards.md +41 -0
  20. adra-0.4.0/adra/clients/synthetic/northwind/conventions.md +46 -0
  21. adra-0.4.0/adra/clients/synthetic/northwind/glossary.md +19 -0
  22. adra-0.4.0/adra/config.py +164 -0
  23. adra-0.4.0/adra/connectors/__init__.py +74 -0
  24. adra-0.4.0/adra/connectors/azure.py +87 -0
  25. adra-0.4.0/adra/connectors/azure_devops.py +210 -0
  26. adra-0.4.0/adra/connectors/base.py +94 -0
  27. adra-0.4.0/adra/connectors/databricks.py +118 -0
  28. adra-0.4.0/adra/connectors/emulator.py +117 -0
  29. adra-0.4.0/adra/connectors/github.py +110 -0
  30. adra-0.4.0/adra/critic.py +119 -0
  31. adra-0.4.0/adra/judge.py +147 -0
  32. adra-0.4.0/adra/llm.py +180 -0
  33. adra-0.4.0/adra/nodes.py +22 -0
  34. adra-0.4.0/adra/orchestrator.py +83 -0
  35. adra-0.4.0/adra/prompts/code_review.md +33 -0
  36. adra-0.4.0/adra/prompts/critic.md +21 -0
  37. adra-0.4.0/adra/prompts/decide.md +21 -0
  38. adra-0.4.0/adra/prompts/document.md +23 -0
  39. adra-0.4.0/adra/prompts/experiment.md +21 -0
  40. adra-0.4.0/adra/prompts/improve.md +19 -0
  41. adra-0.4.0/adra/prompts/judge.md +15 -0
  42. adra-0.4.0/adra/prompts/pr_eval.md +29 -0
  43. adra-0.4.0/adra/provenance.py +74 -0
  44. adra-0.4.0/adra/rubric.py +182 -0
  45. adra-0.4.0/adra/skills/__init__.py +26 -0
  46. adra-0.4.0/adra/skills/base.py +56 -0
  47. adra-0.4.0/adra/skills/code_review.py +66 -0
  48. adra-0.4.0/adra/skills/decide.py +58 -0
  49. adra-0.4.0/adra/skills/document.py +86 -0
  50. adra-0.4.0/adra/skills/experiment.py +58 -0
  51. adra-0.4.0/adra/skills/improve.py +48 -0
  52. adra-0.4.0/adra/skills/pr_eval.py +85 -0
  53. adra-0.4.0/adra/state.py +178 -0
  54. adra-0.4.0/adra/tools/__init__.py +19 -0
  55. adra-0.4.0/adra/tools/bundle_tools.py +52 -0
  56. adra-0.4.0/adra/tools/ci_tools.py +76 -0
  57. adra-0.4.0/adra/tools/discovery_tools.py +45 -0
  58. adra-0.4.0/adra/tools/git_tools.py +89 -0
  59. adra-0.4.0/adra/tools/lang_tools.py +65 -0
  60. adra-0.4.0/adra/tools/sql_tools.py +73 -0
  61. adra-0.4.0/adra/utils.py +86 -0
  62. adra-0.4.0/adra.egg-info/PKG-INFO +217 -0
  63. adra-0.4.0/adra.egg-info/SOURCES.txt +71 -0
  64. adra-0.4.0/adra.egg-info/dependency_links.txt +1 -0
  65. adra-0.4.0/adra.egg-info/entry_points.txt +2 -0
  66. adra-0.4.0/adra.egg-info/requires.txt +32 -0
  67. adra-0.4.0/adra.egg-info/top_level.txt +2 -0
  68. adra-0.4.0/cli/__init__.py +1 -0
  69. adra-0.4.0/cli/__main__.py +147 -0
  70. adra-0.4.0/pyproject.toml +64 -0
  71. adra-0.4.0/setup.cfg +4 -0
  72. adra-0.4.0/tests/test_adversarial_loop.py +171 -0
  73. adra-0.4.0/tests/test_connectors_platform.py +235 -0
adra-0.4.0/LICENSE ADDED
@@ -0,0 +1,201 @@
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 Derivative
95
+ 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 2026 Felipe Santibáñez-Leal
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.
adra-0.4.0/PKG-INFO ADDED
@@ -0,0 +1,217 @@
1
+ Metadata-Version: 2.4
2
+ Name: adra
3
+ Version: 0.4.0
4
+ Summary: ADRA — Adversarial Dev Review Agent: a deterministic-first, adversarial-validation engine for the software lifecycle (PR review, validation/refutation experiments, auto-docs, human escalation).
5
+ Author: Felipe Santibáñez-Leal
6
+ License: Apache-2.0
7
+ Keywords: llm,agent,code-review,adversarial-validation,llm-as-judge,devops,provenance
8
+ Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: License :: OSI Approved :: Apache Software License
11
+ Classifier: Programming Language :: Python :: 3.11
12
+ Classifier: Programming Language :: Python :: 3.12
13
+ Classifier: Topic :: Software Development :: Quality Assurance
14
+ Requires-Python: >=3.11
15
+ Description-Content-Type: text/markdown
16
+ License-File: LICENSE
17
+ Provides-Extra: llm
18
+ Requires-Dist: pydantic-ai-slim[anthropic,google,groq,openai]<2,>=1; extra == "llm"
19
+ Provides-Extra: github
20
+ Requires-Dist: httpx>=0.27; extra == "github"
21
+ Provides-Extra: azuredevops
22
+ Requires-Dist: httpx>=0.27; extra == "azuredevops"
23
+ Provides-Extra: databricks
24
+ Requires-Dist: databricks-sdk>=0.30; extra == "databricks"
25
+ Provides-Extra: azure
26
+ Requires-Dist: azure-identity>=1.17; extra == "azure"
27
+ Requires-Dist: azure-monitor-query>=1.3; extra == "azure"
28
+ Provides-Extra: all
29
+ Requires-Dist: pydantic-ai-slim[anthropic,google,groq,openai]<2,>=1; extra == "all"
30
+ Requires-Dist: httpx>=0.27; extra == "all"
31
+ Requires-Dist: databricks-sdk>=0.30; extra == "all"
32
+ Requires-Dist: azure-identity>=1.17; extra == "all"
33
+ Requires-Dist: azure-monitor-query>=1.3; extra == "all"
34
+ Provides-Extra: dev
35
+ Requires-Dist: pytest>=8.0; extra == "dev"
36
+ Requires-Dist: ruff>=0.6; extra == "dev"
37
+ Requires-Dist: httpx>=0.27; extra == "dev"
38
+ Requires-Dist: pydantic-ai-slim[anthropic]<2,>=1; extra == "dev"
39
+ Requires-Dist: databricks-sdk>=0.30; extra == "dev"
40
+ Requires-Dist: azure-identity>=1.17; extra == "dev"
41
+ Requires-Dist: azure-monitor-query>=1.3; extra == "dev"
42
+ Dynamic: license-file
43
+
44
+ # ADRA — Adversarial Dev Review Agent
45
+
46
+ > A **client-agnostic, deterministic-first, adversarial-validation engine** that supports
47
+ > the software lifecycle: it reviews PRs, designs and runs validation/refutation
48
+ > experiments, writes documentation back, and **escalates to a human** exactly where a
49
+ > senior engineer would. Governed by **LLM-as-Judge + a blocking adversarial critic**,
50
+ > grounded by **deterministic tools**, with **immutable provenance**. Runs **offline with
51
+ > no API key**.
52
+
53
+ `pip install adra` · Python ≥ 3.11 · Apache-2.0 · status: `v0.04.000`
54
+
55
+ ---
56
+
57
+ ## What's different
58
+
59
+ The AI-code-review market splits in two, and both miss the same spot:
60
+
61
+ - **Reviewers** (CodeRabbit, Greptile, Qodo, Korbit, Sourcery, Bito) feed linters into an
62
+ LLM, but the **model's prose is the verdict** — hallucinated and "consistently-stated-
63
+ but-false" findings leak through; the deterministic signals are inputs, never the gate.
64
+ - **Autonomous coders** (Devin, OpenHands, SWE-agent, Sweep) *write* code and treat
65
+ "tests pass" as success rather than adversarially trying to prove the change **wrong**.
66
+
67
+ ADRA occupies the gap: a **deterministic spine** (git / CI / static analysis / SQL probes)
68
+ that *grounds* a **blocking adversarial critic** whose job is to **refute**, not bless, each
69
+ artifact — every finding carrying its evidence, with disciplined **human escalation** when
70
+ nothing deterministic backs the verdict. Existing tools generate opinions; ADRA generates
71
+ proofs and refutations, and escalates when it can't.
72
+
73
+ ## The six capabilities
74
+
75
+ | Skill | What it does |
76
+ |---|---|
77
+ | `code_review` | Review a diff: language/leak scan + test-discoverability + exact CI command + semantic findings |
78
+ | `pr_eval` | Evaluate a PR: merge-base health → `bundle validate` → conformance → verdict + PR body |
79
+ | `experiment` | Hypothesis-driven validation experiment: SQL-warehouse probes + synthesis |
80
+ | `improve` | Minimum-functional improvement proposal (prune filler, smallest safe diff) |
81
+ | `document` | Turn a run record into a PR page / experiment page / methodology-history row |
82
+ | `decide` | Route analysis: candidate routes + trade-offs + recommendation — **human-owned** |
83
+
84
+ Each skill is the same loop, differing only by its domain prompt and deterministic tools.
85
+
86
+ ## Why deterministic-first
87
+
88
+ Tools (`git`, the exact CI command, `bundle validate`, language scan, SQL probe) run
89
+ **first** and become both the grounding the model may not contradict and the evidence in
90
+ the provenance log. Because the deterministic floor carries the verdict, the whole loop
91
+ runs — and the test suite passes — **offline with no API key**. Connecting a real provider
92
+ adds the semantic layer on top.
93
+
94
+ ## Architecture
95
+
96
+ ```
97
+ intake ─▶ plan ─▶ ground (deterministic tools) ─▶ generate ─▶ CRITIC ─┐
98
+ ▲ revise ◀──────┘
99
+ └── accepted / escalate ─▶ artifacts + run record
100
+ ```
101
+
102
+ - `adra/state.py` — the typed **domain model** (`Severity`, `Finding`, `ToolResult`,
103
+ `CriticVerdict`, `RunState`). One contract end to end.
104
+ - `adra/rubric.py` — the shared adversarial **rubric** (criteria as typed data); drives both
105
+ the deterministic critic and the critic prompt, so "what we check" never drifts.
106
+ - `adra/orchestrator.py` — the hand-rolled, **framework-free** state machine.
107
+ - `adra/critic.py` — deterministic red-team pass (rubric-driven) + LLM semantic attacks.
108
+ - `adra/judge.py` — rubric scoring with **swap-and-average** + reference anchoring.
109
+ - `adra/llm.py` — the tiny ADRA-owned `ChatModel` seam: `mock` (offline) | any real provider
110
+ via **pydantic-ai** (`provider:model`, config-only). No LangChain/LangGraph.
111
+ - `adra/tools/` — each returns a `ToolResult` (git / CI / bundle / lang / discovery / sql).
112
+ - `adra/skills/` — the `Skill` base + the six skills.
113
+ - `adra/clients/` — client governance suites (the bundled fictional **Northwind Data
114
+ Platform**); selectable via `ADRA_CLIENT_DIR`.
115
+ - `adra/provenance.py` — the immutable run record (the deep change-history layer).
116
+ - `cli/` — the `adra` command. `refs/` — annotated bibliography + papers. `docs/` — deep
117
+ docs + engine ADRs (`docs/adr/`).
118
+
119
+ ## Quickstart (offline, no key)
120
+
121
+ ```bash
122
+ python -m venv .venv && . .venv/Scripts/activate # Windows: .venv\Scripts\activate
123
+ pip install -e ".[dev]"
124
+ pytest -q # 11 passing, fully offline
125
+ python scripts/demo_offline.py # end-to-end demo, all six skills
126
+ ```
127
+
128
+ Expected: the stale-base PR is **blocked + escalated** (12 commits behind, a notebook
129
+ deletion, a `.yml → .yml.t` rename dropping a bundle resource, `bundle validate` failing);
130
+ the language/leak review is **blocked**; the clean experiment / improve / document / decide
131
+ runs are **accepted**.
132
+
133
+ ```bash
134
+ adra review path/to.diff --ci-command 'python -m coverage run -m unittest discover -s . -p "test*.py"'
135
+ adra decide "Raise the refresh cadence" "edit the shared CI template" "change it in the owning repo"
136
+ ```
137
+
138
+ ## Enable a real provider
139
+
140
+ ```bash
141
+ pip install -e ".[llm]" # pydantic-ai; the seam is provider-agnostic
142
+ export ANTHROPIC_API_KEY=... # or put it in .env (any provider's key works)
143
+ export ADRA_PROVIDER=anthropic # adding a provider is config only: ADRA_PROVIDER / ADRA_MODEL / ADRA_MODEL_<ROLE>
144
+ adra pr-eval --source task/123/x --repo /path/to/repo --external
145
+ ```
146
+
147
+ `--external` (or `ADRA_ALLOW_EXTERNAL=1`) lets the tools actually run git / the CI command.
148
+ Default is **dry-run / read-only**.
149
+
150
+ ## Client-agnostic grounding
151
+
152
+ A *client* = a governance suite (conventions, ADRs, CI standards, glossary, incident cases)
153
+ the engine grounds on. ADRA ships a complete, **fictional** client — **Northwind Data
154
+ Platform** — under `adra/clients/synthetic/northwind/`. Point ADRA at any client:
155
+
156
+ ```bash
157
+ export ADRA_CLIENT_DIR=/path/to/your/standards # or Settings(client_dir=...)
158
+ ```
159
+
160
+ The rubric references the suite by id and the prompts cite it — the engine code does not
161
+ change per client.
162
+
163
+ ## Connectors & emulator
164
+
165
+ The engine grounds through one connector `Protocol` so the same skills run against a real
166
+ platform or a synthetic one:
167
+
168
+ - **Real**: GitHub (PRs/reviews/issues/contents via a thin `httpx` REST v3 client), Azure DevOps
169
+ (REST 7.1), Databricks (`databricks-sdk` + bundles CLI), Azure (`azure-identity` + monitor / health).
170
+ - **Emulator**: a self-contained platform (synthetic git repos + PRs + wiki + boards + CI +
171
+ a SQLite warehouse) so the full flow runs offline.
172
+
173
+ > The GitHub, Azure DevOps, Databricks, and Azure connectors are **implemented**; the offline
174
+ > emulator runs the full flow with no external calls. Each is enabled by its `pip install adra[...]`
175
+ > extra and exercised read-only by default.
176
+
177
+ ## Security model
178
+
179
+ Deterministic floor (tools are ground truth; the LLM cannot overturn a blocker) · read-only
180
+ by default (writes require `--external` **and** explicit human confirmation) · human gates on
181
+ PR create / push / merge and any risk claim · English-only + AI-authorship-leak scan on
182
+ anything written to disk · immutable provenance for every run. The agent reads **untrusted**
183
+ repo/PR/issue content — a dual-LLM / capability split + sandboxed, egress-filtered execution are
184
+ planned for the connector phase (not yet implemented; OWASP LLM/Agentic Top-10).
185
+
186
+ ## Two-repo layout
187
+
188
+ ADRA is the **public-destined OSS engine** (this repo) — no secrets, ever. A separate
189
+ private **ADRA Console** (a private web app + backend) *consumes* this engine for
190
+ experiments and real connections behind access control. The engine is the serious tool you
191
+ can run anywhere with your own tokens; the console is the connected instance.
192
+
193
+ ## Extending
194
+
195
+ - **New criterion:** add a `RubricItem` to `adra/rubric.py` (it shows up in the critic
196
+ prompt and, if `kind="deterministic"`, wire its check in `critic.py`).
197
+ - **New capability:** add a `Skill` subclass + a `prompts/<skill>.md`, register it in
198
+ `adra/skills/__init__.py`, add a `Node`.
199
+ - **New tool:** a function returning a `ToolResult`; call it from a skill's `ground`.
200
+ - **New provider:** config only — set `ADRA_PROVIDER` / `ADRA_MODEL` / `ADRA_MODEL_<ROLE>`
201
+ (pydantic-ai resolves the `provider:model`); no new code.
202
+
203
+ ## Status
204
+
205
+ `v0.04.000` — the engine is complete and green offline, and the GitHub / Azure DevOps / Databricks
206
+ / Azure connectors plus the offline emulator are implemented. Multi-industry synthetic clients and
207
+ the web console are the next phases. Stays `0.x` while connectors are partly untested-live.
208
+
209
+ ## License
210
+
211
+ Apache-2.0 — see [LICENSE](LICENSE).
212
+
213
+ ## References
214
+
215
+ `refs/` holds an annotated bibliography (`refs/README.md`) + BibTeX (`refs/references.bib`)
216
+ + the core papers (ReAct, Reflexion, Self-Refine, Constitutional AI, LLM-as-judge bias,
217
+ agentic security / CaMeL, NIST AI RMF, OWASP LLM/Agentic, provenance, code-review agents).
adra-0.4.0/README.md ADDED
@@ -0,0 +1,174 @@
1
+ # ADRA — Adversarial Dev Review Agent
2
+
3
+ > A **client-agnostic, deterministic-first, adversarial-validation engine** that supports
4
+ > the software lifecycle: it reviews PRs, designs and runs validation/refutation
5
+ > experiments, writes documentation back, and **escalates to a human** exactly where a
6
+ > senior engineer would. Governed by **LLM-as-Judge + a blocking adversarial critic**,
7
+ > grounded by **deterministic tools**, with **immutable provenance**. Runs **offline with
8
+ > no API key**.
9
+
10
+ `pip install adra` · Python ≥ 3.11 · Apache-2.0 · status: `v0.04.000`
11
+
12
+ ---
13
+
14
+ ## What's different
15
+
16
+ The AI-code-review market splits in two, and both miss the same spot:
17
+
18
+ - **Reviewers** (CodeRabbit, Greptile, Qodo, Korbit, Sourcery, Bito) feed linters into an
19
+ LLM, but the **model's prose is the verdict** — hallucinated and "consistently-stated-
20
+ but-false" findings leak through; the deterministic signals are inputs, never the gate.
21
+ - **Autonomous coders** (Devin, OpenHands, SWE-agent, Sweep) *write* code and treat
22
+ "tests pass" as success rather than adversarially trying to prove the change **wrong**.
23
+
24
+ ADRA occupies the gap: a **deterministic spine** (git / CI / static analysis / SQL probes)
25
+ that *grounds* a **blocking adversarial critic** whose job is to **refute**, not bless, each
26
+ artifact — every finding carrying its evidence, with disciplined **human escalation** when
27
+ nothing deterministic backs the verdict. Existing tools generate opinions; ADRA generates
28
+ proofs and refutations, and escalates when it can't.
29
+
30
+ ## The six capabilities
31
+
32
+ | Skill | What it does |
33
+ |---|---|
34
+ | `code_review` | Review a diff: language/leak scan + test-discoverability + exact CI command + semantic findings |
35
+ | `pr_eval` | Evaluate a PR: merge-base health → `bundle validate` → conformance → verdict + PR body |
36
+ | `experiment` | Hypothesis-driven validation experiment: SQL-warehouse probes + synthesis |
37
+ | `improve` | Minimum-functional improvement proposal (prune filler, smallest safe diff) |
38
+ | `document` | Turn a run record into a PR page / experiment page / methodology-history row |
39
+ | `decide` | Route analysis: candidate routes + trade-offs + recommendation — **human-owned** |
40
+
41
+ Each skill is the same loop, differing only by its domain prompt and deterministic tools.
42
+
43
+ ## Why deterministic-first
44
+
45
+ Tools (`git`, the exact CI command, `bundle validate`, language scan, SQL probe) run
46
+ **first** and become both the grounding the model may not contradict and the evidence in
47
+ the provenance log. Because the deterministic floor carries the verdict, the whole loop
48
+ runs — and the test suite passes — **offline with no API key**. Connecting a real provider
49
+ adds the semantic layer on top.
50
+
51
+ ## Architecture
52
+
53
+ ```
54
+ intake ─▶ plan ─▶ ground (deterministic tools) ─▶ generate ─▶ CRITIC ─┐
55
+ ▲ revise ◀──────┘
56
+ └── accepted / escalate ─▶ artifacts + run record
57
+ ```
58
+
59
+ - `adra/state.py` — the typed **domain model** (`Severity`, `Finding`, `ToolResult`,
60
+ `CriticVerdict`, `RunState`). One contract end to end.
61
+ - `adra/rubric.py` — the shared adversarial **rubric** (criteria as typed data); drives both
62
+ the deterministic critic and the critic prompt, so "what we check" never drifts.
63
+ - `adra/orchestrator.py` — the hand-rolled, **framework-free** state machine.
64
+ - `adra/critic.py` — deterministic red-team pass (rubric-driven) + LLM semantic attacks.
65
+ - `adra/judge.py` — rubric scoring with **swap-and-average** + reference anchoring.
66
+ - `adra/llm.py` — the tiny ADRA-owned `ChatModel` seam: `mock` (offline) | any real provider
67
+ via **pydantic-ai** (`provider:model`, config-only). No LangChain/LangGraph.
68
+ - `adra/tools/` — each returns a `ToolResult` (git / CI / bundle / lang / discovery / sql).
69
+ - `adra/skills/` — the `Skill` base + the six skills.
70
+ - `adra/clients/` — client governance suites (the bundled fictional **Northwind Data
71
+ Platform**); selectable via `ADRA_CLIENT_DIR`.
72
+ - `adra/provenance.py` — the immutable run record (the deep change-history layer).
73
+ - `cli/` — the `adra` command. `refs/` — annotated bibliography + papers. `docs/` — deep
74
+ docs + engine ADRs (`docs/adr/`).
75
+
76
+ ## Quickstart (offline, no key)
77
+
78
+ ```bash
79
+ python -m venv .venv && . .venv/Scripts/activate # Windows: .venv\Scripts\activate
80
+ pip install -e ".[dev]"
81
+ pytest -q # 11 passing, fully offline
82
+ python scripts/demo_offline.py # end-to-end demo, all six skills
83
+ ```
84
+
85
+ Expected: the stale-base PR is **blocked + escalated** (12 commits behind, a notebook
86
+ deletion, a `.yml → .yml.t` rename dropping a bundle resource, `bundle validate` failing);
87
+ the language/leak review is **blocked**; the clean experiment / improve / document / decide
88
+ runs are **accepted**.
89
+
90
+ ```bash
91
+ adra review path/to.diff --ci-command 'python -m coverage run -m unittest discover -s . -p "test*.py"'
92
+ adra decide "Raise the refresh cadence" "edit the shared CI template" "change it in the owning repo"
93
+ ```
94
+
95
+ ## Enable a real provider
96
+
97
+ ```bash
98
+ pip install -e ".[llm]" # pydantic-ai; the seam is provider-agnostic
99
+ export ANTHROPIC_API_KEY=... # or put it in .env (any provider's key works)
100
+ export ADRA_PROVIDER=anthropic # adding a provider is config only: ADRA_PROVIDER / ADRA_MODEL / ADRA_MODEL_<ROLE>
101
+ adra pr-eval --source task/123/x --repo /path/to/repo --external
102
+ ```
103
+
104
+ `--external` (or `ADRA_ALLOW_EXTERNAL=1`) lets the tools actually run git / the CI command.
105
+ Default is **dry-run / read-only**.
106
+
107
+ ## Client-agnostic grounding
108
+
109
+ A *client* = a governance suite (conventions, ADRs, CI standards, glossary, incident cases)
110
+ the engine grounds on. ADRA ships a complete, **fictional** client — **Northwind Data
111
+ Platform** — under `adra/clients/synthetic/northwind/`. Point ADRA at any client:
112
+
113
+ ```bash
114
+ export ADRA_CLIENT_DIR=/path/to/your/standards # or Settings(client_dir=...)
115
+ ```
116
+
117
+ The rubric references the suite by id and the prompts cite it — the engine code does not
118
+ change per client.
119
+
120
+ ## Connectors & emulator
121
+
122
+ The engine grounds through one connector `Protocol` so the same skills run against a real
123
+ platform or a synthetic one:
124
+
125
+ - **Real**: GitHub (PRs/reviews/issues/contents via a thin `httpx` REST v3 client), Azure DevOps
126
+ (REST 7.1), Databricks (`databricks-sdk` + bundles CLI), Azure (`azure-identity` + monitor / health).
127
+ - **Emulator**: a self-contained platform (synthetic git repos + PRs + wiki + boards + CI +
128
+ a SQLite warehouse) so the full flow runs offline.
129
+
130
+ > The GitHub, Azure DevOps, Databricks, and Azure connectors are **implemented**; the offline
131
+ > emulator runs the full flow with no external calls. Each is enabled by its `pip install adra[...]`
132
+ > extra and exercised read-only by default.
133
+
134
+ ## Security model
135
+
136
+ Deterministic floor (tools are ground truth; the LLM cannot overturn a blocker) · read-only
137
+ by default (writes require `--external` **and** explicit human confirmation) · human gates on
138
+ PR create / push / merge and any risk claim · English-only + AI-authorship-leak scan on
139
+ anything written to disk · immutable provenance for every run. The agent reads **untrusted**
140
+ repo/PR/issue content — a dual-LLM / capability split + sandboxed, egress-filtered execution are
141
+ planned for the connector phase (not yet implemented; OWASP LLM/Agentic Top-10).
142
+
143
+ ## Two-repo layout
144
+
145
+ ADRA is the **public-destined OSS engine** (this repo) — no secrets, ever. A separate
146
+ private **ADRA Console** (a private web app + backend) *consumes* this engine for
147
+ experiments and real connections behind access control. The engine is the serious tool you
148
+ can run anywhere with your own tokens; the console is the connected instance.
149
+
150
+ ## Extending
151
+
152
+ - **New criterion:** add a `RubricItem` to `adra/rubric.py` (it shows up in the critic
153
+ prompt and, if `kind="deterministic"`, wire its check in `critic.py`).
154
+ - **New capability:** add a `Skill` subclass + a `prompts/<skill>.md`, register it in
155
+ `adra/skills/__init__.py`, add a `Node`.
156
+ - **New tool:** a function returning a `ToolResult`; call it from a skill's `ground`.
157
+ - **New provider:** config only — set `ADRA_PROVIDER` / `ADRA_MODEL` / `ADRA_MODEL_<ROLE>`
158
+ (pydantic-ai resolves the `provider:model`); no new code.
159
+
160
+ ## Status
161
+
162
+ `v0.04.000` — the engine is complete and green offline, and the GitHub / Azure DevOps / Databricks
163
+ / Azure connectors plus the offline emulator are implemented. Multi-industry synthetic clients and
164
+ the web console are the next phases. Stays `0.x` while connectors are partly untested-live.
165
+
166
+ ## License
167
+
168
+ Apache-2.0 — see [LICENSE](LICENSE).
169
+
170
+ ## References
171
+
172
+ `refs/` holds an annotated bibliography (`refs/README.md`) + BibTeX (`refs/references.bib`)
173
+ + the core papers (ReAct, Reflexion, Self-Refine, Constitutional AI, LLM-as-judge bias,
174
+ agentic security / CaMeL, NIST AI RMF, OWASP LLM/Agentic, provenance, code-review agents).
@@ -0,0 +1,36 @@
1
+ """ADRA — Adversarial Dev Review Agent.
2
+
3
+ A client-agnostic, deterministic-first, adversarial-validation engine that supports the
4
+ software lifecycle. It formalizes six capabilities a team runs informally under
5
+ adversarial human direction:
6
+
7
+ code_review | pr_eval | experiment | improve | document | decide
8
+
9
+ The design spine is *adversarial validation*: every generated artifact is passed through
10
+ a blocking, tool-grounded adversarial critic before it is accepted, and every run emits
11
+ an immutable provenance record (the deep change history). Deterministic tools
12
+ (git / CI / SQL / static analysis) are ground truth; the LLM only adds what tools cannot
13
+ settle. Connectors (GitHub / Azure DevOps / Databricks / Azure) and a self-contained
14
+ offline emulator sit behind one Protocol, so the same engine runs against a real
15
+ platform or a synthetic one.
16
+
17
+ The package runs offline with a deterministic ``mock`` provider (no API key required)
18
+ and switches to a real provider (e.g. Anthropic Claude) when its key is present.
19
+ """
20
+
21
+ from adra.config import Settings, load_settings
22
+ from adra.orchestrator import Orchestrator
23
+ from adra.state import CriticVerdict, Finding, RunState, Severity, ToolResult
24
+
25
+ __all__ = [
26
+ "Settings",
27
+ "load_settings",
28
+ "Orchestrator",
29
+ "Finding",
30
+ "Severity",
31
+ "ToolResult",
32
+ "CriticVerdict",
33
+ "RunState",
34
+ ]
35
+
36
+ __version__ = "0.4.0" # PEP 440 package version; display/tag version is v0.04.000 (see VERSION)