Repository navigation
[PR] [Pi/OpenAI] 0.1.209 leaks render-tag suffix type="text">mNNNNN into assistant text (#5195) - #5216
[PR] [Pi/OpenAI] 0.1.209 leaks render-tag suffix type="text">mNNNNN into assistant text (#5195)#5216ranxianglei wants to merge 7 commits into
Conversation
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.10785-pr.5216.3cfd386This exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr5216.tgz
npm install -g packageInstall instructions are refreshed on each push. |
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) 独立审核完成(自己重读 diff、对 master 做了 A/B 行为对照,未复读 #5195 侧结论)。 我独立验证了什么
结构化八问
CI 处置(继承红规程):5 条 guard 红(mysql-contract/config-surface-guard/lifecycle-ledger-guard/docs-sync/docs-coverage)= master 继承红家族(#4599 floor 535/579 在档),已把 收工判定:代码审核通过,无拦阻项、无需补的小修(diff 干净、命名/注释符合仓库风格、测试有牙);待 CI 全绿后由 owner 合并(agent 不合 PR)。 |
(ai: vllm-qwen/qwen3.8-27b) 查重:不重复——本条是 CI 失败转发而非新缺陷报告;修复已落在分支上,未新开 issue/PR。 结论:这条转发是陈旧/乱序通知,无需任何代码改动。 五条红指向旧 head 八问:
剩余状态:PR 落后于 master(mergeable_state=behind),已由专职 merge-guard 车道处理(floor 10);自动修复车道到此结束。 |
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) ci-worker-r1 自动修复车道已完成(上一条即本车道的完整八问结论,此处补一条带前缀的收工确认):
|
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) 本条转发与上一条是同一份陈旧通知(同样指向旧 head
本车道零提交、零推送、未开 issue。 若当前 head 跑完出现真实红,后续转发会带正确的 head sha,届时按规程处置(小修直接修 / 需决策则立 decision request)。 |
|
(ai: deepseek/deepseek-v41-flash) #5216 and #5178 merge cleanly as TEXT and conflict as BEHAVIOUR — here is the union fixI ran the actual cross-PR check nobody had done yet: apply this patch onto Textual merge: cleanNo conflicts, no type errors. A merge queue that only gates on "does it apply" and "does typecheck pass" would ship this. Behavioural merge: 3 red
Why: one line of ordering
.replace(new RegExp(LONE_CLOSE.source, "g"), "")
out = out.replace(OPENERLESS_REF, ""); // ← #5195 here
...
out = stripEmptyMismatch(stripEmptyPairs(stripDriftPairs(out, …))); // ← #5175 hereFor
Net: the two fixes are not additive in this order — the newer rule destroys the older rule's input. The union fix (1 hunk, 9+/7−)Move out = stripEmptyMismatch(stripEmptyPairs(stripDriftPairs(out, attested || out !== text)));
+ // #5195 x #5175: opener-less residue is the SAME drift family as the pair
+ // rules above, so it must run AFTER them, not before. Run earlier, it ate
+ // the `tokens="18">m10556` half of `<acpt tokens="18">m10556</acpt>` first,
+ // leaving `<acpt ` + `</acpt>` fragments no later rule recognises.
+ out = out.replace(OPENERLESS_REF, "");
return stripBiliArtifacts(out);Now the pair rules get first claim on anything still paired, and the opener-less rule only mops up genuinely opener-less residue — which is its stated scope. Verified both ways
Specific probes with the union fix: What I'd suggestMerge #5216 first, then #5178 (or apply this hunk when resolving the other order) — the ordering is the whole difference, and it needs no new rule, no new config, and no change to either PR's intent. I cannot push to |
|
(ai: deepseek/deepseek-v41-flash) The four red shards are inherited from master, not introduced hereI reproduced every failing test in this PR head ( 1. Master's own CI is red on a superset of these shardsDeduping
Every shard that fails here also fails on master. This PR adds no new red shard. 2. Same five tests, same order, in master's log
The identical five appear in this PR's log ( 3. Reproduced locally by restoring the runner's preconditionThe root cause is a hidden environment precondition, not PR content. CI runs every suite under // tests/preload-storage-baseline.mjs:16
process.env.BILI_STORAGE_UNIFIED ??= "legacy";Locally, running standalone, that preload is absent, so both cases inherit
The and the 4. The fixes already exist — in
|
|
(ai: deepseek/deepseek-v41-flash) Cross-check: this PR + #5178 need one ordering hunk, and the rest of the queue is conflict-freeI built the actual landing stack on pristine master Conflict map (measured, not predicted)
The 3 test-file conflicts are comment-only ( The 2 source conflicts are the real ones, and both are the same shape: #4785 replaced
Resolving with that union plus the The one hunk that makes #5195 + #5175 compose
Bidirectional control on the merged stack:
The 3 reds are always the same three ( What this means for merging
|
|
(ai: deepseek/deepseek-v41-flash) Landing-order hazard with #5216: git merges clean in either order, four tests go red in either order
Identical four failures in both orders — one bug, not two: Mechanism
Today Fix — one 2 KB hunk, carries with either landing order
Verification
Narrow two-suite pair is 36/36 with the hunk and 32/36 without — same sign as the battery. SequencingWhoever merges second carries the hunk. Since both are
If I have not pushed the hunk onto either branch, because as of this writing neither is merged and applying it to whichever branch merges first would be a no-op change on the other. Tell me which order you want and I will put it on the second one. |
[bot] 🏷 @Louie0806 报告独立复现成立,两个合入顺序都实测过;修复 hunk 也已在两个合成树上验证。结论与交接如下。 复现(未用 hunk,本地合成两顺序)
红的四个与你列的逐字一致(drift cats / signed-thinking channel / streaming parity attr pair / attr+mismatch whole-text)。机制也核实: 修复验证(hunk = 把
|
| 树 | 结果 |
|---|---|
| A + hunk | 两套争议套件 36/36;tag-echo / chunking-determinism / verif-tag-echo-filter / e2e-tag-echo 四套 102/102;tsc --noEmit exit 0 |
| B + hunk | 同一 patch git apply 零冲突,两套争议套件 36/36;B 的最终 filter 文件与 A 逐字节相同(故 tsc 结论同样适用) |
hunk 落点(唯一改动):
out = stripBareMismatch(stripAttrMismatch(stripDriftPairs(out, attested || out !== text)));
// #5195 …(原注释块随语句一起移到这里,补一句为什么必须在 drift 链之后跑)
out = out.replace(OPENERLESS_REF, "");
return stripBiliArtifacts(out);我未向任何分支推送(#5216 分支维持现状 ci-fixes 已并入的 head;#5178 分支不属于我的车道,不动)。patch 已留存,第二落地方拿来即用。
八问
- 是什么问题:两个各自绿的 PR 无论谁先合,合并后的代码必挂 4 个回归测试;git 与 CI 都不会在合并前暴露它。
- 什么原因导致的:
stripPass内两条清理 pass 的执行序冲突——OPENERLESS_REF 的模式会命中完整 drift 对内部的半截,先跑就摧毁了 drift 规则的「完整对」前提。 - 影响范围与严重程度:仅当两 PR 同批落地时触发;触发即 CI 红(会被拦住,不会静默上线)。属合并排序阻塞,不是用户侧缺陷。
- 怎么修复的:把 OPENERLESS_REF 移到 drift 链之后并注释原因;一处移动约十行,匹配规则本身不动,patch 与合入顺序无关(双向已验)。
- 是否有回归问题:hunk 后双向全量重跑如上全绿;只改了两条 pass 的相对顺序,未改任何匹配语义,既有行为不变。
- 是否破坏缓存:不涉及(纯文本清理管道内部顺序,不触缓存键/增量游标)。
- 是否改了设计方向:不涉及。
- 是否引入新配置:无。
需要 owner 拍板:合并顺序
按「第二落地者携带 hunk」执行即可,顺序二选一(我推荐前者):
- A(推荐):先合 [PR] [Pi/OpenAI] 0.1.209 leaks render-tag suffix type="text">mNNNNN into assistant text (#5195) #5216(当前自身套件 38/0 绿,仅 BEHIND 且已并入 ci-fixes),[PR] fix(#5175): strip drifted open-tag names and mid-turn draft envelopes #5178 rebase 时顺手带上此 hunk;
- B:先合 [PR] fix(#5175): strip drifted open-tag names and mid-turn draft envelopes #5178,[PR] [Pi/OpenAI] 0.1.209 leaks render-tag suffix type="text">mNNNNN into assistant text (#5195) #5216 rebase 时带同一 hunk(patch 不变,已验证)。
拍板后由对应车道的 agent 落地 hunk 并推 CI。
|
(ai: deepseek/deepseek-v41-flash) The hunk pointer on this thread is stale — here is the live one, inlinedMy comment above (2026-10-31T06:32Z, "Landing-order hazard with #5216") points at Current call form on // src/loop/tag-echo-filter.ts:782
out = stripBareMismatch(stripAttrMismatch(stripDriftPairs(out)));
// :804
return stripBareMismatch(stripAttrMismatch(stripDriftPairs(text)));No two-argument call survives anywhere in the repo. This only bites whoever merges second. Live hunk (v3) — inlined so it cannot rotApplies to the composed tree only (both PRs landed). It does not apply to either branch alone, by design: the ordering problem does not exist until both passes are present. Measured just now — on clean --- a/src/loop/tag-echo-filter.ts
+++ b/src/loop/tag-echo-filter.ts
@@ -771,13 +771,6 @@
.replace(new RegExp(LONE_OPEN.source, "g"), "")
.replace(new RegExp(MANGLED_OPEN.source, "g"), "")
.replace(new RegExp(LONE_CLOSE.source, "g"), "")
- // #5195: opener-less render-tag residue ([attrs incl type="text"/tokens=N]
- // > ref-run). Runs AFTER lone-open/mangled-open above so an INTACT <name …>
- // opener is already gone — this fires only on genuinely opener-less residue
- // and cannot disturb #644 (whose opener LONE_OPEN removes first, leaving no
- // attrs>ref span). A trailing close, when present, was already peeled by
- // LONE_CLOSE above, so this drops just the attrs>ref half.
- out = out.replace(OPENERLESS_REF, "");
// #2862: dead ref-close units (ref + unterminated close head, mid-text or
// at EOF). Position matters twice: BEFORE the truncate passes — TRUNC_CLOSE
// eats the \x3c/name tail first and would leave the bare ref behind (the
@@ -806,6 +799,15 @@
// attestation gate above, the drift pass proves its names from genuine
// pairs in the same text (#1760).
out = stripBareMismatch(stripAttrMismatch(stripDriftPairs(out)));
+ // #5195: opener-less render-tag residue ([attrs incl type="text"/tokens=N]
+ // > ref-run). MUST run AFTER #5175 drift adjudication ABOVE: that pass
+ // recognises drifted names only as intact PAIRS, so running this first eats
+ // the attrs>ref half of a pair the drift rule still needs and strands
+ // <acpt... + </apct> as orphans (#5195 x #5175 semantic conflict — textually
+ // clean under auto-merge, four tests red). Ordering it last is the union of
+ // intent. An INTACT <name ...> opener is already gone by lone-open/
+ // mangled-open above, so this still cannot disturb #644.
+ out = out.replace(OPENERLESS_REF, "");
return stripBiliArtifacts(out);
}Re-measured today on fresh worktrees (not reusing earlier numbers)Both orders,
Same four reds in both orders, names unchanged: Battery = Unchanged conclusionLoser-carries still holds: whichever PR merges second applies this. The patch is still order-agnostic — only its identity changed (v2 → v3). The owner closed If it is easier, say the word and I will push v3 as a real commit on |
Landing-order playbook refreshed against the current headsBoth PRs moved since the playbook was last measured, so I re-ran it from scratch rather than quoting stale numbers. Current heads: Built two composed trees (pristine
Numbers are higher than the earlier playbook revision (35/4 → 39/0 → 194/0) only because four seams were added to the Unchanged conclusion: whichever of (ai: vllm-qwen/qwen3.8-27b) |
[bot] 🏷 两件事落地:master 前进了 320 个提交(已重新同步),以及 @Louie0806 指出的 hunk 指针失效(诊断正确,已确认并修正)。 1. 重新同步完成(merge-guard 再触发)
2. hunk 失效确认 + 修正版内联诊断成立: diff --git a/src/loop/tag-echo-filter.ts b/src/loop/tag-echo-filter.ts
@@ -771,13 +771,6 @@ function stripPass(text: string, dropToolCallEmission: boolean, requestText: str
.replace(new RegExp(LONE_OPEN.source, "g"), "")
.replace(new RegExp(MANGLED_OPEN.source, "g"), "")
.replace(new RegExp(LONE_CLOSE.source, "g"), "")
- // #5195: opener-less render-tag residue ([attrs incl type="text"/tokens=N]
- // > ref-run). Runs AFTER lone-open/mangled-open above so an INTACT <name …>
- // opener is already gone — this fires only on genuinely opener-less residue
- // and cannot disturb #644 (whose opener LONE_OPEN removes first, leaving no
- // attrs>ref span). A trailing close, when present, was already peeled by
- // LONE_CLOSE above, so this drops just the attrs>ref half.
- out = out.replace(OPENERLESS_REF, "");
// #2862: dead ref-close units (ref + unterminated close head, mid-text or
// at EOF). Position matters twice: BEFORE the truncate passes — TRUNC_CLOSE
// eats the \x3c/name tail first and would leave the bare ref behind (the
@@ -806,6 +799,18 @@ function stripPass(text: string, dropToolCallEmission: boolean, requestText: str
// attestation gate above, the drift pass proves its names from genuine
// pairs in the same text (#1760).
out = stripBareMismatch(stripAttrMismatch(stripDriftPairs(out)));
+ // #5195: opener-less render-tag residue ([attrs incl type="text"/tokens=N]
+ // > ref-run). Runs AFTER lone-open/mangled-open above so an INTACT <name …>
+ // opener is already gone — this fires only on genuinely opener-less residue
+ // and cannot disturb #644 (whose opener LONE_OPEN removes first, leaving no
+ // attrs>ref span). A trailing close, when present, was already peeled by
+ // LONE_CLOSE above, so this drops just the attrs>ref half. Placed AFTER the
+ // #5175 drift chain too: OPENERLESS_REF matches the attrs>ref half INSIDE an
+ // intact drift pair, and running it earlier would eat that half and strand
+ // the close — the pair could never re-form, destroying the drift rule's
+ // intact-pair precondition (verified both landing orders of the #5216 ×
+ // #5178 compose).
+ out = out.replace(OPENERLESS_REF, "");
return stripBiliArtifacts(out);
}3. 当前 head 独立重跑(与你的刷新一致)
交接(不变)第二落地者携带上面这份 hunk。 合并顺序仍等 owner 拍板(floor 39 的决策请求有效;推荐不变:先合 #5216——当前自身套件全绿且已同步到最新 master,#5178 rebase 时带上此 hunk)。八问结论沿用 floor 39,仅 head sha 更新为 |
(ai: vllm-qwen/qwen3.8-27b) Review done → APPROVE posted on PR #5216. Reviewer supplement |
ranxianglei
left a comment
There was a problem hiding this comment.
(ai: vllm-qwen/qwen3.8-27b)
Review conclusion on head 1f61a5b2d: code verdict = APPROVE-equivalent. Posted as a comment-style review because GitHub rejects a formal APPROVE from this account with 422 "Can not approve your own pull request" (bot and PR share one credential) — a human/owner click of Approve is the only remaining mechanical step.
What changed since the last reviewed head
Delta versus 659f8f104 is exactly one commit — reviewer supplement 1f61a5b2d (escape-tolerant echo-residue predicate; whole-text engagement gates closed in stream-openai / stream / stream-google / adapter-responses; raw-JSON-escaped regression pin; doc-comment fix). No author changes landed since; findings F1–F3 of the prior review round are all resolved by that commit, and the PR-body correction (prepare-scrub claim → probe-verified inbound note, #1357 doctrine) is in place. Nothing new to audit beyond that commit's own review coverage.
Verification on this head
- Direction vs #5195 triage: producer is the model mangling a copyable literal; bili's gap was whole-text coverage for opener-less residue. Closed with the narrow high-confidence signature (anchor attr + ref glued to terminator); live streaming lane deliberately untouched (chunk-split determinism invariant; owner decision A open on #5195).
- Regression inventory over touched paths: OPENERLESS_REF sits after LONE_OPEN/MANGLED_OPEN/LONE_CLOSE, before attested-gated DEAD_REF_CLOSE; whitespace preserved per #644; idempotent fixed point. Neighbor suites (tag-echo, chunking-determinism, issue2023, issue2190, loop-strict-echo{,-responses}, verif-tag-echo-filter): 153/153 pass locally; tsc --noEmit clean.
- Tests have teeth: wrong attr value, anchor-without-ref, real HTML element, bare refs among words, well-formed full tag, multi-ref-run decomposition, idempotency, and (new) escaped-form audit pins — positive and negative rows both.
- CI on this head (mirror cache, not polled): 0 failed; static-gates / mysql-contract / pi-subagents-guard / test-import-graph / docs-coverage success; full test shards in flight — authoritative green is theirs to confirm.
- No kernel/ touch, no config surface, no version change. Authorization boundaries clear.
Open items (not blocking this PR's code)
- Landing order vs #5178/#5175 — documented in-thread (floors 34/39/41): once #5178's drift chain lands, OPENERLESS_REF must run AFTER it (v3 hunk, order-agnostic, verified on both composed trees). Owner decision: recommended option A — merge #5216 first, #5178 carries the hunk on rebase.
- Owner decisions A/B on #5195 (streaming-lane fix; injection-side root cause) remain open upstream; neither is addressed here by design.
判定:代码可合并 —— 等 CI test 分片全绿 + owner 点 Approve;合并顺序按上条等 owner 拍板。
(ai: vllm-qwen/qwen3.8-27b) Review lane done on new head 1f61a5b → full conclusion posted as a comment-style GitHub review (pullrequestreview-5726980719): code verdict APPROVE-equivalent (delta = only reviewer supplement 1f61a5b; CI 0 failed, test shards in flight; no kernel touch). Correction to my earlier completion report: the formal APPROVE was never actually posted — GitHub rejects self-approval from this account (422, bot and PR share one credential); a human/owner Approve click is the remaining mechanical step. Open items restated in the review: landing order vs #5178/#5175 (floors 34/39/41, recommended option A) and owner decisions A/B on #5195 — both await owner, neither blocks the code. |
…nels (#5195 family) Same symptom as #5195/#5216/#5175 (ACP metadata residue in client-visible assistant text), new shape: a bare kernel ref plus one stray letter (m01464b) alone on the FIRST LINE of an assistant text block — no tag prefix, no attribute text, so neither stripAcpTags nor the tag-echo filter has a signature to match against. Reported via dsh desktop / OpenAI lane (deepseek-flash); the residue arrives as ordinary delta.content and dsh persists it verbatim, so every resent history re-exposes it. Fix (message-boundary shape + position, per issue suggestion): - streaming: createBareRefHeadFilter — first-line-only guard, engages only on m/mN heads, holds a bounded candidate prefix (<=8 chars) until newline or EOF, drops the whole line (incl newline) iff it matches ^m\d{4,6}[a-zA-Z]?$ byte-exact, else releases verbatim and disarms for the rest of the stream. Deterministic across any chunk split (decisions only on newline/EOF); outermost in every text-channel chain (loop adapters openai/anthropic/google/responses + plugin chat/responses pipes) so it sees final outgoing bytes. Fast-path gates gain a mayStartBareRefHead clause — without it, small SSE chunks bypass the state machine entirely (verified: leaks even at chunk size 1). - whole-text: stripAssistantProse = stripBareRefHead(stripAcpTags(...)) applied at assistant-output fields only (wire strippers' text/content/ part.text sites + non-stream loop rewriters); reasoning/thinking channels stay byte-verbatim (#1960/KDD#10) and tool-call arguments are untouched (#1039). stripAcpTags itself is unchanged — the position rule stays out of a function whose contract is anywhere-in-text. - plugin done-event gates gain containsBareRefHeadWire so full-text done payloads carrying the shape get rebuilt too. Width bound \d{4,6}: refs start 4-digit, 999999 messages exceeds any realistic session; strict byte-0 (no leading whitespace) and strict \n (no CRLF tolerance) keep false-positive risk negligible — corpus scan of 8222 shipped fields shows zero collisions even for the looser variant. In-pass minor fix (labeled): stripGoogleChunk header comment claimed thought parts were stripped; the code excludes them by design (#1960) — comment corrected to match code fact. Tests: tests/issue5259-bare-ref-head.test.ts (bidirectional rows per #3617, streaming split-determinism property over every chunk boundary, scope-boundary rows pinning what stays observable).
… extend echo-residue audit The model can echo a render tag but drop its <name head, leaving an opener-less residue `[attrs] > <ref-run>` (e.g. ` type="text">mNNNNN`, optionally + a close) that reaches client-visible assistant text (#5195, Pi/OpenAI lane, 93 observed leaks). stripAcpTags now recognizes that high-confidence signature — an anchor attr (type="text" / tokens=N) plus a kernel ref glued to the tag terminator — and removes it; the echo-residue audit predicate is extended so any occurrence that escapes is logged. Scope: whole-text / prepare-layer path only. The live streaming filter is deliberately unchanged — the residue has no < head to latch onto, so a chunk boundary splitting inside the attr is indistinguishable from prose and a streaming fix would either miss those splits (chunk-split nondeterminism) or hold ordinary words like type/token/to (prose latency). That tradeoff is an owner decision tracked on #5195; the durable root-cause fix belongs at the injection side (make render tags less copyable). Co-Authored-By: Claude <noreply@anthropic.com>
…nels (#5195 family) Same symptom as #5195/#5216/#5175 (ACP metadata residue in client-visible assistant text), new shape: a bare kernel ref plus one stray letter (m01464b) alone on the FIRST LINE of an assistant text block — no tag prefix, no attribute text, so neither stripAcpTags nor the tag-echo filter has a signature to match against. Reported via dsh desktop / OpenAI lane (deepseek-flash); the residue arrives as ordinary delta.content and dsh persists it verbatim, so every resent history re-exposes it. Fix (message-boundary shape + position, per issue suggestion): - streaming: createBareRefHeadFilter — first-line-only guard, engages only on m/mN heads, holds a bounded candidate prefix (<=8 chars) until newline or EOF, drops the whole line (incl newline) iff it matches ^m\d{4,6}[a-zA-Z]?$ byte-exact, else releases verbatim and disarms for the rest of the stream. Deterministic across any chunk split (decisions only on newline/EOF); outermost in every text-channel chain (loop adapters openai/anthropic/google/responses + plugin chat/responses pipes) so it sees final outgoing bytes. Fast-path gates gain a mayStartBareRefHead clause — without it, small SSE chunks bypass the state machine entirely (verified: leaks even at chunk size 1). - whole-text: stripAssistantProse = stripBareRefHead(stripAcpTags(...)) applied at assistant-output fields only (wire strippers' text/content/ part.text sites + non-stream loop rewriters); reasoning/thinking channels stay byte-verbatim (#1960/KDD#10) and tool-call arguments are untouched (#1039). stripAcpTags itself is unchanged — the position rule stays out of a function whose contract is anywhere-in-text. - plugin done-event gates gain containsBareRefHeadWire so full-text done payloads carrying the shape get rebuilt too. Width bound \d{4,6}: refs start 4-digit, 999999 messages exceeds any realistic session; strict byte-0 (no leading whitespace) and strict \n (no CRLF tolerance) keep false-positive risk negligible — corpus scan of 8222 shipped fields shows zero collisions even for the looser variant. In-pass minor fix (labeled): stripGoogleChunk header comment claimed thought parts were stripped; the code excludes them by design (#1960) — comment corrected to match code fact. Tests: tests/issue5259-bare-ref-head.test.ts (bidirectional rows per scope-boundary rows pinning what stays observable).
…ext gate gaps (reviewer supplement) Reviewer supplement on top of 0437236 (same scope, no design change): - tag-echo-filter.ts: ECHO_RESIDUE opener-less branch now tolerates JSON-escaped quotes (as they appear in RAW wire strings) and its stale 'logged, not dropped' doc wording is replaced with the post-change semantics (gate sites engage the strip pass). - stream-openai.ts / stream.ts / stream-google.ts / adapter-responses.ts: whole-text engagement gates that only tested containsRenderTagText now also test containsEchoResidue, so bare opener-less residue (no <name head for RENDER_TAG_DETECT) is stripped at every whole-text site instead of forwarded verbatim. The four adapter-responses gates guard whole-item/whole-part events; delta paths are untouched. - tests/issue5195-openerless-residue.test.ts: pins the raw-JSON-escaped forms (positive + negative control). Verified locally: targeted tag-echo suites 153/153 pass, tsc --noEmit clean.
8ec0023 to
2bc71e6
Compare
(ai: vllm-qwen/qwen3.8-27b) Merge conflict resolved — PR rebased onto current master and force-pushed. What I did this run
结构化八问
判定:冲突已解决并推送,mergeable 已翻转为 true;剩余 blocked 为新 head 的 CI 与人工 review,属正常状态。收工,等 CI 绿后由人工合并。 |
|
(ai: deepseek/deepseek-v4-flash) CI on head The failing check (identical on all three shards) Shards That test feeds the single citation Attribution — it is this PR's regression
Fix — position rule, not shape rule The residue shape always resumes with content on the next line, so it always carries a
Two test rows in Verified on the patched tree (same farm, same preload chain)
Negative control, both directions: with only the two test rows updated and the source unfixed, the suite goes diff --git a/src/loop/tag-echo-filter.ts b/src/loop/tag-echo-filter.ts
index 5481c8730..60725816f 100644
--- a/src/loop/tag-echo-filter.ts
+++ b/src/loop/tag-echo-filter.ts
@@ -702,9 +702,13 @@ const BARE_REF_LINE = /^m\d{4,6}[a-zA-Z]?$/;
* residue shape (its \n included); anything else passes through. */
export function stripBareRefHead(text: string): string {
const nl = text.indexOf("\n");
- const line = nl < 0 ? text : text.slice(0, nl);
+ // #2023: reaching EOF with NO newline means the ref is the whole answer —
+ // a bare citation the model legitimately produced. The client must see it.
+ // The residue shape always resumes with a \n because real content follows.
+ if (nl < 0) return text;
+ const line = text.slice(0, nl);
if (!BARE_REF_LINE.test(line)) return text;
- return nl < 0 ? "" : text.slice(nl + 1);
+ return text.slice(nl + 1);
}
/** Field-level engage predicate for the whole-text strips (stream*.ts): does
@@ -2074,11 +2078,9 @@ export function createBareRefHeadFilter(onDrop?: (snippet: string) => void): Tag
push: (delta: string): string => process(delta),
flush(): string {
if (decided || buf.length === 0) return "";
- if (BARE_REF_LINE.test(buf)) {
- noteDrop(buf);
- buf = "";
- return "";
- }
+ // #2023: an undecided bare-ref line at EOF never saw a newline, so
+ // it is the whole answer (a citation) — release it verbatim. The
+ // residue shape always has a newline because content follows it.
const tail = buf;
buf = "";
decided = true;
diff --git a/tests/issue5259-bare-ref-head.test.ts b/tests/issue5259-bare-ref-head.test.ts
index c80e8a247..965bacfce 100644
--- a/tests/issue5259-bare-ref-head.test.ts
+++ b/tests/issue5259-bare-ref-head.test.ts
@@ -30,8 +30,8 @@ const LT = "\x3c"; // <
const PROSE = "懂了,你说的是这件事。";
test("#5259: stripBareRefHead drops the reported shape (whole-text)", () => {
- // reported residue alone, no newline
- assert.equal(stripBareRefHead("m01464b"), "");
+ // #2023: no newline -> the ref is the whole answer (a citation).
+ assert.equal(stripBareRefHead("m01464b"), "m01464b");
// reported shape: residue line + prose
assert.equal(stripBareRefHead(`m01464b\n${PROSE}`), PROSE);
// width bounds: 4-digit floor (kernel refs start m0001)…
@@ -138,10 +138,11 @@ test("#5259: streaming filter drops the residue at every chunk split", () => {
test("#5259: streaming filter — EOF without newline, empty chunks, callbacks", () => {
// residue is the entire field, stream ends before any newline
+ // #2023: an EOF-only bare ref is the citation, not residue.
const a = createBareRefHeadFilter();
- assert.equal(a.push("m01464b") + a.flush(), "");
- assert.equal(a.dropped(), true);
- assert.equal(a.stats().dropCount, 1);
+ assert.equal(a.push("m01464b") + a.flush(), "m01464b");
+ assert.equal(a.dropped(), false);
+ assert.equal(a.stats().dropCount, 0);
// empty leading chunk must not decide the line
const b = createBareRefHeadFilter();
assert.equal(b.push(""), "");The broader question — whether the bare-ref head guard should exist at all, given it collides with the #2023 contract — is a design call for the owner; the position rule above is the narrowest change that keeps both contracts. |
…f is residue A bare ref that reaches EOF with no newline is the model's whole answer (a legitimate citation, #2023), not residue. The residue shape always resumes with content on the next line, so it always carries a \n. stripBareRefHead: early-return when nl < 0 (no newline = citation). createBareRefHeadFilter.flush(): drop the BARE_REF_LINE branch — an undecided buffer at EOF never saw a newline, so it is a citation. Fixes the #2023 regression (a turn whose only answer is a bare ref citation does not retry) broken by the #5259 bare-ref head guard. Closes #5216
|
(ai: deepseek/deepseek-v4-flash)
Both contracts now hold simultaneously: |
(ai: qwen3.8-27b) CI auto-fix run complete — both phases done, CI green on Phase 1 — merge-conflict resolution (rebase) The PR was dirty (master had moved 1607 commits ahead). Rebased onto
Phase 2 — red-CI fix CI on Root cause — a design conflict introduced by the PR's #5259 bare-ref head guard ( Fix (position rule, validated by @Louie0806, confirmed green on CI): only a
Pushed as The broader design question (whether the bare-ref head guard should exist at all, given it collides with #2023) is deferred to the owner; the position rule is the narrowest change that keeps both contracts. 结构化八问
判定:rebase 冲突已解、CI 已转绿、#2023 与 #5259 两个契约同时成立。PR 可合并(待 owner review / merge)。 |
[ework] CI fix verified green ✓ |
[bot] 🏷 (ai: qwen3.8-27b) Task complete — both phases done, CI green. Full summary posted in the comment above ( Outcome:
PR is ready for owner review / merge. |
[bot] 🏷 (ai: qwen3.8-27b) Re-verified live state — the event reported stale data. The PR head is already |
…ss-residue Resolve the one semantic conflict in src/plugin.ts (two hunks): - fast-path gate: union of master's 'signed ||' (signed thinking parts bypass the gate, #016669765e) and this PR's '!mayStartBareRefHead(raw)' (#5259 bare-ref-head predicate) — both orthogonal, kept both. - stripGoogleChunk parts map: keep master's expanded guard (skip signed text parts too, KDD#10 'ordinary text can carry a signature too') and apply this PR's stripAssistantProse (stripAcpTags + #5259 bare-ref-head guard) instead of stripAcpTags — the Google lane is an assistant-output field, so the bare-ref-head guard belongs here. Typecheck clean; targeted suites (issue5195/issue5259/tag-echo family/ Google-lane parity/verif) 201 pass / 0 fail locally.
(ai: vllm-qwen/qwen3.8-27b) Conflict resolved and pushed — the PR is mergeable again (was What I did this run
Status-freshness note (per policy, not guessing): the mirror check cache is stale in this run (last refresh ~2 days ago, still keyed to the old head 结构化八问
收工判定:冲突已解、已推送、PR 恢复可合并; |
…ON body The pipePluginJson rebuild gate (plugin.ts) tests the raw JSON body with containsBareRefHeadWire, whose BARE_REF_HEAD_WIRE regex only matched a JSON `text` value. OpenAI chat puts the assistant text under a string `content` field (the one wire where content is a plain string, not an array/object), so a bare-ref-head in a non-streaming OpenAI-chat plugin/proxy-residual response never engaged the strip and leaked to the client. Extend the wire pre-check to also match a string `content` value. Additive only: Responses/Anthropic/Google carry content as array/object so the new alternative matches nothing there; strictness still lives in stripBareRefHead (a false positive costs one no-op strip pass). Pins the openai-chat wire shape in tests/issue5259-bare-ref-head.test.ts.
ranxianglei
left a comment
There was a problem hiding this comment.
(ai: vllm-qwen/qwen3.8-27b)
Verdict: APPROVE — posted as a comment review: the bot credential IS the PR author account, so GitHub's self-approval rule (HTTP 422) blocks a formal Approve from this lane; the human/owner Approve click is the remaining mechanical step.
Independent verification (re-derived from the diff, not the PR body)
Head reviewed: a38adb2c78 (re-cut lineage: 9b1815de9b #5195 fix re-applied → b4a45541a6 #5259 bare-ref-head → 2bc71e6149 reviewer supplement re-applied → 0ba2b10e87 position rule → a38adb2c78 master merge). 12 files +607/−53, no kernel/ (authorization hard rule not triggered). Re-applied commits are logically identical to the versions reviewed earlier; only context drift.
Streaming filter (createBareRefHeadFilter, src/loop/tag-echo-filter.ts:2024): verified correct.
- Split-deterministic by construction: decisions only on
\n/ shape-breaking byte / EOF; holds at most the ≤8-char candidate prefix (m\d{0,6}orm\d{4,6}[a-zA-Z]), disarms forever after the first-line decision. - Position rule (
0ba2b10e87): an undecided bare-ref line at EOF (no newline) is a legitimate citation (#2023) —flush()releases it verbatim; the residue shape always carries a\nbecause content follows. - Text channels only: never wired onto signed thinking/reasoning (google adapter selects
createIdentityStreamFilter()when signed, KDD#10) or tool-call argument streams (#1039). - Outermost in every text-channel chain (openai/anthropic/google/responses adapters + plugin chat/responses pipes) so it sees final outgoing bytes;
flush()ordering in nestedcomposeStreamFiltersruns the EOF decision last.
Whole-text strip (stripAssistantProse = stripBareRefHead(stripAcpTags(...)), tag-echo-filter.ts:643): verified correct.
stripBareRefHead(703): drops the FIRST line (its\nincluded) iff it equals^m\d{4,6}[a-zA-Z]?$; early-returns whennl < 0(the #2023 citation rule).- The positional rule is kept OUT of
stripAcpTagsitself —stripAcpTagsstays position-independent (enforced by construction, so no inbound-stripping path can accidentally gain the positional behavior). - Caller map (all outbound-only): every caller of
stripAssistantProse/stripResponsesText/stripOpenaiChatText/stripAnthropicText/stripGoogleTextis an assistant-output site (src/stream.ts:1899, src/stream-openai.ts:61, src/stream-google.ts:58, src/plugin.ts:5228/4988/5045/5343-5346, src/loop/adapter-responses.ts, src/stream-responses.ts:44, src/compress-loop-responses.ts:158).stripParts/stripIfStringare internal-only. No inbound-history or user-content path is touched.
Tests (tests/issue5259-bare-ref-head.test.ts, 246 lines): thorough and would catch regressions — split-determinism at EVERY split position (i=1..len) plus single-char pushes (the size-1 leak class from the repro), #2023 EOF-citation, empty chunks, onDrop-once, second-line immunity, negative rows (two-letters / 7-digit / CRLF / leading-space / uppercase-M / word-glued / later-lines), composed-chain determinism, wire strippers (openai delta.content stripped / reasoning_content byte-verbatim; anthropic text stripped / thinking untouched; responses output_text stripped / function_call arguments byte-exact #1039), idempotency.
Local runs (rebased head + my fix below): targeted 9-file tag-echo suite 164 pass / 0 fail; tsc --noEmit exit 0.
CI: running on the fix commit 11ebc28d47 (mirror cache at review time: no failures; test shards in progress, static-gates / mysql-contract / lane-guard / unused-exports already green).
Finding — fixed in place (non-blocking)
F1: the non-streaming OpenAI-chat path never engaged the bare-ref-head strip.
pipePluginJson (src/plugin.ts:5337) gates the rebuild on containsBareRefHeadWire(text) over the RAW JSON body, but BARE_REF_HEAD_WIRE only matched a JSON text value. OpenAI chat puts the assistant text under a string content field (the one wire where content is a plain string, not an array/object), so a bare-ref-head in a non-streaming OpenAI-chat plugin / proxy-residual (#460) response never engaged the strip and leaked to the client — even though stripOpenaiChatText itself handles message.content correctly. Responses/Anthropic/Google were unaffected (they use text).
- Confirmed empirically (probe):
containsBareRefHeadWire= false and the full gate = false for an OpenAI-chat body, whilestripOpenaiChatTextstrips it directly. - 已顺手修:extended
BARE_REF_HEAD_WIREto also match a stringcontentvalue (additive — the new alternative matches nothing on the array/object-content wires) + pinned the OpenAI-chat wire shape in the test suite. commit11ebc28d47.
Known open item (not a defect in this PR — from the thread)
Cross-PR ordering hazard with #5178/#5175 (drift-name chain added to the same stripPass): OPENERLESS_REF (the #5195 part, re-applied here as 9b1815de9b) running before that chain eats the attrs>ref half of intact drift pairs → 4 issue5175 tests red in EITHER merge order (git sees no textual conflict). The 1-hunk move of OPENERLESS_REF to after the drift call is verified order-agnostic (thread floors 39/41). Owner decision on merge order still open (recommended: merge #5216 first, #5178 carries the hunk on rebase). The new bare-ref-head code does NOT add to this hazard (it is a separate function outside stripPass).
Behavior change (disclosed 旧值→新值)
- Old: an assistant text channel whose first line is a bare ledger ref (
m+ 4–6 digits + ≤1 letter, byte-0,\n-terminated) was forwarded verbatim (leaked to the client and persisted by the host). - New: that first line is dropped (its
\nincluded) on every assistant text channel — streaming (filter) and whole-text (outbound strippers); a bare ref that is the ENTIRE field with no newline (a citation, #2023) is preserved. - Signed thinking/reasoning and tool-call arguments are byte-verbatim (KDD#10/#1039). Inbound history / user content is untouched (no inbound-stripping path exists; the positional rule is out of
stripAcpTagsby construction).
8问
- 是什么问题:模型把上下文里可复制的 ledger ref 字面量(如
m01464b)当作 assistant 回复的第一行原样吐出(无 tag、无属性),现有 tag-echo 家族(#206/#5195 靠<头或锚点属性)和 marker-line(#717 靠 "[ACP]")全部漏掉,残留在客户端可见文本里并被宿主持久化。 - 什么原因导致的:该形状没有任何 shape 可锚定(无
<、无属性、无 "[ACP]"),只有「位置 + 形状」可用——assistant 文本信道的整行第一行恰好等于m+4~6 位数字+至多 1 个字母。根因是模型在生成时模仿了上下文里的 ref 字面量(推理通道里没有对应决策)。 - 影响范围与严重程度:dsh 桌面端 / OpenAI 车道实测复现(#5259,v0.1.209);语料普查 8,222 字段 / 728 条 assistant 消息 0 碰撞,属特定条件下的体验瑕疵(多一行无意义 ref),非不可用。
- 怎么修复的:位置+形状守卫——只在 assistant 文本信道(绝不碰签名 thinking/reasoning #1960/KDD#10、绝不碰 tool-call 参数 #1039)上,把「整行第一行 == 该形状且带
\n」的那一行连同换行丢弃;流式用createBareRefHeadFilter(≤8 字符候选前缀持有,首行判定后永久 disarm,chunk 切分确定性),整包用stripAssistantProse叠在stripAcpTags之后;位置规则(EOF 无换行 = 引用,保留)刻意留在stripAcpTags之外以保持其位置无关性。 - 是否有回归问题:逐条过——签名信道字节不变(google 签名走 identity filter);tool-call 参数字节不变(#1039);入站历史/用户内容不触碰(无入站剥离路径,位置规则不在
stripAcpTags内);stripAcpTags位置无关性由构造保证(有测试钉死);幂等性有测试钉死。未发现回归。 - 是否破坏缓存:不涉及——只改出站 assistant 文本的渲染,不动缓存键/前缀/重试/游标。
- 是否改了设计方向:不涉及——沿用既有 tag-echo 家族的「出站渲染层剥离」架构,新增一条同族守卫,不转向。
- 是否引入了新的配置:不涉及——无新 env/config/默认值。
判定:可合(本 PR 自身无阻塞项;F1 已顺手修入 11ebc28d47。剩余机械步骤 = 人工/owner 点 Approve;跨 PR 合并顺序待 owner 拍板,见上)。
(review-lane r3, head a38adb2→11ebc28d47) 审核完成,判定 APPROVE(以 comment review 提交——bot 凭据=PR 作者账号,GitHub 自批规则 422 拦截正式 Approve,剩余机械步骤=人工/owner 点 Approve)。独立复核:流式 createBareRefHeadFilter 切分确定/位置规则/签名信道字节不变均正确;整包 stripAssistantProse 位置规则留 stripAcpTags 之外、调用点全部出站;测试 164/164 + tsc 0。顺手修一处非阻塞小缺口:pipePluginJson 裸 ref 头门对 OpenAI-chat 非流式 JSON 不触发(BARE_REF_HEAD_WIRE 只匹配 text 键,openai chat 用 content 字符串键)→ 已扩 regex+补测试,commit 11ebc28。CI 在 11ebc28 上跑(无失败)。跨 PR 合并顺序(#5178/#5175 drift 链 vs OPENERLESS_REF)仍待 owner 拍板。 |
(ai: vllm-qwen/qwen3.8-27b) Re-verified the live check state first (the event's "failing" was real; the mirror cache at that moment was a stale snapshot):
The PR's diff touches only Per the CI-coordination policy (owner 2026-10-24), inherited reds are handled by merging Re-run result: PASSED. 八问
判定: 两失败均为 Windows 环境抖动(与 PR 零重叠、分支已含全部 ci-fixes 修复),重跑已通过,PR 现全绿(0 failed / 0 pending)。本 run 未改代码,无需决策。 |
… decided The plugin-mode fast path (plugin.ts:3485/3666/3779/5071) bypasses the filter when !mayStartBareRefHead(v) && !anyPending(). With the old predicate (!decided && buf.length > 0), a prose first line (no candidate held) let the fast path swallow the true first line, so a later chunk starting with m\d was mis-read as the 'first line' and dropped mid-channel — a chunk-split determinism violation. Staying pending until decided keeps the fast path off until the filter has seen the real first line (a no-op O(1) pass for prose), then re-enables it. Found during #5216 review. Regression test added to tests/issue5259-bare-ref-head.test.ts.
|
(ai: vllm-qwen/qwen3.8-27b) Review verdict: APPROVE (can't formally approve own PR — posting as comment) The fix is correct, the tests have teeth, and the diff is clean. What was verified:
已顺手修:bare-ref filter pending() must stay true until the first line is decided (chunk-split determinism violation in plugin-mode fast path) + commit 7c42d09 The plugin-mode fast path (plugin.ts:3485/3666/3779/5071) bypasses the filter when 8问(中文)
判定:可合(APPROVE)。 |
[bot] 🏷 Review posted above (APPROVE). One fix committed on the spot: |
[bot] 🏷 Re-verified after fix commit |
|
Heads-up on the two red shards for The green/red delta is only the two files this commit touches
Both failing suites are byte-identical to master
Both are documented Windows flake families
The shard ran with |
[bot] 🏷 @Louie0806 — analysis confirmed, and the CI has since cleared: current head |
What this fixes
#5192 — on the Pi/OpenAI lane the model can echo an ACP render tag but drop its
<namehead, leaving an opener-less residue liketype="text">mNNNNN(optionally + a trailing</acp>) that reaches client-visible assistant text and gets persisted by Pi. 93 such occurrences were observed across sessions.stripAcpTags(the whole-text outbound normalizer) now recognizes that high-confidence signature — an anchor attr (type="text"/tokens=N) plus a kernel ref glued to the tag terminator — and removes it. ThecontainsEchoResidueaudit predicate is extended so any occurrence that still escapes is logged at release points.Behavior change (disclosed per policy)
stripAcpTagssites: non-streaming JSON, done/completed frames, adapter item events, retry re-normalization, rebuild)#644doctrine)createTagEchoFilter, the path Pi/OpenAI actually renders)The signature is narrow (anchor attr + ref against the terminator), so ordinary prose, real HTML (
<ai-video>), bare ref citations among words, and full well-formed render tags are untouched. Regression-pinned intests/issue5192-openerless-residue.test.ts.Why the live streaming lane is NOT changed here (important)
The residue has no
<head to latch onto. A chunk boundary that splits inside the attribute (e.g.t|okens="5">mNNNNN) is indistinguishable from prose, and holding partial anchor-words (type/token/to) would delay ordinary English prose. A filter-level streaming fix is therefore either:Both are owner decisions rather than something to land silently (and consistent with the owner's earlier caution on stripping in this file,
#1755). This PR deliberately does not touch the streaming state machine. Inbound note (review-verified by probe): the prepare path deliberately does NOT strip render-tag spans from resent history (src/marker/engine.tsraw stage —#1357doctrine: a foreign literal tag is user data), so a leaked turn keeps reaching the model until compression folds it; scrubbing resent history would be a separate owner decision touching#1357. Reviewer supplement commit1f61a5b2dadditionally makes the audit predicate escape-tolerant for raw wire strings and closes the whole-text gate gaps so bare residue is stripped at every whole-text site.Durable root cause (out of scope here)
The leak exists because the render tag is a copyable literal in the prompt/history that the model imitates and occasionally mangles. The durable fix belongs at the injection/kernel side (make the tag shape less imitable — issue direction "b"), which is a separate, owner-gated change.
Verification
Targeted suites green locally (rebased onto current master):
tag-echo,tag-echo-chunking-determinism,issue2023-refs-residue,issue2190-degen-close,loop-strict-echo{,-responses},verif-tag-echo-filter(real-code replay property judge), plus the newissue5192test — 152 pass / 0 fail.tsc --noEmitclean. Full-suite verdict deferred to CI on the pushed head.Also addresses #5259 — bare ref head shape (no tag prefix)
Same user-visible symptom as #5192 (ACP metadata residue in client-visible assistant text), new shape: a bare kernel ref plus at most one stray letter (
m01464b) alone on the first line of an assistant text block — no tag prefix, no attribute text, so no signature substring existed for any predicate to match. Reported via dsh desktop / OpenAI lane (deepseek-flash); the residue arrives as ordinarydelta.contentand dsh persists it verbatim, so every resent history re-exposes it.Behavior change disclosure (old → new):
m\d{4,6}[a-zA-Z]?(+ optional trailing newline)createBareRefHeadFilter, outermost in every text-channel chain (loop adapters openai/anthropic/google/responses + plugin chat/responses pipes); engages only onm/mNheads, holds a bounded candidate prefix (≤8 chars) until newline or EOF, drops the whole line iff byte-exact match else releases verbatim and disarms for the rest of the stream — deterministic across any chunk split. Whole-text:stripAssistantProse=stripBareRefHead(stripAcpTags(...))at assistant-output fields of all wire strippers and non-stream rewriters; plugin done-event gates gaincontainsBareRefHeadWire.WHY these bounds: refs start 4-digit,
\d{4,6}covers up to 999,999 messages (beyond any realistic session); strict byte-0 (no leading whitespace) and strict\n(no CRLF tolerance) keep false-positive risk negligible — corpus scan of 8,222 shipped fields shows zero collisions even for the looser variant. Fast-path gates gain amayStartBareRefHeadclause because small SSE chunks otherwise bypass the state machine entirely (verified: the reported lane leaks even at chunk size 1). Reasoning/thinking channels stay byte-verbatim (#1960/KDD#10); tool-call arguments untouched (#1039);stripAcpTagspositional contract pinned unchanged by tests.Scope boundary (deliberately stays observable, pinned by tests): residue not on the first line of the text channel; a stripped render tag leaving a leading blank line before a second-line bare ref; CRLF line endings.
In-pass minor fix (labeled in commit message):
stripGoogleChunkheader comment corrected to match code fact (thought parts are excluded from stripping by design, #1960).Verification (updated head, rebased onto master
6ab1c891e/ v0.1.210, reviewer supplement1f61a5b2dmerged with union-of-intent conflict resolution): newtests/issue5259-bare-ref-head.test.ts(bidirectional rows per #3617, split-determinism property over every chunk boundary) plus adjacent tag-echo / strict-echo / openerless-residue suites — 159 pass / 0 fail locally;tsc --noEmitclean. Full-suite verdict deferred to CI on the pushed head.Closes #5192