Plan 127: Route tests for /api/v1/agents/models merge/degradation contract
Executor instructions: Follow this plan step by step. Run every
verification command and confirm the expected result before moving to the
next step. If anything in the "STOP conditions" section occurs, stop and
report — do not improvise.
Drift check (run first): git diff --stat 34113ac..HEAD -- apps/dashboard/src/routes/api/v1/agents/models.ts
On mismatch, re-read live files.
Status
- Priority: P3
- Effort: S
- Risk: LOW
- Depends on: none
- Category: tests
- Planned at: commit
34113ac, 2026-08-26
- Issue: (filled after publish)
Why this matters
/api/v1/agents/models (~315 lines, 3 commits since July — tied-highest churn
of untested routes) merges FOUR upstream model catalogs with per-step fail-soft
degradation and feeds the model picker for paying cloud users. Leaf modules are
tested; the route's own contract is not: outage degradation ordering,
last-wins preset merging, the "sole configured-authority" filter, and auth
wiring. A regression either empties the picker or exposes unconfigured
providers.
Current state
apps/dashboard/src/routes/api/v1/agents/models.ts — loaders for registry /
OpenRouter dynamic models / AnyRouter presets / providers; per-step try/catch;
filterByConfiguredProviders; authorizeAgentApiRequest. Mock exemplar:
mv-designer.test.ts:11–29 (mock.module style).
Commands you will need
| Purpose |
Command |
Expected |
| New tests |
cd apps/dashboard && bun test src/routes/api/v1/agents --isolate |
pass |
| Full unit |
pnpm run test:unit |
pass |
Scope
In scope: NEW test file beside the route (models.test.ts or
__tests__/models.test.ts matching siblings).
Out of scope: any source change.
Git workflow
- Branch:
advisor/127-agents-models-tests
- Commit:
test(agents): cover models route merge and degradation
Steps
- Mock all four loader modules + auth. Assert:
- OpenRouter loader throws → response still contains registry + AnyRouter entries (200).
- Presets conflict → last-wins per current code (characterize actual order).
- A provider unconfigured locally has its catalog entries stripped even when its loader succeeds.
- Auth rejection → 401 before any loader runs (assert loader mocks untouched).
- Battery green.
Done criteria
STOP conditions
- Route internals not mock-seamable without refactor → characterize through the route export only as far as possible, report gaps.
Maintenance notes
- Update when model-catalog sources change.
Plan 127: Route tests for /api/v1/agents/models merge/degradation contract
Status
34113ac, 2026-08-26Why this matters
/api/v1/agents/models(~315 lines, 3 commits since July — tied-highest churnof untested routes) merges FOUR upstream model catalogs with per-step fail-soft
degradation and feeds the model picker for paying cloud users. Leaf modules are
tested; the route's own contract is not: outage degradation ordering,
last-wins preset merging, the "sole configured-authority" filter, and auth
wiring. A regression either empties the picker or exposes unconfigured
providers.
Current state
apps/dashboard/src/routes/api/v1/agents/models.ts— loaders for registry /OpenRouter dynamic models / AnyRouter presets / providers; per-step try/catch;
filterByConfiguredProviders;authorizeAgentApiRequest. Mock exemplar:mv-designer.test.ts:11–29(mock.modulestyle).Commands you will need
cd apps/dashboard && bun test src/routes/api/v1/agents --isolatepnpm run test:unitScope
In scope: NEW test file beside the route (
models.test.tsor__tests__/models.test.tsmatching siblings).Out of scope: any source change.
Git workflow
advisor/127-agents-models-teststest(agents): cover models route merge and degradationSteps
Done criteria
STOP conditions
Maintenance notes