Skip to content

Fix overlapping layer ownership - #19

Merged
Vashkatsi merged 1 commit into
mainfrom
fix/layer-ownership-contract
Aug 14, 2026
Merged

Fix overlapping layer ownership#19
Vashkatsi merged 1 commit into
mainfrom
fix/layer-ownership-contract

Conversation

@Vashkatsi

@Vashkatsi Vashkatsi commented Aug 14, 2026

Copy link
Copy Markdown
Owner

Summary

  • preserve every layer membership matched by collectors
  • evaluate each unique source-target membership pair while counting the code dependency once
  • apply external-import rules to every membership and keep Mermaid status pair-specific
  • stabilize report ordering for multi-membership violations
  • document the ownership contract and update the DDD recipe and roadmap

Root cause

DeplyRunner stored elements in every matching Layer, but code_element_to_layer retained only the last match. Dependency and external-import checks therefore depended on collector order and disagreed with element-based rules.

Impact

Collector and layer order no longer changes analysis semantics. Overlapping configurations may report multiple violations when multiple membership pairs are explicitly forbidden.

Verification

  • make check
  • Ruff: passed
  • mypy: passed
  • pip-audit: no known vulnerabilities
  • unittest: 174 tests passed

Summary by CodeRabbit

  • Bug Fixes

    • Dependency rules now correctly evaluate code assigned to multiple layers, including all applicable cross-layer combinations.
    • External import rules now apply consistently across every matching layer.
    • Reports now display violations in a stable, deterministic order.
  • Documentation

    • Clarified overlapping layer memberships, dependency evaluation, external-import behavior, and bounded-context rules.
    • Updated the roadmap to reflect resolved layer ownership and overlap semantics.

@coderabbitai

coderabbitai Bot commented Aug 14, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 7e241bac-fbc9-4ad6-8013-9bd3a9a5166a

📥 Commits

Reviewing files that changed from the base of the PR and between 4b30e38 and 8bd5a39.

📒 Files selected for processing (9)
  • README.md
  • deply/deply_runner.py
  • deply/reports/report_generator.py
  • doc/architectures/ddd-bounded-contexts.md
  • doc/configuration.md
  • doc/technical-roadmap.md
  • tests/test_deply_runner.py
  • tests/test_external_import_rule.py
  • tests/test_reports.py

📝 Walkthrough

Walkthrough

The runner now preserves multiple layer memberships per code element, evaluates rules across distinct layer pairs, and applies external-import rules to every matching layer. Reports sort violations deterministically. Documentation and tests describe and verify these semantics.

Changes

Layer analysis and reporting

Layer / File(s) Summary
Multi-layer membership and rule evaluation
deply/deply_runner.py, tests/test_deply_runner.py, tests/test_external_import_rule.py, README.md, doc/configuration.md, doc/architectures/ddd-bounded-contexts.md, doc/technical-roadmap.md
DeplyRunner preserves all matching layers for each code element. Dependency checks evaluate each distinct cross-layer pair. External-import checks cover every matching layer. Tests and documentation reflect the updated behavior.
Deterministic violation reporting
deply/reports/report_generator.py, tests/test_reports.py
ReportGenerator sorts violations by code, path, location, and message. A regression test verifies ordering for violations at the same location.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to 8bd5a

The change updates layer-membership analysis and report ordering, with the stated checks and 174 tests passing; no actionable merge-blocking risk remains beyond normal review.

Sequence Diagram(s)

sequenceDiagram
  participant CodeAnalyzer
  participant DeplyRunner
  participant ExternalImportRule
  CodeAnalyzer->>DeplyRunner: Return dependency results
  DeplyRunner->>DeplyRunner: Evaluate distinct source-target layer pairs
  DeplyRunner->>ExternalImportRule: Check each file-layer membership
  ExternalImportRule-->>DeplyRunner: Return layer-specific violations
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the primary change: preserving overlapping layer memberships.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/layer-ownership-contract

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Vashkatsi
Vashkatsi marked this pull request as ready for review August 14, 2026 13:22
@Vashkatsi
Vashkatsi merged commit 6368e21 into main Aug 14, 2026
14 checks passed
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