Skip to main content

Model Gateway Mode E — S0 spike report: the custom-header carrier on Claude Code 2.1.284

Verdict: PASS on all five acceptance arms of LLD #3698 Appendix A §A.3. The ANTHROPIC_CUSTOM_HEADERS carrier works on the current build; MG-SUB.3's path-prefix fallback is not opened.

Issue#3700 (task 1 of 14)
LLD#3698 + Appendix A (5947806982)
HLD / ADR / PRDHLD #3692 §1, §11 · ADR-0021 Amendment 1 (docs/adrs/ADR-0021-registry-and-gateway-architecture.md §A1, merged in #3689) · PRD #2644 v1.7 Slice 6
Measured on~/.local/bin/claude 2.1.284, Max subscription login (~/.claude.json → oauthAccount.organizationType = claude_max, organizationRateLimitTier = default_claude_max_20x, billingType = stripe_subscription), devbox, Node v26.3.0, Bun 1.4.3, @anthropic-ai/sdk 0.112.1
Date2026-10-02
Corpus51 requests across 11 arms — 40 under /v1/*, 11 HEAD /api/hello
Artefactsinternal/modelgateway/subscriberauth/testdata/s0/ (fixture, bodies, surface seed, recorder) · internal/modelgateway/subscriberauth/shape_fixture_test.go

0. Scope, and the one deviation from §A.3​

§A.3 asks for two targets: (a) a loopback recording listener and (b) the sealed beta edge model-gw-beta.upsquad.ai.

Arm (b) was not run, deliberately. Running it means sending a live Max subscription OAuth bearer to a host on the public internet before the gateway that is supposed to receive it exists, and before anyone has reviewed what that host does with an Authorization header it cannot yet use. That is the one thing this whole design is careful about (ADR A1.3 S-DISCARD/S-PERSIST), and a spike is a bad place to be the first exception. Every measurement below is from loopback; nothing in this task contacted api.anthropic.com or any UpsQuad host.

What that costs, stated plainly. The HEAD /api/hello finding is a measurement of how the CLI reacts to a 404 on that path, which is the behaviour §A.3 actually asks about and which the loopback reproduces exactly (404 on /api/hello, 200 on /v1/*). It is not a measurement of the beta edge's particular 404 body, headers or latency. If the architect wants that confirmed it is a one-line curl -I on D1's branch with no credential attached, and it should be done there rather than here.

Three other deviations, each flagged rather than decided:

  1. The fixture is JSON, not HAR. §2.3 of the LLD names testdata/s0/claude-code-<ver>.har.json; the issue's acceptance names testdata/s0/claude-code-<ver>.json. The file is claude-code-2.1.284.json and is not HAR-shaped: HAR has no place to put a request's header order and casing, which is the part of byte-transparency a canonicalised map cannot express (§4). Renaming it is free if the architect prefers the .har.json spelling.
  2. shape.Spec is DATA here, not a Go declaration. §2.3 puts the one shape(R) declaration in subscriberauth/shape.go, which is task E5's file; #3700 owns no production .go under internal/modelgateway. The measured Spec is therefore in the fixture's shape_spec object, and shape_fixture_test.go carries a test-local transcription of §2.3's verdict logic (s0ShapeCheck) purely to prove the Spec is self-consistent. E5 must delete s0ShapeCheck in the PR that adds shape.go, or there are two implementations of one predicate — the shape that lets the wrong one get patched.
  3. surface.go's seed table is testdata/s0/surface-seed.json, for the same reason (E6 owns surface.go). §5 below gives the Go literal ready to paste.

1. The carrier — does the header arrive, on every request type?​

Yes, on 33 of 33 /v1/* requests in every arm that configured it — 100%, with the count asserted non-zero. The remaining 7 /v1/* requests are the three control arms that deliberately did not configure it.

Request typecarrier present / n in carrier-configured armsrecorded overallnotes
POST /v1/messages?beta=true — user turn, streaming9 / 912the visible turn; full tool registry (22–138 tools)
POST /v1/messages?beta=true — hidden quota probe3 / 35max_tokens:1, messages:[{user,"quota"}], non-streaming, no system, no tools
POST /v1/messages?beta=true — hidden title generation3 / 35streaming, tools:[], system carries the x-anthropic-billing-header line
POST /v1/messages?beta=true — tool-use follow-up (tool_result)2 / 22the second half of a real tool round trip
POST /v1/messages/count_tokens?beta=true16 / 1616emitted by /context, 16 concurrent on separate connections
GET /v1/models—0never emitted — see §3
HEAD /api/hello0 / 1111by design: no Authorization, no custom header, User-Agent: Bun/1.4.3

The four /v1/messages classes are derived from the body (max_tokens==1 ⇒ quota probe; tools==[] ⇒ title generation; a tool_result block ⇒ follow-up; otherwise a user turn) and sum to 24 overall and 17 in carrier-configured arms; 17 + 16 count_tokens = the 33 figure above.

Two carrier mechanics worth writing down.

  • A single-line ANTHROPIC_CUSTOM_HEADERS works (arm D2): the subscriber header alone arrives, team header absent. So X-UpsQuad-Team really is optional on the wire, as OQ-21 assumes.
  • An EMPTY value is sent as a PRESENT header (arm F). ANTHROPIC_CUSTOM_HEADERS="X-UpsQuad-Subscriber: " put X-UpsQuad-Subscriber: on the wire with an empty value; only unsetting the variable entirely (arm G) removes it. This is good for LLD §2.1 — "present (any value, any count) ⇒ the subscriber path and nowhere else" — because a developer who mis-pastes the config gets an honest subscriber_identity_invalid on their own page rather than silently falling through to the API-key admission. It does mean §2.1's selection predicate must be presence-not-emptiness; len(header) > 0 would be a fall-through bug.

The negative control is why any of this means anything. Arm G ran the same interactive script with ANTHROPIC_CUSTOM_HEADERS unset: 0 occurrences of UpsQuad across the whole raw capture, and the fixture carries that request so TestS0Fixture_CarrierOnEveryV1Request asserts its absence. Without that arm, "the header is on every request" is satisfied by a test that cannot tell a working carrier from a broken assertion.

2. surface(R) — which conjuncts are load-bearing, and which are not​

Everything below is a value measured over the 40 /v1/* requests.

Would rely on​

ConjunctMeasuredWhy it is safe
Authorization prefix sk-ant-oat01-40 / 40one distinct bearer shape across the whole corpus
bearer suffix length 95 (total 108)40 / 40invariant; [A-Za-z0-9_-] observed, i.e. base64url
anthropic-beta contains oauth-2025-04-2040 / 40the subscription-auth beta; present on every bearer-bearing request including count_tokens
anthropic-beta contains claude-code-2025021940 / 40identifies the surface as Claude Code, not a bare SDK caller
anthropic-version: 2023-06-0140 / 40single value
x-app: cli40 / 40single value, lowercase on the wire
User-Agent prefix claude-cli/40 / 40see the warning below — prefix only
X-Claude-Code-Session-Id PRESENT40 / 40presence only; the value is a fresh uuid per process (11 distinct over 11 arms)

Would not rely on​

ConjunctMeasuredWhy not
User-Agent exact valueclaude-cli/2.1.284 (external, cli) and claude-cli/2.1.284 (external, sdk-cli)the parenthetical is the entrypoint: interactive gives cli, claude -p gives sdk-cli. An exact match refuses half of a developer's traffic, and the version moves weekly.
the anthropic-beta token SET16 distinct tokens; per-request set sizes 4, 5, 8, 11, 12, 13it varies between consecutive calls of one session. fallback-credit-2026-06-01 appeared exactly once in 51 requests. An allow-list of known betas would have broken this session — FINDINGS #9 on 2.1.222, still true on 2.1.284. Require the two universal tokens; forward the rest untouched and never enumerate.
X-Claude-Code-Session-Id VALUE11 distinct over 11 processesper-process; not an identity and not stable
metadata.user_id as a trust signalclient-supplied, unsignedADR A1.8 already says this; the measurement adds that its schema is Anthropic's to change (§4)
the full header SETcount_tokens lacks X-Stainless-Timeout; everything else identicala set-equality predicate reddens on /context. The only measured difference across the two /v1/* surfaces is that one header.
X-Stainless-*Arch=x64 Lang=js OS=Linux Package-Version=0.112.1 Retry-Count=0 Runtime=node Runtime-Version=v26.3.0 Timeout=600these describe the SDK build and the developer's machine. Fine to forward (and byte-transparency requires forwarding them); useless as a predicate because they move with every SDK bump and differ per OS.
anthropic-dangerous-direct-browser-access: true40 / 40stable today, but it is a flag about CORS behaviour, not an identity of the surface; pinning it buys nothing the two betas do not already give.

X-Stainless-Retry-Count: 0 on 40/40 is itself a finding: the CLI never retried anything in this corpus, including after the /api/hello 404.

3. GET /v1/models was never requested — OQ-24 resolves to "do not add it"​

Measured across: a claude -p one-shot, three full interactive sessions, the /model picker opened and closed, /status, /usage, /context, /cost, /compact, and a run with a deliberately retired --model claude-3-7-sonnet-20250219 while /v1/models was answered 404.

  • The /model picker rendered its six models (Opus 5.5, Opus 1M, Fable, Sonnet 5.5, Sonnet 5.5 1M, Haiku 4.5) with zero requests to the listener.
  • The deprecation warning for the retired model ("Claude 3.7 Sonnet was retired on February 19, 2026") was produced locally; the 404 on /v1/models was never consulted and the session completed normally.

LLD OQ-24 is conditional — "forward GET /v1/models unchanged (if S0 shows the CLI sends it)". It does not. The seed table therefore omits the entry and records the absence explicitly in a not_observed block, because an allowlist entry no reachable input can exercise is a guard with no fireable case: it cannot be tested, and it would satisfy §3.2's "every forwarded prefix owns ≥ 1 forward entry" check through an unreachable member. TestS0SurfaceSeed_AgreesWithTheCapture fails if someone adds it (mutant M8).

Re-measure on a CLI upgrade. This is an absence, and absences expire.

4. The edge seal — HEAD /api/hello is tolerated, D1 needs no route​

HEAD /api/hello carries User-Agent: Bun/1.4.3, Accept: */*, Accept-Encoding: gzip, deflate, br, zstd, Connection: keep-alive — and nothing else. No Authorization, no anthropic-version, no custom header. It cannot be admitted by subscriber(R) and must never reach the gateway, which is exactly why §3.2 marks it edge_answered.

