docs(07-02): complete print-config and LoadResult wiring plan

- SUMMARY.md for plan 02: PrintConfig + CLI wiring
- STATE.md: updated progress (100%), metrics, decisions, session
- ROADMAP.md: Phase 7 marked Complete (2/2 summaries)
- REQUIREMENTS.md: CFG-06 marked complete
This commit is contained in:
2026-03-26 21:52:44 +01:00
parent b52e36b579
commit 3eebb0f590
4 changed files with 107 additions and 12 deletions
+2 -2
View File
@@ -14,7 +14,7 @@ Requirements for custom sound mappings milestone. Each maps to roadmap phases.
- [x] **CFG-03**: User can specify an explicit config path via `--config` flag (error if file missing)
- [x] **CFG-04**: User can override individual values without replicating the entire default config (partial override)
- [x] **CFG-05**: Unknown keys in config file produce a clear error with the typo'd key name
- [ ] **CFG-06**: User can run `netsynth --print-config` to see the effective config as commented TOML
- [x] **CFG-06**: User can run `netsynth --print-config` to see the effective config as commented TOML
### Waveforms
@@ -61,7 +61,7 @@ Which phases cover which requirements. Updated during roadmap creation.
| CFG-03 | Phase 6 | Complete |
| CFG-04 | Phase 6 | Complete |
| CFG-05 | Phase 6 | Complete |
| CFG-06 | Phase 7 | Pending |
| CFG-06 | Phase 7 | Complete |
| WAVE-01 | Phase 5 | Complete |
| WAVE-02 | Phase 5 | Complete |
| RULE-01 | Phase 7 | Complete |
+4 -4
View File
@@ -25,7 +25,7 @@ Full details: `.planning/milestones/v1.0-ROADMAP.md`
- [x] **Phase 5: Waveform Types and Bank Decoupling** - Internal refactors establishing waveform enum and injectable bank signature (completed 2026-03-26)
- [x] **Phase 6: Config Package and Sound Overrides** - TOML loading, auto-discovery, partial merge, and frequency/waveform overrides wired end-to-end (completed 2026-03-26)
- [ ] **Phase 7: Custom Rules and Print-Config** - User-defined classification rules and --print-config UX
- [x] **Phase 7: Custom Rules and Print-Config** - User-defined classification rules and --print-config UX (completed 2026-03-26)
## Phase Details
@@ -68,11 +68,11 @@ Plans:
2. User-defined rules fire before built-in protocol rules — a custom rule for port 443 overrides the default HTTPS classification for packets on that port
3. A user-defined class name gets its own synthesis layer automatically — no silence or missing audio for traffic matched by a custom rule
4. User runs `netsynth --print-config` and sees the full effective config (defaults merged with their overrides) as commented TOML, without starting a capture
**Plans:** 1/2 plans executed
**Plans:** 2/2 plans complete
Plans:
- [x] 07-01-PLAN.md — Config extension: RawRule, LoadResult, rule validation, auto-freq assignment (TDD)
- [ ] 07-02-PLAN.md — CLI wiring: --print-config flag, user rule prepend, PrintConfig output
- [x] 07-02-PLAN.md — CLI wiring: --print-config flag, user rule prepend, PrintConfig output
## Progress
@@ -84,4 +84,4 @@ Plans:
| 4. Power User Features | v1.0 | 2/2 | Complete | 2026-03-26 |
| 5. Waveform Types and Bank Decoupling | v1.1 | 2/2 | Complete | 2026-03-26 |
| 6. Config Package and Sound Overrides | v1.1 | 2/2 | Complete | 2026-03-26 |
| 7. Custom Rules and Print-Config | v1.1 | 1/2 | In Progress| |
| 7. Custom Rules and Print-Config | v1.1 | 2/2 | Complete | 2026-03-26 |
+6 -6
View File
@@ -3,14 +3,14 @@ gsd_state_version: 1.0
milestone: v1.1
milestone_name: Custom Sound Mappings
status: executing
stopped_at: Completed 07-01-PLAN.md
last_updated: "2026-03-26T20:45:59.826Z"
stopped_at: Completed 07-02-PLAN.md
last_updated: "2026-03-26T20:52:30.478Z"
last_activity: 2026-03-26
progress:
total_phases: 3
completed_phases: 2
completed_phases: 3
total_plans: 6
completed_plans: 5
completed_plans: 6
percent: 0
---
@@ -81,6 +81,6 @@ None.
## Session Continuity
Last session: 2026-03-26T20:45:59.819Z
Stopped at: Completed 07-01-PLAN.md
Last session: 2026-03-26T20:52:30.470Z
Stopped at: Completed 07-02-PLAN.md
Resume file: None
@@ -0,0 +1,95 @@
---
phase: 07-custom-rules-and-print-config
plan: "02"
subsystem: config, cmd/netsynth
tags: [config, cli, print-config, rules, wiring, CFG-06, RULE-02]
dependency_graph:
requires: [LoadResult, UserRules, AutoClasses, PrintConfig]
provides: [--print-config flag, runPrintConfig, user-rule-prepend, PrintConfig-output]
affects: [cmd/netsynth/main.go, config/config.go]
tech_stack:
added: ["sort", "time", "strings.Builder"]
patterns: [LoadResult-propagation, user-rule-prepend, annotated-TOML-output]
key_files:
created: []
modified:
- cmd/netsynth/main.go
- cmd/netsynth/main_test.go
- config/config.go
- config/config_test.go
decisions:
- "--print-config check placed after --list-interfaces but before interface-required validation so it works without -i"
- "AutoClasses map added to LoadResult to track which classes were auto-assigned by FNV-32a"
- "PrintConfig returns a string (not writes to io.Writer) for testability; caller prints to stdout"
- "waveformString returns custom for WaveformCustom (zero value used by hand-tuned built-in classes)"
- "classAnnotation: built-in classes compared on both BaseHz and WaveformType for override detection"
metrics:
duration: 8min
completed: "2026-03-26T20:55:00Z"
tasks_completed: 2
files_modified: 4
---
# Phase 7 Plan 02: CLI Wiring and PrintConfig Output Summary
Wire the LoadResult into main.go (user rules prepend, --print-config flag), implement the PrintConfig output function in the config package, and add comprehensive tests for both. Completes RULE-02 and CFG-06 — the final plan for Phase 7 and the v1.1 milestone.
## What Was Built
**cmd/netsynth/main.go:**
- Added `printConfig bool` var and `--print-config` flag registration
- `runPrintConfig()`: calls `config.Load(configPath)` then `config.PrintConfig(result)`, prints to stdout, exits clean
- --print-config check fires before interface-required validation (no -i needed)
- `runLiveMode` and `runPcapMode` now accept `config.LoadResult` instead of bare `map[TrafficClass]FreqConfig`
- User rules prepend in both modes: `append(result.UserRules, classify.DefaultRules...)` (RULE-02)
- Removed unused `synth` import
**config/config.go:**
- `LoadResult` gains `AutoClasses map[classify.TrafficClass]bool` field
- `addAutoFreqEntries` updated to accept and populate `autoClasses` map
- `Load()` initializes `AutoClasses` map and returns it in `LoadResult`
- `PrintConfig(result LoadResult) string`: generates commented TOML output with:
- Header: `# NetSynth effective configuration`, `# Config source: <path or "none (using defaults)">`, `# Generated: <UTC timestamp>`
- `[[rules]]` section for each user rule (port omitted when DstPort==0)
- `[sounds.*]` section for all classes in deterministic order (14 built-ins in AllClasses() order, then user-defined sorted alphabetically)
- Per-class annotation: `(default)`, `(override)`, or `(auto-assigned)`
- `waveformString()`: converts WaveformType to TOML string
- `classAnnotation()`: determines annotation based on AutoClasses membership and comparison with defaults
## Tasks Completed
| Task | Name | Commit | Files |
|------|------|--------|-------|
| 1 | Wire LoadResult into main.go and add --print-config flag | d43914f | cmd/netsynth/main.go, cmd/netsynth/main_test.go |
| 2 | Implement PrintConfig output function with comment annotations | b52e36b | config/config.go, config/config_test.go |
## Deviations from Plan
None - plan executed exactly as written.
## Test Coverage
New tests added (8 PrintConfig tests in config_test.go, 3 print-config tests in main_test.go):
**config/config_test.go:**
- `TestPrintConfigContainsAllClasses` - all 14 class names in output
- `TestPrintConfigSourcePath` - `# Config source: <path>` in header
- `TestPrintConfigNoSourcePath` - `# Config source: none` when no config
- `TestPrintConfigContainsRules` - `[[rules]]` section with port/protocol/class
- `TestPrintConfigRuleNoPort` - port line omitted when DstPort==0
- `TestPrintConfigDefaultAnnotation` - `(default)` for unmodified built-in class
- `TestPrintConfigOverrideAnnotation` - `(override)` for modified built-in class
- `TestPrintConfigAutoAssignedAnnotation` - `(auto-assigned)` for FNV-hash assigned class
**cmd/netsynth/main_test.go:**
- `TestPrintConfigFlagRegistered` - flag exists on command
- `TestPrintConfigNoInterface` - --print-config works without -i
- `TestPrintConfigWithConfigFile` - --print-config with --config succeeds
Full suite: `go test ./... -count=1` all 7 packages pass.
## Known Stubs
None. All functionality is fully implemented and wired.
## Self-Check: PASSED