You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor(provider): expose LookupAlias/EachAlias accessors for the alias table
The Aliases map is package-level mutable global state. External consumers (pkg/config/gather.go, pkg/runtime/model_switcher.go) reach into the map directly, and tests that need to assert what happens when an alias has only a BaseURL or only a TokenEnvVar have to either pick whatever the live table happens to contain or risk corrupting global state for parallel tests.
Introduce two accessors that hide the storage detail:
- LookupAlias(name) (Alias, bool) — single lookup, replaces all uses of Aliases[name].
- EachAlias() iter.Seq2[string, Alias] — Go 1.23 iterator for ranging.
Migrate every external call site (gather.go, model_switcher.go) and all in-package usage outside provider.go to the accessors. The Aliases var stays exported for backwards compatibility but its godoc now points readers at the accessors and notes that direct mutation is unsupported.
Add unit tests that lock in the contracts (LookupAlias case-sensitivity and zero-value miss semantics, EachAlias completeness and early-termination via break).
Behaviour is unchanged. Both new accessors at 100% coverage; package coverage 96.4% -> 96.5%.
Assisted-By: docker-agent
0 commit comments