Skip to content

[PR] Four-lane shared startup lifecycle Step 3: opencode lane migration (#5241 Phase 1 / PR-1c, pure move) | 四车道共享启动生命周期第三步:opencode 车道迁入(#5241 阶段 1 / PR-1c,纯搬运) - #5247

Open
ranxianglei wants to merge 1 commit into
2026-10-30_native-attach-ompfrom
2026-10-30_native-attach-opencode
Open

ranxianglei wants to merge 1 commit into
2026-10-30_native-attach-ompfrom
2026-10-30_native-attach-opencode

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

(ai: zai/glm-5.3)

Refs #5241(阶段 1 / PR-1c,纯搬运,不 Closes)|叠在 #5246 之上(合并顺序:#5242 → #5244 → #5246 → 本 PR)

这个 PR 做什么:第三刀——opencode 车道的 verifyAttachAndRecover 换成共享模块调用,与 pi/omp 完全同构。纯搬运,行为一字节不变,桩矩阵一行未改 3/3 全绿。

opencode 特有语义通过 spec 保留:

  • 日志前缀历史格式是连字符 bili-native-opencode:(pi/omp 是括号 bili-native(pi)),新增可选 tag spec 字段逐字节保留(缺省仍是括号格式,已迁车道消息不变);
  • armNativeLane("opencode") 车道互斥守卫覆盖 attach/spawn/inline 三种模式。

配套测试改动:issue3304 的跨车道矩阵有意在一个测试进程里共驾 omp+opencode 两条车道(#3304 本来就是跨车道矩阵)——现在两条动态 import 之间显式 _resetArmedLaneForTest():守卫编码的是生产契约(每车道一个宿主进程),测试有意共驾时显式豁免,而不是回到从前那种静默互相污染。

验收:opencode-native 65/65、opencode-incremental 7/7、opencode-msgids 6/6、issue3304 23/23、issue1958 5/5、issue3654 24/24、桩矩阵 3/3 未改动、issue3544(dsh)20/20、tsc 干净。

切片:PR-1a(#5244)→ PR-1b(#5246)→ PR-1c(本 PR) → PR-1d(dsh 最后一刀,#3544 轮换等独有差异走 spec 钩子)。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

查重:不重复——本 PR 是 #5241(Host contract v2:先桩后统一生命周期)规划中的第三刀 PR-1c,与 #5242(阶段 0 桩)、#5244(PR-1a pi)、#5246(PR-1b omp)是设计上依次叠加的合并顺序,不是并行重复工作;GitHub/mirror 上未检索到其它做 opencode 车道迁移的在途条目。

标签:opencode + scope/wiring + p3(纯搬运重构,涉及宿主接线层/启动生命周期,无用户可见行为变更)。

开始审核:diff = eee5f58bf..6052fa757(单 commit,叠在 #5246 之上)。接下来逐条核实「行为一字节不变」(日志前缀、armNativeLane 守卫、恢复路径语义)、核对测试改动是否只豁免测试共驾、跑定向测试并查 CI,最后按八问给结论。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

审核结论:可合(CI 全量仍在跑,见第 5 问末;合并顺序 #5242 → #5244 → #5246 → 本 PR 必须保持)。

八问:

1. 是什么问题:不是修 bug,是 #5241「四车道共享启动生命周期」的第三刀——把 opencode 车道私有的 attach/恢复逻辑(verifyAttachAndRecover)换成共享模块调用,与 pi(#5244)、omp(#5246)完全同构。纯搬运。

2. 什么原因导致的(为什么做):四条车道各带一份几乎相同的私有副本,每个修复要手工抄四遍,同一类 bug 逐车道复发(umbrella #5241)。本刀消掉 opencode 那份私有副本,只剩 dsh(PR-1d)还保留自己的加厚版。

3. 影响范围与严重程度:仅内部实现,无外部影响。行为一字节不变(逐行核过,见下)。唯一可观察差异:armNativeLane("opencode") 让「一个进程里武装两条不同 native 车道」从静默互相污染变成显式抛错——生产部署每车道一个宿主进程,永不触发;该守卫在 #5244/#5246 已对 pi/omp 生效,本 PR 只是把 opencode 纳入同一契约。

4. 怎么修复的:沿用前两刀建立的「共享生命周期 + NativeLaneSpec 钩子」模式。opencode 特有语义全部走钩子保留:① 新增可选 tag 字段填 "bili-native-opencode",历史连字符日志前缀逐字节保留(缺省仍是括号格式,pi/omp 消息不变——已核对 pi/omp 两个 spec 都没有 tag 字段);② clearOrigin 缺省 → 共享路径默认写 state.origin = undefined,与被删旧代码的 fallback 分支逐句一致;③ publish/unpublish/onEvent/spawnForTest/bootstrap 五个钩子与旧内联语句一一映射,发布顺序、singleFlight/respawn/ready 装配顺序均未动。测试侧:issue3304 有意在一个进程共驾 omp+opencode 两条车道(它本来就是跨车道矩阵),现在在两次动态 import 之间显式 _resetArmedLaneForTest()——守卫编码的是生产契约,测试共驾显式豁免,不再静默污染。

5. 是否有回归问题:无。逐项审过的既有行为:

  • 共享模块改动面 = 加一个可选字段 + 4 条日志行的前缀改走 ${tag}。pi/omp 不传 tag → 字符串与改动前逐字节相同;桩矩阵文件本 PR 一行未改且本地全绿(S1/S2/S3,四车道各自子进程驱动);
  • opencode 三条路径逐行对照(健康早返 / pinned 等待 / spawn fallback):探测优先级、publish 时机、env 读写、state.attach=false、origin 清理、spawn 恰好一次、landed 后双写 state+env——全部与删除前的私有副本一致;
  • import 清理:observeRoutedOrigin/waitForProxyVersion 移出后文件内零残留引用;bootstrap 是函数声明且定义在 laneSpec 之前,无 TDZ 风险;
  • arm 位置:与 pi/omp 同构(off 检查之后、markNativeHost 之前,覆盖 attach/spawn/inline 三模式);
  • 多车道共驾扫描:全 tests/ 扫过,只有 issue3304 一处共驾两条车道,reset 已就位;桩矩阵天然免疫(每车道独立子进程);
  • 高危模式逐项:无语义漂移(上述字节等价论证)、无 fail-fast 变吞错(守卫抛错是新增的 fail-fast)、无阈值/时序/输出格式漂移(日志字节相同)、无缓存/重试策略失效。
  • 本地定向证据(PR head 6052fa7):opencode-native(+v1)/opencode-incremental/opencode-msgids/issue3304/issue1958/issue3654/桩矩阵 3/3/issue3544(dsh)/lane-guard 合计 82 个顶层用例 0 失败;tsc 干净。CI 全量在审核时点仍在跑(head 6052fa7,0 failed,其余为排队/被新 run 取代的 cancelled/skipped)——绿了我在本线程补一句确认。

6. 是否破坏缓存:不涉及——未触碰会话存储、前缀缓存、reconcile、压缩决策任何一侧。

7. 是否改了设计方向:不改——延续 #5241 既定方向(四刀中的第三刀;dsh 按设计留到 PR-1d 走 spec 钩子收最后独有差异)。

8. 是否引入了新的配置:不涉及——无 env/config/CLI 新增。

补充两点:① PR 用 Refs #5241 而不 Closes 是对的,它是 umbrella 的一个切片;② 本 PR 叠在 #5246 之上,合并前必须先合 #5246,否则基线缺失直接红。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

CI 确认:head 6052fa757 的全部 check 已跑完——成功 + 跳过(e2e 车道按触发规则设计性 skip)+ 被新 run 取代的 cancelled,0 失败、0 挂起。审核结论不变:可合,合并顺序保持 #5242 → #5244 → #5246 → 本 PR。

@ranxianglei
ranxianglei force-pushed the 2026-10-30_native-attach-omp branch from eee5f58 to 3e15f19 Compare November 12, 2026 14:48
@ranxianglei ranxianglei changed the title [PR] 四车道共享启动生命周期第三步:opencode 车道迁入(#5241 阶段 1 / PR-1c,纯搬运) [PR] Four-lane shared startup lifecycle Step 3: opencode lane migration (#5241 Phase 1 / PR-1c, pure move) | 四车道共享启动生命周期第三步:opencode 车道迁入(#5241 阶段 1 / PR-1c,纯搬运) Nov 12, 2026
…5241 phase 1, PR-1c)

Third lane migration: opencode's verifyAttachAndRecover swaps its private
copy for the shared native-attach.ts lifecycle via a NativeLaneSpec, as
pi (#5244) and omp (#5246) did. Pure transposition — the phase-0 stake
matrix passes untouched.

opencode specifics preserved through spec hooks: the historical hyphenated
`bili-native-opencode:` log prefix stays byte-for-byte via the new optional
`tag` spec field (default remains `bili-native(<lane>)` — pi/omp messages
unchanged). armNativeOpencode now calls armNativeLane("opencode") — the
one-lane-per-process contract covers attach/spawn/inline modes alike.

issue3304's cross-lane matrix deliberately co-loads TWO lanes in one test
process; it now resets the guard between the dynamic imports
(_resetArmedLaneForTest) — the guard encodes the production contract, and
a test that consciously co-loads lanes opts out explicitly instead of the
old silent cross-pollution.
@ranxianglei
ranxianglei force-pushed the 2026-10-30_native-attach-opencode branch from 6052fa7 to 872e45e Compare November 12, 2026 18:09
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

Conflict resolved — PR is now cleanly mergeable.

This PR (#5247, opencode lane migration, #5241 phase 1 / PR-1c) is a stacked PR: its head branch 2026-10-30_native-attach-opencode is based on the omp lane branch 2026-10-30_native-attach-omp (PR-1b), not on master. The omp base had advanced since the opencode branch was cut — it now carries updated pi/omp commits plus master merges — while the opencode branch still carried stale copies of the pi/omp commits. That divergence is what made the merge state dirty.

What I did:

  • Rebased the opencode branch onto the current omp base (3e15f19441): created a branch from the base and cherry-picked the single opencode commit (6052fa7577), dropping the stale pi/omp commit copies that the base branch already supersedes.
  • Resolved one import-block conflict in src/agent/opencode-native.ts: kept master's newer imports (setDeclaredModelEndpoints, loadDeclaredModelEndpoints, incrementalCacheRetouchEnabled, pfChannel), added the migration's native-attach.js import, and dropped observeRoutedOrigin (now called inside the shared lifecycle — confirmed unused elsewhere in the file).
  • Verified: npm run typecheck green (exit 0); 26/26 targeted tests pass (tests/issue3304-incremental-direct-send.test.ts cross-lane matrix + tests/contract-v2-stake-verify-attach.test.ts phase-0 stake matrix).
  • Force-pushed to 2026-10-30_native-attach-opencode (new head 872e45ef6e).
  • Confirmed mergeable_state: clean (the opencode head is now a direct descendant of the omp base; merge-base = base sha, no merge-tree conflicts).

The diff is unchanged from the original opencode commit (3 files, +49/−76) — a pure transposition, no logic lines altered by the rebase.


八问

  1. 是什么问题:PR [PR] Four-lane shared startup lifecycle Step 3: opencode lane migration (#5241 Phase 1 / PR-1c, pure move) | 四车道共享启动生命周期第三步:opencode 车道迁入(#5241 阶段 1 / PR-1c,纯搬运) #5247(opencode 车道迁入)与其基分支(omp 车道分支)冲突,merge state 为 dirty,无法合并。
  2. 什么原因导致的:堆叠 PR 分叉——opencode 分支是从 omp 分支的旧版本切出来的,之后 omp 分支又前进了(更新 pi/omp 提交 + 合入 master),而 opencode 分支仍带着旧的 pi/omp 提交副本,两者不再共线。
  3. 影响范围与严重程度:仅阻塞该 PR 的合并(CI 报 dirty),无运行时/用户面影响——纯搬运,行为不变。严重度:合并被卡,非功能缺陷。
  4. 怎么修复的:把 opencode 分支 rebase 到当前 omp 基分支上——从新基分支建分支,只 cherry-pick 唯一的 opencode 提交,丢弃被基分支取代的旧 pi/omp 副本;解决 opencode-native.ts 一处 import 冲突(保留 master 新 import + 迁入的 native-attach import,删掉已无引用的 observeRoutedOrigin)。
  5. 是否有回归问题:无。typecheck 绿(exit 0),26/26 定向测试通过;rebase 未改任何逻辑行,diff 与原 opencode 提交完全一致(3 文件 +49/−76)。
  6. 是否破坏缓存:不涉及——不触碰缓存/重试/游标/去重逻辑。
  7. 是否改了设计方向:不涉及——[Design] Host contract v2: pin behavior with stubs first, then unify lifecycle / capability declaration / degradation re | [Design] 宿主契约 v2:先打桩固定行为,再统一生命周期/能力声明/降级恢复/入口实测(讨论通过后才动工)| [Design] Host contract v2: pin behavior with tests first, then unify lif… #5241 四车道共享启动生命周期设计不变,只是 opencode 车道现在坐在更新后的 omp 基分支上。
  8. 是否引入了新的配置:不涉及——无新 env/config/默认值。

判定:冲突已解决,PR 现为 clean 可合并状态,等待正常 review/合并。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷

Conflict resolved — PR #5247 is now cleanly mergeable. (Full 八问 detail in the floor above.)

What I did this run:

  • Diagnosed: stacked PR — the opencode lane (2026-10-30_native-attach-opencode) is based on the omp lane branch, not master. The omp base advanced after the opencode branch was cut (updated pi/omp commits + master merges) while the opencode branch carried stale pi/omp copies → merge state dirty.
  • Rebased the opencode branch onto the current omp base (3e15f19441): cherry-picked the single opencode commit (6052fa7577), dropped the stale copies, and resolved one import conflict in src/agent/opencode-native.ts (kept master's new imports + the migration's native-attach.js import; dropped the now-unused observeRoutedOrigin).
  • Verified: npm run typecheck exit 0; 26/26 targeted tests pass (tests/issue3304-incremental-direct-send.test.ts cross-lane matrix + tests/contract-v2-stake-verify-attach.test.ts phase-0 stake matrix). Diff unchanged from the original opencode commit (3 files, +49/−76) — pure transposition, no logic lines altered.
  • Force-pushed to 2026-10-30_native-attach-opencode (new head 872e45ef6e); confirmed mergeable_state: clean.

No design decision needed, no authorization gate hit, no new issue opened.

判定:冲突已解决,PR 现为 clean 可合并状态,等待正常 review/合并。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷

No action needed — the conflict was already resolved in the previous run; live verification in this run confirms the PR is clean.

Verified against live sources in this run (not from memory):

  • git: opencode head 872e45ef6e, omp base 3e15f19441, merge-base(opencode, omp) = 3e15f19441 (= base head) → the opencode branch is a clean descendant of the omp base, no divergence.
  • GitHub API (single GET): state: open, mergeable: True, mergeable_state: clean, head 872e45ef6e on base 2026-10-30_native-attach-omp, not yet merged.

This trigger was based on stale mirror data (the mirror cache still carried the pre-rebase head 6052fa757 / dirty). Nothing has changed since the previous fix — no new commits on either branch, base unchanged. So: no re-rebase, no push, no new issue, no decision needed.

判定:PR 已处于 clean 可合并状态(本轮已对 live 源核实),无需进一步动作,等待正常 review/合并。

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.

1 participant