aedificatoria 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.
- aedificatoria-0.1.0/.githooks/pre-commit +23 -0
- aedificatoria-0.1.0/.github/workflows/aed.yml +51 -0
- aedificatoria-0.1.0/.github/workflows/release.yml +75 -0
- aedificatoria-0.1.0/.gitignore +10 -0
- aedificatoria-0.1.0/LICENSE +21 -0
- aedificatoria-0.1.0/PKG-INFO +365 -0
- aedificatoria-0.1.0/README.md +333 -0
- aedificatoria-0.1.0/aed-baseline.json +879 -0
- aedificatoria-0.1.0/aed.toml +46 -0
- aedificatoria-0.1.0/aed.toml.example +63 -0
- aedificatoria-0.1.0/docs/decisions/0001-record-architecture-decisions.md +38 -0
- aedificatoria-0.1.0/docs/decisions/0002-language-adapters.md +61 -0
- aedificatoria-0.1.0/docs/decisions/0003-cargo-advisory.md +57 -0
- aedificatoria-0.1.0/docs/decisions/0004-tree-sitter-js-ts.md +67 -0
- aedificatoria-0.1.0/docs/decisions/0005-tree-sitter-rust.md +56 -0
- aedificatoria-0.1.0/docs/decisions/0006-guard-config-and-per-test-assertions.md +60 -0
- aedificatoria-0.1.0/docs/decisions/0007-persistent-baseline.md +88 -0
- aedificatoria-0.1.0/docs/decisions/0008-history-audit.md +67 -0
- aedificatoria-0.1.0/docs/decisions/0009-squash-aware-history.md +70 -0
- aedificatoria-0.1.0/docs/decisions/0010-pr-ref-recovery.md +69 -0
- aedificatoria-0.1.0/docs/decisions/0011-github-api-recovery.md +69 -0
- aedificatoria-0.1.0/docs/decisions/0012-gh-cli-transport.md +62 -0
- aedificatoria-0.1.0/docs/decisions/0013-gitlab-glab-recovery.md +63 -0
- aedificatoria-0.1.0/docs/decisions/0014-parallel-history.md +67 -0
- aedificatoria-0.1.0/docs/decisions/0015-history-signal.md +71 -0
- aedificatoria-0.1.0/docs/decisions/0016-large-merge-warning.md +48 -0
- aedificatoria-0.1.0/docs/decisions/0017-merge-conflict-resolution.md +61 -0
- aedificatoria-0.1.0/docs/decisions/0018-octopus-merges.md +60 -0
- aedificatoria-0.1.0/docs/decisions/0019-rebase-merges.md +59 -0
- aedificatoria-0.1.0/docs/decisions/0020-staged-index-check.md +67 -0
- aedificatoria-0.1.0/docs/decisions/0021-tsconfig-aliases.md +67 -0
- aedificatoria-0.1.0/docs/decisions/0022-each-test-tables.md +60 -0
- aedificatoria-0.1.0/docs/decisions/0023-python-init-exports.md +73 -0
- aedificatoria-0.1.0/docs/decisions/0024-real-world-audit-fixes.md +63 -0
- aedificatoria-0.1.0/docs/decisions/0025-serialize-worktree-admin.md +60 -0
- aedificatoria-0.1.0/docs/decisions/0026-history-worktree-reuse.md +63 -0
- aedificatoria-0.1.0/docs/decisions/0027-per-file-metric-cache.md +66 -0
- aedificatoria-0.1.0/docs/decisions/0028-incremental-history.md +62 -0
- aedificatoria-0.1.0/docs/decisions/0029-incremental-repo-index.md +55 -0
- aedificatoria-0.1.0/docs/decisions/0030-mit-license.md +53 -0
- aedificatoria-0.1.0/docs/decisions/0031-c-cpp-support.md +74 -0
- aedificatoria-0.1.0/docs/decisions/0032-python-syntax-errors.md +49 -0
- aedificatoria-0.1.0/docs/decisions/0033-tree-sitter-syntax-errors.md +48 -0
- aedificatoria-0.1.0/docs/decisions/0034-tool-diagnostics.md +46 -0
- aedificatoria-0.1.0/docs/decisions/0035-pypi-trusted-publishing.md +52 -0
- aedificatoria-0.1.0/docs/history.md +165 -0
- aedificatoria-0.1.0/docs/real-world-audit.md +75 -0
- aedificatoria-0.1.0/pyproject.toml +51 -0
- aedificatoria-0.1.0/src/aedificatoria/__init__.py +3 -0
- aedificatoria-0.1.0/src/aedificatoria/__main__.py +3 -0
- aedificatoria-0.1.0/src/aedificatoria/adr.py +193 -0
- aedificatoria-0.1.0/src/aedificatoria/baseline.py +392 -0
- aedificatoria-0.1.0/src/aedificatoria/cargo.py +90 -0
- aedificatoria-0.1.0/src/aedificatoria/cfamily.py +525 -0
- aedificatoria-0.1.0/src/aedificatoria/checks.py +785 -0
- aedificatoria-0.1.0/src/aedificatoria/cli.py +341 -0
- aedificatoria-0.1.0/src/aedificatoria/config.py +334 -0
- aedificatoria-0.1.0/src/aedificatoria/doctor.py +138 -0
- aedificatoria-0.1.0/src/aedificatoria/forge.py +46 -0
- aedificatoria-0.1.0/src/aedificatoria/git.py +487 -0
- aedificatoria-0.1.0/src/aedificatoria/github.py +139 -0
- aedificatoria-0.1.0/src/aedificatoria/gitlab.py +153 -0
- aedificatoria-0.1.0/src/aedificatoria/history.py +537 -0
- aedificatoria-0.1.0/src/aedificatoria/jsts.py +1173 -0
- aedificatoria-0.1.0/src/aedificatoria/languages.py +159 -0
- aedificatoria-0.1.0/src/aedificatoria/model.py +118 -0
- aedificatoria-0.1.0/src/aedificatoria/pyast.py +614 -0
- aedificatoria-0.1.0/src/aedificatoria/report.py +70 -0
- aedificatoria-0.1.0/src/aedificatoria/rust.py +657 -0
- aedificatoria-0.1.0/src/aedificatoria/syntax.py +26 -0
- aedificatoria-0.1.0/tests/conftest.py +45 -0
- aedificatoria-0.1.0/tests/test_baseline.py +288 -0
- aedificatoria-0.1.0/tests/test_cfamily.py +137 -0
- aedificatoria-0.1.0/tests/test_checks.py +394 -0
- aedificatoria-0.1.0/tests/test_cli.py +137 -0
- aedificatoria-0.1.0/tests/test_github.py +141 -0
- aedificatoria-0.1.0/tests/test_gitlab.py +121 -0
- aedificatoria-0.1.0/tests/test_history.py +370 -0
- aedificatoria-0.1.0/tests/test_jsts.py +434 -0
- aedificatoria-0.1.0/tests/test_rust.py +387 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# Aedificatoria pre-commit guard.
|
|
3
|
+
#
|
|
4
|
+
# Checks the staged index against HEAD. Enable once per clone:
|
|
5
|
+
# git config core.hooksPath .githooks
|
|
6
|
+
#
|
|
7
|
+
# Set up the project first:
|
|
8
|
+
# uv venv .venv && uv pip install -e '.[dev]'
|
|
9
|
+
set -eu
|
|
10
|
+
|
|
11
|
+
root=$(git rev-parse --show-toplevel)
|
|
12
|
+
cd "$root"
|
|
13
|
+
|
|
14
|
+
if [ -x "$root/.venv/bin/aed" ]; then
|
|
15
|
+
exec "$root/.venv/bin/aed" check --staged
|
|
16
|
+
fi
|
|
17
|
+
|
|
18
|
+
if command -v aed >/dev/null 2>&1; then
|
|
19
|
+
exec aed check --staged
|
|
20
|
+
fi
|
|
21
|
+
|
|
22
|
+
echo "aed: not on PATH and no .venv; skipping architecture check" >&2
|
|
23
|
+
exit 0
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
name: aed
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
pull_request:
|
|
6
|
+
workflow_dispatch:
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
guard:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v7
|
|
16
|
+
with:
|
|
17
|
+
fetch-depth: 0
|
|
18
|
+
|
|
19
|
+
- uses: actions/setup-python@v7
|
|
20
|
+
with:
|
|
21
|
+
python-version: "3.11"
|
|
22
|
+
|
|
23
|
+
- name: Install
|
|
24
|
+
run: |
|
|
25
|
+
python -m pip install --upgrade pip
|
|
26
|
+
python -m pip install -e '.[dev]'
|
|
27
|
+
|
|
28
|
+
- name: Tests
|
|
29
|
+
run: python -m pytest -q
|
|
30
|
+
|
|
31
|
+
- name: Resolve base
|
|
32
|
+
id: base
|
|
33
|
+
env:
|
|
34
|
+
EVENT_BEFORE: ${{ github.event.before }}
|
|
35
|
+
PR_BASE: ${{ github.event.pull_request.base.sha }}
|
|
36
|
+
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
|
|
37
|
+
run: |
|
|
38
|
+
base="${PR_BASE:-$EVENT_BEFORE}"
|
|
39
|
+
if [ -z "$base" ] || [ "$base" = "0000000000000000000000000000000000000000" ] || ! git cat-file -e "$base^{commit}" 2>/dev/null; then
|
|
40
|
+
base=$(git merge-base HEAD "origin/$DEFAULT_BRANCH" 2>/dev/null || git rev-parse HEAD~1 2>/dev/null || git rev-parse HEAD)
|
|
41
|
+
fi
|
|
42
|
+
head=$(git rev-parse HEAD)
|
|
43
|
+
if [ "$base" = "$head" ]; then
|
|
44
|
+
base=$(git rev-parse HEAD~1 2>/dev/null || echo "$head")
|
|
45
|
+
fi
|
|
46
|
+
echo "base=$base" >> "$GITHUB_OUTPUT"
|
|
47
|
+
|
|
48
|
+
- name: Guard
|
|
49
|
+
env:
|
|
50
|
+
AED_BASE: ${{ steps.base.outputs.base }}
|
|
51
|
+
run: aed check --base "$AED_BASE"
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
name: release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- "v*"
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
build:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v7
|
|
16
|
+
with:
|
|
17
|
+
fetch-depth: 0
|
|
18
|
+
|
|
19
|
+
- uses: actions/setup-python@v7
|
|
20
|
+
with:
|
|
21
|
+
python-version: "3.13"
|
|
22
|
+
|
|
23
|
+
- name: Install build tooling
|
|
24
|
+
run: |
|
|
25
|
+
python -m pip install --upgrade pip
|
|
26
|
+
python -m pip install build
|
|
27
|
+
|
|
28
|
+
- name: Verify tag matches package version
|
|
29
|
+
env:
|
|
30
|
+
TAG: ${{ github.ref_name }}
|
|
31
|
+
run: |
|
|
32
|
+
python - <<'PY'
|
|
33
|
+
import os
|
|
34
|
+
import tomllib
|
|
35
|
+
from pathlib import Path
|
|
36
|
+
|
|
37
|
+
version = tomllib.loads(Path("pyproject.toml").read_text(encoding="utf-8"))["project"]["version"]
|
|
38
|
+
tag = os.environ["TAG"]
|
|
39
|
+
if tag != f"v{version}":
|
|
40
|
+
raise SystemExit(f"release tag {tag!r} does not match package version {version!r}")
|
|
41
|
+
print(f"release {tag}")
|
|
42
|
+
PY
|
|
43
|
+
|
|
44
|
+
- name: Build sdist and wheel
|
|
45
|
+
run: python -m build
|
|
46
|
+
|
|
47
|
+
- name: Smoke-test the installed wheel
|
|
48
|
+
run: |
|
|
49
|
+
python -m venv "$RUNNER_TEMP/aed-wheel"
|
|
50
|
+
"$RUNNER_TEMP/aed-wheel/bin/python" -m pip install --upgrade pip
|
|
51
|
+
"$RUNNER_TEMP/aed-wheel/bin/pip" install dist/*.whl
|
|
52
|
+
"$RUNNER_TEMP/aed-wheel/bin/aed" --version
|
|
53
|
+
"$RUNNER_TEMP/aed-wheel/bin/aed" doctor
|
|
54
|
+
|
|
55
|
+
- uses: actions/upload-artifact@v4
|
|
56
|
+
with:
|
|
57
|
+
name: dist
|
|
58
|
+
path: dist/
|
|
59
|
+
|
|
60
|
+
publish:
|
|
61
|
+
needs: build
|
|
62
|
+
runs-on: ubuntu-latest
|
|
63
|
+
environment:
|
|
64
|
+
name: pypi
|
|
65
|
+
url: https://pypi.org/project/aedificatoria/
|
|
66
|
+
permissions:
|
|
67
|
+
contents: read
|
|
68
|
+
id-token: write
|
|
69
|
+
steps:
|
|
70
|
+
- uses: actions/download-artifact@v4
|
|
71
|
+
with:
|
|
72
|
+
name: dist
|
|
73
|
+
path: dist/
|
|
74
|
+
|
|
75
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Daniel Tralamazza
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: aedificatoria
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Architecture guard for coding agents: make design constraints executable.
|
|
5
|
+
Project-URL: Homepage, https://github.com/tralamazza/aedificatoria
|
|
6
|
+
Project-URL: Repository, https://github.com/tralamazza/aedificatoria
|
|
7
|
+
Project-URL: Issues, https://github.com/tralamazza/aedificatoria/issues
|
|
8
|
+
Author: Daniel Tralamazza
|
|
9
|
+
License: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: architecture,ci,coding-agents,guard,static-analysis
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Environment :: Console
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
22
|
+
Requires-Python: >=3.11
|
|
23
|
+
Requires-Dist: tree-sitter-c==0.24.2
|
|
24
|
+
Requires-Dist: tree-sitter-cpp==0.23.4
|
|
25
|
+
Requires-Dist: tree-sitter-javascript==0.25.0
|
|
26
|
+
Requires-Dist: tree-sitter-rust==0.24.2
|
|
27
|
+
Requires-Dist: tree-sitter-typescript==0.23.2
|
|
28
|
+
Requires-Dist: tree-sitter==0.27.0
|
|
29
|
+
Provides-Extra: dev
|
|
30
|
+
Requires-Dist: pytest>=8; extra == 'dev'
|
|
31
|
+
Description-Content-Type: text/markdown
|
|
32
|
+
|
|
33
|
+
# Aedificatoria
|
|
34
|
+
|
|
35
|
+
Deterministic architecture guard for coding agents and humans.
|
|
36
|
+
|
|
37
|
+
`aed check` compares the working tree (including untracked files) against a base
|
|
38
|
+
commit materialized into a temporary tree. `--staged` compares the index instead.
|
|
39
|
+
It exits non-zero on mechanical violations. No LLM calls, no network, no source
|
|
40
|
+
mutation.
|
|
41
|
+
|
|
42
|
+
## Install
|
|
43
|
+
|
|
44
|
+
Requires Python 3.11+ and Git.
|
|
45
|
+
|
|
46
|
+
```sh
|
|
47
|
+
uv tool install aedificatoria
|
|
48
|
+
# or
|
|
49
|
+
pipx install aedificatoria
|
|
50
|
+
|
|
51
|
+
aed doctor
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
For a one-off run without a persistent install:
|
|
55
|
+
|
|
56
|
+
```sh
|
|
57
|
+
uvx --from aedificatoria aed check --staged
|
|
58
|
+
# or
|
|
59
|
+
pipx run --spec aedificatoria aed check --staged
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
In a project virtualenv, `pip install aedificatoria` also works. Then start with:
|
|
63
|
+
|
|
64
|
+
```sh
|
|
65
|
+
aed init # aed.toml + docs/decisions/0001-*.md
|
|
66
|
+
aed baseline # aed-baseline.json
|
|
67
|
+
aed check
|
|
68
|
+
aed check --json
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Install from source
|
|
72
|
+
|
|
73
|
+
```sh
|
|
74
|
+
uv venv .venv
|
|
75
|
+
uv pip install -e '.[dev]'
|
|
76
|
+
|
|
77
|
+
.venv/bin/aed doctor
|
|
78
|
+
.venv/bin/aed init
|
|
79
|
+
.venv/bin/aed baseline
|
|
80
|
+
.venv/bin/aed check
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
`aed check` never stages or commits.
|
|
84
|
+
|
|
85
|
+
## Tool diagnostics
|
|
86
|
+
|
|
87
|
+
```sh
|
|
88
|
+
aed doctor
|
|
89
|
+
aed doctor --json
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Required: Python 3.11+, `git`, and the pinned tree-sitter runtime/grammars.
|
|
93
|
+
Optional: `cargo` for advisory metadata, `gh` for GitHub PR audits, and `glab`
|
|
94
|
+
for GitLab MR audits. Optional tools are reported but do not fail the command.
|
|
95
|
+
Exit `1` when a required tool is missing or incompatible. The command is local,
|
|
96
|
+
read-only, and makes no network calls.
|
|
97
|
+
|
|
98
|
+
| Exit | Verdict | Action |
|
|
99
|
+
|---:|---|---|
|
|
100
|
+
| `0` | `allow` | No findings. |
|
|
101
|
+
| `0` | `review` | Warnings only; read before merge. |
|
|
102
|
+
| `2` | `block` | Error(s); do not commit/merge. |
|
|
103
|
+
|
|
104
|
+
`2` also covers CLI, config, and git errors.
|
|
105
|
+
|
|
106
|
+
## Commands
|
|
107
|
+
|
|
108
|
+
| Command | Purpose |
|
|
109
|
+
|---|---|
|
|
110
|
+
| `aed check [--base REV] [--config PATH] [--staged] [--json]` | Check working tree or staged index against a base. |
|
|
111
|
+
| `aed doctor [--json]` | Check required and optional installed tools. |
|
|
112
|
+
| `aed baseline` | Write the persistent metric baseline. |
|
|
113
|
+
| `aed history [--limit N] [--all] [--jobs N]` | Audit local history. |
|
|
114
|
+
| `aed history --github-pr N --repo OWNER/REPO` | Audit a GitHub PR via `gh`. |
|
|
115
|
+
| `aed history --gitlab-mr N --repo GROUP/PROJECT` | Audit a GitLab MR via `glab`. |
|
|
116
|
+
| `aed adr new TITLE [--status proposed]` | Create a numbered ADR. |
|
|
117
|
+
| `aed rules` | Print effective config and thresholds. |
|
|
118
|
+
| `aed init` | Create `aed.toml` and the first ADR. |
|
|
119
|
+
|
|
120
|
+
## Output contract
|
|
121
|
+
|
|
122
|
+
Text findings include severity, rule, path, message, and optional evidence.
|
|
123
|
+
`--json` returns:
|
|
124
|
+
|
|
125
|
+
```json
|
|
126
|
+
{"verdict":"block","base":"<sha>","changed":{"files":3,"added":42,"deleted":7},
|
|
127
|
+
"counts":{"error":1,"warn":0,"info":0},
|
|
128
|
+
"findings":[{"rule":"one-way-door","severity":"error","path":"migrations/42.sql"}]}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Agents should consume `verdict` and `findings`, not parse text. `path`, `line`,
|
|
132
|
+
and `evidence` are optional per finding.
|
|
133
|
+
|
|
134
|
+
## Rules
|
|
135
|
+
|
|
136
|
+
| Rule | Default | Trigger | Remedy |
|
|
137
|
+
|---|---|---|---|
|
|
138
|
+
| `one-way-door` | error | Change under migrations, schema, API, auth, `.proto`, or OpenAPI. | Accepted ADR. |
|
|
139
|
+
| `guard-config` | error | Effective `aed.toml` or baseline-file change. | Accepted ADR. |
|
|
140
|
+
| `change-amplification` | error | Diff exceeds the file/line budget. | Split it, or add an ADR. |
|
|
141
|
+
| `baseline` | error | Metric growth beyond caps, removed tests, assertion drop. | Fix it, or refresh with an ADR. |
|
|
142
|
+
| `test-tampering` | error | Deleted tests/assertions, new `skip`/`xfail`/`.only`. | Restore the test. |
|
|
143
|
+
| `syntax-error` | error | New Python/Rust/JS/TS/C/C++ file fails to parse. | Fix the syntax error. |
|
|
144
|
+
| `test-config` | warn/error | Test configuration changed/deleted. | Restore; keep the verifier stable. |
|
|
145
|
+
| `import-cycle` | error | New top-level package cycle. | Remove the edge. |
|
|
146
|
+
| `forbidden-edge` | error | New `[[aed.forbidden_edges]]` edge. | Remove the edge. |
|
|
147
|
+
| `complexity` | error | New function over `max_complexity`, or existing function growth over `complexity_delta`. | Refactor. |
|
|
148
|
+
| `public-api` | error | Removed/renamed public symbol or changed signature. | Restore compatibility or add an accepted ADR. |
|
|
149
|
+
| `new-dependency` | error | New third-party import not allowlisted. | Reuse a dependency or record an allowlist decision. |
|
|
150
|
+
| `adr-quality` | warn | ADR missing title, status, or `## Decision`. | Fix the ADR. |
|
|
151
|
+
|
|
152
|
+
Private paths (`_module.py`, `_dir/`) are excluded from public API unless a
|
|
153
|
+
symbol is explicitly re-exported through a package `__init__.py`. `docs/**`,
|
|
154
|
+
`examples/**`, and `benchmarks/**` are excluded from production metrics by
|
|
155
|
+
default.
|
|
156
|
+
|
|
157
|
+
## ADRs
|
|
158
|
+
|
|
159
|
+
**ADR** means **Architecture Decision Record**: a numbered Markdown file under
|
|
160
|
+
`adr_dir` (default `docs/decisions/`) that records the context, decision,
|
|
161
|
+
alternatives, consequences, invariants, and rollback path for a consequential
|
|
162
|
+
change. Create one with `aed adr new TITLE`.
|
|
163
|
+
|
|
164
|
+
An accepted ADR needs a `# title`, `- Status: accepted`, and a `## Decision`
|
|
165
|
+
section. Accepted ADRs authorize one-way-door, verifier-config, baseline, and
|
|
166
|
+
public-API changes; `adr-quality` checks only that structure, not whether the
|
|
167
|
+
decision itself is good.
|
|
168
|
+
|
|
169
|
+
## Configuration
|
|
170
|
+
|
|
171
|
+
Show effective values with `aed rules`. Minimal `aed.toml`:
|
|
172
|
+
|
|
173
|
+
```toml
|
|
174
|
+
[aed]
|
|
175
|
+
base = "HEAD"
|
|
176
|
+
adr_dir = "docs/decisions"
|
|
177
|
+
source_roots = ["src", "."]
|
|
178
|
+
metric_excludes = ["docs/**", "examples/**", "benchmarks/**"]
|
|
179
|
+
baseline_path = "aed-baseline.json"
|
|
180
|
+
|
|
181
|
+
[thresholds]
|
|
182
|
+
max_changed_files = 25
|
|
183
|
+
max_changed_lines = 800
|
|
184
|
+
max_complexity = 15
|
|
185
|
+
complexity_delta = 5
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
All keys, one-way-door overrides, test/API paths, excludes, and block flags:
|
|
189
|
+
[`aed.toml.example`](aed.toml.example). Baseline growth caps default to `0`.
|
|
190
|
+
Policy config and baseline changes require an accepted ADR; `guard-config`
|
|
191
|
+
enforces this. `cargo_advisory` is the one excluded toggle because it cannot
|
|
192
|
+
affect the verdict.
|
|
193
|
+
|
|
194
|
+
### Baseline
|
|
195
|
+
|
|
196
|
+
```sh
|
|
197
|
+
aed baseline # commit aed-baseline.json
|
|
198
|
+
aed check
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
The baseline stores per-function complexity, public API signatures (including
|
|
202
|
+
resolved Python `__init__.py` re-exports), external dependencies, package edges,
|
|
203
|
+
per-test assertion counts, and parameterized test-case counts. Growth is
|
|
204
|
+
ratcheted against it; removals and assertion/case drops are always errors.
|
|
205
|
+
Renames look like a removal plus an addition and require a refresh.
|
|
206
|
+
|
|
207
|
+
## History audit
|
|
208
|
+
|
|
209
|
+
```sh
|
|
210
|
+
aed history --limit 100 --jobs 8
|
|
211
|
+
aed history --all --limit 400 --jobs 8
|
|
212
|
+
aed history --github-pr 123 --repo owner/repo
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
Report-only: exit `0`, no writes. Each commit is measured in a temporary
|
|
216
|
+
worktree. First-parent is the default; `--all` walks every reachable commit and
|
|
217
|
+
compares it to its first parent. `--jobs` parallelizes local collection with
|
|
218
|
+
output identical to `--jobs 1`.
|
|
219
|
+
|
|
220
|
+
Merge commits are net diffs against the first parent; squashes are single atomic
|
|
221
|
+
commits; rebases are linear commits; octopus merges use the N-parent path.
|
|
222
|
+
Conflict-resolution edits are reported heuristically as `merge-only lines`.
|
|
223
|
+
Deep semantics, recovery, and caveats: [`docs/history.md`](docs/history.md).
|
|
224
|
+
|
|
225
|
+
## Agent and CI integration
|
|
226
|
+
|
|
227
|
+
### Agent harness
|
|
228
|
+
|
|
229
|
+
Apply the candidate patch, then run the guard before commit:
|
|
230
|
+
|
|
231
|
+
```python
|
|
232
|
+
import json
|
|
233
|
+
import subprocess
|
|
234
|
+
|
|
235
|
+
def run_guard(repo: str, base: str | None = None, staged: bool = False):
|
|
236
|
+
cmd = ["aed", "check", "--path", repo, "--json"]
|
|
237
|
+
if base:
|
|
238
|
+
cmd += ["--base", base]
|
|
239
|
+
if staged:
|
|
240
|
+
cmd.append("--staged")
|
|
241
|
+
|
|
242
|
+
proc = subprocess.run(cmd, text=True, capture_output=True)
|
|
243
|
+
try:
|
|
244
|
+
result = json.loads(proc.stdout)
|
|
245
|
+
except json.JSONDecodeError:
|
|
246
|
+
raise RuntimeError(proc.stderr or "aed produced no JSON")
|
|
247
|
+
|
|
248
|
+
if result["verdict"] == "block":
|
|
249
|
+
return "block", result["findings"]
|
|
250
|
+
if result["verdict"] == "review":
|
|
251
|
+
return "human", result["findings"]
|
|
252
|
+
return "allow", []
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
Harness policy:
|
|
256
|
+
|
|
257
|
+
- `block` / exit `2`: feed `rule`, `path`, `line`, and `message` back into the
|
|
258
|
+
repair loop; cap retries, then fail.
|
|
259
|
+
- `review` / exit `0`: stop for human approval; do not auto-commit.
|
|
260
|
+
- `allow`: commit.
|
|
261
|
+
- Run `aed check --staged --json` immediately before committing to check the
|
|
262
|
+
exact index.
|
|
263
|
+
- Exit `2` also covers CLI/git/config errors, so parse the JSON rather than
|
|
264
|
+
treating every failure as a finding.
|
|
265
|
+
|
|
266
|
+
### CI
|
|
267
|
+
|
|
268
|
+
```yaml
|
|
269
|
+
- uses: actions/checkout@v4
|
|
270
|
+
with:
|
|
271
|
+
fetch-depth: 0
|
|
272
|
+
- uses: actions/setup-python@v5
|
|
273
|
+
with:
|
|
274
|
+
python-version: "3.11"
|
|
275
|
+
- run: pip install -e .
|
|
276
|
+
- name: Guard
|
|
277
|
+
env:
|
|
278
|
+
BASE: ${{ github.event.pull_request.base.sha || github.event.before }}
|
|
279
|
+
run: aed check --base "$BASE" --json > aed.json
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
- `fetch-depth: 0` is required so `--base` is resolvable.
|
|
283
|
+
- This repository installs the guard with `pip install -e .`. In another project,
|
|
284
|
+
replace that line with a pinned `aedificatoria` package/commit install.
|
|
285
|
+
- If the event base is missing or the zero SHA, resolve
|
|
286
|
+
`git merge-base HEAD origin/main`; the repository workflow does this and the
|
|
287
|
+
HEAD~1 fallback already: [`.github/workflows/aed.yml`](.github/workflows/aed.yml).
|
|
288
|
+
- CI uses working-tree mode. `--staged` is for pre-commit.
|
|
289
|
+
- `review` exits `0`; to fail warnings too:
|
|
290
|
+
`jq -e '.verdict == "allow"' aed.json >/dev/null`.
|
|
291
|
+
- Upload `aed.json` as an artifact even on failure.
|
|
292
|
+
|
|
293
|
+
### Pre-commit and trust boundary
|
|
294
|
+
|
|
295
|
+
```sh
|
|
296
|
+
git config core.hooksPath .githooks
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
The hook runs `aed check --staged`; `--no-verify` can bypass it locally, so CI
|
|
300
|
+
is authoritative.
|
|
301
|
+
|
|
302
|
+
The guard is not a sandbox. Protect `aed.toml`, `aed-baseline.json`,
|
|
303
|
+
`docs/decisions/**`, `.githooks/pre-commit`, and `.github/workflows/aed.yml`
|
|
304
|
+
with `CODEOWNERS`/branch protection. `guard-config` detects verifier edits, but
|
|
305
|
+
an accepted ADR authorizes them; make ADR acceptance a human gate. Install `aed`
|
|
306
|
+
from a pinned version outside the agent-writable workspace when possible.
|
|
307
|
+
|
|
308
|
+
## Languages
|
|
309
|
+
|
|
310
|
+
| Language | Parser | Public API | Tests | Dependencies |
|
|
311
|
+
|---|---|---|---|---|
|
|
312
|
+
| Python | `ast` | top-level functions/classes, `__all__`, `__init__` re-exports | `test_*`, asserts, skip/xfail | absolute imports |
|
|
313
|
+
| Rust | tree-sitter | `pub` items, fields, variants, impl methods | `#[test]`, `assert!`, `#[ignore]` | `use` roots, Cargo tables |
|
|
314
|
+
| JS/TS | tree-sitter | ES/TS exports, CJS exports, methods | `test`/`it`/`describe`, `.skip`/`.only`, `.each` case tables | imports, `require`, `package.json` |
|
|
315
|
+
| C/C++ | tree-sitter C/C++ | header functions/classes/enums/typedefs, public members | GoogleTest/Catch2 macros, assertions, skips | local quoted includes, external angled headers |
|
|
316
|
+
|
|
317
|
+
Adapters live in `languages.py`; rule code is language-neutral. Rust/JS/TS is
|
|
318
|
+
AST-level: no macro expansion or type checking. JS/TS resolves nearest
|
|
319
|
+
`tsconfig.json`/`jsconfig.json` `baseUrl`/`paths` aliases, including local
|
|
320
|
+
`extends`; package-manager `extends` and unresolved aliases fall back to external
|
|
321
|
+
classification. `test.each`/`it.each` literal and template tables contribute
|
|
322
|
+
case counts; variable tables are recognized but not ratcheted. C/C++ API is
|
|
323
|
+
header-only; `.h` tries C++ then C when parse errors are lower. C/C++ includes
|
|
324
|
+
use quoted-local/angled-external classification, with C/C++ standard headers
|
|
325
|
+
allowed; CMake targets/dependencies, macros, templates, and ABI are not
|
|
326
|
+
resolved. With cargo installed and a root `Cargo.toml`, `aed check` adds
|
|
327
|
+
`cargo-advisory` info findings from `cargo metadata --no-deps --offline`.
|
|
328
|
+
|
|
329
|
+
## Limitations
|
|
330
|
+
|
|
331
|
+
- Default checks use the working tree; use `--staged` (or the hook) to check the
|
|
332
|
+
index.
|
|
333
|
+
- Complexity is a branch-count heuristic.
|
|
334
|
+
- Cycles are package-level (Python top-level packages, Rust crates), not
|
|
335
|
+
intra-package.
|
|
336
|
+
- Baseline keys use file plus symbol/function name; renames require a refresh.
|
|
337
|
+
- History uses current config, does not re-evaluate historical ADRs, and `--all`
|
|
338
|
+
does not recover squashed internals.
|
|
339
|
+
- GitHub/GitLab fallback modes are opt-in, non-hermetic, and require `gh`/`glab`.
|
|
340
|
+
- ADR quality is structural. Semantic test weakening and cumulative drift are
|
|
341
|
+
not fully detectable.
|
|
342
|
+
- C/C++ uses header declarations as API. Macros/templates are not expanded,
|
|
343
|
+
ABI is not checked, and CMake targets/dependencies are not parsed; package
|
|
344
|
+
edges use directory components and local quoted includes.
|
|
345
|
+
|
|
346
|
+
## Development
|
|
347
|
+
|
|
348
|
+
```sh
|
|
349
|
+
uv venv .venv
|
|
350
|
+
uv pip install -e '.[dev]'
|
|
351
|
+
.venv/bin/python -m pytest -q
|
|
352
|
+
.venv/bin/aed check
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
Design decisions: [`docs/decisions/`](docs/decisions/). Real-world audit notes:
|
|
356
|
+
[`docs/real-world-audit.md`](docs/real-world-audit.md). Dogfood the guard with:
|
|
357
|
+
|
|
358
|
+
```sh
|
|
359
|
+
git config core.hooksPath .githooks
|
|
360
|
+
aed check --base HEAD~1 # review the last commit
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
## License
|
|
364
|
+
|
|
365
|
+
MIT. See [`LICENSE`](LICENSE).
|