Tolerance, measured as a controlled comparison rather than asserted:

arm A3 (/api/hello → 404)arm B (/api/hello → 200)
(method, path) multiset1 × hello, 3 × /v1/messages1 × hello, 3 × /v1/messages
anthropic-beta count per /v1/messages8, 11, 138, 11, 13
hello probes per process11
diagnostics in the terminal transcriptnone — grep for error|fail|unreachable|cannot|offline|unable|retry|warn|404|connect returns 0 linesnone, same grep
session outcometool call ran, /model opened and closed, clean /exitidentical
X-Stainless-Retry-Count0 on every request0 on every request

The two arms are indistinguishable. Taking the acceptance's first branch: the CLI tolerates the edge 404 with no functional loss, so the seal stays and task D1's exact-match direct_response 200 is NOT required.

One wording consequence for the architect. LLD §3.2's edge-agreement guard says every edge_answered entry "must have an exact direct_response route above the seal". On this measurement the generic seal's own 404 is the edge's answer, so either (a) the guard accepts "answered by the seal" for an entry that declares edge_answer_status: 404 — which is what surface-seed.json records — or (b) D1 adds the exact route anyway, for explicitness rather than for function. That is a design call, not mine; the seed file encodes (a) and flags it.

5. The surface(R) seed table​

Measured source of truth: internal/modelgateway/subscriberauth/testdata/s0/surface-seed.json, cross-checked against the capture by TestS0SurfaceSeed_AgreesWithTheCapture in both directions (observed-but-undeclared fails; declared-but-unobserved fails; carries_account must match the recorded bodies). E6's surface.go should be:

// Seeded by the S0 spike (#3700) from 40 recorded /v1/* requests on claude-cli
// 2.1.284. The oracle is testdata/s0/surface-seed.json; do not hand-edit either
// half without re-running the spike.
var seed = []Entry{
{Method: "POST", Path: "/v1/messages", Disposition: Forward, CarriesAccount: true,
Justification: "the only substantive surface; 24/24 recorded bodies carried metadata.user_id, including both hidden calls"},
{Method: "POST", Path: "/v1/messages/count_tokens", Disposition: Forward, CarriesAccount: false,
Justification: "emitted by /context, 16 concurrent; 0/16 bodies carried a metadata object at all, so stepAccount must be skipped"},
{Method: "HEAD", Path: "/api/hello", Disposition: EdgeAnswered, CarriesAccount: false,
Justification: "startup probe, Bun UA, no auth and no custom header on 11/11 arms; measured tolerant of the seal's 404"},
}

CarriesAccount for count_tokens is false, settling the LLD §3.2 placeholder. 0 of 16 recorded count_tokens bodies carried a metadata object at all — the body is {"messages":…,"model":…,"tools":…} and nothing else. So stepAccount must be skipped on that surface; running it there would refuse every /context with subscriber_account_unreadable (400) even though the subscriber is legitimate. The seed also asserts all-or-nothing per surface, because a surface that sometimes carries an account id cannot fail closed.

6. metadata.user_id — the account carrier​

Parsed on 24 of 24 POST /v1/messages bodies, including both hidden calls. Only ONE encoding was observed on 2.1.284 — the JSON-object-as-string form:

"metadata": { "user_id": "{\"device_id\":\"<64 hex>\",\"account_uuid\":\"<uuid>\",\"session_id\":\"<uuid>\"}" }

The widely-quoted flat form user_<sha>_account_<uuid>_session_<uuid> was not seen once. account.Parse must still accept both (gwpoc identity.go:182-189 saw the flat form historically and the schema is Anthropic's to change), but the object form is the one that must be exercised by tests — a parser tested only against the flat form would return empty on every real request, and §3.5 refuses on an unreadable account, so the failure would be a universal 400 rather than silence. That is the better direction of failure, and it is still an outage.

device_id is a stable per-machine fingerprint that arrives whether or not anyone asked for it. ADR A1.3 S-PERSIST forbids storing the bearer and its digests; the measurement adds that metadata.user_id as a whole must not be persisted either — only the account_uuid segment the design asks for (observed_account_uuid). The committed fixture sentinelises it.

count_tokens bodies carry no metadata — §5.

7. The committed fixture​

internal/modelgateway/subscriberauth/testdata/s0/claude-code-2.1.284.json (26 KB) + testdata/s0/bodies/ (two bodies, 78 KB and 75 KB, verbatim). 7 requests, each with a role:

rolearmrequestbody
edge_probeA3HEAD /api/hello—
subjectA3POST /v1/messages — quota probeinline, 315 B
subjectA3POST /v1/messages — title generationinline, 4 094 B
subjectA4POST /v1/messages/count_tokensinline, 3 652 B
subjectEPOST /v1/messages — tool registry, answered tool_usesidecar, 78 364 B
subjectEPOST /v1/messages — the tool_result follow-upsidecar, 75 213 B
negative_controlGPOST /v1/messages with ANTHROPIC_CUSTOM_HEADERS unsetinline, 315 B

Each entry carries request_line and header_lines in wire ORDER with wire CASE — X-Stainless-OS not X-Stainless-Os, anthropic-beta and x-app lowercase, the X-UpsQuad-* pair sorted into the SDK's own ASCII-ordered block rather than appended after it. net/http canonicalises both away, so the recorder tees the literal connection bytes before the parser sees them.

What E3–E7 must and must not assert from this — corrected​

The order and case in header_lines are FOR THE RECORD, not an assertion target. An earlier revision of this section told E3–E7 to "diff against header_lines (order and case)", which contradicted the fixture's own transport_caveat and would have produced an unpassable test. The caveat is the correct statement; the architect verified the mechanism on #3715 and ruled accordingly:

  • the live edge answers over HTTP/2 (curl -sI https://model-gw-beta.upsquad.ai/api/hello → HTTP/2 404), where header names are lowercase by protocol;
  • infra/edge/envoy.yaml on main sets no header_key_format / preserve-case, so Envoy lowercases every key;
  • Go's net/http canonicalises on read, and the gateway → Anthropic hop is a Go client over TLS.

The CLI's wire order and case are gone before the gateway sees a byte. So:

E3–E7 compare the header SET, each header VALUE (including every anthropic-beta token, in order within the value), and the body bytes. They do not assert on-the-wire header casing or inter-header ordering end to end.

header_lines remains the record of what the CLI emitted — it is the only place that information exists, and it is what a future R12 question would be answered from. Whether the gateway's own outbound h2 header order is R12 fingerprinting surface is an open question on the LLD (architect filing it as OQ-25), not an E3–E7 assertion.

What is sentinelised, and what is not​

valuesentinellength-preserving
the sk-ant-oat01- bearersk-ant-oat01- + S0FIXTUREPLACEHOLDER… truncated to 95yes — required, because shape(R) asserts the suffix LENGTH; a shortened placeholder would make the fixture reject itself
device_id (64 hex)dede…deyes
account_uuid00000000-0000-4000-8000-00000000a0ccyes
each session_id / X-Claude-Code-Session-Id00000000-0000-4000-8000-0000000000aNyes
the recording host's home path and user name/home/s0usr, s0usryes
the scratch capture directory/tmp/s0spike.000000yes
X-UpsQuad-Team: 00000000-…-000000000000left alone — it is the test value itself—

Length preservation is not cosmetic: every recorded Content-Length must still equal its body, or a replay is malformed. TestS0Fixture_ContentLengthMatchesBody asserts it in bytes (the system prompt is UTF-8 with multi-byte punctuation; a character-length comparison reported a 16-byte discrepancy that did not exist).

Residual identifiers — the full list, accepted rather than hidden. Silence about a residual is the failure mode, not the residual itself.

residualwherewhy it is accepted
noreply@anthropic.comsystem / tool textAnthropic product text
s0usr@upsquad.aisystem blockalready sentinelised (ashik → s0usr)
the six uuid sentinels + the all-zero team valuebodies and headersall synthetic
## claude.ai Claude Docs MCP-instruction textthe arm A4 count_tokens bodyit is a token count over whatever was in the session, and it discloses that the recording account has that connector enabled — the same class --strict-mcp-config was used to keep out of the two sidecars. The text itself is Anthropic product text and no tool name, schema or account id appears; it stays because the count_tokens surface measurement (0 of 16 bodies carry metadata) needs a real body. Found by the architect's own scan on #3715, not by mine — mine checked shapes (hex64, uuid, e-mail, /home/), which this is not.
Linux 6.8.0-136-genericthe env block of the two sidecarsthe recording host's kernel string. Not an identifier of a person or an account; it is a machine fingerprint of the same family as X-Stainless-OS: Linux, which the CLI sends on every request anyway.

Neither of the last two is length-sensitive, so a future revision may sentinelise them without invalidating any Content-Length.

Why one large body is included​

The two sidecars are a real tool-use round trip at 78 KB and 75 KB Content-Length. A transparency test on a 4 KB body cannot exercise a buffer boundary, a chunking decision or a Content-Length path. They were recorded with --strict-mcp-config, which drops the account's 69 mcp__claude_ai_* connector tools (Gmail, Drive, Calendar — FINDINGS #8): the same run without it produces a 331 KB body whose tool schemas disclose which connectors the account has enabled, which does not belong in a repo. If a later task needs the 331 KB shape, re-run the recorder without the flag — the command is in §9.

8. Tests and mutation evidence​

internal/modelgateway/subscriberauth/shape_fixture_test.go — 5 tests, package subscriberauth, no non-test Go file (the package is test-only until E5 lands; go build ./..., go vet ./... and go test ./... are all clean on that shape).

Every mutant below was applied, RUN, and restored via git checkout HEAD -- <path> with the restore verified. Mutants target the testdata the guard reads, not Go source, because reading those files from disk is the guard's entire job.

#LOCUSSCOPEORACLEverdict
M1fixture header_lines Authorizationthe committed fixtureTestS0Fixture_CarriesNoCredentialKILLED
M2fixture header_lines X-UpsQuad-Subscriberone subject requestTestS0Fixture_CarrierOnEveryV1RequestKILLED
M3shape_spec.suffix_len 95 → 94the Spec vs every recorded bearer…ShapeSpecAdmitsEveryRecordedBearerAndRejectsOthersKILLED
M4fixture requests[].rolethe negative control relabelled subjectTestS0Fixture_CarrierOnEveryV1RequestKILLED
M5fixture requests[] → []the whole corpusevery test (empty corpus must FAIL)KILLED
M6surface-seed entries[]count_tokens entry deletedTestS0SurfaceSeed_AgreesWithTheCaptureKILLED
M7surface-seed carries_account false → truecount_tokensTestS0SurfaceSeed_AgreesWithTheCaptureKILLED
M8surface-seed entries[]GET /v1/models ADDED (unobserved)TestS0SurfaceSeed_AgreesWithTheCaptureKILLED
M9fixture requests[].body + one byteone inline bodyTestS0Fixture_ContentLengthMatchesBodyKILLED
M10sidecar body: device-id sentinel → the real fingerprintbodies/*.jsonTestS0Fixture_CarriesNoCredentialKILLED
M11seed disposition edge_answered → forwardHEAD /api/helloTestS0SurfaceSeed_AgreesWithTheCaptureKILLED
M12seed disposition forward → edge_answeredPOST /v1/messagesTestS0SurfaceSeed_AgreesWithTheCaptureKILLED
M13one /v1/messages subject de-credentialledthe mixed-surface branchTestS0SurfaceSeed_AgreesWithTheCaptureKILLED
M14seed edge_answer_status removedthe edge_answered entryTestS0SurfaceSeed_AgreesWithTheCaptureKILLED

14 of 14 killed, no survivors — and each of M11–M14 was confirmed to fire the intended assertion, by line number and message, not merely to redden the test.

M11 is the architect's MA, and it SURVIVED the first revision of this PR (#3715). The first disposition check asserted only membership of {forward, edge_answered}, which is not a pin: edge_answered → forward on the one surface that carries no credential passed. The disposition is now derived from the capture (all recorded non-control requests credential-less ⇒ must be edge_answered; all credentialled ⇒ forward; mixed ⇒ hard failure), and M12–M14 exist because a pin in one direction only is half a pin and a mixed ⇒ fail branch with no reachable input is not a guard. M13 is that reachability demonstration. The lesson generalises: an enum-membership check on a security-relevant column reads exactly like a pin and is not one.

The harness was self-tested in both directions: a cosmetic edit to a note field (which no assertion reads) correctly reported SURVIVED, so "10/10 KILLED" is not a classifier stuck on one verdict. The classifier itself had to be fixed first — it keyed on "\nok " in out, and go test prints ok \tpkg as the first line with no preceding newline, so every PASS read as NO-VERDICT.

Two unplanned REDs found real defects in this task's own instruments, both now fixed and both recorded because the second one is the kind that reads as a finding:

  1. The raw-head tee was line-anchored ((?m)^…\r$) and silently dropped heads. On a keep-alive connection a request head follows the previous body with no newline (…"}}POST /v1/messages…), so ^ never matched. Cost: 1 of 4 heads lost on an interactive arm, 5 of 21 on the /context arm. A lost head reads exactly like "the CLI did not send that request" — the precise mis-conclusion this spike exists to avoid. shape_fixture_test.go reddened on the three affected fixture entries before the fix.
  2. The fixture's leak scan was scoped to the whole document and reported one bearer leak and seven device-id leaks that were all the fixture's own metadata: shape_spec.bearer_prefix is a bare sk-ant-oat01- and every body_sha256 is 64 lowercase hex. The scan now runs over recorded material only. A scanner whose false positives are indistinguishable from real findings trains the next reader to ignore it.

9. Reproducing this​

The recorder is committed under testdata/, which the Go tool ignores entirely — nothing here is built, vetted or linted as part of the module.

cd internal/modelgateway/subscriberauth/testdata/s0/recorder
go build -o /tmp/s0rec ./s0rec.go

# loopback recorder: 127.0.0.1 is ENFORCED; the binary contains no http.Client.
/tmp/s0rec -addr 127.0.0.1:19797 -out cap.jsonl -raw raw/ \
-hello 404 -models 200 -tooluse /path/to/a/file -label armA &

# a -p one-shot
ANTHROPIC_BASE_URL=http://127.0.0.1:19797 \
ANTHROPIC_CUSTOM_HEADERS=$'X-UpsQuad-Subscriber: uq_sub_TESTPLACEHOLDER\nX-UpsQuad-Team: 00000000-0000-0000-0000-000000000000' \
claude -p 'Reply with exactly: S0 ACK' --model sonnet

# an interactive session, scripted (the /model picker and both hidden calls only
# appear in interactive mode). The folder-trust dialog DEFAULTS TO "No, exit", so
# a bare Enter quits before any API call — ptydrive sends Down then Enter.
python3 ptydrive.py --port 19797 --transcript t.txt --cwd /some/dir \
-- "$HOME/.local/bin/claude" --model sonnet

# sentinelise and rebuild the committed fixture (derive_sentinels REFUSES on any
# uuid in the capture it cannot classify; mkfixture REFUSES on any surviving
# credential, device id, /home path, redaction note or length mismatch)
python3 recorder/derive_sentinels.py --capture-root /tmp/s0spike.XXXX \
--select select.json --out-extra extra.json --out-forbid forbid.txt
python3 recorder/mkfixture.py --capture-root /tmp/s0spike.XXXX \
--out claude-code-<ver>.json --bodies-dir bodies \
--select select.json --extra extra.json --forbid forbid.txt

select.json, extra.json and forbid.txt hold real identifiers and live in the scratch capture directory, never in the repo.

10. Acceptance, arm by arm (LLD §A.3)​

ArmRequiredMeasured
1the custom header on 100% of /v1/* requests, count > 033 / 33 in carrier-configured arms, plus a negative control proving absencePASS
2bearer shape stable; a Spec admitting all and rejecting sk-ant-api… and uq_key_*one distinct shape over 40 requests (sk-ant-oat01- + 95 base64url); Spec admits 6/6 fixture bearers, rejects sk-ant-api03-…, uq_key_…, a JWT, a short suffix, an out-of-alphabet suffix, a missing scheme, a second Authorization, an X-Api-Key, and a missing oauth-2025-04-20PASS
3HEAD /api/hello: tolerance or D1's route becomes REQUIREDtolerant — the 404 and 200 arms are indistinguishable (§4); D1's route not requiredPASS
4metadata.user_id parses on every POST /v1/messages including title generation24 / 24, one encoding (object-as-string)PASS
5fixture committed with the bearer replaced; CI reds on sk-ant-oat01- followed by anything but the placeholderTestS0Fixture_CarriesNoCredential, mutants M1 and M10PASS
6surface.go seed drafted, one entry per measured shape with disposition + justification§5, cross-checked both ways; GET /v1/models omitted because it is never emitted (§3)PASS
7this report + a comment on #3698this file; comment postedPASS

Neither FAIL branch of §A.3 applies. The header is present on every /v1/* request, so MG-SUB.3's path-prefix fallback is not opened. The bearer shape does not vary, so the shape term is not redesigned.

11. Carried forward​

ForWhat
E5 (shape.go)assert shape.Check against this fixture and delete s0ShapeCheck in the same PR — one predicate, one implementation
E5 (select.go §2.1)select on presence, not non-emptiness: an empty-valued header is on the wire (§1)
E6 (surface.go)the §5 literal; count_tokens is CarriesAccount: false; do not add GET /v1/models
E6 (account.go §3.5)accept both encodings, but test against the object form — it is the only one 2.1.284 emits
D1 (envoy.yaml)no HEAD /api/hello route — ruled on #3715: an explicit 200 is unmeasured new edge behaviour and would make the sealed host distinguishable from a default-404 host. D1's acceptance gains a credential-free curl -I against the seal
E3–E7 (byte-transparency)compare the header SET, each VALUE and the body bytes; do not assert wire casing or inter-header order end to end (§7, ruling R1) — the edge is h2 and both are gone before the gateway sees a byte. The 78 KB sidecar is the realistic size
E6 (edge-agreement guard)option (a) with the guard strengthened: an edge_answered entry must not fall under any forwarded prefix of the model-gateway vhost, and whatever answers it must return the entry's EdgeAnswerStatus. Entry gains EdgeAnswerStatus int; surface-seed.json already records it (404)
E6 / A.4 lintgrep -rn "sk-ant-oat01" internal/ --include=*.go | grep -v _test now matches testdata/s0/recorder/s0rec.go; that lint must exclude /testdata/ (as scripts/check-llm-callsite-census.py already does), and MG-SUB.21's X-UpsQuad-Subscriber allowlist must name the fixture, s0rec.go, ptydrive.py, this report and tasks/lessons/feat-3700-backend-sme.md
Architectall six routing items are ruled on PR #3715 and mirrored to #3698 as [LLD Δ]; OQ-25 (outbound h2 header order as R12 surface) is theirs to file
On any CLI upgradere-run §9 and re-check: the beta token set, the User-Agent entrypoint suffix, the bearer suffix length, and the absence of GET /v1/models