aws-samples / aws-samples/sample-autonomous-cloud-coding-agents
feat(ci): mechanical module-boundary enforcement (eslint-plugin-boundaries/dependency-cruiser + madge) (CA-03)
- Lingua principale
- TypeScript
- Stelle
- 143
- Fork
- 46
- Merge medio
- 3g 10h
- PR unite (30g)
- 24
Descrizione
> **This is a finding from https://github.com/krokoko/cairn** (action item **CA-03**).
### Component
Tooling / CI
### Describe the feature
Add **mechanical module-boundary enforcement** that encodes the `AGENTS.md` routing table as code, using `eslint-plugin-boundaries` or `dependency-cruiser`, plus `madge --circular` for circular-dependency detection. Start the boundary rules in **warn** mode, snapshot the current baseline, then flip to **error** once the baseline is clean.
Boundaries to enforce (from `AGENTS.md`):
- Handler layer (`cdk/src/handlers/`) can't import stack/construct internals (`cdk/src/stacks/`, `cdk/src/constructs/`).
- CLI (`cli/src/`) can't import CDK internals.
- No circular dependencies anywhere.
### Use case
The `AGENTS.md` layering rules are **prose, not mechanically enforced** (AI007 / AI003). Nothing stops an agent — or a human — from introducing an import that violates the intended architecture, and circular dependencies go undetected. A boundary linter turns the routing table into a binding fitness function that catches architectural drift at PR time instead of in review.
### Proposed solution
1. Add `eslint-plugin-boundaries` (or `dependency-cruiser`) to `cdk` / `cli` and encode the `AGENTS.md` routing table as boundary rules.
2. Add `madge --circular` as a fast check (pre-commit + CI).
3. Land the rules in **warn** mode; record the current violation baseline.
4. Once the baseline is clean, flip to **error** and add to the required `build` check.
### Acceptance criteria
- [ ] Boundary rules encode the `AGENTS.md` routing table (handler↛stack/construct internals; CLI↛CDK internals).
- [ ] `madge --circular` runs in pre-commit and CI; zero circular deps in the clean baseline.
- [ ] Rules start in **warn**; baseline violations are documented.
- [ ] A follow-up flips clean rules to **error** in the required `build` check.
- [ ] Remediation text on failures is agent-targeted (what to fix, not just what failed).
### Other information
Source reports: `readiness-roadmap.md`, `verification-strategy.md` (§"Architecture Fitness Functions", maturity 0→3), `ai-smells-gates-report.md` (AI003/AI007). Effort: **S–M**. Calibrate permissively — agents route around hard blockers, so introduce the error line only after the code is behind it. Per ADR-003 this issue needs the `approved` label before work begins.
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia leggendo AGENTS.md e le sezioni sull’architettura in readiness-roadmap.md e verification-strategy.md. Ispeziona gli import in cdk/src/handlers/, cdk/src/stacks/, cdk/src/constructs/ e cli/src/, quindi esegui madge --circular per stabilire la baseline. Il lavoro è completato quando le regole dei boundary e il controllo delle dipendenze circolari vengono eseguiti in pre-commit e CI, con avvisi documentati, testo per la remediation e un percorso verso l’imposizione della build richiesta.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- eslint, typescript
- Ambito
- build-system, ci-cd, tooling
- Tipo di issue
- Funzionalità
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Tranquilla
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 48/100