Home

mweinbach / agent-coworker

publicmweinbach/agent-coworker
Overview Code History Branches Pull requestsIssuesInsights
main
HomeOverview Code PRsIssues

test: cover model discovery cache fail-closed gates

open
Stack 2/2
#350 opened by cursor[bot]cursor/missing-test-coverage-7b13→main
Conversation0
cursor[bot]
Commits
0
Files changed…
opened this pull request
Author
· 4 days ago

Risky behavior now covered

discoverProviderModelsWithCache is the shared gate behind OpenAI-compatible, Codex, Bedrock, and LM Studio catalogs. These tests lock the fail-closed policy:

  • A fresh cache is served without calling discovery, and only for the adapter's endpoint scope.
  • forceRefresh and ttlMs: 0 still verify the live source. A zero TTL does not leave an expiry that would make the next read look fresh.
  • An app-server cache with a default reasoning effort and no advertised choices is refreshed. The same gap on an API cache, or a complete app-server cache, stays fresh.
  • A static or empty live result does not replace a non-static cache or rewrite the file. Empty results are persisted only when the adapter allows them. A static result with no cache is returned and not written.
  • Discovery errors and timeouts keep the cached catalog and record the failure. With no cache, the error is rethrown and nothing is written.
  • A successful write drops blank ids, duplicate ids, and secret runtime fields.
  • Cache documents with the wrong version, provider, source, or timestamp are treated as a miss and do not short-circuit discovery.

Test files added/updated

  • Added test/providers/model-discovery-service.test.ts

Why these tests materially reduce regression risk

Catalog callers already exercise a few provider paths, but the shared policy was untested on its own. A change that honored a fresh cache when TTL is zero, wiped a live catalog with a static or empty response, mixed endpoint scopes, or trusted a malformed cache file would ship the wrong models or reasoning efforts without a failing unit test.

Validation

  • bun run test -- test/providers/model-discovery-service.test.ts test/platform-boundary.test.ts (9 + 1 pass)
  • bunx biome check test/providers/model-discovery-service.test.ts
  • bun run typecheck
Open in Web View Automation 
This branch can’t be merged automatically yet
Branch comparison failed — verify branches still exist in storage.
0 approving reviews
None yet
Checks
No checks recorded
Fast-forward
Source must contain the target branch tip
main ← cursor/missing-test-coverage-7b13

Sign in to comment.

Stack

2/2
1

Merge readiness

Checking mergeability after the indexing worker computes the current branch state.

Autopilot

Debug

Reviews

Approved0
ReviewersNone yet

Configure an OpenRouter key in repository settings.

Update README.md

#125 mobile-fixes ← main

Updated 4 months ago

merged
2

test: cover model discovery cache fail-closed gates

#350 main ← cursor/missing-test-coverage-7b13

Updated 4 days ago

open