Skip to content

session identity: order-primary resolver on the wire-neutral domain (#2944) - #2951

Closed
ranxianglei wants to merge 1 commit into
masterfrom
2026-10-13_order-primary-resolver
Closed

ranxianglei wants to merge 1 commit into
masterfrom
2026-10-13_order-primary-resolver

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Part of #2944 — the parallel-implementation phase. Per the issue's rollout discipline, switch-over (persona-anchor retirement + handle.ts lane switching) is a SEPARATE small step after the differential soak; merging this PR changes zero server behavior.

What

Independent ework implementation of the owner-approved order-primary session resolver (owner rule 2026-10-12), built on the wire-neutral domain after the raw-field draft was reviewed out:

skeletonOf(messages) = neutralTurns(messages).map(t => t.kind) — one source of protocol-shape knowledge (src/affinity-neutral.ts, the #2791 projection that #2939 runs on): content-blind by construction, four wires first-class (google parts, responses function_call included for free), leading system run / client marker turns / image placeholders stripped by the projection.

Claim rules: unambiguous client-minted id + main shape (≥3 turns incl. assistant) + head-or-tail order match → raw (continue/reanchor); shallow no-assistant blob → |sub:aux (the #1916/#2156 blob-steals-raw race dies structurally); deep stranger → |sub:task:<skel8>; id fails provenance → anonymous prefix-affinity ladder untouched. System prompts NEVER enter the claim decision.

Rule-3 guard rail (v2.1 semantics, matching the #294936ecf83 ruling): the projection's per-turn content fragments disambiguate ONLY the two order-ambiguous corners — shorter-with-aligned-tail and grown-with-rewritten-head. Genuine compaction keeps the tail verbatim (frags equal → raw + reanchor); a codex-style subagent replay (#150 id reuse) carries different tail content (frags differ → derived-task). Task lanes are discriminated by skeleton hash so distinct subagents under one main id stay separate while same-shape replays keep a stable key.

Relationship to #2942 / #2949

Per the owner direction in #2944 (「ework需要单独提交一个pr」), this is an independent implementation. It adopts the v2.1 semantics that landed on #2949 and adds corpus rows that PR lacks:

File-collision note: src/session-resolve.ts also exists in #2942 (v1 draft) and #2949 (v2.1). Whichever merges first, this PR rebases and its version takes over (same file path). Suggested cleanup (owner call): close #2949 (superseded); trim or close #2942 to stage 1 only.

Delivery form (per issue acceptance)

Verification

  • typecheck clean; new suite 12/12; unused-export gate clean; persona-family suites 31/31 (dsh-persona-fingerprint, issue2601-model-drift-absorption, session-continuity-proof, dsh-persona-continuity)
  • full matrix delegated to CI

config surface

N/A — no config fields, env vars, or CLI flags.

@github-actions

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-13_order-primary-resolver (b5811a1)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.3326-pr.2951.1e008ca

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-pr2951.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] 🏷 已拉取分支 2026-10-13_order-primary-resolver(head b5811a1ad,单提交,base = 当前 master,无 stale-base)逐项核实。结论:声称与实物一致,#2944 验收约束逐条落地,可合(待 4 个 test-matrix job 跑完,其余 26/30 全绿)。

核实证据(本地实测,非转述)

代码审查要点(主关)

结构化八问

  1. 是什么问题:架构落地 PR(会话身份:顺序+自铸id 为认领主判,hash 降级为防漂移护栏(通用规则,取代 persona-fp 阶梯) #2944 并排实现阶段)——会话身份层的认领判据从「内容表示(fp/链哈希)」换成「顺序骨架 + 自铸 id」,hash 降级为防漂移护栏;本 PR 交付新解析器 + 差分 corpus,不切换。
  2. 什么原因导致的:并发同 session-id 流互相覆盖 lastInputTokens 基线:#388 侧请求分类漏掉「整段上下文单消息」形态,#1595 re-anchor 放大覆盖 #1916→[[bug] dsh 0.1.185: main lane forks itself on a mid-session model switch, orphaning the persona anchor — every native compress is refused (9/9, not covered by #2157) #2241→codex 线 responses 身份仍走 instructions-hash subagentNamespace:同 id 下 instructions 中途变更会 fork 主 lane 丢压缩(#2241 同款暴露,未审计) #2250→[Bug] dsh 会话反复 model/provider 切换时主对话迁移到 |sub:<fp> persona fork,宿主盖章的 compress/decompress/acp_status 仍解析在陈旧父 id —— ref 跨空间不可解析直至熔断 #2601→[Bug] 升级/重启后 system 文本漂移把同一会话分叉成零折叠命名空间(|sub:<fp>):长会话随即 400 空 body / 502 preflight_compress_failed #2917 同族根因 = 身份层以表示为键,表示 churn(bili 自升级改工具措辞/host 重投影/模型切换)→ 幽灵 fork(|sub:<fp> 零 fold 账本)→ 巨包 preflight 502。修法让表示在认领决策中构造性不可见(内容盲,不是过滤)。
  3. 影响范围与严重程度:合并时零影响面(无调用方)。被修问题本身属严重故障级(特定条件下压缩状态完全丢失 + 502),其受影响面在切换时才激活,由你列的接线实测清单负责(dsh 切模型/fork 会话/Codex 集成:guardian 审批请求进入压缩管线,导致明确授权无法被识别 #150·并发同 session-id 流互相覆盖 lastInputTokens 基线:#388 侧请求分类漏掉「整段上下文单消息」形态,#1595 re-anchor 放大覆盖 #1916·fix(#2592): sniff the unattributed raw-URL branch for the dsh compaction envelope #2763 复现/老阶梯全 corpus 浸泡)。一个已在 A1 行显式钉死的设计取舍提醒:全新会话 req1/req2(剥 system 后 <3 turn)派生 |sub:aux,raw 要 req3 才认领——turn-1 会留一个 1-turn 幽灵会话(压缩状态零损失,GC 前无害);这是纯形状判据下与 review-blob 不可区分的必然代价,切换前你若不接受可在切换 PR 调判据,A1 行保证了阈值不会静默漂移。
  4. 怎么修复的:策略层 = 「顺序决定分支,内容片段只在顺序歧义处消歧」。骨架复用 dsh anthropic-messages lane bypasses native-intercept fetch patch: anonymous pfa-* session, fold ledger orphaned, silent ~182s re-fold on cross-protocol switch #2791 wire-neutral 投影(协议知识单点、四 wire 一等、system-run/marker/image-placeholder 投影级剥离);两个歧义角用 per-turn frag 判定真压缩(verbatim 尾 → raw+重锚)vs id 复用重放(异内容尾 → task lane);task lane 按骨架哈希分裂。
  5. 是否有回归问题:无。既有行为清点:server 管线/persona-anchor 阶梯/prefix-affinity 匿名阶梯/持久化格式/kernel/config surface 全部未触碰;old-ladder 特征化套件原样通过证明旧行为未被顺手改动。无高危模式命中(未接线,无语义漂移面;fail-fast/阈值/输出格式零变化)。
  6. 是否破坏缓存:不涉及——持久化格式/游标/去重键零改动;skeletons map 进程内存,与旧 anchors map 同生命周期类别。
  7. 是否改了设计方向:是——本 PR 记录的正是那次转向(owner rule 2026-10-12),已写入 AGENTS.md KDD feat: self-update (auto + manual) #11;代码层面未转向(未接线)。注:session identity: tool-prompt neutralization (#2917) + order-primary resolution (#2944) #2942 若先合入其 KDD,rebase 时重编号 refactor: reapOrphanBlocks should live in acp-kernel, not the proxy #12,纯文档冲突,PR 正文已预告。
  8. 是否引入新配置:无(config-surface-guard 绿)。

待你拍板的协调项(上轮已提,再列一次)

① 建议关闭 #2949(被本 PR 取代,且其堆叠基座 #2815 未合);② 建议关闭或裁剪 #2942 至 stage 1——stage 1(#2917 neutralizeToolPrompts)若要保留,我另开小 PR 独立验证。

判定:除 4 个在跑的 test-matrix job 外全部核实通过,该 4 个绿后即可合(我不代合)。切换(旧文件退役 + handle.ts 换道)维持计划外另行小步执行。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 CI 收尾确认(上轮回复的待办项):head b5811a1ad 上 30/30 check 跑完,唯一红项是 test (windows-latest, 22)——已定位到具体测试并排除与本 PR 相关。判定不变:可合。

红项定性(证据链)

挂的是哪个:全量 6546 中仅 1 fail——not ok 2369 - pi plugin wiring: session_info_changed reports rename and clear end-to-end (#2322),断言在 tests/issue2322-session-name.test.ts:223(clear reported (undefined name → empty string),actual 'My named session')。

为什么挂:测试侧确定性缺陷,不是产品 bug。reportSessionName(src/agent/pi.ts:293-311)是有意的 fire-and-forget(事件处理器 :1326-1329 同步返回、fetch 不 await——上报永不阻塞 host 事件循环,失败时 dedupe map 重新武装下次事件重试,这是设计);而该 e2e 用固定 50ms onceTick() 等整个 loopback POST 往返落地后才断言服务端状态。runner 负载下(该 run 全套件 608s)单次往返 >50ms → 读到旧值。rename/dedupe/clear 三步共享同一竞态面,这次 clear 步先中招。

为何与本 PR 无关:diff 未触碰 src/agent/pi.ts / session-name endpoint / 该测试文件;新模块零调用方(结构上不可能影响任何运行时行为);同 commit 其余三条矩阵腿(ubuntu-22/24、windows-24)全绿;本地连跑 3 次全绿;master 最近提交 e76b35f9 两条 windows 腿也全绿——属既有 flake 本次被负载触发。

处置

已立项 #2953(带来源标记):记录机制 + 修法方向(poll-until-settled 替代固定 tick,断言保持严格)+ 同模式另两处待核实位置(tests/responses-websocket.test.ts:889,915、tests/external-summary-autofold.test.ts:369)。按「一 issue 一 scope」+ diff 整洁要求,不并入本 PR(保持其纯增量性质)。

更新后的判定(对应上轮八问第 5 问)

  • ⑤ 回归问题:维持「无」——CI 红项定性为既有测试 flake,与本 diff 无关,不构成回归证据。
  • 其余各问不变(合并时零行为变化、缓存不涉及、配置无新增)。
  • 总判定:可合。若想在合并前让面板全绿,重跑单个失败 job 即可(大概率转绿);是否重跑由你定,我不代合。

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.

1 participant