Repository navigation
fix(#2190): strip model-emitted degenerate-close echo residue in streaming + whole-text paths - #2211
Conversation
Models imitate ACP render tags with drifted close names (field census: ap/p/a/apc/cap/ck/div/warn/aph/ambient/apm) that no matcher recognizes. The stream filter then swallows the open tag, hits its budget or EOF, and either releases the 'mNNNNN</word>' residue verbatim (mid-stream) or silently drops the following prose (flush). Whole-text stripAcpTags had no pair rule for degenerate closes either. - swallow mode now accepts any short close name as terminator when the body since the opening is exactly one bare ref (degenCloseAfterRef); wrapped-imitation mode is excluded (payload may hold arbitrary markup) - stripAcpTags gains DEGEN_PAIR: acplike open + bare ref + any short close removed atomically, before the lone passes - fast path gains mayStartDegenerateRenderTag (broad <word tail <=16) so degenerate heads engage the state machine instead of riding through; kept out of PARTIAL_TAIL/mayStartRenderTag so #1760 orphan-markup accounting still classifies prose tails like 'a<b' as prose - completion pre-checks gain containsEchoResidue so residue-shaped final artifacts go through the whole-text rebuild path - new warn logs at fast-path forward and filter release points make the formerly silent leak observable (#2190 fix suggestion 4) Behavior change: ref-body spans closed by a degenerate name are now stripped instead of leaking or evicting adjacent prose; fast path engages one fragment earlier on ambiguous '<word' tails (bounded delay, no byte loss). No config surface change; kernel untouched.
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.2334-pr.2211.d3e3d45This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr2211.tgz
npm install -g packageInstall instructions are refreshed on each push. |
[bot] 🏷 收到,开始对 PR #2211 做 review(代码 + 回归审查 + CI 状态核对)。初查:分支单 commit |
CI 状态说明:首跑 22 个 check 中 21 绿,唯一失败是 |
[bot] 🏷 Review 完成。本地做了定向验证(非全量,全量归 CI):PR head 上 tag-echo 家族 13 个测试文件 207/207 绿;新测试的「有牙性」用 A/B 复现钉住——把两个核心文件回退到 base(5e43209)后,issue 实测 chunk 序列经完整 gate+filter 链回放,pre-fix 输出 结构化七问
既有行为回归审计(审了哪些、各自结论)
测试有效性11 例真测试:实测 chunk 序列逐 delta 过完整 gate 链、普查 11 种闭名逐一、多标签 blob、EOF flush、wrapped-imitation 守卫、HTML 误报守卫( 已知残留(记录)
Base 状态分支落后 master 103 commits,但逐一核对:6 个改动文件中 5 个在 base 与当前 master 间字节相同;唯一差异 判定可合。 方向对(修的是产生残骸的识别机制,不是症状层过滤)、回归面逐项过净、测试有牙且本地 A/B 证实、行为变更已按规披露、无新配置。残留 #2 不阻塞合并。 |
…tack compat) One-line compat for the agreed #2025 -> #2211 -> #2067 merge order: #2025 folds the master REF_LIKE constant into REF_TOKEN/REFS_RUN, which would leave this call dangling (silent tsc break once stacked, each PR green alone). Standalone const carries the identical regex /^\s*m\d{4,}\s*$/; behavior unchanged.
…audit raw-forward exits - buildAcplikeName: add acacp/accessp/acpx/acb (case-folded, exact enumeration; char-class generalization rejected — FP risk on real words like acgroup/acmap). All name-derived matchers pick them up; 229-session census validated 10/10 leak forms cleared, 170/170 legit-word contexts preserved. - plugin.ts: log-only residue audits at the unfiltered raw-forward exits (processOpenai E1 no-choices branch + E5 tail fallthrough, chat/responses JSON.parse-fail branches); openaiFrameHasToolCalls excludes argument frames (#1039 byte-exact). - tests: +4 drift-name cases in issue2190 suite (streaming char-by-char, cross-name pairing, whole-text, gate predicates, legit-word survival); tag-echo.test.ts fixture <acpx> -> <abc> since acpx is now a recognized echo name by design.
… ignore .tmp/ The stacked compat commit accidentally committed node compile-cache binaries and test artifacts under .tmp/ (diff-cleanliness gate). Untrack only; .gitignore gains .tmp/ (it had tmp/ but not .tmp/, which is how they got in).
…es-wire exits The #2190 exit audit (auditRawForward) covered only the openai E1/E5 and both parse-fail exits; the isomorphic raw exits named in the #2248 mechanism table were still silent, leaving holes in the zero-log-leak attribution net. Log-only, zero byte change (#1039 wire fidelity preserved by construction): - processAnthropic: content_block_start / non-delta events / unmanaged delta types (input_json_delta excluded — tool-call arguments are user intent). - processGoogle: non-candidates frames + tail fallthrough (frames carrying non-text parts excluded via googleFrameHasNonText — functionCall/ functionResponse are structured or user data). - responses pipe: unrecognized-type fallthrough (responsesFrameHasToolCalls excludes function_call/custom_tool_call argument streams). Tests: new issue2248 suite pins all ten audited exits (warn fires AND byte-exact forward) plus the three argument-frame exclusions and two clean negative controls; also pins the four #2190 sites which shipped without direct tests.
…amination Open-side census counts are inflated by models quoting tag names inside their own reasoning. Under the decontaminated standard (block-initial emission + tokens= attribute + deduped n>=4), only accessp/acacp/acb qualify; acpx's raw census (~217) proved self-referential/constructed with one case-variant sighting only. Excluded forms stay observable via the #2190 residue audits, so a clean attestation earns re-inclusion. tag-echo.test.ts fixture reverts to its original <acpx> sample, which is ordinary markup again under the reduced name set.
… always logs a drop
…ps via ref-anchored open-set rule
|
[bot] 🏷 Round 8 收口:新增提交 e4e0f96(test-only)把 #2190 线程的字段级反例 seq=22409(71 个真实 tokenizer 分片、末标签闭名漂成退化短词、k 不在任何 acplike 字符类)钉成回归测试——回放零泄漏,证明闭名侧的 ref 锚定开放集规则(degenCloseAfterRef/DEGEN_PAIR)无需名单成员即覆盖任意短闭名。CI 24/24 全绿(head e4e0f96)。分支完整历史:cb4020644 → dbf4f1b(#2229 兼容) → 10b978b → 83fb43f(.tmp 清理) → 7977aeb(#2248 审计全 wire) → 46dc831(acpx 去污染移除) → f5e9eb4(H2 不变量测试) → e4e0f96(字段回放测试)。可合并;Closes #2190。 |
Closes #2190
结构化七问结论
1. 是什么问题:模型生成文本时模仿 ACP render 标签,闭名漂移成任意短词(实测普查 122 例:ap/p/a/apc/cap/ck/div/warn/aph/ambient/apm)。全部既有匹配器(RENDER_TAG_DETECT / PAIRED / LONE_CLOSE / looseCloseSpan)只认 acplike 名,流式过滤器吞掉开标签后认不出闭标签:超预算时把 mNNNNN 残骸原样放出(流中泄漏),EOF 时把后续 prose 静默丢弃;stripAcpTags 也没有退化闭名的配对规则。
2. 什么原因导致的:识别集粒度与模型漂移空间不匹配。闭名漂移是开放集(普查仅 11 种且会增长),而所有检测锚定封闭的 acplike 变异集;swallow 模式除「认出闭名」外没有出口——泄漏与丢失两种失败形态同源于这一个机制。
3. 怎么修复的(机制层):
<acp …>标签会漏到用户可见输出(附根因、量化与修法建议) #2190 修法建议④):原先静默的泄漏从此可观测。4. 是否有回归问题:逐项审过既有行为——
PAIRED正则吞掉最多 64 个字符的助手正文 #1720 prose-body 保护保持(配对标签间的 prose 仍释放);5. 是否破坏缓存:不涉及。prefix-cache 锚点字节、session key、重试/去重策略均未触碰;head system message 字节不变。
6. 是否改了设计方向:不涉及。沿用「流式状态机 + whole-text 兜底」既有架构,本 PR 是架构内识别集扩展,非新管线。
7. 是否引入新配置:不涉及。无新 env/config/CLI 字段(Environment Variable Discipline 合规)。
行为变更披露(old → new)
验证
Reviewer 备注(证据审核,详见 issue 线程)
Round 2(名称集扩展 + 出口审计,commit 10b978b)
触发:#2190 线程新证据(229 会话普查)显示 OPEN 侧名称漂移成封闭集外的词。这些开名在 gate 与 filter 两侧都不识别,整标签 byte-exact 通过。
Round 3 去污染修正(commit 46dc831):开名侧 grep 计数被模型在自身 reasoning 中引用标签名所污染(对方 r4 文档 §4.1 三口径对照证实)。按去污染标准(块首自发形态 + tokens= 属性 + 去重 n≥4)复核:保留 accessp、acacp、acb;移除 acpx(其原始计数 ~217 证实为自述污染/构造命中,干净样本仅 1 个大小写变体)。acpx 移出后由 residue 审计日志持续观察,出现 ≥4 处干净自发形态即可一行加回。tests/tag-echo.test.ts 夹具随之一并还原为原始版本(acpx 裸开标签重新成为「普通 markup」)。
<acp …>标签会漏到用户可见输出(附根因、量化与修法建议) #2190 线程的零日志真泄漏样本即该机制证据)。行为变更披露(round 2 增量)
分支集成说明
验证(round 2)
tests/issue2190-degen-close.test.ts 扩至 15 例(+漂移名流式逐字符回放、跨名配对、whole-text、gate 谓词、合法词存活);定向回归 9 套件 159/159 绿;typecheck 干净;build 成功。全量回归交 CI。