Repository navigation
Conversation
|
自动评审最终意见(最终以维护者审阅为准): 维护者已复核,结论为修后可合,无阻断项。src 修复确认正确:npm 形态下常驻 Node launcher 再拉起原生 app-server,旧实现把 launcher 当执行引擎出证,会让 worker 把随后发布的真原生引擎误判为「旧进程仍存活却换了身份」而 fail-closed;改为 initialize 完成后从 原初审提出的唯一 P2(初始化窗口的新行为没有仓库内测试钉住)已由维护者在上一条评论给出测试补丁(仅改 test 文件,可直接 两个非阻断 P3,不影响本 PR 合入,建议后续处理:
合入前需要作者按顺序完成两件事(顺序不能反:补丁的上下文含 master 已合入的 #2523/#2526,直接在当前 head 上 apply 会有冲突):
推送新 head 后 CI 需在新 head 首跑全绿(含 bun-test),随后即可合入,不需要改 src。 |
|
复审结论:src 修复方向认可;原先的 P2(初始化窗口无测试钉守)已可用确定性用例咬红,补丁见下。 P2 复现与修法原来摘掉 确定性用例:把
变异复验(同一份测试):
红的方式是真实失败而非超时断言: 测试改动(仅 test 文件,未动 src)要点: // node-launcher 形态:launcher 延迟可配,窗口宽到足以容纳一次 re-auth
+ await new Promise(resolve => setTimeout(resolve, Number(process.env.FAKE_CODEX_LAUNCH_DELAY_MS ?? '100')));
const expectNoRootDuringReplacementInitialization = async (collector, running) => {
const before = collector.states.length;
await collector.restartEndpoint(); // 断开已接受连接 → 触发 re-auth
await waitFor(running, () => collector.states.length > before, 60_000);
const windowStates = collector.states.slice(before);
expect(windowStates.length).toBeGreaterThan(0);
expect(windowStates[0].appServerProcess).toBeUndefined(); // initialize() 窗口内不得出证
expect(windowStates.filter(s => s.appServerProcess).map(s => s.appServerProcess.pid))
.not.toContain(running.child.pid); // 尤其不得把 launcher 当引擎根
};
其余
|
|
P2 补丁(仅 diff --git a/test/codex-app-runner.integration.test.ts b/test/codex-app-runner.integration.test.ts
index a014cff6a..5b8278f83 100644
--- a/test/codex-app-runner.integration.test.ts
+++ b/test/codex-app-runner.integration.test.ts
@@ -1969,7 +1969,7 @@ describe('codex-app-runner app-server protocol integration', { timeout: 120_000,
+ `import { spawn } from 'node:child_process';\n`
// Keep the launcher alive across an idle-settle timer before the
// native server exists, including after idle engine recovery.
- + `await new Promise(resolve => setTimeout(resolve, 100));\n`
+ + `await new Promise(resolve => setTimeout(resolve, Number(process.env.FAKE_CODEX_LAUNCH_DELAY_MS ?? '100')));\n`
+ `const child = spawn(${JSON.stringify(fakeCodex)}, process.argv.slice(2), { stdio: 'inherit' });\n`
+ `for (const signal of ['SIGTERM', 'SIGINT', 'SIGHUP']) process.on(signal, () => child.kill(signal));\n`
+ `child.on('exit', code => process.exit(code ?? 1));\n`);
@@ -2041,7 +2041,11 @@ describe('codex-app-runner app-server protocol integration', { timeout: 120_000,
};
await control.listen();
harness = startRunner(codexBin, dir, logPath, '0.144.6', 'success', control.bootstrap.path,
- { env: { FAKE_CODEX_PID_PATH: pidPath, FAKE_CODEX_FINISH_GATE: finishGate } });
+ { env: { FAKE_CODEX_PID_PATH: pidPath, FAKE_CODEX_FINISH_GATE: finishGate,
+ // Wide enough that the control re-acceptance below lands inside the
+ // replacement client's initialize() window, before the launcher has
+ // spawned the native engine.
+ ...(launchMode === 'node-launcher' ? { FAKE_CODEX_LAUNCH_DELAY_MS: '1200' } : {}) } });
const enginePublications = () => published.filter((entry: any) => entry?.enginePid !== undefined);
const waitForNative = async (predicate: () => boolean) => {
await waitFor(harness!, () => rejected.length > 0 || predicate(), 60_000).catch(error => {
@@ -2053,6 +2057,33 @@ describe('codex-app-runner app-server protocol integration', { timeout: 120_000,
});
expect(rejected).toEqual([]);
};
+ // A replacement client is created and assigned to `client` before its
+ // initialize() RPC returns, and signed state can be emitted inside that
+ // window: an idle settle, or the control re-acceptance edge
+ // (`controlAcceptanceCount > 1`). Such a state must carry NO engine root.
+ // Attesting the npm launcher there freezes it as the engine root, and the
+ // real native engine's next state then reads as an unauthorized swap, so
+ // the worker runs failCodexAppControlGeneration. This drops the accepted
+ // control socket to force that re-authentication while the slow launcher
+ // has not spawned the native engine yet.
+ const expectNoRootDuringReplacementInitialization = async (
+ collector: ControlCollector, running: Harness,
+ ): Promise<void> => {
+ const before = collector.states.length;
+ await collector.restartEndpoint();
+ await waitFor(running, () => collector.states.length > before, 60_000);
+ const windowStates = collector.states.slice(before);
+ expect(windowStates.length).toBeGreaterThan(0);
+ // The first state of the window is the one emitted by the re-acceptance,
+ // while the replacement client is still inside initialize(): it must not
+ // claim any engine root at all.
+ expect(windowStates[0].appServerProcess).toBeUndefined();
+ // And the spawned child is the npm launcher, kept alive by the delay above
+ // so it is still the only process this client has. Publishing it is the
+ // defect that turns the real engine into an "unauthorized swap".
+ const rooted = windowStates.filter(state => state.appServerProcess !== undefined);
+ expect(rooted.map(state => state.appServerProcess.pid)).not.toContain(running.child.pid);
+ };
// The runner settles idle 20ms after a turn. "The last state is idle" was
// already true from the startup state, so the engine could be killed
// before that settle. When the runner then noticed the exit first, its
@@ -2071,6 +2102,7 @@ describe('codex-app-runner app-server protocol integration', { timeout: 120_000,
expect(control.states.at(-1)?.appServerProcess).toEqual({
pid: enginePublications()[0].enginePid, procStart: enginePublications()[0].engineProcStart,
});
+ let probeInitWindow = false;
for (const [index, turnId] of ['om_native_before', 'om_native_after', 'om_native_next'].entries()) {
if (index === 1) {
const pid = Number(readFileSync(pidPath, 'utf8'));
@@ -2079,12 +2111,17 @@ describe('codex-app-runner app-server protocol integration', { timeout: 120_000,
try { process.kill(pid, 0); return false; }
catch (error) { if ((error as NodeJS.ErrnoException).code === 'ESRCH') return true; throw error; }
});
+ probeInitWindow = launchMode === 'node-launcher';
}
// Production reserves a local liveness slot BEFORE the runner discovers
// the dead engine. This must not be confused with native execution.
tracker.begin(turnId);
authority.beginWork();
harness.child.stdin.write(`${CONTROL_PREFIX}${encodeRunnerInput(turnId, { text: turnId }, turnId)}\r`);
+ if (probeInitWindow) {
+ probeInitWindow = false;
+ await expectNoRootDuringReplacementInitialization(control, harness!);
+ }
await waitForNative(() => control.finals.length === index + 1);
tracker.completeCurrent();
await waitForNative(idleAfterLastFinal);
@@ -2107,7 +2144,7 @@ describe('codex-app-runner app-server protocol integration', { timeout: 120_000,
&& marker.kind === 'activity' && marker.payload.phase === 'submitted');
expect(boundaryIndex).toBeGreaterThan(-1);
expect(submittedAfter).toBeGreaterThan(boundaryIndex);
- expect(control.authCount).toBe(1);
+ expect(control.authCount).toBe(launchMode === 'node-launcher' ? 2 : 1);
expect(control.finals.map(final => final.turnId)).toEqual(['om_native_before', 'om_native_after', 'om_native_next']);
// Replace the observing worker during native work. The signed state must
// bind the exact persisted reply turn, rather than guessing from busy.
@@ -2131,7 +2168,7 @@ describe('codex-app-runner app-server protocol integration', { timeout: 120_000,
writeFileSync(finishGate, 'ready');
await waitForNative(() => control.finals.length === 4);
tracker.completeCurrent();
- expect(control.authCount).toBe(2);
+ expect(control.authCount).toBe(launchMode === 'node-launcher' ? 3 : 2);
expect(rejected).toEqual([]);
expect(readRequests(logPath).filter(request => request.method === 'thread/start')).toHaveLength(1);
expect(readRequests(logPath).filter(request => request.method === 'thread/resume')).toHaveLength(1); |
复验记录(本地候选树,等新 head 后重申)候选树: 一个应用顺序的提醒(重要)P2 补丁是基于 rebase 后的树生成的(其上下文含 #2523/#2526 合入 master 的
所以作者的动作顺序必须是:先 rebase 到最新 master,再 关于两条 bun 用例失败(修正我先前的归因)我先前写成「共享机 CPU 争抢的偶发」,更准确的原因已定位:裸
master 与本候选树表现完全一致 ⟹ 与本 PR 无关,是调用方式差异,不是产物问题,也不是随机抖动。 本轮验证结果(候选树)
关于 G1当前远端 head 仍是 作者 push 出新 head 后,请把新 OID 贴到本群,我会在新 head 上核对 |
最终重申(head
|
|
@uestcwangci @deepcoldy 合入 master 后的 Midscene E2E 失败:Dashboard Midscene 失败;Feishu live Midscene 失败。 这次运行覆盖 fda858c。 |
|
已合入 master(squash 为 fda858c),感谢贡献! 评审中确认的两个非阻断项记录在此,供后续跟进(不影响本次合入):
欢迎继续提交。 |
|
这个版本什么时候发布?我也遇到了。本来提了PR,重复了。 |
|
🚀 Released in v3.57.0 |
npm 形态的 Codex 由常驻 Node launcher 拉起原生引擎。旧 runner 把 launcher 当作 app-server 根,后续发布真正引擎时会被误判为换身份,出现 current_execution_unverified。
等待 initialize 与进程捕获完成后才发布身份,从唯一核验的 processIdentity 选择 enginePid,并重读出生令牌。初始化中的替换客户端不发布 launcher。初始化窗口测试使用可配置延迟,在替换 launcher 实际启动后断开控制端点强制 re-auth,检查首条签名状态无 appServerProcess,窗口内无真实 launcher PID;保留最新主干空闲恢复与 worker 重连用例。
已普通 merge 最新 master 58ea44e,保留分支历史,无 rebase/force-push。当前 head ccd0a79。只涉及 Linux Codex App 引擎出证与相应集成测试,其他 CLI/后端授权范围不变,无环境专用策略。
验证:
bun run build通过(含类型、Dashboard、dist 与嵌入资产审计)。未自动合并、打tag或正式发布。capture 失败时 getter 回退 child.pid 的既有 P3 边界保留后续处理。后台专属登记见 #2519。