CL-6484: @corbits/mocks skeleton and Ollama provider - #219
Merged
Merged
Conversation
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.
Contributor
Author
|
Fixed the FetchLike signature defect from review:
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. |
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Unit 1 of CL-6484: package skeleton for
@corbits/mocksplus the Ollama provider mock. Do not merge — reviewer sign-off requested per task instructions.@corbits/mocks/ollama); root export (.) is intentionally empty, existing only so the workspace'scheck:packagesbare-import probe resolves — no barrel that drags providers in.@workbench/hub-client'scredential-test.ts):GET /api/tags,POST /api/show,POST /v1/chat/completions(tool calls, streaming and non-streaming).expectModel,expectToolsDeclared,expectMessageRoles,expectHistoryContains— the shape of check that would have caught CL-6448 (tools: [], no history reaching the model).mock.fetchas a Fetch-API handler) and as a server (mock.listen()) for the e2e path.src/ollama/cl-6448-demo.test.tsdemonstrates the assertions failing against CL-6448's exact broken request shape, and passing once tools/history are sent correctly.Deferred (see README roadmap)
packages/evals' scattered fakes (github MCP fake, stub inference) onto this packageNot verified
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; scopedtypecheck/testforpackages/mocksand repo-widebun run lintare green.credential-test.ts/model-capability.ts, not a live-traffic capture.Test plan
bun testinpackages/mocks(17 pass)bun run typecheckinpackages/mocksbun run lintfrom repo root (0 errors)check:packagesrepo-wide run (in progress at PR open time)