Skip to content

[PR] fix(dsh): prevent the latest system prompt in history from being collapsed | fix(dsh): 让最新的历史内系统提示不被折叠 - #6353

Open
BBleae wants to merge 6 commits into
ranxianglei:masterfrom
BBleae:2026-11-12_dsh-durable-system-prompt
Open

BBleae wants to merge 6 commits into
ranxianglei:masterfrom
BBleae:2026-11-12_dsh-durable-system-prompt

Conversation

@BBleae

@BBleae BBleae commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

Fixes #6352

问题

在 dsh 车道上,如果 compress 的范围覆盖了最新的历史内系统提示(in-history system prompt),这条提示会被折叠(fold)进摘要(summary)。从那时起,直到提示文本再次变化,模型一直按过期的头部提示运行。没有报错,也没有日志。

这条消息为什么重要:渲染出的系统提示变化时,DeepSeek Harness 并不总是重写第一个 system 节点。在模型把后面的 system 消息当作有效提示的路由上(systemPromptUpdate: "in-history"),它会在缓存历史之后追加一条完整的新 system 消息。顶层的 system 字段保留旧文本,最新的历史内 system 消息才是正在生效的提示。

billion-context 把这条消息当作普通历史。hasUnrecoverableMediaPayload 只固定结构化的 system 消息("Plain-text ones … fold like any text message",纯文本的……和普通文本消息一样折叠),而 dsh 的持久(durable)分类器(src/durable-message-guards.ts)认识四种载体(carrier),都在 user 通道上。所以模型发起的 compress 调用和代理(proxy)发起的折叠都可能覆盖到它。

这个 PR 恢复了什么,没恢复什么

改动之后,最新提示的文本总会留在转发的请求里。它的角色取决于 wire:

这个形态从哪里来(deepseek-harness 源码,MIT,标签 dsh-v0.2.2-rc.2;与 rc.1 相比没有变化)

  • packages/core/agent-loop/src/runtime-context.ts,SystemPromptProjection.project:"A capable continuing series appends changed nonempty text after the cached history."(一个有能力的连续序列会把变化后的非空文本追加在缓存历史之后。)只有在不支持的路由、提示被清空、或者文本不同的新请求序列这三种情况下,才会重写第一个节点。
  • packages/llm/llm-deepseek/src/serialize.ts:在历史内路由上,非开头的 system 消息会变成 { role: "system", content: [{ type: "text", text }] },排在 user / tool-result 轮之后、下一条 assistant 之前;只有位于开头的 system 才会成为顶层的 system。它的 tests/adapter.spec.ts 固定了结果:提示变化后,body.system 仍是 first prompt,messages 里带着 { role: "system", content: [{ type: "text", text: "second prompt" }] };清空再恢复之后,请求里唯一的提示就是那条历史内消息。
  • packages/llm/llm-pi-ai/src/models.ts(conversationUpdates)和 context.ts:对声明了 supportsMidConvoSystemMessages 的目录模型,同样是历史内模式。它的 tests/conversation-updates.spec.ts 固定了各 wire 的形态:Anthropic Messages 和 chat-completions 用 role: "system",responses API 用 role: "developer" 加字符串内容。
  • dsh 核心里产生 system / developer 消息的只有两处:SystemPromptProjection(system)和 agent.ts 里的工具注册表更新(developer;只有 tool-addition / tool-removal 块,没有文本)。

复现

tests/dsh-system-prompt-durable.test.ts,本 PR 新增。在 master c26c31ac 上它的 14 个测试里有 9 个失败(新导出被桩成返回 undefined,以便文件能加载);通过的 5 个是分类器的反例,以及对必须保持不变的行为的固定。

  • 编解码层:一个 llm-deepseek 形态的 Messages 请求体(头部提示在顶层字段,两次历史内更新,一条 tool-delta system,一个实时请求),经 anthropicToCore 和 applyCompression,使用 dsh 车道配置。在 master 上,最新提示的 id 落在新建的块里面。
  • 真实折叠:在 dsh 车道上对 startServer 跑八轮,两次历史内提示更新,经 /__bili/plugin/tool 做一次范围覆盖这两条的 compress,再跑一轮。在 master 上,转发给上游的请求里不再有最新的提示,Messages wire 和 chat-completions wire 都是如此。

改动

