Skip to content

[PR] feat(dsh): source-kind attestation channel — hosts declare message types instead of copied text markers (#7085) - #7104

Closed
ranxianglei wants to merge 6 commits into
masterfrom
2026-11-18_dsh-msg-kinds
Closed

ranxianglei wants to merge 6 commits into
masterfrom
2026-11-18_dsh-msg-kinds

Conversation

@ranxianglei

@ranxianglei ranxianglei commented Nov 18, 2026 •

Copy link
Copy Markdown
Owner

这是啥问题

dsh 宿主注入的消息(运行时上下文快照、技能目录、AGENTS.md 基线等)在 bili 里靠抄宿主的文案标记识别。宿主一改文案,分类器就静默失明——消息丢掉保护/记账,没有任何信号。#7085 就是这么发生的:dsh 0.2.2-rc.3 改了运行时上下文快照的开头,整个类别丢保护三天无人知晓(#7087 修的是抄新文案的下一版)。

本 PR 修的是根因:让宿主直接声明自己注入消息的类型。

方案

  • 插件侧(src/agent/dsh-native.ts):dsh 每条消息内部都带结构化 source.kind(wire 上看不到)。插件在 llm/stream 钩子里对证据许可表内的 9 类消息,盖 kind=sha256(原文)前16hex 对到请求头 x-bili-msg-kinds。指纹把类型绑定到确切文本——不匹配文本的指纹命中不了任何消息。
  • 服务端(src/msgid-pin.ts 解码器 + src/durable-message-guards.ts 分类器工厂):严格解码(全有或全无:一个坏对或同一指纹两个类型 = 整个头作废 = 行为等同未发;≤512 对/64KiB),按指纹命中请求自己的消息,先于文案标记归类;查不到/未知类型/指纹不中 → 回落到今天的文案匹配。
  • 上游隔离:新头与 x-bili-msg-ids 同剥除清单,模型/上游永不可见。
  • 无开关:缺头/旧宿主/旧代理 = 逐字节等同今天的行为,零迁移零升级面,故不设 rollout。

v1 边界(有意为之)

  • 只接全量重发车道:增量 lane 转发该头但不读(保持文案回落),延后。
  • 9 类映射,每类都有源码验证的 emitter + 文案分类器孪生(kind 路径与标记路径必须同意家族——类型命中只会救活漂移文案,不会改变保护级别)。不映射:mcp-catalog(第三方插件)、image-handle/offload(仓库外 @dsh-compaction 包)、tmux-context(无分类器家族)。
  • 两个类型带 form 过滤(客户端侧):agent-instructions 只声明 baseline 不声明 reconcile 通知、agent-message 只声明 relay——文案分类器刻意留 foldable 的那些形态不被类型误救。

#7121 扩展面:side-request 降级门 + 标题派生(v1 有意延后的两个分类面)

审核期间按 #7121 跟踪 issue 发现:v1 还有两个 marker 分类面未接 kind 通道,宿主改文案后同样会静默失明(与 #7085 同一机制类,触发面窄、非缺陷)。按「连贯修复不拆片」并入本 PR(commit a8582ee):

  1. side-request 降级门(isDshSingleShotSidecar,src/server/side-request.ts):无 tools 的单 user body + ≤8192 single-shot budget 时,改文案的 carrier 不再被误路由到 verbatim side lane——那样会跳过 kernel,carrier 的 BLOCKED ref 永不盖章(开启 bili 后「规矩与 skill 好像没被使用」? #2419/compress 增加按内容标记的硬排除(protectedContentMarkers),保护会话的基础设施注入免于折叠 #2446/dsh 车道:AGENTS.md(workspace instructions,user 消息形态)被折叠后从 wire 消失 —— 与 #2419 同类,但 #2428 白名单只覆盖 <available_skills> #2447/[Bug] dsh 车道切模型 fork 出的 _sub: 会话不继承父会话 fold 块:上游上下文从 ~83K 瞬间膨胀到 794K、命中归 0、节省转负(0.1.187/0.1.188) #2817/[Bug][dsh] 20k-message / 81 MiB-inbound session: host aborted 6× in 2 h — the #3050 resident-AST OOM is not bounded by sessions.hardMaxBytes (Windows, 0.1.210) #5403 契约)。
  2. 标题派生(deriveTitle / isAutoInjectedNotification,src/server.ts):改文案的注入通知不再把会话标题锁死(标题 set-once,会话标题被自动注入的系统通知占用,无法反映真实会话内容 #2286)。

行为变更披露(旧值→新值 + 原因):

  • 旧:这两个面只看文案标记/前缀。宿主改文案后,①主轮可能被误判为 sidecar(该轮跳过 kernel),②会话标题被通知文案锁死。
  • 新:请求携带合法 x-bili-msg-kinds 头时,认证过的改文案 unit 按 kind 归类——与消息分类器共用同一个 kind-first 表达式(dshCarrierPathByKind,src/durable-message-guards.ts),kind 只救活漂移文案、不改变保护级别(家族一致性不变)。
  • 不变:缺头/坏头(整头作废)/未映射 kind = 逐字节等同旧行为;mcp-catalog、image-offload 无 kind 家族(许可表外),保持纯标记;触发面仅 dsh 宿主(唯一产生该头的客户端)。

验证:tests/msgkind-channel.test.ts 新增 13 用例(#3617 双向门:认证改文案 carrier 被救活 / 无头 = 旧判决 / 错指纹与未映射 kind 不救活 / 标记与前缀回落不变 / 真 sidecar 保持 side lane / 指纹对未 trim 的确切字节);title-derive、issue5656、side-lane-invariants、durable 家族定向回归全绿(160 用例);tsc --noEmit 干净。

文件(本扩展新增):src/server/side-request.ts、src/server.ts、src/server/handle.ts(解码提前到 sideRequestLike 之前 + 两个调用点)、4× src/server/prepare-*.ts(解码提升 + 标题接线)、tests/msgkind-channel.test.ts。顺手修:prepare-responses.ts 两行既有缩进缺陷(列 0 → 8 空格)。

验证

文件

代码:src/agent/dsh-native.ts(采集+盖章)、src/msgid-pin.ts(解码器)、src/durable-message-guards.ts(许可表+工厂)、src/server/handle.ts(消费缝)、src/server/headers.ts(剥离);测试:tests/msgkind-channel.test.ts;文档:docs/plugin-protocol.md §2、reference/architecture.md、CHANGELOG.md

@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-11-18_dsh-msg-kinds (1a996fa)

Latest build — install this exact version

npm install -g billion-context@0.0.10759-pr.7104.d167fcb

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
1a996fa billion-context@0.0.10759-pr.7104.d167fcb build
a8582ee billion-context@0.0.10757-pr.7104.59dbd47 build
e8e2d09 billion-context@0.0.10740-pr.7104.44b97ea build
acee2d3 billion-context@0.0.10725-pr.7104.5352750 build
c1818a9 billion-context@0.0.10701-pr.7104.ce15a25 build
84a5bfd billion-context@0.0.10697-pr.7104.77c0360 build

Download artifact

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

Install instructions are refreshed on each push.

@ranxianglei ranxianglei changed the title feat(dsh): source-kind attestation channel — hosts declare message types instead of copied text markers (#7085) [PR] feat(dsh): source-kind attestation channel — hosts declare message types instead of copied text markers (#7085) Nov 18, 2026
ranxianglei added a commit that referenced this pull request Nov 18, 2026
… raw-pair cap, docs dedup, test lockstep (#7104)

- tool-jobs now form-filtered to 'notice': dsh stamps only that form today
  (single emission site, packages/jobs/tool-jobs/src/index.ts:391) but its
  source type is ContextFormed — a future form would have no text-marker
  twin, violating the kind/markers family agreement invariant.
- msgTextUnitsOf: bare string ARRAY PARTS now attest (kernel/src/wire/openai.ts
  turns them into their own text cores).
- collector skips role:'assistant' defensively (server role gate unchanged).
- incomingMsgKindsHeader caps RAW pair count (duplicates included), matching
  the documented '≤512 pairs' — previously only the deduped index was capped.
- docs/plugin-protocol.md: drop the duplicated x-bili-msg-kinds bullet.
- stale comments: ~13KiB→~30KiB worst case; durable-message-guards.ts file
  header no longer claims source.kind never reaches the wire for the dsh lane.
- tests 23→28: factory registry keys === [dsh] (non-dsh lanes can never
  obtain the dsh factory), host attestable kind set ↔ server permitlist
  lockstep, interior-comma tolerance + space-voids-whole-header, raw-pair
  513-cap with duplicate pairs, bare-string-part attestation, assistant skip.

@ranxianglei ranxianglei left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

评审模型自声明:本评审由 AI agent 独立完成,模型 qwen3.8-27b(provider sglang-gpu0,本地 sglang 推理)。人工合并前请过目。

结论:无 blocker,可合并(合并留给人)。 独立干净上下文评审跑完:1 major + 5 minor + 2 nit,全部已在分支上就地修掉(fix commit c1818a9c)并回归验证。

Major(已修)

  • tool-jobs 原未加 form 过滤:文案孪生 dshToolJobNoticePath 只匹配 notice 形态,若 dsh 未来发其他 form 会违反「kind 路径与 marker 家族必须一致」的不变量。已对 dsh 源码核实(packages/jobs/tool-jobs/src/index.ts:391 是唯一发射点,今天只发 notice;类型是 ContextFormed 可扩展)——补了 ATTESTABLE_KIND_FORMS["tool-jobs"]="notice",与 agent-instructions/agent-message 的过滤同纪律。

Minor/Nit(已修)

  • docs/plugin-protocol.md 重复条目:feat 与 docs 两笔提交各写了一条 x-bili-msg-kinds bullet,删重复、保留更完整一条(补上 bare-string-array-part 说明)。
  • 采集器漏采裸字符串数组项:kernel/src/wire/openai.ts 会把数组里的裸字符串拆成独立 text core,msgTextUnitsOf 现在同样采集——否则这种消息静默降级回文案匹配。
  • 解码上限语义:incomingMsgKindsHeader 原先只限制去重后 index.size,文档却写「≤512 pairs」;改为按原始对数计数(513 对即 void),与文档一致。
  • 采集器防御性跳过 role:assistant(服务端角色门保持不变,双层)。
  • 测试 23→28:工厂 registry 恰为 ["dsh"](非 dsh lane 拿不到 dsh 工厂)、host 可声明 kind 集 ↔ server 许可表 keys lockstep(单边加 kind 会挂 CI)、内逗号容忍、对间空格/前导空格整头作废、重复对计入 512 上限、裸字符串数组项、assistant 跳过。
  • 过期注释:~13KiB → ~30KiB worst case;durable-message-guards.ts 文件头「source.kind 永远到不了 wire」改为注明 dsh 车道已过时、文案标记降为 fallback。

验证:typecheck 干净;tests/msgkind-channel.test.ts 28/28;msgid 家族(msgid-pin / msgid-rule-parity / msgid-header-channel / egress-header-isolation)+ durable 家族(issue2481 / issue5142 / issue2447 / durable-tool-identity)回归全绿;tools/check-architecture-docs.mjs 全绿。

设计确认项(评审逐条核过,无问题):

  • 字节相等链:kernel 两个 wire codec 对用户文本逐字解码(无 trim/surrogate 处理/图片规范化),dsh 侧任何变换只会让指纹 miss 降级回 marker,不可能错映射。
  • ALS 作用域:llm/stream 全部 dispatch 走 runLlmDispatch,作用域外请求(capability probe、plugin/tool)不盖章 → 与通道前逐字节一致。
  • 信任边界:伪造头最多只能给自己的请求消息贴标(指纹要求知道确切文本;x-bili-plugin 冒充本就是既有行为);egress 剥离保证上游永不可见。
  • KDD 纪律:非 identity 载体(永不作 attribution rung、永不 pin);host bundle 镜像常量不 import server 模块,lockstep 由测试钉死。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

查重: 不重复。 open PR 中只有本 PR 一个命中 source-kind / attestation / #7085 主题;止血 PR #7087(抄新文案)已 closed,与本 PR 是「下一版 vs 根因」的关系,不是并行修复。无重复调度风险。

标签: enhancement, p1, dsh, scope/wiring —— 本 PR 是新增协议信道(feat,非 bug 修复);根因是 #7085 的整类消息静默丢保护(数据完整性类,与 #7085 的 p1 同级);宿主车道 dsh;领域取 scope/wiring(新请求头信道 + 请求管道消费缝,分类器工厂只是消费端)。

当前状态(实时核对):head 84a5bfd,e2e 各车道(codex/dsh/pi/opencode/registry/persona/ws 共 10 条)全绿,主 CI 测试车道仍在跑。

我将按 PR 审核规范做完整审核:① 原 issue 方向关 → ② 回归审查(既有行为清点) → ③ 代码审查 → ④ 测试有效性 → ⑤ diff 整洁度/代码整洁硬标准,结论用结构化八问回复。审核中。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

PR #7104 审核结论

审核范围: 完整 diff(9 文件)通读 + 回归审查 + 定向测试 + 代码整洁度。

核心发现(已当场修复): PR 把保护分类器(durable message path)做成了 kind-aware,但fold-drift 记账分类器(oneShotCarrierPaths,fold-reconcile channel 1)仍是纯文案标记。宿主改文案后保护保住了,但 expected-rebase 记录会漏记 → 下次 fold 时该 id 落进 missing → #5139 O(全历史) reconcile 税(1.8s→25s 先例)+ 假漂移告警,整个 carrier 家族,无信号。这与 #7085 是同一机制、同一车道的残留面。

修复(commit acee2d38dc,已推 PR 分支): 镜像保护分类器的模式(kind 优先、文案回落、未认证时逐字节等同),把 kind 索引接进 channel 1——ReconcileOptions.inboundMsgKinds + 4 个 wire 站点(prepare-anthropic/google/openai/responses)透传 + oneShotCarrierPathFactories 注册表(仅 dsh,KDD #9)。新增 6 个测试(工厂注册表/parity/kind 命中/负向/回落/角色门)。定向套件全绿:msgkind 34、fold-reconcile+5142+5173 91、durable+msgid-pin 45、msgid 家族 58、fold-reconcile perf/large/positional 30(合计 258 用例)。

v1 未覆盖面(已立项跟踪 #7120): kind 通道未覆盖以下 marker 分类面(下次宿主改文案会静默失明,但触发面窄/严重度低/需不同机制,v1 有意延后):① Channel 2 stored-row 回填(需持久化 kind,存储 schema 变更);② side-request 降级(窄触发);③ 标题派生(最低严重度)。详见 #7120 清单。

PR 正文勘误: 「23 用例」已过时——PR head 实际 28 用例(reviewer-findings commit 加了 5 个),加 channel-1 修复后 34 个。建议更新 v1 边界节,把 #7120 的 3 个未覆盖面列进去(当前只列了增量 lane/未映射 kind/form 过滤)。

CI: 新 head acee2d38dc 刚推,CI 待跑(旧 head c1818a9c7b 0 失败、14 排队中,无红)。

八问

  1. 是什么问题: PR 引入 source-kind attestation 通道(dsh 车道),让宿主声明注入消息类型,替代抄文案标记([Bug][dsh] 0.2.2-rc.3 changes the runtime-context snapshot copy, dshRuntimeContextPath silently stops classifying #7085)。审核发现一个残留:fold-drift 记账(channel 1)仍是纯文案。
  2. 什么原因导致的: PR 只把保护分类器改成 kind-aware,漏了同一机制的 fold-drift 记账分类器——两者都是 marker-based,但只更新了一个。
  3. 影响范围与严重程度: dsh 车道的 fold-drift 记账。宿主改文案后保护保住但漂移记账漏记 → [Bug][Codex] Temporary separator selected as compression endpoint, causing acp_status to silently fail to report ~180K t | [Bug][Codex] 临时分隔符被选作压缩端点,导致 acp_status 静默漏报约 18 万 token 可压缩历史 #5139 O(全历史) 税 + 假告警。p2(性能下降 + 假告警,非数据丢失)。已修复。
  4. 怎么修复的: 镜像保护分类器模式,把 kind 索引接进 channel 1(kind 优先、文案回落、未认证逐字节等同)。
  5. 是否有回归问题: 无。定向套件全绿(258 用例)。缺头/坏头/未映射 kind/指纹不中 = 逐字节等同 pre-channel 行为;非 dsh 车道不受影响;session.ts 重建路径仍用注册表条目(未变);增量 lane 仍只转发不读(v1 边界未变)。
  6. 是否破坏缓存: 无。kind 索引是 per-request(不持久化);channel-1 改动只影响 expected-rebase 记录(元数据),不影响前缀缓存。
  7. 是否改了设计方向: 无。修复遵循既有模式(保护分类器),无架构变更。
  8. 是否引入了新的配置: 无。kind 通道是 header-based(x-bili-msg-kinds),不是 config-based。无新 env/config/CLI。

合并判定: 可合并(CI 绿后)。channel-1 残留已当场修复,v1 未覆盖面已立项跟踪(#7120,不阻塞)。合并权在 owner。

@ranxianglei

Copy link
Copy Markdown
Owner Author

CI 红项归因(补充评审):模型 qwen3.8-27b(provider sglang-gpu0)。

当前 CI 唯一红项 test (windows-latest, 22, 1) 不是本 PR 的回归,证据链:

  1. CI 检出的是 merge ref(PR + master):job 日志第 90 行 git checkout --force refs/remotes/pull/7104/merge。
  2. 挂掉的测试 tests/server-process-listeners.test.ts 是刚合入 master 的 PR [PR] batch-2: 4 held Afloat16 fixes (2 as-is, 2 with review-patch commits) #7101 新增的——本 PR base(10b0c2b1)上不存在此文件,本 PR 四个提交(含 acee2d38)也都不碰进程 handler 逻辑。
  3. master 自身同症:master 0e475ceb([PR] batch-2: 4 held Afloat16 fixes (2 as-is, 2 with review-patch commits) #7101 合并)的 CI 是 failure,windows 分片 (22,5)/(24,5) 挂掉同一文件、同一形状(swallowed 闷死、隔离重跑复现、CI 自判 deterministic break)——[PR] batch-2: 4 held Afloat16 fixes (2 as-is, 2 with review-patch commits) #7101 的新测试在 Windows 车道上行为不同,master 侧待修。
  4. 同一分片在本 PR 两个 head(c1818a9c、acee2d38)上都红,与本 PR 提交内容无相关变量。

本 PR 相关车道全部绿:12/13 workflow success(含全部 e2e 真二进制车道、gate 静态检查),主 CI 其余 11/12 分片 success。master 侧修复后本 PR rebase 即可全绿(PR 当前 BEHIND master,rebase 是合并前的既定动作,base 差异只涉及 #7101 的 google/tunnel/ca/进程 handler 文件,与本 PR 零重叠)。

@ranxianglei
ranxianglei force-pushed the 2026-11-18_dsh-msg-kinds branch from acee2d3 to 02344b6 Compare November 18, 2026 04:48
ranxianglei added a commit that referenced this pull request Nov 18, 2026
… raw-pair cap, docs dedup, test lockstep (#7104)

- tool-jobs now form-filtered to 'notice': dsh stamps only that form today
  (single emission site, packages/jobs/tool-jobs/src/index.ts:391) but its
  source type is ContextFormed — a future form would have no text-marker
  twin, violating the kind/markers family agreement invariant.
- msgTextUnitsOf: bare string ARRAY PARTS now attest (kernel/src/wire/openai.ts
  turns them into their own text cores).
- collector skips role:'assistant' defensively (server role gate unchanged).
- incomingMsgKindsHeader caps RAW pair count (duplicates included), matching
  the documented '≤512 pairs' — previously only the deduped index was capped.
- docs/plugin-protocol.md: drop the duplicated x-bili-msg-kinds bullet.
- stale comments: ~13KiB→~30KiB worst case; durable-message-guards.ts file
  header no longer claims source.kind never reaches the wire for the dsh lane.
- tests 23→28: factory registry keys === [dsh] (non-dsh lanes can never
  obtain the dsh factory), host attestable kind set ↔ server permitlist
  lockstep, interior-comma tolerance + space-voids-whole-header, raw-pair
  513-cap with duplicate pairs, bare-string-part attestation, assistant skip.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

归因核实成立,补充当前状态与一处文件级细节。

归因独立复核(不照抄结论,重新查证):

当前状态(实时核实):

一处文件级细节(结论不变):「与本 PR 零重叠」在文件级不完全准确——3 个文件有重叠(src/server/handle.ts、src/server/prepare-anthropic.ts、reference/architecture.md),但 master 与 PR 的改动落在不同区域:

无冲突,rebase 干净(已实测:4 提交零冲突重放)。可干净 rebase 的结论不变。

下一步:等 PR CI 跑完。master 已从 0e475ceb(#7101 合并,红)前进到 4b77eab409(#7107 合并);#7101 的 Windows 测试修复是否已落地待 master CI 确认。本 PR 已在其上,master 修好后 CI 重跑即绿。

结论:归因成立;PR 已在最新 master 上、CI 进行中——可合并(CI 绿后)。

@ranxianglei

Copy link
Copy Markdown
Owner Author

CI 归因更新(rebase 后 head e8e2d097):模型 qwen3.8-27b(provider sglang-gpu0)。

rebase 到最新 master 后 CI 重跑:37 SUCCESS / 14 SKIPPED(e2e 真二进制车道,基线就跳过)/ 1 FAILURE。唯一红项 test (windows-latest, 22, 4) 拉日志确认:仍是 tests/server-process-listeners.test.ts,签名与上一条归因逐字节一致(swallowed 闷死、隔离重跑 1.7s 复现、CI 自判 deterministic break),检出仍是 refs/remotes/pull/7104/merge。

补充一个佐证:rebase 后分片号从 (22,1) 漂到 (22,4)——master 新文件进来导致测试切片重新分配,同一个必挂的测试落在不同分片。master 侧该文件的确定性失败在哪个分片跑就会红哪个分片,与 PR 内容无关。本 PR 自身车道(含 CI 追加的 fold-reconcile 记账提交 e8e2d097 的 52 个新用例)全部绿。

ranxianglei pushed a commit that referenced this pull request Nov 18, 2026
…rivation (#7121)

The v1 kind channel (#7085, PR #7104) covered the durable protection
classifier and fold-drift accounting (channel 1), but two marker-
classification surfaces stayed marker-only and go blind when a host
rewords its injections:

1. isDshSingleShotSidecar (src/server/side-request.ts) — a reworded
   carrier in a tool-less single-user body with a <=8192 single-shot
   budget is misrouted to the verbatim side lane, skipping the kernel,
   so the carrier's BLOCKED ref is never stamped (#2419/#2446/#2447/
   #2817/#5403).
2. deriveTitle / isAutoInjectedNotification (src/server.ts) — a
   reworded notification titles the session forever (set-once, #2286).

Both now resolve through the same kind-first expression as the message
classifiers (dshCarrierPathByKind / dshTextUnitIsCarrier,
src/durable-message-guards.ts): fingerprint of the EXACT unit bytes ->
attested kind -> permitlist path. An absent or voided header keeps
every surface byte-identical to pre-channel behavior; unmapped kinds
never rescue. The x-bili-msg-kinds decode in handle.ts moves before
sideRequestLike so the demotion gate can consume it; the prepare
adapters hoist their existing inline decode and feed the title
derivation.

Gate discipline (#3617): both directions pinned in
tests/msgkind-channel.test.ts — attested reworded carrier rescued; no
header = pre-channel verdict; wrong fp / unmapped kind never rescue;
marker/prefix fallback unchanged; a genuine sidecar keeps the side
lane; byte-equality over untrimmed unit bytes.

Also fixes a pre-existing indentation defect in prepare-responses.ts
(foldMode/reconcileFoldCoverage lines at column 0).
ranxianglei and others added 5 commits November 18, 2026 14:18
…pes instead of copied text markers (#7085)

The durable/oneshot classifiers recognize host-injected carriers by COPIED
text markers; when a host rewords its injection the classifier silently stops
matching and the message loses its protection/accounting with no signal
(#7085: dsh 0.2.2-rc.3 reworded the runtime-context snapshot and the whole
class went unprotected for three days).

The channel: the dsh plugin observes the in-process llm/stream options where
every MessageBase carries its structured source.kind, and attests
kind=sha256(exact-text) first-16-hex pairs per injected message on the
x-bili-msg-kinds request header. The server decodes the header strictly
(all-or-nothing: one malformed pair or an ambiguous fingerprint voids the
whole header, which then behaves exactly as if absent; <=512 pairs / 64KiB),
resolves each fingerprint against the request's own messages, and for kinds
on the evidence-permitlist (9 kinds, each with a source-verified emitter and
a text-classifier twin) classifies by declared kind BEFORE the text markers.
Unknown kinds pass validation but are unmapped; a fingerprint miss (any
transform that broke host↔wire byte-equality) falls through to the markers.
The header is egress-stripped like x-bili-msg-ids and never reaches the
model. Absent header / old host / old proxy all degrade to byte-identical
pre-channel classification, so there is no rollout gate and no migration.

v1 scope: full-resend lane only (the incremental lane forwards the header
unread and keeps marker classification). Unmapped on purpose: mcp-catalog
(third-party plugin), image-handle / image-offload-placeholder (out-of-repo
@dsh-compaction package), tmux-context (no classifier family).

Regression: tests/msgkind-channel.test.ts (23 cases, #3617 both-direction
gates: malformed headers void whole, ambiguous-fp void, assistant role
never a carrier, factory(undefined) === text-only classifier, host<->server
fingerprint lockstep corpus, e2e collector->header->decoder->classifier
roundtrip).
- docs/plugin-protocol.md §2: the new optional request header — format
  (kind=sha256-first-16-hex pairs, comma-joined ASCII), all-or-nothing
  decode, 512-pair/64KiB caps, unknown-kind pass-through, egress strip,
  and the absence-degrades-to-today guarantee (old proxies ignore it, old
  hosts keep working); 中文要点 inline.
- reference/architecture.md: durable-message-guards.ts + msgid-pin.ts map
  lines carry the new responsibility.
- CHANGELOG.md [Unreleased] → Changed.
… raw-pair cap, docs dedup, test lockstep (#7104)

- tool-jobs now form-filtered to 'notice': dsh stamps only that form today
  (single emission site, packages/jobs/tool-jobs/src/index.ts:391) but its
  source type is ContextFormed — a future form would have no text-marker
  twin, violating the kind/markers family agreement invariant.
- msgTextUnitsOf: bare string ARRAY PARTS now attest (kernel/src/wire/openai.ts
  turns them into their own text cores).
- collector skips role:'assistant' defensively (server role gate unchanged).
- incomingMsgKindsHeader caps RAW pair count (duplicates included), matching
  the documented '≤512 pairs' — previously only the deduped index was capped.
- docs/plugin-protocol.md: drop the duplicated x-bili-msg-kinds bullet.
- stale comments: ~13KiB→~30KiB worst case; durable-message-guards.ts file
  header no longer claims source.kind never reaches the wire for the dsh lane.
- tests 23→28: factory registry keys === [dsh] (non-dsh lanes can never
  obtain the dsh factory), host attestable kind set ↔ server permitlist
  lockstep, interior-comma tolerance + space-voids-whole-header, raw-pair
  513-cap with duplicate pairs, bare-string-part attestation, assistant skip.
…nnel 1 (#7085)

The source-kind attestation channel made the PROTECTION classifier
(durable message path) kind-aware, but the FOLD-DRIFT ACCOUNTING
classifier (oneShotCarrierPaths, fold-reconcile channel 1) was still
marker-only. A host rewording its carrier would therefore keep
protection yet re-break the expected-rebase record: the reworded
carrier misses every text marker, is never recorded as an expected
rebase, and later lands in `missing` — the #5139 O(full-history)
reconcile tax plus a false drift warning, for the whole carrier
family, with no signal.

This closes that residual by mirroring the protection classifier's
pattern exactly:
  - durable-message-guards.ts: oneShotCarrierPathsWithKinds(index)
    (kind-first under the same role/content gates, then the twelve
    text markers as fallback; `undefined` index returns the text-only
    classifier unchanged) + the oneShotCarrierPathFactories registry
    ({ dsh } only, KDD #9).
  - fold-reconcile.ts: ReconcileOptions.inboundMsgKinds carries the
    decoded attestation index; channel 1 consults the lane's factory
    before the prebuilt text-only entry.
  - the four wire sites (prepare-anthropic/google/openai/responses)
    thread the decoded header into reconcileFoldCoverage.

Absent header / rejected header / unmapped kind / fingerprint miss all
degrade to byte-identical pre-channel behavior; the incremental lane
still forwards the header without reading it (v1 boundary unchanged).

Tests: 6 new cases in tests/msgkind-channel.test.ts (factory registry
is exactly { dsh }; factory(undefined) IS the text-only classifier;
attested reworded carrier reaches its oneshot path; unattested
reworded carrier stays unclassified; unattested text keeps marker
classification; assistant role is never a carrier). Full targeted
suites green: msgkind 34, fold-reconcile+5142+5173 91, durable+msgid-pin
45, msgid family 58, fold-reconcile perf/large/positional 30.
…rivation (#7121)

The v1 kind channel (#7085, PR #7104) covered the durable protection
classifier and fold-drift accounting (channel 1), but two marker-
classification surfaces stayed marker-only and go blind when a host
rewords its injections:

1. isDshSingleShotSidecar (src/server/side-request.ts) — a reworded
   carrier in a tool-less single-user body with a <=8192 single-shot
   budget is misrouted to the verbatim side lane, skipping the kernel,
   so the carrier's BLOCKED ref is never stamped (#2419/#2446/#2447/
   #2817/#5403).
2. deriveTitle / isAutoInjectedNotification (src/server.ts) — a
   reworded notification titles the session forever (set-once, #2286).

Both now resolve through the same kind-first expression as the message
classifiers (dshCarrierPathByKind / dshTextUnitIsCarrier,
src/durable-message-guards.ts): fingerprint of the EXACT unit bytes ->
attested kind -> permitlist path. An absent or voided header keeps
every surface byte-identical to pre-channel behavior; unmapped kinds
never rescue. The x-bili-msg-kinds decode in handle.ts moves before
sideRequestLike so the demotion gate can consume it; the prepare
adapters hoist their existing inline decode and feed the title
derivation.

Gate discipline (#3617): both directions pinned in
tests/msgkind-channel.test.ts — attested reworded carrier rescued; no
header = pre-channel verdict; wrong fp / unmapped kind never rescue;
marker/prefix fallback unchanged; a genuine sidecar keeps the side
lane; byte-equality over untrimmed unit bytes.

Also fixes a pre-existing indentation defect in prepare-responses.ts
(foldMode/reconcileFoldCoverage lines at column 0).
@ranxianglei
ranxianglei force-pushed the 2026-11-18_dsh-msg-kinds branch from d6abb33 to a8582ee Compare November 18, 2026 06:20
…(lane-guard, #7120)

The #7120 side-request demotion edit (isDshSingleShotSidecar + kinds)
changed lane logic, so the lane-guard (#2170) requires a dedicated
side-lane suite update. Pin the three cells: attested reworded carrier
rescued to the main pipeline, absent index byte-identical to
pre-channel, wrong-fp / unmapped-kind never rescue.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

CI 归因与处理结论(当前 head a8582ee181,已 rebase 到当前 master 548e396022)

1. windows 测试(你 floor-11 关注的红项)— 已解决

master 已带 3186e54ad2「fix(tests): make the shutdown-signal test portable to Windows (it killed its own child on win32)」。根因:win32 上 process.kill(self, SIGINT/SIGTERM) = TerminateProcess,不运行已安装的 handler,CI 子进程在第一条 kill 行就死了(文件级失败、零 TAP 输出、确定性)。修复:win32 上直接调用已安装的 handler(与 console Ctrl+C 同路径)+ 有界等待替代固定 500ms sleep。commit 信息:「Verified: 4/4 pass on a real win10 box (node v22.23.2), 4/4 on Linux」。

已确认 3186e54ad2 是 a8582ee181 的祖先 → windows 失败已在分支上修复(通过 rebase 到当前 master)。

2. 分支状态 — 干净,无冲突

分支 2026-11-18_dsh-msg-kinds 已 force-update 到 head a8582ee181(你 floor-11 引用的 e8e2d097 是旧 head,rebase 后 hash 变了,已不是祖先)。5 个 commit 在当前 master 548e396022 上,merge-base == master head → 干净,无冲突。

ci-fixes 完全落后于 master(0 commits ahead),且未触碰 tests/server-process-listeners.test.ts → 无需从 ci-fixes 合并任何东西。

3. 新发现 — lane-guard 失败(#7121 commit 引入,在你 floor-11 之后加入)

当前 head a8582ee181 有一个新的 lane-guard 失败(job 完成于 06:29:29Z,运行 13s)。这是新增的:你 floor-11 的 e8e2d097 run 只有 1 个失败(windows),lane-guard 那时是绿的。

原因:#7121 commit(a8582ee181)改了 side-lane 逻辑:

  • isDshSingleShotSidecar(src/server/side-request.ts,side-lane demotion gate)改为 kind-aware
  • 把 x-bili-msg-kinds decode 移到 sideRequestLike 之前(src/server/handle.ts)
  • deriveTitle/isAutoInjectedNotification(src/server.ts)

但只更新了 tests/msgkind-channel.test.ts,没有更新专门的 side-lane suite。lane-guard(#2170,.github/workflows/ci.yml:638-675)要求:side-lane 逻辑变了(src/server/side-request.ts 有 diff,或 src/server.ts/src/server/handle.ts 的 LANE_SYMBOLS 行变了),必须有一个专门的 side-lane suite(tests/(fork-side-request-lane|side-lane-truth-table|side-lane-invariants|side-request-isolation).test.ts)跟着动。

Log 判决(原文):「side-lane logic changed: src/server/side-request.ts, src/server/handle.ts (lane symbols)」→「##[error]Side-lane logic changed without updating any dedicated side-lane suite」。

4. 关键连锁 — fail-fast 分层导致 test matrix 被跳过

当前 head 的 CI run(id=44250660049)有 17 个 job:13 success(guards)+ lane-guard FAILURE + 3 SKIPPED(test matrix、static-gates matrix、red-signal)。

test matrix 被跳过的原因 = fail-fast 分层(#2637),.github/workflows/ci.yml:273-275:

test:
  needs: [plan, version-guard, kernel-guard, pi-subagents-guard, lane-guard, docs-sync, docs-coverage, unused-exports, lock-sync, test-import-graph]
  if: ${{ !contains(github.event.head_commit.message, '[ework:ci-held]') && (!failure() && !cancelled() && needs.plan.outputs.scope != 'skip' ) }}

lane-guard 是 needs 之一,它 failed → !failure() 为 false → test matrix(和 static-gates、red-signal)被 SKIPPED,没跑。

后果:windows 测试在当前 head 没跑(被跳过,不是失败)。当前 head 的唯一根因红项就是 lane-guard 失败。lane-guard 修好后,test matrix 会跑,windows 测试应该过(master 的 fix 已在分支上)。

5. 建议

#7121 commit 需要补 side-lane suite 覆盖(例如在 tests/side-lane-truth-table.test.ts 加一行 attested-reworded-carrier-rescued 的 case,钉住 kind-aware demotion 的双向判决)。这是 #7121 commit 作者(主开发 lane)的内容决策。你拍板后我可以代做,或让 #7121 的 lane 自己补。


8问

  1. 是什么问题:windows 测试失败(test (windows-latest, 22, 4))是 master 继承的失败(PR [PR] batch-2: 4 held Afloat16 fixes (2 as-is, 2 with review-patch commits) #7101 的新测试),不是 PR 回归,已在分支上解决(master fix 3186e54ad2 在分支上)。新发现一个 lane-guard 失败([Drive-by] Marker classification surface not covered by kind channel v1 (channel-2 backfill / side-request degradation / | [Drive-by] kind 通道 v1 未覆盖的 marker 分类面(channel-2 回填 / side-request 降级 / 标题派生) #7121 commit 引入)。
  2. 什么原因导致的:
  3. 影响范围与严重程度:
    • windows 测试:已解决(fix 在分支上),无影响。
    • lane-guard:阻塞 test matrix(fail-fast 分层),PR 无法验证绿。严重程度:中(PR 被阻塞,但修复范围小——补一个 side-lane suite 的 test case)。
  4. 怎么修复的:
  5. 是否有回归问题:
  6. 是否破坏缓存:不涉及。
  7. 是否改了设计方向:不涉及。
  8. 是否引入了新的配置:不涉及。

结论:windows 测试(你关注的红项)已解决。当前 head 的唯一根因红项是 lane-guard 失败(#7121 commit 的内容问题:side-lane 逻辑变了但没更新专门的 side-lane suite)。等你拍板:让 #7121 的 lane 补 side-lane suite 覆盖,还是我代做。

@ranxianglei

Copy link
Copy Markdown
Owner Author

模型 qwen3.8-27b(provider sglang-gpu0)。

用户决定:本 PR 先 hold(关闭)。kind 声明通道方向保留讨论,指纹指针的实现方式因性能疑虑待重新评估后另起方案。分支 2026-11-18_dsh-msg-kinds 保留全部 6 笔提交可随时复用。

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant