Skip to content

[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

Open
ranxianglei wants to merge 1 commit into
2026-10-31_contract-v2-stake-testsfrom
2026-10-30_native-attach-pi

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

(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 侧变成一份车道配置 + 一行转发。纯搬运,行为一字节不变。

改动:

验收证据(等价性):

切片状态: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。

@ranxianglei ranxianglei changed the title 四车道共享启动生命周期第一步:pi 车道迁入 native-attach(#5241 阶段 1 / PR-1a,纯搬运) [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,纯搬运) Oct 30, 2026
…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.
@ranxianglei
ranxianglei force-pushed the 2026-10-30_native-attach-pi branch from 47b2656 to 2b68520 Compare November 11, 2026 23:37
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[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 2026-10-31_contract-v2-stake-tests (#5242's branch), so the fix integrates that base, not master.

2. Root cause of the conflict. Head 2026-10-30_native-attach-pi = branch point 3518c2f + one commit (the pure relocation of the pi lane's verifyAttachAndRecover into a new src/agent/native-attach.ts). Its base branch had advanced 391 commits past that branch point, and among them a commit that edited the same import line in src/agent/pi-native.ts the PR also edits → textual collision.

3. What I did. Rebased the single commit onto the live base tip d18e0f55. Only src/agent/pi-native.ts conflicted; the two added files (src/agent/native-attach.ts, tests/native-attach-lane-guard.test.ts) applied cleanly because they don't exist on the base.

4. How the one conflict was resolved. The native-intercept.js import line: the PR removed observeRoutedOrigin (its usage moved into native-attach.ts); the base added setDeclaredModelEndpoints (+ a new model-endpoints.js import, #1295). Resolved as union of intents after verifying symbol usage in the post-relocation file: dropped observeRoutedOrigin and waitForProxyVersion (both have 0 remaining references), kept noteRoutedOrigin / readyOrigin / installNativeFetchIntercept / NativeInterceptState / setDeclaredModelEndpoints / loadDeclaredModelEndpoints, and added the native-attach.js import. Resulting imports match exactly the symbols actually referenced — no missing, no unused.

5. Verification (local, targeted per test discipline). npm ci → typecheck exit 0, build exit 0 (build-info commit 2b68520e18), and 25/25 targeted tests pass across tests/native-attach-lane-guard.test.ts, tests/contract-v2-stake-verify-attach.test.ts (pins the relocated verifyAttachAndRecover behavior), and tests/pi-native.test.ts. Full regression suite deliberately left to remote CI.

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 kernel-change declaration required.

7. Final state & judgment. Guarded force-push (--force-with-lease; pre-push guard confirmed the remote head was still exactly 47b2656 before pushing, so no concurrent work was clobbered) → origin/2026-10-30_native-attach-pi is now 2b68520e18. Authoritative git check: the current base tip d18e0f55 is an ancestor of the new head → conflict-free, fast-forward-mergeable; the base did not move again during the operation. ⚠️ One caveat on freshness: the mirror checks-cache still holds a stale 2026-10-30 snapshot (old sha, mergeable_state: unstable), so I did not assert CI green/red from it — GitHub will recompute mergeable_state and re-run the gates on the new push within ~60s. Verdict: conflict cleared, ready for CI re-run.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[ework] CI fix verified green ✓

1 similar comment
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[ework] CI fix verified green ✓

ranxianglei added a commit that referenced this pull request Nov 12, 2026
…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).
ranxianglei added a commit that referenced this pull request 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.

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