Skip to content

feat: architectural rule DSL — user-defined boundary enforcement #28

@bntvllnt

Description

@bntvllnt

Summary

Define a declarative DSL for architectural rules that enforces module boundaries, layer dependencies, and naming conventions — checked automatically via MCP and CI.

Motivation

Proposed DSL (.architecture.yml)

layers:
  - name: controllers
    match: "src/controllers/**"
    allowed-deps: [services, types]
    
  - name: services  
    match: "src/services/**"
    allowed-deps: [models, types, utils]
    
  - name: models
    match: "src/models/**"
    allowed-deps: [types]

rules:
  - name: no-circular-modules
    type: no-circular
    severity: error
    
  - name: max-coupling
    type: metric-threshold
    metric: coupling
    max: 0.7
    severity: warning
    
  - name: max-complexity
    type: metric-threshold  
    metric: cyclomaticComplexity
    max: 15
    severity: warning

Features

  1. Layer definitions: glob patterns → allowed dependency targets
  2. Metric thresholds: fail on coupling > X, complexity > Y
  3. Structural rules: no-circular, max-fan-out, required-tests
  4. Severity levels: error (blocks), warning (reports)
  5. Auto-generate: codebase-intelligence init-rules infers rules from existing structure

Acceptance Criteria

  • .architecture.yml schema defined and validated (zod)
  • Rules checked by enforce_architecture tool
  • init-rules command generates rules from existing graph
  • CI-friendly exit codes (0 = pass, 1 = violations)
  • Documentation with examples

Priority

Long-term — Builds on enforce_architecture (#21). High enterprise value.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions