feat: add because rule rationales#15
Open
TristanKruse wants to merge 9 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Adds user-facing rationale strings to fluent architecture rules via .because(...), and threads that rationale into assertion failure formatting. In the same change set, it also introduces a .archignore mechanism to exclude files/directories from analysis/metrics, plus release-metadata synchronization scripts and CI checks.
Changes:
- Add
RuleRationaleMixinwith.because(...)/.because_reason, and include rationale inassert_passes()/format_violations(). - Add
.archignoresupport to the graph/file discovery pipeline and ensure metrics/class extraction respect it. - Add release-metadata tooling (
scripts/) and CI steps (metadata check, build) to keep versions synchronized and validate packaging.
Reviewed changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/metrics/test_metrics_fluentapi.py | Adds a regression test ensuring file metrics respect .archignore. |
| tests/integration/test_e2e.py | Adds integration coverage for rationale inclusion in assertion/format output. |
| tests/files/test_files_fluentapi.py | Adds unit coverage for .because_reason and empty rationale validation. |
| tests/common/test_extract_graph.py | Adds tests for .archignore pattern handling and exclusion behavior in graph extraction. |
| src/archunitpython/testing/assertion.py | Extends violation formatting to optionally include a “Because:” rationale; assert_passes() forwards rule rationale. |
| src/archunitpython/slices/fluentapi/slices.py | Enables .because(...) on slice rule conditions via the new mixin. |
| src/archunitpython/metrics/fluentapi/metrics.py | Enables .because(...) on metric conditions; updates file scanning to use resolved exclude patterns (incl. .archignore). |
| src/archunitpython/metrics/extraction/extract_class_info.py | Ensures class extraction uses resolved exclude patterns (incl. .archignore). |
| src/archunitpython/files/fluentapi/files.py | Enables .because(...) on file rule conditions via the new mixin. |
| src/archunitpython/common/fluentapi/checkable.py | Introduces RuleRationaleMixin and .because(...) API with validation. |
| src/archunitpython/common/fluentapi/init.py | Exposes RuleRationaleMixin from the fluentapi package. |
| src/archunitpython/common/extraction/extract_graph.py | Adds .archignore loading and expanded exclude matching logic; adjusts dependency target handling for excluded files. |
| src/archunitpython/common/init.py | Exposes RuleRationaleMixin from archunitpython.common. |
| scripts/check_release_metadata.py | New script to validate pyproject.toml version, package __version__, and changelog heading alignment. |
| scripts/bump_release_version.py | New script to update version fields for semantic-release. |
| README.md | Documents .archignore and .because(...) usage. |
| pyproject.toml | Adds build to dev dependencies for CI packaging validation. |
| BACKLOG.md | Marks .archignore, .because(...), and release checks as completed. |
| .releaserc.json | Switches semantic-release prepare step to use the new bump script and commits __init__.py version updates. |
| .github/workflows/integrate.yaml | Adds release-metadata check, expands ruff scope to scripts/, and builds the package in CI. |
Comments suppressed due to low confidence (1)
src/archunitpython/testing/assertion.py:21
- The
format_violations()docstring doesn’t document the newbecauseparameter, so users reading the API docs won’t know how to include a rationale when calling this helper directly.
Args:
violations: List of violations to format.
Returns:
Formatted string describing all violations.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+140
to
+144
| ### Excluding Files With `.archignore` | ||
|
|
||
| Add a `.archignore` file to your project root to permanently exclude generated or | ||
| irrelevant files from architecture checks and file-based metrics: | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request
Adds
.because(...)support to architecture rules so users can attach a human-readable rationale to a rule.When
assert_passes(...)fails, the rationale is included in the failure message. This makes architecture test failures easier to understand and prepares the API for future generated architecture documentation.Example: