6 Commits
Author SHA1 Message Date
gurix 374282e5de feat(11-02): add [groups] TOML support and group-ordered PrintConfig
- Add Groups map[string]string field to rawConfig struct
- Add applyGroupOverrides function for [groups] reassignment with stderr warning on unknown class
- Add groupOrder canonical slice for section header ordering
- Refactor PrintConfig to emit group headers (Infrastructure, Web, Mail, Remote Access, File Transfer, Database, Discovery, VoIP, Unknown)
- Classes within each group sorted by ascending BaseHz
- User-defined classes emitted under '# User-defined' section
- Non-canonical group names (user-invented) emitted in sorted order after canonical groups
2026-03-27 16:35:10 +01:00
gurix 8ae1ddc773 feat(09-02): update autoAssignFreq range to [2500, 4000] Hz
- Change baseHz from 1200.0 to 2500.0
- Change numSteps from uint32(24) to uint32(31)
- Update function comment to reflect new range
- Prevents collision with built-in frequencies (max 2449 Hz)
2026-03-27 14:08:03 +01:00
gurix b52e36b579 feat(07-02): implement PrintConfig function with comment annotations
- Add AutoClasses map[TrafficClass]bool to LoadResult for tracking auto-assigned classes
- PrintConfig() returns commented TOML with header (source, date), [[rules]] section, [sounds.*] section
- waveformString() helper converts WaveformType back to string
- classAnnotation() returns default/override/auto-assigned per class
- Built-in classes emitted in AllClasses() order; user-defined classes sorted alphabetically
- Rules section emits [[rules]] blocks; port omitted when DstPort==0
- Tests: TestPrintConfigContainsAllClasses, TestPrintConfigSourcePath, TestPrintConfigNoSourcePath,
  TestPrintConfigContainsRules, TestPrintConfigRuleNoPort, TestPrintConfigDefaultAnnotation,
  TestPrintConfigOverrideAnnotation, TestPrintConfigAutoAssignedAnnotation
2026-03-26 21:51:27 +01:00
gurix 4b365cd5f4 feat(07-01): add RawRule, LoadResult, validation, auto-freq to config package
- Add RawRule struct with Port *uint16, Protocol, Class fields
- Add LoadResult struct with FreqCfgs, UserRules, ConfigPath fields
- Change Load() signature to return LoadResult instead of bare map
- Add validateRules: checks protocol required, class required, valid protocols
- Add convertRules: converts RawRule slices to classify.Rule slices
- Add autoAssignFreq: FNV-32a deterministic Hz in [1200-2350] range
- Add addAutoFreqEntries: creates FreqConfig for new class names, skips built-ins
- Reorder ops: addAutoFreqEntries before merge so sounds overrides apply to user classes
- Update main.go call site to use LoadResult.FreqCfgs
- Update all 8 existing tests to use LoadResult return type
- Add 13 new tests covering rule parsing, validation, auto-freq, and LoadResult
2026-03-26 21:44:53 +01:00
gurix 1f877e7574 feat(06-01): implement config package with TOML load, merge, validate
- Load() discovers, parses, validates, and merges TOML config over defaults
- SoundOverride struct with *float64/*string pointer fields for partial-merge (CFG-04)
- parseFile uses BurntSushi/toml DecodeFile + Undecoded() for unknown-key errors (CFG-05)
- discoverPath probes ./netsynth.toml then ~/.config/netsynth/config.toml (CFG-02)
- merge applies non-nil overrides per class; warns on unknown class names (D-09)
- parseWaveform maps sine/square/sawtooth/triangle strings to WaveformType
- Harmonics regenerated via WaveformPresetHarmonics when waveform/frequency changes
- All 9 tests pass; go vet clean
2026-03-26 20:57:00 +01:00
gurix b9ec05aebc test(06-01): add failing tests for config package TOML load, merge, validate
- 9 table-driven tests covering CFG-01 through CFG-05
- TestLoadPartialOverrideFrequency, TestLoadPartialOverrideWaveform, TestLoadBothOverrides
- TestLoadUnknownKey, TestLoadNoConfig, TestLoadExplicitMissing
- TestLoadUnknownClass, TestLoadInvalidWaveform, TestLoadAllDefaultsPresent
- Stub config.Load returns nil,nil — all tests fail (RED)
2026-03-26 20:56:03 +01:00