Skip to content

Epic: Testing Infrastructure [POC] #10

@radoxtech

Description

@radoxtech

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

  • bun test at repo root runs tests across all packages
  • Each package has its own vitest.config.ts with correct paths
  • Coverage reports generated per-package and aggregate
  • packages/test-utils/ exports shared factories and mocks
  • Entity factories create valid instances with minimal required fields
  • MockLLMProvider supports configurable responses and error injection
  • Integration test harness: server starts on random port, seeds DB, tears down after
  • In-memory SQLite test database with auto-migration
  • GitHub Actions CI runs full test suite on PR
  • Tests complete in <60s for unit tests, <5min for integration tests

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions