Repository navigation
fix(session): reject an unknown configured provider before unbound routing - #2976
Conversation
…uting When every registered deep provider rejected a target, select() returned an intentionally unbound success for any concrete environment selector, including one that names no registered provider. A misconfigured REA_ANALYSIS_PROVIDER therefore opened the target unbound, and the later deep-operation diagnostic blamed target support instead of the unknown configuration. The same identifier requested explicitly already failed with unknown_provider. Take the unbound shortcut only for a registered environment preference. An unknown configured identifier now reaches concrete selection and fails with unknown_provider, matching the explicit request. Registered preferences and auto still leave artifact-only targets unbound. Fixes morluto#2592
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
|
Thanks for making an unknown configured provider report a configuration error, @555aaditya. That points users to the incorrect provider name instead of blaming the target. Welcome to REA. |
|
Thanks @morluto, glad it helps! Happy to be here. |
Summary
Fixes #2592.
When every registered deep provider rejects a target (for example an archive target, where no deep provider applies),
AnalysisProviderRegistry.select()returned an intentionally unbound success for any concrete environment selector. That included an identifier no provider is registered under. So a misconfiguredREA_ANALYSIS_PROVIDER=missing-provideropened the target unbound. The first deep operation then failed withtarget_unsupported, blaming the target instead of the unknown configuration. Passing the same identifier explicitly already failed correctly withunknown_provider.After this change, the unbound shortcut applies only to a registered environment preference. An unknown configured identifier goes on to concrete selection and fails with
unknown_provider, the same as an explicit request. Registered preferences andautostill leave artifact-only targets unbound, so artifact-only routing is unchanged.Problem and expected behavior
Smallest trigger: a registry built with one registered candidate
alphaand the default selectormissing, thenselect(archiveTarget)with no explicit request, wherealphareportstargetSupport.status === "unsupported"for the target.select(target)with configuredmissingok,binding: null; a laterunboundOperationErrorreportstarget_unsupportederr,selection_reason: "unknown_provider",requested_provider_id: "missing"select(target, "missing")(explicit)unknown_providerunknown_provider(unchanged)select(target)with configuredalpha(registered)ok, unboundok, unbound (unchanged)select(target)withautook, unboundok, unbound (unchanged)Violated invariant: AGENTS.md says unresolved identity must stay unknown rather than be treated as absent or aligned. The shortcut decided "intentionally unbound" before the identity of the configured provider was resolved; that check only ran later, in
#selectConcrete.Change and scope
The owning check is the unbound shortcut in
AnalysisProviderRegistry.select(), so the fix goes there. The guardselector !== "auto"becomesthis.#byId.has(selector).autois reserved and can never be a registered id (analysisProviderIdSchemarefuses it), so the new condition is strictly narrower than the old one. Every selector it excludes is an unknown concrete id, and those now go through the existing#selectConcretepath, which already producesunknown_providerwith the full candidate list.Not included: rejecting the unknown identifier when configuration is parsed (
src/contracts/providerSelection.ts). The configuration boundary doesn't know which providers are registered. The registry does, and it already owns theunknown_providerdiagnosis for explicit requests, so both paths now share it.Contribution scope: an ordinary fix within an existing boundary, so a maintainer scope decision is not applicable.
Contract and boundary impact
src/application/binary/AnalysisProviderRegistry.ts, inselect()(application layer).open_binary(and the CLI paths that open a target) now reportunknown_providerinstead of succeeding unbound, but only whenREA_ANALYSIS_PROVIDERnames an unregistered provider and no registered provider supports the target.#selectConcretereturns before evaluating any candidate.Expected effects:
(No target interaction: this is provider selection logic over already-parsed target metadata and candidate status.)
Evidence and regression coverage
src/application/binary/AnalysisProviderRegistry.test.ts, testrejects an unknown environment preference even when every candidate rejects the target. It checks that the configured unknown selector and the explicit unknown selector both fail withunknown_provider,requested_provider_id: "missing"andcandidate_ids: ["alpha"]. The existing testkeeps artifact-only targets unbound under auto or environment preferencestill covers the registered-preference andautocontrols from the issue's restoration check.1 failed | 6 passed), because the configured unknown selector returns an unbound success. With the change, all 7 tests in the file pass.unknown_providerselection error, now also returned for the configured-default path.open_binarysession with a real misconfiguredREA_ANALYSIS_PROVIDER. Production routing forwards this registry result unchanged, and the provider-selection MCP boundary test passes.Validation performed
All run on macOS (arm64), Node 26.5.0, npm 11.17.0, with locked dependencies, rebased on current
origin/main:npx vitest run src/application/binary/AnalysisProviderRegistry.test.ts: with the source fix reverted, 1 failed (the new test) and 6 passed.npx vitest run src/application/binary/: 6 files, 45 passed.npx vitest run tests/boundary/mcp/providerSelectionMcp.test.ts src/application/binary/BinarySessionStatus.test.ts: passed.npm run check:fast(typecheck + lint + module boundaries): passed, also via the pre-push hook.npx oxfmt --checkandnpx oxlinton both changed files: clean.Compatibility, safety, and release
REA_ANALYSIS_PROVIDERset to an unregistered id, which previously opened artifact-only targets "successfully", now gets theunknown_providerdiagnostic and should correct the variable or remove it.Before merge
type(scope): outcome.