Skip to content

fix: exclude display-only plugins & separate suspected from confirmed conflicts (#2324) - #2331

Merged
ranxianglei merged 2 commits into
masterfrom
2026-10-07_pi-compact-transcript-false-positive
Oct 8, 2026
Merged

ranxianglei merged 2 commits into
masterfrom
2026-10-07_pi-compact-transcript-false-positive

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Fixes #2324

是什么问题

Overview / GET /__bili/stats → conflicts 把仅改终端显示的插件 pi-compact-transcript 当成与 bili 并存的第三方压缩器,打出"两个压缩器会双压缩、破坏消息引用——请只保留一个压缩器"的命令式告警。该插件实际只折叠工具输出/调整消息渲染,不压缩发给模型的上下文;且触发告警的记录全部是 [suspected](纯名称匹配),并非已观察到的冲突。

根因(分层)

  1. 检测层:src/thirdparty-scan.ts 的 KEYWORD_RE 命中名字里的 compact,会话首请求写入 [suspected] 记录——纯名称匹配,不验证是否真的压缩上下文。
  2. 展示层(误报真正来源):Web banner(src/web/client.ts overview 渲染)把所有 third-party-plugin 记录都当作"已确认第三方压缩器";只要 tpN>0 && active>0 就套用 conflict.risk_active(那句命令式文案),全 [suspected] 也照打。对比:acp_status 文本路径(formatConflictSection)早在 [bug] acp_status COMPRESSION CONFLICTS mis-attribution: native dsh-compaction-basic labeled "dsh-context [suspected]" #1736 就区分了 suspected/confirmed,唯独 Web banner 没跟上。
  3. 语义层:banner 行的 N active · M historical 用词让用户把"近 7 天有记录"读成"当前正在运行的冲突"。

怎么修的(同一失败域:疑似 vs 实际被混为一谈,一个 PR 分点处理)

  • 检测精确排除:新增证据充分的 KNOWN_DISPLAY_ONLY 白名单(首个条目 pi-compact-transcript,其 README 明确 "changes display only")。按解析后的精确 token 匹配——bare / npm spec(含版本)/ 有界路径段——复用 isOpencodeAcpEntry 的纪律,避免两套判定漂移。不是 transcript/display 子串规则:真实压缩器(context-compactor)与近似名(my-pi-compact-transcript-fork)仍会命中。全部 8 处 KEYWORD_RE 站点都加了守卫。
  • 展示区分疑似/实际:summarizeConflicts 增补 suspected 计数(kinds["third-party-plugin"] 的子集,与 sibling 不相交)。新增纯函数 bili_conflictSeverity(c) 按"存在哪些家族"选标题/风险措辞:只有存在已确认冲突(known third-party 或 native-compaction)才用命令式"双压缩/只留一个";纯疑似改用中性"名称关键词匹配、非双压缩证据、先确认再处理、勿按名移除只读工具",标题软化为"检测到疑似压缩插件"。疑似+实际混合时保留强告警并同时点名两类。
  • 时间语义:age split 本地化为"近 7 天 N 条 / 更早 N 条"(en: "{n} in last 7 days / {n} older"),不再暗示运行中。
  • 误报清理:清除入口 POST /__bili/conflicts/clear 本已存在;配合检测排除后新的误报不再产生,无需新增配置或字段。

⚠️ 行为变更(旧值 → 新值 + 原因,均为有意)

  1. pi-compact-transcript 不再被扫描为 [suspected](旧:每个新会话都命中关键词写入一条 suspected 记录 → 新:完全不产生 finding)。本 issue 核心修复。未知但含压缩关键词的插件仍产生 suspected 提示。
  2. Web banner 对纯疑似 ledger 的文案与颜色:旧=命令式"检测到压缩冲突…请只保留一个压缩器" + warn 色;新="检测到疑似压缩插件…非双压缩证据…勿按名移除只读工具" + info 中性色。原因:名称匹配不构成双压缩证据,命令式卸载建议会诱导用户误删只读工具。
  3. banner 颜色判据从"是否有近期记录"改为"是否存在已确认冲突"(warn 仅在 confirmed && active 时)。连带:sibling-only(bili 自家兄弟扩展,本就自动让位、非冲突)由 warn 降为 info 中性色——良性场景不再告警,属改进。已确认冲突的显示(active→warn / historical→info)不变。
  4. banner age 措辞:N active · M historical(英文硬编码)→ 本地化"近 7 天 N 条 / 更早 N 条"。含义不变(同为 7 天窗口切分),仅消除"active=运行中"的误读。

兼容性

测试

  • tests/web-conflict-banner.test.ts:新增 bili_conflictSeverity 决策矩阵 7 例(纯疑似 / 已确认-active / 已确认-historical / sibling-only / 疑似+实际混合 / native-only / 旧 payload 降级)+ age 标签本地化断言更新。
  • tests/issue1206-thirdparty-scan.test.ts:新增 pi/opencode 扫描排除用例(bare+版本 source 不报、真实压缩器仍报)、isKnownDisplayOnlyPlugin 形式识别单测(含近似名反例)、summarizeConflicts.suspected 计数用例(与 sibling 不相交)。
  • 定向验证:npm run typecheck 绿 + 上述三套件 50/50 绿(rebase 到当前 master 后复跑)。全量回归交给 CI。

Closes #2324

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 收到 PR #2331(fix: exclude display-only plugins & separate suspected from confirmed conflicts,Closes #2324)。开始按 PR Review 规范审查:先读原 issue #2324、拉取分支核对代码与既有行为,再按结构化七问给结论。稍后回复。

@github-actions

github-actions Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-07_pi-compact-transcript-false-positive (fa083b2)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.2578-pr.2331.67bc80e

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-pr2331.tgz
npm install -g package

Install instructions are refreshed on each push.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 PR #2331 review 结论(Closes #2324)。我独立重验了全部关键声明,不是照单全收。

先说验证过什么:npm run typecheck 绿;三个冲突套件 web-conflict-banner + issue1206-thirdparty-scan + conflict-lifecycle 定向跑 50/50 绿;分支已 rebase 到当前 master head(merge-base == origin/master,无 stale base);逐条追了 isSuspectedEvent/t()/bili_conflictSeverity/isKnownDisplayOnlyPlugin 的逻辑与所有 KEYWORD_RE 站点。CI 目前 mergeable_state: blocked=必需检查还在跑,非失败。


结构化七问

  1. 是什么问题:终端纯显示插件 pi-compact-transcript 被当成与 bili 并存的第三方压缩器,Overview banner 打出命令式"两个压缩器会双压缩、破坏消息引用——只留一个"的卸载建议;而触发记录全是 [suspected](纯名字匹配),根本不是已观察到的冲突。

  2. 什么原因导致的(分层):检测层 KEYWORD_RE 命中名字里的 compact 就写 [suspected],不验证是否真压缩上下文;展示层 Web banner 把所有 third-party-plugin 记录当"已确认压缩器"套用强告警——acp_status 文本路径早在 [bug] acp_status COMPRESSION CONFLICTS mis-attribution: native dsh-compaction-basic labeled "dsh-context [suspected]" #1736 就区分了 suspected/confirmed,唯独 Web banner 没跟上;语义层 N active · M historical 让用户把"近 7 天有记录"读成"正在运行"。根因是"疑似 vs 实际被混为一谈"这一失败域贯穿检测+展示两层。

  3. 怎么修复的:同一失败域一个 PR 分点处理——检测层加证据充分的 KNOWN_DISPLAY_ONLY 白名单(按解析后精确 token 匹配,复用 isOpencodeAcpEntry 纪律),展示层用纯函数 bili_conflictSeverity 按"存在哪些家族"选措辞:只有存在已确认冲突才用命令式文案,纯疑似改中性"名称匹配、非双压缩证据、先确认再处理、勿按名移除只读工具",时间措辞本地化消除"active=运行中"误读。修的是产生误报的机制(源头判定 + 展示分流),不是过滤症状。

  4. 是否有回归问题:审过的既有行为逐项如下——

  5. 是否破坏缓存:不涉及。ConflictSummary 是瞬态 stats 响应 JSON,suspected 只是新增响应字段,非落盘格式;消息引用 / ref 空间 / 前缀缓存均未触碰。

  6. 是否改了设计方向:不涉及架构转向。仅在既有"conflict ledger + severity 展示"框架内补上 suspected/confirmed 的分流(对齐 acp_status 已有语义),边界与数据流不变。

  7. 是否引入了新的配置:不涉及。无新 env / config / CLI flag;owner-gated 配置面未动;CONFLICT_ACTIVE_WINDOW_MS(7 天内部常量)未动。


⚠️ 行为变更(均为有意,PR 已披露,我复核一致)

  • pi-compact-transcript 不再产生 [suspected] finding(核心修复);未知但含压缩关键词的插件仍产生 suspected。
  • 纯疑似 banner:命令式+warn → 中性+info。
  • banner 颜色判据从"是否有近期记录"改为"是否存在已确认冲突"(连带 sibling-only active warn→info)。
  • age 措辞 N active · M historical → 本地化"近 7 天 N 条 / 更早 N 条"(同 7 天窗口,仅消除误读)。

小问题(不拦合并)

  • PR 正文写"全部 8 处 KEYWORD_RE 站点加了守卫",实际是 9 处(行 199/283/311/343/363/389/414/422/431),一处不多一处不少全守住了——文档 off-by-one,功能完整。
  • scoped 包名如 @scope/pi-compact-transcript 会命中路径段尾正则而被排除——理论边缘,与既有 isOpencodeAcpEntry 纪律同模式,可接受。
  • 测试提取片段起点从 function escapeHtml 改到 "use strict";,依赖该区间内无未 try/catch 包裹的顶层 DOM 调用才能跑在 Node 下——当前成立且 50/50 通过,是个轻微脆弱点,留意即可。

判定:可合。 方向对(治根因非堵症状)、范围收敛到单一失败域、双向兼容有测试钉住、行为变更全部披露且合理。等 CI 转绿即可由你手动合并(我不代合)。

@ranxianglei

Copy link
Copy Markdown
Owner Author

又冲突

…m confirmed conflicts (#2324)

- thirdparty-scan: add evidence-backed KNOWN_DISPLAY_ONLY allowlist
  (pi-compact-transcript), matched as an exact token (bare / npm spec /
  bounded path segment) mirroring isOpencodeAcpEntry; guard every
  KEYWORD_RE site so display-only plugins no longer raise [suspected].
- conflict-watch: summarizeConflicts now reports a suspected count
  (additive subset of kinds[third-party-plugin], disjoint from sibling).
- web banner: new pure bili_conflictSeverity() picks title/risk wording
  from the families present; name-only [suspected] matches get a soft
  "verify first" framing instead of the imperative keep-one-compressor
  warning, and only a CONFIRMED conflict (known third-party / native)
  triggers it. Localize the age split (active/historical -> recency) so
  records are not read as currently-running conflicts. Old payloads
  without c.suspected degrade to the previous behavior.
@ranxianglei
ranxianglei force-pushed the 2026-10-07_pi-compact-transcript-false-positive branch from 103fb0f to 5d8ecb7 Compare October 8, 2026 06:01
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 上游冲突已解决并 push(rebase)。摘要如下。

冲突来源:master 期间合并了 #2219/#2220(冲突面按客户端给处置提示),恰好改到本 PR 的同一批文件——src/conflict-watch.ts、src/web/client.ts、src/web/i18n.ts。两边都在 window.bili_conflictLine 之后插函数、都重写了 banner 渲染块,产生语义级(非文本级)冲突。

怎么解的(取两者意图的并集,不是二选一):

⚠️ 关键诚信点——差点丢一个提交:这个 PR 分支其实有两个提交,不只是主修复 b7e38ae34,还有一个后续 103fb0f93「keep conflict-banner i18n keys visible to the #1024 ref-scanner」。它专门把我新增的 conflict.on_suspected/risk_suspected 等 key 从「变量间接引用」改成「直接 t("…") 调用」(返回值补 onText/riskText),否则 #1024 i18n liveness 门禁会把这些新 key 当死键拦下。若只按第一个提交 rebase,force-push 会静默丢掉这个后续。我已把它找回并按其原消息单独成 commit 重新应用;且它的 banner 行早于 #2219、没有 conflictHintBlock,所以我把它和 master 的提示块合并后落位,而非直接照搬。

验证(全部在 rebase 后的新 head 上跑):

回归审查(rebase 本身是否破坏既有行为):无新增行为变更。并集严格保持两个 PR 各自声明的语义;唯一"变化"是 banner 现在同时呈现"疑似/确认分级措辞+颜色"与"按客户端处置块",两者本就是各自 PR 的意图。acp_status 文本路径、持久化格式、配置面均未动。

当前状态:PR mergeable_state 已从 dirty(冲突)转为 behind(非阻塞)。master 又前进了 3 个纯文档提交(README pi-subagent 说明,#2380),与本 PR 六文件零重叠,故无需再次 rebase(BEHIND 不构成阻塞,且避免重复 rebase 抖动)。

判定:冲突已解、代码在最新 base 上定向验证全绿,等 CI 转绿后即可由你手动合并(我不代合)。

@ranxianglei
ranxianglei merged commit a5e7af1 into master Oct 8, 2026
24 checks passed
@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.142-master.a5e7af1 (rolling master tag).

npm install -g billion-context@0.0.142-master.a5e7af1  # 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.

@ranxianglei
ranxianglei deleted the 2026-10-07_pi-compact-transcript-false-positive branch October 15, 2026 05:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] pi-compact-transcript 被误判为压缩插件,Overview 将疑似记录显示为压缩冲突

1 participant