207 lines
7.8 KiB
Markdown
207 lines
7.8 KiB
Markdown
---
|
|||
|
|
phase: 09-frequency-design-and-group-architecture
|
||
|
|
plan: 02
|
||
|
|
type: execute
|
||
|
|
wave: 1
|
||
|
|
depends_on: []
|
||
|
|
files_modified:
|
||
|
|
- config/config.go
|
||
|
|
- config/config_test.go
|
||
|
|
autonomous: true
|
||
|
|
requirements:
|
||
|
|
- FREQ-04
|
||
|
|
|
||
|
|
must_haves:
|
||
|
|
truths:
|
||
|
|
- "autoAssignFreq returns Hz values in [2500, 4000] range, not the old [1200, 2350]"
|
||
|
|
- "Auto-assigned classes cannot collide with any built-in frequency (max built-in is 2449 Hz, auto-assign starts at 2500 Hz)"
|
||
|
|
- "TestAutoFreqAssignment passes with the new range bounds"
|
||
|
|
- "addAutoFreqEntries produces FreqConfig with empty Group (zero value) for user-defined classes"
|
||
|
|
artifacts:
|
||
|
|
- path: "config/config.go"
|
||
|
|
provides: "Updated autoAssignFreq constants"
|
||
|
|
contains: "baseHz = 2500.0"
|
||
|
|
- path: "config/config_test.go"
|
||
|
|
provides: "Updated range assertion"
|
||
|
|
contains: "cfg.BaseHz < 2500.0 || cfg.BaseHz > 4000.0"
|
||
|
|
key_links:
|
||
|
|
- from: "config/config.go"
|
||
|
|
to: "synth/config.go"
|
||
|
|
via: "addAutoFreqEntries creates synth.FreqConfig entries"
|
||
|
|
pattern: "synth\\.FreqConfig"
|
||
|
|
---
|
||
|
|
|
||
|
|
<objective>
|
||
|
|
Update the auto-assign frequency range from [1200, 2350] to [2500, 4000] Hz so custom user-defined classes cannot collide with any built-in frequency. Update the corresponding test assertion.
|
||
|
|
|
||
|
|
Purpose: Per D-04, the auto-assign range must be pushed above all built-in frequencies (max 2449 Hz) to prevent collision. The 51 Hz buffer between 2449 and 2500 guarantees no overlap.
|
||
|
|
|
||
|
|
Output: Updated config/config.go constants, updated config/config_test.go assertion.
|
||
|
|
</objective>
|
||
|
|
|
||
|
|
<execution_context>
|
||
|
|
@$HOME/.claude/get-shit-done/workflows/execute-plan.md
|
||
|
|
@$HOME/.claude/get-shit-done/templates/summary.md
|
||
|
|
</execution_context>
|
||
|
|
|
||
|
|
<context>
|
||
|
|
@.planning/PROJECT.md
|
||
|
|
@.planning/ROADMAP.md
|
||
|
|
@.planning/STATE.md
|
||
|
|
@.planning/phases/09-frequency-design-and-group-architecture/09-CONTEXT.md
|
||
|
|
@.planning/phases/09-frequency-design-and-group-architecture/09-RESEARCH.md
|
||
|
|
|
||
|
|
<interfaces>
|
||
|
|
<!-- From config/config.go — current autoAssignFreq function (lines 208-219) -->
|
||
|
|
```go
|
||
|
|
func autoAssignFreq(className string) float64 {
|
||
|
|
h := fnv.New32a()
|
||
|
|
h.Write([]byte(className))
|
||
|
|
const (
|
||
|
|
baseHz = 1200.0
|
||
|
|
stepHz = 50.0
|
||
|
|
numSteps = uint32(24)
|
||
|
|
)
|
||
|
|
return baseHz + float64(h.Sum32()%numSteps)*stepHz
|
||
|
|
}
|
||
|
|
```
|
||
|
|
|
||
|
|
<!-- From config/config.go — addAutoFreqEntries (lines 225-238) -->
|
||
|
|
```go
|
||
|
|
func addAutoFreqEntries(cfgs map[classify.TrafficClass]synth.FreqConfig, userRules []classify.Rule, autoClasses map[classify.TrafficClass]bool) {
|
||
|
|
for _, rule := range userRules {
|
||
|
|
if _, exists := cfgs[rule.Class]; !exists {
|
||
|
|
baseHz := autoAssignFreq(string(rule.Class))
|
||
|
|
cfgs[rule.Class] = synth.FreqConfig{
|
||
|
|
BaseHz: baseHz,
|
||
|
|
WaveformType: synth.WaveformSine,
|
||
|
|
Harmonics: synth.WaveformPresetHarmonics(synth.WaveformSine, baseHz, synth.SampleRate),
|
||
|
|
Pan: 0.0,
|
||
|
|
}
|
||
|
|
autoClasses[rule.Class] = true
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
```
|
||
|
|
|
||
|
|
<!-- From config/config_test.go — current range assertion (line 363) -->
|
||
|
|
```go
|
||
|
|
if cfg.BaseHz < 1200.0 || cfg.BaseHz > 2350.0 {
|
||
|
|
t.Errorf("GameServer BaseHz: got %v, want in [1200, 2350]", cfg.BaseHz)
|
||
|
|
}
|
||
|
|
```
|
||
|
|
</interfaces>
|
||
|
|
</context>
|
||
|
|
|
||
|
|
<tasks>
|
||
|
|
|
||
|
|
<task type="auto">
|
||
|
|
<name>Task 1: Update autoAssignFreq constants and comment</name>
|
||
|
|
<files>config/config.go</files>
|
||
|
|
<read_first>
|
||
|
|
- config/config.go (lines 208-238: autoAssignFreq function and addAutoFreqEntries)
|
||
|
|
</read_first>
|
||
|
|
<action>
|
||
|
|
1. In the `autoAssignFreq` function (line 208-219), update three things:
|
||
|
|
|
||
|
|
a. Change the function comment from `[1200, 2350]` to `[2500, 4000]`:
|
||
|
|
```go
|
||
|
|
// autoAssignFreq computes a deterministic frequency in [2500, 4000] Hz for a class name
|
||
|
|
```
|
||
|
|
|
||
|
|
b. Change the constants inside the function:
|
||
|
|
```go
|
||
|
|
const (
|
||
|
|
baseHz = 2500.0
|
||
|
|
stepHz = 50.0
|
||
|
|
numSteps = uint32(31) // [2500, 4000] Hz in 50 Hz steps
|
||
|
|
)
|
||
|
|
```
|
||
|
|
|
||
|
|
Verification: `2500.0 + float64(30)*50.0 = 4000.0`. With numSteps=31, the modulo produces values 0..30, yielding Hz values 2500, 2550, ..., 4000.
|
||
|
|
|
||
|
|
2. Do NOT modify `addAutoFreqEntries`. The Group field will be zero-value `""` for auto-assigned entries, which is correct — user-defined classes are not part of any built-in family. The struct literal in addAutoFreqEntries does not need a `Group:` field because Go zero-initializes missing named fields.
|
||
|
|
</action>
|
||
|
|
<verify>
|
||
|
|
<automated>cd /home/dev/workspace/yoloyolo && go build ./config/...</automated>
|
||
|
|
</verify>
|
||
|
|
<acceptance_criteria>
|
||
|
|
- config/config.go contains `baseHz = 2500.0` (NOT 1200.0)
|
||
|
|
- config/config.go contains `numSteps = uint32(31)` (NOT 24)
|
||
|
|
- config/config.go contains `// autoAssignFreq computes a deterministic frequency in [2500, 4000] Hz`
|
||
|
|
- config/config.go still contains `stepHz = 50.0` (unchanged)
|
||
|
|
- `go build ./config/...` exits 0
|
||
|
|
</acceptance_criteria>
|
||
|
|
<done>autoAssignFreq produces frequencies in [2500, 4000] Hz range with 31 steps of 50 Hz</done>
|
||
|
|
</task>
|
||
|
|
|
||
|
|
<task type="auto">
|
||
|
|
<name>Task 2: Update config_test.go auto-assign range assertion</name>
|
||
|
|
<files>config/config_test.go</files>
|
||
|
|
<read_first>
|
||
|
|
- config/config_test.go (search for `1200.0` and `2350.0` — the TestAutoFreqAssignment assertion around line 363)
|
||
|
|
</read_first>
|
||
|
|
<action>
|
||
|
|
1. In `TestAutoFreqAssignment` (around line 363), update the range assertion:
|
||
|
|
|
||
|
|
Change from:
|
||
|
|
```go
|
||
|
|
if cfg.BaseHz < 1200.0 || cfg.BaseHz > 2350.0 {
|
||
|
|
t.Errorf("GameServer BaseHz: got %v, want in [1200, 2350]", cfg.BaseHz)
|
||
|
|
}
|
||
|
|
```
|
||
|
|
|
||
|
|
To:
|
||
|
|
```go
|
||
|
|
if cfg.BaseHz < 2500.0 || cfg.BaseHz > 4000.0 {
|
||
|
|
t.Errorf("GameServer BaseHz: got %v, want in [2500, 4000]", cfg.BaseHz)
|
||
|
|
}
|
||
|
|
```
|
||
|
|
|
||
|
|
2. Also update the test comment at the top of TestAutoFreqAssignment (around line 344-346) from:
|
||
|
|
```
|
||
|
|
// NO [sounds.GameServer] -> FreqCfgs contains "GameServer" entry with BaseHz in [1200, 2350]
|
||
|
|
```
|
||
|
|
To:
|
||
|
|
```
|
||
|
|
// NO [sounds.GameServer] -> FreqCfgs contains "GameServer" entry with BaseHz in [2500, 4000]
|
||
|
|
```
|
||
|
|
|
||
|
|
3. Check if `TestAutoFreqSkipsBuiltins` (around line 563) references `BaseHz == 175.0` for HTTPS. After Plan 01 rebalances HTTPS to 150.0, this test will need its expected value updated from `175.0` to `150.0`. Find the assertion and update it.
|
||
|
|
|
||
|
|
Search for `175.0` in config_test.go and update to `150.0` wherever it references the built-in HTTPS BaseHz.
|
||
|
|
</action>
|
||
|
|
<verify>
|
||
|
|
<automated>cd /home/dev/workspace/yoloyolo && go test ./config/... -v -count=1 -run "TestAutoFreq"</automated>
|
||
|
|
</verify>
|
||
|
|
<acceptance_criteria>
|
||
|
|
- config/config_test.go contains `cfg.BaseHz < 2500.0 || cfg.BaseHz > 4000.0` (NOT 1200/2350)
|
||
|
|
- config/config_test.go contains `want in [2500, 4000]` in the error message
|
||
|
|
- config/config_test.go contains `BaseHz in [2500, 4000]` in the test comment
|
||
|
|
- If HTTPS 175.0 was referenced, it is now 150.0
|
||
|
|
- `go test ./config/... -run TestAutoFreqAssignment` exits 0
|
||
|
|
- `go test ./config/... -run TestAutoFreqDeterministic` exits 0
|
||
|
|
- `go test ./config/... -run TestAutoFreqSkipsBuiltins` exits 0
|
||
|
|
</acceptance_criteria>
|
||
|
|
<done>All auto-assign test assertions match new [2500, 4000] range; HTTPS built-in reference updated to 150.0 if applicable; all config tests pass</done>
|
||
|
|
</task>
|
||
|
|
|
||
|
|
</tasks>
|
||
|
|
|
||
|
|
<verification>
|
||
|
|
- `go build ./config/...` compiles without errors
|
||
|
|
- `go test ./config/... -v -run "TestAutoFreq"` passes all auto-freq tests
|
||
|
|
- `go test ./...` passes full suite (cross-package with synth changes from Plan 01)
|
||
|
|
</verification>
|
||
|
|
|
||
|
|
<success_criteria>
|
||
|
|
- autoAssignFreq base is 2500.0 Hz, not 1200.0 (FREQ-04)
|
||
|
|
- numSteps is 31, producing range [2500, 4000] with 50 Hz steps
|
||
|
|
- No collision possible between built-in frequencies (max 2449 Hz) and auto-assign (min 2500 Hz)
|
||
|
|
- All config tests pass with updated assertions
|
||
|
|
</success_criteria>
|
||
|
|
|
||
|
|
<output>
|
||
|
|
After completion, create `.planning/phases/09-frequency-design-and-group-architecture/09-02-SUMMARY.md`
|
||
|
|
</output>
|