Skip to content

CL-6484: @corbits/mocks skeleton and Ollama provider - #219

Merged
TheGreatAxios merged 2 commits into
mainfrom
cl-6484-mocks
Aug 21, 2026
Merged

TheGreatAxios merged 2 commits into
mainfrom
cl-6484-mocks

Conversation

@TheGreatAxios

Copy link
Copy Markdown
Contributor

Summary

Unit 1 of CL-6484: package skeleton for @corbits/mocks plus the Ollama provider mock. Do not merge — reviewer sign-off requested per task instructions.

  • Per-provider entry point (@corbits/mocks/ollama); root export (.) is intentionally empty, existing only so the workspace's check:packages bare-import probe resolves — no barrel that drags providers in.
  • Ollama mock covers the three endpoints actually called (@workbench/hub-client's credential-test.ts): GET /api/tags, POST /api/show, POST /v1/chat/completions (tool calls, streaming and non-streaming).
  • Request capture + assertions are the highest-value half: expectModel, expectToolsDeclared, expectMessageRoles, expectHistoryContains — the shape of check that would have caught CL-6448 (tools: [], no history reaching the model).
  • Usable in-process (mock.fetch as a Fetch-API handler) and as a server (mock.listen()) for the e2e path.
  • src/ollama/cl-6448-demo.test.ts demonstrates the assertions failing against CL-6448's exact broken request shape, and passing once tools/history are sent correctly.

Deferred (see README roadmap)

  • OpenAI-compatible and Anthropic provider mocks
  • Adversarial output catalogue (malformed tool names, truncated JSON, refusals, tool-name-length edges)
  • Converging packages/evals' scattered fakes (github MCP fake, stub inference) onto this package

Not verified

  • Full repo-wide bun run scripts/checks/packages.ts (packs/consumes every workspace package) was still running in the background when this PR was opened due to its runtime; scoped typecheck/test for packages/mocks and repo-wide bun run lint are green.
  • Not tested against a real Ollama instance — this is a mock of the wire contract inferred from credential-test.ts/model-capability.ts, not a live-traffic capture.

Test plan

  • bun test in packages/mocks (17 pass)
  • bun run typecheck in packages/mocks
  • bun run lint from repo root (0 errors)
  • Full check:packages repo-wide run (in progress at PR open time)

Deterministic mock of the inference boundary's Ollama path: scriptable
/api/tags and /api/show catalogue, /v1/chat/completions with tool-call,
streaming, and non-streaming support, and request capture with readable
assertions (expectModel, expectToolsDeclared, expectMessageRoles,
expectHistoryContains) covering the contracts that broke in CL-6448 and
CL-6477. Usable in-process (fetch handler) and as a real server (listen()).

Per-provider entry point (@corbits/mocks/ollama) only; no barrel. OpenAI-
compatible/Anthropic providers, the adversarial output catalogue, and
converging packages/evals' scattered fakes are left for later units.
.fetch took a single Request, but every real caller this package plugs
into (@workbench/hub-client's testProviderCredential,
fetchOllamaModelCatalog, fetchOllamaModelCapabilities) calls fetchImpl
as (url: string, init) => Promise<Response> — the same shape as global
fetch. The mismatch didn't just fail to typecheck; forced through a
cast it silently returned undefined at runtime, because those callers
swallow throws as "unreachable".

.fetch now mirrors global fetch's (input, init?) signature, building
the Request internally; routing logic moved to a private route()
method so listen()'s Bun.serve handler isn't affected. Added
hub-client-consumer.test.ts, which wires the mock into the real
hub-client functions instead of calling .fetch directly — the gap that
let the original signature ship. Also dropped a stale comment
referencing a nonexistent expectStream helper.
@TheGreatAxios

Copy link
Copy Markdown
Contributor Author

Fixed the FetchLike signature defect from review:

  • `OllamaMock.fetch` now mirrors global `fetch`'s `(input: string | Request, init?) => Promise` shape (building the `Request` internally) instead of taking a single `Request`. This is what makes `fetchImpl: ollama.fetch` actually assignable to `@workbench/hub-client`'s `FetchLike` with no cast — the README's own Quickstart now typechecks.
  • Routing logic moved to a private `route(request: Request)` method; `listen()`'s `Bun.serve` handler calls that directly so it isn't affected by the public signature change.
  • Added `src/ollama/hub-client-consumer.test.ts`, which wires the mock into the real `@workbench/hub-client` functions (`testProviderCredential`, `fetchOllamaModelCatalog` + `preferCompletionCapable`) instead of calling `.fetch` directly — the CL-6477 scenario (embeddinggemma present, chat model correctly selected). This is the test that would have caught the original signature mismatch: it wouldn't typecheck without the fix.
  • Removed the stale `expectStream` comment in `mock.ts`.

Scoped `typecheck`/`test` for `packages/mocks` and repo-wide `bun run lint` are green. Repo-wide `check:packages` (packs/consumes every workspace package, including the new `@workbench/hub-client` workspace devDependency) is running to completion before merge — will confirm here.

Still not merging per instructions.

@TheGreatAxios
TheGreatAxios merged commit 5d91691 into main Aug 21, 2026
2 checks passed
@TheGreatAxios
TheGreatAxios deleted the cl-6484-mocks branch August 25, 2026 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant