Skip to content

feat(enforcement): add mypy, tsconfig, and import-linter adapters#17

Merged
kschlt merged 3 commits into
mainfrom
feat/config-adapters
Apr 2, 2026
Merged

feat(enforcement): add mypy, tsconfig, and import-linter adapters#17
kschlt merged 3 commits into
mainfrom
feat/config-adapters

Conversation

@kschlt

@kschlt kschlt commented Apr 2, 2026

Copy link
Copy Markdown
Owner

Why

The enforcement pipeline had adapters for ESLint and Ruff but lacked support for mypy, TypeScript tsconfig, and Python import-linter. Users who define architectural constraints (e.g., layer boundaries, type-checking overrides) in their ADR contracts had no way to enforce them via these commonly used tools.

Approach

Three new adapters following the established BaseAdapter pattern:

  • MypyAdapter: Generates .mypy-adr.ini from config_enforcement.python.mypy contract data. Produces per-module [mypy-<module>] sections with overrides like disallow_untyped_defs.
  • TsconfigAdapter: Generates tsconfig.adr.json from config_enforcement.typescript.tsconfig contract data. Outputs a standard compilerOptions JSON structure.
  • ImportLinterAdapter: Generates .importlinter-adr from architecture.layer_boundaries contract data. Produces INI-format import-linter contracts defining forbidden cross-layer imports.

Key design decisions:

  • Standalone config files (not pyproject.toml sections) — matches the existing pattern (.ruff-adr.toml, .eslintrc.adrs.json) and avoids modifying user-owned config files.
  • ConflictDetector extended with INI conflict detection for the new ini_file fragment type, so drift between generated and on-disk files is caught.
  • All three adapters registered in EnforcementPipeline alongside existing ones.

What Was Tested

  • Unit tests for each adapter: correct INI/JSON generation from contract data, empty-input handling, proper section/key formatting.
  • ConflictDetector INI parsing: detection of value conflicts, missing sections, missing keys in INI fragments.
  • Pipeline registration: all three adapters appear in the pipeline's adapter list.
  • 443 tests pass, mypy clean, ruff clean.

Risks

Additive changes only — no existing adapter behavior is modified. The new adapters only activate when the corresponding contract sections exist. Existing pipelines without these contract sections are unaffected.

kschlt added 3 commits April 2, 2026 10:47
The .agent/CLAUDE.md (V2) renamed "task" to "item" throughout the
workflow system, but the root CLAUDE.md still referenced the old
next_task.py script and used "task" terminology. This updates the
Task Workflow section to match, fixing stale script references.
Three new enforcement adapters that read from the compiled constraints
contract and generate native config files, following the BaseAdapter
pattern established by ESLint/Ruff:

- MypyAdapter: .mypy-adr.ini from config_enforcement.python.mypy
- TsconfigAdapter: tsconfig.adr.json from config_enforcement.typescript.tsconfig
- ImportLinterAdapter: .importlinter-adr from architecture.layer_boundaries

Also extends ConflictDetector with INI conflict detection for the new
ini_file fragment type, and registers all three in the EnforcementPipeline.

Standalone files chosen over pyproject.toml sections to match the
established pattern (.ruff-adr.toml, .eslintrc.adrs.json) and avoid
modifying user config files.
@kschlt kschlt merged commit 1d7d2ad into main Apr 2, 2026
8 checks passed
@kschlt kschlt deleted the feat/config-adapters branch April 2, 2026 23:04
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