- 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
4.5 KiB
4.5 KiB
phase, plan, subsystem, tags, dependency_graph, tech_stack, key_files, decisions, metrics
| phase | plan | subsystem | tags | dependency_graph | tech_stack | key_files | decisions | metrics | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 07-custom-rules-and-print-config | 02 | config, cmd/netsynth |
|
|
|
|
|
|
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 boolvar and--print-configflag registration runPrintConfig(): callsconfig.Load(configPath)thenconfig.PrintConfig(result), prints to stdout, exits clean- --print-config check fires before interface-required validation (no -i needed)
runLiveModeandrunPcapModenow acceptconfig.LoadResultinstead of baremap[TrafficClass]FreqConfig- User rules prepend in both modes:
append(result.UserRules, classify.DefaultRules...)(RULE-02) - Removed unused
synthimport
config/config.go:
LoadResultgainsAutoClasses map[classify.TrafficClass]boolfieldaddAutoFreqEntriesupdated to accept and populateautoClassesmapLoad()initializesAutoClassesmap and returns it inLoadResultPrintConfig(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)
- Header:
waveformString(): converts WaveformType to TOML stringclassAnnotation(): 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 outputTestPrintConfigSourcePath-# Config source: <path>in headerTestPrintConfigNoSourcePath-# Config source: nonewhen no configTestPrintConfigContainsRules-[[rules]]section with port/protocol/classTestPrintConfigRuleNoPort- port line omitted when DstPort==0TestPrintConfigDefaultAnnotation-(default)for unmodified built-in classTestPrintConfigOverrideAnnotation-(override)for modified built-in classTestPrintConfigAutoAssignedAnnotation-(auto-assigned)for FNV-hash assigned class
cmd/netsynth/main_test.go:
TestPrintConfigFlagRegistered- flag exists on commandTestPrintConfigNoInterface- --print-config works without -iTestPrintConfigWithConfigFile- --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.