ADR-037: Test-Driven Locking Strategy

Status: Accepted Date: September 26, 2025 Deciders: Christian Crumlish (PM), Claude Opus (Chief Architect) Category: Testing, Quality, Methodology

Context

The 75% pattern revealed a critical weakness in our development process: completed work can become disabled through “temporary” comments, TODO markers, or partial implementations. During CORE-GREAT-1, we discovered QueryRouter had been 75% complete but disabled with TODO comments for months, blocking 80% of features.

We need a systematic approach to prevent completed work from regressing, being accidentally disabled, or degrading in quality. This approach must balance preventing regression with maintaining development velocity.

Decision

We will implement a comprehensive Test-Driven Locking Strategy that makes regression impossible without deliberate test modification. Each completed component or epic will have multiple lock mechanisms that prevent various forms of degradation.

Lock Categories

1. Existence Locks

Tests that verify a component exists and is initialized:

2. Performance Locks

Tests that prevent performance degradation:

3. Coverage Locks

Tiered enforcement based on component status:

4. Integration Locks

Tests that verify component connections:

5. Quality Locks

Automated checks that maintain standards:

Implementation Requirements

For Each Epic/Component

  1. During Development
    • Write tests for new functionality
    • Establish performance baselines
    • Document expected behavior
  2. At Completion
    • Create regression test suite
    • Set coverage thresholds
    • Configure CI/CD gates
    • Remove old patterns physically
  3. Post-Completion
    • Monitor for violations
    • Update baselines only with justification
    • Maintain lock tests through refactors

Lock Lifecycle

Creation

Modification

Removal

CI/CD Integration

All locks must be enforced in CI/CD pipeline:

- name: Run Lock Tests
  run: |
    pytest tests/regression/ -v
    pytest tests/unit/ --cov --cov-fail-under=80
    pytest tests/performance/ --benchmark-fail-if-slower=threshold

Developer Experience

Locks must not significantly impede development:

Consequences

Positive

  1. Regression Prevention: Completed work cannot be accidentally disabled
  2. Quality Maintenance: Performance and coverage cannot degrade silently
  3. Confidence: Changes can be made knowing locks will catch breaks
  4. Documentation: Lock tests serve as executable specifications
  5. 75% Pattern Prevention: Incomplete work becomes immediately visible

Negative

  1. Initial Overhead: Time required to create comprehensive locks
  2. Maintenance Burden: Lock tests must be updated with legitimate changes
  3. False Positives: Overly strict locks may block valid improvements
  4. Learning Curve: Developers must understand lock patterns

Mitigation

Examples from Implementation

GREAT-1C QueryRouter Locks

# Existence Lock
def test_queryrouter_must_be_enabled_in_orchestration_engine():
    engine = OrchestrationEngine()
    assert engine.query_router is not None
    assert callable(engine.query_router.route_query)

# Performance Lock
def test_performance_requirement_queryrouter_initialization_under_500ms():
    times = []
    for _ in range(10):
        start = time.time()
        QueryRouter()
        times.append(time.time() - start)
    assert sum(times) / len(times) < 0.5

CI/CD Configuration

# Coverage Lock
- run: pytest tests/ --cov=services/orchestration/queryrouter --cov-fail-under=80

# Performance Lock
- run: pytest tests/performance/ --benchmark-fail-threshold=5400ms

Review Schedule

This decision should be reviewed after:

Notes

The test-driven locking strategy emerged from painful experience with the 75% pattern. It represents a shift from trust-based development (“this should work”) to evidence-based development (“this is proven to work and cannot be broken without deliberate action”).

The key insight: regression tests are not just about detecting breaks, they’re about making breaks impossible without conscious override.


“Tests make incomplete work visible. Locks prevent ‘temporary’ disabling.”