aws-samples / aws-samples/sample-autonomous-cloud-coding-agents

feat(ci): mechanical module-boundary enforcement (eslint-plugin-boundaries/dependency-cruiser + madge) (CA-03)

Open
#254 0 comments 0 reactions 0 assignees View on GitHub
tooling validation-loop
Dominant language
TypeScript
Stars
143
Forks
46
Avg merge
3d 9h
Merged PRs (30d)
20

Description

> **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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.