Relates to WI-97
chatd kept a 10 second cache of every enabled AI provider, with a pubsub
subscription to invalidate it. The only way to reach it was calling
`resolveUserProviderAPIKeys` with a `uuid.Nil` provider ID, and nothing
can pass one. Every caller either goes through
`resolveNormalizedProviderForModelConfig`, which requires a valid
provider ID, reads its model configs from a query that inner joins
`ai_providers`, or passes the ID of a provider it just fetched.
This PR just deletes the cache, its subscription, the `uuid.Nil` branch
and the helpers that only that branch used, i.e. `aiProviderConfigs`,
`ensureUniqueConfiguredProviderTypes`,
`chatprovider.PruneDisabledProviderKeys` and `Config.ProviderAPIKeys`.
Most of the added lines are `newInternalTestServer` call sites losing
their keys argument.
I don't think we want to make the cache reachable again, or add a new
one. By the top of this stack the AI provider read is one query per
generation step, about 2% of what a step runs, so a cache would save
very little and could serve a stale provider. The larger costs are chatd
loading the chat row again to authorise each of its own queries, and
building the turn's environment on steps that never call the model. I
think fixing those is the better long term solution, since neither needs
a cache, and that's tracked in CODAGT-1657.
For now, #32840, further up the stack, consolidates the reads chatd
repeats when it builds a turn's environment, which takes a plain turn to
58 queries (`main` was at 94 when I measured it).
To check that nothing relied on the cache, I ran a live chat on the top
of the stack and, between turns, disabled and re-enabled its provider,
swapped the provider's key for an invalid one and back, and deleted the
provider. Each change applied to the very next turn, the same as on a
local `main` build.
I came across this whilst working on #32811, which takes
`ai_provider:read_secret` away from chatd. The cache holds full provider
rows, base URL and settings included, which chatd can't load without
that permission. Keeping it would've meant rebuilding it on the
summaries from #32837, for a path nothing reaches, so I've deleted it
and split the deletions out of #32811 to be reviewed on their own. This
is on top of #32899 in the stack.