Skip to content

[PR] fix: require package identity for the high-cost plugin advisory, not just the loader id - #7082

Open
ranxianglei wants to merge 1 commit into
masterfrom
2026-11-18_fix-cost-advisory-id-collision
Open

ranxianglei wants to merge 1 commit into
masterfrom
2026-11-18_fix-cost-advisory-id-collision

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

来源: #7068 分析高成本插件告警误报时发现(第二次误报;第一次 #3838 已由 #3840 修复 disabled 维度)

问题

高成本插件告警(dsh auto-review)只比对 cordis.patch.yml 的 patch 条目 id(auto-review),从不比对条目实际加载的包。社区插件 PerryLink/dsh-auto-review(- id: auto-review + name: dsh-auto-review)被认成官方 @deepseek-ai/dsh-experimental-auto-review,触发永久横幅——而官方插件根本没装(#7068 报告者已验证 global prefix + 各 profile 的 node_modules)。

修法(issue 方案 C)

条目 name: 行就是 dsh 为该 loader id 加载的包,因此 id 命中后必须再确认包身份:

  1. name 存在 → 必须指向官方包(全名或去 scope 尾名);写了别的名字就是判决,不再兜底;
  2. name 缺失(早于 name 约定的老条目)→ 回退磁盘检查:官方包须装在某 profile 的 node_modules 里(与 src/notices.ts probeDshIotThinking 同一探测形状,不 spawn npm)。

parseDshPatchEntries 顺带捕获每个条目块内首个缩进 name:(去引号;列 0 与嵌套列表项之后的行不归属该条目),DshPatchEntry 增加可选 name 字段——没有 name 行的文本解析结果与之前逐字节一致(既有 strict deepEqual 测试不动、保持绿)。

⚠️ 行为变更(有意)

  • 旧:enabled 条目 id 命中即告警(不看包)。
  • 新:id 命中 + 包身份确认(name 匹配,或无 name 时磁盘存在)才告警。
  • 受影响面:无 name 行、且官方包未装在任何 profile bundle 的 enabled 条目不再告警——这正是本 issue 的误报类。有 name 行的条目:name 匹配照告,name 不匹配不告(新增的防误报维度)。

测试

顺提(不在本 PR 内,需决策)

Closes #7068

@ranxianglei ranxianglei added bug Something isn't working dsh p2 scope/wiring labels Nov 17, 2026
@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-11-18_fix-cost-advisory-id-collision (c46291a)

Latest build — install this exact version

npm install -g billion-context@0.0.10667-pr.7082.f2d1433

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
c46291a billion-context@0.0.10667-pr.7082.f2d1433 build
d873940 billion-context@0.0.10664-pr.7082.8a5d8e4 build

Download artifact

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

Install instructions are refreshed on each push.

@ranxianglei ranxianglei changed the title fix: require package identity for the high-cost plugin advisory, not just the loader id [PR] fix: require package identity for the high-cost plugin advisory, not just the loader id Nov 17, 2026
…just the loader id

The dsh cost-advisory gate fired on the cordis.patch.yml patch-entry id alone
(`auto-review`). A community plugin (PerryLink/dsh-auto-review) that reuses
that loader id but loads a different package was misidentified as the official
@deepseek-ai/dsh-experimental-auto-review and flagged high-cost — the second
false positive of this advisory (#7068; the first, disabled entries, was
#3838).

The entry's `name:` line is the package dsh actually loads for that id, so
the advisory now requires the id match to be confirmed by package identity:
- name present: it must name the official package (full, or unscoped tail);
  a present-but-different name is a verdict — no advisory;
- name absent (entries predating the name convention): fall back to the
  official package being installed in a profile bundle (same on-disk probe
  shape as probeDshIotThinking in src/notices.ts).

parseDshPatchEntries now captures the first indented `name:` of each entry
block (quotes stripped; column-0 and post-list-item lines ignored) and
DshPatchEntry gains an optional `name` field — entries without a name line
parse exactly as before, keeping the existing strict deepEqual tests green.

Behavior change: a nameless enabled entry that does NOT have the official
package installed in any profile bundle no longer fires the advisory (it
fired before). That class is exactly the false-positive class this fixes.

Closes #7068
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷
(ai: vllm-qwen/qwen3.8-27b)

查重: 不重复 — 镜像 open+closed 检索「cost advisory / auto-review / 误报」: 本 PR 是该线程唯一在途 PR(无并列第二 PR)。相关条目: #3838(第一次误报,disabled: true 维度,#3840 已修)、#2462(告警功能来源)、#7080/#7081(本 PR 顺提的两个独立症状,已核实存在且症状/机制各自独立,拆分合规)。

标签: PR 已带 bug + p2 + dsh + scope/wiring(按本 PR 自身 diff 判定,满足最低档);源 issue #7068 已带 bug + p2 + dsh + scope/wiring + scope/docs。无需补。

状态核实(实时): PR head 已 rebase 到当前 master(c46291a21f,base = a259e0b8fa = origin/master);rebase 前后 diff 逐字节一致(已比对)。CI 在新 head 上:static-gates 绿、gate 绿、test 矩阵 11 分片在跑、0 失败。本地独立复验:定向两文件 30/30 绿、typecheck 绿、build 绿。


审核结论(独立重审,非复读 issue)

① 方向关: 修的是根因不是症状。判定链「条目存在且未 disabled → id 是 auto-review → 就是官方高成本插件」缺了「这个条目实际加载哪个包」这一步——loader id 是本地别名,不是包身份;name: 行才是 dsh 为该 id 实际加载的包(证据: dsh.bundle.patch.yml 自身注释「the loader resolves name from the profile's node_modules」+ #7068 报告者机器上社区条目 name: dsh-auto-review 与实装包一致)。修在判定决策点(detectCostAdvisories),不是中途过滤,是疏不是堵。实现忠实于 issue 方案 C(name 快判 + 无 name 时磁盘兜底);issue 里标「推荐」的是 A,但 C 被描述为「最稳」,且 C 在「社区条目启用 + 官方包恰好装了但没启用」这个关键误报场景上严格优于 A(A 会误报、C 不报)——选 C 成立,PR 正文已披露,owner 合入时可最终确认。

② 回归关(逐条清点既有行为):

  • parseDshPatchEntries(src/dsh-channel.ts:74,共享解析器): 无 name 行的文本,解析对象与之前逐属性一致(name 属性从不被设置,不是设为 undefined),既有 strict deepEqual 测试未动、绿;另一消费方 host-plugin-notice.ts:109 的 patchDisabled 只读 .id/.disabled,行为不变。
  • 循环重构(if (current && disabledRe.test(line)) → if (!current) continue; + 独立判断)语义等价。
  • detectCostAdvisories: disabled 过滤、缺文件不抛、5 分钟 TTL 缓存(env-keyed)、多 profile 去重、CostAdvisory 载荷形状全部不变;唯一变化是命中条件——即 PR 正文已披露的有意行为变更。
  • 消费方 admin.ts:1320/:1378 的 status/overview 载荷与 web 横幅渲染形状不变。
  • 高危模式逐项: 无语义漂移(变更即修复本身)、无 fail-fast 变吞错(新增 fs 全部 guarded,符合模块 never-throw 契约)、无阈值/时序/输出格式漂移。
  • 已知边界(非本 PR 引入): 行式解析器不认 YAML 层级——条目块内嵌套 config: 子块下的 name:/disabled: 也会归属该条目(首个生效)。与既有 disabled 语义一致,且要求 config 键恰好叫 name 且值撞上官方包名,概率可忽略。
  • 诚实边界: 官方条目若写子路径 name(如 @deepseek-ai/.../dist/index.js)不匹配且无磁盘兜底 → 不告警。issue 方案 B 本身也不处理子路径;现有证据显示 dsh plugin-manager 写裸包名。

③ 代码关: 命名达意(patchEntryLoadsPackage/dshPackageInstalled/dshEnabledPatchEntries);dshPackageInstalled 与 notices.ts:99 probeDshIotThinking 同探测形状(不 spawn npm,scoped 包路径拼接正确);patchEntryLoadsPackage 的 unscoped 尾名匹配对无 scope 包安全(slash=-1 时不匹配)。一处 2 行引号剥离逻辑在 id/name 两处重复——按 ⑤b 标准「≥2 处考虑抽公共」,判定可接受(同函数内、id 处为既有代码,为它动 id 路径不值得),不拦。

④ 测试关: 5 个新 advisory 测试全是真测试、断言有牙——#7068 复现(社区 name→不告)、name 判决(不同 name + 官方包在盘→不告,钉死「不兜底」)、磁盘兜底双向(在盘→告/不在盘→不告)、unscoped 匹配;4 个新 parser 测试钉死块作用域/引号剥离/列 0 不归属/首个生效/嵌套列表项后不泄漏。writeProfilePatch 助手为 auto-review id 补真实形态 name 行,既有测试随之建模真实形状。双向 gate 纪律(#3617)满足: 告/不告方向都有钉。回归可兜底: 若有人回退成只看 id,「社区 name→不告」测试立刻红。

⑤ diff 整洁度: 4 文件 183+/27-,单 commit,每行都与本 PR 目的相关;无跑题文件、无空行/重排噪音、无 lockfile 变动。干净。

八问

  1. 是什么问题: 高成本插件告警只比对 patch 条目的 loader id,不比对条目实际加载的包;社区插件 PerryLink/dsh-auto-review 恰好 id 也叫 auto-review,被认成官方 @deepseek-ai/dsh-experimental-auto-review,官方包根本没装也触发永久横幅(该告警的第二次误报,第一次是 [bug] False positive in high-cost plugin alert: entries with disabled:true still trigger continuous warnings (dshEnabled | [bug] 高成本插件告警误报:条目 disabled:true 仍持续警示(dshEnabledPatchIds 不读 disabled 字段) #3838 的 disabled 维度)。
  2. 什么原因导致的: 包身份判定只依赖一个弱信号——loader id 是本地别名不是包身份;真正的包身份是条目的 name: 行(dsh 为该 id 实际加载的包)。检测链中间缺了「这个条目加载的到底是哪个包」这一步;[bug] False positive in high-cost plugin alert: entries with disabled:true still trigger continuous warnings (dshEnabled | [bug] 高成本插件告警误报:条目 disabled:true 仍持续警示(dshEnabledPatchIds 不读 disabled 字段) #3838 修掉 disabled 口子后,id 撞名口子一直敞着。
  3. 影响范围与严重程度: 只影响 dsh profile 的 cordis.patch.yml 里有 enabled auto-review 条目的用户;其中装社区插件(id 撞名)的用户看到永久误报横幅 + 错误的成本描述,装官方插件的用户不受影响。p2: 能用但体验有明确问题(横幅常驻且当时无关闭途径,内容误报)。
  4. 怎么修复的: id + 包身份双校验(issue 方案 C): id 命中后,条目有 name 则必须指向官方包(全名或去 scope 尾名),写了别的名字就是判决、不再兜底;条目无 name(早于 name 约定的老格式)则回退磁盘检查——官方包须装在某 profile 的 node_modules 里(与 probeDshIotThinking 同探测形状)。解析器顺带捕获每个条目块内首个缩进 name:(去引号、首个生效、列 0 与嵌套列表项之后的行不归属)。
  5. 是否有回归问题: 无。审过的既有行为: 解析器对无 name 文本输出不变(既有测试不动且绿)、host-plugin-notice 消费方行为不变、disabled 过滤/缺文件不抛/TTL 缓存/多 profile 去重/载荷形状全部保持;唯一变化是命中条件,即 PR 正文已披露的有意行为变更(旧: id 命中即告;新: id 命中 + 包身份确认才告;受影响面 = 无 name 行且官方包未装在任何 profile bundle 的 enabled 条目不再告——正是本 issue 的误报类)。
  6. 是否破坏缓存: 不涉及 prompt/压缩缓存;模块自身 5 分钟扫描 TTL 缓存机制不变,磁盘检查在缓存计算内。
  7. 是否改了设计方向: 没有。检测架构(patch 层扫描 + 共享解析器 + TTL 缓存 + admin 载荷)不变,只在命中条件上补了包身份维度。
  8. 是否引入了新的配置: 没有。无新 env/config/CLI/默认值。

判定: 可合(等 CI test 矩阵全绿后)。顺提的 #7080(横幅无关闭按钮)、#7081(链接钉死已关闭的 #2462)已核实存在、拆分合规,不在本 PR 范围内,由各自 issue 后续安排。

This branch has not been deployed

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

Labels

Projects

None yet

1 participant