# DDR-0013: One-Way Import Rule for the messages Package

Status: Accepted  
Date: 2025-12-22  
Related ADRs: ADR-0007 (E27 Layering)

## Context

The E27 message layer will be split into a messages/ subpackage with multiple modules.
Without explicit import discipline, circular imports can easily appear between:
- top-level message facade
- dispatcher
- registry
- domain handlers
- shared types

## Decision

Enforce a one-way import rule:

- messages/* modules MUST NOT import elkm1/elke27_lib/message.py (the facade).
- message.py (facade) MAY import from messages/* to re-export public entrypoints.
- Domain handler modules should import only:
  - messages/types.py (shared types)
  - local helpers within messages/*
  - and must not import the dispatcher or registry unless strictly necessary.

## Rationale

- Prevents circular imports and side-effect-driven initialization bugs
- Keeps dispatcher/registry testable and predictable
- Maintains a clean dependency graph consistent with layered design

## Consequences

- message.py must remain thin (re-exports only)
- messages/__init__.py should avoid heavy imports that trigger domain loading unnecessarily
- Reviewers should reject PRs that violate the one-way import rule
