Skip to content

[PR] Step 2 of the Four-Lane Shared Startup Lifecycle: OMP Lane Migration In (#5241 Phase 1 / PR-1b, pure move) | 四车道共享启动生命周期第二步:omp 车道迁入(#5241 阶段 1 / PR-1b,纯搬运) - #5246

Open
ranxianglei wants to merge 1 commit into
2026-10-30_native-attach-pifrom
2026-10-30_native-attach-omp
Open

ranxianglei wants to merge 1 commit into
2026-10-30_native-attach-pifrom
2026-10-30_native-attach-omp

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

(ai: zai/glm-5.3)

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

这个 PR 做什么:按已批准的阶段 1 方案做第二刀——omp 车道的 verifyAttachAndRecover 换成共享模块 native-attach.ts 调用(和 #5244 的 pi 完全同构)。纯搬运,行为一字节不变,#5242 桩矩阵一行未改 3/3 全绿。

omp 特有语义通过 spec 钩子保留(不是抹平):

  • omp 所有 origin 写都走 publishOrigin()(带测试钉保护:_setOmpOriginForTest 钉住的探针基座要能在套件中途的 attach verify / respawn 落地时幸存)——spec.publish 直通它;
  • fallback 分支的状态清理也走同一守卫——为此给 NativeLaneSpec 加了可选 clearOrigin 钩子(缺省=其他车道的直接 state.origin = undefined,pi 行为不变)。

改动:omp-native.ts -67 行(换 spec + 一行转发);native-attach.ts +clearOrigin 可选钩子;armNativeOmp 加 armNativeLane("omp") 车道互斥守卫(现在 pi/omp 两条已迁车道都被显式约束)。

验收:omp-native 23/23、omp-msgids 7/7、omp-native-incremental 5/5、issue3304 23/23(omp+opencode 同进程——opencode 尚未加守卫,PR-1c 时处理)、桩矩阵 3/3 未改动、issue3544(dsh)20/20、pi-native 19/19、tsc 干净。

切片:PR-1a(#5244,已开)→ PR-1b(本 PR) → PR-1c(opencode)→ PR-1d(dsh,#3544 轮换等独有差异走 spec 钩子)。base 叠在 #5244 分支上,合并后自动 retarget。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

查重: 不重复。 本 PR 是伞 issue #5241(宿主契约 v2)阶段 1 已批准方案的切片 PR-1b(第二刀),兄弟切片为 #5242(桩矩阵)/ #5244(PR-1a pi)/ #5247(PR-1c opencode)/ #5248(PR-1d dsh)——刻意切片而非并行重复工作;无其他 open 条目覆盖「omp 车道 attach 生命周期迁移」。

标签: omp + scope/wiring + p3(纯搬运重构,行为字节级不变,无外部影响)。

审核进行中:代码级等价性审查已完成(被删 omp 代码 vs 共享模块 + spec 钩子逐分支比对);CI 截至 16:19Z 仍 14/14 queued。CI 结果出来后单独发最终结论。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

PR 审核结论:可合(CI 全绿 + 代码级等价性逐分支验证通过)

结构化八问

1. 是什么问题:不是修 bug,是计划内重构切片——四车道的启动 attach/fallback 逻辑(verifyAttachAndRecover)曾是四份近逐字拷贝(~90 行×4),同型 bug 跨车道独立复发(端口钉死 #926→#4566→#5127)。本 PR 把 omp 那份迁入共享模块 src/agent/native-attach.ts,是 #5241 阶段 1 批准方案的第二刀(第一刀 pi=#5244),纯搬运、行为一字节不变。

2. 什么原因导致的:历史手抄——各车道当年各自实现同一套探测/attach/fallback/spawn 逻辑,缺单源。打桩阶段还挖出一个没写进任何文档的隐含契约:「一个进程只装一条 native 车道」(四条车道抢同一个 process.env.BILLION_CONTEXT_PROXY 和同一个全局 fetch 拦截槽)。本 PR 顺带把该契约显式化(armNativeOmp 加 armNativeLane("omp") 互斥守卫)。

3. 影响范围与严重程度:纯内部重构,零外部用户面影响。生产行为不变(桩矩阵背书 + CI 绿)。唯一新行为:armNativeOmp 在同进程已有另一条已迁车道(pi)被 arm 时抛错。生产里每车道一个宿主进程,此路径不可达;若真触发,fail-fast 抛错优于旧的静默互相覆盖地址/顶掉拦截。

4. 怎么修复的:共享模块以 NativeLaneSpec 钩子参数化(publish/unpublish/clearOrigin/onEvent/spawnForTest/bootstrap/lane 标签)。omp 特有语义走钩子保留而非抹平:所有 origin 写都经 publishOrigin()(含 _setOmpOriginForTest 钉保护——钉住时 publishOrigin 早退,套件中途的 attach verify/respawn 落地探针基座能幸存),spec.publish/clearOrigin 直通它;为此给 NativeLaneSpec 加可选 clearOrigin(缺省=直接 state.origin = undefined)。我逐分支与被删代码比对过:healthy / pinned-recovery / pinned-dead / fallback / spawn 五条路径,日志字符串(含 (omp) 车道标签)、env 操作、状态写顺序全部一致;fallback 清理顺序 unpublish(delete env)→attach=false→clearOrigin≡publishOrigin(undefined,false) 与旧码一致;pinned-dead 分支仍走直接写(不经 clearOrigin),与旧 omp 完全一致。

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

  • omp 生命周期:字节等价(见上);
  • pinned-dead 直接写保留,未误路由进钩子;
  • pi 车道:spec 未定义 clearOrigin → 默认分支执行原语句,零变化;
  • verifyAttachAndRecover(attachOrigin) 导出签名保留,外部/测试导入不受影响;
  • 新增跨车道抛错:有意契约收紧。核查了所有会 arm 多车道的测试:桩探针每子进程只 arm 一条车道,omp/pi/opencode 各自测试文件只 arm 自己车道,node --test 文件间进程隔离;issue3304 的有意双车道共驾(omp+opencode 同进程)因 opencode 尚未加守卫(PR-1c 处理)不受影响——与作者验收描述一致,且 CI 实测绿;
  • 高危模式逐项:无语义漂移、无 fail-fast 变吞错、无阈值/时序/输出格式漂移、wire/配置/持久化均未触碰。
    结论:无回归。

6. 是否破坏缓存:不涉及。不碰前缀缓存、重试策略、增量游标、去重键,不碰 wire 消息形状。

7. 是否改了设计方向:没有转向——这是已批准阶段 1 方案(生命周期单源化)的执行本身。「一车道一进程」从隐含假设变为显式契约属于方案设计目标,不是漂移。

8. 是否引入新配置:无。没有新 env/config key/默认值。

行为变更披露(Deliverables 第 4 条)

唯一变化:armNativeOmp 旧行为=无条件继续(隐含假设一进程一车道,违反时静默互相覆盖)→ 新行为=同进程已有另一已迁移车道时立即抛错。生产不可达,属 fail-fast 收紧,非语义漂移。

过程观察(不阻塞,请 owner 知悉)

#5241 线程里阶段 1 方案稿(14:48Z)明确写「owner 批准后才动工」,41 分钟后(15:29Z)四刀全部开出并称「按批准的方案 A」,但我在 GitHub 线程里找不到显式的 owner 批准评论(伞 issue 仅那两条评论,#5244/#5246 评论数为零)。若批准发生在其他渠道,忽略本段;否则建议补一句记录,免得「先批准后动工」的规矩留个证据缺口。

判定

可合。 CI:head eee5f58b 上 14/14 gate 全绿(typecheck/build/test 分片等),16 个实客户端 e2e 车道按预期 skip(本 PR 未触碰请求管道/update/registry 触发路径)。diff 整洁:仅 2 文件(native-attach.ts +9/-1、omp-native.ts 净 -39 行),每一行都与目的相关,无无关改动。合并顺序按叠栈:#5244 合入后 GitHub 自动 retarget 本 PR。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

收工确认:审核已完成并全部落在本线程——floor 2(查重结论+标签)、floor 3(结构化八问最终结论)。判定:可合。CI head eee5f58b 14/14 gate 全绿;diff 仅 2 文件、行为字节级等价、无回归;唯一新行为是 armNativeOmp 的跨车道 fail-fast 抛错(生产不可达)。合并按叠栈顺序走(#5244 合入后自动 retarget),合并操作留给人工。

ranxianglei pushed a commit that referenced this pull request Oct 31, 2026
…lling back to 272K (#5246)

Codex resolves its live model table from exactly one path, <CODEX_HOME>/models_cache.json. On installs driven by a custom catalog (config.toml `model_catalog_json = ...`) that file does not exist, so bili fell through to the bundled snapshot (no entry) and the flat 272K floor, clamping the effective window far below what codex actually perceives and triggering emergency nudges at ~35% of the real window.

- Parse `model_catalog_json` from codex's own config.toml and resolve the live table from that path when set, else models_cache.json (relative paths resolve against CODEX_HOME).
- When neither file is readable but config.toml sets `model_context_window`, size from that value capped by the known max_context_window (the bundled entry's max, or the 272K unknown-model ceiling) instead of the flat 272K floor — never budgeting above what codex perceives — and log a warn naming the degraded path.
- Name the winning window source (client-report/catalog-json/models-cache/config-context-window/bundled-snapshot/flat-fallback) in the clamp log line instead of the misleading "current client metadata preferred" text.

Local codex peers on such installs now get the real perceived window (toward larger, never below codex perception); remote peers, non-codex clients, operator modelContextLimit, min() semantics and output reservation are unchanged.

Closes #5246
ranxianglei pushed a commit that referenced this pull request Oct 31, 2026
The sole call site moved to src/server/handle.ts when handle() was
extracted (e7af746); the import at server.ts:17 has been unused since.
Found while reviewing #5246 — trivial cleanup, no behavior change.
@ranxianglei
ranxianglei force-pushed the 2026-10-30_native-attach-pi branch from 47b2656 to 2b68520 Compare November 11, 2026 23:37
@ranxianglei ranxianglei changed the title [PR] 四车道共享启动生命周期第二步:omp 车道迁入(#5241 阶段 1 / PR-1b,纯搬运) [PR] Step 2 of the Four-Lane Shared Startup Lifecycle: OMP Lane Migration In (#5241 Phase 1 / PR-1b, pure move) | 四车道共享启动生命周期第二步:omp 车道迁入(#5241 阶段 1 / PR-1b,纯搬运) Nov 11, 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
ranxianglei force-pushed the 2026-10-30_native-attach-omp branch from eee5f58 to 3e15f19 Compare November 12, 2026 14:48
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

Conflict resolved and pushed. The PR was dirty (mergeable: false) because the omp branch was based on the OLD pi commit (47b2656575), while the pi branch (#5244, PR-1a) had since been rebased onto current master (new pi tip 2b68520e18, absorbing 2281 master commits). The omp commit's base was therefore superseded, producing an add/add + import-block conflict in src/agent/omp-native.ts.

What I did this run:

  1. Rebased the omp commit onto the new pi tip: git rebase --onto origin/2026-10-30_native-attach-pi 47b2656575 — drops the superseded old-pi commit, replays ONLY the omp commit (eee5f58bfc) onto 2b68520e18. Keeps the stacked PR linear on the new base.
  2. Resolved the single conflict (the import block in src/agent/omp-native.ts) as the union of both intents:
    • Dropped observeRoutedOrigin + waitForProxyVersion — used only inside verifyAttachAndRecover, which the omp migration moves into native-attach.ts.
    • Kept master's setDeclaredModelEndpoints / loadDeclaredModelEndpoints / pfChannel — used in untouched functions (arm section line 424, ompIncrementalBeforeSend line 184).
    • Added the omp's native-attach.js import (armNativeLane, verifyAttachAndRecoverShared, NativeLaneSpec).
    • native-attach.ts auto-merged cleanly (the clearOrigin hook addition).
  3. Verified locally (targeted, per local-testing discipline — no full-suite run):
    • npm run typecheck → clean (kernel + pi-subagents build, tsc --noEmit no errors).
    • Targeted suites tests/contract-v2-stake-verify-attach.test.ts + tests/native-attach-lane-guard.test.ts → 6/6 pass.
  4. Force-pushed (authorized for this conflict-rebase): eee5f58bfc → 3e15f19441. Fetched first; remote was still at the original head, no concurrent push to integrate.

Result: PR #5246 is now mergeable: true (was dirty). The rebase is a byte-equivalent pure move — the diff is exactly the reviewed commit's content, now on top of the new pi tip with master's changes preserved. CI is re-running on the new head (3e15f19441); the mirror cache currently reports 0 failed / 0 pending (the new run is still settling — the e2e suites take several minutes).


八问(结构化审核结论)

  1. 是什么问题:PR 与 base 分支冲突(merge state: dirty)——omp 分支钉在旧的 pi 提交上,而 pi 分支([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)已 rebase 到当前 master,omp 提交的基础被取代,在 src/agent/omp-native.ts 的 import 块产生 add/add + 内容冲突。
  2. 什么原因导致的:stacked PR 的 base(pi 分支)被 rebase 重写(旧 pi 提交 47b2656575 → 新 pi 提交 2b68520e18,吸收 2281 个 master 提交),omp 分支未跟随;两个分支对 omp-native.ts 的 import 块各有改动(omp 迁移删 observeRoutedOrigin/waitForProxyVersion,master 加 setDeclaredModelEndpoints/loadDeclaredModelEndpoints/pfChannel)→ 冲突。
  3. 影响范围与严重程度:仅影响本 PR 的可合并性(阻塞 [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 阶段 1 的 omp 车道迁入);不涉及运行时行为——纯搬运,代码逻辑与已审查的原始提交逐字节等价。严重程度:阻塞性(不解决则无法合并),无用户面影响。
  4. 怎么修复的:git rebase --onto 把 omp 提交重放到新 pi 顶端(丢弃被取代的旧 pi 提交),冲突块按「双方意图并集」解决——保留 master 三处新增 import(在未被触碰的函数中使用),删掉 omp 迁移已移除函数里独占的两个 import,加上 omp 的 native-attach import。
  5. 是否有回归问题:无。逐符号核验:observeRoutedOrigin/waitForProxyVersion 仅在被移除的 verifyAttachAndRecover 内使用(删 import 安全);setDeclaredModelEndpoints(行 424)/loadDeclaredModelEndpoints(行 424)/pfChannel(行 184)在 master 新增的未触碰函数中(保留正确);nativeAttachOrigin 仍在 planNativeOmp(行 53)使用(保留)。typecheck + 两个定向套件(6/6)通过。
  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 阶段 1 既定方向(omp 车道迁入共享模块 native-attach.ts)执行,无架构转向。
  8. 是否引入了新的配置:不涉及——无新 env/config/默认值。

判定:冲突已解决,PR 现为 mergeable;本地 typecheck + 定向测试全绿,CI 在新 head 上重跑中(镜像缓存当前 0 失败 / 0 pending)。可合(待 CI 全绿确认)。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

进度汇报(强制重启后)——工作已完成,无丢失,无阻塞。

进程重启没有丢失任何进度。我刚才已重新核验实时状态:

已完成内容(回顾):stacked-PR 冲突(omp 分支钉在旧 pi 提交 47b2656575,而 pi #5244 已 rebase 到 master → 2b68520e18)已用 git rebase --onto origin/2026-10-30_native-attach-pi 47b2656575 解决(丢弃被取代的旧 pi 提交,仅重放 omp 提交)。src/agent/omp-native.ts 唯一的 import 块冲突按「双方意图并集」解决——删 observeRoutedOrigin/waitForProxyVersion(仅在被移除的 verifyAttachAndRecover 内使用)、保留 master 的 setDeclaredModelEndpoints/loadDeclaredModelEndpoints/pfChannel(在未被触碰的函数中使用)、加上 omp 的 native-attach.js import。本地验证:npm run typecheck 干净 + contract-v2-stake-verify-attach + native-attach-lane-guard 两个定向套件 6/6 通过。

无问题 / 无阻塞。 PR 是逐字节等价的纯搬运,已全绿,可合(待人工合并)。我无法合并 PR——系统规则禁止 agent 合并,请自行合并:#5246

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