Contracts Layer

June 5, 2026 · View on GitHub

中文 | English

Contracts Layer

This layer owns stable contracts and product-domain models that can be shared by execution, services, adapters, assembly, and interfaces without pulling implementation details upward.

Modules

CrateResponsibilityLocal doc
core-typesShared DTOs, errors, session/surface data, and small value typesAGENTS.md
eventsEvent payloads and emitter contractsAGENTS.md
product-domainsProduct domain DTOs, rules, policies, and narrow portsAGENTS.md
runtime-portsRuntime-facing traits and ports used by owner cratesAGENTS.md

Placement Rules

  • Add a type here only when it is stable across more than one owner layer.
  • Keep contracts behavior-light: validation helpers are acceptable; runtime, filesystem, network, UI, or platform behavior is not.
  • Prefer narrow DTOs or traits over broad facade objects.
  • If a type is only needed by one runtime or product crate, keep it with that crate until a second owner needs it.

Dependency Boundaries

  • This layer may depend on workspace primitives and other contract crates.
  • It must not depend on execution, services, adapters, assembly, interfaces, src/apps, frontend packages, Tauri, or OS-specific adapters.
  • New dependencies must stay minimal and justified by contract shape, not by implementation convenience.