test(translation): cover Claude Code 2.1.84 billing-header rotation variants#580
Open
icebear0828 wants to merge 1 commit into
Open
test(translation): cover Claude Code 2.1.84 billing-header rotation variants#580icebear0828 wants to merge 1 commit into
icebear0828 wants to merge 1 commit into
Conversation
…ariants Three batches of live samples (~50 /v1/messages ingress) confirm Claude Code 2.1.84 always emits x-anthropic-billing-header as a standalone system[0] block with rotating cc_version (3-hex suffix) and cch (5-hex token) per request. The existing prefix-startsWith strip handles this shape correctly, but only a single fixture exercised it. A future refactor — swapping the prefix check for a regex, adding inline cleanup, etc. — could silently regress and leak cch back into the flattened instructions, defeating the cache-buster guard that inspired the strip in the first place. Add an it.each fixture across five observed cc_version suffixes (c8e / 76b / f51 / 5b4 / 4f3) plus an explicit invariance assertion that two different billing-header values produce byte-identical instructions. Fixture mirrors the real 3-block shape including cache_control ephemeral markers on the prompt blocks. No production code change.
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
Lock down the existing
x-anthropic-billing-headerstrip against silent regression. Three batches of live/v1/messagesingress samples (~50 requests) confirmed Claude Code 2.1.84 always emits the billing header as a standalonesystem[0]block with rotatingcc_version(3-hex suffix) andcch(5-hex cache-buster token) per request. The existingstartsWithstrip handles this shape, but only one fixture covered it — a future refactor (regex swap, inline cleanup) could quietly leakcchintoinstructionsand defeat the upstream prompt-cache anchor.Changes
tests/unit/translation/anthropic-to-codex.test.tsit.eachover five observedcc_versionsuffixes (c8e / 76b / f51 / 5b4 / 4f3)cache_control: ephemeralmarkers on the prompt blocksinstructionsAND that the output contains nocch=/cc_version=/x-anthropic-billingsubstringinstructionsCHANGELOG.md—### Fixedbullet under[Unreleased]No production code change.
Test Plan
npx vitest run tests/unit/translation/anthropic-to-codex.test.ts— 47 tests pass (40 existing + 6 new variant + 1 invariance)Notes
Data backing the variants comes from
logs.capture_body=trueon the local dev proxy with a real Claude Code client. All fivecc_versionsuffixes and 50+ distinctcchtokens were observed; the strip is invariant across all of them today, this PR proves it.