Repository navigation
[PR] Four-lane shared startup lifecycle, Step 1: migrate pi lane into native-attach (#5241 Phase 1 / PR-1a, pure relocation) | 四车道共享启动生命周期第一步:pi 车道迁入 native-attach(#5241 阶段 1 / PR-1a,纯搬运) - #5244
ranxianglei wants to merge 1 commit into
Conversation
…phase 1, PR-1a) First lane migration of the approved phase-1 plan (#5241 comment): the verifyAttachAndRecover lifecycle moves from pi-native.ts into a shared native-attach.ts, parameterized by a per-lane NativeLaneSpec (publish / unpublish / onEvent / spawn seam / bootstrap). Pure transposition — the pi lane's observable behavior is unchanged, proven by the phase-0 stake matrix (tests/contract-v2-stake-verify-attach.test.ts) passing untouched. Also lands the one-lane-per-process guard (armNativeLane): the four lane implementations all assume they are alone in the process (same BILLION_CONTEXT_PROXY env var, same global fetch-intercept slot, background timers that outlive any call). Phase-0 probing (#5242) showed two armed lanes in one process overwrite each other within milliseconds. Production never does this — the guard makes the implicit contract explicit and plainly worded. Re-arming the same lane stays legal (tests/restarts); a second, different lane throws. omp/opencode/dsh keep their own copies until their migration PRs; their suites and issue3544 stay green untouched. Net: pi-native.ts -77 lines, one spec + one-line wrapper in their place.
47b2656 to
2b68520
Compare
[bot] 🏷 (ai: zai/glm-5.3) Conflict resolved — PR #5244 rebased onto its live base and force-pushed. Seven-question summary of this run: 1. What was blocked. Merge state was dirty: the PR head conflicted with its base branch. Note this is a stacked PR — its base is not master but 2. Root cause of the conflict. Head 3. What I did. Rebased the single commit onto the live base tip 4. How the one conflict was resolved. The 5. Verification (local, targeted per test discipline). 6. Regression / behavior change. None introduced by the resolution — it is a pure relocation and behavior is frozen by the stake-verify-attach tests. The only other content now present (pi inline-default flip #5428, declared model endpoints #1295) came from the base branch itself, not from this fix. No kernel/ diff, no config/wire/persistence change → no gate or 7. Final state & judgment. Guarded force-push ( |
[ework] CI fix verified green ✓ |
1 similar comment
[ework] CI fix verified green ✓ |
…phase 1, PR-1b) Second lane migration: omp's verifyAttachAndRecover swaps its private copy for the shared native-attach.ts lifecycle via a NativeLaneSpec, exactly as pi did in PR-1a (#5244). Pure transposition — the phase-0 stake matrix (tests/contract-v2-stake-verify-attach.test.ts) passes untouched. omp specifics preserved through spec hooks instead of being silently unified: every origin write funnels through omp's publishOrigin() so a test-pinned probe base (_setOmpOriginForTest) survives a mid-suite attach verify / respawn landing, and the fallback branch's state clear routes through the same guard — hence the new optional clearOrigin spec hook (default remains the direct state.origin = undefined the other lanes use). armNativeOmp now calls armNativeLane("omp"): the one-lane-per-process contract (BILLION_CONTEXT_PROXY + fetch-intercept slot are per-process singletons — #5242 phase-0 stakes) is enforced for both migrated lanes. opencode/dsh keep their own copies until PR-1c/1d; their suites stay green untouched (issue3544 20/20, opencode-native 65/65).
…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.
(ai: zai/glm-5.3)
Refs #5241(阶段 1 / PR-1a,纯搬运,不 Closes)|基于 #5242 分支(桩矩阵在 CI 里直接当验收网,故意 stack)
这个 PR 做什么:按 #5241 里已批准的阶段 1 方案(方案对比见 issuecomment-6525633059)做第一刀:把 pi 车道的
verifyAttachAndRecover搬进共享模块src/agent/native-attach.ts,pi 侧变成一份车道配置 + 一行转发。纯搬运,行为一字节不变。改动:
src/agent/native-attach.ts:共享生命周期实现 + 每车道NativeLaneSpec配置接口(publish/unpublish/onEvent/spawn 缝/bootstrap);src/agent/pi-native.ts-70 行:原实现换成 spec 构造 + 转发,导出签名不变,所有调用方/测试零改动;armNativeLane:同一进程 arm 第二条不同车道直接抛错(把 [PR] Boot contract stubbing: four-lane verifyAttachAndRecover behavior matrix + latch permanence + health glossary (#5241 Pha | 启动契约打桩:四车道 verifyAttachAndRecover 行为矩阵 + 闩锁永久性 + health 词汇表(#5241 阶段 0,只加测试) #5242 打桩实测的"两条车道互相覆盖代理地址/抢 fetch 拦截槽"隐含契约变成显式约束,报错信息说人话);同车道重复 arm 合法(测试/重启常态);tests/native-attach-lane-guard.test.ts(3 测)。验收证据(等价性):
切片状态:PR-1a(pi,本 PR)→ PR-1b(omp)→ PR-1c(opencode)→ PR-1d(dsh,独有差异走 spec 钩子,S2 轮换分歧保留待专项)。本 PR 合入后新旧并存跑一个周期,确认无回归再迁 omp。
注意:base 故意设在 #5242 分支上,让桩矩阵进本 PR 的 CI;#5242 合并后 GitHub 会自动 retarget 到 master。