Search docs...⌘/
Search docs...⌘/
DocsADRsADR-007: Dependency Rules & Import Restrictions
ADR-007: Dependency Rules & Import Restrictions
Architectural Decision Record 7 mapping core software structure decisions.
Status
Proposed
Context
In a multi-package monorepo, it is easy to introduce circular dependencies or violate architectural boundaries by importing modules across package limits. For example, a business agent importing OpenRouter clients directly bypasses the runtime abstraction. We need a strict set of dependency rules enforced at the monorepo level.
Decision
We will restrict import paths between monorepo packages using TypeScript project references and ESLint boundaries:
- Runtime (
packages/ai): Depends only onschemaandcore. Must never importagent-sdk,agents, or Electron. - SDK (
packages/agent-sdk): Depends onai(interfaces only) andschema. Must never importagents, Electron, or SQLite connections. - Agents (
packages/agents): Depends onagent-sdkandschema. Must never import provider-specific code or raw HTTP clients. - Desktop App (
apps/desktop): Serves as the application shell; can depend on all packages.
No package other than apps/desktop may import Electron or SQLite.
Alternatives Considered
- Trust-Based Enforcement: Rely on developers to follow guidelines without compiler/lint rules.
- Tradeoffs: High risk of architectural drift over time as the team grows.
- Bespoke Monorepo Linting Scripts: Write custom bash scripts to check dependencies.
- Tradeoffs: Harder to maintain than standard ESLint or TypeScript configurations.
Tradeoffs
- Pros:
- No Circular Dependencies: TypeScript projects cannot compile circular structures.
- Clear Interfaces: Restricts developers from using implementation details instead of interfaces.
- Cons:
- Requires setting up TypeScript project references.
Consequences
- Architectural boundaries are enforced during local development and CI build pipelines.
- Violating import rules causes build compilation failures.