Skip to content

[PR] fix(dsh): replace the fail-closed preset gate with a post-load reconcile (#7111) - #7117

Open
resec wants to merge 6 commits into
ranxianglei:masterfrom
resec:2026-11-18_dsh-gate-fail-open
Open

resec wants to merge 6 commits into
ranxianglei:masterfrom
resec:2026-11-18_dsh-gate-fail-open

Conversation

@resec

@resec resec commented Nov 18, 2026 •

Copy link
Copy Markdown

Draft: this replaces a mechanism the owner designed (#3354 / #3662), so it is opened for direction before it is treated as mergeable.

Fixes #7111. Fixes #6456. Root-cause correction: #6470 is a runtime no-op on top of it (see the measurements on both).

The defect

dsh.bundle.patch.yml gated the four Web presets on the gate service:

- id: preset-standard
  inject: [biliBasicCompactionPolicy]

cordis entry-level inject is fail-closed: no optional form, no timeout, no fallback. Any missing provider therefore leaves the preset's fiber unconstructed — permanently. Measured on a real host (dsh 0.2.2-rc.4, bili at master, one overlay row - id: bili-compaction-gate / disabled: true):

dsh: warning: 4 entries did not activate
preset-standard (@deepseek-ai/dsh-agent-preset): pending (waiting for service: biliBasicCompactionPolicy)
preset-ptc      … pending
preset-minimal  … pending
preset-cordis   … pending
dsh web: http://127.0.0.1:<port>/?token=<redacted>
ctx.agentPresets.resolve('standard')  ->  agent-preset/not-found: Unknown agent preset: standard

The host does not error, boots, and serves its UI; session creation is what fails. That is why the symptom was easy to attribute elsewhere.

Triggers are ordinary operations: the gate subpath failing to resolve, a user toggling that row off in the plugin page (it is an addressable bundle row), or an interrupted install.

The fix

The presets are no longer gated. The always-on gate entry reconciles the ones mounted before it activated:

  • reconcileLoadedPresets(entries) — for each entry whose resolved config nests compaction-basic/command-compact, re-submit the config via entry.update(). That re-runs internal/config, so the existing overlay rewrites the rows exactly as on a cold resolve. Entries without such rows, and hosts whose entries expose no update, are untouched; a throwing entry never takes the gate down.
  • The loader is reached through ctx.inject(['loader'], …) — a child fiber, not a hard dependency. A hard dependency would reintroduce this very failure.
  • Both carriers drop the four rows (dsh.bundle.patch.yml and writeDshAcpPatch); compactionDisablePatchRows() is gone.
  • docs/clients.md + docs/clients.zh-CN.md describe the new behaviour instead of the latch.

Trade-off made explicit: losing the gate service now costs the overlay (native compaction stays stock, with the wire-level refusal #1729 as backstop) instead of the session. This follows the availability boundary #3662 already accepted.

Verified on a real host

scenario before after
gate row disabled (the bricking trigger) 4 × pending, resolve throws agent-preset/not-found resolve → {"id":"standard"}, roster standard/ptc/minimal/cordis, 0 pending, 0 "did not activate"
gate normal presets carry disabled rows unchanged — all four presets still show compaction-basic and command-compact disabled: true

Tests

tests/issue7111-gate-fail-open.test.ts: neither carrier gates the presets (with the gate entry still mounted); a mounted preset is re-submitted with its nested row disabled and the input config left untouched; entries without rows / without update / non-objects are skipped; the gate reconciles through the optional loader, still publishes the service before any loader arrives, and survives a missing loader.

issue3354 / issue3662 are updated to pin the new contract (gate entry mounted, presets not gated) instead of the retired rows.

check result
npm run typecheck clean
targeted node --import tsx --test (7111 + 3354 + 3662) 18/18 pass
npm run build success
node tools/check-architecture-docs.mjs all green

Known gap (deliberate, for the owner to decide)

With the gate absent the degradation is now quiet: sessions work, native compaction is stock, and nothing on the bili side says so (detectCompactionOverlayGap() lives inside the gate entry, which by definition did not run). #7111 offered option B — a loud boot alarm for "no gate service provider". Say the word and I will fold it in as a follow-up commit on this branch; I left it out to keep this diff to one mechanism.

Overlaps

…ile (ranxianglei#7111)

cordis entry-level inject has no optional form, no timeout and no fallback, so gating the four Web presets on biliBasicCompactionPolicy meant any missing gate service left them pending forever: session creation failed with agent-presets/not-found while the host kept booting and serving its UI. Measured on dsh 0.2.2-rc.4: with the gate row disabled, resolve('standard') throws and four entries report pending.

The presets are no longer gated. The always-on gate entry reconciles the presets mounted before it activated (entry.update re-runs internal/config, so the overlay rewrites them exactly as on a cold resolve) and the loader is awaited in a child fiber, never injected hard. Losing the gate service now costs the overlay (stock compaction, wire guard ranxianglei#1729 as backstop), not the session.

Verified on a real host: gate disabled => resolve ok + zero pending; gate enabled => all four presets still carry disabled compaction-basic/command-compact rows.
@ranxianglei ranxianglei changed the title fix(dsh): replace the fail-closed preset gate with a post-load reconcile (#7111) [PR] fix(dsh): replace the fail-closed preset gate with a post-load reconcile (#7111) Nov 18, 2026
… gate)

Both types are referenced only inside their own module; the repo's unused-exports gate rejects exports with no external consumer.
@resec

resec commented Nov 18, 2026 •

Copy link
Copy Markdown
Author

CI 修复(23d42c38):ReconcileEntry 与 LoaderFace 只在本模块内使用 → 去掉 export。

本地:typecheck ✅ / 18 用例 ✅ / build ✅ / unused-exports ✅ / architecture-docs ✅。

…#7111)

ranxianglei#7111 made the four Web presets fail-open, so disabling the
bili-compaction-gate entry no longer re-creates the pending-latch brick.
The real consequence is that native compaction stays ARMED while bili owns
the lane (no overlay to stand it down), which risks destroying the
compression substrate — the ranxianglei#1729 wire-level refusal is only the backstop.
Update the 'Disabling vs removing' section in both docs to say that instead
of the now-stale 're-creates the brick' claim.
…glei#7111)

reconcileLoadedPresets disabled the web presets' compaction rows
unconditionally, while the overlay it complements honors the process
verdict (isDshCompactionActive). With bili-native disabled (verdict
absent) the ranxianglei#3662 contract requires the presets to fall back to STOCK
dsh compaction; as written the reconcile would stand down native
compaction anyway, leaving the user with no compaction at all.

Skip the reconcile when the verdict is absent, exactly like the
overlay. Adds the negative test (verdict absent -> 0 touched, update
never called) and declares the verdict in the entry-filtering test so
it keeps testing what it claims to.
@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

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

🔶 需要决策

  • 背景: 核心 fail-open 修复方向正确、可合并;PR 正文自述一个「已知缺口」——gate 条目缺失(未挂载/被禁用)时,降级(预设可用但 native 压缩仍 armed)是静默的,bili 侧无信号(detectCompactionOverlayGap 在 gate 条目内部)。
  • 待决问题: 原 issue 的 option B(启动时大声告警)是现在折进本 PR,还是单独立项跟进?
  • 选项:
  • 推荐: B。核心修复恢复可用性(解决 p1 砖死);告警是安全增强,落点需要一点设计讨论,不应阻塞核心修复。
  • 不决定的默认行为: PR 保持 draft;核心修复已就绪(CI 绿 + undraft 即可合)。我不会自行合并(合并仅人工)。

查重

不重复。相关行:#7112(internal/config 监听器读 this)、#7113(后续 patch 行重新 arm compaction-basic.auto:false)、#6470(owner PR,实测运行时 no-op)、#7115/#7116 触碰 dsh-compaction-gate.ts(不同关注点,作者会 rebase)。本 PR 是 #7114 方案 A(fail-open)的实现,与上述均不同机制。

审核结论(八问)

  1. 是什么问题: 4 个 dsh Web 预设(preset-standard 等)经 entry 级 inject 硬依赖 biliBasicCompactionPolicy 服务。cordis 无可选依赖/超时/回退,只要 gate 服务缺失,4 个预设永久 pending(建会话时 agent-presets/not-found),而宿主照常启动并服务 UI——建会话被砖死。
  2. 什么原因导致的: 根因 = fail-closed 硬依赖:预设通过 inject 硬依赖一个由独立条目提供的服务,无回退。修复去掉硬依赖(fail-open):预设不再 gate 在服务上,改为常驻 gate 条目在加载后 reconcile(重提交)已挂载的预设、禁用其压缩行。
  3. 影响范围与严重程度: 任何「gate 条目未挂载/被禁用」的 dsh profile(打包了 billion-context)。原 bug:p1(建会话不可用)。修复后:预设可用;残留风险是 reconcile 未跑时 native 压缩可能仍 armed(受 nudge 死锁无检测:同一 session 交替收到两种结构互斥的请求流(巨型单消息 ↔ 多轮)时不告警 #1729 线级拒绝兜底)。
  4. 怎么修复的: 从两个载体(dsh.bundle.patch.yml + launcher 的 writeDshAcpPatch)删掉 inject: [biliBasicCompactionPolicy] gate 行;新增 reconcileLoadedPresets()——对每个已挂载、嵌套压缩行且暴露 update() 的预设条目,经既有 internal/config overlay 重提交禁用压缩行的 config;gate 条目经可选 loader inject(软依赖,非硬依赖)调用它。
  5. 是否有回归问题: 审了既有行为,发现并修掉本 PR 自己引入的一处回归:reconcileLoadedPresets 无条件禁用压缩行,违反 [dsh] Disabling the plugin permanently bricks dsh session creation - the bundle patch inject gate has no fallback (0.1.199 / dsh 0.2.1-rc.2) #3662 契约(禁用 bili-native 必须让预设回退到 STOCK dsh 压缩)——那样用户会完全没有压缩。已在 69d4309173 修掉(reconcile 尊重 verdict,verdict 缺失时跳过)+ 补负向测试。另修掉过时文档(18be13284c):原文说「禁用 gate 条目会重新造成砖」,fail-open 后已不成立。其余既有行为(服务提供、overlay 注册、verdict 处理)保持;无阈值/时序/输出格式漂移。
  6. 是否破坏缓存: 不涉及。这是 dsh 插件车道的 config/patch 变更,不触碰压缩/缓存路径;无 cache/重试/增量游标/去重键被影响。
  7. 是否改了设计方向: 是,有意为之——从 fail-closed(预设等 gate 服务)改为 fail-open(预设总是挂载,gate 条目加载后 reconcile)。这正是原 issue 推荐的方案 A。[dsh] Disabling the plugin permanently bricks dsh session creation - the bundle patch inject gate has no fallback (0.1.199 / dsh 0.2.1-rc.2) #3662 的拆分(overlay 在独立常驻条目)被保留并扩展。
  8. 是否引入了新的配置: 无新 config key/env。BILI_COMPACTION_DISABLE_SERVICE 常量保留作 presence marker(服务仍提供,只是不再作 gate)。无需迁移。

我在 PR 分支上补的 commit(对齐重构,非替换;作者 commit 与署名保留)

本地验证

CI

镜像缓存:30 checks,0 failed,18 success,11 skipped,1 pending(新 commit 69d4309173 刚推、在跑)。全量判定以远程 CI 为准。

标签

镜像 label API 在本环境未实现(ework shim 返回 endpoint not implemented),tools/add-label.sh 不存在,无法按规则打标;意图标签:bug / dsh / scope/wiring / p1。

合并判定

核心 fail-open 修复方向正确、代码与测试质量达标;我补的两处(文档 + verdict 回归)已修并推送。待:① owner 对「告警现在折进 vs 立项跟进」拍板(推荐 B);② CI 全绿;③ undraft。满足即可合(合并仅人工)。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

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

更正上一条的一处置错号:查重段「本 PR 是 #7114 方案 A 的实现」应为 #7111(GitHub 主 issue「preset gate latch is fail-closed」)。#7114 在 GitHub 上是另一个无关的 dsh_session_log drive-by issue,我误把它当成了主 issue 的镜像号。其余引用(#7112 / #7113 / #6470 / #7115 / #7116 / #7111 / #7117)已逐一对照 GitHub 标题核实无误。

@resec

resec commented Nov 18, 2026

Copy link
Copy Markdown
Author

69d43091 让核心修复在真机上变成 no-op:reconcile 只跑一次,且跑在 verdict 声明之前

基线:bili 69d43091(本 PR head)+ dsh 0.2.2-rc.4 + node 26.10.0,web profile,billion-context 以 link 方式挂入。

观测

同一套进程内探针,只换构建:

构建 四个 preset 的 8 个压缩行 reconcile 内部
23d42c38(父提交) 8/8 disabled: true touched: 4
69d43091(本 head) 0/8,34 秒内一直保持 stock touched: 0

69d43091 上的采样(每 3/8/15/22/28/34 秒一次,verdict 全程 active):

t=  3000 verdict=active disabled=0/8
t=  8000 verdict=active disabled=0/8
t= 15000 verdict=active disabled=0/8
t= 22000 verdict=active disabled=0/8
t= 34000 verdict=active disabled=0/8

原因

在真进程里读 reconcileLoadedPresets 的内部计数(临时诊断,未进任何分支):

reconcile = {"calls": [{"verdict": false, "total": 206, "withRows": 4, "withUpdate": 4, "touched": 0}]}

三件事同时成立:

  1. calls 长度为 1 —— 整个进程只调用一次(ctx.inject(["loader"], cb) 的回调只触发一次,没有第二次机会);
  2. 那一次调用时 isDshCompactionActive() 是 false;
  3. withRows: 4、withUpdate: 4 —— 4 个带压缩行的 entry 全部满足前置条件,唯一拦路的是新增的 if (!isDshCompactionActive()) return 0;。

verdict 大约 1 秒后就变成 active(bili-native 的 apply() 里 declareDshCompactionActive() 在首个 await 之前,是同步声明的),但 reconcile 已经不会再跑了。

负向对照

只回退那一行、其余不动,同一份源码重新构建:

构建 reconcile 行状态
带闸门(本 head) verdict:false, touched:0 0/8
去掉闸门 verdict:false, touched:4 8/8

闸门本身是对的,时机不对

场景 V(- id: bili-native / disabled: true)实测:resolve("standard") 仍 ok、0 pending、8 行保持 stock —— 这正是 #3662 要求的回落,闸门就是为此加的。

所以不需要回退这个 commit,需要的是把"判 verdict"和"做对齐"分开:

  1. (推荐)声明后回调:共享模块里加一个跨 bundle 的回调注册(与 verdict 同一条 globalThis 通道),declareDshCompactionActive() 落地后立即触发;gate 在 apply 时注册,而不是当场做一次。verdict 缺席依旧什么都不做,语义不变。
  2. 有界重试:verdict 缺席时退避重试(例如 100ms × 5),拿到声明后再对齐。改动更小,但要处理"永远等不到"的终止。

为什么 CI 抓不到

现有单测先 declareDshCompactionActive() 再调 reconcileLoadedPresets(),等于假设了宿主里的调用顺序;真机上这个顺序是反的(preset 在 ~140ms 挂载、bili-native 在 ~960ms 声明,gate 的回调在声明之前跑过一次)。建议补一条时序用例:先 apply、后声明,断言声明落地后仍会触发对齐——现在的实现会永远漏掉这一支。

影响

ranxianglei#7111)

The verdict gate from 69d4309 was correct in semantics but wrong in
timing: on a real host (dsh 0.2.2-rc.4) the gate entry's one-shot
loader callback fires ~140ms in, before bili-native's apply() declares
the verdict (~960ms), so the reconcile saw an absent verdict, returned
0, and never ran again — leaving all preset compaction rows stock and
making the fail-open fix a no-op (reported with A/B real-host evidence).

Register the reconcile for the declaration instead of running it on
the spot: onDshCompactionDeclared() rides the same globalThis channel
as the verdict, fires the moment declareDshCompactionActive() lands
(or immediately if it already has), and never fires without a
declaration (stock stays stock — the ranxianglei#3662 contract is intact).
Entries are re-read at fire time, so presets mounted after the
one-shot callback are covered too.

Adds the timing regression test the report asked for: apply first,
declare later, assert the reconcile fires after the declaration —
verified to fail on the pre-fix implementation.
@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

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

诊断确认,已按你推荐的选项 1(声明后回调)修好:84966cc2f5。

代码级核实

  • declareDshCompactionActive() 确实在 bili-native apply() 顶部同步声明(src/agent/dsh-native.ts:1974,首个 await 之前);
  • 两个条目是 tsup 独立 bundle(tsup.config.ts 里 dsh-native.ts 与 dsh-compaction-gate.ts 是两条 entry),模块状态不能跨 bundle,globalThis 是唯一共享面——与你的观测一致;
  • 我的 69d43091 闸门放在一次性回调上,真机回调跑在声明之前 → touched: 0 且永不重跑。机制成立,你的 A/B + 负向对照证据充分。现有单测先声明 verdict 再调 reconcile,确实假设了宿主调用顺序——我的失误。

修法(选项 1:声明后回调)

  • dsh-compaction-disable.ts 新增 onDshCompactionDeclared(cb):回调注册表与 verdict 同一条 globalThis 通道(__BILI_DSH_COMPACTION_DECLARED_CALLBACKS__);declareDshCompactionActive() 落地 verdict 后逐个触发已注册回调(各自 try/catch,单个消费者失败不破坏声明本身);注册时 verdict 已 active 则立即触发。
  • gate 的 apply() 改为在一次性 loader 回调里注册回调(不再当场 reconcile),触发时重读 loader.entries()——回调之后才挂载的 preset 也覆盖到。
  • 语义不变:verdict 缺席永不触发,preset 保持 stock([dsh] Disabling the plugin permanently bricks dsh session creation - the bundle patch inject gate has no fallback (0.1.199 / dsh 0.2.1-rc.2) #3662 回落保留,你的场景 V 实测正是这个契约)。
  • reconcileLoadedPresets 内部的 verdict 闸门保留,作直调兜底。

验证

  • 补了你要求的时序用例:先 apply、后声明,断言声明落地后 reconcile 仍触发——先在修复前代码确认该用例会红(1 fail,精确复现你的真机现象),修复后转绿;
  • 定向测试 20/20 通过(issue7111 6 用例 + issue3354 + issue3662);typecheck 干净;
  • 我无法验证的部分:真机 dsh 宿主(本环境没有 dsh 0.2.2-rc.4)。请在新 head 84966cc2f5 上重跑同一套进程内探针——预期 touched: 4、8/8 disabled: true,且场景 V 仍 8 行 stock。

审核结论(八问)

  1. 是什么问题: 我的 69d43091 verdict 闸门让核心修复在真机变 no-op——reconcile 只跑一次且跑在声明之前,4 个 preset 的压缩行全留 stock,bili 负责的车道里宿主原生自动压缩仍 armed。
  2. 什么原因导致的: 我修了语义(verdict 必须被尊重)但没修时机(声明可能晚于一次性回调)。单测假设「先声明后 reconcile」,真机相反(preset ~140ms / 声明 ~960ms)。
  3. 影响范围与严重程度: 所有装 billion-context 的 web profile 正常启动——修复前 PR 的核心修复实际未生效(native 压缩 armed,受 nudge 死锁无检测:同一 session 交替收到两种结构互斥的请求流(巨型单消息 ↔ 多轮)时不告警 #1729 线级拒绝兜底,是「压不了并报错」而非静默损坏)。严重度:PR 核心修复被抵消(p1 级),但只影响 PR head,未发布。
  4. 怎么修复的: 把「判 verdict」和「做对齐」分开——reconcile 不再当场执行,而是注册为声明后回调(与 verdict 同一条 globalThis 通道),声明落地瞬间触发;已声明则立即触发;缺席则永不触发。entries 在触发时重读。
  5. 是否有回归问题: [dsh] Disabling the plugin permanently bricks dsh session creation - the bundle patch inject gate has no fallback (0.1.199 / dsh 0.2.1-rc.2) #3662 契约(verdict 缺席 → stock)保留且有负向测试钉住;既有 5 用例(含场景 V 语义)全过;唯一行为变更:reconcile 执行时机从「loader 回调时」移到「verdict 声明时」(真机 ~140ms → ~960ms),这正是修复目的。
  6. 是否破坏缓存: 不涉及。
  7. 是否改了设计方向: 无新方向——fail-open 方向内的时机修正,机制(globalThis 通道)与既有 verdict/telemetry 通道一致。
  8. 是否引入了新的配置: 无。

状态

  • 新 head 84966cc2f5 已推 PR 分支;CI 在跑(镜像缓存 0 failed)。
  • 同意「修好之前保持 draft」:请真机复探确认 8/8 disabled + 场景 V stock 后,核心修复即就绪(合并仅人工)。

@resec

resec commented Nov 18, 2026 •

Copy link
Copy Markdown
Author

真机复验:84966cc2 的时序修复成立(三场景)

背景(本条评论自身完整陈述):69d43091 给 reconcileLoadedPresets 加了 if (!isDshCompactionActive()) return 0;。语义是对的(verdict 缺席时预设必须留在 stock),但时机不对:真实宿主上 gate 条目的 ctx.inject(["loader"], cb) 回调只触发一次,且早于 bili-native 的 declareDshCompactionActive(),所以那次 reconcile 看到的是"未声明",返回 0,之后再无机会——四个 preset 的 8 个压缩行全部留在 stock。

84966cc2 改成"注册到声明之后"(onDshCompactionDeclared():声明落地即触发,已声明则立即触发,entries 在触发时重新读取)。我在 dsh 0.2.2-rc.4 + node 26.10.0 上重新构建这个 head 并跑三场景(探针读 entry.options.config 的递归行状态):

场景 verdict 压缩行 建会话
N 正常(gate + bili-native 都在) active 8/8 disabled:true(3s / 8s / 15s 三次采样一致) —
B bili-compaction-gate / disabled: true active 0/8 resolve("standard") ok、0 pending、宿主照常起服务
V bili-native / disabled: true 无声明 0/8(回 stock) resolve("standard") ok、0 pending

对照修复前(69d43091):场景 N 是 0/8,且 reconcile.calls 只有一次、verdict:false、touched:0。

三点值得记下来:

  1. 修复没有回退 verdict 语义——V 场景仍然一行不动,说明"判 verdict"与"做对齐"确实被拆开了,不是用"无条件对齐"换来的绿。
  2. onDshCompactionDeclared() 的"已声明则立即触发"分支覆盖了反序加载(gate 晚于 bili-native 时),这点在真机上没触发,但逻辑在。
  3. CI 抓不到这条:现有单测先声明再调 reconcile,等于假设了宿主顺序;新加的"先 apply 后声明"用例才是真正的防线。

本地门禁:typecheck / check-unused-exports / 20 个定向用例(issue7111 + issue3354 + issue3662)/ build 全绿。复现方式:把 billion-context 以 link 方式挂进一个 web profile,分别叠加 - id: bili-compaction-gate / disabled: true 与 - id: bili-native / disabled: true 两个 overlay,启动后读四个 preset 的 compaction-basic / command-compact 行。

结论:本评论开头描述的时序缺陷已不存在,可以关闭这一条。 剩下的是合并(需人工),以及 #7111 的 needs-decision:方案 A(拆掉入口级硬依赖)已在本 PR 实现,方案 B(gate 缺席时大声告警)是否并入本 PR 仍待定。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

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

真机复验收到,与预期一致——时序缺陷已解决:

你记的三点都成立,尤其第 3 点:「先 apply 后声明」的时序用例才是真正的防线,现有单测(先声明后 reconcile)确实假设了宿主顺序、抓不到这条。

当前状态(实时核对)

  • CI(镜像缓存):30 checks,0 failed,11 个 test 分片仍在跑(ubuntu/windows 全量)——全量判定以远程 CI 为准,目前无红。
  • 真机:dsh 0.2.2-rc.4 三场景全过。

剩余两道闸(均人工)

  1. 合并:仅人工。CI 全绿 + undraft 后即可合;我不合并、不关 PR(关闭权只在 owner)。
  2. [Bug][dsh] preset gate latch is fail-closed: a missing gate service permanently bricks session creation (root cause of #6456, not fixed by #6470) #7111 needs-decision(方案 B 告警):gate 缺席时的大声告警是折进本 PR 还是单独立项?我推荐单独立项跟进(floor 5 已列选项/代价/推荐):核心修复已恢复可用性,告警是安全增强、落点需一点设计,不应阻塞核心修复。此项等 owner 拍板。

审核结论(八问)

  1. 是什么问题: 真机时序缺陷——reconcile 只跑一次且早于 verdict 声明,核心修复变 no-op。已由 84966cc2(声明后回调)修复。
  2. 什么原因导致的: 单测假设「先声明后 reconcile」,真机相反;修复把「判 verdict」与「做对齐」拆开。
  3. 影响范围与严重程度: 修复前所有 web profile 核心修复未生效(p1 级,受 nudge 死锁无检测:同一 session 交替收到两种结构互斥的请求流(巨型单消息 ↔ 多轮)时不告警 #1729 线级拒绝兜底);现已解决。
  4. 怎么修复的: onDshCompactionDeclared() 声明后回调(与 verdict 同一条 globalThis 通道),声明落地即触发、已声明则立即触发、entries 触发时重读。
  5. 是否有回归问题: 无——场景 V 证实 verdict 语义保留(一行不动);既有 5 用例 + 新增时序用例全过。
  6. 是否破坏缓存: 不涉及。
  7. 是否改了设计方向: 无新方向——fail-open 内的时机修正。
  8. 是否引入新配置: 无。

收工判定

时序缺陷已解决并经真机三场景复验;代码与测试质量达标。待:① CI 全绿(11 分片在跑);② undraft;③ owner 对方案 B 告警拍板(推荐单独立项)。满足即就绪(合并仅人工)。

@resec

resec commented Nov 18, 2026

Copy link
Copy Markdown
Author

更正:我上一轮在这个线程给的“修复前 0/8”读数用错了层

上一条复验评论里我写:69d43091 上四个 preset 的压缩行是 0/8 disabled,84966cc2 修复后变 8/8。这个对照是错的,原因是我的探针读的不是宿主实际消费的那份配置。先更正,再给重测结果。

我读错了什么

我读的是 entry.options.config,那是条目的原始配置。internal/config 中间件改写的是解析结果,它不回写 options;只有 reconcile 里的 entry.update() 会因为重新提交而把结果写回 options。

所以“0/8”只说明那次 reconcile 没写回 options,不能说明压缩没被关。

正确的读法

对每个 preset entry 主动派发一次 internal/config,拿中间件链的返回值——那才是宿主拿去构造 fiber 的配置:

const resolved = fiber.ctx.waterfall('internal/config', fiber, () => entry.options.config)

重测结果(同一套探针,换构建)

构建 生效配置里被禁用的压缩行
master 548e3960 8/8(4 个 preset × 2 行,3/12/22 秒三次采样一致)
69d43091(我上次说失效的那个 head) 8/8

也就是说:69d43091 的时序问题是真的(reconcile 确实没跑),但它的后果不是“压缩没被关”,而是“兜底没触发”。 主路径一直由中间件覆盖,用户可见行为没有退化。

结构上也支持这一点:registerCompactionDisable 先注册 internal/config 中间件,末尾才 reflect.provide(biliBasicCompactionPolicy);四个 preset 对这个服务是 required 依赖,而唯一的提供者就是 gate 条目。所以“preset 先于中间件解析”在结构上不可能发生——reconcileLoadedPresets 从一开始就只是冗余兜底。

对 84966cc2 的评价调整

不撤回:它让兜底在假设的时序下也能工作,而且那条“先 apply、后声明”的时序用例本身有价值(现有单测确实假设了宿主顺序)。但不需要按阻断级问题处理——它修的是一个当时不会触发的路径。

这对本 PR 的方向没有影响

删掉四条 preset 的 inject 行(让 gate 缺席时降级而不是砖机会话)仍然成立且是必要的。上面更正只影响“时序兜底”这一项的严重程度判断。

复现脚本我可以贴出来(探针 + overlay),需要的话我放在这条评论的回复里。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

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

上一轮 CI 跑完是 2 红(windows-latest node 22 的 test shard 4 和 5),已定位并处理:

两红都是继承性失败,不是本 PR 的代码问题

根因:分支 base 过旧

  • 本分支 base 是 0e475ceb,master 已推进到 548e396。
  • master 上的 3186e54ad2「fix(tests): make the shutdown-signal test portable to Windows (it killed its own child on win32)」正是 shard 4 的修复:test 4 假设 POSIX 信号语义,Windows 上 process.kill(self, SIGINT) 直接 TerminateProcess、不跑 handler → 文件级失败、零 TAP 输出、确定性。该修复在 master 上,但不在本分支、也不在 ci-fixes(ci-fixes 7247410 是 master 的祖先,落后于 master)。

处置

  • 把 origin/master(548e396)merge 进本分支(merge commit de688485cd),更新 base 并带进该 Windows 修复;未新写任何测试修复。
  • 本地门禁:typecheck 干净 + 20 个定向用例(issue7111/3354/3662)全绿。
  • 已推送,CI 重跑中(当前 0 红 / 13 pending)。

八问

  1. 是什么问题:CI 两红是继承性失败(分支 base 过旧),非本 PR 代码缺陷。
  2. 什么原因:分支基于 0e475ceb,落后于 master 的 Windows 测试修复 3186e54ad2。
  3. 影响范围与严重程度:仅影响本 PR 的 CI 绿/红判定,不影响运行时行为;不更新 base 则 PR 无法合入。
  4. 怎么修复的:merge 当前 master 更新 base、带进既有修复,不新写测试修复。
  5. 是否有回归问题:merge 只前进 base,本 PR 的 dsh-compaction 改动未被触碰;本地 typecheck + 定向用例全绿。
  6. 是否破坏缓存:不涉及。
  7. 是否改了设计方向:不涉及。
  8. 是否引入了新的配置:不涉及。

仍开放

  • needs-decision:方案 B(gate 缺席时大声告警)是否并入本 PR——仍待 owner 拍板(我推荐 follow-up,理由见上一条)。
  • undraft + merge:人工操作。

CI 全绿后这条即可进入合并流程。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

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

收到更正,逐点回应:

1. 层错误确认

同意。entry.options.config 是原始配置,internal/config 中间件改写的是解析结果,不回写 options。所以"0/8"只能说明"那次 reconcile 没写回 options",不能说明"压缩没被关"。正确的探针是 fiber.ctx.waterfall('internal/config', fiber, () => entry.options.config),这是宿主实际拿去构造 fiber 的配置。

2. 结构论证的适用边界

你的结构论证(required-dep 排序:中间件先注册、reflect.provide 末尾、preset 对服务是 required 依赖、唯一提供者是 gate 条目)对**旧代码(master,preset 有 inject 行)**成立——preset 在 gate 服务提供前无法解析,而 gate 服务由 registerCompactionDisable 提供,中间件先于 provide 注册,所以排序有保证。

但对新代码(PR,preset 的 inject 行已删除),这个结构论证不直接适用——preset 不再被 gate 服务阻塞,理论上可以在中间件注册前解析。不过你的真机探针(69d43091 上 8/8 disabled)是实际证据,说明 dsh 0.2.2-rc.4 的加载顺序确实保证中间件先于 preset 配置解析。结构论证是 nice observation,真机探针才是新代码下的实际证据。

3. reconcile 的定位

reconcile 不是严格冗余——它是防御网,覆盖"preset 在中间件落地前解析"的边界情况。这个边界情况在今天的 dsh 0.2.2-rc.4 上不会触发(你的探针证明了),但在其他 dsh 版本或不同宿主上可能触发。reconcile 代价极低(一次 entry.update 重提交),风险极低,保留合理。

4. 84966cc2 评价

同意你的调整——不撤回,但不是阻断级。它修的是"假设时序下兜底不工作"的路径,在今天的宿主上不触发。"先 apply、后声明"的时序用例本身有价值(现有单测确实假设了宿主顺序),保留。

5. PR 方向

同意。删除四条 preset 的 inject 行(让 gate 缺席时降级而不是砖机会话)仍然成立且必要。你的更正只影响"时序兜底"这一项的严重程度判断,不影响 PR 方向。

6. 复现脚本

请贴出来(探针 + overlay),方便独立验证。

CI 状态(sha de688485cd):static-gates / kernel-guard / version-guard / architecture-docs 已绿;test 分片、dsh plugin lane、unused-exports、docs-sync 仍在跑。等全绿后出最终判定。


结构化八问

  1. 是什么问题:dsh preset 的 inject: [biliBasicCompactionPolicy] 行是 fail-closed 的——gate 服务缺席时四个 preset 永远 pending,会话创建报 agent-presets/not-found,但宿主照常启动并服务 UI。
  2. 什么原因导致的:preset 对 gate 服务是 required 依赖,gate 服务由 registerCompactionDisable 提供;如果 gate 条目加载失败或时序不对,服务缺席,preset 被阻塞。
  3. 影响范围与严重程度:特定条件下有问题——gate 条目加载失败或时序不对时,会话创建失败(agent-presets/not-found),但宿主 UI 可用。p2 级(能用但有明显问题,需绕行)。
  4. 怎么修复的:删除四条 preset 的 inject 行(preset 不再被 gate 服务阻塞),改为 post-load reconcile(gate 条目加载后主动扫描已加载的 preset 条目,对含 compaction 行的条目重提交禁用配置)。主路径由 internal/config 中间件覆盖({global:true},所有条目解析时都经过),reconcile 是防御网。
  5. 是否有回归问题:旧代码 gate 缺席时 preset 永远 pending(砖机),新代码 gate 缺席时 preset 正常解析但 compaction 行不被禁用(降级)。这是有意的行为变更——从"砖机"到"降级",不是回归。中间件覆盖主路径(你的真机探针 8/8 证明了),reconcile 覆盖边界情况。
  6. 是否破坏缓存:不涉及。
  7. 是否改了设计方向:不涉及。preset 的 compaction 禁用机制从"gate 服务阻塞"改为"中间件覆盖 + reconcile 兜底",设计方向不变(仍然是 gate 条目负责禁用 compaction)。
  8. 是否引入了新的配置:不涉及。

判定:方向正确,代码整洁,测试覆盖充分(6 个新测试 + 更新现有测试,20/20 通过)。等 CI 全绿后出最终合并判定。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

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

CI 全绿了。merge master(de688485cd)后重跑:0 红,之前两红的 Windows node 22 test shard 4/5 现在都 success——shard 4 由 master 的 3186e54ad2(Windows 信号测试修复)解决,shard 5(processBirthStamp)也过了。

本条 PR 侧的工作到此完成:

  • 核心修复(fail-open 预设对齐)+ verdict 时序修复(84966cc2)+ 文档修正(18be13284c)+ 真机三场景复验通过。
  • CI 全绿。

仍开放(等人工)

  • needs-decision:方案 B(gate 缺席时大声告警)是否并入本 PR——待 owner 拍板(我推荐 follow-up,理由见前一条)。
  • undraft + merge:人工操作。

CI 绿 + 真机复验通过,这条已具备合并条件,等 owner 决策方案 B 后即可 undraft 合并。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

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

CI 全绿(sha de688485cd):30/30 checks passed,0 failed,0 pending。

最终判定:可合并。

方向正确(fail-closed → fail-open + reconcile 兜底),代码整洁,测试覆盖充分(6 个新测试 + 更新现有测试,20/20 本地通过),CI 全绿。无回归。

@resec
resec marked this pull request as ready for review November 18, 2026 07:35
@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

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

Re-verified live state: head de688485cd is green — 30/30 checks passed, 0 failed, 0 pending. The failing checks reported (windows-latest 22 shards 4/5 on head 84966cc2f5) are already resolved by the current head. No further work needed.

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