Skip to content

Post-#2671: Absorbing File-Shaped State Plane Mechanisms — Session Registry Convergence, Fork↔Replica Merging, CCR Retirement, Affinity Table Materialization (discussion) | Post-#2671: 收编文件形状的状态面机制 — session registry 收口、fork↔replica 合流、CCR 退役、affinity 落表… #2811

Closed

Description

@ranxianglei

基于 #2671 统一存储的向上重构地图:哪些状态面机制可以收编/合流

背景

#2690(Phase 1/1.5/2a/2b/2c)+ #2768(评审修复)已合入 master:统一 SQLite 存储(corpus pins、parity core、shadow dry-run、full 读路径、replicas/checkpoints REST、fork v2、--jsonl 导出)。生产与 VM 实测都过了:

  • dogfood lane full 模式多日零 DIGEST DRIFT;
  • Windows 10 真机 legacy + full 双模式实测(26 个旧会话有机导入、replica create/restore 经 REST 全通、中途重启恢复,零 [storage] 错误,better-sqlite3 不可用时 node:sqlite 兜底同样工作)。

存储脊柱已经在生产形状。本 issue 讨论下一个问题:压在它上面的、仍然是"文件形状"的机制,哪些值得收编/合流/退役。 这是讨论 issue,不是实施计划——每一条都欢迎拍砖,尤其是 owner 正在动的区域(④②)。

现状盘点:四个平面,存储渗透度完全不同

平面 内容 存储渗透度
协议面 4 个 adapter(anthropic/openai/google/responses)+ stream-*.ts,归一化为 CoreMessage 本来就该薄,健康。#2807 刚把亲和哈希做成 wire-neutral
内核面(kernel/) refs/blocks/compress pipeline、CCR、recommend、panel 零渗透(设计正确:独立 npm 包只吃 host 喂的视图,不该知道 SQLite)
状态面(src/) session/persist/plugin/fork/CCR 文件/affinity/GC 一半一半——重构主战场
运维面 instances 台账、port-zone、multi-lane 守护、effectiveConfig 印章 纯文件

七个重构候选(按依赖排序)

① 会话注册表收口(收益最大,owner 未在该区域活动)

boot 扫 JSON(buildForLoadAll)、web 列表 listSessions() 目录扫描、CLI/export 各自扫描——三套独立扫描器,都 O(全部文件)。#2803(bounded session loading)正在跟同一个症状搏斗。sessions 表已是权威注册表(有机导入实测),把所有读者收口到一个 unified 优先的 listSessions 单缝,一个改动消掉三个扫描器,顺带解决 #2803 想解决的问题。

② fork ↔ replicas 合流(协议级,需先对齐)

两套相似机制并存:fork v2(prefix+blockSet 哈希,#2690 P2b)与 replicas(完整状态 blob 进 CAS + REST restore)。sessions 表已有 parent_session_id/fork_point_seq 列。fork 可建模为"一个 pinned 的 fork_base checkpoint + 血缘列",子会话走 restore 路径构建,可消掉一整族文件形状:

  • pluginSnapshot 冻结信封(structuredClone 前缀,src/plugin.ts:402/:446)
  • forkContentStore sidecar 重建 hack
  • fork-as-copy 导出路径

全部变成 CAS 上的视图。分叉从"文件快照镜像"变成"数据库原生分支"。#2795(identity-orphan 冲突事件化)说明血缘语义正是活跃痛点。

③ CCR 退役(Phase 3 主体)

ccr_entries 已镜像全部内容,但检索路径仍读 per-session content-store JSON(src/persist.ts:388 loadContentStore 走 <host>_<hash>.json 两级降级)。翻转方向:DB 优先读、文件镜像、然后停写。做完后 kernel 的 content-store 才真正无状态化。

④ prefix-affinity 收编(owner 正在活动,先讨论)

1021 行独立子系统 + 自有 JSON 持久层(src/prefix-affinity.ts、src/affinity-persist.ts)。#2807 刚把哈希 wire-neutral 化,正好顺势落到 messages 表(前缀哈希索引),匿名重连从独立台账变成 sessions/messages 查询。

⑤ lastMessages 折叠尾巴(prune 语义)查表化

设计文档标 dead(export/web 应查 messages 表),但 session.ts(5 处)/persist.ts(8 处)/plugin.ts(2 处)/export.ts(3 处)仍在碰。messages 表已在,纯查表替换,风险低,适合作为 ① 的附带项。

⑥ 多实例协调:config epoch 行

instances 台账 + port-zone.json + effectiveConfig 陈年印章(#405/#2401 族)。SQLite 本身是共享状态面:一个 config-epoch 行让 tool-lane 原子读新鲜配置,替代 wire 请求盖章。⚠️ 多实例对 WAL 单写者语义需要设计,不急。

⑦ GC 体系 SQL 化

session-gc/state-gc/orphan-gc 三套 JSON 世界观 → SQL(archiveAfterDays 已定稿;blocks/refs 权威替换 #2768 已铺路)。

第 ⓪ 项(前置讨论):协议面其实才是最大的一块

上一节把协议面标为"健康"——这个评估太窄了,修正:四个 adapter 本身健康,但协议面远不止那四个文件,实测 ~15.5K 行,占 src 的 1/4 强:

块 行数 状态
四个 wire adapter ~2,900 健康,边界清楚(协议面的一小块而已)
src/loop/tag-echo-filter.ts 1,520 单文件 流式 tag 回声剥离,四代补丁叠加(#206/#673/#717/#1731)
stream.ts + responses-ws + stream-* ~3,100 每协议一份流处理
per-client 互操作堆 ~3,900 且增长中 zcode 1,372 / kimi 807 / claude-native-bootstrap 571 / dsh-channel 453 / codex-compact 206 / pi-channel 170——五套 native 代码解同一道题:"客户端自己做状态手术时 bili 怎么保持 refs/blocks 连续"(#2360 是这族的祖师爷)
三车道入口(proxy/MITM/plugin)+ prepare-* 家族 ~4,400 prepare-responses 688 / prepare-anthropic 446 / handle.ts 2,205——"剥掉客户端历史里的 bili 渲染物"这件事散在 5+ 处各写一遍

Bug 密度证据:最近一轮 8 个 issue/PR 有 6~7 个在这层——#2774 marker-id 毒化、#2789 acp_status 只剥头行、#2798 google lane 完全没剥(prepare-google import 了却没用)、#2791 dsh 绕过 fetch patch、#2779 opencode 父子共享可变状态、#2769 gemini wire 重试失效。病根不是架构烂,是组合爆炸:4 协议 × 6 客户端 × 3 车道,同一族 bug 在不同协议上重复发生(#2789 vs #2798)。

协议面重构四步(按依赖序):

⚠️ 硬约束:owner 当前最活跃区域恰是这层(#2804/#2805/#2807/#2802)。B 动手前必须对齐,避免同墙各拆各砖。

建议排序与不动清单

建议:B(声明化,先对齐)→ ① → ⑤(附带)→ ③ → ②/④/⑥ 协议级(需 owner 对齐)。B/①/⑤ 纯收编;协议面的 C/D 在 A 契约定型后推进。

暂不动:adapter 四件套本体(健康且刚被动过,B 只动剥离规则的归属不动 adapter 边界);kernel/src(渗透破坏独立性);JSON 双写(Phase 3 最终翻转,soak 数据说话);external-summary(#2806 合并中)。

定位叙事(欢迎讨论)

wire 面继续变薄、状态面全部落到 SQLite 原生原语、内核保持纯净。做完之后 sessions/forks/checkpoints 是内核原语而不是文件约定——bili 的对外叙事从"压缩代理"变成"带记忆折叠和分支的会话内核",客户端(pi/DSH/Codex/Claude/opencode)随便换,状态面不动,#2807 是这个论点的最新实证。

Activity

  1. ranxianglei commented on Oct 11, 2026

    @ranxianglei
    OwnerAuthor

    🤖 Powered by ework · qwen3.8-27b

    已按当前 checkout 逐条核过这七项的"文件形状"现状。整体同意盘点和建议排序的大方向,但有两处 framing 需要修正——它们会改变风险排序,所以我建议的执行顺序和 issue 略有不同。先说修正,再说排序,最后逐项拍砖。

    两处 framing 修正(基于代码核对)

    ① 不是"三套独立扫描器",是「一条共享枚举 + 一个本来就对的内存表」。

    • 真正走目录枚举的只有两处,且都汇聚到同一个底层函数 SessionStore.loadAll():boot(src/persist.ts:521 boot() → this.store.loadAll())和 web/CLI/export(src/export.ts:33 listSessions(opts) → new SessionStore().loadAll())。
    • src/session.ts:782 listSessions() 是 [...sessions.values()],纯内存活会话表,O(live),本来就不是文件扫描,不用动。
    • 所以 ① 的真实工作量是:加一个 SELECT session_id FROM sessions 枚举原语(storage/ 里现在没有任何 list-all 查询,我查过——所有查询都是 WHERE session_id=?),把 loadAll() 的枚举基座从 fs.readdir 翻到 SQL。一处改动同时消掉 boot + web/export 两条,比"重写三个扫描器"小得多。

    ③ 的 DB 读路径其实已经存在,不是"翻方向再建读者"。

    • src/storage/store.ts:709 已有 SELECT ord, ccr_key, content_hash FROM ccr_entries WHERE session_id=? ORDER BY ord(Phase 2c full 读路径建的)。
    • 所以 ③ = 让 src/persist.ts:388 loadContentStore 优先走这条现成 DB 读、文件降级为 soak 期回退、然后停写 <proto>/<host>_<hash>.content-store.json。比 issue 描述的"翻转方向"更小。

    由此得出的关键区分(也是我想改排序的原因)

    full 模式现状已经是"逐 id DB 优先 + 文件回退"(buildForLoadAll,src/persist.ts:536),这个回退已被 dogfood full 多日零 DRIFT 验证过。区别在于:

    • ③ / ⑤ 只改「逐 id 的读偏好」,回退机制 Phase 2c 已经证明 → 低新颖度、低风险。
    • ① 改的是「列表本身从哪来」(枚举基座),这是真正的新颖点,且引入一个跨 ①③⑤ 的共同前置问题:从未被打开过的 legacy 会话在 sessions/messages/ccr_entries 里没有行——它们只在被 ingest/打开时才入库。逐 id 读有文件回退兜底没事;但"列表来自 DB"会漏掉这些没碰过的 id。所以 ① 需要一个一次性 backfill(全量扫一次目录把 id 灌进 sessions,之后不再 walk),或保留一次性的自退役 bootstrap。这是 ① 真正的成本所在,也是它风险最高的一处——恰恰不是 issue 说的"收益最大所以最先做"的安全区。

    我的排序建议:⑤ → ③ → ① →(设计稿)②。
    理由:整个项目的立足点是"存储脊柱已经在生产形状",那就要先银行低风险高确定性的 win、把「DB 优先读 + 文件回退」这个模式在小面上钉死,再去动枚举基座。

    • ⑤ lastMessages 折叠尾巴查表化:最低风险(messages 表每行都在 ingest 时写,无"从未打开"缺口),先把模式跑通;
    • ③ CCR 退役:读者现成(store.ts:709),纯偏好翻转 + 停写 + soak,紧跟着;
    • ① 注册表收口:带着前两步证明好的模式去做,外加显式 backfill 设计作为 gate;做完顺带解锁 Bound startup session loading and preserve historical recovery #2803(bounded loading 从"boot 全量解析"变成 SELECT … LIMIT);
    • (设计稿)② fork↔replicas:协议级,先出设计对齐再动手。

    若 owner 更看重"无争用 + 单次收益",① 先行也成立——但我倾向先吃稳 ⑤③。最终听 owner 拍板。

    逐项判断

    不动清单 全部认同(adapter 四件套健康且刚动过;kernel 渗透破坏独立性;JSON 双写留到 Phase 3 soak;external-summary 合并中)。

    补一句定位叙事:完全同意"sessions/forks/checkpoints 变内核原语"的方向,#2807 是实证。唯一想强调的执行纪律:①③⑤ 共享的"legacy-only 未 ingest 会话"前置问题要在动手前一次性定掉(backfill vs 自退役 bootstrap),别在三项里各撞一遍。

    这是一条讨论 issue,我没有开工实现;以上是核对代码后的判断与建议,等 owner 对排序(尤其 ① 是否坚持先行 + backfill 方案)和 ② 的设计稿拍板后再进入实施。

  2. ranxianglei commented on Oct 11, 2026

    @ranxianglei
    OwnerAuthor

    B(strip/导入声明化)设计方案 — 单 PR 五步

    结论先行:一个 PR 全做,内部 5 个语义 commit,每步行为对拍。设计如下,拍砖处已标注。

    第 1 步:MarkerSpec 声明表(新 src/marker/spec.ts)

    把"bili 塞进历史的东西"建成唯一可枚举的表(实测 7 类):

    id 方向 shape carrier-aware 现状家
    acp_status_head inbound line — acp-panel.ts(stripMarkerLines 只做这个)
    acp_status_body inbound line — 无人剥 = #2789
    acp_panel_line inbound line — acp-panel.ts(stripAcpPanelMessages 族)
    summary_anchor inbound block 是(查 state.blocks+carrier) server.ts:1532 stripKernelSummaries
    render_tag both span — tag-echo-filter.ts
    forged_header inbound line — 混在 tag-echo-filter :708/:735
    notification_title title 域 — — server.ts:2953
    interface MarkerSpec {
      id: MarkerId; direction: "inbound"|"outbound"|"both";
      shape: "line"|"span"|"block"; scope: "message"|"title";
      carrierAware?: boolean; emptyReplacement?: string; // 剥空填 " ",保现状语义
    }

    单一事实源:pattern 本体从发射方 import(acp-panel/kernel panel 渲染常量),spec 只引用不复制——渲染格式改动不可能与 strip 表漂移。

    第 2 步:通用引擎(新 src/marker/engine.ts)

    每协议只提供文本槽访问器(ContentWalk.walkText(record): Iterable<{get,set}>;anthropic content blocks[].text / openai string|parts[].text / google content.parts[].text / responses input items;另有现成泛型 recordWalk 供 fork 路径)。引擎按表遍历+剥+计数。

    现有三户的剥离函数原样搬家不改逻辑(stripKernelSummaries 含 #1567 plugin callId 特判、acp-panel 全家、伪造头判定)。engine 只管"在哪调、调几处、漏没漏"。

    不动:tag-echo-filter 的出站流式状态机(#717/#1731 行为敏感)——只改为从 spec import pattern。

    第 3 步:强制接线 + 防回归测试

    两个固定钉点(时序本质不同):

    • raw 钉点:body parse 完立即剥 status_head/body、panel_line、forged_header(无会话状态依赖);
    • state 钦点:processTurn 后剥 summary_anchor(需 turn.state 判断 carrier)。

    接线面:4 个 prepare-* + fork 路径(fork-adoption.ts:123/:132、agent/fork-adopt.ts:101/:118/:292,现 7 处手工调用收编)。google lane 从此必然剥(#2798 消失),body 规则必然存在(#2789 消失)。

    新测试 tests/marker-lane-coverage.test.ts:fixture 含全部 7 类 marker,逐协议入站管道,断言每 spec.id 计数 >0。双向强制:新增 marker 类没配 fixture → 红;新接 lane 没过 fixture → 红。

    第 4 步:三户合一(文件手术)

    src/marker/{spec,engine}.ts + rules/{status,panel,summary-anchor,forged-header,title}.ts
    

    acp-panel.ts/server.ts 保留 re-export(现有 import 方不破坏);tag-echo-filter 瘦身为纯出站防御。

    第 5 步:prepare 收敛(实测四文件 ~80% 克隆)

    新 src/server/prepare-shared.ts orchestrator(~700 行),固定顺序:
    title → raw-strip → processTurn → state-strip → nudge → reasoning-drop → token-count → fold-reconcile → image-billing → rewrite-detect → render

    四个 prepare-* 退化为 parse + wire 转换(acp-kernel/wire)+ quirk 钩子 + 出站 render(~各 150 行)。quirk 留在各自文件(warnAnthropicThinkingPairs / hardenOpenaiAssistantContent / responses ordering repair / google 双 stripKernelSummaries :185/:319——真实差异,参数化保留不抹平)。收敛标准:只收形状完全相同的 stage。

    对拍:wire-contract goldens + storage-render goldens + 每协议 marker-fixture golden(字节级)。预计 prepare 四件 1,874 → ~600 行。

    commit 序(单 PR,5 个)

    1. feat(marker): spec + engine + rules(纯新增零接线)
    2. feat(marker): fixed stages in 4 prepares + fork paths(顺带修 acp_status visibility markers: stripMarkerLines removes the head line but leaves the multi-line report body in incoming history (#1029 follow-up) #2789 Google (Gemini native) lane never strips ACP panels/status markers from incoming history — vestigial import in prepare-google #2798)
    3. test(marker): lane-coverage + fixtures
    4. refactor(server): prepare-shared orchestrator(纯搬家)
    5. docs + CHANGELOG(链 acp_status visibility markers: stripMarkerLines removes the head line but leaves the multi-line report body in incoming history (#1029 follow-up) #2789 Google (Gemini native) lane never strips ACP panels/status markers from incoming history — vestigial import in prepare-google #2798 Post-#2671: Absorbing File-Shaped State Plane Mechanisms — Session Registry Convergence, Fork↔Replica Merging, CCR Retirement, Affinity Table Materialization (discussion) | Post-#2671: 收编文件形状的状态面机制 — session registry 收口、fork↔replica 合流、CCR 退役、affinity 落表… #2811)

    风险与缓解

  3. ranxianglei commented on Oct 11, 2026

    @ranxianglei
    OwnerAuthor

    🤖 Powered by ework · qwen3.8-27b

    设计 B 评审 — 方向成立,但动手前有三件事要落定

    结论先行:B 的方向我认同——把「bili 往历史里塞的东西」建成唯一可枚举的表 + 通用引擎 + 双向强制回归网,是治本(疏)而非堵;第 3 步的 marker-lane-coverage fixture(新增 marker 类没配 fixture→红、新接 lane 没过 fixture→红)是整份设计里最值钱的一块,正是 #2789/#2798 这类缺口反复出现所缺的那张网。但按当前 checkout 核对后,有三个前置问题必须先定,且我建议把第 5 步拆出去单独做。

    核对代码后的事实基线(不凭描述,逐条验过)

    • ~80% 克隆属实:四个 prepare-* 合计正好 1874 行(anthropic 446 / google 343 / openai 397 / responses 688)。逐 lane 数共享 stage:四条 lane 都调同一组 10 个 helper(deriveTitle/diagNudge/diagTagSummary/effectiveTokenCount/imageBillingFor/isAutoInjectedNotification/reapOrphansLogged/runNudgeDecision/stripKernelSummaries/withReasoningDrop,大多各 ×2)。实测差异点:google 完全没有 withReasoningDrop;responses 和 openai 各多一次 effectiveTokenCount+stripKernelSummaries(responses 在 :282/:620 双剥,与 google :185/:319 同形)。所以收敛空间真实存在,但「形状完全相同」这条边界比清单列的要刁钻。
    • marker 家底对得上:stripAcpPanelMessages(:95)/stripAcpStatusMarkers(:120)/stripAcpPanelResponsesInput(:160)在 src/acp-panel.ts(176 行),MARKER_LINE/stripMarkerLines 定义在 src/loop/tag-echo-filter.ts(1520 行,伪造头切块逻辑在 ~:703–777);stripKernelSummaries 定义在 src/server.ts:1532(carrier-evidence index 在 :1473,[Performance] Summary-carrier lookup rescans full history per active block (O(B*N)) #2042);fork 侧手工调用点实测约 8 处(fork-adoption.ts:123/:131/:132 + agent/fork-adopt.ts:100/:101/:117/:118/:292)。
    • 「现成泛型 recordWalk」不存在:全仓 grep 只有 fs 层的 walkJsonFiles/walkSessionFiles(无关)。ContentWalk.walkText 对四条 wire + fork 都是净新工作,不能按「现成」预算。

    三个动手前必须落定的问题

    ① 时序:B 的两个「动机 bug」已被另两个未合 PR 修掉,B 必须排在它们之后并吸收其代码。
    #2789(acp_status body 残留)已由 PR #2797 修(sentinel-pair [acp-status]…[/acp-status] + 新增 stripAcpStatusBlocks);#2798(google lane 从不剥)已由 PR #2805 修(parts-aware stripAcpPanelGoogleContents/stripAcpStatusMarkersGoogleContents + prepare-google/fork-adoption 接线 + golden 重生成)。两者当前都还是 OPEN,最新 master(e7b94a2e,#2788)里都没有。而 B 的 MarkerSpec 表把 acp_status_body 标成「无人剥 = #2789」、把 google 标成「从此必然剥(#2798 消失)」——这是在描述修复前的世界。B 若先于/并行于它们落地,要么冲突,要么把刚修的 sentinel-pair / google parts 变体冲掉。你风险节只点了 #2805,漏了 #2797(它改的正是 B 表里 acp_status 那两行的机制)。建议:等 #2797+#2805 都合入 master 再开 B,且 B 的第 1 步 spec 表直接以「吸收后的现状」为基线(acp_status_body 的 strip 规则 = #2797 的 sentinel-pair,不是重新发明)。commit 2 的措辞也应从「顺带修 #2789 #2798」改成「收编这两个已修 lane 的手工调用」。

    ② 拆分:第 5 步(prepare 收敛 1874→~600)应与第 1–4 步分开做。
    第 1–4 步(spec+engine+接线+三户合一)是一个内聚的「marker 收编」变更;第 5 步是把四条 wire 每条请求路径都重写成 orchestrator,爆炸半径和 risk class 完全不同。捆在一个 PR 里:diff 大到没法审、auto-merge gate 必然不适用(碰 wire/message shape + 跨多模块),而且一旦第 5 步出问题会拖累本来干净的 marker 收编。建议 PR-B1 = 第 1–4 步(marker 收编),engine 被 golden 钉住稳定后再开 PR-B2 = 第 5 步(prepare orchestrator)。两者共享 spec 表,顺序天然成立。

    ③ 归属:B 是 wire-plane 卫生 + DRY,不是 #2811 的「文件形状状态面 → SQLite」主题。
    #2811 七个候选全是 state-surface 落库;B 属于 OP 定位段那句「wire 面继续变薄」,但和存储脊柱正交。若要做实,建议给 B 单独立 issue(它自成一个「marker 声明化 + prepare 收敛」工作流),让 #2811 保持聚焦在 SQLite 收编上。这条是可选的、听你的。

    八问

    1. 是什么问题:入站 ACP 清理靠每条 lane 手工散点调用、无单一枚举,导致漏剥(acp_status visibility markers: stripMarkerLines removes the head line but leaves the multi-line report body in incoming history (#1029 follow-up) #2789 body / Google (Gemini native) lane never strips ACP panels/status markers from incoming history — vestigial import in prepare-google #2798 google)与格式漂移风险;四份 prepare-* ~80% 互相克隆。
    2. 什么原因导致:剥离规则没有「可枚举的事实源」,发射方与剥离方各自维护 pattern;prepare 各 lane copy-paste 同一 stage 序列而无共享编排。
    3. 影响范围与严重程度:底层缺口影响所有 echo-back 客户端的 token 成本/上下文污染 + google lane 永久多计费(特定 wire 条件,非不可用);B 本身是重构,主要风险是回归(一次触碰四条 wire 全部请求路径)。
    4. 怎么修复(设计思路):spec 表(pattern 从发射方 import,单一事实源)+ 每协议文本槽访问器引擎 + raw/state 两个固定钉点 + 双向强制 fixture + 三户合一到 src/marker/ +(建议拆出的)prepare orchestrator。
    5. 是否有回归问题:这是最大关切。守卫 = 规则函数原样搬 + wire-contract/storage-render/每协议 marker-fixture 三层 golden 字节对拍;硬前置 = ①时序(吸收 fix(#2789): strip the whole acp_status marker block from incoming history #2797/[PR] fix: strip ACP panels and status markers on the google lane before projection (#2798) #2805)。⚠️ quirk 清单需补全:除 google 双剥外,responses 也双剥(:282/:620)、openai/anthropic 用 stripReasoning 包一层而 google 无 withReasoningDrop——这些就是「只收同形 stage」要显式参数化的真实差异,别抹平。
    6. 是否破坏缓存:剥离移除的是 proxy 注入的瞬态产物,转发前缀只会更稳;但每次翻一条 lane 都会动那条 wire 的 golden([PR] fix: strip ACP panels and status markers on the google lane before projection (#2798) #2805 已实证 google 修完 body release v0.1.3 #10–14 各恒定 -268 字节的有意漂移),必须逐字段核 diff,不能默认零漂移。
    7. 是否改了设计方向:wire-plane 收薄、kernel 保持纯净,与 OP 叙事一致;但如 ③ 所述它不属于 Post-#2671: Absorbing File-Shaped State Plane Mechanisms — Session Registry Convergence, Fork↔Replica Merging, CCR Retirement, Affinity Table Materialization (discussion) | Post-#2671: 收编文件形状的状态面机制 — session registry 收口、fork↔replica 合流、CCR 退役、affinity 落表… #2811 的存储收编主题,建议独立 issue。
    8. 是否引入新配置:无。无新 env/config/默认值,compress.visibilityMarkers 表面不变。

    判定:设计可推进,但现在不开工——先把 ①时序(#2797+#2805 合入)、②拆分(B1/B2)、③归属三件事拍板。你定了之后我可以先出 MarkerSpec 表(以吸收后的现状为基线)+ engine 骨架作为 B1 的设计稿,再进入实现。

  4. ranxianglei commented on Oct 11, 2026

    @ranxianglei
    OwnerAuthor

    摸底结论(打桩报告)——设计修订 3 处

    修订 1:marker 类表 7 → 10

    # id 方向 证据 状态
    1 acp_status_head inbound acp-panel.ts:111(#1029) 已有
    2 acp_status_body inbound #2789,无人剥 缺规则
    3 acp_panel_line(messages+responses_input 两 wire 变体) inbound acp-panel.ts 已有
    4 summary_anchor inbound server.ts:1532(carrier-aware,#1567) 已有
    5 render_tag both tag-echo-filter 已有
    6 forged_header inbound tag-echo-filter:708/:735 混居 搬家
    7 notification_title title 域 server.ts:2953 已有
    8 confirmation_marker(📦/❌ [ACP]) both proxy 工具执行后即时文本,#1029/#717;与 status_head 同行文法、不同发射点 独立成类
    9 chain_carrier(<bili-chain …>) both bili-artifact-strip 全套矩阵;该族已有 injector↔stripper 单源纪律测试(bili-artifact-strip.test.ts:69),设计照抄此纪律 已有+已单源
    10 nudge_echo inbound? 无任何入站 strip;nudgeSuppressed 仅抑制未来注入;客户端是否回存待 fixture 定夺 待验证

    修订 2:引擎 walk 两层化

    实测:raw 剥离发生在 wire 形状(strip 在 wire→core 转换前;anthropic:128/openai:86/responses:114);state 剥离发生在 core 形状(turn.messages:BiliMessage,processTurn 后)。→ 每协议一个 wire-walk + 一个统一的 core-walk。

    顺序核对(四文件逐一):parse → raw-strip → count → rewrite-detect → fold-reconcile → processTurn → title → attach-subagent → state-strip → nudge → reasoning-drop → render;rewrite-detect 必须先于 reconcile(anthropic:198 注释);raw-strip 只改 content 不动 id → 按 id 的 rewrite-detect 安全。

    修订 3:#2789 修复 = 有意行为翻转(评审决策点亮出)

    marker-echo.test.ts:114 现钉死 "strips the acp_status marker head line but keeps its body" 为预期行为——本 PR 翻转它(body 也剥),同步改断言+注明 issue。不静默改。

    风险面排序(实施时按此配重)

    • 最大:4 协议 × 3 启动方式(proxy/MITM/plugin lane)矩阵——MITM 与 proxy 同走 handle.ts→prepareX,插件模式带 pluginMode 分支需逐协议核;fixture 矩阵按 4×3 铺。
    • 次要:acp_status 族——规则简单、已有大量测试。
    • 低:nudge 文本本身——渲染在内核(renderNudgeText),外围只管注入与回声,即使要加 nudge_echo 规则也是纯外围逻辑。

    下一步:打桩驱动(fixture 矩阵)

    1. 10 类 marker × 4 协议 × 3 车道 fixture 矩阵,先跑现状得出泄漏矩阵(哪些类在哪个 lane 现在就漏);
    2. nudge_echo 第 10 类定夺(泄漏→加规则;不泄漏→记 no-op);
    3. 泄漏矩阵即日后 marker-lane-coverage.test.ts 的种子。
  5. ranxianglei commented on Oct 11, 2026

    @ranxianglei
    OwnerAuthor

    🤖 Powered by ework · qwen3.8-27b

    打桩报告核对 — 三处修订都站得住,补一个关键收口

    结论:三处修订我逐条对过代码,基线准确、方向对。唯一要收口的是修订 3——它和已开的 PR #2797 撞在同一处行为翻转上,得定成「一个实现」而不是两个。

    逐条核对(验过的)

    • 修订 2(walk 两层化)成立:raw-strip 确在 wire 形状(parsed.messages/parsed.input,四 lane 转换前),state-strip 确在 core 形状(turn.messages:BiliMessage,processTurn 后)。→ 「每协议 wire-walk + 统一 core-walk」有依据。顺序里「rewrite-detect 先于 reconcile、raw-strip 只改 content 不动 id → 按 id 的 rewrite-detect 安全」我认可。
    • 修订 1 release v0.1.2 #9(chain_carrier)模型选得好,且比描述还硬:tests/bili-artifact-strip.test.ts:69 实测就是「把发射方真实输出喂进剥离方、断言剥干净」——stripBiliArtifacts(renderForgedSummary({...})) === "" + 压缩 handoff(handoff.startsWith(H1) 共享头常量)整块剥空。这正是 marker-lane-coverage fixture 该照抄的牙。另 :78 那条 directionality 测试(request 侧盖章 carrier 经 request-path 归一化字节不变)正好对应你两钉点的方向语义——建议 coverage fixture 也带一条 outbound/request 方向对照,别只测 inbound。
    • 修订 1 feat: release CI (npm auto-publish on release branch) #8 / release v0.1.3 #10 判断合理:confirmation_marker(📦/❌,工具执行即时文本)与 status_head(📊)同文法、不同发射点,独立成类对(marker-echo.test.ts:119–123 图标表 📦 ❌ 📤 🔍 📊 🫧 佐证)。nudge_echo 标「待验证」、交给 fixture 矩阵跑现状定夺——方法对,现在不用争。
    • 风险排序认同:4 协议 × 3 启动方式(proxy/MITM/plugin lane)是最大面,pluginMode 分支逐协议核是对的;fixture 按 4×3 铺。

    关键收口:修订 3 与 PR #2797 撞车,必须合成一个实现

    tests/marker-echo.test.ts:114 我又核了一遍,确实钉死 "strips the acp_status marker head line but keeps its body" 为预期行为——你的前提对。但这个翻转已有 open PR #2797 在做,机制是:发射端把 body 包成 [acp-status]…[/acp-status] sentinel 对 + 入端新增 stripAcpStatusBlocks + 对无 sentinel 的旧持久化 body 做 best-effort 报告语法消费。即现在两个 PR 各自要实现同一个行为翻转(B 的引擎 row-2 规则 + #2797 的专用函数)。

    处置(不是回避冲突,是让落点回到你自己设计的原则上):按第 1 步「pattern 从发射方 import、单一事实源」,row-2 acp_status_body 的 pattern 家就是 #2797 的发射端 sentinel 常量——B import 它、不重定义;引擎的 row-2 规则直接路由到 / 吞并 #2797 的 stripAcpStatusBlocks,而非另写一套 body-strip。结果:一个实现、一个被翻转的断言(:114)、不产生重复剥离路径。同理 #2798/#2805(google parts 变体)如前述仍适用——B 排在其后 rebase,spec 表以「吸收后现状」为基线。

    下一步

    #2797 时序一定,B 就具备打桩驱动条件了。你拍板「吸收 #2797/#2805 而非并行重造」之后,我可以先出 10 行 MarkerSpec(基线 = 吸收后)+ wire-walk/core-walk 骨架作为 B1 设计稿,再进实现。要不要我先把 #2797 的 sentinel 常量 + stripAcpStatusBlocks 签名拉出来核对一遍,确认它能原样当 row-2 的 pattern 家?(只读不改。)

  6. ranxianglei commented on Oct 11, 2026

    @ranxianglei
    OwnerAuthor

    打桩驱动结果:现状入站泄漏矩阵(实测)

    方法:每协议 wire 形状 fixture 注入全部 10 类 marker,按现行接线跑 raw stage(stripAcpPanel* → stripAcpStatusMarkers → stripEmbeddedChainCarriers;google 只接了第三个),看什么漏到上游。

    类 anthropic openai google responses 判定
    status_head ✅strip ✅strip 🔴LEAK ✅strip google 没接线(#2798)
    status_body 🔴LEAK 🔴LEAK 🔴LEAK 🔴LEAK 全协议漏(#2789)
    confirmation(📦/❌) ✅strip ✅strip 🔴LEAK ✅strip 同 MARKER_LINE 文法
    panel 三变体(box/cache/rule) ✅strip ✅strip 🔴LEAK ✅strip 整消息级
    chain_carrier ✅strip ✅strip ✅strip ✅strip 全绿(responses 需 type:"message" 正确形状——fixture 教训)
    render_tag 🔴LEAK×4 stripAcpTags 只用于出站,入站未接
    forged_header 🔴LEAK×4 同上
    summary_anchor raw 层不剥 = 设计如此(state 层 stripKernelSummaries carrier-aware 剥,乱剥会丢摘要) 非 bug
    nudge_echo 🔴LEAK×4 见下方定夺

    关键结论

    1. google 列 10/11 漏:不止 Google (Gemini native) lane never strips ACP panels/status markers from incoming history — vestigial import in prepare-google #2798 的"没调用"——stripAcpStatusMarkers 的泛型 walk 认 content: string|part[],google 是 content.parts 对象,walk 本身 google 盲。声明化的 per-protocol wire-walk 正好根治。
    2. render_tag/forged_header 全漏,但规则已存在:battery 实验(stripAcpTags 逐文本槽跑)证明接进 raw walk 即全消——无需发明新 pattern,只是接线。
    3. 真正要新写的规则只有 1 个:status_body;anchor 整消息级(panel 族)+ state 级(anchor)已有。
    4. nudge_echo 定夺:440+ 会话 dogfood 语料查 messages 表(CAS join),用户角色回存命中 0;6 个命中全是模型 reasoning 引用/工具结果/一条 summary 内文。→ 回存风险实际很低,但按 panel 同款整消息精确匹配纳入(便宜、零误伤、fixture 覆盖),不剥块内引用。
    5. 车道维度:raw-strip 是协议级(与 proxy/MITM/plugin 车道无关,全走同一 prepare);唯一例外是 plugin 早退路径(anthropic :58/:68 classifier passthrough、global-scope-system;responses prepareResponsesCompact)在 strip 之前 return——依赖"该路径客户端不发面板"假设。coverage 测试将这些形状列为显式豁免,假设一旦被打破测试会红。
  7. ranxianglei commented on Oct 11, 2026

    @ranxianglei
    OwnerAuthor

    🤖 Powered by ework · qwen3.8-27b

    泄漏矩阵核对 — 实证扎实,结论成立;补一个动手前必须一等公民化的高危面(KDD #10)

    结论:矩阵是按现行接线实测出来的,基线可信;五条关键结论我都核过代码,方向对。唯一要在进实现前钉死的是——把 stripAcpTags(render_tag/forged_header)接进入站 raw walk 这一动作,恰好落在 KDD #10「签名校验的 thinking 族永不改写」的高危区,现有出站 walker 已经带这条纪律,新的入站 walk 是不同形状、净新写的,必须把它继承下来并配一条字节级 fixture。

    逐条核对(验过的)

    • 结论 2(render_tag/forged_header 规则已存在、只是没接入站)成立:stripAcpTags(src/loop/tag-echo-filter.ts:390)是纯 string→string;现行调用点全在出站/流(stream.ts:1031、stream-openai.ts:61、stream-google.ts:46)和 filter 自己的出站形状 walker 里,入站 prepare 确实没接。所以是接线不是发明新 pattern——对。
    • 结论 5(车道维度 + plugin 早退)精确:早退路径核实无误——anthropic isAutoModeClassifier passthrough(:56)、hasGlobalScopeSystem(:[Bug][claude MITM] 注入 ACP 工具破坏宿主请求:scope:"global" 缓存前缀 400 + Threads continue 指纹不符(thread_fingerprint_mismatch) #2648,:69)、responses prepareResponsesCompact(:558),都在 raw-strip 前 return。「coverage 测试把这些形状列为显式豁免、假设被打破就红」是对的处置。
    • summary_anchor「raw 层不剥 = 设计如此」认同:carrier-aware,归 state 层 stripKernelSummaries 剥,两钉点分工正确,非 bug。
    • 结论 4(nudge_echo 整消息精确匹配、不剥块内引用)认同:440+ 会话 0 用户角色回存命中,风险确实低;整消息精确匹配是零误伤的保守选择。边界说明:它抓不到「nudge 被拼进更大一条 user 消息里」的情形——按语料证据可接受,记一笔即可。

    关键补强:入站 wire-walk 必须继承 KDD #10 的 thinking 排除,并配字节级 fixture

    现状:出站那套 walker 已经编码了「prose filter 永不碰 thinking」——stripAnthropicText(tag-echo-filter.ts:1351)只动有 string .text 的槽,天然跳过携带 .thinking+.signature 的块;stripOpenaiChatText(:1318–1324)只剥 content、明确不碰 reasoning_*;#2805 还专门给 google 加了「跳过 thought:true/带 thoughtSignature 的 part」。

    问题:B 设计的入站 wire-walk 是另一种形状(request history,非 response/stream)、且是净新写。如果它把 stripAcpTags 无差别跑过每个文本槽,一旦碰到签名 thinking 块就会改写字节 → 与 signature 失步 → replay 直接 brick(KDD #10;AGENTS.md 明列此为高危、要求两条签名 wire 上的 loop 级字节相等测试,#1882 就是栽在这)。

    要求(进实现前落定):

    1. 每协议 accessor 显式跳过签名槽:anthropic {type:"thinking"|"redacted_thinking"};google part.thought/thoughtSignature;openai reasoning_content/reasoning;responses 对应 reasoning item。
    2. coverage fixture 每条签名 wire 加一个「含 tag 形内容的签名 thinking 块」用例,断言入站 raw walk 之后该块字节不变。没有这条,回归网正好在 fix: harden ACP render-tag stripping; keep NEVER-echo prohibition when injectTool is off (#1881) #1882/[acp-loop] In-turn compress re-request edits the latest assistant message → Anthropic 400 "thinking blocks … cannot be modified" (session stays broken) #1960 咬过人的地方留了个洞。

    两个小注

    下一步

    KDD #10 排除做成一等公民(+ 那条字节相等 fixture)之后,这套方案就具备实施条件了。你确认「吸收 #2797/#2805」的时序后,我可以先把 每协议 accessor(带签名槽跳过)+ 字节相等 fixture 用例作为 B1 骨架的一部分出出来,再铺 4×3 矩阵。要我现在就把三个出站 walker 的签名槽判定条件抽成一份对照清单(确认入站 accessor 逐条对齐)?(只读不改。)

  8. changed the title [-]Post-#2671: 收编文件形状的状态面机制 — session registry 收口、fork↔replica 合流、CCR 退役、affinity 落表(discussion)[/-] [+]Post-#2671: Absorbing File-Shaped State Plane Mechanisms — Session Registry Convergence, Fork↔Replica Merging, CCR Retirement, Affinity Table Materialization (discussion) | Post-#2671: 收编文件形状的状态面机制 — session registry 收口、fork↔replica 合流、CCR 退役、affinity 落表(discussion)[/+] on Oct 16, 2026
  9. changed the title [-]Post-#2671: Absorbing File-Shaped State Plane Mechanisms — Session Registry Convergence, Fork↔Replica Merging, CCR Retirement, Affinity Table Materialization (discussion) | Post-#2671: 收编文件形状的状态面机制 — session registry 收口、fork↔replica 合流、CCR 退役、affinity 落表(discussion)[/-] [+]Post-#2671: Absorbing File-Shaped State Plane Mechanisms — Session Registry Convergence, Fork↔Replica Merging, CCR Retirement, Affinity Table Materialization (discussion) | Post-#2671: 收编文件形状的状态面机制 — session registry 收口、fork↔replica 合流、CCR 退役、affinity 落表…[/+] on Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions