Skip to content

test: deterministic fake-upstream real-codex compression E2E (#686) - #715

Open
ranxianglei wants to merge 1 commit into
masterfrom
2026-09-11_fake-api-e2e
Open

test: deterministic fake-upstream real-codex compression E2E (#686)#715
ranxianglei wants to merge 1 commit into
masterfrom
2026-09-11_fake-api-e2e

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

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 against codex-cli 0.147.0:
    • stream:true → Responses SSE assistant turn;
    • stream:false → plain JSON body that bili's summarization call parses (extractSummaryTextjson.output[].content[].text).
    • Recognises bili summarization calls by their exact TASK text in instructions; replies with a faithful summary preserving the sentinel numbers found in the segment, dropping bulk filler. Every /v1/responses request is logged to FAKE_REQLOG as the assertion oracle.
  • tests/e2e/e2e-codex-fake.test.ts — gated by ACP_TEST_E2E_FAKE=1:
    • overflow (window 12k): warms up planting sentinels, then pushes ~10KB of bulky filler on every load turn via 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.
    • control (window 60k): one small turn asserts no compression and no summarization calls (no false positives).

Local usage

npm i -g @openai/codex@latest   # or set E2E_CODEX_BIN
ACP_TEST_E2E_FAKE=1 npm run test:e2e:fake

Validation (this sandbox, Linux)

Ran against the real codex-cli 0.147.0: typecheck clean · build ok · 2/2 pass (~64s). The overflow run shows repeated preflight compressed events 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/codex changes its wire format on a future @latest bump, this test fails loudly (by design) and the fake needs updating — same maintenance trait as the existing tests/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 livePidHoldsOverlay warning, 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 用例全绿。

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
@github-actions

Copy link
Copy Markdown

📦 Built Package Artifact

Branch: 2026-09-11_fake-api-e2e (97df100)

Option A — Install from npm PR tag (recommended)

npm install -g billion-context@pr-715

Each push to this PR publishes a new version under the pr-715 npm tag.

Option B — Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr715.tgz
npm install -g package

This comment is automatically updated on each push.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 Reviewed PR #715 against real codex-cli 0.147.0 in this sandbox. Verdict: mergeable — reproduced green end-to-end and verified every load-bearing assumption against source. No defects found that need a commit.

What I ran (all green)

  • typecheck clean · build ok · default unit suite 1371 pass / 0 fail / 2 skip.
  • E2E (ACP_TEST_E2E_FAKE=1): 2/2 pass in ~64s — matches your claim.

The test is not vacuous — oracle artifacts confirm real in-process compression

I inspected the fake's request log after the run:

  • overflow dir: 10 requests = 5 summarization + 5 forwarded. Forwarded payload sizes [80420, 80660, 80944, 81228, 81512] → grew only ~1.1KB across four ~10KB filler injections (peak/min ratio 1.014, well under the 1.3 bound). Final payload carries [Compressed conversation section] and all three planted sentinels (4781 / 2903 / 6577). So compression genuinely folds the bulk instead of accumulating it.
  • control dir (60k window): 1 request, 0 summarization calls → no false positive.

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

  • src/preflight.ts:227 — Responses summaryPayload puts the summary TASK into instructions, which is exactly what the fake's isSummaryRequest inspects.
  • src/preflight.ts:312 — the TASK text contains both regex alternatives the fake matches ("must be compressed because the session context exceeds" + "Write a tier-1 compression summary").
  • BILI_LAUNCHER_MODEL_WINDOWS (src/server.ts:162) and --no-auto-update (src/cli.ts:174) are real; the /bili/<absolute-url> base_url matches the documented tunnel convention (README).
  • Diff is clean: 4 purpose-related files, package.json adds only the test:e2e:fake script (no version bump), no lockfile/generated churn. Code follows §3 (precise type assertions, no as any/@ts-ignore).

Non-blocking notes

Duplicate screening

Distinct 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,这点维护成本请知悉。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant