Skip to content

recommend/apply 共用一个区间可折叠性判定:acp_status 不再推荐必然被拒的区间 - #3268

Merged
ranxianglei merged 5 commits into
masterfrom
2026-10-15_recommend-apply-integrity-shared-judgment
Oct 15, 2026
Merged

ranxianglei merged 5 commits into
masterfrom
2026-10-15_recommend-apply-integrity-shared-judgment

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

kernel-change: #3236 — 压缩的资格判定与执行此前有两套「区间可否折叠」定义(recommend 侧对全部 compressible 消息做全局判定,apply 侧按提交的每个区间单独判定、且用不同的消息数组),导致 acp_status/nudge 反复推荐被 apply 整段拒绝("Range would split N turn(s)")的区间,形成永久循环。本变更把 apply 的既有判定序列原样抽成共享 projectUnit 函数,两侧走同一入口;涉及 kernel/ 核心判定路径修改,需人工 review。

Closes #3236

改了什么

  1. 新模块 kernel/src/unit-projection.ts:projectUnit = applySingleRange pre-block 序列的原样提取(边界扩展 → carrier/coverage/media/受保护工具剔除 → 保护区剔除 → turn-integrity 撤回 → 空检查),返回结构化投影或可直接抛出的 fatal error(zone/split)。collectCoverage 一并移入。
  2. applySingleRange 改为委托 projectUnit:错误文案/warnings 与之前逐字节一致(原样提取;protect-recent 等既有测试不改动全过)。
  3. recommendNode:mergeRangesToThreshold 产出最终推荐单元后逐单元过 projectUnit 复核,必败单元降为 gap(不再推荐);过滤后不重新 merge(防震荡);非必败单元照常推荐(apply 侧部分撤回走 warning)。
  4. 数组类统一(新增 additive 字段 ProcessTurnInput.applyView / NodeEffects.applyView):判定必须跑在 applyCompression 实际执行的那份消息数组类上。plugin lane(DSH native 等)processTurn 输入是 processed view(含合成分隔符,[Bug][Responses] acp_turn_sep 合成分隔符进入持久压缩覆盖集合,导致重复历史漂移误报 #2627),连 pre-prune originalMessages 都不是 apply class——本次由 host 传 mem.original;relay/proxy lane 传 compressMessages(= prepared.originalMessages)。
  5. acp_status uncompressed 视图:投影必败的行追加 additive ⚠ 后缀(protected zone only / would split N turns or pairs / nothing new to fold / refs unresolvable);legacy 调用(不带 config/originalMessages)输出逐字节不变。行只标记、不移除(诊断面)。

行为变更(旧 → 新,均为有意)

  • 推荐列表(nudge / acp_status ranges / failure-receipt liveNudgeDecision):doomed 区间(apply 必抛 split/zone 者)不再出现。旧 = 永久 advertise→reject 循环(报障会话 2.5h 内 4/4 全拒);新 = 不推荐,几何变化后(如全部结果到齐)该内容自然可压。这是修复意图本身。
  • acp_status uncompressed 视图:bili 从此恒带 config+originalMessages,必败行行尾多 ⚠ 后缀。旧 = 无标记;新 = 有标记。additive,不影响既有列解析。
  • 判定数组类(plugin/relay lane):旧 = processed/pre-prune 视图;新 = raw history(apply class)。判定更严格且更忠实;两视图一致时(proxy lane raw msgs)行为不变。
  • apply 侧错误文案/warnings:逐字节不变(提取验证 + 既有套件全过)。

测试

  • 新增 kernel/tests/issue3236-recommend-apply-consistency.test.ts:A 延迟结果不可达(复现原几何)— doomed 区间不再被推荐 + 手动提交仍抛同一错误(gate 完好);A2 延迟结果可达 — 自愈区间照常推荐且可折叠;B 双 burst 交错 — 同一契约 + 手动抛 "2 turns and 4 pairs";健康完整 turn — 照常推荐(不过滤);acp_status ⚠ 只出现在 doomed 行、legacy 输出不变。
  • kernel 全套 1298/1298 绿;root typecheck 绿;status/nudge/plugin 定向 bili 套件(55 例)绿。全量回归交给 CI。

八问

  1. 是什么问题:acp_status/nudge 反复推荐永远折不下去的区间(一个 turn 的 reasoning/call/result 伙伴散落在不同推荐单元里),提交即被 apply 整段拒绝,永久循环(报障会话 4/4 全拒)。
  2. 什么原因导致的:资格判定(recommend)与执行(apply)用了两套「可折叠」定义——判定集合不同(全局 vs 按区间)、数组不同(render 视图 vs apply class)、且 apply 边界扩展有 ≤20-slot 窗口;turn 伙伴散落且不可达时全局判定放行、按区间判定失败。
  3. 影响范围与严重程度:工具结果迟到/散落的 lane(异步工具、长任务、DSH native lane);属特定条件问题——相关区间永远压不动 + 浪费模型提交 + 误判压缩可用性;其他区间与会话本身不受影响。
  4. 怎么修复的:把 apply 的既有判定序列原样抽成共享 projectUnit,recommend merge 出最终单元后逐单元同入口复核、必败者降 gap;判定数组类经 applyView 统一到 apply class;acp_status uncompressed 视图对必败行 additive 标记。
  5. 是否有回归问题:逐项审过——apply 侧错误/warning 文案逐字节一致(含 protect-recent 的既有套件全过);健康区间推荐行为不变(专门用例钉住);acp_status legacy 调用输出逐字节一致;multi-spec coverage set 语义未动(维持每 call 一次计算的既有行为)。未发现回归。
  6. 是否破坏缓存:不涉及 prefix cache/增量游标/去重键;推荐内容变化(doomed 项消失)是修复意图,无缓存失效机制参与。
  7. 是否改了设计方向:无架构转向——把「两套定义」收敛为「一套定义」,正是 [kernel][recommend] selector advertises spans the apply side structurally rejects — live-carrier screening missing (permanent advertise/validate disagreement) #2663/Compression failure recovery hints advertise protected or already covered refs as immediately compressible #2778 确立的方向(共享谓词/共享决策);新增 applyView/originalMessages 均为 additive 字段。
  8. 是否引入新配置:无。applyView/originalMessages 是内部 pipeline 字段,非用户可配。

合并判定:kernel suite + typecheck + 定向集成绿,全量回归待 CI。按 Kernel Boundary 需人工 review。

@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-15_recommend-apply-integrity-shared-judgment (1169e77)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.3850-pr.3268.d9a1e61

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-pr3268.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] 🏷 (ai: vllm-qwen/qwen3.8-27b)

**查重:不重复。**本 PR 是 #3236(已批准 A 方案)的实现,原 issue 侧查重已核过 #2663/#2778/#3192/#3205/#3204/#2886/#2638/#3185 各面;我又按失败签名在 open+closed 的 issue/PR 里搜了 recommend/apply 一致性、unit-projection、turn-integrity withdraw、"would split" 相关条目,无并行实现或重复立项。

开始独立审核(不复读 PR 描述与 issue 结论):方向关(#3236 根因是否真在此 diff 里被修掉)→ 回归清点(apply 侧既有行为逐项)→ 代码逐段精读(kernel 高危域)→ 测试有效性 → diff 整洁度。涉及 kernel/**,按 Kernel Boundary 人工 review 档,本地只做定向验证(新增回归用例 + typecheck),全量交给 CI。结论稍后按八问体例给出。

awork added 2 commits October 15, 2026 16:56
#3236)

Eligibility and execution used two different definitions of "can this
range fold": recommend screened turn-integrity over the GLOBAL
compressible set while apply judged each SUBMITTED range alone, on a
different array class, and widened boundaries within a capped window.
A turn whose partners sat in other advertised units passed global
screening yet made every submission throw "Range would split N
turn(s)" — a permanent advertise/reject loop (billion-context#3236).

- unit-projection.ts: projectUnit extracts applySingleRange's pre-block
  sequence verbatim (boundary widening -> carrier/coverage/media/
  protected-tool carve -> protected-zone carve -> turn-integrity
  withdrawal -> emptiness); returns the projection or the ready-to-throw
  fatal error (zone/split). collectCoverage moves here.
- applySingleRange delegates to projectUnit; errors/warnings stay
  byte-identical (existing suite passes untouched).
- recommendNode re-screens every FINAL merged unit through projectUnit
  and demotes fatal units to gaps (no re-merge after filtering).
- NodeEffects.applyView: judgment now runs on the EXACT array class
  applyCompression executes on; absent it, falls back to the pre-prune
  original (#2663) or the given view.
- report.ts: buildStatusReport accepts config + originalMessages; the
  uncompressed view appends an additive warning flag to rows whose
  projection is fatal (flagged, never dropped); legacy output unchanged.
- kernel/tests/issue3236-recommend-apply-consistency.test.ts: both
  divergence geometries (delayed results unreachable / reachable,
  double-burst interleave), healthy-turn non-over-screening, gate
  intactness on manual submit, and the acp_status flag surface.

kernel 0.0.124 -> 0.0.125
Host lanes whose processTurn input is a render/processed view (plugin
panel: mem.processed with synthetic separators, #2627; relay loop:
processed messages) passed that view to the kernel, so even the pre-
prune originalMessages fallback was not the class applyCompression
executes on. Pass applyView everywhere it differs:

- acp-status: AcpStatusCtx gains compressMessages (structural typing —
  both LoopCtx and RewriteCtx already carry it); liveCompressionRanges
  feeds it as applyView; handleAcpStatus passes config + original
  messages to buildStatusReport so the uncompressed view can flag
  un-foldable rows.
- stream postCompressTail fallback + plugin panel status: applyView set
  from ctx.compressMessages / mem.original respectively.

AGENTS.md: KDD bullet 12 records the shared unit-projection judgment.
@ranxianglei
ranxianglei force-pushed the 2026-10-15_recommend-apply-integrity-shared-judgment branch from 73f2a5f to f8b95a6 Compare October 15, 2026 09:01
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b)

Review 结论(独立重读全量 diff + 本地验证)

先交代一个操作:PR 基线已落后 master 3 个合并(基于 b2868ca,master 已到 c2a73cc)。我已把它 rebase 到当前 master——零冲突,推回原分支(旧提交 6f05cda/73f2a5f3e → 新 d1c47ba/f8b95a64d,内容不变)。rebase 是必要的前置而非顺手:master 侧 #3213(dead-ref 过滤,#3192/#3204)恰好改了本 PR 触碰的同一批 host 文件,必须在合并视角下确认两套机制共存。

回归清点(逐项审过的既有行为与结论):

  1. apply 侧错误/warning 文案 → 逐字节一致。把 origin/master 上旧的 applySingleRange pre-block 序列完整 dump 出来与新 projectUnit 机械比对:四个提取的 helper(pair 边界扩展、受保护工具剔除、target-tier 解析、coverage 统计)逐字节相同,全部错误/警告模板串相同,执行顺序不变;livelock 守卫、validateCompressionRange、block 创建仍留在 apply 侧未动。
  2. 健康区间推荐行为 → 不变。新增「healthy complete turns remain advertised」用例钉住:完整 turn 照常推荐且折叠干净应用。
  3. acp_status legacy 调用(不带 config/originalMessages)→ 输出逐字节一致(无 ⚠ 后缀),有测试钉住。
  4. nudge 面 → 确认消费的是复核后的 recommendedRanges(compress.ts:1750),doomed 区间从 nudge / acp_status ranges / failure-receipt 消失是修复意图本身,非旁路。
  5. dead-ref 过滤(The compress failure receipt is self-contradictory: the same message first declares the ref permanently DEAD, then lists the range containing that DEAD ref as the "current compressible range." | compress 失败回执自相矛盾:同一条消息先宣告 ref 永久 DEAD,再把含该 DEAD ref 的区间列为「当前可压缩范围」 #3192/nudge 决策指令与 /acp 面板仍会列出含 DEAD ref 的压缩区间(#3192 同根机制的另外两条产线) #3204,master 新合入) → 审查中一度误报为「被本 PR 删除」:PR 基线时该函数尚不存在,diff 假象。实际两者机制正交(前者剔除跨 dead-ref 的 span 端点,后者只剔除必然折不下的区间),rebase 后树里两者并存(acp-status.ts:50,82 / plugin.ts:1476 / stream.ts:506,537 保留;applyView 接线独立新增),无回归。
  6. 判定数组类(plugin/relay lane) → 有意变更且 PR 正文已披露:processed/pre-prune 视图 → raw history(apply class);两视图一致时(proxy lane raw msgs)行为不变。

一个非阻塞观察:screenRecommendedUnits 对 projectUnit 的任何 throw 统一降为 gap(预期只有 BoundaryNotFoundError),可接受,此处记录在案。

本地验证(rebase 后头 f8b95a6): typecheck 绿;kernel 定向套件 47/47(compress、protect-recent pair-integrity、message-protection、新 issue3236 文件 4 例);bili 定向套件 31/31(含 dead-ref-range-filter / issue3204-dead-ref-nudge-panel / acp-status / nudge-decide / issue2847-doomed-nonretryable-status 全过)。全量回归交给远程 CI。

测试有效性: 新测试复现报障几何(5-call burst 首结果即时 + 4 延迟结果超出 20-slot 扩展窗;双 burst 交错),且双向钉契约——doomed 区间不再被推荐 且 手动提交仍抛同一错误(gate 没有被放宽)、自愈几何照常可折、健康 turn 不被过度过滤、acp_status 标记但不删行。断言有牙,此 bug 回归能抓住。

八问:

  1. 是什么问题:acp_status/nudge 反复推荐永远折不下去的区间,每次提交都被 apply 整段拒绝("Range would split N turn(s)"),形成永久循环(报障会话 2.5h 内 4/4 全拒)。
  2. 什么原因导致的:资格判定(recommend)与执行(apply)用了两套「可折叠」定义——判定集合不同(全局 compressible vs 按提交区间)、消息数组不同(render 视图 vs apply class)、加上 apply 侧 ≤20-slot 边界扩展窗;turn 伙伴散落且不可达时全局判定放行、按区间判定失败。
  3. 影响范围与严重程度:工具结果迟到/散落的 lane(异步工具、长任务、DSH native);特定条件问题——相关区间永远压不动 + 浪费模型提交 + 误判压缩可用性;其他区间与会话本身不受影响。
  4. 怎么修复的:把 apply 侧既有判定序列原样抽成共享 projectUnit,recommend merge 出最终单元后逐单元同入口复核、必败者降为 gap(过滤后不重新 merge,防震荡);判定数组类经 additive applyView 统一到 apply class;acp_status uncompressed 视图对必败行 additive 标记。
  5. 是否有回归问题:未发现。六项清点见上——apply 侧文案逐字节一致、健康区间推荐不变、legacy 输出不变、dead-ref 过滤正常共存、nudge 面消费复核后列表。
  6. 是否破坏缓存:不涉及——未触碰 prefix cache/增量游标/去重键;推荐中 doomed 项消失是修复意图,无缓存失效机制参与。
  7. 是否改了设计方向:无转向——「两套定义」收敛为「一套定义」正是 [kernel][recommend] selector advertises spans the apply side structurally rejects — live-carrier screening missing (permanent advertise/validate disagreement) #2663/Compression failure recovery hints advertise protected or already covered refs as immediately compressible #2778 确立的共享判定方向;applyView/originalMessages 均为 additive 字段。
  8. 是否引入新配置:无。applyView/originalMessages 是内部 pipeline 字段,非用户可配。

合并判定:可合(待远程 CI 全量套件 + Kernel Boundary 人工批准)。代码正确、提取逐字节一致、测试真实钉住契约、stale base 已 rebase 并验证;本回复即 kernel 层人工审核的结构化记录。

@ranxianglei

Copy link
Copy Markdown
Owner Author

ci不跑了

…via 164f5d9, which erased this PR's version delta in the clean auto-merge and tripped kernel-guard rule 2 (#3236)
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b)

查清了,CI 没坏,是主线测试被 fail-fast 挡掉了,根因是 kernel 版本号撞车。已修,说明如下:

现象拆解:上一轮跑在 ea0dbe7 上时,test / static-gates 两条主力 lane 状态是 skipped(不是没触发),kernel-guard 是 failure。这是 ci.yml 的 fail-fast 分层设计(#2637):guard 红 → 后续测试腿自动跳过,省得白烧 4×(install+typecheck+suites+build)。所以「不跑了」= kernel-guard 红了。

为什么 kernel-guard 红:版本号撞车。本 PR 把 acp-kernel 从 0.0.124 提到 0.0.125;而先合入 master 的另一个 kernel 提交(164f5d9e4,MCP-form compress 豁免孤儿剥离那个)也占了 0.0.125。两边把同一行改成同一个值,git 自动合并干净无冲突——但副作用是 PR diff 里「版本变更」整行消失了。kernel-guard 规则 2 检查的是「动了 kernel/src 就必须有版本行变化」,于是判成「源码变了没提版本」→ 红。本地用 guard 的原逻辑复现确认:SRC_CHANGED=5 个文件、BUMPED=0,与 CI 报错一致。

修复:在分支顶端加了一个独立小提交 b07444b20,把 acp-kernel 提到 0.0.126(只动 kernel/package.json + package-lock.json 各一行,lockfile 按 lock-sync 纪律重新生成)。已推到 PR 分支(ea0dbe793..b07444b,fast-forward)。本地按 guard 原逻辑复核:源码变更 ✓、版本行变更 ✓、body 有 kernel-change 声明 ✓——三条全过。

当前状态:新 head 上全套 CI 已重新触发(多 lane 排队中,仓库并发高)。kernel-guard 转绿后 test/static-gates 会照常开跑;如果还有红我会继续跟。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b)

状态更新(收工摘要):版本号撞车已修复,CI 恢复正常。新 head b07444b20(acp-kernel → 0.0.126)上 kernel-guard 已转绿,其余 guard lane 全绿、零 failure;test / static-gates 两条主力 lane 在 runner 排队中,guard 全部就绪后会自动开跑。本 PR 侧我这边没有待办了——如果主力 lane 出红我会继续跟。

此前已完成的两件事回顾:① review 结论(八问 + 六项回归清点)见上条长回复,判定可合(待 CI + kernel 层人工批准);② stale base 已 rebase 到当前 master(零冲突),dead-ref 过滤(#3192/#3204)与本 PR 机制正交共存已验证。

@ranxianglei
ranxianglei merged commit b726fb4 into master Oct 15, 2026
26 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.467-master.b726fb4 (rolling master tag).

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

Labels

None yet

Projects

None yet

1 participant