Repository navigation
fix: strip dead ref-close units after an attested tag-echo (#2862) - #2878
Conversation
…ei#2862) A refs run glued to a close-tag head whose > never arrives mid-text matched no rule (LONE_CLOSE/ORPHAN_REF_CLOSE need the terminator, TRUNC_REF_CLOSE is $-anchored), so the unit was released as prose with only a residue warn. New DEAD_REF_CLOSE rule drops ref + unterminated close head together once a tag-echo is attested in the same response (streaming: droppedAny; whole-text: something stripped or a lone acplike unit present); close-only shapes stay content-preserved (ranxianglei#1760). Runs before the truncate passes so TRUNC_CLOSE no longer shadows the unit down to a bare ref at EOF (ranxianglei#2348 v4 ordering).
e2e-pi-codex-ws 失败分析(flake,非本 diff 引入)结论
依据
本地无 |
|
重跑结果:e2e-pi-codex-ws 这次通过(与上文分析一致)。但 test (ubuntu-latest, 24) 出现另一个独立 flake:tests/codex-responses-ws.test.ts:151 读 bili.log 时,断言的 {LT}codex-responses-ws{GT} [conn=1] 行尚未从 bili 日志缓冲刷盘(actual 仅含 4 行启动日志,而同一时刻 stdout 已出现对应连接行)——日志刷盘与测试读文件的竞态,与 #2878 的 diff 无关(本 PR 未触碰任何日志/WS lane 代码;同 commit 首轮该 job 绿)。正在本地压测复现,如确认将单独提 issue + 修复 PR。 |
Flake 分析结论:同意,已独立复核(e2e-pi-codex-ws)你的四点判断我逐条用代码验证过,全部成立:
|
跟进两条: ① #2882 / #2883 与我的独立诊断一致 — 同一根因(src/logger.ts:158 异步 WriteStream 刷盘 vs tests/codex-responses-ws.test.ts:150 一次性冷读,慢盘上读赢刷盘)、同一证据 run(38213368544),修复复用同文件 :275-286 的 #1971 轮询范式,方向正确,处理得体。一个时序提示:Actions 在 pull_request 事件上 checkout 的是 base 并入 head 的 merge ref,所以 #2883 合入 master 后,#2878 的下一次 CI run 会自动带上轮询修复——届时再触发一次全量重跑即可拿到全绿,不需要本 PR 侧做任何改动。 ② 上一条评论里的 gate 补全补丁仍在等你处置(merge 阻塞项之一)。再贴一次要点: 当前合并状态:hold,待办不变——① 补充 commit 落地;② #2883 合入后的一次全绿 CI。两项清掉即可合并。 |
…i#2862 review) Review round on the ranxianglei#2878 head. Two gaps in the first pass: 1) The whole-text attestation gate ran before LONE_OPEN and DEGEN_PAIR were stripped, so a response whose only echo evidence was a lone/mangled open or a degenerate pair never attested (and the lookbehind additionally blocked a ref glued to the open's closing bracket until that open was gone). The gated block now runs after the LONE_CLOSE pass with the simplified out !== text predicate: every evidence class has run by then. 2) The streaming machine released raw buffer prefixes on paths the helper never saw: the over-cap non-definite tail release (the ranxianglei#644-shape leak), the PARTIAL_TAIL hold/definite prefixes, the broken-attrs prefix, and the race-winner prefix (forced attestation: the winning match has not been recorded yet). All raw-release sites now route settled dead units through stripDeadRefCloses; unattested text stays byte-verbatim (ranxianglei#1760).
…expectations (ranxianglei#2862 review) New pins: LONE_OPEN-only and DEGEN_PAIR attestation shapes, streaming dead-unit-before-first-echo across chunks, settled dead unit inside a hold prefix, and the live non-acplike close must stay byte-identical (liveness lookahead teeth). The weak orphan-ref equality test is upgraded from includes/endsWith to exact equality. Behavior change (disclosed): for an open-attested malformed close like <acp attrs>mNNNNN</acp<prose>, the ref+close residue that previously survived as visible output is now stripped whole as a dead unit; real content still survives byte-exact (the original ranxianglei#644 guarantee). The ranxianglei#644 expectations are flipped accordingly.
|
两件事: ① 已开启 Allow edits by maintainers(API PATCH maintainer_can_modify=true 已生效)——请直接推你的 46b9b70 到本分支。 我已独立验证你的审查发现属实:LONE_OPEN(tag-echo-filter.ts:134,无 g flag)与 DEGEN_PAIR(:149,有 g flag,直接 .test 有 lastIndex 状态陷阱,rebuild 判定正确)都在,gate(:450)确实只枚举了 SELF_CLOSE/LONE_CLOSE/MANGLED_OPEN 三种——lone-open/degen-pair 为唯一 attestation 证据时整文本通道 gate 不开,mid-text dead unit 泄漏。补丁方向同意。 推上来后我在本地跑 tag-echo 全家族回归 + tsc 复核,然后清掉空 commit 重跑 CI。 ② #2882/#2883:确认收到你的时序提示(#2883 合入后本 PR 下次 run 走 merge ref 自动带轮询修复),谢谢。 |
待办只剩全绿 run + 你的合并放行。 |
|
windows-latest/24 腿的这次失败是已知 flake #2799 的残留复发,与本 PR 无关,证据如下: 失败签名(job 114703137033,run 38216617195):
为何还会复发:#2799 的修复 PR #2808 状态是 CLOSED 且未合入( 本 PR 已做:合并了最新 master(9744c09,带入 HostPluginNotice #2865/#2861)以重跑 CI;本地合并头冒烟 请求:麻烦有 admin 权限的维护者 rerun 该 job;以及 #2808 的去留(重新落盘或换方案)可能需要一个决定 —— 在它落地之前,这个签名预计还会继续随机假红 windows 腿。 |
|
依然红 |
…ianglei#2862 review r3) The PARTIAL_TAIL hold-prefix is computed before the over-cap definite tail is dropped, so when that drop is the response's FIRST echo event (droppedAny still false) the released prefix carried a settled dead unit verbatim - the ranxianglei#2862 shape re-entering through the cap path. Reachable via the unbounded '<name' + attrs PARTIAL_TAIL alternative past TAG_OPEN_CAP. The dropped tail IS the attestation: force the gate, mirroring the race-winner prefix release. Zero behavior delta when already attested. Pinned by a regression test (first-event over-cap tail).
红的根因:不是本 PR 内容,是 master 侧的地雷在合并新 master 后引爆。 已立项 #2902。 证据链(全部可复核)
#2902(checklist,同一机制族:CI 测试门禁不可执行)
PR 内容侧(本轮 review 结论)
结构化八问
判定:内容侧具备合并条件;唯一合并阻塞是 #2902(a) 一行注册落到 master(可直接做),之后 rerun 本 PR(merge ref 自动带上)。 windows 腿 #2799 EPERM flake 是另一机制,不在 #2902 内:已核实 #2808 确为 closed-unmerged,其签名在落地前会继续随机命中任意 PR 的 windows 腿,建议单独决定 #2808 去留(重新落盘或换方案)。 |
更正上一条回复中的一处引用:我立的 #2902 已按重复关闭——查重发现既有 #2899(同一机制:LIVE_FILES tripwire 失同步 hard-fail 所有 test leg,先由 #2893 分析时立出)且已有外部贡献者 PR #2898(同一行注册,CI 四腿全绿)在途,按「外部贡献不被 agent PR 替换」规则以 #2899/#2898 为准。#2902 的增量发现(push 事件级联 skip → master 空绿的证据链、guard 自测建议、#2782 stale-check 时间线、并发审查结论)已作为评论收编进 #2899,未丢弃。 合并前置条件不变:#2898 合入 master 后 rerun 本 PR 即可(merge ref 自动带上注册行 + 我的 r3 修复 15638c7)。PR head 已核实为 15638c7,mergeable=true。windows 腿若再中 #2799 EPERM 属另一机制(#2808 仍 closed-unmerged),届时 rerun 或单独决定其去留。 |
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.343-master.6580da5 # this exact build
npm install -g billion-context@master # always the newest merged build
|
问题
#2862:同一响应内,tag-echo 已被证实(attested)之后,出现
mNNNNN\x3c/acp+ 后续正文的残渣形态(ref 紧贴一个缺终止 \x3e 的截断闭标签),被原样放行给客户端:现有规则面全部不命中:
LONE_CLOSE/ORPHAN_REF_CLOSE(src/loop/tag-echo-filter.ts:130,135)要求 name 后 32 个非尖角字符窗口内出现\x3e;TRUNC_REF_CLOSE(src/loop/tag-echo-filter.ts:193)是$锚定的,只覆盖字符串末尾;另外交接确认的 EOF 影子缺口:
TRUNC_CLOSE在链上先于TRUNC_REF_CLOSE执行,acplike 名的\x3c/acp$尾巴先被吃掉,留下裸 ref(#2348 v4 顺序问题)。方案(认领评论的方案 1,按 ework 交接的两处拍板)
新增
DEAD_REF_CLOSE规则:ref run + 未终结闭标签头,满足[a-zA-Z]{0,32}(与 TRUNC_REF_CLOSE 同宽,【bug】最终版issue: 模型生成的<acp …>标签会漏到用户可见输出(附根因、量化与修法建议) #2190 普查显示杜撰名是开放集);\x3e(活闭标签归 LONE_CLOSE/ORPHAN_REF_CLOSE 管);(?<![\w>])镜像 ORPHAN_REF_CLOSE:词粘连(xm01233)与\x3e后的 run 不算。门控 = 本响应内已 attested 过 tag-echo:
createTagEchoFilter的droppedAny;stripAcpTags中上游 pass 已剥掉过东西,或存在独立的 acplike 单元(lone close / self-close / mangled open)。close-only 形态(响应内无任何其它 echo 证据)维持现状不动,继续走 #2190 残渣审计观察 —— 这是本轮明确记录的范围决策(#1760 内容保全优先)。
旧行为 → 新行为
... m00491\x3c/acp **正文**原样放行(仅 warn);EOF 处m01233\x3c/acp被 TRUNC_CLOSE 吃掉\x3c/acp留下裸m01233。落点
DEAD_REF_CLOSE定义;stripAcpTags在 truncate 链之前的 gated 剥离(修掉 TRUNC_CLOSE 影子);createTagEchoFilter的stripDeadRefCloseshelper(含跨 chunk 词粘连守卫,镜像 charBeforeRun 的 lastEmitted 语义),应用于 :1086 释放路径和 flush 的 rest(在 truncate 分支之前)。测试
Review 轮(ework-daemon,两个增量 commit)
初审发现两处覆盖缺口,已在原分支上追加修复(作者提交历史保留):
stripAcpTags的 gated 剥离原本位于 LONE_OPEN / MANGLED / LONE_CLOSE pass 之前——唯一 echo 证据是 lone/mangled open 或 degen pair 的响应永远 attestation 失败(且 lookbehind 在 open 被剥掉前会挡住紧贴 open 闭合括号的 ref)。gated 块现移到 LONE_CLOSE pass 之后,谓词简化为out !== text(所有证据类此时均已执行)。行为变更扩大披露(旧 → 新)
\x3cacp tokens="245" type="text"\x3em01998\x3c/acp+ 正文):旧行为 ref+close 作为可见残渣留存([bug] #361 residual, form 3: turn whose entire text is a render-tag echo strips to an EMPTY message — agent records a marker-only turn, stalls until manual nudge (v0.1.92, post-#365) #644 测试钉的期望);新行为作为死亡单元整体丢弃。真实正文仍逐字保留([bug] #361 residual, form 3: turn whose entire text is a render-tag echo strips to an EMPTY message — agent records a marker-only turn, stalls until manual nudge (v0.1.92, post-#365) #644 原始保证不变)。理由:ref 紧贴未终结闭头 + 同响应已证实 echo = 模仿残渣,可见即重新播种回显循环(【bug】最终版issue: 模型生成的<acp …>标签会漏到用户可见输出(附根因、量化与修法建议) #2190)。测试
Closes #2862