Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
10 KiB
10 KiB
phase, plan, type, wave, depends_on, files_modified, autonomous, requirements, must_haves
| phase | plan | type | wave | depends_on | files_modified | autonomous | requirements | must_haves | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 06-config-package-and-sound-overrides | 02 | execute | 2 |
|
|
true |
|
|
Purpose: Completes CFG-03 (explicit --config flag) and D-10 (RunSynthesis signature change). After this plan, the end-to-end flow works: user creates TOML -> tool loads it -> synthesis uses overridden frequencies/waveforms.
Output: Updated cmd/netsynth/main.go, encode/mp3.go, encode/mp3_test.go
<execution_context> @$HOME/.claude/get-shit-done/workflows/execute-plan.md @$HOME/.claude/get-shit-done/templates/summary.md </execution_context>
@.planning/PROJECT.md @.planning/ROADMAP.md @.planning/STATE.md @.planning/phases/06-config-package-and-sound-overrides/06-CONTEXT.md @.planning/phases/06-config-package-and-sound-overrides/06-01-SUMMARY.mdFrom config/config.go (created in Plan 01):
// Load finds, parses, validates, and merges a config file.
// configPath is the --config flag value; empty string triggers auto-discovery.
func Load(configPath string) (map[classify.TrafficClass]synth.FreqConfig, error)
From encode/mp3.go (current signature to change):
// Current:
func RunSynthesis(snapshots []classify.WindowSnapshot, outputPath string) error
// New:
func RunSynthesis(snapshots []classify.WindowSnapshot, outputPath string, freqCfgs map[classify.TrafficClass]synth.FreqConfig) error
From cmd/netsynth/main.go (existing flags pattern):
var (
ifaceName string
listIfaces bool
verbose bool
outputPath string
bpfFilter string
readPath string
)
// Flag registration pattern:
rootCmd.Flags().StringVar(&bpfFilter, "filter", "", "BPF filter expression")
From synth/config.go:
var ClassFreqConfigs = map[classify.TrafficClass]FreqConfig{ /* 14 entries */ }
1. Add `freqCfgs map[classify.TrafficClass]synth.FreqConfig` as third parameter to RunSynthesis:
```
func RunSynthesis(snapshots []classify.WindowSnapshot, outputPath string, freqCfgs map[classify.TrafficClass]synth.FreqConfig) error
```
2. Change line 57 from:
```
bank := synth.NewBank(1.0, synth.ClassFreqConfigs)
```
to:
```
bank := synth.NewBank(1.0, freqCfgs)
```
3. No other changes to encode/mp3.go.
**encode/mp3_test.go changes:**
4. Update `TestMP3Valid` (line 56): change `RunSynthesis(snaps, tmpPath)` to `RunSynthesis(snaps, tmpPath, synth.ClassFreqConfigs)`.
5. Update `TestZeroPacketError` (line 101): change `RunSynthesis([]classify.WindowSnapshot{}, tmpPath)` to `RunSynthesis([]classify.WindowSnapshot{}, tmpPath, synth.ClassFreqConfigs)`.
6. Update `TestZeroPacketError` (line 121): change `RunSynthesis(zeroSnaps, tmpPath2)` to `RunSynthesis(zeroSnaps, tmpPath2, synth.ClassFreqConfigs)`.
The `synth` import is already present in mp3_test.go.
1. Add `configPath` to the var block (after `readPath`):
```go
configPath string // NEW: --config flag (CFG-03)
```
2. Add import for config package in the import block:
```go
"github.com/netsynth/netsynth/config"
```
Also add import for `synth` package (needed for ClassFreqConfigs fallback reference — though config.Load handles this internally):
No — `synth` is NOT needed in main.go. `config.Load` returns the full map. Only add `config` import.
3. Add flag registration in main() after the `readPath` flag line (line 44):
```go
rootCmd.Flags().StringVar(&configPath, "config", "", "Path to TOML config file (default: auto-discover)")
```
4. In the `run` function, add config loading AFTER the BPF filter validation block (after line 80) and BEFORE output path resolution (before line 83). This is per D-11 (fail fast on config errors before capture):
```go
// Load config (CFG-01 through CFG-05, D-11: fail fast)
freqCfgs, err := config.Load(configPath)
if err != nil {
return err
}
```
5. The `freqCfgs` variable must be accessible in both `runLiveMode` and `runPcapMode`. Two approaches:
- Option A: Pass freqCfgs to both functions (cleanest).
- Option B: Store in a package-level var (simpler change).
Use Option A. Change signatures:
- `runLiveMode(cmd *cobra.Command) error` -> `runLiveMode(cmd *cobra.Command, freqCfgs map[classify.TrafficClass]synth.FreqConfig) error`
- `runPcapMode(cmd *cobra.Command) error` -> `runPcapMode(cmd *cobra.Command, freqCfgs map[classify.TrafficClass]synth.FreqConfig) error`
This requires adding `synth` import after all:
```go
"github.com/netsynth/netsynth/synth"
```
Update call sites in `run()`:
- Line 92: `return runPcapMode(cmd)` -> `return runPcapMode(cmd, freqCfgs)`
- Line 94: `return runLiveMode(cmd)` -> `return runLiveMode(cmd, freqCfgs)`
6. In `runLiveMode`, change the RunSynthesis call (line 147):
From: `encode.RunSynthesis(collectedSnapshots, outputPath)`
To: `encode.RunSynthesis(collectedSnapshots, outputPath, freqCfgs)`
7. In `runPcapMode`, change the RunSynthesis call (line 215):
From: `encode.RunSynthesis(collectedSnapshots, outputPath)`
To: `encode.RunSynthesis(collectedSnapshots, outputPath, freqCfgs)`
After all changes, run `go build ./cmd/netsynth/...` to verify compilation.
<success_criteria>
- --config flag appears in CLI help output (CFG-03)
- Explicit --config with missing file produces error before capture (CFG-03)
- RunSynthesis uses injected config map, not hardcoded ClassFreqConfigs (D-10)
- Full test suite passes including encode and config package tests </success_criteria>