2.1 KiB
ADR 0002: Layered Hexagonal Architecture
Status
Accepted
Context
Upcoming milestones add semantic understanding, world state, skill retrieval, workflow orchestration, multi-agent behavior, and cloud scheduling. Those features introduce LLM, embedding, HTTP, MCP, storage, and plugin concerns that must not leak into the device and domain contracts.
The device-agent-runtime-foundation design decision D7 records the governing
architecture: Hexagonal / Ports-and-Adapters with DDD-style domain boundaries.
Decision
Use this dependency direction:
core: domain models and errors. No framework, LLM, HTTP, MCP, or external device SDK dependencies.driver: adapters over external device SDKs, implementing theDrivercontract.device: device lifecycle management and active driver ownership.tools: capability layer called by the runtime. Tools use device/driver capabilities and do not import concrete drivers.perception: producesScenebehindPerceptionProvider.storage: persists timeline, task metadata, artifacts, and device config.runtime: application layer. Planner and Executor orchestrate tools, perception, storage, retries, and task state. LLM-backed planning first enters here.api: outermost transport adapter for REST, MCP, and future platform APIs.
Future milestones must build bottom-up through these boundaries. LLM and
transport dependencies may not be introduced into core, driver, device,
or tools.
Alternatives Considered
Leaving the layering implicit was rejected because upcoming AI-heavy milestones will otherwise tend to call LLM or transport APIs from convenient lower layers.
Adding lint enforcement now was deferred. The written architecture is the current source of truth; mechanical enforcement can be added when a concrete boundary violation or second-driver pressure appears.
Consequences
The runtime can add smarter planning and richer perception without changing the device capability contract. API and cloud concerns stay outside domain and adapter layers. Future OpenSpec designs must state how they uphold this dependency direction.