Skip to main content

iil-adrfw

ADR Framework for the IIL Platform — schema validation, loader normalization, constitution graph, audit tooling.

PyPI Python 3.12+ License: MIT

What it does

  • Schema v3 — strict JSON Schema for ADR frontmatter with additionalProperties: false
  • Phase 1 Normalizer — 15+ field aliases, status normalization, type coercion, reference extraction
  • Phase 2 Validator — jsonschema validation against adr_frontmatter.schema.json
  • Phase 3 Domain — typed ADR dataclass with Status enum, temporal fields, relations
  • Constitution Graph — cross-ADR dependency/supersession graph with cycle detection
  • Audit — staleness checks, implementation evidence verification, drift detection
  • CLI + MCP Serveriil-adrfw CLI and iil-adrfw-mcp FastMCP server

Real-world validation

Tested against 239 real platform ADRs (as of v0.8.0):

Mode Result
Schema validation 239/239 (100%)
Staleness (>6mo) 0 stale
Runtime packages installed 12

Installation

pip install iil-adrfw

That is the lean install — 12 runtime packages, everything needed to load, validate, graph, audit, diff, narrate and propose ADRs. Two capabilities are optional extras because they carry heavy dependency trees most consumers never use:

Extra Install Adds Needed for
mcp pip install 'iil-adrfw[mcp]' FastMCP the iil-adrfw-mcp server
checkers pip install 'iil-adrfw[checkers]' libcst iil-adrfw check, validate-cross-repo
all pip install 'iil-adrfw[all]' both the pre-0.8 footprint

If you invoke something that needs an extra you don't have, the CLI says exactly which one and exits 2 (configuration error) — it never fails silently.

# From source with dev dependencies:
python3 -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"

# PEP-668-managed hosts without a venv (fallback only):
pip install --user --break-system-packages -e ".[dev]"

Using it from another repo

The framework assumes the layout every ADR-carrying repo already uses: docs/adr/ADR-*.md. With that, nothing needs configuring.

1. Gate ADRs in CI

Call the reusable workflow — no copy-pasted steps to drift:

# .github/workflows/adr-validate.yml
name: ADR Validation
on:
  pull_request:
    paths: ["docs/adr/**"]
  push:
    paths: ["docs/adr/**"]

jobs:
  adr:
    uses: achimdehnert/iil-adrfw/.github/workflows/_adr-validate.yml@main
    with:
      adr-dir: docs/adr      # optional, this is the default
      audit: true            # also run the constitution audit (non-gating)

2. Gate ADRs before the commit

# .pre-commit-config.yaml
repos:
  - repo: https://github.com/achimdehnert/iil-adrfw
    rev: v0.8.0
    hooks:
      - id: adr-validate

3. Configuration

Everything is resolvable three ways, with this precedence: CLI flag → environment variable → default.

What Flag Environment variable Default
ADR directory --adr-dir IIL_ADRFW_ADRS_DIR docs/adr
JSON schemas --schema-dir IIL_ADRFW_SCHEMAS_DIR bundled with the package
Repo root IIL_ADRFW_REPO_ROOT .

The bundled schemas are the default, so a pip install is self-sufficient — you never have to vendor a schemas/ directory or point an env var at a checkout.

4. Exit codes

Every subcommand honours the same contract, so CI can branch on it:

Code Meaning
0 Success, no findings
1 Findings or violations present
2 Configuration or invocation error (bad args, missing/empty ADR dir, missing extra)
3 Internal error

An empty or missing ADR directory is an error (2), never a clean bill of health. A pipeline pointed at the wrong path fails loudly instead of reporting health score 1.000 over zero ADRs. Repos that legitimately have no ADRs yet pass --allow-empty.

Usage

Python API

The common entry points are re-exported at the top level, so they stay stable even if the internal module layout moves. The package ships py.typed, so these types are visible to mypy in your repo:

from pathlib import Path
from iil_adrfw import ConstitutionGraph, get_schema_dir, load_adr, load_adrs, run_audit

# The bundled schemas are the default — nothing to vendor or configure.
adrs = load_adrs(Path("docs/adr"), get_schema_dir())

graph = ConstitutionGraph(adrs)
report = run_audit(graph)          # AuditReport: .findings + .health snapshot
print(report.health.score, len(report.findings))

# Single ADR
adr = load_adr(Path("docs/adr/ADR-099.md"), get_schema_dir())

# Diagnosis mode: see what the loader sees BEFORE normalization. Pair raw=True
# with validate=False — un-normalized frontmatter will not satisfy the schema,
# and that is the point (it shows which ADRs rely on the loader's tolerance).
raw = load_adr(Path("docs/adr/ADR-099.md"), get_schema_dir(), validate=False, raw=True)

CLI

Every subcommand accepts --adr-dir and falls back to $IIL_ADRFW_ADRS_DIR and then docs/adr. Subcommands that historically took a positional directory still accept it.

# Validate all ADR frontmatters against the schema
iil-adrfw validate                        # uses docs/adr
iil-adrfw validate --adr-dir docs/adr     # explicit
iil-adrfw validate docs/adr/              # positional, still supported

# Staleness (>6 months), broken references, missing reviews
iil-adrfw staleness --months 6

# Constitution-level health audit
iil-adrfw audit --json

# Which ADRs govern a given file?
iil-adrfw impact apps/billing/models.py

# Do the ADRs still describe the repo? (versions, ports, images)
iil-adrfw freshness --repo-path .

# Query by question, domain, or path
iil-adrfw query --question "Which ADR governs deployment?"

# Dependency graph (text, DOT, or JSON)
iil-adrfw graph --dot > graph.dot

# Outline-compatible markdown registry
iil-adrfw export -o adr-registry.md

# INDEX.md table (ADR-138 Impl column); --table-only for the bare block
iil-adrfw index -o docs/adr/INDEX.md

# Schema v4 controlling metrics
iil-adrfw metrics --report

Full surface: validate, staleness, graph, export, index, check, explain, list, validate-cross-repo, query, audit, propose, diff, narrate, metrics, freshness, impact.

MCP Server (12 tools)

pip install 'iil-adrfw[mcp]'
iil-adrfw-mcp  # stdio transport

Register it with the ADR directory of the repo it should serve:

{
  "mcpServers": {
    "iil-adrfw": {
      "type": "stdio",
      "command": "iil-adrfw-mcp",
      "env": { "IIL_ADRFW_ADRS_DIR": "/abs/path/to/repo/docs/adr" }
    }
  }
}

Tools: adr_validate, adr_staleness, adr_impact, adr_check, adr_explain, adr_query, adr_audit, adr_validate_cross_repo, adr_propose, adr_diff, adr_narrate, adr_freshness

Schema v3 highlights

  • 5 new fields: updated, version, review_status, owner, implementation_done_when
  • 3 removed fields: glossary, review_cadence, next_review_date
  • Status enum: {draft, proposed, accepted, deprecated, superseded, rejected, experimental}
  • Implementation status: {none, planned, in_progress, partial, implemented, complete, verified, rolled_back}

Loader normalizations (Phase 1)

Step What
C.1 12 field aliases (datedecision_date, authorowner, etc.)
C.2 Status normalization (case, suffixes)
C.3 Scalar-to-list auto-wrapping
C.4 Reference field normalization (ADR-NNN extraction)
C.5 ID inference, title inference, domains default, deciders default
C.6 Amended-format normalization
C.7 implemented field → implementation_status mapping
C.8 Strip unknown properties

See SCHEMA_V3_SPEC.md for full specification.

Running tests

make test   # python3 -m pytest examples/  (the full suite lives in examples/)

Project structure

iil-adrfw/
├── schemas/                    # JSON Schema files
│   ├── adr_frontmatter.schema.json
│   ├── adr_rules.schema.json
│   └── constitution.schema.json
├── src/iil_adrfw/
│   ├── persistence/            # Loader (normalize + validate + construct)
│   ├── domain/                 # ADR dataclass, Status enum
│   ├── graph/                  # Constitution graph
│   ├── audit/                  # Staleness, evidence checks
│   ├── checkers/               # AST-based code checkers
│   ├── cli.py                  # CLI entry point
│   └── server.py               # FastMCP server
├── examples/                   # Example ADRs + test suites
├── SCHEMA_V3_SPEC.md          # Full v3 specification
└── SCHEMA_V3_CHANGELOG.md     # Changelog for downstream consumers

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

iil_adrfw-0.8.0.tar.gz (192.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

iil_adrfw-0.8.0-py3-none-any.whl (100.4 kB view details)

Uploaded Python 3

File details

Details for the file iil_adrfw-0.8.0.tar.gz.

File metadata

  • Download URL: iil_adrfw-0.8.0.tar.gz
  • Upload date:
  • Size: 192.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for iil_adrfw-0.8.0.tar.gz
Algorithm Hash digest
SHA256 b8b09a253458035d2314e622e2ff18f1bca4eab152bfaa7c2cf6b76d2e7063cc
MD5 b922e4d5fc26e9e3e1c72ac810f7140a
BLAKE2b-256 4594c73825dc306d83d1064b4f0627c27efe99f3dab706edf1336f765450f8a9

See more details on using hashes here.

Provenance

The following attestation bundles were made for iil_adrfw-0.8.0.tar.gz:

Publisher: publish.yml on achimdehnert/iil-adrfw

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file iil_adrfw-0.8.0-py3-none-any.whl.

File metadata

  • Download URL: iil_adrfw-0.8.0-py3-none-any.whl
  • Upload date:
  • Size: 100.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for iil_adrfw-0.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5a5046eae4054f521d39ecf8250a1bdca82abde7bea983cfd4d83af8a8b132aa
MD5 8af1f3a80692fb1dd4346fa923a96543
BLAKE2b-256 10f0680b47c979d3be6c5a0e6255ec981954ba675e944190f75c91b09aed5dee

See more details on using hashes here.

Provenance

The following attestation bundles were made for iil_adrfw-0.8.0-py3-none-any.whl:

Publisher: publish.yml on achimdehnert/iil-adrfw

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.8.0 This release

2 files

0.7.2

2 files

0.7.1

2 files

0.7.0

2 files

0.6.0

2 files

0.5.0

2 files

0.3.1

2 files

0.3.0

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page