4.5 KiB
Phase 8: Test and Constant Cleanup - Context
Gathered: 2026-03-27 Status: Ready for planning
## Phase BoundaryRemove 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.
Constant Removal Strategy
- D-01: Delete
NumLayersandGainPerLayerconstants entirely fromsynth/config.go. They are dead code —NewBankalready computesgainPerLayerdynamically as1.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 inTestFrequenciesInRangewith dynamic validation — derive the valid range from theClassFreqConfigsdata 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
TestNumLayersMatchesAllClassestoTestClassFreqConfigsMatchAllClasses(or similar) to reflect the actual invariant being tested afterNumLayersremoval. The test body already useslen(synth.ClassFreqConfigs)andlen(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
WhisperFlooror 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_refs>
Canonical References
Downstream agents MUST read these before planning or implementing.
Synth Package (primary targets)
synth/config.go— ContainsNumLayersandGainPerLayerconstants to remove (lines 9-10)synth/config_test.go— ContainsTestFrequenciesInRange(lines 18-24),TestNumLayersMatchesAllClasses(lines 61-66), andTestClassFreqConfigsComplete(lines 53-59)synth/bank.go—NewBankalready computesgainPerLayerdynamically (line 21) — confirms constants are dead code
Research Context
.planning/research/PITFALLS.md— Pitfall C4 documentsTestFrequenciesInRangehardcoding 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
</canonical_refs>
<code_context>
Existing Code Insights
Reusable Assets
synth/bank.go:NewBankalready has the correct dynamic gain computation — no new code needed for gain behavior
Established Patterns
- Test file
synth/config_test.gouses table-driven validation againstClassFreqConfigsmap andclassify.AllClasses()— new/renamed tests should follow this pattern GainPerLayerconstant at line 10 has a comment referencing "D-10" — cleanup should not leave orphan decision references
Integration Points
- Only
synth/config.goandsynth/config_test.goare modified — no downstream package changes expected go test ./...is the verification gate — must pass with zero new failures
</code_context>
## Specific IdeasNo specific requirements — this is a straightforward cleanup phase with clear targets identified in research.
## Deferred IdeasReviewed 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