# Story Series 7.0: Test Suite Value & Confidence Improvement

## Overview

This series addresses findings from the Test Value Audit conducted in January 2026. The goal is to transform the test suite from "coverage-focused" to "defect-prevention-focused" while maintaining the 90% coverage requirement.

## Guiding Principles

1. **Coverage is a minimum, not a goal** — 90% coverage is the floor, but tests must also verify behavior
2. **Assertions prove correctness** — Tests without meaningful assertions provide false confidence
3. **Integration tests catch real bugs** — Unit tests with heavy mocking often test the mocks, not the code
4. **Security-critical paths need contract tests** — Redaction must be verified at every boundary
5. **Failures should be tested as rigorously as successes** — Recovery paths need behavioral verification

## Audit Summary

The Test Value Audit identified several patterns of "coverage padding" — tests that hit lines without verifying behavior:

- **12+ test files** with names like `*_coverage.py`, `*_more_coverage.py`, `*_priority1_coverage.py`
- **Always-true assertions** like `assert result.dropped >= 0`
- **Heavy internal mocking** that tests the mocks rather than the code
- **"Didn't crash" tests** with no behavioral verification

Despite 90%+ line coverage, several critical behaviors are undertested:

- Serialization failure recovery
- Redaction enforcement across all sink types
- Backpressure behavior under sustained sink failures

## Stories

### P0 - Must Do (7.1 - 7.4)

| Story | Title                                         | Risk | Effort   | Status   | Story File |
| ----- | --------------------------------------------- | ---- | -------- | -------- | ---------- |
| 7.1   | Refactor Coverage-Padding Tests to Behavioral | Low  | 4-5 days | Complete | [7.1](7.1.refactor-coverage-padding-tests.md) |
| 7.2   | Add Serialization Failure Recovery Tests      | Low  | 1 day    | Complete | [7.2](7.2.serialization-failure-recovery-tests.md) |
| 7.3   | Add Redaction Integration Tests for All Sinks | Low  | 2 days   | Complete | [7.3](7.3.redaction-integration-tests-all-sinks.md) |
| 7.4   | Add Test Assertion Strength Lint              | Low  | 1 day    | Complete | [7.4](7.4.test-assertion-strength-lint.md) |

### P1 - Should Do (7.5 - 7.7)

| Story | Title                                     | Risk   | Effort | Status | Story File |
| ----- | ----------------------------------------- | ------ | ------ | ------ | ---------- |
| 7.5   | Consolidate Duplicative Logger Test Files | Low    | 2 days | Ready  | [7.5](7.5.consolidate-duplicative-logger-tests.md) |
| 7.6   | Add Property-Based Serialization Tests    | Medium | 2 days | Ready  | [7.6](7.6.property-based-serialization-tests.md) |
| 7.7   | Add Concurrency Tests for Circuit Breaker | Medium | 1 day  | Complete | [7.7](7.7.concurrency-tests-circuit-breaker.md) |

### P2 - Nice to Have (7.8 - 7.9)

| Story | Title                               | Risk | Effort | Status | Story File |
| ----- | ----------------------------------- | ---- | ------ | ------ | ---------- |
| 7.8   | Add Mutation Testing CI Integration | Low  | 1 day  | Ready  | [7.8](7.8.mutation-testing-ci-integration.md) |
| 7.9   | Tag Tests by Risk Category          | Low  | 1 day  | Ready  | [7.9](7.9.tag-tests-by-risk-category.md) |

### P1 - Coverage Gap Tests (7.10 - 7.11)

| Story | Title                                  | Risk | Effort   | Status | Story File |
| ----- | -------------------------------------- | ---- | -------- | ------ | ---------- |
| 7.10  | Worker/Logger Lifecycle Coverage Tests | Low  | 2-3 days | Ready  | [7.10](7.10.worker-logger-lifecycle-coverage.md) |
| 7.11  | Redactor Branch Coverage Tests         | Low  | 2 days   | Ready  | [7.11](7.11.redactor-branch-coverage.md) |

## Key Metrics

### Current State (Pre-7.0)

| Metric                          | Value       |
| ------------------------------- | ----------- |
| Line coverage                   | 90%+        |
| Test files with `*_coverage.py` | 12          |
| Always-true assertions          | ~50+ (est.) |
| Integration tests               | 11 files    |
| Property-based tests            | 0           |

### Target State (Post-7.0)

| Metric                          | Target     |
| ------------------------------- | ---------- |
| Line coverage                   | 90%+       |
| Test files with `*_coverage.py` | 0          |
| Always-true assertions          | 0          |
| Integration tests               | 15+ files  |
| Property-based tests            | 3+ modules |

## Success Metrics

- [ ] Zero test files named `*_coverage.py` or `*_more_coverage.py`
- [ ] Zero assertions of form `>= 0` on counters (always true)
- [ ] All security-critical paths (redaction) have integration tests with real sinks
- [ ] Serialization failure recovery verified with behavioral tests
- [ ] CI lint rejects new tests with weak assertions
- [ ] 90% coverage maintained throughout

## Dependencies

- Stories 7.1-7.4 can proceed in parallel (P0 work)
- Story 7.5 depends on 7.1 completion (consolidation after refactoring)
- Story 7.6 is independent
- Story 7.8 can proceed after any P0 story is complete

## Out of Scope

- New feature development
- Increasing coverage percentage beyond 90%
- Removing tests that have value (only refactoring weak tests)
- Breaking existing test infrastructure
