# Phase 8: Test and Constant Cleanup - Context
**Gathered:** 2026-03-27
**Status:** Ready for planning
## Phase Boundary
Remove stale exported constants (`NumLayers`, `GainPerLayer`) from the synth package and update hardcoded test assertions (`TestFrequenciesInRange`) so that subsequent v1.2 phases can add new traffic classes and frequencies without triggering false CI failures. This is pure cleanup — no new features, no new protocols.
## Implementation Decisions
### Constant Removal Strategy
- **D-01:** Delete `NumLayers` and `GainPerLayer` constants entirely from `synth/config.go`. They are dead code — `NewBank` already computes `gainPerLayer` dynamically as `1.0 / float64(len(cfgs))` (bank.go:21). No external callers reference either constant outside the test file.
### Frequency Range Test Bounds
- **D-02:** Replace the hardcoded `[60, 1100]` bounds in `TestFrequenciesInRange` with dynamic validation — derive the valid range from the `ClassFreqConfigs` data itself (e.g., check that all frequencies are positive and below Nyquist) rather than hardcoding a new magic number that would need manual updating when Phase 9/10 add classes above 1100 Hz. The specific approach (positive+Nyquist check, or a generous static bound like `[20, 8000]`) is at Claude's discretion — the key constraint is that adding a new class in the 1100-4000 Hz range must not require editing this test.
### Test Naming
- **D-03:** Rename `TestNumLayersMatchesAllClasses` to `TestClassFreqConfigsMatchAllClasses` (or similar) to reflect the actual invariant being tested after `NumLayers` removal. The test body already uses `len(synth.ClassFreqConfigs)` and `len(classify.AllClasses())` — only the name references the deleted constant.
### Claude's Discretion
- Whether to use a generous static upper bound vs a computed Nyquist-based bound for D-02 — either approach satisfies the constraint
- Whether `WhisperFloor` or other constants in config.go need any adjustment (they don't reference NumLayers, so likely no)
- Whether `TestClassFreqConfigsComplete` (line 53) should be consolidated with the renamed test since both verify the same invariant
### Folded Todos
- **"Expand Traffic Classes"** (from `.planning/todos/pending/001-expand-traffic-classes.md`) — This todo requests adding protocols like IMAP, POP3, SNMP, FTP and researching common traffic classes. Phase 8 enables this work by removing the test/constant blockers, but the actual protocol additions are Phase 10's scope. Folded here as context, not as direct Phase 8 work.
## Canonical References
**Downstream agents MUST read these before planning or implementing.**
### Synth Package (primary targets)
- `synth/config.go` — Contains `NumLayers` and `GainPerLayer` constants to remove (lines 9-10)
- `synth/config_test.go` — Contains `TestFrequenciesInRange` (lines 18-24), `TestNumLayersMatchesAllClasses` (lines 61-66), and `TestClassFreqConfigsComplete` (lines 53-59)
- `synth/bank.go` — `NewBank` already computes `gainPerLayer` dynamically (line 21) — confirms constants are dead code
### Research Context
- `.planning/research/PITFALLS.md` — Pitfall C4 documents `TestFrequenciesInRange` hardcoding issue
- `.planning/research/ARCHITECTURE.md` — Lines 414+ document NumLayers/ClassFreqConfigs mismatch risk
- `.planning/research/SUMMARY.md` — Lines 69, 85, 100 describe Phase 8 cleanup scope
## Existing Code Insights
### Reusable Assets
- `synth/bank.go:NewBank` already has the correct dynamic gain computation — no new code needed for gain behavior
### Established Patterns
- Test file `synth/config_test.go` uses table-driven validation against `ClassFreqConfigs` map and `classify.AllClasses()` — new/renamed tests should follow this pattern
- `GainPerLayer` constant at line 10 has a comment referencing "D-10" — cleanup should not leave orphan decision references
### Integration Points
- Only `synth/config.go` and `synth/config_test.go` are modified — no downstream package changes expected
- `go test ./...` is the verification gate — must pass with zero new failures
## Specific Ideas
No specific requirements — this is a straightforward cleanup phase with clear targets identified in research.
## Deferred Ideas
### Reviewed Todos (not folded)
None — the matched todo was folded as milestone context.
None — discussion stayed within phase scope.
---
*Phase: 08-test-and-constant-cleanup*
*Context gathered: 2026-03-27*