Skip to content

fix(#2698,#2699,#2697): repair stripImages-removal race — typecheck + budget tests + doc - #2702

Merged
ranxianglei merged 2 commits into
masterfrom
2026-10-11_fix-image-budget-typecheck
Oct 11, 2026
Merged

ranxianglei merged 2 commits into
masterfrom
2026-10-11_fix-image-budget-typecheck

Conversation

@ranxianglei

@ranxianglei ranxianglei commented Oct 10, 2026 •

Copy link
Copy Markdown
Owner

Summary

Fixes the master typecheck breakage reported in #2699 — and completes the repair of the same breakage reported in #2698 and #2697 (identical mechanism: merge race between #2688 removing compress.stripImages and #2613 adding tests/image-request-budget.test.ts written against the pre-removal base; master broke at ae7d9c0b).

#2688 (remove-strip-images) removed compress.stripImages / stripImagesKeepRecent from CompressSettings, but #2613's budget test — merged after #2688 — still referenced both fields, leaving master red on typecheck (TS2353 @ line 49, TS2339 @ line 111) and failing every open PR's CI at the tsc step. It was not only a type error (#2698): two of the file's tests also exercised the removed stripImages recovery path at runtime and fail on master with the forward-stage 413.

Change

Test file + one reference doc, zero runtime behavior change (no src/ diff):

Commit 1 (990cbe86f):

Commit 2 (b0d511987, supplement for #2698/#2697):

Verification

  • npx tsc --noEmit --project tsconfig.json → clean (was red with exactly the two reported errors).
  • Full affected suite locally: node --import tsx --test --test-concurrency=1 tests/image-request-budget.test.ts tests/request-body-budget.test.ts → 10/10 pass, 0 fail, including both adapted tests ("over-budget rebuilt bodies stop at the forward-stage byte budget without touching upstream…" and "third large decode gets retryable admission error, then hits the forward-stage budget once a slot is released").
  • Baseline on master before this PR: tsc red (2 errors) + 2 of the 6 budget tests failing at runtime (413 ≠ 200) — the exact failure mode from master is typecheck-broken: image-request-budget test still uses removed compress.stripImages (#2688 x #2613 race) #2698's mechanical repro, reproduced identically locally.

Notes

  • Pure fix: scoped to the test file + its reference doc; no config schema / wire / persistence / kernel / updater change.
  • No src/ diff → no behavior change: the proxy already behaves exactly as the adapted tests now assert (forward-stage 413 guard in src/server/relay.ts; admission slot released in finally, src/server/handle.ts).
  • No new config surface.
  • The fix: 让压缩图片历史先减量,再检查发送字节预算 #2613 contributor's (overFloweee) test logic is preserved in intent: same fixtures and scenarios (message vs tool-output images, admission slots, SSE-committed error path); assertions updated only where they asserted the removed mechanism.
  • Spurious package-lock.json churn from local installs was reverted before committing.
  • Observation only (not fixed here): master's root package-lock.json version metadata lags package.json (lock records bili 0.1.190 / acp-kernel 0.0.112 vs actual 0.1.191 / 0.0.114); npm install self-heals it and CI is unaffected.

Closes #2699
Closes #2698
Closes #2697

…dget test

#2688 removed compress.stripImages/stripImagesKeepRecent from CompressSettings, but #2613's image-request-budget test (merged after #2688) still referenced them, breaking master typecheck. Drop the dead keys from the fixture config and the inert stripImages=false toggle line; keep every assertion intact (over-budget rebuilt request -> forward-stage 413, no upstream contact). Zero behavioral change.
@github-actions

github-actions Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-11_fix-image-budget-typecheck (b0d5119)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.2918-pr.2702.e81f07a

This exact version is immutable and reproducible. The rolling pr tag tracks the newest test build across all PRs.

Option B — Download artifact

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

Install instructions are refreshed on each push.

…semantics

Supplement to 990cbe8 (which fixed only the tsc errors): under
post-#2688 semantics there is no wire-side image reduction left, so
the two tests that asserted the removed stripImages recovery path
(200 + reduced rebuilt body) fail at runtime with the forward-stage
413. Adapt them to assert the actual contract: over-budget rebuilt
bodies stop at stage=forward / request_too_large without touching
upstream, whether images sit in messages or tool outputs; the
admission-slot flow ends at the same forward guard once a slot is
released. Also fix reference/request-body-budget.md (en+zh), which
still told users to configure the removed compress.stripImages.

Verified locally: tsc --noEmit clean; node --import tsx --test
--test-concurrency=1 tests/image-request-budget.test.ts
tests/request-body-budget.test.ts -> 10/10 pass.
@ranxianglei ranxianglei changed the title fix(#2699): remove stale stripImages refs breaking master typecheck fix(#2698,#2699,#2697): repair stripImages-removal race — typecheck + budget tests + doc Oct 10, 2026
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

Review 结论(含在本分支上直接完成的补充工作):

方向关:正确。issue 家族(#2699/#2698/#2697)同一机制(#2688/#2613 merge race),修复方向是适配 post-#2688 语义而非恢复被删机制——即 #2698 的 option 2。

首轮 review 发现(已就地修掉,commit b0d511987):原 commit 990cbe86f 只修了两个 tsc 错误,但 #2698 明确指出"It is not only a type error"——同文件另有两个测试断言的正是被删掉的 stripImages 恢复路径,机械删除死引用后它们在 runtime 失败(413≠200):"reaches explicit image reduction" 期望减量后的 200 body,admission 测试期望 retry 后 200。原样合并的话 master typecheck 转绿但 test 步骤仍红。另外 reference/request-body-budget.md(en+zh)仍在指导用户配置已删除的 compress.stripImages / stripImagesKeepRecent。补充内容:这两个测试改写为断言当前契约(over-budget rebuilt body → forward-stage 413、不触碰上游,覆盖 message/tool-output 两种图片位置;admission 槽位释放后同样终止于该守卫),文档改指向 #2640 媒体折叠 + decompress({imageRef});标题/正文同步更新(Closes #2699/#2698/#2697)。

八问:

  1. 是什么问题:merge race 导致的 CI 阻塞(typecheck 2 错 + 2 个 runtime-red 测试 + 文档陈旧引用)。
  2. 什么原因:fix: 让压缩图片历史先减量,再检查发送字节预算 #2613 基于移除前 base 编写、比 refactor(#2607): remove compress.stripImages — default media folding replaces it #2688 晚 32 秒合入,其自身 CI 跑在早于移除的 merge-ref 上。
  3. 影响范围/严重程度:所有开放 PR 在 tsc 阶段变红,PR 管线整体阻塞;运行时行为零影响。
  4. 怎么修的:零 src/ 改动,测试/文档适配既有 post-refactor(#2607): remove compress.stripImages — default media folding replaces it #2688 契约(option 2)。
  5. 回归:无——无 src/ diff;适配断言钉住的是既有行为(relay.ts forward 守卫、handle.ts finally 槽位释放)。审过的既有行为逐项:receive/decode/forward 三道边界、admission 名额、SSE-committed 错误通道、passthrough 边界——全部保持。
  6. 缓存:不涉及。
  7. 设计方向:不变(option 1 属设计决策,留待 owner,见 master is typecheck-broken: image-request-budget test still uses removed compress.stripImages (#2688 x #2613 race) #2698)。
  8. 新配置:无(反而清掉了已删项的陈旧引用)。

测试有效性:改写后的断言有牙——未来若有人重新引入对超预算 body 的静默缩减、或让大 body 触碰上游,calls.length == 0 / 413-forward 断言会抓住;保留了 #2613 原作者(外部贡献者 overFloweee)的数据安全覆盖意图,fixture/场景原样,仅改了断言被删机制的那部分。

验证:本地 tsc clean;受影响全套 10/10 pass(含两个改写测试);合并前复现了 master 基线(tsc 2 错 + 2 个 runtime 失败)。

diff 整洁度:2 文件(测试 + reference 文档),每行都与本 PR 目的相关;lockfile churn 已还原。

结论:可合。顺带观察(不在本 PR):master lock 版本元数据漂移 → 已独立立项 #2704。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 Review 结论:PR #2702 不完整 —— 只修了 typecheck 半边,运行时 2 个测试仍红,合并后 CI 依旧失败。不建议按现状合并。 更完整的 #2703(同根因,CI 全绿)已存在,建议收敛到它。证据与细节如下。

验证过程(全部实际执行)

  • 代码核对:fetch pr2702(head 990cbe8)本地核对,diff 确为单文件 tests/image-request-budget.test.ts(+4/−5):L49 fixture 删 stripImages: true, stripImagesKeepRecent: 1、删失效的 opts.compress.stripImages = false;、测试改名、5 条断言逐字保留。✅ 与描述一致。
  • 本地 typecheck:PR head 上跑 npm run typecheck → 绿(修复前为 TS2353@49 / TS2339@111)。✅
  • CI 实测(决定性):本 PR 的 CI run 38070269323 = failure,test matrix 四条腿全挂(ubuntu-22/24、windows-22/24),各 guard job 全绿。ubuntu-22 job(114266108598)日志下载后确认恰好 2 个失败:

结构化八问

  1. 是什么问题:fix: 让压缩图片历史先减量,再检查发送字节预算 #2613 × refactor(#2607): remove compress.stripImages — default media folding replaces it #2688 合并顺序交互弄红 master——refactor(#2607): remove compress.stripImages — default media folding replaces it #2688 删除了 compress.stripImages/stripImagesKeepRecent,而更晚合入的 fix: 让压缩图片历史先减量,再检查发送字节预算 #2613 新增的 tests/image-request-budget.test.ts 仍引用这两个字段。
  2. 什么原因导致的(分层):两层。typecheck 层 = 对已删字段的陈旧引用(TS2353/TS2339)。runtime 层 = 同一删除还抽掉了文件里另外两个测试赖以成立的行为:refactor(#2607): remove compress.stripImages — default media folding replaces it #2688 之前 stripImages: true 正是把超预算重建体缩回 100 MiB 预算内并返回 200 的机制;refactor(#2607): remove compress.stripImages — default media folding replaces it #2688 之后没有 wire 侧缩减路径,这类请求一律 forward 413。fix(#2698,#2699,#2697): repair stripImages-removal race — typecheck + budget tests + doc #2702 只修了 typecheck 层,runtime 层的 200 期望原样保留。
  3. 影响范围与严重程度:本 PR 合入后 master CI 仍红(test matrix 四腿全挂),阻塞所有 open PR 的 CI;无生产行为影响(纯测试文件)。严重度:master-red / 发布阻塞级。
  4. 怎么修复的(本 PR 思路):删共享 fixture 的陈旧字段引用 + 删失效 toggle 行,保留所动单个测试的 413 断言。方向正确但不完整——验证只做了「改动的单个测试隔离通过」,未验证整文件;其余两个测试共享该 fixture,其 200 期望已被 refactor(#2607): remove compress.stripImages — default media folding replaces it #2688 失效。PR 描述中「zero behavioral change、baseline 也过」仅对该单个测试成立,对整个文件不成立(master 基线直接跑是 pass 4/fail 2,master is typecheck-broken: image-request-budget test still uses removed compress.stripImages (#2688 x #2613 race) #2698 已报告)。
  5. 是否有回归问题:本 PR 自身无新回归(零 src 改动)。它遗留的是既有问题本体:两个未改动的兄弟测试仍编码 refactor(#2607): remove compress.stripImages — default media folding replaces it #2688 前语义(超预算→缩减→200),对当前行为必然失败。
  6. 是否破坏缓存:不涉及。
  7. 是否改了设计方向:本 PR 本身:没有。但底层存在一个未拍板的产品决策(master is typecheck-broken: image-request-budget test still uses removed compress.stripImages (#2688 x #2613 race) #2698 明确提出):选项 1 恢复显式超预算缩减路径(旧测试 200 期望成立)vs 选项 2 接受 forward 413 为正确语义(旧测试期望需改写)。选哪个决定哪套测试期望是对的——需要 owner 拍板。
  8. 是否引入新配置:不涉及。

与 #2703 的对照及处置建议

判定:#2702 按现状不达合并标准(CI 红、修复不完整);等待 owner 对「选项 1 vs 选项 2」与「保留哪个 PR」拍板后执行收敛。本轮我未向任何分支推送改动。

@ranxianglei
ranxianglei merged commit ba0b532 into master Oct 11, 2026
13 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.239-master.ba0b532 (rolling master tag).

npm install -g billion-context@0.0.239-master.ba0b532  # this exact build
npm install -g billion-context@master  # always the newest merged build

npm view billion-context@master prints the current version at any time.

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

Labels

None yet

Projects

None yet

1 participant