ADR-029: Domain Service Mediation Architecture

Status

Accepted (September 12, 2025)

Context

During comprehensive DDD refactoring (Issue #168), direct integration access was causing significant architectural violations:

Specific Violations Identified

Decision

Implement comprehensive domain service mediation for all external system access:

Domain Services Created

  1. GitHubDomainService (services/domain/github_domain_service.py)

    • Mediates all GitHub operations (issues, repositories, commits)
    • Provides clean error handling with domain-appropriate exceptions
    • Abstracts GitHub agent implementation details
  2. SlackDomainService (services/domain/slack_domain_service.py)

    • Mediates Slack webhook routing and response handling
    • Manages spatial event processing and intent classification
    • Provides orchestration engine integration
  3. NotionDomainService (services/domain/notion_domain_service.py)

    • Mediates Notion MCP operations (workspace, database, page management)
    • Provides comprehensive CRUD operations
    • Handles Notion client lifecycle and error boundaries

Implementation Pattern

# Domain Service Pattern
class GitHubDomainService:
    def __init__(self, github_agent: Optional[GitHubAgent] = None):
        self._github_agent = github_agent or GitHubAgent()

    async def get_open_issues(self, project: str, limit: int = 10):
        # Domain-level validation and orchestration
        # Delegate to integration layer
        # Return domain-appropriate results

Layer Access Pattern

Consequences

Positive

Negative

Migration Impact

Implementation Evidence

Validation Results (September 12, 2025)

Performance Impact

Future Considerations

References