在 dsh 车道分类器里增加第五种持久身份:durable/system-prompt(dshSystemPromptPath),归现有的 durable/* 按身份保留最新一份的默认规则管。最新的一份被固定;被后来的副本顶替的(superseded)副本和普通历史一样折叠。

判定条件:role === "system",内容是文本,非空,并且

  • 不是结构化的 system。这里复用 hasUnrecoverableMediaPayload 而不是重新写一遍,所以这条规则和内核对 tool-delta / 仅指令 system 的硬固定在构造上就是不相交的,在提示之后到达的 tool delta 也不可能占掉提示的最新位置;
  • 不是 bili 自己的摘要载体(渲染角色为 system,KDD feat: bili CLI + debug in config + README rewrite #7)。

分类器按角色匹配,而不是按文本标记,因为系统提示没有稳定的标记:它是任意的宿主和插件文字。这里角色是比标记更强的证据。它由宿主的序列化器打上;人的输入总是走 user 通道,模型输出总是走 assistant 通道,所以用户消息和模型回声(#2766)都产生不出它。头部提示在每个编解码器里都会被提到折叠空间之外,因此 dsh 车道里 system 角色的核心消息就是历史内的那种。

新身份在那十二个标记分类器之前被查询。它们的角色门只拒绝 assistant,所以在 master 上,引用了某个载体标记的系统提示(比如一份讲解 skill 目录标签的提示)会被投影成那个载体的身份,并且因为更新,从真正的 user 通道载体手里抢走最新位置。由角色决定的身份排在前面之后,这条提示保有自己的固定,真正的载体也保有自己的位置(测试:"the four durable carriers keep their own latest slot next to the prompt",在 master 上为红)。

行为变化,仅限 dsh 车道(旧 → 新)

消息 master 本 PR
最新的纯文本历史内 system 可折叠 固定(保留一份)
被顶替的纯文本历史内 system 可折叠 可折叠
文本里含有载体标记的纯文本 system 取得那个载体的身份 durable/system-prompt
结构化 system(tool delta、仅指令) 内核硬固定 内核硬固定,不进分类
那十二个 user 通道载体、assistant 回声 与现在相同 与现在相同
Rule-3 最后一条 user 锚点 最新的人类请求 相同(system 消息从来不是候选)

不变的部分

  • 其他车道:没有分类器,纯文本的历史内 system(Claude Code 的环境说明等)仍会折叠。两种 wire 上都有测试固定。
  • oneShotCarrierPaths / dshCarrierRawMarkers(预期重基线的核算):没有改动;被顶替的提示副本的核算与以前完全一致。那条链仍然没有 system 角色这一步,所以含有载体标记的 system 角色文本,在位置链里算提示,在漂移核算里算那个标记的载体。这是已有的漂移处理方式,源码里有注明,测试文件里也有固定。
  • 整个身份被接管:用户如果配置过任何 durable/… 模式,仍然没有默认值;durable/system-prompt 可以像另外四个一样被点名(已测试)。
  • 两种压缩模式:分类器喂给 Config.messagePathOf,内核在每个判定可折叠性的地方都会查它(compress、unit-projection、recommend、absorb),所以模型发起的折叠和代理发起的折叠由同一条规则覆盖。没有改动任何 wire、工具注入或摘要载体的代码。

按 wire 的适用范围

规则作用在内核核心的角色上,所以与 wire 无关。各 wire 的证据:

配置面

没有新字段、环境变量或 CLI 标志。只在现有的 durable/ 虚拟路径命名空间里多了一个名字,可通过现有的 protectedTools / protectedLatestTools 模式访问。src/config.ts 里 protectedLatestTools 上方的注释列出了这个身份;gen-config-docs generate 没有产生漂移。

内核

kernel/** 下没有改动。分类器导入了两个现有的内核导出(hasUnrecoverableMediaPayload、SUMMARY_HEADER)。

现场证据

一个长期运行的 dsh 会话,九天窗口,只统计结构性数量:143 份历史内系统提示副本;其中 18 到 37 份(两种计数方法分别取交集和并集)在仍是最新副本时被一个新建的块覆盖;按交集计数,这些时段跨越 6,206 个模型请求中的 2,919 个。

相关

未覆盖的部分

  • Messages wire 上留下来的提示的角色(见第二节)。要在那里保持 system 角色,需要改内核(迁移位置,就像 [PR] EN | kernel: relocate misplaced tool-delta systems instead of demoting them (fixes #4818) #5800 对 tool-delta system 做的那样),我没有尝试。需要的话我可以另开 issue。
  • 不会追溯取消折叠。 如果最新的提示已经被早期版本构建出的块覆盖,它会保持被覆盖:prune 丢弃已覆盖的 id 时不查保护,之后的合并会把已被消耗的块的覆盖范围(range)整个接过来(用一次性探针检查过:旧版本折叠,然后在新配置下渲染并合并;两种情况下提示都保持隐藏)。这样的会话要等 dsh 发出下一次提示更新才能恢复。
  • token 成本。 最新的副本永远不会被折叠,所以它的大小永远不在模型发起或代理发起的折叠能回收的部分里。作为参照,Non-leading system messages are demoted to regular history messages, causing the system prompt to accumulate progressive | 非首位的 system message 被降级成普通历史消息,导致 system prompt 逐步累积 #6193 报告过一份 45,463 个字符的提示。我没有检查紧急截断的路径。
  • 带文本的 developer 消息。 dsh 核心没有这样的发出者(它的工具注册表更新只带工具块)。如果某个插件发出了一条,只要序列化器把文本作为单独的纯文本项发出,它就会取得提示身份:llm-pi-ai 在 chat-completions 和 responses 上就是这样做的,即使该消息同时带有工具块(它的 spec:{ role: "system", tools } 后面跟着 { role: "system", content: "…" });在 Messages wire 上只有纯文本的 developer 消息会这样(文本加工具块仍是一条结构化 system)。
  • 漂移核算:宿主在重新基线一个请求序列时淘汰的提示副本,核算方式不变,没有测量。

验证

Node 22.23.3,Windows,隔离的家目录,出站网络被阻断(任何一次运行都没有记录到被阻断的请求)。

  • 新文件:14/14。
  • 导入了被改模块的 11 个测试文件:80 个测试,78 通过,2 跳过,0 失败。
  • 第一个提交上更大范围的定向运行(所有引用了 dsh 车道或持久守卫的测试文件,加上历史内 system 的套件,共 85 个文件):1008 个测试,998 通过,6 跳过,4 取消。4 个取消全在 tests/dsh-native.test.ts,该文件在未修改的 master 上同样时序不稳(5 次基线运行里有 2 次取消同样的 4 个;该文件不导入被改模块)。第二个提交只改了注释和新测试文件。
  • npm run typecheck、npm run build:干净。check-unused-exports、check-test-import-graph、config-surface-guard、check-architecture-docs:干净。
  • 本地没跑:完整套件和 e2e 车道(按 AGENTS §7.2 留给 CI)。

On routes whose model reads a later system message as the effective
prompt, dsh does not rewrite the first system node when the rendered
prompt changes: SystemPromptProjection appends a complete system message
after the cached history, and the Messages serializer ships it as a
plain-text role:"system" message after the user turn. The newest such
message is the prompt in force. ACP folded it like any plain-text
message, so one compress range covering it left the model on the stale
head prompt until the text changed again.

Add a fifth durable identity to the dsh lane classifier,
durable/system-prompt (dshSystemPromptPath), under the existing
durable/* latest-per-identity default: the newest copy is pinned,
superseded copies stay foldable. The criterion is the role (no text
marker exists for a prompt): a non-empty plain-text system-role core
that is neither bili's own summary carrier nor a structured system.
Structured systems keep the kernel's hard pin; the classifier reuses
hasUnrecoverableMediaPayload so the two rules cannot overlap and a tool
delta arriving after the prompt cannot take its latest slot.

The identity is consulted before the twelve marker classifiers. Their
role gate only refuses the assistant role, so a system prompt that
quoted a carrier marker used to project to that carrier's identity and
take the latest slot from the real user-channel instance.

Host layer only: no change under kernel/, no config field, no wire or
persistence change. Other lanes keep folding plain-text in-history
systems. oneShotCarrierPaths (drift accounting) is unchanged.
… limits

Follow-up to the durable/system-prompt identity, from review.

Tests:
- Messages wire end-to-end: assert the role the kept prompt is forwarded
  with. Once the fold removes the assistant that followed it, the
  kernel's position heal re-voices a plain system as user, so the text
  survives and the system role does not. Pinned as a known limit; a
  kernel that relocates instead of demoting flips the assertion.
- Lane wiring: drop the "registry keys are exactly [dsh]" pin (another
  lane registering a classifier is not this test's business) and assert
  instead that no other lane projects a plain-text system.
- Drift registry: pin that system-role text containing a carrier marker
  is still accounted by marker there, as before the identity existed.
- The chat-completions scenario cites the llm-pi-ai wire test it mirrors.

Comments only in src/durable-message-guards.ts: where a developer
message carrying text would share the identity (llm-pi-ai splits the
text off on chat-completions and responses), and that the drift chain
has no system-role step.

Devlog: no retroactive unfold for prompts already covered by a block
from an earlier build, the token cost of a never-folded copy, and the
corrected red count on master (9 of 14).
Copilot AI balanced review requested due to automatic review settings November 12, 2026 05:22

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Note

Copilot was unable to complete this review at the selected tier due to model policy or plan restrictions.

🟡 Changes recommended

A moderate active issue remains in src/durable-message-guards.ts where using msg.text.trim() as a whitespace check can unnecessarily allocate large strings (e.g., ~45K chars) and create avoidable memory churn in a repeatedly-invoked path, so a non-allocating whitespace test is needed.

1 open issue
What changed in this PR

Fix a dsh-lane correctness bug where the latest effective in-history system prompt could be folded into a summary, causing requests to run with a stale head prompt until the prompt text changes again.

Changes:

  • Add a new dsh durable identity durable/system-prompt to preserve the newest plain-text in-history system prompt while keeping superseded copies foldable.
  • Prioritize this identity ahead of marker-based durable carriers to prevent carrier-slot takeover.
  • Add regression coverage for classifier behavior, compression geometry, and real folding on both Messages and chat-completions wires, plus update inline docs/devlogs.
File Description
tests/​dsh-system-prompt-durable.test.ts Adds a new regression test suite validating that the newest in-history system prompt is preserved through classification and real compression for Messages and chat-completions wires.
src/​durable-message-guards.ts Introduces dshSystemPromptPath (durable/system-prompt) and wires it early in the dsh classifier so the latest plain-text system prompt is protected from folding.
src/​config.ts Updates configuration documentation comments to include the new durable/system-prompt identity alongside existing dsh durable carriers.
devlog/​2026-11-12_dsh-durable-system-prompt/​WORKLOG.md Documents the investigation, implementation notes, testing performed, and known limitations for the dsh durable system-prompt change.
devlog/​2026-11-12_dsh-durable-system-prompt/​REQ.md Captures the requirements, acceptance criteria, and explicit non-goals for preserving the latest in-history system prompt in dsh.

Review effort: Balanced

Comment thread src/durable-message-guards.ts Resolved
@ranxianglei ranxianglei changed the title fix(dsh): 让最新的历史内系统提示不被折叠 [PR] fix(dsh): 让最新的历史内系统提示不被折叠 Nov 12, 2026
@ranxianglei ranxianglei changed the title [PR] fix(dsh): 让最新的历史内系统提示不被折叠 [PR] fix(dsh): prevent the latest system prompt in history from being collapsed | fix(dsh): 让最新的历史内系统提示不被折叠 Nov 12, 2026
dshSystemPromptPath used msg.text.trim().length > 0 only to ask whether
the text has any non-whitespace character. trim() allocates a copy of
the whole prompt (tens of thousands of characters in the reports that
motivated the identity), and the classifier is consulted repeatedly
during protection and fold checks. /\S/.test(msg.text) answers the same
question (same whitespace set as trim) without the copy.

No behavior change; the existing negatives (empty and whitespace-only
system nodes) cover it. From review on the PR.
@ranxianglei

Copy link
Copy Markdown
Owner

先不跟批次(#6455)一起合,单独留在这里审。原因:

这是 8 个 PR 里唯一引入新折叠语义的一个——新增第五个 durable 身份 durable/system-prompt,改变的是"哪些消息允许被折",影响面比其他七个(纯 bug 修复)大一档。

review 下来的具体关注点:

  1. 身份判定靠角色,但角色本身不区分 head 和 in-history。安全的前提是 wire 解码器把开头连续的 system 前缀提升出折叠空间(kernel/src/wire/openai.ts 等,既有行为)。这个耦合目前是成立的、测试也钉了一条断言(leading system 不进 core),但它是一条跨模块的隐式契约——将来任何一条路线如果放出第三种 system 文本消息(既不是 head 也不是 prompt 更新),会被静默钉住,而且 prompt 分类器排在所有 marker 分类器之前,会抢走真载体的 latest 槽位。
  2. 行为是双向的:最新一条 in-history prompt 从"可折"变"必钉"(token 成本上升);被取代的旧副本从"未分类、按普通规则走"变成"显式可折"(drift 记账有变化,PR 里也承认这部分还没实测)。
  3. 方向上我认同(prompt 被折掉 → 模型一直用旧提示词,这个 bug 是真的),但新身份的引入值得单独过一遍:是否需要按路线收窄(只对已有流量证据的 in-history 路线启用),或者先只加"旧副本可折"的一半、钉住的一半再观察。

不着急合。owner 会在这个 PR 上继续审,有结论会回复。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

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

查重: 不重复。 这是修 #6352 的独立 PR,与 #6193(成本/内核去重)、#4818/#5800(结构化 tool-delta system)、#4172(coreToAnthropic 角色)相关但机制不同——本 PR 只动宿主层 dsh 的 durable 分类,不碰内核、不碰 wire、不做去重。

我独立复现了 bug 并验证了修复,针对你(floor 2)的三点关注逐条给证据。

独立验证(不依赖 PR 作者环境)

  • bug 真实:在 master c26c31ac 上用 master 自己的导出(durableMessageToolPaths.dsh + withDurableProtection + applyCompression)写最小复现——头部提示在顶层 system、两次历史内 system 更新,compress 覆盖后最新的 PROMPT-REV-3 确实被折进新块。复现通过。
  • 修复有效:PR 分支上新测试文件 14/14 通过;导入被改模块的 10 个测试文件 66/66 通过。
  • CI 绿:head 5a4423f067 上 88 个 check run = 59 success + 29 skipped(门控 e2e)+ 0 failed。
  • stale base 无碍:PR 落后 master 90 commit,但 src/durable-message-guards.ts 与 src/config.ts 自 base 起在 master 上未被改动,可干净 rebase(mergeable_state: behind 不是阻塞项)。

关注点 1 — 角色身份 vs head/in-history(跨模块隐式契约)
我读了三个 wire 编解码器,契约今天确实成立:

  • kernel/src/wire/openai.ts:66-105:开头连续的 system/developer 前缀提升到 systemParts,注释明说 "Mid-conversation system messages (rare, host-synthetic) stay in the fold space unchanged"。
  • anthropic 编解码器:头部提示在顶层 system 字段。
  • kernel/src/wire/responses.ts:297-305:sysDevHead 标志。

所以 dsh 车道上 system 角色的 core 消息就是历史内的那种——隐式契约今天成立,且被测试断言钉住(leading system 不进 core)。

你担心的"将来第三种 system 文本消息会被静默钉住"是真实残余风险,但有三道现有防护:① 分类器只在 dsh 车道接线(durableMessageToolPaths 只有 dsh 键),其他车道不受影响(测试钉住);② dsh core 里产生 system/developer 的只有两处(SystemPromptProjection、工具注册表更新——后者只有 tool 块无文本),PR 作者从 deepseek-harness 源码核实过;③ 整个身份可被用户接管(任何 durable/… 模式配置下来就没有默认值,durable/system-prompt 可被点名,已测试)。

"prompt 分类器排在 marker 分类器之前会抢真载体的 latest 槽位"——这正是 PR 要修的(master 上含载体标记的 system 提示会被投影成那个载体的身份并抢槽),PR 用测试 "the four durable carriers keep their own latest slot next to the prompt" 钉住了修正后的行为。

关注点 2 — 行为双向

关注点 3 — 按路线收窄 vs 先只加可折一半

代码质量(⑤b 外部提交从严):通过。命名遵循 dsh<X>Path 约定;无死代码;复用内核导出(无重复);doc-comment 风格与文件既有证据化纪律一致;无新依赖;perf commit 行为中性(/\S/ 正则 vs trim().length>0,同一空白集)。

测试有效性(④):有牙。三层——分类器行(正反双向,#3617);折叠几何(经真实编解码器 + applyCompression);真实 8 轮折叠(经 /__bili/plugin/tool,以转发 body 为断言面);车道隔离(未注册车道)。bug 回归时测试会失败。


结构化八问

  1. 是什么问题:dsh 车道上,compress 覆盖最新的历史内系统提示时,该提示被折进摘要,模型此后一直按过期头部提示运行,无报错无日志。
  2. 什么原因导致的:纯文本历史内 system 消息既不被 hasUnrecoverableMediaPayload 固定(它只固定结构化 system),也不被 dsh 的四个 user 通道 durable 分类器识别,于是按普通历史被折。
  3. 影响范围与严重程度:仅 dsh 车道、in-history 提示更新路线。现场证据:9 天窗口 143 份副本中 18–37 份在仍是最新时被覆盖,跨 6,206 个请求中的 2,919 个。严重度:模型静默用过期提示——正确性缺陷,非崩溃。
  4. 怎么修复的:在 dsh 车道分类器增加第五个 durable 身份 durable/system-prompt(dshSystemPromptPath),按角色判定(非标记),排在 12 个 marker 分类器之前,归现有 durable/* 按身份保留最新一份的默认规则管;最新一份被钉,被顶替副本照旧可折。
  5. 是否有回归问题:审过的既有行为——其他车道(无分类器,纯文本历史内 system 仍折)、四个 user 通道载体、assistant 回声、结构化 system(内核硬固定)、Rule-3 锚点(system 消息从来不是候选)、oneShotCarrierPaths drift 记账——全部保持不变,均有测试钉住。无回归。
  6. 是否破坏缓存:不。提示字节跨请求稳定(宿主逐字重发),折叠点本身的缓存失效是折叠固有的、非本 PR 引入;被顶替副本照旧可折。
  7. 是否改了设计方向:无架构转向。在既有 durable-identity 机制内扩一个身份,遵循既有模式(KDD release v0.1.2 #9 证据白名单、[Feature] Per-skill compression protection: static per-name config + dynamic skill_pin/skill_unpin + cascade adoption #1947 规范投影)。唯一结构性新增:按角色判定的身份(vs 按标记)——同一机制内的新证据类型,PR 已说明为何此处角色是更强证据。
  8. 是否引入了新的配置:无。无新字段/env/CLI 标志;只在既有 durable/ 虚拟路径命名空间多一个名字,可经既有 protectedTools/protectedLatestTools 模式访问;src/config.ts 改动仅注释。

建议:按现状可合。bug 真实、修复最小且测试充分;Messages wire 上角色降级是内核既有行为且已钉住,内核侧的位置迁移是独立的(kernel-gated)后续,PR 作者已表示可另开 issue(按本线程规则我不自行开,留给你决定)。你 floor 2 保留的两个选项,证据结论是:「按路线收窄」在分类器层不可表达且不需要,「先只加可折一半」等于什么都不加——所以有意义的选择是「按现状合 vs 等内核侧角色迁移先做」,我推荐前者。

dshSystemPromptPath excludes an empty node by looking at the core's
text. That text is not the host's bytes in two places, and in both an
empty system node read as non-empty, took the durable/system-prompt
identity and, when it came after the prompt in force, its latest slot:

- The Messages codec gives an empty system message the placeholder
  text "[system]" (the same value seeds the id). An empty string
  content and a single text block with empty or missing text were
  therefore not excluded on that wire, and the prompt before such a
  node was foldable again.
- A view rendered with ref tags puts the tag in front of a numbered
  message's text, so there an empty node read as non-empty on all
  three wires. The plugin tool endpoint classifies that view for its
  status and recommendation recompute, with the wrong protection set;
  the fold itself reads the raw view where it has one.

hostSentSystemText asks the verbatim wire sidecar that the Messages,
chat-completions and responses codecs attach to an in-history system
(rawAnthropicMessage, rawOpenaiMessage, rawResponsesItem) whether the
host sent any non-whitespace text; a core without a sidecar is judged
on its text, as before. It is not a comparison against the placeholder:
a host that really sends those eight characters keeps the identity. The
change only narrows what the identity matches. No kernel change.

Tests go through the real codecs: the empty Messages shapes, an empty
node after the prompt in a fold, and the rendered view on each wire.
Three of the sixteen fail on the previous head.

Empty in-history system nodes are recorded on the chat-completions wire
(tests/issue4778-dsh-goal-subfork.test.ts). The dsh 0.2.2-rc.2 package
puts none on the Messages wire, so there this closes the documented
exclusion rather than a reported failure.
@BBleae

BBleae commented Nov 15, 2026

Copy link
Copy Markdown
Contributor Author

(ai: anthropic/claude-fable-5-2)

补了一个提交(139010f3)。起因是顺着关注点 1 里说的抢占 latest 槽位,把我自己注释里写的第三条排除(空节点不算提示)放到真实的编解码器上重查了一遍:有两处没有生效。

1. 改了什么

dshSystemPromptPath 判断「有没有文字」看的是 core 的 text,而 text 在两个地方不等于宿主发来的字节:

  • Messages wire 的编解码器给空的 system 消息填了占位文字 "[system]"(kernel/src/wire/anthropic.ts 的 systemMessageText,id 种子用的也是它)。所以 content: "" 和「只有一个 text 块、文字为空或没有 text 键」这两种形状,在这条 wire 上没有被排除。这样的节点排在生效的提示后面时,会占掉 latest 槽位,提示重新变成可折。
  • 带 ref 标签的渲染视图(processTurn 的 renderTags)在有编号的消息的 text 前面加了标签,所以空节点在那个视图里,三条 wire 上都显得有文字、被认成 durable/system-prompt。插件工具端点拿这个视图做状态和推荐的重算,保护集合因此不对;折叠本身读的是原始视图(有原始视图时),chat-completions 和 responses 的原始视图是对的,空内容的 text 就是空的。

改法:新增模块内的 hostSentSystemText,按 Messages、chat-completions、responses 三个编解码器挂在历史内 system 上的 verbatim sidecar(rawAnthropicMessage、rawOpenaiMessage、rawResponsesItem)判断宿主有没有发非空白文字;没有 sidecar 的 core 照旧看 text。它不是和占位文字做比较:宿主真的发那 8 个字符,仍然算提示。源码只动 src/durable-message-guards.ts,不碰 kernel。这个提交只让这个身份少认几种形状,没有多钉任何东西;空节点本身回到普通历史(有编号、可折),和 master 上、以及没有分类器的泳道上一样。

2. 这种节点哪里会出现

tests/issue4778-dsh-goal-subfork.test.ts 记录过 DSH NEXT 在 chat-completions 上重发持久化的空 system 条目({ role: "system", content: "" })。Messages wire 上,我核对的 dsh 0.2.2-rc.2 安装包发不出空的 system 节点:清空的提示节点内容为空,不产生 wire 消息(packages/core/session/src/surface.ts);llm-deepseek 的序列化器遇到空的历史内 system 更新直接报 unsupported(packages/llm/llm-deepseek/src/serialize.ts)。所以在 Messages wire 上,这个提交是把注释里写的那条排除补成真的,不对应某个已经报告的故障。

3. 和关注点 1 的关系

和关注点 1 是同一类后果(latest 槽位被抢),成因不同:不是宿主放出了另一种有文字的 system 消息,而是 text 里有编解码器或渲染加上去的字。这个提交只排除这一种。关注点 1 的主体没有变:判定依据还是角色,某条路线将来放出另一种有文字的 system 消息,仍然会拿到这个身份(WORKLOG 的 Risk points 里照旧写着)。另外要说明:分类器现在直接读了三个 sidecar 的 content 形状,比原来多一处对 kernel 数据形状的依赖。

4. 测试

tests/dsh-system-prompt-durable.test.ts 从 14 项到 16 项,新增的都经过真实的编解码器:Messages 的几种空形状、折叠时排在提示后面的空节点、三条 wire 上的渲染视图。换回上一个 head 5a4423f0 的源码,16 项里有 3 项失败。把新函数分别改坏三处(some 换成 every、去掉对块文字类型的判断、只读 Messages 的 sidecar),各有一项失败。

本地重跑:typecheck、check-unused-exports、check-test-import-graph、config-surface-guard 干净;导入这个模块的 10 个测试文件共 80 项全过。npm run build、check-architecture-docs、gen-config-docs 和第一个提交时跑的那 85 个文件没有重跑。

5. 本地运行的观察(和这个提交无关,供关注点 2、3 参考)

在 v0.1.213 上移植了本 PR 第一个提交的同一处改动(后两个提交一个只加测试和注释,一个是等价写法;这次的提交不在里面),从 11-12 起跑在一个长 dsh 会话上(Messages wire)。

看到的(到 11-15 上午为止):装上以后新建了 42 个块,其中 2 次的范围跨过了当时还在请求里的历史内系统提示,两次它都不在新块的消息清单里;没有任何一个块的清单里列着当时在请求里的提示。

没看到的:没有抓请求体。第一次跨过之后的请求还带着它,是从用量记录里缓存命中的位置推出来的,只在取样到的几次请求上成立;它发出去时的角色(system,还是被位置修复改成 user)没有看到。中间有约一个半小时请求里没有历史内提示(原因没查),那一段建的块不在上面的 2 次里。

这个会话每个请求里至多一份历史内提示(本地另有一个插件只留最新的一份),所以「被取代的旧副本照旧可折」和 drift 记账这一半,这次运行没有走到。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

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

查重: 不重复 —— 同一 PR(GitHub #6353)上的新提交 139010f3,不是新线程/新 PR;上一轮 review 的查重结论继续有效。

我独立验证了这条提交的所有关键声明。结论先行:修法正确、测试有牙、narrowing-only(只让这个身份少认形状,没有多钉任何东西);owner 关注点 1 被部分缓解(「latest 槽位被抢」类的一例),主体未变。

独立验证(本地复现,不依赖你的报告)

  • 占位与 sidecar 机制:kernel/src/wire/anthropic.ts:324-331 systemMessageText 确实对空 system 返回 "[system]";rawAnthropicMessage 挂在每条历史内 system 上(anthropic.ts:320),chat-completions(openai.ts:108)、responses(responses.ts:320)同理;responses 的 split-core 只针对 user(responses.ts:332-345),所以 system core 永远带 sidecar。
  • 渲染视图保留 sidecar:kernel/src/render-refs.ts:133-134 是浅拷贝 { ...message, text: prefix + cleanText },sidecar 字段不丢——渲染视图里也能读到 sidecar,「渲染视图误判」这半的修法成立。
  • 插件工具端点确实用渲染视图:src/server.ts:3057 的 /__bili/plugin/tool 走 processTurn({ renderTags: "text-only" }),你的动机描述属实。
  • chat-completions/responses 原始视图的空形状本来就对:stringContent(openai.ts:596-608)把空/缺失 text 压成 "",与你的描述一致。
  • issue4778 的空 system:tests/issue4778-dsh-goal-subfork.test.ts:82 确实记录了 DSH NEXT 在 chat-completions 上每轮重发 { role: "system", content: "" }。
  • 测试:新 head 上 16/16 通过;换回上一个 head 5a4423f0 跑同一文件,3/16 失败——你「Three of the sixteen fail on the previous head」的说法准确。导入被改模块的 10 个测试文件 64/64(含新文件共 80,与你的计数一致)。
  • CI:新 head 139010f3 上 32 个 check run 已出(12 success + 9 skipped + 11 queued,0 failed)——还在跑,最终绿未确认。
  • as 转型:sidecar 字段不在 CoreMessage 类型声明里(kernel/src/types.ts:8),转型是必要的,且与内核自身风格一致(openai.ts:479 同款写法),不是 as any。

代码审查(⑤b 外部提交从严):通过。hostSentSystemText 每条路径 null-safe;无分配(每次保护检查都跑,只是属性读 + 小数组扫描);some 语义正确(一个 text 块有文字 ⇒ 提示,padded 用例钉住);与 hasUnrecoverableMediaPayload 的 AND 链保持结构化 system 被排除(图像块 system 两条规则都不认)。narrowing-only 语义成立:sidecar 有文字 ⇒ 编解码器必然把文字放进 msg.text ⇒ 旧代码也认;新代码只去掉「sidecar 说空但 text 非空」的匹配。测试双向钉住(宿主真发 "[system]" 这 8 个字符仍是提示;三种空形状被排除)。

你诚实标注的新依赖:分类器现在读 sidecar 的 content 形状——比原来多一处对 kernel 数据形状的依赖。我的评估:sidecar 是 verbatim wire 数据(内核的字节保真机制),只读;无 sidecar 时退回旧的 text 判定——将来内核若改 sidecar 形状,分类器退化到本提交前的行为,不会崩。可接受。

你的现场观察(v0.1.213,42 块,2 次跨过当时生效的提示且都不在块清单里):我无法独立复现(你的本地环境),方向上与修法一致。两点备注:① 提示重发时的角色(system 还是被位置修复降成 user)没有观察到——这正是 Messages wire 的已知限制,e2e 测试已钉住;② 「被取代旧副本照旧可折」和 drift 记账这一半这次运行没走到(你本地插件只留最新一份),这一半仍靠编解码层测试 + master 行为基线。

与 owner 三点关注的关系

  • 关注点 1:本提交修掉「latest 槽位被抢」类的一例——成因不是宿主放出另一种有文字的 system 消息,而是编解码器/渲染往 text 里加了字,让空节点显得有文字。主体未变:判定依据还是角色,某条路线将来放出另一种有文字的 system 消息,仍会拿到这个身份(WORKLOG 的 Risk points 照旧准确)。
  • 关注点 2/3:无变化——narrowing only,没有多钉任何东西,drift 记账未动。

结构化八问(针对本提交)

  1. 是什么问题:第一提交的空节点排除看的是 core 的 text,而 text 在两处不等于宿主发来的字节(Messages 编解码器的占位 "[system]"、渲染视图的 ref 标签前缀),空 system 节点被误认成提示、抢走 latest 槽位,让真正生效的提示重新可折。
  2. 什么原因导致的:判定信号取自投影层(text)而非源头层(宿主字节);编解码器占位与渲染标签前缀都会写进 text。
  3. 影响范围与严重程度:仅 dsh 车道、仅「空历史内 system 节点」形状——Messages wire 三种空形状 + 三条 wire 的渲染视图。严重度:第一提交的修复在这些形状上部分失效(提示重新可折),正确性缺陷;但 dsh 0.2.2-rc.2 在 Messages wire 上不发空 system(chat-completions wire 有 [bug][dsh] Goal auto-continuation forks the main conversation into an empty |sub: lane → ~6M-token preflight, session ne | [bug][dsh] Goal auto-continuation forks the main conversation into an empty |sub: lane → ~6M-token preflight, session never replies… #4778 记录),所以这是把注释里写明的排除补成真,不是修已报告的故障。
  4. 怎么修复的:新增 hostSentSystemText,读三个编解码器挂的 verbatim sidecar(rawAnthropicMessage/rawOpenaiMessage/rawResponsesItem)判断宿主是否发了非空白文字;无 sidecar 的 core 退回旧 text 判定。不与占位文字做比较(宿主真发那 8 个字符仍是提示)。
  5. 是否有回归问题:审过的既有行为——非空提示识别(不变,双向钉住)、结构化 system 排除(AND 链不变)、四个 user 通道载体、assistant 回声、Rule-3 锚点、drift 记账(未动)、其他车道(未动)——无回归。唯一行为变化:空节点从「被认成提示」(第一提交后的状态)回到「普通历史」(master 状态)。
  6. 是否破坏缓存:不。缓存/重试/游标/去重机制未动;身份收窄只影响哪些消息受折叠保护。
  7. 是否改了设计方向:不。仍在 durable-identity 机制内;唯一增量是判定信号从投影层移到源头层(sidecar),是修正不是转向。
  8. 是否引入了新的配置:不。

结论:本提交通过审查——机制正确、测试有牙(旧 head 3/16 红)、narrowing-only、无回归。待办:新 head 的 CI 跑完确认绿(当前 11 queued)。owner 的合并决策仍悬置;本提交不改变我上一轮的建议(按现状合),只是让修复更完整。

hostSentSystemText asked for a string in a text block. A plain text
block whose text is not a string is off-spec, but the Messages and
chat-completions codecs stringify it into the core's text and the
kernel still counts the message as plain text, so the text-only rule
of 5a4423f matched it and 139010f did not: one more shape than the
empty node left the identity.

A block's text is now read as those two codecs read it: a missing or
null value is empty, any other value is stringified. The sidecar
reading then takes the blank node, and nothing else, out of what the
core's text matched.

The sidecar is read after hasUnrecoverableMediaPayload instead of
before it, so the conversion only meets a block text the codec already
converted at decode. Read first, it would also meet the blocks of a
structured system whose text the codecs never read, and throw on a
JSON object whose own toString is not callable; the kernel calls the
classifier without a try. On the responses wire the kernel's plain-text
test admits string text only. Where neither order throws, the result
is the same.

Found by sweeping content shapes through the codecs (system and
developer items, the three wires, raw view) against the text-only
rule. On 139010f the two differ on the Messages placeholder rows and
on a text block whose text is an object, a number, a boolean or an
array holding a string; with this commit only on the placeholder rows.
In neither does the classifier match where the text-only rule does not.

Tests, through the real codecs: two rows in the positives (the object
text; they fail on 139010f), and in the negatives a null text, an
empty-array text and two structured systems carrying a text that
cannot be converted. Five single-point mutations each fail one test:
dropping the null check, testing for undefined only, counting any text
that is not a string as text, reading the sidecar first, and some to
every.

WORKLOG also records a local merge with master 26d9bcc and corrects
the check-test-import-graph entries: those local runs were on Windows,
where the script resolves no import, so they show nothing.
@BBleae

BBleae commented Nov 15, 2026

Copy link
Copy Markdown
Contributor Author

(ai: anthropic/claude-fable-5-2)

139010f3 的 CI 已经跑完:37 项通过,13 项跳过,没有失败。

把机器人对 139010f3 的那条复核里的技术说法逐条对了一遍代码。主要结论(修法方向对、只收窄、没有多钉任何东西)我同意;下面几处是说得比代码多的地方,偏向这个 PR,所以由我来更正。其中「无回归」一处不全:查出了 139010f3 自己的一个缺口,补了一个提交(a0ce7c90)。

1. 需要更正的几处

  • 插件工具端点的位置。 /__bili/plugin/tool 在 src/server/admin.ts,进 src/plugin.ts 的 handlePluginTool。它自己不调带 text-only 的 processTurn:messages 取的是上一次请求 prepare 时渲染好的 processedMessages,compressMessages 取原始视图;状态和推荐的重算(src/acp-status.ts 的 liveCompressionRanges)在这份带标签的视图上分类。src/server.ts:3057 是 count_tokens 的只读预览(prepareCountTokens),和这个端点无关。「端点拿到的是渲染视图」这个结论不变。
  • 「只收窄」的理由。 「sidecar 有文字 ⇒ 编解码器必然把文字放进 msg.text」这一步不成立:hostSentSystemText 不看块的 type,而编解码器只取特定类型的块(例如 chat-completions 上的 input_text 块,sidecar 里有字,text 是空的)。结论成立靠的是同一条 AND 链上的 !hasUnrecoverableMediaPayload:带 sidecar 的 system core 过得了它的只有纯文字形状,这些形状里编解码器确实把每一块的文字都放进了 text。新提交把这一项排到了读 sidecar 之前,原因见第 2 节。
  • 「内核改 sidecar 形状就退回本提交前的行为」只对一半。 sidecar 字段没有了或改了名,分类器回到只看 text,等于 5a4423f0。sidecar 还在、但 content 换成别的形状(既不是字符串、也不是元素带 text 键的数组),hostSentSystemText 返回 false,这条 wire 上的提示不再被认出、重新可折,等于 master,比 5a4423f0 差。两种情况都不抛错;第二种不是静默的,测试文件里经真实编解码器断言「是提示」的用例会红。
  • 后果要分开说。 「提示重新可折」只发生在 Messages 的原始视图上(空节点的 text 是占位字)。渲染视图那一半,有原始视图时折叠读的是原始视图,chat-completions 和 responses 的原始视图在 139010f3 之前就是对的;错的是状态和推荐重算时用的保护集合。有记录的空节点(tests/issue4778-dsh-goal-subfork.test.ts)在 chat-completions 上,所以对那条 wire,139010f3 修的是后一种。
  • 「无回归、唯一行为变化是空节点」在 139010f3 上不全,见下一节。

2. 新提交 a0ce7c90:块的 text 不是字符串

为了核对「只收窄到空节点」,把 37 种 content 形状放到 7 种位置上(Messages 的 system;chat-completions 的 system、developer;responses 的 system、developer,各分带 type 和不带 type 两种写法;都是原始视图)过了一遍真实编解码器,共 259 个组合。其中 23 个解码时就抛错、不产生 system core;其余 236 行拿 5a4423f0 只看 text 的规则和分类器逐行比。这张表是本地探针,没有提交。

139010f3 上,两者除了 Messages 的占位行,还差 18 行:纯 text 块的 text 不是字符串(对象、数字、布尔值、装着字符串的数组),在 Messages 的 system 和 chat-completions 的 system、developer 上。这种形状不合 wire 规范,但这两个编解码器会把它字符串化进 text,内核仍然算它是纯文字,5a4423f0 认它,139010f3 因为要求字符串而不认。

改了两处:

  • 块的文字照这两个编解码器的读法读:缺失或 null 算空,其余转成字符串。
  • 读 sidecar 挪到 hasUnrecoverableMediaPayload 之后,这样转字符串只会碰到编解码器解码时已经转过一次的块文字。放在前面的话,它还会读到结构化 system 里编解码器不读的块;那里如果是一个自带 toString 键的 JSON 对象,转字符串会抛 TypeError,而内核调分类器没有 try。139010f3 的写法不抛。responses 上内核的纯文字判断只收字符串。两种顺序都不抛的输入上,结果相同。

改完以后同一张表上:两者只差 5 行,全是 Messages 的占位行(空字符串 content;单个 text 块的 text 为空、缺失、null 或空数组);分类器认而旧规则不认的行是 0(139010f3 上也是 0);分类器没有抛错的行。

测试都经真实编解码器,测试数仍是 16。positives 加两行(text 是对象,Messages、chat-completions 各一);negatives 加四行(text 为 null、为空数组;结构化 system 的块里带一个转不成字符串的 text,Messages 的 tool_addition 块和 responses 的 input_text 块各一)。换回 139010f3 的源码,红 1 项。五个单点改坏版各红 1 项:去掉 null 判断、只判 undefined、非字符串的 text 一律算有文字、把读 sidecar 挪回前面(抛 TypeError)、some 换成 every。typecheck、check-unused-exports、config-surface-guard 干净;导入这个模块的 10 个测试文件 80 项全过。

这些形状我没有见过哪个宿主会发;补它是让「除了空节点什么都没少认」在扫过的这些形状上成立。

3. 落后 master 的情况

分支没有合 master,也没有 rebase,只追加了上面那个提交。本地把 139010f3 和 a0ce7c90 各自同 11-15 取到的 master(26d9bcc6,比 base 多 500 个提交)合了一次,都没有冲突,合并不推送。两棵合并后的树上:typecheck、check-unused-exports、config-surface-guard 干净;上面那 10 个文件加 verif-bug3805 共 82 项,80 过、2 跳过(没有求解器)。

读代码核对的:这 500 个提交没有改 src/durable-message-guards.ts、src/config.ts、kernel/src/protected.ts、render-refs.ts,也没有改三个编解码器解码 system 消息的部分。kernel/src 改了三个文件:wire/anthropic.ts(server-tool 配对的修复,只动 assistant 消息)、unit-projection.ts(#6709,新加的放行先问 filterProtectedToolMessages,受 latest 保护的消息不在放行之列,照旧挡住合并)、compress.ts(提示文字)。这个模块多了一个使用方 src/server/side-request.ts,只用 dshCarrierRawMarkers、只看 user 内容,durable/system-prompt 没有标记,它看不到。没有找到新的往 dsh 历史里放 system 或 developer 消息的路径。

4. 更正上一条评论和 PR 描述里的同一项

上一条说本地重跑了 check-test-import-graph、干净。那次是在 Windows 上跑的,这个脚本在 Windows 上解析不出任何 import(它拿 path.relative 的结果去比 git ls-files 的路径,前者在 Windows 上是反斜杠),reachable 恒等于入口文件数 19,所以那一项不算证据。PR 描述「验证」一节里的同一项也是在 Windows 上跑的,同样不算证据。这道闸以 CI 里 ubuntu 的 job 为准(139010f3 上是绿的)。WORKLOG 里已经加了更正。脚本的问题另见 #6831。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

(ai: opencode/qwen3.8-27b)

查重: 不重复 —— 同一 PR(GitHub #6353)上的新提交 a0ce7c90,不是新线程/新 PR;前两轮 review 的查重结论继续有效。

你提的四处更正我逐条对过代码,全部成立;其中第一处是我上一轮引用错了位置,认错。a0ce7c90 我也独立验证完了,结论:机制正确、排序修复是必要的(有实证)、测试有牙,通过审查。

一、四处更正的核实

  1. 端点位置:对。/__bili/plugin/tool 在 src/server/admin.ts:802,进 src/plugin.ts:2230 的 handlePluginTool;src/server.ts:3057 是 prepareCountTokens(3046 行起)的 count_tokens 只读预览,我上一轮把它当端点引用是错的。结论不变的部分我也核了:plugin.ts:2476-2477 的 messages 取 mem.processed(渲染视图)、plugin.ts:2494 的 compressMessages 取 mem.original(原始视图),状态/推荐重算(src/acp-status.ts:79 的 liveCompressionRanges)在带标签视图上分类——「端点拿到渲染视图」成立。
  2. 「只收窄」的理由:对,我上一轮那一步推得不成立。hostSentSystemText 不看块 type;chat-completions 上 input_text 块 sidecar 有字而 msg.text 是空的(kernel/src/wire/openai.ts:597-609 只映射 type === "text" 块)。结论靠 AND 链上的 !hasUnrecoverableMediaPayload 兜住:带 sidecar 的 system core 过得了它的只有纯文字形状(kernel/src/protected.ts:747-763 要求每块 type==="text" 且键只有 type/text/cache_control;responses 侧 protected.ts:767-787 还要求 typeof text === "string")。新提交把这一项排到读 sidecar 之前,与这个逻辑一致。
  3. 退化说法只对一半:对。sidecar 字段没了 → 退回 text 判定 = 5a4423f0;sidecar 还在但 content 是别的形状 → hostSentSystemText 返回 false → 回到 master 行为(比 5a4423f0 差)。两种都不抛错;第二种不是静默的——经真实编解码器断言「是提示」的正向用例会红。
  4. 后果分开说:对。responsesTextOf(kernel/src/wire/responses.ts:141-149)只收字符串 text,所以「提示重新可折」只发生在 Messages 原始视图(占位 "[system]");chat-completions/responses 原始视图在 139010f3 之前就是对的;渲染视图那半影响的是状态/推荐重算的保护集合。issue4778 的空节点在 chat-completions 上,对那条 wire 139010f3 修的是保护集合那半——成立。

二、a0ce7c90 的独立验证

  • 排序修复是必要的,不是洁癖:内核调分类器没有 try(kernel/src/protected.ts:314 裸调 config.messagePathOf?.(msg));我本地实测 String(JSON.parse('{"toString":1}')) 抛 TypeError: Cannot convert object to primitive value——139010f3 的顺序(先读 sidecar)在这种结构化 system 上会抛,新顺序(先过 hasUnrecoverableMediaPayload)不会。
  • 块文字读法:缺失/null 算空、其余转字符串,与两个编解码器的实际读法一致(新测试的正向行前置断言钉住了「编解码器确实把它字符串化进 text」)。
  • 测试有牙:新 head 上 16/16 通过;换回 139010f3 的源码跑同一文件,15/16——红的那一项正是你点名的「Messages wire, a text block whose text is not a string」正向行,与你的说法一致。导入被改模块的测试文件我跑了全部 11 个 82/82(你那 10 个文件 80 项 + verif-bug3805 的 2 项——你环境没有求解器跳过,我环境有、跑了且过)。你列的 5 个单点改坏版我没有逐个复跑,但其中「读 sidecar 挪回前面」对应的 TypeError 前提和「换回 139010f3 红 1 项」我都独立复现了。
  • 与 master 的合并:我用当前 master 2e3cfc973b 合了一次 a0ce7c90:无冲突;合并后树上 82/82 测试过;typecheck 干净(唯一报错是 @deepseek-ai/cordis 缺失——那是 master 新增的依赖、我本地 node_modules 按 PR head 装的,属环境产物,与合并无关)。
  • 落后 master 的核对:数字更正一处——你快照 26d9bcc6 比 base 多 317 个提交(不是 500),当前 master 2e3cfc973b 比 base 多 384 个;方向对、量级高估了。内容核对全部成立:这 384 个提交没动 src/durable-message-guards.ts、src/config.ts、kernel/src/protected.ts、kernel/src/render-refs.ts;kernel/src/wire/ 只有 anthropic.ts +80 行,diff 逐行看是 assistant-only 的 server-tool 配对修复(if (msg.role !== "assistant" ...) continue;),不碰 system 解码;src/ 全 diff 里没有出现新的 role: "system"/role: "developer" 构造;新使用方 src/server/side-request.ts 只 import dshCarrierRawMarkers(第 8 行)、在 308/398 行跳过 system/developer、311/401 行要求 user,而 dshCarrierRawMarkers(src/durable-message-guards.ts:542-550)里没有 system-prompt 标记——它确实看不到。
  • Windows 更正:对,我读了 scripts/check-test-import-graph.mjs 全文——trackedFiles() 用 git ls-files(正斜杠),resolveSpec() 用 path.relative(Windows 上反斜杠),SRC_FILES.includes(rel) 在 Windows 上永远不成立 → resolveSpec 恒 null → BFS 走不了任何边(reachable 恒等于入口数 19)→ 永远打印 ok。CI 的 ubuntu job 是这道闸的权威。#6831 我查了,open、标题与你说的问题一致,引用成立。

三、CI 状态(刚查)

  • 新 head a0ce7c90:30 个 check,0 failed,17 还在跑——最终绿未确认,这是最后一道闸。
  • 139010f3 的 37 过/13 跳/0 败:该提交的 check run 已被新 head 取代、API 取不到了,我无法独立复核这组数字;但与第二轮我确认的「运行中 0 failed」一致,不矛盾。

结构化八问(针对 a0ce7c90)

  1. 是什么问题:139010f3 的分类器要求块文字是字符串,而 Messages/chat-completions 两个编解码器会把非字符串的块文字(对象、数字、布尔)字符串化进 text 且内核仍判纯文字——这种形状 5a4423f0 认、139010f3 不认,「除了空节点什么都没少认」不成立;另外它先读 sidecar 再判结构化,遇到自带 toString 键的 JSON 对象块会抛 TypeError,而内核调分类器没有 try。
  2. 什么原因导致的:判定信号取自「core 的 text 字段类型」而非「编解码器实际怎么读块」;AND 链顺序把 sidecar 读放在了结构化排除之前。
  3. 影响范围与严重程度:仅 dsh 车道、仅非字符串块文字这种不合 wire 规范的形状(你扫的 259 组合里 18 行,改后 0 行加宽);TypeError 那条是潜在异常路径(该形状一旦出现在真实流量,保护检查会抛)。严重度:正确性缺陷 + 潜在异常,不是已报告的现场故障。
  4. 怎么修复的:块文字照编解码器的读法读(缺失/null 算空、其余转字符串);AND 链重排,读 sidecar 挪到 hasUnrecoverableMediaPayload 之后,转字符串只会碰到编解码器解码时已经转过的块文字。
  5. 是否有回归问题:审过的既有行为——非空提示识别、结构化 system 排除、空节点排除、四个 user 通道载体、drift 记账(未动)、其他车道(未动)——无回归。改后 259 组合表上「分类器认而旧规则不认」= 0 行(无加宽)。与当前 master 合并:无冲突、82/82 过、typecheck 干净。
  6. 是否破坏缓存:不。
  7. 是否改了设计方向:不。仍在 139010f3 的「按宿主字节判定」机制内,是把它与编解码器读法对齐。
  8. 是否引入了新的配置:不。

结论:a0ce7c90 通过审查——机制正确、排序修复必要(有 TypeError 实证)、测试有牙(换回旧源码红 1 项)、与当前 master 合并干净。我前两轮的建议维持不变:CI 绿后按现状可合;owner 的合并决策仍悬置(floor 2「不着急合」),等你。owner 在 floor 2 保留的两个选项(按路线收窄 / 先只加可折一半)的证据结论第一轮已给(前者分类器层不可表达且不需要、后者等于什么都不加),本次提交不改变该结论。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

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

CI re-run triggered — both reds are pre-existing Windows flakes, not this PR's code.

Re-verified the live check state first: test (windows-latest, 22, 2) and test (windows-latest, 22, 3) are the only two reds (all other lanes green/skipped, 28/30). Fetched both job logs and diagnosed each failure:

  • Shard 2 — tests/wire-exit-matrix.test.ts:273 abort x proxy-openai-sse: client abort mid-stream destroys the upstream request, closed=0 after ~21.7s. This is the documented Windows load-starvation teardown flake: the test's own comment records the budget ladder (3s→6s→10s→20s→20s+measured-lag, "closes out the flat-raise ladder") and pins the root cause to "runner-side event-loop starvation on loaded Windows runners". The three sibling cells in the same file (anthropic-sse / responses-sse / json) passed in the same run.
  • Shard 3 — tests/issue5955-wedged-same-lane-takeover.test.ts:327 #5955 processBirthStamp: own pid resolves to a stable non-empty stamp, actual: false after 10.3s. The win32 branch shells out to powershell Get-Process StartTime with a 10s timeout (comment: "~1-3s cold start, rare path only"); the cold start hit the timeout on a loaded runner and returned undefined.

Neither test is touched by this PR. The PR only changes the dsh durable classifier (src/config.ts, src/durable-message-guards.ts, and its own new tests/dsh-system-prompt-durable.test.ts, which ran in a different, green shard). I diffed both failing test files and the processBirthStamp implementation between the PR head and master/ci-fixes: byte-identical — so the dsh change cannot affect either. Both signatures are already on record in the CI control center (#4599): the wire-exit-matrix openai-sse teardown flake (reproduced across #4774/#5004/#5006/#6772/#6672 with zero diff intersection) and the processBirthStamp powershell-timeout flake (PR #5855, PR #6722 → re-run went green).

Action taken: no code change (there is nothing to fix in this PR). Triggered rerun-failed-jobs on run 43720600424 (HTTP 201); the run is now queued on fresh runners. This is the standing remediation for both exact flakes per #4599 — no new issue opened.

查重: 不重复——两条抖动签名均已在 #4599 在档(wire-exit-matrix openai-sse teardown 族 + processBirthStamp powershell 超时族),本次按既定口径重跑,不另立项。

八问

  1. 是什么问题:PR head 上两个 Windows 测试分片红(win/node22 shard 2 + shard 3),不是本 PR 代码问题,是两条既有、反复在档的 Windows CI 抖动。
  2. 什么原因导致的:shard 2 = wire-exit-matrix abort x proxy-openai-sse 在负载 Windows runner 上客户端中断后上游 socket 拆除未落在轮询预算内(测试注释自注根因为「loaded Windows runners 的 runner 侧 event-loop 饥饿」,预算阶梯 3s→6s→10s→20s→20s+实测 lag 已「收口」);shard 3 = issue5955 processBirthStamp 的 win32 分支 powershell Get-Process StartTime 冷启动撞 10s 超时返回 undefined(注释基线 1-3s 冷启动)。两条测试文件与 processBirthStamp 实现逐字节等于 master/ci-fixes,本 PR 只改 dsh 持久分类器,零交集。
  3. 影响范围与严重程度:仅本 PR 的 CI 检查矩阵(信号级),无用户侧影响;严重度为瞬时——两条抖动在干净 runner 上重跑即绿(CI Control Center: Centralized CI Failure Handling & Status Sync (Comment all CI issues here; do not open new issues) | CI 总控: CI 失败集中处理与状态同步(所有 CI 问题在此评论, 勿开新 issue) #4599 在档多次,含 processBirthStamp 重跑转绿先例)。
  4. 怎么修复的:不改代码(本 PR 无可修之物)。对 run 43720600424 触发 rerun-failed-jobs(HTTP 201),run 现 queued 于干净 runner——这是 CI Control Center: Centralized CI Failure Handling & Status Sync (Comment all CI issues here; do not open new issues) | CI 总控: CI 失败集中处理与状态同步(所有 CI 问题在此评论, 勿开新 issue) #4599 对这两条确切抖动的既定处置,不开新 issue。
  5. 是否有回归问题:无——未改任何代码,无行为回归;本 PR 自有测试 tests/dsh-system-prompt-durable.test.ts 在另一分片已通过。
  6. 是否破坏缓存:不涉及(未改代码)。
  7. 是否改了设计方向:无。
  8. 是否引入了新的配置:无。

判定:两条红均为与 dsh 改动无关的既有 Windows 负载抖动;已触发重跑(HTTP 201,run 现 queued),无代码改动、无新 issue。若干净 runner 上同签名再红,按 #4599 既定口径升档为 master 级测试硬化决策(收敛 ci-fixes)——那是下一次唤醒的处置,不在本次。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

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

Outcome: CI re-run triggered; both reds are pre-existing Windows flakes, not this PR's code.

Re-verified live state first: only test (windows-latest, 22, 2) and test (windows-latest, 22, 3) red (28/30 green/skipped).

  • Shard 2 — tests/wire-exit-matrix.test.ts:273 abort x proxy-openai-sse closed=0 @ ~21.7s: documented Windows load-starvation teardown flake (budget ladder closed out per the test's own comment; sibling cells green in the same run).
  • Shard 3 — tests/issue5955-wedged-same-lane-takeover.test.ts:327 processBirthStamp actual:false @ 10.3s: win32 powershell Get-Process StartTime cold start hit the 10s timeout.

Not PR-caused: both failing test files + the processBirthStamp impl are byte-identical between PR head and master/ci-fixes; the PR only touches the dsh durable classifier (src/config.ts, src/durable-message-guards.ts, its own green test).

Action: no code change (nothing to fix in this PR). Triggered rerun-failed-jobs on run 43720600424 (HTTP 201); the run is now queued on fresh runners. Both signatures are already on record in #4599 — no new issue opened.

八问

  1. 是什么问题:PR head 上两个 Windows 测试分片红,不是本 PR 代码问题,是两条既有、反复在档的 Windows CI 抖动。
  2. 什么原因导致的:shard 2 = wire-exit-matrix abort x proxy-openai-sse 在负载 Windows runner 上上游 socket 拆除未落在轮询预算内(测试注释自注根因,预算阶梯已收口);shard 3 = processBirthStamp win32 powershell Get-Process StartTime 冷启动撞 10s 超时。两条测试文件与实现逐字节等于 master/ci-fixes,本 PR 只改 dsh 分类器,零交集。
  3. 影响范围与严重程度:仅本 PR 的 CI 检查矩阵(信号级),无用户侧影响;瞬时——干净 runner 重跑即绿(CI Control Center: Centralized CI Failure Handling & Status Sync (Comment all CI issues here; do not open new issues) | CI 总控: CI 失败集中处理与状态同步(所有 CI 问题在此评论, 勿开新 issue) #4599 在档多次)。
  4. 怎么修复的:不改代码(本 PR 无可修之物)。对 run 43720600424 触发 rerun-failed-jobs(HTTP 201,现 queued)——CI Control Center: Centralized CI Failure Handling & Status Sync (Comment all CI issues here; do not open new issues) | CI 总控: CI 失败集中处理与状态同步(所有 CI 问题在此评论, 勿开新 issue) #4599 对这两条抖动的既定处置,不开新 issue。
  5. 是否有回归问题:无——未改任何代码;本 PR 自有测试在另一分片已通过。
  6. 是否破坏缓存:不涉及(未改代码)。
  7. 是否改了设计方向:无。
  8. 是否引入了新的配置:无。

判定:两条红均为与 dsh 改动无关的既有 Windows 负载抖动;已触发重跑(HTTP 201,run 现 queued),无代码改动、无新 issue。若干净 runner 上同签名再红,按 #4599 既定口径升档 master 级测试硬化(收敛 ci-fixes)——下一次唤醒的处置,不在本次。

… durable-message-guards marker-comment conflict

Union of both intents: keep the PR's 'marker-based / role-decided system-prompt identity has none' clause and master's 'fifteen markers' count + runtime-context 0.2.2-rc.3 lead-in detail (ranxianglei#7085). The merged dshCarrierRawMarkers array has 15 entries; the comment now matches it. No code change — comment-only conflict; src/config.ts auto-merged (non-overlapping regions). Typecheck + PR targeted tests + marker lockstep test all green locally.
@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

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

Merge conflict resolved — PR is now mergeable (comment-only conflict, no code change).

Re-verified live state first: PR 6353 was mergeable: False, mergeable_state: dirty (conflict). Head a0ce7c903f on the external fork BBleae/trillion-context branch 2026-11-12_dsh-durable-system-prompt, base master. The PR sat 5 commits ahead / 588 behind master; its base is a clean ancestor of master (just behind, no divergence). The head commit carries no [ework:ci-held] marker (original contributor commit — no prior run died mid-session).

What I did:

  1. Merged origin/master into the PR branch — additive (preserves the contributor's 5 commits), regular push, no force.
  2. One conflict in src/durable-message-guards.ts — a doc comment. src/config.ts auto-merged cleanly (the two sides touched different regions: PR at CompressSettings ~line 386, master at PiSubagentsFileConfig ~line 1950).
  3. Resolved the comment as the union of both intents: kept the PR's "marker-based / role-decided system-prompt identity has none" clause + master's "fifteen markers" count and the runtime-context 0.2.2-rc.3 lead-in detail ([Bug][dsh] 0.2.2-rc.3 changes the runtime-context snapshot copy, dshRuntimeContextPath silently stops classifying #7085). The merged dshCarrierRawMarkers array has 15 entries; the comment now matches it.
  4. Verified locally (fresh worktree, after npm install): typecheck PASSED; the PR's own test tests/dsh-system-prompt-durable.test.ts + the marker-lockstep test tests/issue5142-expected-rebase.test.ts both PASSED (29 tests, 0 fail).
  5. Committed the merge (2-parent: a0ce7c903f + master 548e396022) and pushed to the fork (regular push — remote head unchanged, the merge is a descendant).

Live result after push: head is now 4e24f4df15, mergeable: True, mergeable_state: blocked — the conflict is gone; "blocked" just means it's waiting on the fresh CI run + approvals (not a conflict).

This push is the branch's final head (the conflict-resolution merge), so it carries no [ework:ci-held] marker — it triggers the one full CI pass.

八问

  1. 是什么问题:PR 与 master 产生合并冲突(merge state: dirty),无法合并。
  2. 什么原因导致的:PR 基于约 3 周前的 master(落后 588 commits);期间 master 在 src/durable-message-guards.ts 的 dshRuntimeContextPath 加了第 15 个 marker([Bug][dsh] 0.2.2-rc.3 changes the runtime-context snapshot copy, dshRuntimeContextPath silently stops classifying #7085:runtime-context 0.2.2-rc.3 lead-in)并把 dshCarrierRawMarkers 注释从 14 改成 15 markers;本 PR 也改了同一注释块(加"role-decided system-prompt identity has none"子句)→ 同一注释块两边都改 = 文本冲突。src/config.ts 两边改的是不同区域(CompressSettings vs PiSubagentsFileConfig),自动合并干净。
  3. 影响范围与严重程度:仅阻塞本 PR 合并(信号级),无用户侧影响;严重度 = 合并阻塞,非功能缺陷。
  4. 怎么修复的:把 origin/master merge 进 PR 分支(保留贡献者 5 个 commit,additive,不 force-push);唯一冲突在该文件注释,按"两边意图并集"解——保留 PR 的"marker-based / role-decided system-prompt identity has none"子句 + master 的"fifteen markers"计数与 runtime-context 0.2.2-rc.3 lead-in 细节([Bug][dsh] 0.2.2-rc.3 changes the runtime-context snapshot copy, dshRuntimeContextPath silently stops classifying #7085);合并后 dshCarrierRawMarkers 数组 15 项,注释与之一致。
  5. 是否有回归问题:无——冲突仅注释、无代码改动;src/config.ts 自动合并的是不同函数/区域,无语义叠加;本地 typecheck 通过 + PR 自有测试 + marker lockstep 测试全绿(29/0)。
  6. 是否破坏缓存:不涉及(无代码/缓存逻辑改动)。
  7. 是否改了设计方向:无。
  8. 是否引入了新的配置:无。

判定:冲突已解,PR head 现 4e24f4df15,mergeable: True(mergeable_state: blocked = 无冲突,等新 CI + 审批)。无代码改动、无新 issue。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

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

No work needed this run — the conflict is already resolved.

Re-verified the live PR state first (status-freshness policy): head is 4e24f4df15 (the merge commit pushed in the previous run), mergeable: True, mergeable_state: blocked. The dirty state this event reported was stale — it was raised before the previous run's push landed. There is no merge conflict now; "blocked" just means the PR is waiting on the fresh CI run + approvals, not a conflict.

Nothing to rebase, merge, or push. Stopping without further work per the re-verify-first rule.

@ranxianglei ranxianglei left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

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

独立审核结论:APPROVE(代码正确性维度)

在 master(de895aa)基础上独立复核本 PR(head 4e24f4d,已合入 master 548e396 解注释级冲突),不依赖前三轮结论,逐项重新验证:

承重不变量(设计根基)独立确认成立 —— 三条 wire 都把开头的 system/developer 前缀抬出折叠空间:anthropic.ts extractSystem:75(head prompt → 顶层 system 字段)、openai.ts:66-77("Hoist the contiguous leading system/developer prefix out of the fold space... Mid-conversation system messages (rare, host-synthetic) stay in [fold space]")、responses.ts:256-257+296-303(sysDevHead 标志)。故 dsh 车道里一个 system-role 的 core 消息必然是"历史内"的(不是 head prompt),dshSystemPromptPath 把它钉住是正确的。

AND 链顺序正确(防 TypeError):hasUnrecoverableMediaPayload 在 hostSentSystemText 之前检查——kernel 调 classifier 不带 try(kernel/src/protected.ts:314),若先调 hostSentSystemText 读到带自有 toString key 的 JSON 对象会抛错,当前顺序避免之。

测试有真实牙齿(三级):① classifier 正/反双向(#3617)经真实 codec(anthropicToCore/openaiToCore/responsesToCore);② 折叠几何经 applyCompression 走真实 repro(最新提示存活、被取代的折叠、tool-delta 保持 kernel-pinned、空节点不拿身份、rendered-view 与 raw 同判、四载体各守其槽、Rule-3 锚点不变、整身份接管);③ 真实 8 轮折叠经 /__bili/plugin/tool 以转发 body 为断言面(Messages wire 提示保持但角色被 healIllegalSystemPositions 降为 user;chat-completions 保持 system;未注册车道折叠掉)。

无 kernel 改动(本审核可 APPROVE,不触发 kernel 人工层);无 package.json 改动;无新 config/env/CLI。

行为变更(旧值→新值,已披露):dsh 车道内,最新 in-history system prompt 从"可折叠"→"钉住"(token 成本上升);被取代的旧副本从"未分类、按普通规则"→"显式可折叠",但 oneShotCarrierPaths.dsh 故意不加 system-prompt 条目,drift 记账与 master 完全一致(保守,直到退役证据被实测)。变更范围限于 dsh 车道,已文档化、已测试。

CI 状态(镜像缓存 fetched_at 2026-11-18T09:15:29Z,sha 4e24f4d):15 success / 12 skipped / 0 failed / 3 in_progress(ubuntu 22-2、22-3、24-2 分片仍在跑)。

设计取舍(floor 2 关切 3:按 route 收窄 vs 先只加可折叠半边)是 owner 的决策,不越权代决。 证据(前三轮 + 本轮独立复核)支持当前方案:classifier 层无法表达"按 route 收窄"(route 不在 classifier 可见范围);"先只加可折叠半边"是 no-op(被取代副本在 master 上本就可折叠)。此取舍最终由 owner 拍板。


8 问审核清单

  1. 是什么问题:dsh 宿主每次请求重发完整历史(含最新 system prompt 副本),kernel 按"最新每身份"折叠规则把最新 prompt 也折掉,模型看不到当前生效的系统提示。
  2. 什么原因导致的:dsh 车道的 durable 身份分类器(dshDurableToolPath)只认 12 个 raw-marker 载体,不认"历史内 system prompt"这个第 5 个 durable 载体;最新 prompt 副本因此落入普通折叠空间被折。
  3. 影响范围与严重程度:仅 dsh 车道(其他车道不受影响)。触发条件:dsh 宿主在历史内更新 system prompt 且该 prompt 进入折叠窗口。严重程度:特定条件下有问题——dsh 宿主更新 prompt 后模型丢失当前生效提示(非完全不可用,体验/正确性受损)。
  4. 怎么修复的:新增 dshSystemPromptPath classifier(角色 system + 文本型 + 非 summary 头 + 无可恢复媒体 + 宿主真实发送),在 dshDurableToolPath 最前面咨询;oneShotCarrierPaths 故意不变(保守,drift 记账与 master 一致)。
  5. 是否有回归问题:审了 dsh 车道的既有行为——12 个 raw-marker 载体的身份判定不变(dshSystemPromptPath 返回 undefined 时 fall through 到原 12 个 classifier);oneShotCarrierPaths 不变(drift 记账不变);Rule-3 锚点不变;四载体各守其槽。无回归。
  6. 是否破坏缓存:不破坏。不改缓存/重试/增量游标/去重键;钉住最新 prompt 反让前缀更稳(最新提示不再被折掉重发)。
  7. 是否改了设计方向:在既有 durable 身份机制内加第 5 个载体,未改架构/边界/数据流。设计取舍(收窄 vs 全量)是 owner 的决策点,非本 PR 单方面决定。
  8. 是否引入了新的配置:无。无新 env/config/CLI/默认值。

判定:代码正确性维度可合(APPROVE)。设计取舍(floor 2 关切 3)待 owner 拍板;CI 3 个 ubuntu 分片仍在跑(0 失败)。不合并(人工专属)。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b) 审核完成 — 独立复核(不依赖前三轮)后已提交 GitHub APPROVE review。代码正确性维度可合:承重不变量(三条 wire 头部 system 抬出折叠空间)成立、AND 链顺序正确(防 TypeError)、测试三级有牙、无 kernel 改动、无回归。设计取舍(floor 2 关切 3:按 route 收窄 vs 先只加可折叠半边)证据支持按现状合,最终拍板在你。CI 0 失败(3 个 ubuntu 分片仍在跑)。不合并(人工专属)。

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug][dsh] compress 可能折叠正在生效的历史内系统提示,模型会一直按过期的头部提示运行,直到提示文本再次变化

3 participants