Skip to content

✨ feat: Add optional description field to rules#24

Merged
heumsi merged 1 commit intomainfrom
feat/add-rule-description
Mar 31, 2026
Merged

✨ feat: Add optional description field to rules#24
heumsi merged 1 commit intomainfrom
feat/add-rule-description

Conversation

@heumsi
Copy link
Copy Markdown
Owner

@heumsi heumsi commented Mar 31, 2026

Summary

  • Add an optional description field to Rule that provides human-readable context for why a rule exists
  • Show description in violation output when present, helping users understand violations at a glance
  • Update violation output format so the arrow line (source → imported) is always on its own line for consistency

Output format

With description:

contexts/boards/domain/models.py:6
    [domain-isolation] Domain layer must remain pure
    contexts.boards.domain → contexts.boards.application.service (local)

Without description (backward compatible):

contexts/boards/domain/models.py:6
    [domain-isolation]
    contexts.boards.domain → contexts.boards.application.service (local)

Config example

rules:
  - name: domain-isolation
    modules: contexts.*.domain
    description: Domain layer must remain pure  # optional
    allow:
      standard_library: [dataclasses, typing]

Changed files

  • config.pyRule dataclass + parsing
  • checker.pyViolation dataclass + propagation
  • matcher.pymerge_rules preserves description
  • reporter.py — output format
  • tests/ — test_config, test_checker, test_matcher, test_reporter
  • docs/ — config-schema, rules guide, getting-started

Test plan

  • description parsed from YAML config
  • description parsed from TOML config
  • description is None when omitted
  • Violation carries rule_description for both allow and deny violations
  • merge_rules preserves first rule's description
  • Reporter shows description when present
  • Arrow line always on separate line
  • All 100 tests pass

🤖 Generated with Claude Code

Add an optional `description` field to rules that is shown in violation
output, helping users understand why a rule exists and why a violation
was reported. The violation output format is updated so the arrow line
is always on its own line for consistency.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@heumsi heumsi merged commit 45176b9 into main Mar 31, 2026
5 checks passed
@heumsi heumsi deleted the feat/add-rule-description branch March 31, 2026 15:51
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