① JS 层
getAttributionHeader()
src/constants/system.ts
const cch = feature('NATIVE_CLIENT_ATTESTATION')
? ' cch=
00000;'
: '';
JS 永远只拿到 00000 · 抓 fetch、hook XHR 都看不到真值
↓ 请求 body 进入 HTTP 缓冲区 ↓
② HTTP buffer
请求 body 完整字节
{ ..., system: [ { text: "x-anthropic-billing-header: ...; cch=00000;" }, ... ], ... }
5 个 0 = 5 位 hex 长度 · Content-Length 不动, buffer 不重分配
↓ Bun Zig native HTTP 栈接管 ↓
③ Zig 层
native HTTP 覆盖
bun-anthropic/src/http/Attestation.zig
扫描 buffer · 定位 "cch=00000;" · in-place 覆盖
{ ..., system: [ { text: "...; cch=
97bd6;" }, ... ], ... }
Zig 在 JS 沙箱之外执行 · 第三方代理只看到最终结果, 摸不到生成逻辑
↓ 真正发到服务端 ↓
④ 上线请求
on the wire
POST /v1/messages → system[0].text = "x-anthropic-billing-header: ...; cch=97bd6;"