Symptom
ModelPrice.builtInDefaults comment says "ordered longest-prefix-first" but the array is not actually sorted by prefix length. Currently only the gpt-4o-mini / gpt-4o overlap is handled correctly by manual positioning. Future additions could introduce prefix shadowing bugs silently.
Prior Hypotheses
N/A — not a bug
Related Files
ModelProxy/Models/ModelPrice.swift:21-41 — builtInDefaults array
ModelProxy/Models/ModelPrice.swift:44-53 — lookup() uses .first with prefix matching
Notes
Two options:
- Sort the array programmatically by descending prefix length at lookup time (or use a computed property)
- Add a unit test that asserts no entry's prefix is a prefix of a later entry's prefix (catches shadowing at compile/test time)
Option 2 is lighter and catches the actual failure mode.
Symptom
ModelPrice.builtInDefaultscomment says "ordered longest-prefix-first" but the array is not actually sorted by prefix length. Currently only thegpt-4o-mini/gpt-4ooverlap is handled correctly by manual positioning. Future additions could introduce prefix shadowing bugs silently.Prior Hypotheses
N/A — not a bug
Related Files
ModelProxy/Models/ModelPrice.swift:21-41—builtInDefaultsarrayModelProxy/Models/ModelPrice.swift:44-53—lookup()uses.firstwith prefix matchingNotes
Two options:
Option 2 is lighter and catches the actual failure mode.