Purpose

In a hexagonal-architecture project, every bounded context is expected to carry the same layers: a domain for business rules, an application for use cases, and adapters for the outside world. This rule enforces that every context directory contains all three, so a context can never ship half-built or drift into an ad-hoc layout.

Configuration

rules:
  - name: context-layers
    type: directory-exists
    description: Each context has domain, application, and adapters layers
    within: src/contexts/{ctx}
    require: [domain, application, adapters]

within matches every context directory under src/contexts (the {ctx} segment captures one level and reads like a name); require lists the directories each match must contain.

Violation Example

The payments context has domain and application, but no adapters:

src/contexts/payments/
├── __init__.py
├── application/
└── domain/
    └── entities/
        └── payment.py

Passing Example

Add the missing layer so all three required directories are present:

src/contexts/payments/
├── __init__.py
├── adapters/
├── application/
└── domain/
    └── entities/
        └── payment.py

Output

$ psl check
src/contexts/payments
    [context-layers] Each context has domain, application, and adapters layers
    missing required directory 'adapters'

Found 1 violation(s).