Skip to content

fix: pin dsh mcp_catalog durable-state carrier (#2446) - #2547

Merged
ranxianglei merged 1 commit into
masterfrom
2026-10-09_dsh-mcp-catalog-guard
Oct 9, 2026
Merged

ranxianglei merged 1 commit into
masterfrom
2026-10-09_dsh-mcp-catalog-guard

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

What

Fourth dsh durable-state carrier: the MCP server catalog injected by the third-party plugin dsh-skill-mcp-manager — a system-reminder-wrapped <mcp_catalog> block (~5K tokens, 11 servers + tool-schema digests in the #2446 report). The plugin re-emits it only when the visible MCP/skill set changes, so one fold silently kills the session's server inventory forever; the report's failure mode is the model hunting for MCP servers by wrong names mid-session. Reporter verified via decompress that the originals were intact — the loss happens at fold time, exactly the #2419/#2447/#2481 mechanism family.

Fix

Extend the dsh lane entry in src/durable-message-guards.ts with dshMcpCatalogGuard (text.includes on the <mcp_catalog> marker, matched on its own rather than on the wrapper — same rationale as #2419). No kernel change: the generic Config.isMessageProtected hook (kernel 0.0.108, merged via #2428) already covers any content type; the POLICY (which shapes, which lane) lives host-side by design.

First guard entry whose emitter is the dsh plugin ecosystem rather than dsh core. Same KDD #9 evidence bar as the previous three: marker shape from the #2446 report, stability owned by the plugin's author — who filed the report.

Scope note (deliberately NOT in this PR)

The reporter runs proxy mode (no x-bili-plugin lane), where the lane-keyed registry structurally cannot fire — even the three merged guards don't cover him. That gap needs an owner decision on the escape hatch (user-facing compress.protectedContentMarkers vs a self-declared <bili-durable> injector opt-in marker); both proposals are laid out in the #2446 triage comment for the owner. This PR fixes the plugin-lane half only and does not close the issue.

Tests

tests/issue2446-dsh-mcp-catalog.test.ts (4 tests, pattern of #2481's suite): guard unit matrix (wrapper + bare marker match; lowercase prose / the #2419 skill-catalog carrier / non-text / undefined text stay foldable; lane entry covers all four carrier shapes; registry stays dsh-only) · dsh-lane fold survival through a real /__bili/plugin/tool compress whose range positionally covers the catalog · unregistered lane folds it away (pins lane scoping) · BLOCKED ref stamped at assignment time.

Regression family: issue2419 + issue2447 + issue2481 suites 12/12 green; npm run typecheck clean.

§7.4 self-check

Not auto-merge eligible (message-protection policy, same review tier as #2428): single-module change, regression tests present, clean diff, refs #2446 without auto-close (proxy-mode half remains owner-gated).

dsh-skill-mcp-manager (third-party dsh plugin) injects the MCP server
inventory as a durable user-role message (system-reminder wrapper around
a mcp_catalog block, ~5K tokens in the report) and re-emits it only when
the visible MCP/skill set changes — one fold silently kills the session's
server inventory forever. Fourth dsh durable carrier, first whose emitter
is the dsh plugin ecosystem rather than dsh core; same evidence bar as
#2419/#2447/#2481 (shape + stability from the #2446 report, authored by
the plugin's own author). Lane-scoped via the existing KDD #9
evidence-permitlist registry.
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-09_dsh-mcp-catalog-guard (5bd4af4)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.2727-pr.2547.f7a11f9

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-pr2547.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 #2547(#2446 plugin-lane 半区:dsh mcp_catalog durable-state carrier)。已读完 #2446 全链分拣(floor 8),方向明确:只动 host 侧 src/durable-message-guards.ts dsh 泳道条目,不动 kernel。正在拉分支核对代码、跑定向测试与回归族,结论按结构化八问给出。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 Review 完成。已拉分支核对代码、本地跑定向测试、逐格查 CI。结论:可合(human merge;CI 唯一红格与本 diff 无关,属既有 flake,已立项跟踪)。

结构化八问

1. 是什么问题:dsh-skill-mcp-manager 插件注入的 MCP 服务器目录(<mcp_catalog> 块,~5K tokens)作为普通 user 消息进历史,一次折叠即静默丢失;插件只在可见 MCP/skill 集合变化时重发 ⇒ 丢失是永久性的,会话中段模型按错误名字找 server(#2446 报告的失败模式)。

2. 什么原因导致的:宿主把全会话基础设施当一次性 user 消息注入,ACP 压缩把每条历史当可折叠材料,且重注入有指纹门控——折叠与重发机制结构性冲突。与 #2419/#2447/#2481 同族(第四个载体,首个发射方为 dsh 插件生态而非核心)。本 PR 修在决策点:kernel isMessageProtected 钩子(#2428 已合)+ host 侧泳道策略条目,非症状层打补丁。✔ 方向与 #2446 floor 8 分拣完全一致。

3. 影响范围与严重程度:仅 dsh plugin lane(x-bili-plugin: dsh)会话。修复前,任何一次位置覆盖该目录的折叠都会造成静默退化(模型不自报),命中即整段会话工具选择受损——特定条件下严重。proxy 模式用户(报告人自身配置)仍不覆盖——PR 明确声明不在范围内,逃生门两方案待你在 #2446 floor 8 拍板,本 PR 不关 issue,纪律正确。

4. 怎么修复的:dsh 泳道注册表 OR 入第四谓词 dshMcpCatalogGuard——仅 text 内容类型、精确匹配 <mcp_catalog> 标记本身(源文件内 hex 转义,符合 KDD #2),marker-over-wrapper 理由同 #2419(wrapper 改词不能拆掉守卫);误报良性(命中的消息只是保持可见)。无 kernel 改动、无配置面改动。证据标准同前三条(KDD #9):形状来自 #2446 报告,稳定性由插件作者(即报告人)持有——因插件闭源,证据弱于前三条的源码引用,doc comment 已如实声明,与你分拣时的接受一致。

5. 是否有回归问题:审过的既有行为逐项结论——

  • 前三条 dsh 载体(skill catalog / workspace instructions / runtime context):不变,OR 语义互不干扰,回归族套件本地 12/12 绿;
  • 其他泳道:不变,注册表键仍恰为 ["dsh"](新单测 deepEqual 钉死,KDD release v0.1.2 #9 allowlist 纪律);
  • dsh 内非匹配消息:可折叠性不变(小写 prose、相邻载体、非 text 类型均有负例钉住);
  • proxy 模式:结构性不受影响(lane-keyed,无 lane 不触发);
  • wire 形态 / 配置 schema / 持久化格式 / kernel / update.ts / 安全面:未触碰(diff 仅 2 文件,+278/-2,每行都与目的相关,diff 干净);
  • 高危模式(语义漂移、fail-fast 变吞错、阈值/时序/输出格式变化):逐项过,无。
    结论:无回归。

6. 是否破坏缓存:不。受护消息原地常驻(anchor 不动、永不折),比折掉更利于前缀缓存(零字节漂移,#2446 分析已确认);未触碰任何失效/重试/去重策略。

7. 是否改了设计方向:没有。沿用既定机制(kernel 泛化钩子 + host 侧 per-lane 策略表),只加第四个条目。

8. 是否引入了新的配置:无。无新 env/config/默认值。

CI 状态与 flake 定性

矩阵 23 格绿,唯一红:test (ubuntu-latest, 24)。拉了完整 job log:唯一失败测试是 tests/zcode-native.test.ts:222「bootstrapZcodeNative fails closed on an unhealthy attach target」(Missing expected rejection,expected /not healthy/)——zcode attach 健康探测路径,本 PR diff 完全不触碰。定性为既有端口竞态 flake:

  • deadOrigin()(tests/zcode-native.test.ts:54-61)listen(0)→close→返回 origin,假设释放的临时端口保持死亡;并行 npm test 负载下该端口被其他进程在 300ms 健康窗口内抢占,probeProxyHealth 接受任何 live 2xx ⇒ "死亡"目标回答了 healthy;
  • 证据链:base commit(4b56664)数分钟前同一 ubuntu-24 格全绿;同 commit 其余三格(ubuntu-22/windows-22/24)全绿;本地 Node 22 跑该套件 34/34 通过(含失败那条);
  • 该隐患仓内已有命名:testss/port-race.ts(flaky CI: freed-port tests race on port reuse (log-mask #255 tunnel test got HTTP 200 instead of 502) #1689)头注释明写此竞态,log-mask.test.ts:393 已用 assertPortDead 守护其实例;但 zcode-native 的 3 个调用点和 upstream-alerts 的 2 个调用点未守护。

处置:已立项 #2548(带来源标记,含受影响位置清单与两层修法建议:确定性方案=保持 live unhealthy 服务器占位不再释放端口;过渡=5 处调用点包 assertPortDead)。建议:重跑失败的 ubuntu-24 job 或直接合并(flake 定性如上,不影响本 PR 判定)。

测试有效性(质量关)

新套件 4/4,断言有牙:①守卫单测矩阵含负例(小写 prose / #2419 相邻载体 / 非 text / undefined text 均可折)且钉死注册表 dsh-only;②真 /__bili/plugin/tool compress,range 位置覆盖目录,断言折叠确实发生(前缀 filler A1-/F5- 消失)的同时目录整体存活——不是"保护否决整个 range"的空过;③未注册泳道折掉目录,钉死 lane scoping;④BLOCKED ref 在赋号时刻盖戳。回归族 12/12 复验通过。npm run typecheck 本地 clean。§7.4 自报不可 auto-merge(消息保护策略,human tier)——同意,维持 human merge。

判定:可合。 合并后请留意 #2446 proxy-mode 半区的拍板(方案 A/B 在 floor 8),那是本 PR 刻意留下的另一半。

@ranxianglei
ranxianglei merged commit 055caad into master Oct 9, 2026
35 of 36 checks passed
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.196-master.055caad (rolling master tag).

npm install -g billion-context@0.0.196-master.055caad  # 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.

thlinhit pushed a commit to thlinhit/billion-context that referenced this pull request Oct 9, 2026
…nxianglei#2548)

zcode-native's deadOrigin() released its listen(0)+close port and assumed it stayed
dead; under parallel 'npm test' another process could rebind it inside the 300ms
health window, so probeProxyHealth saw a live answer and the expected refusal
flipped to an active attach (the ranxianglei#2547 CI flake). Replace it with a live server
bound for the whole test that answers 500 - probeProxyHealth judges a 500 answer
unhealthy - so the unhealthy expectation is constructed, not assumed: the race is
closed rather than narrowed.

upstream-alerts' freePort() feeds a connect-refused assertion, which cannot be
constructed with a live server (hang = connect-timeout, 500 = a real response);
guard its real consumer with assertPortDead right before the first dial, matching
log-mask (ranxianglei#1689). The banner site never dials the port (/__bili/overview reads
fs/in-memory state only), so it is left unchanged - adding a guard there would
introduce a new flake.

Closes ranxianglei#2548
@ranxianglei
ranxianglei deleted the 2026-10-09_dsh-mcp-catalog-guard branch October 15, 2026 05:33
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