{"record":{"id":"e1248d36de5bd3de","repo":"Yeachan-Heo/oh-my-codex","slug":"detached-leader-pid-missing-before-release","errorCode":null,"errorMessage":"detached leader PID missing before release","messagePattern":"detached leader PID missing before release","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"src/cli/index.ts","lineNumber":6699,"sourceCode":"            return \"committed-released\";\n          },\n          updatePaneMetadata: async (_binding, pane) => {\n            const state = await readSessionState(cwd, detachedSelectedStateEnv);\n            if (state?.session_id !== sessionId || state.tmux_pane_id !== pane) {\n              throw new Error(\"detached pane metadata was not committed by the leader\");\n            }\n            return \"committed-released\";\n          },\n          publishActiveRecord: async () => {\n            const activeRecordPath = contextKey ? madmaxDetachedActiveRecordPath(runsRoot, contextKey) : join(omxRoot(cwd), \"state\", \"detached-active-record.json\");\n            const record = readMadmaxDetachedActiveRecord(activeRecordPath);\n            if (!record || record.launch_nonce !== detachedLaunchNonce || record.leader_pid !== detachedLeaderPid || record.session_id !== sessionId || record.tmux_session_name !== sessionName || record.tmux_pane_id !== detachedLeaderPaneId) throw new Error(\"detached active record does not bind the ready leader\");\n            const bytes = readFileSync(activeRecordPath, \"utf-8\");\n            return { bytes, digest: createHash(\"sha256\").update(bytes).digest(\"hex\"), nonce: detachedLaunchNonce };\n          },\n          finalizeSetupFailure: async () => {},\n          releaseBarrier: async () => {\n            if (!detachedLeaderPid) throw new Error(\"detached leader PID missing before release\");\n            publishDetachedReleaseMarker(releaseMarkerPath, detachedLaunchNonce, sessionId, sessionName, detachedLeaderPid, detachedHudAuthority ?? undefined);\n          },\n          abortAndAwaitFinalization: async () => {\n            // The leader has the retained binding. Publishing abort is the only\n            // outer action permitted after a D9 write failure; a mismatched or\n            // missing report leaves every artifact and the tmux session intact.\n            if (!detachedLeaderPid) {\n              rollbackFromPreReportAuthority = detachedLeaderAuthority !== null;\n              return { acknowledged: false, rollbackAuthorized: rollbackFromPreReportAuthority };\n            }\n            const current = readDetachedLeaderReport(releaseMarkerPath);\n            if (current?.nonce === detachedLaunchNonce && current.sessionId === sessionId &&\n              current.sessionName === sessionName && current.leaderPid === detachedLeaderPid &&\n              current.finalized === true && (current.kind === \"failed\" || current.kind === \"terminal\")) return {\n                acknowledged: true,\n                nonce: current.nonce,\n                sessionId: current.sessionId,\n                sessionName: current.sessionName,","sourceCodeStart":6681,"sourceCodeEnd":6717,"githubUrl":"https://github.com/Yeachan-Heo/oh-my-codex/blob/3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2/src/cli/index.ts#L6681-L6717","documentation":"The releaseBarrier phase must publish a release marker naming the leader PID; if detachedLeaderPid was never captured (undefined/null) the barrier refuses to run. Publishing a release marker without a real leader PID would unblock the leader with an unverifiable identity, so it is a hard invariant.","triggerScenarios":"Reaching releaseBarrier before any step recorded detachedLeaderPid — normally a downstream consequence of earlier bootstrap failures (new-session produced no pane id, or the leader report binding steps failed) rather than an independent user error.","commonSituations":"Seen stacked on top of errors 187/190/192 when the bootstrap already degraded; forked code paths skipping the leader-PID capture; extreme edge cases where the leader exits before PID capture.","solutions":["Fix the upstream bootstrap failure (see errors 187, 190, 192): clean tmux config, clean stale state, modern tmux","Full reset: kill orphaned detached tmux sessions, delete release markers and detached state, then relaunch","If forking, ensure detachedLeaderPid is captured before the establishment callbacks run"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if (!detachedLeaderPid) throw new Error(\"cannot release: leader PID never captured; cleaning up manually\");","typeGuard":"function hasLeaderPid(v: unknown): v is number { return typeof v === \"number\" && v > 0; }","tryCatchPattern":"try { establish(); } catch (e) { if (/leader PID missing before release/.test(e.message)) { await manualCleanup(); /* session unusable */ } }","preventionTips":["Fix upstream bootstrap failures (pane id parse, marker binding) that skip PID capture","Full-reset state after this error before relaunching","Never fabricate a PID to force release — clean state instead"],"tags":["detached-launch","invariant","release-barrier"],"backgroundTag":"state-machine-invariant-violated","analyzedSha":"3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2","analyzedAt":"2026-08-27T22:18:39.783Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}