Skip to content

[PR] fix: serve the missing /__bili/upstreams endpoint so the DSH upstream banner works - #5147

Merged
ranxianglei merged 15 commits into
masterfrom
2026-10-29_5146-bili-upstreams-endpoint
Oct 31, 2026
Merged

ranxianglei merged 15 commits into
masterfrom
2026-10-29_5146-bili-upstreams-endpoint

Conversation

@ranxianglei

@ranxianglei ranxianglei commented Oct 29, 2026 •

Copy link
Copy Markdown
Owner

Closes #5145

查重: 无(open+closed issue/PR 全量检索 upstreams / upstreamBanner / CORS / 横幅,无同症状同机制条目;相关历史为 #4254 → #4257/#4267,两者均关闭未合并——见下)。

What happened

The DSH frame-level upstream banner (shipped in 6874e39 from #4254) polls GET /__bili/upstreams every 10 s. Its server half never landed: PR #4257 closed unmerged and the re-land 050241c kept only the egress fixes, so every poll 404s AND is CORS-blocked in the DSH renderer (admin JSON routes send no Access-Control-Allow-Origin). Result: the banner slot bili-upstreams never shows, and each session logs one console error per 10 s (19+/day for the reporter).

Fix (one closed loop)

  1. Loopback-gated GET /__bili/upstreams in handleAdminRoute projecting the alert table + open circuits into the Circuit-open 502 keeps an opaque error string, and connect-refused alerts never reach the host GUI | [Bug][dsh] 熔断/连接失败时客户端只见常量 "acp-proxy failure":detail/upstreamFailure/alerts 全都没到用户眼前 #4254-settled contract {upstreams:[{host,port,kind,code,hint,count,firstSeen,lastSeen,circuit:{state,nextProbeInMs}|null}]}: one row per host; an OPEN circuit outranks alerts (fail-fast stops minting alerts once open — it is the authoritative down signal); alerts cover the pre-circuit window and carry the hint.
  2. ACAO echo on this route only, same gate-first pattern as the /__bili/ shell and /__bili/plugin/status ([Bug] Inconsistent host-side context statistics after compression in dsh plugin mode (ref: dsh-context#173) | [Bug] dsh 插件模式压缩后宿主侧上下文统计不一致(引用 dsh-context#173) #3862): only origins the trusted-origin gate admitted reach dispatch, so echoing cannot widen the admin surface.
  3. errno captured at failure time (optional code on UpstreamAlert/UpstreamCircuitFailure) so the report shows WHY beyond the classified kind; the client banner renders it when present.
  4. Attached sub-problem from the issue (diagnostics "host client versions" all "?"): on DSH Desktop bundle installs the @deepseek-ai core ships inside the app, not under the profile's node_modules, so all three lookups missed with no hint where to look. The diagnostics line now annotates the all-miss case explicitly (separate labeled commit).

No client-side change: once the request returns 200+ACAO the browser stops logging; proxy-down degrades to a plain network-error rejection (no CORS line), same behavior as the Context-tab poller.

Behavior changes (old → new)

  • NEW route GET /__bili/upstreams (additive; nothing changes until something polls it).
  • That route's responses carry access-control-allow-origin equal to the requesting Origin when one is present — new route only; every other admin route's headers are byte-identical to before.
  • /__bili/overview's upstreamAlerts entries may now include an optional code field (errno at failure time) — additive, ignored by existing consumers.
  • Diagnostics blob: a profile whose bundle resolves NONE of the three @deepseek-ai packages now prints an explanatory line instead of three bare "?"; partial absence keeps the per-package "?".

Tests

New tests/issue5146-upstreams-endpoint.test.ts (projection semantics: alert-only window / circuit precedence / recovery drops the host / portless host; HTTP surface: ACAO echo, healthy empty list without ACAO, non-loopback 403, tunnel 403) plus an extended fixture + assertion in tests/web-diagnostics-enrichment.test.ts. Targeted suites green locally (70 tests across the eight files touching these modules); full-suite verdict comes from CI.

ci-check added 2 commits October 29, 2026 21:17
…s its data (#5146)

The DSH frame-level upstream banner (shipped via 6874e39 from #4254) polls
/__bili/upstreams every 10s, but its server half never landed: PR #4257 closed
unmerged and the re-land (050241c) kept only the egress fixes. Every poll
therefore 404'd AND was CORS-blocked in the DSH renderer (admin JSON routes
send no Access-Control-Allow-Origin), so the banner never showed and each
session logged one console error per 10s.

- Add loopback-gated GET /__bili/upstreams to handleAdminRoute projecting the
  alert table + open circuits into the #4254-settled contract
  {upstreams:[{host,port,kind,code,hint,count,firstSeen,lastSeen,circuit}]};
  one row per host, the OPEN circuit outranks alerts (fail-fast stops minting
  alerts once open, so it is the authoritative down signal), alerts cover the
  pre-circuit window and carry the hint.
- Echo the requesting Origin as ACAO on this route only — same gate-first
  pattern as the /__bili/ shell and /__bili/plugin/status (#3862); only
  origins the trusted-origin gate admitted reach dispatch, so the echo cannot
  widen the admin surface. No Origin (curl/probes) → no ACAO, unchanged.
- Capture the errno at failure time into UpstreamAlert/UpstreamCircuitFailure
  (optional code field) so the report shows WHY beyond the classified kind —
  the client banner renders it when present.
- Tests: projection semantics (alert-only window / circuit precedence /
  recovery drops the host / portless host) plus the HTTP surface (ACAO echo,
  healthy empty list without ACAO, non-loopback 403, tunnel 403).
… has no @deepseek-ai packages (#5146)

Attached sub-problem of #5146: on DSH Desktop bundle installs the profile's
node_modules holds third-party plugins (billion-context) alone — the
@deepseek-ai core ships inside the app — so all three lookups missed and
reports read 'dsh ?, dsh-compaction-basic ?, dsh-web-app ?', losing the
host-version dimension with no hint where to look. When NONE of the three
resolves for a profile, the line now says so explicitly (and asks reporters
to include the app version); partial absence keeps the per-package '?'.
@ranxianglei ranxianglei changed the title fix: serve the missing /__bili/upstreams endpoint so the DSH upstream banner works [PR] fix: serve the missing /__bili/upstreams endpoint so the DSH upstream banner works Oct 29, 2026
@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-29_5146-bili-upstreams-endpoint (9a88a8c)

Latest build — install this exact version

npm install -g billion-context@0.0.7259-pr.5147.f168366

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

Recent builds (commit → version)

commit version build
9a88a8c billion-context@0.0.7259-pr.5147.f168366 build
2a9dad3 billion-context@0.0.7125-pr.5147.89b345a build
885ac31 billion-context@0.0.6943-pr.5147.16a2ee5 build
345aab3 billion-context@0.0.6793-pr.5147.b5d1030 build
26f36a5 billion-context@0.0.6789-pr.5147.6dab6bc build
6829827 billion-context@0.0.6781-pr.5147.6714c13 build

Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr5147.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

(ai: vllm-qwen/qwen3.8-27b)

查重: 不重复。open+closed 全量检索 upstreams / upstreamBanner / CORS / 横幅,无同症状同机制条目;相关历史为 #4254 → #4257 / #4267,两者均已关闭且未合并(#5146 是 DIGEST DRIFT,与本问题无关,编号巧合)。

标签: bug dsh scope/wiring p2 —— DSH 帧级横幅每 10s 轮询的服务端路由缺失,属协议接线缺陷;核心代理能力不受影响(横幅不显示 + 控制台报错刷屏),有绕行(忽略),故 p2 而非 p1。

开工计划(按 issue「一个闭环」四件落地,客户端零改动):

  1. handleAdminRoute 加 loopback 门控 GET /__bili/upstreams:把 alert 表 + open circuit 投影成 Circuit-open 502 keeps an opaque error string, and connect-refused alerts never reach the host GUI | [Bug][dsh] 熔断/连接失败时客户端只见常量 "acp-proxy failure":detail/upstreamFailure/alerts 全都没到用户眼前 #4254 契约 {upstreams:[…]},一 host 一行,OPEN circuit 优先于 alert(fail-fast 后 alert 停发,circuit 才是权威 down 信号)。
  2. 仅该路由回显 access-control-allow-origin(gate-first,同 /__bili/ shell 与 [Bug] Inconsistent host-side context statistics after compression in dsh plugin mode (ref: dsh-context#173) | [Bug] dsh 插件模式压缩后宿主侧上下文统计不一致(引用 dsh-context#173) #3862 模式)。
  3. 失败时捕获 errno → UpstreamAlert / UpstreamCircuitFailure 加可选 code,横幅在存在时渲染。
  4. diagnostics 的 @deepseek-ai 三包全缺时补一句说明(DSH Desktop bundle 把 core 打进 app 而非 profile node_modules)——独立标注 commit。

定向测试本地跑,全量回归交 CI。代码落地后即提 PR 并回贴链接。

@ranxianglei ranxianglei added bug Something isn't working dsh p2 scope/wiring labels Oct 29, 2026
The new GET /__bili/upstreams read contract (UpstreamHealthEntry / UpstreamHealthReport) is referenced only inside src/upstream-alerts.ts; admin.ts consumes getUpstreamHealthReport() structurally via JSON.stringify. Keep the exports so the wire shape stays named at its definition site, mirroring the LastInstallRecord / ResidentFieldBreakdown+MemoryReport precedents in the same WAIVERS list.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

CI 已直接在 PR 分支上修好并推送,unused-exports 门本地验证通过(exit 0)。这是纯门禁小修、单文件、无设计取舍,故按自动修复车道直接处理,不立项。

红在哪:PR 新增的 GET /__bili/upstreams 读契约里两个类型 UpstreamHealthEntry(src/upstream-alerts.ts:335)、UpstreamHealthReport(src/upstream-alerts.ts:354)被判为 INTERNAL_ONLY 而挂红。它们只在 src/upstream-alerts.ts 内部作为 getUpstreamHealthReport()(src/upstream-alerts.ts:358)的返回/元素类型被引用;admin.ts:248 用 JSON.stringify(getUpstreamHealthReport()) 按结构消费,测试按 .upstreams[0] 结构访问——没有任何地方 import 这两个名字,纯文本词频的门就判「只内部使用」。

怎么修的:在 scripts/check-unused-exports.mjs 的 WAIVERS 表加一条有理由的豁免,保留这两个 export。不是删 export——同一张表里已有 4 个完全同类的先例都这么处理:LastInstallRecord(src/update.ts)、ResidentFieldBreakdown+MemoryReport(src/session.ts)、DshCompactionGateTelemetry(src/agent/dsh-compaction-disable.ts),全是「admin.ts 按结构消费的 /__bili/* 或状态 payload 接口,保留导出让线上形状在定义处有名」。跟先例保持一致,不另起第 5 种处理;删 export 反而会让作者写好的字段级 wire 契约文档失去命名载体。

八问:

  1. 是什么问题:PR 新增的两个 wire 契约类型被 unused-export 门判为「只内部使用」而挂红,与运行时逻辑无关。
  2. 什么原因导致:这两个 interface 只在声明文件内被引用、外部无 import;门是词频统计,判 INTERNAL_ONLY(合法出口有三个:删 DEAD / 去 export / 加有理由 WAIVER)。
  3. 影响范围与严重程度:仅 CI 门禁层面,不影响任何运行时行为或用户面;属「门红挡合并」,非功能缺陷。
  4. 怎么修复的:走门自身给的第三个合法出口——加有理由 WAIVER,措辞镜像既有 4 个同类先例,保留导出。
  5. 是否有回归问题:无。改动只落在 CI 脚本 scripts/check-unused-exports.mjs(该脚本把自己排除在扫描外,新增的是数据条目不是逻辑),不碰任何 src/test/kernel/config/wire 代码;同一次运行里其余 11 个前置 job(docs-sync / version-guard / kernel-guard / lane-guard / config-surface-guard / …)全绿,证明是 PR 自身门问题而非继承性 master 红。
  6. 是否破坏缓存:不涉及(与缓存/重试/游标/去重键无关)。
  7. 是否改了设计方向:不涉及(未改架构/边界/数据流)。
  8. 是否引入了新的配置:不涉及(无新 env/config/默认值)。

push:6829827d2..26f36a5b3 @ 2026-10-29_5146-bili-upstreams-endpoint。判定:小修已闭环,等 CI 重跑确认绿即可合入。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

先说结论:这不是要我另开 PR 的任务。 查重命中在途 PR #5147(同症状、同机制、同方案),它已经完整实现了这个闭环。按「已有修复 PR 在途 → review/接力,不并列开重复 PR」的纪律,我没有新开 PR,而是:①独立从零复现了同一修复做本地验证;②拉取并审阅了 #5147 的实际代码与测试覆盖;③修掉它一处元数据缺陷。

我实际做的事(可复核):

  1. 独立本地验证:从零实现同一修复并跑通——npm run typecheck 绿 + 定向测试 16/16 绿(新端点 10 例 + diagnostics 6 例)。证明该设计成立且可测。
  2. 审阅 [PR] fix: serve the missing /__bili/upstreams endpoint so the DSH upstream banner works #5147:确认它是同架构的并行实现——getUpstreamHealthReport() 投影告警表+open 熔断成 Circuit-open 502 keeps an opaque error string, and connect-refused alerts never reach the host GUI | [Bug][dsh] 熔断/连接失败时客户端只见常量 "acp-proxy failure":detail/upstreamFailure/alerts 全都没到用户眼前 #4254 契约、handleAdminRoute 里 loopback-gated GET /__bili/upstreams + gate-first ACAO echo(src/server/admin.ts:243-248)、errnoCode() 在失败时抓 errno、diagnostics 对"三包全 miss"标注;其 tests/issue5146-upstreams-endpoint.test.ts 8 例覆盖同一正/负矩阵(alert-only / 熔断优先于 stale 告警 / 恢复移除 host / portless / ACAO echo / 无 Origin 不回 / 非 loopback 403 / tunnel 403)。代码审核通过。
  3. 修一处缺陷:正文 Closes #5146 指向的是无关的 DIGEST DRIFT(GitHub In storage unified FULL mode, the same session repeatedly hits DIGEST DRIFT (views are not converging), dropping the ing | storage unified FULL 模式下同一会话反复 DIGEST DRIFT (views are not converging),每次丢 ingest 水位并重灌尾部 #5146),真正的 bug 是 The DSH client's upstreamBanner requests a non-existent /__bili/upstreams endpoint, and since the admin panel lacks | DSH 客户端 upstreamBanner 请求不存在的 /__bili/upstreams,且管理端无 CORS 头,导致横幅永久失效并每 10 秒刷一条控制台错误 #5145(upstreamBanner 请求不存在的端点)。已 PATCH 为 Closes #5145 并复核生效——否则合并时会误关 DIGEST DRIFT。(注:ework 内部编号与 GitHub 编号已错位,ework 的 In storage unified FULL mode, the same session repeatedly hits DIGEST DRIFT (views are not converging), dropping the ing | storage unified FULL 模式下同一会话反复 DIGEST DRIFT (views are not converging),每次丢 ingest 水位并重灌尾部 #5146 ≈ GitHub 的 The DSH client's upstreamBanner requests a non-existent /__bili/upstreams endpoint, and since the admin panel lacks | DSH 客户端 upstreamBanner 请求不存在的 /__bili/upstreams,且管理端无 CORS 头,导致横幅永久失效并每 10 秒刷一条控制台错误 #5145。)

八问

  1. 是什么问题:DSH 客户端的 upstream 不可用横幅(Circuit-open 502 keeps an opaque error string, and connect-refused alerts never reach the host GUI | [Bug][dsh] 熔断/连接失败时客户端只见常量 "acp-proxy failure":detail/upstreamFailure/alerts 全都没到用户眼前 #4254 上线)每 10s 轮询 GET /__bili/upstreams,但服务端这个路由从未落地,且 admin JSON 路由不发 CORS 头——横幅槽永远不显示,每个会话每 10s 刷一条 console error。
  2. 什么原因导致的:服务端半侧缺失。Circuit-open 502 keeps an opaque error string, and connect-refused alerts never reach the host GUI | [Bug][dsh] 熔断/连接失败时客户端只见常量 "acp-proxy failure":detail/upstreamFailure/alerts 全都没到用户眼前 #4254 只落了客户端轮询+横幅渲染;服务端 endpoint 在 [PR] Make upstream-failure egress diagnosable (#4254): informative error, 503+Retry-After on circuit-open #4257 写出后该 PR 关闭未合并,后续 re-land(050241c)只捡回 egress 修复没带这个路由。叠加 admin 面一律不回 access-control-allow-origin,跨源 dsh fetch 即便拿到 200 也读不到 body。两个缺陷叠加 = 横幅永久失效。
  3. 影响范围与严重程度:仅影响 dsh 车道用户看到的 upstream 不可用横幅(诊断性 UI),核心代理功能不受影响。触发条件:upstream 真不可用时本应亮横幅却永远不亮 + 持续 console error(报告者 19+/天)。严重度 p2——能用、有绕行(无视横幅和日志噪音),但一个已上线的诊断能力整体失灵且持续刷错;非 p1(不丢数据、不毁会话、核心可用)。
  4. 怎么修复的:一个闭环四件事——① 加 loopback-gated GET /__bili/upstreams,把告警表+open 熔断投影成 {upstreams:[{host,port,kind,code,hint,count,firstSeen,lastSeen,circuit:{state,nextProbeInMs}|null}]},一 host 一行、OPEN 熔断优先于其 stale pre-circuit 告警、恢复即移除该 host;② 仅在该路由回 ACAO echo(gate-first,同 /__bili/ shell 与 plugin/status [Bug] Inconsistent host-side context statistics after compression in dsh plugin mode (ref: dsh-context#173) | [Bug] dsh 插件模式压缩后宿主侧上下文统计不一致(引用 dsh-context#173) #3862 既有模式);③ 失败时抓 errno(可选 code 字段),报告能显示 WHY;④ 附带子问题:DSH Desktop bundle 下 @deepseek-ai core 在 app 内而非 profile node_modules,三探测全空时无提示→diagnostics 行对全-miss case 显式标注。无客户端改动。
  5. 是否有回归问题:审过的既有行为——新增路由纯增量(此前无人轮询它);ACAO echo 只加在新路由,其余 admin 路由 header 逐字节不变,loopback/tunnel/trusted-origin 三道门顺序与 403 语义不变;/__bili/overview 的 upstreamAlerts 可能多一个可选 code(additive,既有消费者忽略);diagnostics 仅对"三包全 miss"的 profile 多一行(partial absence 仍保持 per-package "?")。高危模式逐项过:无 fail-fast→吞错、无阈值/时序/输出格式漂移。
  6. 是否破坏缓存:不涉及——纯新增只读 admin 端点 + diagnostics 文本行,不触碰任何缓存/重试/增量游标/去重键。
  7. 是否改了设计方向:不涉及——无架构转向,只是把 Circuit-open 502 keeps an opaque error string, and connect-refused alerts never reach the host GUI | [Bug][dsh] 熔断/连接失败时客户端只见常量 "acp-proxy failure":detail/upstreamFailure/alerts 全都没到用户眼前 #4254 已定的客户端契约的服务端半侧补齐到既定位置(handleAdminRoute),沿用既有 gate-first 模式。
  8. 是否引入了新的配置:不涉及——无新 env/config/默认值;errno code 是 additive 字段不是旋钮。([PR] fix: serve the missing /__bili/upstreams endpoint so the DSH upstream banner works #5147 另改了 scripts/check-unused-exports.mjs 给它的两个导出接口登记 waiver,那是构建期 lint 豁免,非运行时配置。)

合并判定:修复已完成并落在 PR #5147,代码审核通过(我的独立复现证明其设计成立且可测)。CI 在其 head 上运行中——static-gates / mysql-contract / pi-subagents-guard / test-import-graph / docs-coverage 已 success/skipped,test shards 进行中,暂无失败;全量绿是合并前最后一道门禁。待 CI 转绿后即可由你合并(mergeable_state 现为 behind,master 已前进;如需要我可把 master rebase 进 #5147 让 CI 重跑)。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

这轮 7 个 test 分片红不是本 PR 的代码问题,是继承性 master 红。已按 CI 协调政策把 origin/ci-fixes merge 进分支并推送,等 CI 重跑。

怎么判定的(拉了全部 7 个分片日志逐条核对,22 处 not-ok 全数清点):失败用例 100% 落在 master 1fad21de8 引入、ci-fixes@cf99d93 已修的那个家族——

  • ubu22-s2 / ubu24-s2 / win22-s1:claude-native 的 resolveNativeAttach{External,LanePriority,Policy,Url} ×4(preload 把 BILI_CONFIG_FILE 钉到不存在文件 → 影子掉所有 XDG-fixture 断言);
  • win22-s4 / ubu22-s3 / ubu24-s3:#3436 …mitm.domains + file-layer prepend ×2(mitm.domains 解析成 [] → 走 spawn 路径超时);
  • win22-s2:snapshotSessionsTree + leak-guard #5107 CLI-run ×4(Windows path.relative() 反斜杠不匹配 / 约定)。
    本 PR 自己的文件(admin.ts / upstream-alerts.ts / diagnostics.ts / 新增的 issue5146-upstreams-endpoint.test.ts / web-diagnostics-enrichment.test.ts)在失败列表里零出现。 上一轮 run 里 test 层是被 unused-exports 门挡在后面 skip 的,所以这是本 PR 测试套件第一次真正跑起来,撞上的正是当时还红的 master。

做了什么:merge origin/ci-fixes(cf99d93,含「删 BILI_CONFIG_FILE 钉」+「leak-guard relpath 归一化」+ e2e drain-wait 修复)。merge 干净无冲突;我上一轮加的 unused-exports waiver 保留完好;tests/preload-test-env.mjs 已确认变成 delete process.env.BILI_CONFIG_FILE。ci-fixes 侧哨兵已验证 49/49 check 全绿,同签名的一批兄弟 PR(#5144/#5143/#5126…)也都是这么自愈转绿的。master 本身因载体 PR #5133(ci-fixes→master)还没人工合并而仍红,所以这里只能代合 ci-fixes——rebase master 拿不到那两处修复。

八问:

  1. 是什么问题:7 个 test 分片红,但全是继承自 master 的 hermetic data-root 集群(Running the test suite locally writes test sessions into the production sessions directory. | 本地跑测试套件会把测试会话写进生产 sessions 目录 #5107/[PR] Running tests locally writes test sessions into the real ~/.local/billion-context — preload sandboxes the default direct | 本地跑测试会把测试会话写进真实的 ~/.local/billion-context——预载把默认目录沙箱化(Fixes #5114) #5115/[PR] fix: keep test suite off the production sessions dir (#5107) #5120)引入的测试基建缺陷,与本 PR 功能无关。
  2. 什么原因导致:①preload 钉死 BILI_CONFIG_FILE 影子掉 XDG-fixture(claude-native ×4 + native lanes suspected of not reusing instances: one proxy per process, instances only grow (v0.1.197 / opencode v2) | [Bug?] native 车道疑似不复用实例:一进程一代理,实例只增不减(v0.1.197 / opencode v2) #3436 spawn 超时);②Windows leak-guard 快照键用原生反斜杠路径。两者都已在 ci-fixes 修好、尚未合入 master。
  3. 影响范围与严重程度:仅 CI/本地测试面,生产零影响;对本 PR 表现为「挡合并」的假红,非功能缺陷。
  4. 怎么修复的:继承红走标准自愈——merge origin/ci-fixes 进 PR 分支(不自己去改那些测试基建,那是哨兵收敛面)。
  5. 是否有回归问题:无本 PR 自身回归。merge 带入的是哨兵已验证全绿的 test-infra + web client 微调,与本 PR 文件零交集、无冲突;最终判定以重跑的远程 CI 为准。
  6. 是否破坏缓存:不涉及。
  7. 是否改了设计方向:不涉及。
  8. 是否引入了新的配置:不涉及(没加 env/config/默认值;反而是删了一个测试用的 env 钉子)。

push:26f36a5b3..345aab38c @ 2026-10-29_5146-bili-upstreams-endpoint(merge commit)。判定:继承红已按政策处置,等 CI 重跑绿即可合入;若重跑仍红再升级。

ci-check and others added 11 commits October 30, 2026 10:03
…uires (#4599)

The #5140 recovery test proves forkSnapshot reconstructs a non-retained
parent's raw tail from the UNIFIED index — but it never pinned its own
storage mode. Under the CI storage baseline (preload-storage-baseline.mjs
sets BILI_STORAGE_UNIFIED=legacy for the broad corpus) no unified rows
exist, so the reconstruction has no source and forkSnapshot fails closed
with 409 SNAPSHOT_UNAVAILABLE. Deterministic, not a flake: reproduces 100%
on master and any merged branch with BILI_STORAGE_UNIFIED=legacy, passes
without it (default shadow). Pin full like the sibling persist tests and
restore the ambient value afterwards.
ci-fixes at 67f8e89 still leaves four Windows shards red, and all four
deltas already exist on PR #5178. This ports the missing hunks so the
convergence branch actually converges.

1. `test (windows-latest, 2x, 3)` — #5103. `UnifiedShadow` builds its db
   path as `${dir}/index.db`, so the open-failure warning reads
   `C:\...\sessions/index.db`. `issue5103` asserts the warning contains
   `path.join(dir, "index.db")` — `...\index.db` on win32 — so a mixed
   separator never matches. `path` is already imported at :30 and the db is
   opened through the same join, so POSIX output is byte-identical.

2. `test (windows-latest, 22, 4)` + the 4788 leg — #4739/#4788 teardown.
   The suites arm a real `SessionStorage` under
   `BILI_STORAGE_UNIFIED=full`, so the sidecar is still open at teardown.
   `cancelAll()` clears timers and the build map but never closes the
   shadow; Windows refuses to unlink a directory holding an open file
   (`EBUSY`/`EPERM` on `index.db`). Use `closeQuietly()` — cancel, then
   close — in the short-lived-store teardown.

3. `test (ubuntu-latest, 24, 3)` + `(windows-latest, 22, 2)` — #5155.
   Both cold-rebuild cases waited for the debounced durable flush with a
   fixed `setTimeout(20)`. A millisecond budget is a deadline a loaded
   runner can miss, and the miss is an honest `409 !== 200` from a
   one-turn-stale table. Await the settle itself: `afterNextFlush("conv-ptrs")` resolves once the armed save lands.

4. `test (ubuntu-latest, 22, 3)` — #4788 verdict deadlock.
   `afterNextFlush` parks a resolver in `flushWaiters`, and the only thing
   that drains it is the debounce timer — which is armed `unref?.()`.
   Once that timer is the last pending handle the loop drains, the promise
   never settles, and node reports
   `Promise resolution is still pending but the event loop has already
   resolved`. Keep the timer referenced exactly while a waiter exists
   (`ref()` on waiter registration; the host-upkeep default stays unref'd).

Both view hunks and the two test-teardown hunks are byte-identical to the
ones already on PR #5178, so this converges the branches instead of
inventing a third variant.

Verified locally: `npx tsc --noEmit` clean; issue4788 0/4 -> 4/4;
issue4739 4/4; issue5103 5/5; inc-canonical-pointers 3/3.

The `cancelAll` -> `closeQuietly` hunk has no local negative control:
reverting it keeps Linux green because `EBUSY`/`EPERM` only fire where an
open handle blocks unlink. That control can only run on a Windows lane —
stated rather than papered over.

The #4788 arm's own reader is confirmed instead: `cancelAll()` leaves
`index.db`, `index.db-shm`, `index.db-wal` in `/proc/self/fd` while
`closeQuietly()` leaves none (probed directly).
…e settle (#4599)

The turn() helper arms scheduleSave whose debounce timer is unref by design
(persist.ts: a pending save must not hold the process open at shutdown) and
then awaits afterNextFlush. Nothing else in that await is refd, so in a
node:test child whose only surviving handles are unref sockets the event
loop drains before the 50 ms debounce fires and the settle promise never
resolves: all four subtests fail with "Promise resolution is still pending
but the event loop has already resolved" / cancelledByParent. Reproduced
deterministically on master 44067a5 AND on pre-merge ci-fixes 67f8e89
(standalone run, exact CI preload chain), while the same file has passed
some CI legs by ambient-liveness luck - a born-flake per section 7.2
(no environmental luck). The pin at 67f8e89 does not touch this path.

Fix: arm a refd 25 ms keep-alive interval around the afterNextFlush await
(cleared in finally) so the debounce fires deterministically on every host.
Test-only diff; production settle semantics untouched.
…ts ref-tracking fix (#4599)

PR #5262 fixes #4788 at the source: scheduleSave now leaves the debounce
timer refd while flush waiters exist (and afterNextFlush refs a pending
unrefd timer when a waiter registers), so the settle is deterministic for
EVERY caller on every host. The 25 ms keep-alive interval added in
a3019b0 only patched this one test file and is redundant now; removing it
leaves one mechanism instead of two. The comment stays: without it a future
reader re-adds the interval or deletes the persist.ts tracking as dead weight.
@ranxianglei
ranxianglei merged commit 1876186 into master Oct 31, 2026
51 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.966-master.1876186 (rolling master tag).

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

bug Something isn't working dsh p2 scope/wiring

Projects

None yet

2 participants