feat(types): centralize provider identifiers#952
Conversation
📝 WalkthroughWalkthroughAdds shared active and retired provider identifier registries with derived public types, re-exports them from ChangesProvider Identifier Registry
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related issues
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/types/src/provider-settings.ts (1)
119-119: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueRestore compile-time immutability for the derived provider name arrays.
Previously, the hardcoded arrays were defined using
as const, which made themreadonlyat compile time. SinceObject.valuesreturns a mutable array and the current tuple casts drop thereadonlymodifier, the derived arrays are now technically mutable at compile time. Consider casting these asreadonlytuples to match the previous safety guarantees (Zod's.enum()natively acceptsreadonlytuples).
packages/types/src/provider-settings.ts#L119-L119: addreadonlyto theproviderNamestuple cast:as readonly [ProviderIdentifier, ...ProviderIdentifier[]].packages/types/src/provider-settings.ts#L132-L135: addreadonlyto theretiredProviderNamestuple cast.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/types/src/provider-settings.ts` at line 119, Restore compile-time immutability for the derived provider name tuples by adding the readonly modifier to the tuple casts in providerNames and retiredProviderNames. Update both affected sites in packages/types/src/provider-settings.ts (lines 119-119 and 132-135); no other behavior should change.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@packages/types/src/provider-settings.ts`:
- Line 119: Restore compile-time immutability for the derived provider name
tuples by adding the readonly modifier to the tuple casts in providerNames and
retiredProviderNames. Update both affected sites in
packages/types/src/provider-settings.ts (lines 119-119 and 132-135); no other
behavior should change.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: bc71e3be-4647-4f05-9b1e-92df2eb2e702
📒 Files selected for processing (4)
packages/types/src/__tests__/provider-identifiers.test.tspackages/types/src/index.tspackages/types/src/provider-identifiers.tspackages/types/src/provider-settings.ts
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Review: centralize provider identifiers
The core types change looks solid — the registry order in provider-identifiers.ts exactly preserves the previous providerNames ordering (dynamic → local → internal → custom → faux → static), serialized values are unchanged, and the new tests cover uniqueness, active/retired separation, schemas, and type guards well. Nice work on that part.
However, this PR contains two changes that are unrelated to its stated scope, one of which looks like a regression. Findings below with line anchors.
1. Race-condition regression — locking removed from cache invalidation
src/core/task-persistence/TaskHistoryStore.ts:432 (invalidate) and src/core/task-persistence/TaskHistoryStore.ts:448 (invalidateAll)
Both methods previously ran inside withLock(...), guaranteeing they couldn't interleave with an in-flight upsert/writeTaskFile. That guard is now gone:
invalidate()can read a task file while anupsertfor the same task is mid-write, get the stale contents, and repopulate the cache with stale data after the write lands.invalidateAll()can clear the cache mid-write and have the in-flight write re-add its entry afterwards, leaving the cache in exactly the state the caller tried to clear.
This isn't hypothetical — the two deleted tests in src/core/task-persistence/__tests__/TaskHistoryStore.spec.ts ("waits for an in-flight write before refreshing the cache" and "waits for an in-flight write before clearing the cache") were written specifically to pin this behavior. Deleting the lock and the tests that guarded it in the same PR, without any justification, reads as an accidental regression. If the lock removal is intentional (e.g. deadlock concern — note withLock is non-reentrant), it needs its own PR with an explanation and replacement coverage.
2. Out-of-scope workflow change
.github/workflows/code-qa.yml — removal of the "Upload coverage reports to GitHub" artifact step
Nothing in the PR description mentions CI coverage artifacts, and the PR explicitly describes itself as a foundational types-only change ("intentionally does not migrate provider category collections or production consumers"). If this upload step should go, it deserves its own PR so the intent and any downstream consumers of those artifacts can be evaluated separately. If it came along accidentally (branching off a dirty worktree?), it should be reverted here.
3. Misleading doc comment (nit)
src/core/task-persistence/TaskHistoryStore.ts:445-447
The new comment says "Clear all in-memory cache and reload from index", but the method only clears the cache — it no longer reloads anything (the caller in webviewMessageHandler.ts:966-968 follows up with reconcile() itself). The previous wording ("a subsequent reconcile() repopulates them") described this accurately; the new one overstates what the method does.
4. Nit — unchecked non-empty assertion
packages/types/src/provider-settings.ts:119 and :132
Object.values(providerIdentifiers) as [ProviderIdentifier, ...ProviderIdentifier[]] asserts a non-empty tuple for z.enum, but nothing enforces that at the type level — if the registry were ever emptied this cast would lie and z.enum would throw at module load. The runtime tests make this unlikely to slip through, so it's fine as-is; just noting that the safety now lives in tests rather than types.
Summary: the provider-identifier registry itself is good to ship. I'd ask for the TaskHistoryStore locking changes (and deleted tests) and the code-qa.yml change to be split out or reverted before merge — they're unrelated to #951 and the lock removal appears to reintroduce a real race.
(Note: posted as a single review comment rather than per-line inline threads — inline threading wasn't available from my tooling, hence the explicit file:line anchors.)
Summary
Scope
This foundational PR intentionally does not migrate provider category collections or production consumers.
Testing
npx vitest run src/__tests__/provider-identifiers.test.ts src/__tests__/provider-settings.test.tsnpm run check-typesnpm run lintnpm test(236 tests passed)Closes #951
Tracking issue: #944
Summary by CodeRabbit
New Features
Tests