test: deterministic fake-upstream real-codex compression E2E (#686) - #715
test: deterministic fake-upstream real-codex compression E2E (#686)#715ranxianglei wants to merge 1 commit into
Conversation
Delivers the "real regression" asked for in #686: a test where compression ACTUALLY happens inside real codex, driven by a deterministic fake Responses-API upstream — no model, no tokens, no external secrets. - tests/e2e/fake-upstream.mjs: standalone fake serving the two contracts observed against codex-cli 0.147.0 (stream:true -> Responses SSE assistant turn; stream:false -> plain JSON that bili's summarization call parses via extractSummaryText). Recognises bili summarization calls by their exact TASK text and replies with a faithful summary that keeps sentinel numbers and drops bulk filler. Logs every /v1/responses request to FAKE_REQLOG as the oracle. - tests/e2e/e2e-codex-fake.test.ts: ACP_TEST_E2E_FAKE=1 gate. overflow scenario (window 12k) accumulates ~10KB filler per turn via `resume --last`; asserts real compression fires repeatedly, the forwarded payload stays bounded despite heavy injection, sentinels survive, and the summary block is present. control scenario (window 60k) asserts NO compression (no false positives). - package.json: npm run test:e2e:fake - .github/workflows/ci-e2e-fake.yml: pull_request + workflow_dispatch gate on ubuntu-latest, installs @openai/codex, zero tokens/secrets. Validated locally against codex-cli 0.147.0: typecheck clean, build ok, 2/2 pass. Refs #686
📦 Built Package ArtifactBranch: Option A — Install from npm PR tag (recommended)npm install -g billion-context@pr-715Each push to this PR publishes a new version under the Option B — Download artifact
tar xzf billion-context-pr715.tgz
npm install -g packageThis comment is automatically updated on each push. |
[bot] 🏷 Reviewed PR #715 against real What I ran (all green)
The test is not vacuous — oracle artifacts confirm real in-process compressionI inspected the fake's request log after the run:
If the filler weren't being folded, turn 5 would be ~+40KB and the ratio assertion would fail — so the bound has real discriminating power. Load-bearing assumptions verified against source
Non-blocking notes
Duplicate screeningDistinct from the other two #686 follow-ups — #688 (Windows MCP-registration, config-level/headless) and #697 (Docker full lifecycle vs a real model, needs secrets). This one is the deterministic fake-upstream variant (real codex + in-process compression, zero tokens/secrets). Not a duplicate; keep open. 中文摘要:在真实 codex-cli 0.147.0 上复现了 typecheck/build/单测(1371 过)/E2E(2/2 约 64s)全绿,并核对假上游的断言确实有效(溢出用例转发体四次注入仅涨约 1.1KB、保留全部哨兵值,对照用例零压缩),关键假设逐条对源码核实无误,diff 干净无版本号改动,可合并;唯一需你确认的是它成为每次 PR 的强制门禁后,codex 线格式漂移会阻塞所有 PR,这点维护成本请知悉。 |
What
The "real regression" requested in #686 — compression actually happens inside real
codex, driven by a deterministic fake Responses-API upstream. No model, no tokens, no external secrets, so it can gate every PR.Distinct from the two earlier #686 follow-ups:
How it works
tests/e2e/fake-upstream.mjs— standalone fake serving the two wire contracts verified againstcodex-cli 0.147.0:stream:true→ Responses SSE assistant turn;stream:false→ plain JSON body that bili's summarization call parses (extractSummaryText→json.output[].content[].text).instructions; replies with a faithful summary preserving the sentinel numbers found in the segment, dropping bulk filler. Every/v1/responsesrequest is logged toFAKE_REQLOGas the assertion oracle.tests/e2e/e2e-codex-fake.test.ts— gated byACP_TEST_E2E_FAKE=1:resume --last. Asserts: a real compression event fires (log), summarization is called repeatedly (oracle), the forwarded payload stays bounded despite heavy injection (compression folds the bulk instead of letting it accumulate), sentinels survive into the final payload, and the[Compressed conversation section]block is present.Local usage
npm i -g @openai/codex@latest # or set E2E_CODEX_BIN ACP_TEST_E2E_FAKE=1 npm run test:e2e:fakeValidation (this sandbox, Linux)
Ran against the real
codex-cli 0.147.0: typecheck clean · build ok · 2/2 pass (~64s). The overflow run shows repeatedpreflight compressedevents and a forwarded payload that grows only ~1KB across four ~10KB filler injections — i.e. compression is genuinely folding context inside codex.Caveat / review note
The fake encodes the exact SSE/JSON contract of
codex-cli 0.147.0. If@openai/codexchanges its wire format on a future@latestbump, this test fails loudly (by design) and the fake needs updating — same maintenance trait as the existingtests/e2e/e2e-codex.test.ts. Nothing pinned, matching that convention.Scope vs #686
Covers the "real compression really happens in codex + assert behaviors" ask. The Windows-specific acceptance items (concurrent-window
livePidHoldsOverlaywarning, interactive compress-tool visibility) still need a human on a real Windows box — tracked under #688 / #683.Refs #686
中文摘要:按你"用 fake api 造数据、让压缩真的在 codex 里发生、并断言一系列行为"的要求,加了一个确定性假上游 E2E(真实 codex + 进程内真压缩,零 token/零密钥),可作每次 PR 的门禁;已在本地对真实 codex-cli 0.147.0 验证 typecheck/build/2 用例全绿。