Skip to main content

Module arch_rules

Module arch_rules 

Expand description

Layered-architecture rule validation.

Parses .codelore-arch-rules.toml at the repo root and exposes the rule set to the architecture-violations analysis. Each layer declares its path prefixes + which other layers it may depend on; the analysis flags imports that cross a forbidden boundary.

Format:

[layer."domain"]    paths = ["src/domain/"]    may_depend_on = []
[layer."app"]       paths = ["src/app/"]       may_depend_on = ["domain"]
[layer."infra"]     paths = ["src/infra/"]     may_depend_on = ["app", "domain"]

Matching rules:

  • A file’s layer is the first layer whose paths prefix-matches the file’s path. Order matters when paths nest.
  • Imports to external (npm / pypi / std) targets are skipped — they don’t have a layer.
  • Imports within the same layer are always allowed.
  • Imports to a layer not in the source’s may_depend_on list surface as violations.
  • Files outside every declared layer are unclassified — their imports are not validated. Documented in the config so users opt INTO coverage rather than being forced to cover the whole repo upfront.

Structs§

Layer
One declared architectural layer.
LayerRules
Complete parsed rule set.
Violation
One detected rule break. The analysis aggregates these into (src_path, target_path, src_layer, target_layer) rows for the emitter.

Constants§

ARCH_RULES_FILENAME
Conventional filename auto-discovered at the repo root, parallel to .codelore-teams and .codeloreignore.

Functions§

arch_rules_path