Skip to content

[PR] fix: close the judge's echo normalization to the filter's strip set (#3938 PR-D) - #3985

Merged
ranxianglei merged 1 commit into
masterfrom
2026-10-20_3938-prd-rendertags
Oct 20, 2026
Merged

ranxianglei merged 1 commit into
masterfrom
2026-10-20_3938-prd-rendertags

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

(ai: zhipuai-lb/glm-5.3)

PR-D: renderTags 收口 — 判官豁免清单与过滤器形状集闭合

Part of #3938 (拍板①落地). 沿 #3944 (PR-A 判官转正) 的 L1 判官补上最后一块:归一化形状集与出站过滤器的剥离形状集单一事实源化。

三项审计结论(#3938 拍板① 要求的「重点看」)

  1. kernel text-only render 严格性 — 通过: kernel/src/render-refs.ts:79 非 text 永不打标; ownTagRe 只剥自己 ref 的 tag (foreign tags survive); 纪律注释在案。
  2. tag-echo 过滤器布线 — 通过: 四条 adapter 车道全 prose-only (text deltas / part.text / content[].text); reasoning 全走 identity filter; thinking 签名块有 [acp-loop] In-turn compress re-request edits the latest assistant message → Anthropic 400 "thinking blocks … cannot be modified" (session stays broken) #1960 不可动注释; function_call_arguments 直建不过滤 ([bug] 插件透传会剥掉工具调用参数里的 render tag(arguments 流挂了 tag-echo 过滤器) #1039)。
  3. 豁免清单闭合 — 真缺口,本 PR 修: 判官 normText 只认规范 render-tag 形状,而过滤器剥的族大得多 — 两套形状集各自维护 = 判官静默落后于过滤器生长的维护接缝。

修复

  • src/loop/tag-echo-filter.ts 新导出 normalizeEchoArtifacts(text): stripAcpTags 的薄封装(尾部已含 marker 行 + bili 内部工件),带 fast-path gate(三个 contains* 预检全 false 直接返回,干净消息零正则成本)。单一事实源:过滤器长,判官归一化跟着长。
  • src/invariant-judge.ts normText 改用它,RENDER_TAG_RE 保留兜底 kernel 规范形。
  • 测试按真实过滤器输出逐形状建模(mangled open 剥壳留 ref;伪造 chain 标记过不了 checkpoint 校验、两侧都 verbatim 保留——判官与过滤器一致);任意中途改写仍然红。

覆盖的 echo 族(出处见代码注释)

case-drift #1731 / typo drift #673 / bare #1881 / degenerate close #2190 / self-close #2348 / mangled open #2066 / forged marker #717 / bili-chain 工件 #1634 / dead ref-close #2862。

验证

  • tests/invariant-judge.test.ts 26/26(新增 3:九族形状零误报、prose-wearing 双侧保内容、真改写仍红)
  • tests/invariant-judge-e2e.test.ts 5/5;tag-echo 族 106/0;cache-proof 13/0;basic 29/0;cache-friendly 5/0;typecheck 绿
  • host-only(src/),无 kernel/ 改动,判官两挂点(relay.ts:666 / loop/core.ts:505)已默认开

Part of #3938

…3938 PR-D)

The judge's normText only stripped the canonical render-tag shape
(RENDER_TAG_RE) while the outbound stream filters strip a much wider
echo family (case-drift #1731, typo drift #673, bare #1881, degen/
self-close #2190/#2348, mangled open #2066, forged marker lines #717,
bili-chain artifacts #1634, dead ref-close #2862). Two independently
maintained shape sets silently drift apart — any future path that
strips echo shapes asymmetrically would read as a false mid-history
rewrite.

normText now normalizes through normalizeEchoArtifacts (a thin export
of stripAcpTags — the filter's own whole-text transform, single source
of truth by construction), with a fast-path gate so clean messages pay
no regex cost. RENDER_TAG_RE stays as a belt for the kernel's
canonical form. Verified against the real filter outputs per shape
(mangled opens leave the ref behind; fabricated chain markup fails
checkpoint validation and is preserved verbatim — the judge agrees
with the filter either way); arbitrary mid-history rewrites still
flag.
@ranxianglei ranxianglei changed the title fix: close the judge's echo normalization to the filter's strip set (#3938 PR-D) [PR] fix: close the judge's echo normalization to the filter's strip set (#3938 PR-D) Oct 20, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-20_3938-prd-rendertags (6a0729d)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.4762-pr.3985.9bb1d56

This exact version is immutable and reproducible. The rolling pr tag tracks the newest test build across all PRs.

Option B — Download artifact

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

Install instructions are refreshed on each push.

@ranxianglei
ranxianglei merged commit 860e617 into master Oct 20, 2026
36 of 37 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.685-master.860e617 (rolling master tag).

npm install -g billion-context@0.0.685-master.860e617  # this exact build
npm install -g billion-context@master  # always the newest merged build

npm view billion-context@master prints the current version at any time.

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