# DDR-0002: Dispatcher Lives in messages/dispatcher.py

Status: Accepted  
Date: 2025-12-22  
Related ADRs: ADR-0007 (E27 API Message Layer Architecture)

## Context

The E27 implementation requires a dispatcher that routes inbound JSON messages
by `(domain, command)` rather than by M1-style opcodes.

There was a choice between placing this dispatcher in the top-level `message.py`
(for familiarity with M1) or in the `messages/` subpackage.

## Decision

The E27 dispatcher is implemented in:

elkm1/elke27_lib/messages/dispatcher.py

The top-level `message.py` may act as a thin facade or re-export, but must not
contain the primary dispatch logic.

## Rationale

- Prevents `message.py` from becoming large and tightly coupled
- Avoids circular imports between dispatcher, registry, and domain handlers
- Keeps dispatcher logic close to registry and inventory code
- Makes dispatcher unit-testable in isolation

## Consequences

- `messages/*` modules must not import `message.py`
- All dispatch entrypoints ultimately delegate to `messages.dispatcher`
- `message.py` changes should be rare once dispatcher is stable
