Epic: Testing Infrastructure
Package: root, packages/test-utils/
Iteration: POC → MVP-1 (cross-cutting, evolves with each milestone)
Goal
Establish a shared testing platform across the DiriCode monorepo that enables TDD workflows for all 9 modules. This epic provides: Vitest workspace configuration, reusable test utilities and factories, deterministic integration test harnesses for server and database layers, and a test-utils package for cross-package test sharing.
Context
Testing infrastructure is a cross-cutting concern that every module depends on. Without standardized test setup:
- Each package reinvents test configuration
- Integration tests are flaky (non-deterministic DB state, server ports)
- No shared factories for common entities (sessions, agents, tools, permissions)
- No consistent mocking strategy for LLM providers
The testing epic must be implemented BEFORE or alongside the first implementation epics to enable TDD. It's foundational infrastructure, not a feature.
Scope
DC-TEST-001: Vitest Workspace and Monorepo Test Baseline
- Vitest workspace config at repo root covering all packages
- Per-package
vitest.config.ts with correct TypeScript paths
bun test / vitest unified commands
- Coverage reporting (c8/v8) with per-package thresholds
- CI integration: test matrix in GitHub Actions
DC-TEST-002: Shared Test Utilities, Factories, and Fixtures
packages/test-utils/ package exporting shared helpers
- Entity factories:
createSession(), createAgent(), createTool(), createPermissionConfig()
- Mock providers:
MockLLMProvider, MockToolExecutor, MockPermissionEngine
- Fixture system: deterministic test data sets loadable per test suite
- Snapshot utilities for approval-based testing
DC-TEST-003: Server Integration Test Harness
- Test server bootstrap: start/stop server per test suite
- Port allocation: automatic free port selection (no conflicts)
- Request helpers: typed HTTP client for API testing
- WebSocket test helpers for real-time event testing
- Database seeding: load known state before integration tests
DC-TEST-004: Memory Layer Test Harness + SQLite FTS5 Spike
- In-memory SQLite for test isolation (
:memory: database)
- Migration runner for test databases
- FTS5 virtual table testing patterns
- Query assertion helpers: verify SQL results structurally
- Test data generators for permission audit logs, approval records
Tracking
Child Issues
- DC-TEST-001: Vitest workspace and monorepo test baseline
- DC-TEST-002: Shared test utilities, factories, and fixtures
- DC-TEST-003: Server integration test harness
- DC-TEST-004: Memory layer test harness + SQLite FTS5 spike
Module Coverage Map
| Module |
Primary Test Concerns |
packages/core/ |
Permission engine decisions, hook execution, config validation |
packages/code-index/ |
AST parsing, symbol resolution, caching |
packages/prompt-composer/ |
Template rendering, token counting, context assembly |
packages/semantic-search/ |
Embedding generation, vector queries, FTS5 search |
packages/memory/ |
SQLite operations, migration, session persistence |
packages/dirirouter/ |
Model selection, provider routing, fallback logic |
packages/agents/ |
Agent lifecycle, skill loading, tool dispatch |
packages/orchestrators/ |
Wave execution, state machines, parallel coordination |
packages/tools/ |
Tool execution, annotation validation, permission checks |
Acceptance Criteria
Must NOT Do
- No testing framework other than Vitest (standardized choice)
- No test-specific code in production packages — all test utils in
packages/test-utils/
- No reliance on external services in unit tests — all dependencies mocked
- No shared mutable state between test suites — each suite gets fresh state
- No skipping tests in CI — if a test is flaky, fix it or remove it
Dependencies
References
Epic: Testing Infrastructure
Package: root,
packages/test-utils/Iteration: POC → MVP-1 (cross-cutting, evolves with each milestone)
Goal
Establish a shared testing platform across the DiriCode monorepo that enables TDD workflows for all 9 modules. This epic provides: Vitest workspace configuration, reusable test utilities and factories, deterministic integration test harnesses for server and database layers, and a test-utils package for cross-package test sharing.
Context
Testing infrastructure is a cross-cutting concern that every module depends on. Without standardized test setup:
The testing epic must be implemented BEFORE or alongside the first implementation epics to enable TDD. It's foundational infrastructure, not a feature.
Scope
DC-TEST-001: Vitest Workspace and Monorepo Test Baseline
vitest.config.tswith correct TypeScript pathsbun test/vitestunified commandsDC-TEST-002: Shared Test Utilities, Factories, and Fixtures
packages/test-utils/package exporting shared helperscreateSession(),createAgent(),createTool(),createPermissionConfig()MockLLMProvider,MockToolExecutor,MockPermissionEngineDC-TEST-003: Server Integration Test Harness
DC-TEST-004: Memory Layer Test Harness + SQLite FTS5 Spike
:memory:database)Tracking
Child Issues
Module Coverage Map
packages/core/packages/code-index/packages/prompt-composer/packages/semantic-search/packages/memory/packages/dirirouter/packages/agents/packages/orchestrators/packages/tools/Acceptance Criteria
bun testat repo root runs tests across all packagesvitest.config.tswith correct pathspackages/test-utils/exports shared factories and mocksMockLLMProvidersupports configurable responses and error injectionMust NOT Do
packages/test-utils/Dependencies
References
packages/*/src/__tests__/