ArchUnitPython icon indicating copy to clipboard operation
ArchUnitPython copied to clipboard

[FEATURE] Independence contracts (mutual independence)

Open LukasNiessen opened this issue 4 months ago • 0 comments

In short

Say three feature modules should never import each other. Today you'd write a separate rule for every pair. This lets you say it once: 'these modules are mutually independent.'

Problem

Enforcing that a group of sibling modules stay decoupled is a common need; expressing it today requires N×(N-1) pairwise should_not().depend_on_files() rules that are easy to get wrong or leave incomplete. A single independence assertion is declarative and complete.

Proposal

Add a mutual-independence assertion to the existing slices API, e.g. project_slices("src/").defined_by("src.features.(*)").should_not().depend_on_each_other() — one rule instead of N×(N-1) pairwise file rules.

Acceptance criteria

  • [ ] project_slices("src/").defined_by("src.features.(*)").should_not().depend_on_each_other() fails if any slice imports another, naming the edge.
  • [ ] Works with the existing defined_by / defined_by_regex slice definitions.
  • [ ] Empty-test protection applies.

LukasNiessen avatar Jul 26 '26 20:07 LukasNiessen