Repository navigation
test(e2e): live tests for the deployed proxy use cases (MASTRA-768) - #4
Conversation
Seven live-only tests, one minimal request per use case: keyless and keyed /v1/models, Open SWE non-streaming Responses, streaming Responses, Claude Code streaming Messages on Haiku, Responses on claude-sonnet-4-6, and the OSWE-278 native Messages 429 asserted as a known failure. lib/live.ts classifies non-product failures: missing CLIPROXY_LIVE_URL or CLIPROXY_CLIENT_KEY and a rejected key exit 2; an unreachable proxy and a provider 429/5xx exit 3. Model requests assert X-CPA-TRACE-ID, which v7.3.17 and v8.0.13 both set once a credential is selected. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MASTRA-768 Verify our CLIProxyAPI use cases with Tester Army e2e in the fork
ContextEric's decision (2026-10-03): adopt Tester Army's Research done 2026-10-03. The plan was reviewed by Astra (gpt-6-astra, xhigh), and every accepted finding was verified against source. This body reflects that review. Use cases (studio2
|
| Client | Request shape | Status today |
|---|---|---|
| Open SWE | POST /v1/responses, non-streaming, gpt-5.6-sol at xhigh; store:false, include:[reasoning.encrypted_content], about 17 function tools, full history, no previous_response_id. About 28,300 requests; p99 110 s, max 632 s. stream:false is seen in the 9 sampled request dumps |
Works; idle since 2026-09-26 (Open SWE reviewer disabled) |
| Open SWE fallback (OSWE-113) | same, gpt-5.6-terra at max | 10 requests, all 429 |
| Claude Code CLI | HEAD /api/hello (404), then POST /v1/messages?beta=true, SSE |
Works (1 probe) |
| Native Messages | POST /v1/messages: Sonnet returns 429 (OSWE-278); Haiku returns 200 |
Sonnet fails |
| Responses with Claude models | POST /v1/responses, claude-sonnet-4-6 and claude-opus-5-5 |
Works |
/v1/models, keyless |
401 without a key | Works |
Planned, MASTRA-767: panel codex-cli |
Responses SSE, custom provider | 23.6% of panel reviewer attempts |
Planned, MASTRA-767: panel claude-cli |
Messages ?beta=true SSE |
4.1% of panel reviewer attempts |
| Planned: daily findings pass | claude --print; codex exec --output-schema |
1 run/day each |
| Planned: MASTRA-647 custom provider | /chat/completions, json_schema, include_usage |
Blocked: needs https or loopback |
Never exercised: client-side SSE on the Codex route, Chat Completions, websocket Responses, and Claude selection across more than one credential.
How the suite works
- Runner:
e2e0.16.0, exact pin. There is no command-only target type, so we use a no-op engine (defineEngine({ name, version, spiVersion: 1, platform })), which no documented example shows for HTTP-only use. The first test proves it works. Tests usefetch,expectandtoMatchSchema. We write our own SSE and websocket helpers. - Hermetic target: a wrapper script starts a mock upstream and the candidate binary (built from the checkout) on loopback ports.
- Credentials are config
codex-api-key/claude-api-keyentries withbase-urlpointing at the mock. They get providercodex/claude(internal/watcher/synthesizer/config.go:205-207) and pass through the same selector, affinity, quota-header capture, 429 classification and cooldown as OAuth logins. - OAuth files cannot be pointed at a mock.
- The serving credential is read from the
X-CPA-TRACE-IDresponse header (internal/logging/cpa_trace.go), formatted<time>-<auth_index>-<request_id>. - Sessions are pinned with
Session_id(Responses) orX-Claude-Code-Session-Id(Messages).
- Credentials are config
- Live tests: the runner accepts a plain-HTTP
urlonly for loopback hosts (e2e docsreference/config.mdx), and studio2 listens only on its tailnet address. So the live target declares noapp.url, and the tests fetchCLIPROXY_LIVE_URLdirectly. They run on studio2 and read the client key from the local config. There are no management checks: management accepts only loopback clients.
Scope
- U2, scaffold.
e2e/gets its own package and lockfile:e2e0.16.0,zod, oxfmt and oxlint, all exact pins, 100 columns,E2E_TELEMETRY_DISABLED=1.- A no-op engine.
hermetic/start.mjsstartshermetic/mock-upstream.mjson a loopback port, writes a temp config, and execs the candidate binary on{port}. The config holds the API-key credentials pointing at the mock, the client key and an empty auth dir, and the binary runs with-local-model.lib/sse.ts.- The first test, a keyless
GET /v1/modelsreturning 401, proves the no-op engine. - CI builds
./cmd/server, runs--target hermeticand uploadsreport.json.
- U3, hermetic protocol tests. These must pass on stock v8.0.13. The mock always answers Codex with upstream SSE that ends in a terminal response event, because the proxy calls upstream with SSE even for non-streaming clients (
codex_executor_execute.go:130-170).- Open SWE shape: non-streaming Responses with function tools,
store:falseandinclude:[reasoning.encrypted_content]. Assert the upstream request carries them, and assert the client gets a complete JSON response. - Streaming Responses (the
codex execshape): assert SSE event order. - Claude Code shape:
POST /v1/messages?beta=true, streaming, withX-Claude-Code-Session-Id. - Responses with a Claude model.
- Chat Completions with
json_schemaandinclude_usage. /v1/modelswith a key.- Failover: 429
usage_limit_reachedon A; the same request is served by B, named inX-CPA-TRACE-ID. - All credentials quota-cooled: the proxy returns its local 429
model_cooldown(sdk/cliproxy/auth/selector.go:528-541), not 503.
- Open SWE shape: non-streaming Responses with function tools,
- U4, hermetic selector tests. These land as the first commit of the MASTRA-765 PR, not in this suite's required baseline.
- Selector-specific: S1, S2, S3, S5, S10. Fixtures make the expected winner differ from ID order, so that stock fill-first cannot pass by coincidence. Exhaustion is seeded with 200 responses that carry exhausted headers, not with 429s, so the tests exercise the header rule rather than native cooldown. Every request sends an explicit session ID.
- Regression only, existing upstream behaviour: S7 (stickiness) and S8 (burst at exhaustion).
- Isolation. Each scenario gets its own model name and its own credentials, through per-key
modelslists, so scenarios do not share state in one proxy. The first two-scenario test proves this isolation. - S10 recipe. Observe every credential. Trigger a save, since saves are throttled to once a minute and shutdown does not flush. Inspect the saved file. Restart with the same auth dir and the same mock URL, because
base-urlis part of credential identity. Then send a new session with the mock omitting quota headers.
- U6, live tests. One minimal request per use case that works today: the Open SWE shape (Codex, tiny input), streaming Responses (Codex), Claude Code Messages (Haiku), Responses with a Claude model,
/v1/models, and a keyless 401. The OSWE-278 Sonnet native Messages 429 is recorded as a known failure, not asserted green. - Exit codes follow mastra-pilot: 1 = product failure, 2 = configuration, 3 = infrastructure.
Acceptance criteria
- The no-op engine test passes, or the runner gap is reported to Tester Army and the fallback is written down.
- The U3 protocol tests pass on stock v8.0.13 in the private repo's CI.
- The U4 selector-specific tests fail on the tests-only commit of the MASTRA-765 PR and pass at its head. The S7 and S8 regression tests pass on both.
- The live suite's
report.json(commit, dirty flag, outcomes, attempts) is attached to MASTRA-766, once before the upgrade and once after.
Source refs
- Parent: MASTRA-763. Related: MASTRA-765 (repo and selector), MASTRA-766 (deploy; uses the live suite), MASTRA-767 (factory routes), OSWE-11 (13-item live Responses suite to absorb), OSWE-113, OSWE-278.
The known-failure test exempted every 429, so a genuine rate limit made it pass. live() now takes a predicate over status and body, and the test accepts only OSWE-278's captured response: rate_limit_error with the message "Error". Any other 429 stays an infrastructure failure (exit 3). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…(MASTRA-768) The live test sent none of the four signals DetectClaudeCodeRequest needs, so it exercised the cloaking path. It now sends X-App: cli, the claude-cli/2.1.280 User-Agent, the claude-code-20250219 beta and a valid metadata.user_id, the same values as the hermetic test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Review gate: pstack:interrogate (see #3 and MASTRA-765). Fix-round commits:
Live run on studio2 against the deployed v7.3.17, at 4261d34: 7 of 7 passed, exit 0. |
Linear: MASTRA-768 (U6)
Adds the live e2e tests: one minimal request per proxy use case that works today, run against the deployed proxy on studio2 with
--target live. They needCLIPROXY_LIVE_URLandCLIPROXY_CLIENT_KEY. On studio2, the key is read from the local proxy config into the environment and never printed.What is here
e2e/lib/live.ts: thelive()helper, which classifies failures:Redirects are not followed, so the key never leaves for another host. One 60 s AbortSignal bounds each request: the slowest case is OSWE-278 at about 10.5 s, and the runner's own test timeout is 120 s.
expectTrace()assertsX-CPA-TRACE-ID, which v7.3.17 already sets (internal/api/server.go:147,sdk/api/handlers/handlers.go:233).e2e/tests/live.e2e.ts(7 tests):store:false,includeand a function tool);Evidence
TEST_SETUP_FAILED);http://127.0.0.1:9: exit 3 (ENVIRONMENT_UNAVAILABLE);AUTH_CREDENTIAL_INVALID);run.vcs.dirty: false, exit 0, 7 of 7 live tests passed, 9 hermetic tests skipped by target. Durations ran from 23 ms (keyless) to 10.75 s (OSWE-278). The report is attached to MASTRA-766.🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmithwith what you need. Autofix is disabled.