Fix stale session routes for removed providers#90500
Conversation
|
Codex review: needs maintainer review before merge. Reviewed June 9, 2026, 4:50 AM ET / 08:50 UTC. Summary PR surface: Source +154, Tests +488. Total +642 across 4 files. Reproducibility: yes. source inspection shows current main returns persisted provider/model state before visibility checks and Review metrics: none identified. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land the focused runtime guard if maintainers accept fallback-to-default semantics, and track doctor/reset-session cleanup separately. Do we have a high-confidence way to reproduce the issue? Yes, source inspection shows current main returns persisted provider/model state before visibility checks and Is this the best way to solve the issue? Yes, if maintainers accept the policy tradeoff; resolver-level validation plus conditional AGENTS.md: found and applied where relevant. Codex review notes: model gpt-5.5, reasoning high; reviewed against 257b251e2690. Label changesLabel justifications:
Evidence reviewedPR surface: Source +154, Tests +488. Total +642 across 4 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
76baa71 to
0f84019
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
0f84019 to
b23c616
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Command router queued. I will update this comment with the next step. Re-review progress:
|
b23c616 to
57011af
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
@clawsweeper re-review |
68ec270 to
d7f2aa2
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
d7f2aa2 to
7f9161c
Compare
|
Rebased on current Verification on this head: GitHub checks are currently green on the updated head. @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Command router queued. I will update this comment with the next step. Re-review progress:
|
Summary
What problem does this PR solve?
resolveSessionModelRef, and wireschat.sendto pass catalog visibility when provider rows, replace mode, or a non-default persisted session route can make stale providers risky.providerOverride/modelOverrideand stale runtimemodelProvider/modelfields.Why does this matter now?
What is the intended outcome?
What is intentionally out of scope?
sessions.jsonentries on disk.What does success look like?
models.providerscontinue to work.What should reviewers focus on?
chat.sendloads catalog visibility at the right point for persisted session route validation.Linked context
Which issue does this close?
Closes #90471
Which issues, PRs, or discussions are related?
Related #90462
Was this requested by a maintainer or owner?
Real behavior proof (required for external PRs)
tsxafter this patch.{ "provider": "custom-api-deepseek-com", "model": "deepseek-v4-pro" }{ "shouldLoadCatalog": true, "resolved": { "provider": "openai", "model": "gpt-5.4" } }{ "provider": "plugin-provider", "model": "plugin-model" }The added
chat.sendregression stores a stale custom-provider session route, calls/stop, and assertsloadGatewayModelCatalogis not called before the stop response returns.Additional fresh/default custom-provider no-catalog proof run after the latest ClawSweeper review finding:
The added regressions prove fresh custom-provider sessions, default persisted custom-provider sessions, and explicitly configured provider overrides do not call for catalog validation; the direct
chat.sendtest assertsloadGatewayModelCatalogis not called before starting a fresh custom-provider send.Observed result after fix: stale persisted override/runtime fields are ignored when absent from current catalog/config, including when there are no remaining custom provider rows, while a valid catalog-backed provider outside
models.providersremains selected in default merge mode. Stop commands and fresh/default custom-provider sends now return before session model catalog validation is loaded.What was not tested: a live Windows gateway sending real paid-provider traffic; no paid provider credentials were used.
Proof limitations or environment constraints: this proof exercises the actual gateway session resolver and catalog-load predicate used by chat send, but does not perform an external model API call.
Before evidence (optional but encouraged): the added regression tests encode the prior failure shape; before this patch,
resolveSessionModelRefreturned persisted override/runtime state before checking current provider visibility.Tests and validation
Which commands did you run?
Results:
pnpm install --frozen-lockfile: passed.node scripts/run-vitest.mjs src/gateway/session-utils.test.ts: passed, 4 files / 456 tests on the final run.node scripts/run-vitest.mjs src/gateway/server.chat.gateway-server-chat-b.test.ts: passed, 2 files / 70 tests on the final run.node scripts/run-oxlint.mjs src/gateway/session-utils.ts src/gateway/session-utils.test.ts src/gateway/server-methods/chat.ts src/gateway/server.chat.gateway-server-chat-b.test.ts scripts/check-no-raw-channel-fetch.mjs: passed.pnpm run lint:tmp:no-raw-channel-fetch: passed.git diff --check: passed.pnpm tsgo:core:test: passed.node scripts/run-additional-boundary-checks.mjs --shard=2/4,3/4,4/4: passed after updating the qa-lab raw-fetch allowlist line numbers to match current main.custom-api-deepseek-com/deepseek-v4-pro.shouldLoadCatalog: trueandopenai/gpt-5.4.plugin-provider/plugin-model.chat.sendstarted successfully without callingloadGatewayModelCatalog; helper tests returnedfalsefor fresh, default persisted, and explicitly configured provider-row sessions.What regression coverage was added or updated?
models.providers.chat.sendtest shard after wiring catalog-aware session route resolution.chat.send/stopregression proving stop commands bypass session model catalog validation.chat.sendregressions proving fresh/default custom-provider sends skip unnecessary catalog validation.What failed before this fix, if known?
If no test was added, why not?
Risk checklist
Did user-visible behavior change? (
Yes/No)Yes.
Did config, environment, or migration behavior change? (
Yes/No)No config shape, environment, or migration behavior changed. Runtime route resolution now treats catalog-missing persisted session providers as invalid when chat routing has catalog visibility.
Did security, auth, secrets, network, or tool execution behavior change? (
Yes/No)Yes, provider/auth routing behavior changes for stale persisted session state.
What is the highest-risk area?
How is that risk mitigated?
models.providersare preserved when catalog visibility is available.Current review state
What is the next action?
What is still waiting on author, maintainer, CI, or external proof?
d7f2aa2e13c9808920e37dcfd6b33e0bd7531db4.Which bot or reviewer comments were addressed?
models.providersby validating persisted routes against catalog visibility instead of treating provider rows as exhaustive./stopbefore loading session model catalog validation.