Search

0001: Keep the Domain Behind Hexagonal Ports

On this page

Status: Proposed Date: 2026-06-25 Supersedes: N/A Superseded by: N/A

Context

Tower is organized around DDD, Hexagonal Architecture, and a microkernel extension model. The domain owns VFS metadata, mutation rules, indexing behavior, extension routing contracts, and user-facing tool semantics. Infrastructure concerns include Sled persistence, real filesystem access, OS file watching, MCP transport, and sidecar process management.

The core constraint is that domain behavior must remain testable with in-memory doubles. If infrastructure leaks into domain/, domain tests become slower, less deterministic, and harder to reason about. It also weakens the port contracts that let real adapters and fakes share behavior.

Candidates

OptionProsCons
Keep strict hexagonal boundariesDomain remains deterministic, portable, and easy to test with fakesRequires explicit ports and adapter wiring
Allow pragmatic infrastructure imports in domain modulesShorter implementation path for some featuresCouples business rules to storage, transport, and OS behavior
Split the domain into pure and impure subdomainsMakes exceptions explicitCreates a second boundary that future changes can misunderstand

Decision

We will keep domain/ pure. Domain modules must not import Sled, std::fs, notify, MCP transport, process management, or sidecar implementation details. Domain behavior depends on port traits, and infrastructure is wired through adapters.

Inbound ports define use cases. Outbound ports define dependencies. Real adapters and in-memory fakes must implement the same contracts.

Consequences

What becomes easier:

  • Domain unit tests stay fast and deterministic.
  • Storage, filesystem, watcher, MCP, and sidecar implementations can evolve independently.
  • Adapter contract tests can verify real implementations against the same behavior as fakes.

What becomes harder:

  • New features need explicit port design before implementation.
  • Some simple-looking changes require adapter wiring and test doubles.

Constitution Compliance

PrincipleStatusJustification
Domain purityCompliantThe decision keeps infrastructure out of domain/.
TestabilityCompliantDomain behavior remains testable with in-memory doubles.
MaintainabilityCompliantBoundaries make ownership and dependency direction explicit.

View original on GitHub