Skip to content

wire-exit 早提交时序断言改为相对不变量,消除 Windows CI 偶发误报(#3228) - #3233

Merged
ranxianglei merged 1 commit into
masterfrom
2026-10-15_wire-exit-timing-relative-invariant
Oct 15, 2026
Merged

ranxianglei merged 1 commit into
masterfrom
2026-10-15_wire-exit-timing-relative-invariant

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

问题

#3228:tests/wire-exit-matrix.test.ts 里「早提交」时序断言在 CI Windows runner 上偶发误报,挡合并。失败签名 'headers committed before the slow summarization failed (1968ms)' @ tests/wire-exit-matrix.test.ts:348,仅 test (windows-latest, 24, 1) 单格红、其余 7 格绿,本地 standalone 全绿——是 CI runner 负载抖动下的测试自身脆弱性,不是回归。

根因

断言用的是绝对墙钟上界 assert.ok(r.tHeaderMs < SLOW_MS)(SLOW_MS=1500)。它假设「客户端收到 header 的时刻 < 1500ms」,但客户端计时与 mock 的 setTimeout(..., 1500) 都挂在同一个 Node 事件循环上;当 runner 负载把事件循环卡住 >1500ms(mock 定时器还没到点、header 却已先被提交),这个绝对上界就误判。真实缺陷(早提交失效 → header 拖到 summarization 完成之后才发出)本应被抓,但绝对上界把「先后顺序」错当成了「时长」。

同类机制已在 #3147-C(PR #3152,已合入)把 preflight-hold.test.ts 的同款断言改成相对不变量。本 PR 覆盖 class-scan 找到的残留实例。

修法

镜像 #3152-C:mock 在慢速 summarization 调用真正完成/失败的那一刻记录 summaryDoneMs(同一进程时钟),断言从绝对上界改为相对顺序不变量:

assert.ok(up.summaryDoneMs() > 0, "the slow summarization call completed");
assert.ok(r.tHeaderMs < up.summaryDoneMs() - r.t0, `headers committed before ... (${r.tHeaderMs}ms vs ${up.summaryDoneMs() - r.t0}ms)`);

tHeaderAt 与 summaryDoneAt 同进程同时钟:均匀的事件循环卡顿对两者等量拉伸、不改变先后顺序(300ms hold-grace 定时器永远先于 1500ms 定时器触发),因此负载无关;而真实的早提交失效会让 header 落在 summarization 完成之后,仍会被抓住——牙齿没丢。

改动文件(仅两个测试文件,无 server/config/wire 变更):

  • tests/wire-exit-matrix.test.ts — 两处断言(slow-summary-fwd-429 / slow-summary-429)
  • tests/wire-exit-gap-cells.test.ts — gap 3 一处断言

行为变更披露

仅测试断言语义变化:绝对墙钟上界 < 1500ms → 相对顺序「早于 summarization 完成」。断言抓取的缺陷集合不变(仍抓早提交失效),只去掉负载相关的假阳性。无任何生产代码、配置、wire 协议改动。

验证

  • 本地定向跑两个改动文件:12/12 通过
  • npm run typecheck:干净
  • 全量回归交给远程 CI

查重

查重: 与已关闭的 #3147(子缺陷 C,PR #3152 已合)为同一机制家族,非纯重复——#3152-C 只改了当日触发文件 preflight-hold,未覆盖本 PR 的两个兄弟文件;#3228 是残留实例,作为 tracker 保留并在此一并修完。

Closes #3228

Replace the absolute 'tHeaderMs < SLOW_MS' (SLOW_MS=1500) wall-clock bound in the wire-exit early-commit tests with a relative invariant ('tHeaderMs < summaryDoneMs - t0', both timestamps on the same process clock). The absolute bound flakes under CI runner load whenever the event loop stalls >1500ms before the mock's summarization timer fires; the relative form is load-invariant and still catches a true regression (headers committed after summarization completes/fails). Mirrors the #3147-C fix already merged in preflight-hold.test.ts (#3152) and covers the residual instances in wire-exit-matrix.test.ts and wire-exit-gap-cells.test.ts surfaced by class scan.

Fixes #3228
@github-actions

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-15_wire-exit-timing-relative-invariant (6a5241c)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.3729-pr.3233.8f82358

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-pr3233.tgz
npm install -g package

Install instructions are refreshed on each push.

@github-actions

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.441-master.db046b2 (rolling master tag).

npm install -g billion-context@0.0.441-master.db046b2  # 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

Development

Successfully merging this pull request may close these issues.

wire-exit-matrix 的墙钟时序断言在 CI Windows runner 上偶发误报,挡合并

1 participant