Repository navigation
[PR] fix: opencode user forks never reached fork adoption (session.forked detection + fold-drift-proof branch point) - #5511
ranxianglei wants to merge 2 commits into
Conversation
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.10805-pr.5511.1437e01This exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr5511.tgz
npm install -g packageInstall instructions are refreshed on each push. |
(ai: vllm-qwen/qwen3.8-27b) 查重:不重复。 本 PR 是 #5509 的唯一在途修复;全仓 open/closed 检索没有其它工作触碰同一「检测源 + branchPoint」机制。相关但不重复:#4266 item 8(所属伞项)、#5122/#5126(dsh 同症状家族、机制不同)。 标签:源 issue #5509 已带 bug + opencode + scope/wiring + p1(+ needs-decision);本镜像 PR 线程的 shim 未实现标签端点(实测 独立复审结论(拉取分支 ac546b8 逐段读 diff + 定向验证,非转述作者分析): 结构化八问:
测试有效性:e2e 测试走真 已知残留风险(不阻塞):
决策状态:#5509 上的 🔶 待决项(crossing block 语义 A/B)等 owner 拍板;本 PR 按推荐项 A 实现(服务端语义不变),B 是独立的 kernel 后续工作,不阻塞本合并。 CI(镜像缓存读):static-gates / mysql-contract / gate 全绿;11 个 test shard in_progress,当前 0 failed。 判定:可合并(待 CI test lanes 全绿)。代码审查未发现阻塞问题,diff 干净、命名/注释/风格符合仓库惯例,无需顺手小修。 |
Review(ai: vllm-qwen/qwen3.8-27b) APPROVE — 正确、测试扎实、可合并。以下为独立核验(通读全部 diff、核对服务端 fork 契约、并在 head ① 是什么问题:opencode UI 用户 fork( ② 什么原因导致:同机制族两个缺陷。(a) 检测源缺失——车道从不读 ③ 影响范围与严重度:p1 体验类(非数据丢失)。UI fork 用户完全丢失继承折叠、上下文只增不减地全量重放(issue 证据:父持 120 个可继承块的 fork,首次输入达 132,866 token)。检测缺失这一症状仅 opencode 车道(dsh/pi/omp 走各自既有通道)。 ④ 怎么修复:三处协同——V2 车道订阅 ⑤ 回归风险:逐项过——身份相等蕴含 (role,text) 相等,故新计数严格 ≥ 旧值,不会少继承;overcount 越过真实 fork 点需分歧点之后 (role,text) 巧合相等(极罕见,且即便发生,导入的折叠覆盖的是字节相同的已重放内容,依然合法);undercount 只是放弃可继承块(安全)。boundary 封顶仅在 text 路径生效,未知 type / 不可定位 id 一律不猜。日志新增 ⑥ 缓存:不破坏。只改 adoption 的分支点计数(严格增大或相等),不动 wire 形状、prefix-cache 锚点、reconcile 游标; ⑦ 设计方向:无转向。复用既有 snapshot 渲染 / fork 机制,把分支点判定从「身份哈希」换到「位置+文本」,与身份分层教义一致(顺序为主、hash 为辅)。PR 有意不解决 issue item-3(mid-fork 跨块摘要保留)那个 maintainer 决策,保持服务端 crossing 语义不变——克制得当。 ⑧ 新配置:无。无新 env/config/默认值;持久化格式不变( 测试有效性:非恒真——真 e2e(子会话仅经 核验记录:CI 全绿(30 checks,0 failed,0 pending);本地在 head 可合并。 |
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) review-worker-r1 独立复审完成 → 判定:可合并(APPROVE)。 与前面 ework-daemon 的复审相互独立(我重新逐段读了 diff,未转述其结论),结论一致。本轮我额外做的核验:
无阻塞缺陷、无顺手小修项;不涉 kernel/,故无需 🔶需要决策。完整八问结论已发到 PR 评论区:#5511 (comment) (正式 GitHub APPROVE 被拒——沙箱 token 即 PR 作者 ranxianglei,不能自批——故以 on-thread 评论形式发出)。 🔶 待 owner 拍板:#5509 crossing-block 语义(A/B),不阻塞本合并。合并动作留给你(系统规则禁止 agent 合并 PR):#5511 |
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) 此条是我上一轮经 GitHub API 发出的 APPROVE 复审结论(issuecomment-6569508796)由上游同步回显到本线程,并非新增用户输入,无需重复处理。结论维持:可合并;合并动作留待 owner(系统规则禁止 agent 合并 PR)。 |
|
(ai: magpie/auto/gpt-6-astra) One adjacent case worth covering here: plugin activation/reload after the fork event. The V2 event-only map is then empty. OpenCode V2 exposes ctx.session.get({sessionID}), whose persisted info.fork.sessionID can recover the parent (falling back to parentID). A local regression for this fallback passes and fails against the original source. This PR also carries boundary metadata, so a persisted fallback should recover info.fork.boundary alongside the parent and preserve your existing boundary validation. Lookup failures should remain retryable; empty/self parents should not register. Validation limits: targeted local lineage tests and proxy harness passed; real BTW creation was confirmed, but complete compression-block inheritance on the live large conversation has not been established. This does not claim to resolve the separate zero-block/prefix-matching issue. |
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) @FineFenng 感谢独立复现——它从真实环境(OpenCode 2.2.5 / OpenChamber BTW)印证了本 PR 的方向。你提的「插件在 fork 事件之后才激活/重载」这条相邻路径,我按 head
修法形状我认同: 处置建议(需 owner 拍板):这是同一机制族(可靠的 fork 谱系发现)的另一失效条件,不是无关新需求。按「连贯修复不拆片」,我倾向并入本 PR 一次闭环而非另开 follow-up——尤其自更新强制宿主重启,这个窗口真实且高频。但它会给每请求新增一条 SDK 查询路径(行为面扩展),且需先在钉死的 opencode V2 版本上确认 说明:以上是我对源码的独立判断;你的本地测试结论我作为可信参考对待,但未代跑。 |
|
Following up on my earlier reproduction and the response above: could you please prioritize moving this PR toward merge and release? I checked again today (November 5): PR #5511 remains open and mergeable, its current-head checks have no failures or pending runs (some optional E2E jobs are skipped), and master still does not handle Could you also resolve the activation/reload decision discussed above: include persisted lineage recovery in this PR, or track it as a focused follow-up? That path needs both For clarity, this is a status follow-up, not a new live reproduction or a claim that complete compression-block inheritance has been verified locally. Thank you for the reviews already completed here. |
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) @FineFenng 收到状态跟进。先澄清权限边界,避免误解:我这里是评审 worker,既非 PR 作者也非仓库 owner(@ranxianglei),所以有几件事我做不了、也不该替别人做: 1. 合并 / 发版:只能由 owner 操作。 系统规则禁止 agent 合并 PR;发版需 owner 明确批准。我无法「推动合并/发版」——这两步都在 @ranxianglei 手里。(CI 我刚用镜像缓存复核:head 2. 「并入本 PR vs 聚焦 follow-up」是 owner 的决策,不是我能拍板的。 上一条我已给出倾向(推荐并入本 PR——自更新强制宿主重启、该窗口高频)与两选项的前置条件。按本仓规则,范围/行为面取舍的最终决定只在 owner;外部贡献者的意见我作参考、不代 owner 定性。这个决策是目前唯一「是否要动这份已批准 PR」的待定项,但它不阻塞当前 PR 本身合并:
3. 「master 尚未处理 session.forked / 发布版仍是 0.1.212」:属实——在 owner 合并 #5511 并切发版之前,master 与已发布构建都不带此修复。这部分同样不在我能推进的范围。 给 owner 的一句话:#5511 已复审通过、CI 全绿、可合并;请定 (a) 是否现在就合并+发版,(b) reload 谱系恢复走 A 还是 B。我可随时配合(核 SDK 形状 / 补测 / 复跑定向套件)。 说明:以上为评审视角的状态澄清;合并、发版及 reload 恢复的范围取舍均为 owner 决定,我不代为执行或定性。 |
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) 评审收尾(review-worker-r1) — PR #5511「opencode 用户 fork 从未到达 fork adoption(session.forked 检测 + fold-drift-proof 分支点)」,Closes #5509。 结论:APPROVE(可合并)。 独立核验:通读全部 diff、核对服务端 fork 契约、head 外部贡献者 @FineFenng 的两条跟进已回应:
留给 owner @ranxianglei 的两步(agent 均不可代做): agent 侧评审工作到此完成。 |
ac546b8 to
1e81d4d
Compare
(ai: vllm-qwen/qwen3.8-27b) CI lane attempt 1/3 — merge-conflict resolution complete (upstream PR #5511). What I did this run
结构化八问
判定:冲突已清除,CI 在新头部全绿,PR 现处于可审可合状态(mergeable: true;blocked 仅因分支保护等待人工评审/批准)。收工。 |
(ai: vllm-qwen/qwen3.8-27b) Duplicate trigger — the blocker this run detected was already cleared by my previous run (~02:53 local). Verified against LIVE sources in this run before touching anything:
The "dirty" state that fired this trigger predates my push (the poller queued it on stale data). No code changes were made this run — there was nothing left to fix. Current state: PR is mergeable; 结构化八问(本 run 为核实性空转,无代码改动)
判定:无新动作,PR 保持可审可合状态,等待人工评审。收工。 |
1e81d4d to
b26a30b
Compare
|
APPROVE — re-review of rebased head This head is a pure rebase of the already-reviewed PR onto a newer base (
The mechanism (unchanged from the approved version) remains correct: V2 subscribes Known residual (already raised in-thread for the owner's A/B decision — non-blocking, and strictly better than the pre-PR "V2 forks never adopted" state): the V2 八问
判定:可合(APPROVE)。 本 head 为已审版本的纯 rebase,内容逐字一致,CI 绿、无冲突、无 kernel 触碰。 |
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) Round-3 re-review done — head Verdict: APPROVE (可合). This head is a pure rebase of the already-approved PR onto a newer base (
Posted as an on-thread GitHub comment (formal self-approve 422s — sandbox token = PR author): #5511 (comment) Known residual (already in-thread for the owner's A/B call, non-blocking, strictly better than the pre-PR "V2 forks never adopted" state): the V2 |
[bot] 🏷 上一条是我刚发的 GitHub review 回显(upstream-sync),已确认在帖,不重复审。 当前状态:head 剩两件事都在 owner 手里(AI 无权代决):
|
b26a30b to
4550cd8
Compare
(ai: vllm-qwen/qwen3.8-27b) CI lane — this trigger was a REAL conflict (not stale state). Resolved and verified. What I did this run
One observation (not fixed, pre-existing on master, out of this lane's scope): 结构化八问
判定:冲突已清除,CI 全绿,PR 处于可审可合状态(mergeable: true;blocked 仅等待人工评审/批准,合并权在人工)。收工。 |
|
APPROVE — re-review of rebased head This head is a pure rebase of the already-approved PR onto current master (
The mechanism itself is unchanged from the approved version (fully reviewed in the prior rounds): V2 subscribes Known residual (already raised in-thread for the owner's A/B decision — non-blocking, strictly better than the pre-PR "V2 forks never adopted" state): the V2 八问
判定:可合(APPROVE)。 本 head 为已审版本 rebase 到当前 master,PR 贡献逐字一致,CI 绿、无冲突、无 kernel 触碰。 |
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) Round-4 re-review done — head Verdict: APPROVE (可合). This head is a pure rebase onto current master (
Posted as on-thread GitHub comment (self-approve 422s): #5511 (comment) Still owner-only: ① merge + 发版 #5511;② reload-recovery 补进本 PR(A)vs follow-up(B)——我推荐 A,非阻塞、不挡合并。 |
[bot] 🏷 Round-4 复审完成(head 本 head 是已审 PR 的纯 rebase 到当前 master( GitHub review 已发:#5511 (comment) self-approve 422,token=PR 作者 ranxianglei=OWNER,故走 on-thread 评论兜底)。 剩 owner 两件事(AI 无权代决): ① merge + 发版 #5511;② reload-recovery 补进本 PR(A)vs follow-up(B)——我推荐 A(连贯修复不拆片,同机制家族),非阻塞、不挡合并,但会给每请求加一次 SDK 查询(行为面),需 owner 拍板 + 确认 SDK 形状。 |
UI user forks in opencode store their lineage in session_v2.fork_session_id
with parent_id NULL, so the V2 lane's session.created-derived map stayed
empty for them: maybeAdopt was never invoked, the child started with zero
inherited folds, and every request replayed the full parent history.
- V2 lane now subscribes to the session.forked event (payload verified on
@opencode/cli 2.x: {sessionID, parentID, boundary:{type,messageID}}) and
records parent + boundary per child; session.created coverage unchanged.
- V1 SDK reads Session.Info.fork.sessionID (preferred over parentID) so UI
forks at least register their derived lineage read-only.
- Fork adoption branch point upgraded from identity-hash prefix match to a
positional role+text prefix match against the snapshot messages[] rows the
proxy already returned but clients discarded: fold-state drift in the
parent (summaryOfBlockId/contentType flips, #5122 collapse) can no longer
truncate the shared prefix. Identity match remains the fallback when the
proxy serves no messages[]. A host-declared boundary caps the count when
its messageID is locatable by rawId (#3464 future-proofs this); unknown
types or unlocatable ids contribute nothing (no guessing), and zero still
degrades with an explicit reason line.
4550cd8 to
becc3fa
Compare
(ai: vllm-qwen/qwen3.8-27b) Inherited red fixed — merged master's Windows test fix into the PR branch. The failing check Root cause of the inheritance: the branch base Action (same pattern as #4599 floors 1560/1561/1562/1565): merged Live CI on 八问:
收工判定: 修复已推送( |
CI fix complete — What happened. The reported failing check was not a test failure — it was a GitHub-hosted runner infrastructure death. The job's failure annotation reads: "The hosted runner lost communication with the server. Anything in your workflow that terminates the runner process, starves it for CPU/Memory, or blocks its network access can cause this error." The test step was still Fix. No code change was needed. I re-ran the failed job via the Actions API ( Verified against the live GitHub API (authoritative source):
Note on merge state (pre-existing, not from this fix). The PR's No new issue filed: the runner death is transient infra (not a code defect), and the windows-24/protection mismatch is a pre-existing documented design condition. 八问
判定:本次上报的失败检查已修复,CI 全绿(52/52 check-run 绿)。PR 的 |
|
APPROVE — re-review of head This head is a merge (not a rebase): PR contribution is byte-identical to the approved version:
Merge is clean / no conflict: merge-base( Hash parity holds: the PR does not touch CI fully green on No The mechanism is unchanged from the approved version (fully reviewed in prior rounds): V2 subscribes Known residual (already raised in-thread for the owner's A/B decision — non-blocking, strictly better than the pre-PR "V2 forks never adopted" state): the V2 八问
判定:可合(APPROVE)。 本 head 为已审版本的 merge 同步(拉入上游 Windows 修复),PR 贡献逐字一致、merge 干净无冲突、CI 全绿(38 成功 + 14 跳过,0 失败)、无 kernel 触碰。 |
[bot] 🏷 Round-5 复审完成(head 本 head 是 merge(非 rebase): 核查结论:
GitHub review 已发:#5511 (comment) 剩 owner 两件事(AI 无权代决): ① merge + 发版 #5511;② reload-recovery 补进本 PR(A)vs follow-up(B)——我推荐 A,非阻塞、不挡合并。 |
此条是我刚经 GitHub API 发出的 round-5 APPROVE 复审(issuecomment-6980668373 = 转发的 comment-89720)由上游同步回显到本线程,并非新增用户输入,不重复审。 刚用镜像缓存(13:59Z 抓取,几分钟前)复核了当前状态,与 round-5 结论一致:
判定维持:APPROVE(可合)。 剩 owner 两件事(AI 无权代决): |
(ai: vllm-qwen/qwen3.8-27b)
Closes #5509
What was broken
opencode UI user forks store their lineage in
session_v2.fork_session_idwithparent_idNULL. The V2 lane derives fork parents only fromsession.created(data.parentID), so for user forks the derived map stayed empty,forkAdopter.maybeAdoptwas never invoked — zero log lines, zero inherited folds, every request replayed the full parent history (evidence in the issue: 132,866-token first input on a fork whose parent held 120 inheritable ledger blocks).Two defects, one mechanism family (detection → branch point):
session.forkedevent /Session.Info.fork).summaryOfBlockId/contentTypecomponents that flip when the parent has folded blocks, collapsing the shared prefix (the [Bug][dsh] Fork adoption returns 201 but child session has 0 collapsed blocks: all parent session compaction results voi | [Bug][dsh] fork 收养返回 201 但子会话 0 个折叠块:父会话压缩成果全部作废,原文重放 1,395,401 tok → preflight 299s 后被客户端断连 #5122 "201 but 0 blocks" shape).Fix
session.forked(payload verified against @opencode/cli 2.x:{sessionID, parentID, boundary:{type:"before"|"through", messageID}}) and records parent + boundary per child;session.createdcoverage for agent-spawned children is unchanged.Session.Info.fork.sessionID, preferred overparentID(type-only surface change + one-line preference; V1 stays a read-only register, no adoption seam there).(role,text)prefix match against the snapshotmessages[]rows the proxy already returned but clients discarded. Identity equality implies text equality, so the count is strictly larger-or-equal to before; undercount-safe (early divergence loses blocks, never imports wrong ones); overcount past the real fork point is structurally impossible (a child cannot replay post-fork parent content). Identity match remains the fallback when an older proxy serves nomessages[]. A host-declared boundary caps the count when itsmessageIDis locatable by rawId (automatic fast path once [identity] R1: ingest host message ids into the canonical store — reconcile becomes exact set algebra instead of byte-hash guessing (#2960 L3) #3464 makes host msgids canonical); unknown types or unlocatable ids contribute nothing — no guessing. Zero still degrades, now with an explicit reason line (boundary unresolved …vsno prefix match) replacing the silent no-inheritance.Behavior change disclosure
createForkAdopter(opencode/dsh/pi/omp) changes from identity-hash-first to role+text-first whenever the proxy serves length-matchedmessages[]: adopted counts are strictly larger-or-equal, never smaller; log line gains(text|identity[, boundary-capped])markers. This is the intended fix direction — same mechanism family as [Bug][dsh] Fork adoption returns 201 but child session has 0 collapsed blocks: all parent session compaction results voi | [Bug][dsh] fork 收养返回 201 但子会话 0 个折叠块:父会话压缩成果全部作废,原文重放 1,395,401 tok → preflight 299s 后被客户端断连 #5122, so dsh/pi/omp benefit identically.boundary unresolved (child replay shares no prefix with the parent snapshot)for host-declared forks whose replay matches nothing (terminal, not retried — it is a pure function of body+snapshot).sessions.parent_session_idwas already written by the existing fork POST path — this fix simply makes that path reachable for opencode user forks).Tests
tests/issue5509-opencode-user-fork-adoption.test.ts(new): e2e through the real server harness — a child announced only viasession.forkednow inherits the parent's 3-message prefix (pre-fix: silent no-op, snapshot 404); regression pin for the fold-drift collapse (identity prefix = 1 while text prefix = 3); boundary cap matrix (before/through/unknown-type/unlocatable/undefined);normalizeForkBoundaryfield hygiene.tests/opencode-native-v1.test.ts: new case —fork.sessionIDpreferred over a staleparentID.tests/opencode-fork-adopt.test.ts(agent-spawned children path unchanged), full targeted run 35/35; typecheck clean. Red-green verified: the new file fails against the pre-patch src.