Skip to content

feat(enforce): complete enforcement loop with script/CI generators and docs update#11

Merged
kschlt merged 3 commits intomainfrom
feat/enforcement-loop
Mar 23, 2026
Merged

feat(enforce): complete enforcement loop with script/CI generators and docs update#11
kschlt merged 3 commits intomainfrom
feat/enforcement-loop

Conversation

@kschlt
Copy link
Copy Markdown
Owner

@kschlt kschlt commented Mar 23, 2026

Why

ADR enforcement currently requires manual setup of validation scripts and CI pipelines. Teams approve ADRs but have no automated path from policy definitions to running checks in CI. This closes the loop: approved ADRs automatically produce runnable enforcement infrastructure. Project documentation still referenced enforcement as planned — it now accurately reflects the current state.

Approach

Built in three layers:

  1. Reporter + Architecture checks — A structured JSON reporter (EnforcementReport Pydantic model) gives CI and agents machine-readable output with fix suggestions and ADR references. Architecture layer boundary enforcement detects cross-layer imports in Python and JS/TS using regex-based import parsing with glob/directory-name file filtering. Enriched the Violation dataclass with adr_title and fix_suggestion across all check types.

  2. Script + CI workflow generatorsScriptGenerator produces standalone stdlib-only Python validation scripts from ADR policies (import, pattern, architecture, structure checks) with a validate_all.py runner outputting JSON per the EnforcementReport schema. CIWorkflowGenerator produces GitHub Actions YAML that runs enforcement, posts structured PR comments, and fails on violations. Both use managed-file headers for safe regeneration.

  3. Documentation update — Updated CHANGELOG, ROADMAP, README, and TECHNICAL to reflect the completed enforcement loop, staged enforcement, and DX polish as implemented (not planned). Restructured ROADMAP: moved 3 completed items to "Recently Completed", new "Up Next" = pattern linter adapters + config enforcement. Updated policy schema status table, added enforcement CLI commands to TECHNICAL, fixed test count (187→309), added 2 FAQ entries about staged enforcement and CI generation.

Key trade-off: generated scripts use only stdlib so they run anywhere without installing adr-kit as a dependency in the target project's CI.

What Was Tested

  • Reporter serialization: round-trip JSON output with violations, fix suggestions, and ADR references
  • Architecture layer checks: cross-layer import detection for Python and JS/TS, boundary rule parsing
  • Script generator: 26 tests covering all check types via subprocess execution of generated scripts
  • CI workflow generator: YAML structure, PR comment formatting, managed-file header detection
  • Integration with approval workflow: script generation triggered on ADR approval
  • Documentation: verified no remaining references to enforcement as "planned" or "on the roadmap"

Risks

  • Regex-based import detection may miss aliased or dynamic imports — acceptable for a first pass, documented as a known limitation
  • Generated scripts are standalone and may drift from the core validator logic over time

kschlt added 3 commits March 23, 2026 08:19
…hecks

Implements ENF Step 1+2: a structured JSON reporter for CI/agent
consumption (--format json flag) and architecture layer boundary
enforcement that detects cross-layer imports in Python and JS/TS files.

Reporter converts ValidationResult into a Pydantic EnforcementReport
model with fix suggestions and ADR references. Architecture checks
parse "source -> target" boundary rules and use regex-based import
detection with glob/directory-name file filtering.

Enriches Violation dataclass with adr_title and fix_suggestion fields
across all check types to support actionable output.
Implements Steps 3-4 of the enforcement loop:

ScriptGenerator produces standalone stdlib-only Python validation scripts
from ADR policies (import, pattern, architecture, structure checks) with
a validate_all.py runner outputting JSON per EnforcementReport schema.
Uses chr() to embed regex patterns safely in f-string-generated code.

CIWorkflowGenerator produces GitHub Actions YAML that runs enforcement,
posts structured PR comments, and fails on violations. Uses managed-file
headers for safe overwrites.

Adds generate-scripts and generate-ci CLI commands and integrates script
generation into the approval workflow. 26 new tests covering both
generators via subprocess execution.
…mpletion

Staged enforcement, complete enforcement loop, and DX polish are all
implemented. Update CHANGELOG, ROADMAP, README, and TECHNICAL to
accurately describe current capabilities instead of listing them as
planned.
@kschlt kschlt changed the title feat(enforce): add enforcement loop with script/CI generators feat(enforce): complete enforcement loop with script/CI generators and docs update Mar 23, 2026
@kschlt kschlt merged commit 3d98003 into main Mar 23, 2026
8 checks passed
@kschlt kschlt deleted the feat/enforcement-loop branch March 23, 2026 08:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant