Skip to content

ArchUnit-style Rules API (Python, Code-first) #35

@akhundMurad

Description

@akhundMurad

Defining architecture rules purely via configuration files becomes hard to maintain as complexity grows.

Many users want to express architecture constraints as code, similar to ArchUnit in the Java ecosystem:

  • with IDE autocomplete
  • reusable rule definitions
  • composable logic

This issue proposes introducing a Python-based rules API, allowing users to write architecture rules in code instead of YAML.

Example (conceptual)

from pacta import rule

@rule
def domain_must_not_depend_on_infrastructure(dep):
    return not dep.from_layer("domain").to_layer("infrastructure")

Why this matters

  • Improves developer experience
  • Enables reuse and abstraction of rules
  • Makes complex rules easier to express and test

Acceptance Criteria

  • Users can define rules in Python
  • Rules integrate with existing Pacta CLI and CI workflow
  • Clear mapping between rule failures and architecture elements
  • YAML-based rules remain supported

Out of scope

  • Plugin marketplace
  • Enterprise rule packs

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions