Skip to content

test(#1785): raise dsh-native attach-mode poll budget from 5s to 15s for loaded hosts - #1793

Merged
ranxianglei merged 2 commits into
masterfrom
2026-09-30_dsh-test-wait-headroom
Oct 1, 2026
Merged

ranxianglei merged 2 commits into
masterfrom
2026-09-30_dsh-test-wait-headroom

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

What & why

tests/dsh-native.test.ts gates async tool-registration behind a FIXED wall-clock poll deadline (waitFor at ~line 413, plus two inline attach loops at ~line 1386 / ~line 1433). On a heavily loaded dev host (CPU/event-loop starvation) a real loopback manifest round-trip can exceed 5s wall-clock, tripping uniform ≈5.0–5.1s timeout failures across the attach cluster (one #1130 case + five #1365 cases) even though the same code passes in CI and on a light host. Root-caused in #1785.

Centralize the budget in POLL_DEADLINE_MS = 15000 and apply it to all three sites. Fast CI (sub-second) is unaffected; a genuine hang still fails, just later.

Scope / behavior

  • Test-only: tests/dsh-native.test.ts (1 file, +11/−8). No product/wire/config/persistence impact.
  • The only observable change is the test timeout budget: 5s/4s → 15s (intended, disclosed here per policy). It strictly widens the acceptance window; no assertion semantics are inverted (all three sites throw-on-timeout).
  • Deliberately NOT applied to the other 14 test files that share the same pattern — only dsh-native is implicated by [tests] dsh-native attach-mode cluster (#1130/#1365) times out / stalls on dev host (suspected environmental) #1785; rewriting all of them would be unrelated diff churn.

Pre-flight

  • typecheck (tsc --noEmit --project tsconfig.build.json): clean
  • node --import tsx --test tests/dsh-native.test.ts: green on clean master AND with this change (see note below re: pre-existing flakes)
  • build (tsup): success

Note for reviewers / CI

While verifying I observed pre-existing intermittent flakes unrelated to this change — #983 maybeRetry self-heals a base-less register after a failed respawn (fast ~95ms, non-timeout) and #956 apply() runtime-info: a mid-resolve model switch discards the stale resolve rotate across runs and also appear on current master's windows/22 CI. A red dsh-native job on this PR may be one of those rather than this diff. Tracked separately: #1791.

Closes #1785
Related: #1791

…oaded hosts

The shared waitFor cap plus two inline attach polls used a fixed 5s/4s
wall-clock deadline around a real loopback manifest round-trip. On a
heavily loaded dev host (CPU/event-loop starvation) that round-trip can
exceed 5s wall-clock, tripping uniform ~5s timeout failures across the
attach cluster (one #1130 case + five #1365 cases) even though the same
code passes in CI and on a light host.

Centralize the budget in POLL_DEADLINE_MS (15000) and apply it to all
three sites. Fast CI (sub-second) is unaffected; a genuine hang still
fails, just later. Test-only; no product/wire/config/persistence impact.
@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-09-30_dsh-test-wait-headroom (0876a5e)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.1769-pr.1793.239a9a3

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

Install instructions are refreshed on each push.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 收到,开始 review PR #1793(test(#1785):dsh-native attach-mode 轮询预算 5s→15s)。计划:拉分支核对 diff(单文件 +11/−8)→ 本地跑 typecheck / dsh-native 测试 / build → 核对 CI 状态 → 按结构化七问给结论。完成后更新。

The pre-PR comment said the full grace default would outlast the 5s
waitFor cap — true then (grace 5s == cap 5s). After the cap moved to
POLL_DEADLINE_MS = 15000 that inequality no longer holds (5s < 15s);
the pin's real job is keeping each legacy dead-attach suite from sitting
out the full grace window so the cap dominates timing.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 Review 完成。结论:可合并(merge 由人执行)。

结构化七问:

  1. 是什么问题:dsh-native attach 模式的异步工具注册被固定 wall-clock 轮询 deadline(5s/4s)把关;高负载主机上真实的 loopback manifest round-trip(registerTools→fetchManifest)可超过 5s,导致 attach 测试簇(native attach 模式无运行时 respawn:共享代理的属主退出后,attach 方全部模型请求永久硬失败 #1130 ×1 + bug: dsh-native — attach 目标瞬时不可达 → 回退 spawn 第二实例:routed baseURL 下工具/模型通道必然脑裂(工具 404 → preflight 502 → 会话不可自愈) #1365 ×5)在 ~5.0–5.1s 整齐超时,而 CI 与轻载机器全绿。
  2. 什么原因导致的:deadline 包裹的是真实网络 I/O,CPU/event-loop 饥饿下 wall-clock 必然漂移——环境负载而非代码缺陷;旧 deadline 对该类真实 I/O 过紧([tests] dsh-native attach-mode cluster (#1130/#1365) times out / stalls on dev host (suspected environmental) #1785 已根因定位,本次审核复核了代码路径,成立)。
  3. 怎么修复的:集中为 POLL_DEADLINE_MS = 15000(tests/dsh-native.test.ts:411),三处统一引用(waitFor helper :416 + 两个 inline loop :1389/:1436);全部保留 throw-on-timeout,只放宽接受窗口、不反转断言语义;刻意不动其余 14 个共享同模式的文件,避免无关 diff churn。
  4. 是否有回归问题:无。逐项审过的既有行为:
  5. 是否破坏缓存:不涉及(test-only,产品零改动)。
  6. 是否改了设计方向:否。行为变更披露:测试超时预算 5s/4s → 15s(PR body 已声明,严格放宽;真挂死仍会失败,只是更晚)。
  7. 是否引入新的配置:否。POLL_DEADLINE_MS 是测试文件模块级常量,非 config surface;无新 env/config/默认值。

Review 期间的额外工作(披露):发现 PR 新增 header 注释里 grace-pin 的理由「(it would outlast the POLL_DEADLINE_MS cap and race it)」不成立——grace 默认 5s < 新 cap 15s,不存在「outlast」;pin 的真实作用是防止 legacy dead-attach 用例坐满整个 grace 窗口。按「小问题直接修」就地修正:commit 0876a5e3(纯注释,零逻辑变化)已推到 PR 分支,typecheck + dsh-native 39/39 本地复验绿。

Pre-flight 复核(pr head 本地):typecheck clean / tsup build OK / node --import tsx --test tests/dsh-native.test.ts 39/39(两次运行)。CI(head 0876a5e3):12/12 全绿(含 windows/22 重跑)。Base 为当前 origin/master HEAD,无需 rebase。

判定:可合并。 测试单文件、base 最新、无热文件冲突、断言有牙未失、flake 属预存在且单独跟踪(#1791)。请人工合并:#1793

@ranxianglei
ranxianglei merged commit 0924e90 into master Oct 1, 2026
16 of 17 checks passed
@ranxianglei
ranxianglei deleted the 2026-09-30_dsh-test-wait-headroom branch October 15, 2026 05:32
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.

[tests] dsh-native attach-mode cluster (#1130/#1365) times out / stalls on dev host (suspected environmental)

1 participant