provider-mock-e2e guide
Overview
provider-mock-e2e is the cross-platform qualification suite that tests real, unmodified AI coding agent CLIs installed by lminstall against a checksum-verified lmmock loopback server. It verifies that 13 distinct provider CLIs can be configured hermetically on Linux, macOS, and Windows without vendor credentials, telemetry leaks, or global configuration pollution.
Reusable five-step qualification procedure
Every provider leg executes the same five-step contract:
- Step 1 — Binary acquisition via lminstall: scripts/run.py runs lminstall status <provider> --json and extracts the exact installed binary path, refusing global PATH fallbacks.
- Step 2 — Checksum verification and fixture compilation: scripts/prepare.py verifies the lmmock release SHA256SUMS and compiles a checked llm-api.lms policy where advertised built-in tools do not force a tool call during the no-tool text smoke test (retaining the stock handler separately for wire-shape probes).
- Step 3 — Isolated HOME and environment synthesis: scripts/probe.py builds a clean environment map pointing HOME, USERPROFILE, XDG_CONFIG_HOME, XDG_DATA_HOME, XDG_CACHE_HOME, XDG_STATE_HOME, LOCALAPPDATA, and APPDATA to a fresh scratch directory and writes the provider's exact config file (JSON or TOML).
- Step 4 — Prompt execution and reply extraction: sends Reply with exactly PROVIDER_MOCK_OK_129. Do not call any tools. with stdin closed and parses the provider's JSON, JSONL, or plain-text stdout.
- Step 5 — Exact oracle, request audit, and negative control: verifies exit code 0 and exact reply PROVIDER_MOCK_OK_129, invokes the same oracle with a wrong expected string to prove it raises AssertionError, and verifies the lmmock request audit.
Cross-platform details: Windows batch bypass and Hermes gateway reaping
Two platform-specific safeguards prevent subtle false failures:
- Windows npm .cmd wrapper resolution (tool_argv in scripts/probe.py): on Windows, npm's generated .cmd batch wrappers alter empty and JSON-quoted arguments (such as --tools "" or --mcp-config '{"mcpServers":{}}'). When the binary ends in .cmd, tool_argv inspects the owned node_modules/<package>/package.json bin entry, verifies the target stays inside the package directory, and invokes either the native .exe or node directly to preserve exact argv boundaries.
- Hermes detached gateway cleanup (scripts/cleanup-hermes.py): Hermes (chat --native) spawns a per-HOME background gateway process even for a one-shot query. The finally block runs cleanup-hermes.py, which reads only the scratch HOME gateway PID file, verifies its process kind, HOME, and start-time fingerprint, and terminates that exact numeric PID without scanning or touching any other process on the machine.
Endpoint matrix across wire families
The 13 qualified tools span four distinct LLM HTTP wire protocols served by lmmock on loopback origin B (http://127.0.0.1:PORT) and V (B/v1):
- Anthropic Messages (POST /v1/messages): Claude Code (claude --bare -p --output-format json) and DeepSeek Harness (dsh headless, which issues two POST /v1/messages calls).
- OpenAI Responses (POST /v1/responses): Codex (codex exec --skip-git-repo-check --json with wire_api="responses") and Miniplayer (miniplayer run --model openai/mock-agent).
- Google Gemini streamGenerateContent (POST /v1beta/models/*:streamGenerateContent?alt=sse): Gemini CLI (gemini -m gemini-2.5-flash with GEMINI_CLI_TRUST_WORKSPACE=true) and Antigravity CLI (agy -p --model gemini-3.8-flash with modelProvider="gemini").
- OpenAI Chat Completions (POST /v1/chat/completions): GitHub Copilot (BYOK mode with COPILOT_OFFLINE=true), OpenCode, Kimi Code CLI (.kimi-code/config.toml with --output-format stream-json), Qwen Code, Pi Coding Agent, lmplayer, and Hermes (chat --native).