Skip to content

[PR] feat: POC — carry fold summaries as CCR placeholders (default-off) - #6125

Open
ranxianglei wants to merge 4 commits into
masterfrom
2026-11-10_poc-fold-summary-ccr
Open

ranxianglei wants to merge 4 commits into
masterfrom
2026-11-10_poc-fold-summary-ccr

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

What & why

POC for #6111 (root cause tracked in #6025): in proxy mode a weak model misreads the user-voiced inline fold summary as the current question → 答非所问. This experimental path carries each rendered summary out as a deterministic [acp-stored …] CCR placeholder and hands retrieval back to the model via acp_retrieve, so the summary can no longer be mistaken for live input.

Host-only — no kernel change. Every primitive already ships in acp-kernel (storeOriginal, buildStoredPlaceholder, applyRetrieve, refForRaw, …).

Closes #6111

Config surface (owner-gated — declared per Configuration Surface Discipline)

Adds ONE rollout feature key, default OFF:

  • rollout.features.foldSummaryCcr = { percent: 0 } in src/rollout.ts.
  • Force on: config rollout.features.foldSummaryCcr: true or env BILI_ROLLOUT_FOLD_SUMMARY_CCR=1.
  • Absent from registry AND config => OFF (fail-closed). Reuses the existing ROLLOUT_FEATURES map + featureEnabled() gate — no new top-level section.

Wire / message-shape note (human review required)

Flag ON => proxy-mode egress replaces each rendered-summary message text with the placeholder (egress-view only; session state untouched) and advertises + services acp_retrieve under the flag even when ccr.enabled is false. Flag OFF => byte-identical to today (zero behavior change).

Why this shape

  • Egress-view transform (fresh objects) => next compression unaffected.
  • Placeholder deterministic/immutable => prefix-cache stable.
  • Stores the summary's OWN prose under its own ref — storeCoveredOriginals only covers folded-away originals, not the surviving summary.

Status

Experimental POC — non-merging until owner reviews the data. Targeted test tests/fold-summary-ccr.test.ts (on/off/idempotent); full regression rides remote CI.

Proxy-mode weak models misread the user-voiced inline fold summary as the
current question (#6025). This experimental, default-off path carries each
rendered summary out as a deterministic `[acp-stored …]` placeholder and hands
retrieval back to the model via acp_retrieve, so the summary can no longer be
mistaken for live input.

Host-only; no kernel change — every primitive already ships in acp-kernel.
Gated by rollout feature `foldSummaryCcr` (percent:0 = off); force on with
config `rollout.features.foldSummaryCcr:true` or env
`BILI_ROLLOUT_FOLD_SUMMARY_CCR=1`.

- src/server/fold-summary-ccr.ts: egress-view transform (never mutates state)
- server/prepare-openai.ts: apply at egress + advertise acp_retrieve under flag
- loop/core.ts, stream.ts, absorb.ts: service acp_retrieve when the flag is on
- rollout.ts: register the default-off feature
- tests/fold-summary-ccr.test.ts: on/off/idempotent assertions

Experimental POC for #6111 — non-merging until owner reviews the data.
@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-11-10_poc-fold-summary-ccr (0b56424)

Latest build — install this exact version

npm install -g billion-context@0.0.9166-pr.6125.192b618

This exact version is immutable and reproducible. The rolling pr tag tracks the newest test build across all PRs.

Recent builds (commit → version)

commit version build
0b56424 billion-context@0.0.9166-pr.6125.192b618 build
c16fd69 billion-context@0.0.8969-pr.6125.84974d2 build
53affe3 billion-context@0.0.8943-pr.6125.4d68a76 build

Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr6125.tgz
npm install -g package

Install instructions are refreshed on each push.

FoldSummaryCcrResult is referenced only inside its own file; the
unused-exports gate flags it INTERNAL_ONLY and reds the PR (#6125).
Drop the leading export per the gate's fix hint — no external
consumer names the type.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

查重: 不重复,但存在同题并行 PR——GitHub #6120(2026-11-10_fold-summary-ccr-poc,同日更早创建)与本 PR 同一主题(#6111/#6025)。设计差异:#6120 用保留段 [5_000_000..9_999_998] 铸造合成 mNNNNN ref(绕过 kernel ref 账本)且要求 ccr.enabled;本 PR 走 refForRaw 真实 kernel ref(无 ref 消息跳过)且 ccr.enabled=false 时也能工作。本 PR 取代 #6120,建议 owner 将 #6120 按 superseded 关闭(agent 无权关闭);两个 PR 目前都还开着。

This round: fixed the CI red, completed the review.

  • CI red root cause & fix: the unused-exports static gate flagged INTERNAL_ONLY src/server/fold-summary-ccr.ts: FoldSummaryCcrResult (exported interface referenced only inside its own file). Fixed additively on this PR branch — commit c16fd69899 drops the leading export per the gate's own hint (no external consumer names the type). Verified locally before pushing: unused-exports gate clean, npm run typecheck clean, tests/fold-summary-ccr.test.ts 3/3, related suites 95/95 (rollout / store / ccr-v2 / storage-ccr / issue4733-ccr-restamp / ccr-plugin / openai-assistant-content-harden).
  • Live CI now (verified via mirror cache @ head c16fd69899): 30 checks, failed 0, pending 0 — fully green. The two previously-cancelled lanes (e2e, codex persona) ran to completion. Branch is behind master (not a blocker for a held POC).
  • Mechanism verified end-to-end (does it actually fire?): yes, in steady state. assignRefsNode runs unconditionally before pruneNode; renderSummary (kernel/src/prune.ts:548) preserves the anchor id acp_summary_<blockId>, so the rendered summary inherits its ref. D-lane (src/server/snapshot-render.ts:291) inserts the empty anchor before the pipeline → ref assigned same turn. Legacy proxy lane: the birth turn's summary has no ref yet → transform skips → inline prose (documented skip); ref exists from turn N+1 onward (refs persist across restarts, kernel contract: never reused). Egress reads turn.state fresh each turn (src/server/prepare-openai.ts:397, 模型切换后压缩块跨模型失配,新模型收到 61.3 万 token 全量上下文 #1001), so placeholders kick in as soon as the ref lands.
  • Flag OFF = zero behavior change confirmed by construction: every change sits behind featureEnabled("foldSummaryCcr") (default {percent: 0}, fail-closed); retrieveAdvertised falls back to ccrEnabled(session) when the flag is off.
  • Review notes (non-blocking for POC):

结构化八问

  1. 是什么问题:proxy 模式下折叠摘要以 user 口吻的内联散文形式出站,弱模型把它当成当前问题来回答(答非所问,POC: carry fold summaries as CCR placeholders (not inline prose) — weak-model confusion, from #6025 #6111,根因追踪于 In proxy mode, the model confuses historical queries with the current one, resulting in irrelevant responses. | 在proxy模式下,模型会混淆历史提问和当前提问,造成答非所问 #6025)。
  2. 什么原因导致的:摘要渲染成与真实输入不可区分的 prose block——不是模型能力问题,是信道设计让摘要与当前输入同形。
  3. 影响范围与严重程度:仅当 rollout 开关打开时生效(默认 OFF、percent=0、fail-closed),当前零用户受影响;若开启,影响 proxy 模式 openai-wire 上有折叠的会话。属实验性路径,无现网严重度。
  4. 怎么修复的:egress-view 变换——每条已渲染摘要的文本替换为其自身 kernel ref 下的确定性 [acp-stored …] CCR 占位符,原文先经 storeOriginal 按 first-write-wins 存入统一存储,检索交还模型通过 acp_retrieve(三处服务点 OR 上 featureEnabled,即使 ccr.enabled=false 也广告该工具)。会话状态零改动,只动出站视图。
  5. 是否有回归问题:flag OFF ⇒ 字节级不变(全部改动在 gate 之后,已逐项核对);flag ON 仅限 proxy 模式 openai-wire,anthropic/google/responses 有意不接(一致 no-op),plugin 车道不受影响(KDD feat: bili CLI + debug in config + README rewrite #7)。高危模式逐项过:无语义漂移、无阈值/时序变化、无输出格式漂移(OFF 态)。已知边缘:legacy 车道出生轮摘要无 ref 保持内联(文档化行为);transform 调用点无 try/catch(风险面与既有 ccr-on 会话同档);decompress-shared 拒绝措辞未对齐(边缘)。
  6. 是否破坏缓存:不破坏。占位符字节 = f(ref, kind, tokens, head, toolName),会话内稳定不可变 ⇒ 前缀缓存友好;store 为纯增量写入(first-write-wins),不动既有条目;重试/游标/去重键均不涉及。
  7. 是否改了设计方向:无转向。复用 acp-kernel 既有原语(storeOriginal/buildStoredPlaceholder/applyRetrieve/refForRaw),host-only、零 kernel 改动;仅在既有 ROLLOUT_FEATURES 机制下加一个 key。
  8. 是否引入了新的配置:有,PR 正文已按 Configuration Surface Discipline 声明——rollout.features.foldSummaryCcr(默认 {percent: 0},OFF);强制开:config 同名键 true 或 env BILI_ROLLOUT_FOLD_SUMMARY_CCR=1。无新顶层段,无迁移成本(纯 opt-in)。

判定:CI 修复完成、PR 全绿,代码审查通过(POC 档)。按 PR 声明保持 hold——等 owner 审阅 A/B/C 实验数据后再谈合并;在那之前建议把 #6120 关掉收敛到本 PR 一条线。

@BsoBird

BsoBird commented Nov 11, 2026

Copy link
Copy Markdown

POC反馈了一些问题,该方案还不成熟,需要在#6111 中继续讨论设计方案

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

收到反馈:方案尚不成熟,设计讨论转到 #6111。已做的动作:

本线程我不再动代码——等 #6111 的设计结论。

ci-check added 2 commits November 11, 2026 22:27
…7-ci-engineer-r1

# Conflicts:
#	src/absorb.ts
#	src/server/prepare-openai.ts
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

Live state verified this run (mirror cache + single GH fetch): head 0b564247c7, mergeable: true, mergeable_state: behind — the merge conflict is cleared ("behind" only means master advanced again; not a blocker). Checks at this head: unused-exports ✅, architecture-docs ✅, gates ✅, 0 failures; the 6 test shards are still in progress and were left running.

What was done across these wakes (no earlier reply had been posted, so this covers all of it):

Run 1 — red CI (unused-exports reported at stale head 53affe31a1)

  • Re-verified live first: head had already moved to c16fd69 where unused-exports is green (fixed by an earlier commit). The remaining red was actually architecture-docs: FAIL: reference/architecture.md missing: src/server/fold-summary-ccr.ts.
  • Fixed by adding the missing file-map row for src/server/fold-summary-ccr.ts in reference/architecture.md; guard passes locally. Pushed 0126dfb4aa.
  • Note: after that push, CI took ~20 min to trigger (transient anomaly); after Run 2's push it triggered normally within minutes (51 check-runs registered, fast gates already green). Self-resolved, no action needed.

Run 2 — merge conflict (merge state dirty)

  • Merged origin/master into the PR branch. Two conflicts, both resolved as semantic unions of master's Request two capabilities: compressed block "retirement" and summary "external rewrite". | 请求两个能力:压缩块「退役」与摘要「外部重写」 #5765 block-ops work and this PR's CCR/foldSummaryCcr work:
    • src/absorb.ts isProxyToolFor: kept master's new block-ops gate line plus our modified retrieve-tool condition (ccrEnabled(session) || featureEnabled("foldSummaryCcr")).
    • src/server/prepare-openai.ts tool injection: kept our retrieveAdvertised extraction AND master's appended blockOps.openai tools entry; the tool-injection flag arg uses retrieveAdvertised.
  • Verified on the merged tree: architecture-docs guard green locally, full typecheck clean. Pushed as a plain fast-forward merge commit 0b564247c7 (no force-push).
  • Honest process note: one misstep along the way — I ran pull --rebase after creating the merge commit, which started a bogus rebase replaying master history. I aborted it immediately; nothing bad was pushed (the push in flight was a no-op "up-to-date"), then pushed cleanly. No effect on branch content.

No design decisions were required, so nothing was parked for owner decision.


结构化八问(中文)

  1. 是什么问题:PR 分支有两类阻塞——CI 红(architecture-docs 守卫报文件地图缺 fold-summary-ccr.ts)和与 master 的合并冲突(事件最初报的 unused-exports 红在旧 head 上已被先前提交修复)。
  2. 什么原因导致的:① 新模块 src/server/fold-summary-ccr.ts 加入后未登记进 reference/architecture.md 文件地图,架构文档守卫按「全量覆盖 src/」规则判红;② master 同期合入 Request two capabilities: compressed block "retirement" and summary "external rewrite". | 请求两个能力:压缩块「退役」与摘要「外部重写」 #5765(block ops),与本 PR 在 absorb.ts 工具判定和 prepare-openai.ts 工具注入两处产生语义交叉。
  3. 影响范围与严重程度:仅本 PR 的合并阻塞与流水线红灯;功能面零影响——两处冲突均为「双方新增逻辑并存」的并集解决,不改变任何一侧既有行为。
  4. 怎么修复的:补一行文件地图(纯文档);合并 master 后对两个冲突 hunk 做语义并集(保留双方新增的 gate/工具条目,不删任何一侧逻辑),本地跑过架构守卫 + 全量 typecheck 后以普通 merge commit 快进推送。
  5. 是否有回归问题:无。已核对既有行为:block-ops gate(Request two capabilities: compressed block "retirement" and summary "external rewrite". | 请求两个能力:压缩块「退役」与摘要「外部重写」 #5765)原样保留、CCR retrieve-tool 判定原样保留、OpenAI 工具注入数组同时含两侧条目;typecheck 全绿。唯一过程瑕疵(pull --rebase 误触发重放)当场 abort,未推送任何错误内容。
  6. 是否破坏缓存:不涉及(无缓存/重试/游标相关改动)。
  7. 是否改了设计方向:不涉及。
  8. 是否引入了新的配置:不涉及(foldSummaryCcr rollout key 是 PR 原有内容,非本次修复引入)。

结论:两类阻塞均已解除(head 0b564247c7,mergeable=true,0 failed checks),剩余 6 个测试分片在途、无失败;本轮无需进一步动作,等测试分片收尾即可。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

Re-verified live this run — the reported "dirty" merge state is stale; nothing to fix:

  • Head 0b564247c7 (the merge commit that resolved the conflict): mergeable: true, mergeable_state: behind — no conflict. "behind" just means master advanced again; it is not a merge blocker.
  • Checks at this head: 30/30 complete, 0 failures, 0 pending — fully green.

No action taken this run (no push, no edits). The PR is merge-ready from CI's side; the remaining "behind" state is informational and will re-compute on the next base refresh — not something this lane chases.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

Re-verified live this run — the "dirty" report is stale again; nothing to fix:

  • Head 0b564247c7 (the merge commit that resolved the conflict): mergeable: true, mergeable_state: behind — no conflict. "behind" only means master advanced; it is not a merge blocker.
  • Checks at this head: 30/30 complete, 0 failures, 0 pending — fully green.

No action taken this run (no push, no edits). This is the third identical stale event; the conflict was already resolved and CI is fully green at the current head.

Process note: my previous session was force-restarted by the watchdog after 34 minutes of no output (it had gone idle after posting the last confirmation). No work was in flight, nothing lost — this run re-verified from live sources as above.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

POC: carry fold summaries as CCR placeholders (not inline prose) — weak-model confusion, from #6025

2 participants