Architecture

Bounded Contexts & Rules

Conceptual foundation of Domain-Driven Design (DDD) domain ownership and dependency governance in Septum.

In growing repositories, AI coding agents often fix a bug or implement a feature by importing whatever internal helper or database model is closest at hand. Over time, direct cross-module imports blur module ownership, create circular dependencies, and turn isolated features into tightly coupled monoliths.

Septum brings Bounded-Context Architecture Governance into the agent workflow.


Theoretical Model

Drawing from Domain-Driven Design (DDD) and modular architecture principles, Septum models a codebase as a collection of named domains, each owning a physical root directory inside the workspace:

   ┌────────────────────────┐
   │  apps/web (Consumer)   │ ── allowed ──► [shared]
   └───────────┬────────────┘
               │ forbidden
               ▼
   ┌────────────────────────┐
   │  internal-billing      │ ◄── cycle check ──► [orders]
   └────────────────────────┘
  1. Explicit Domain Ownership: Every source file inside a domain root belongs to that domain (nested domain roots resolve to the most specific matching root).
  2. Directional Dependency Policies: Each domain can declare:
    • allowed_dependencies: Which sibling or shared domains it is permitted to import from (enforced when operating in strict mode).
    • forbidden_dependencies: Which domains it must never import from (enforced in both warn and strict modes).
  3. Cycle Prevention: Even when individual imports appear locally reasonable, circular domain dependencies (A → B → A) undermine clean layering and independent testing. Septum runs static cycle detection across resolved domain and file graphs.

Benefits for AI-Assisted Software Engineering

  • Predictable Architectural Boundaries: Before an agent writes a new import, septum_boundary(scope: "file") or septum hook pre-write informs the agent whether that dependency crosses a forbidden boundary.
  • Reviewable Policy Ownership: Rules live explicitly in septum.config.json (or SQLite), making architectural intent visible to both human engineers and AI coding agents.
  • Frozen Pre-Commit Gate: Running septum check --staged evaluates the exact Git index snapshot rather than relying on unstaged working-tree files.

Boundaries of Domain Rules

  • Import Topology, Not Runtime Contracts: Domain rules govern static import edges between mapped roots; they do not govern HTTP calls, shared database tables, or runtime event buses.
  • Policy Accuracy Depends on Configuration: Auto-discovered domains from septum init are heuristic starting points. Reviewing and curating septum.config.json ensures rules match your real architectural intent.