{"record":{"id":"d1b4fccc26129c56","repo":"Yeachan-Heo/oh-my-codex","slug":"detached-leader-authority-missing-before-tmux-muta","errorCode":null,"errorMessage":"detached leader authority missing before tmux mutation","messagePattern":"detached leader authority missing before tmux mutation","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"src/cli/index.ts","lineNumber":6594,"sourceCode":"            enableNotifyFallbackAuthority: preLaunchOptions.enableNotifyFallbackAuthority,\n            worktreeDirty: preLaunchOptions.worktreeDirty,\n            shouldAttach: detachedPreflight.shouldAttach,\n          },\n          detachedControlPlane,\n        );\n        for (const step of bootstrapSteps) {\n          try {\n            if (step.name === \"new-session\") {\n              const output = execTmuxFileSync(step.args, { stdio: \"pipe\", encoding: \"utf-8\" });\n              createdSession = true;\n              const leaderPaneId = parsePaneIdFromTmuxOutput(output || \"\");\n              if (!leaderPaneId) throw new Error(\"detached session did not report a leader pane id\");\n              detachedLeaderPaneId = leaderPaneId;\n              detachedLeaderAuthority = captureDetachedLeaderAuthority(leaderPaneId, sessionName, sessionId);\n              continue;\n            }\n            const authority = detachedLeaderAuthority;\n            if (!authority) throw new Error(\"detached leader authority missing before tmux mutation\");\n            if (step.name === \"tag-session\") {\n              runDetachedLeaderMutation(authority, step.args, false);\n              // tmux can acknowledge the session tag before the first owner-format\n              // evaluation sees it. Retrying this idempotent first owner-guarded\n              // mutation once gives the server a command boundary without relaxing\n              // any part of the captured session, window, pane, PID, or owner fence.\n              runDetachedLeaderMutation(authority, [\"set-option\", \"-q\", \"-t\", authority.sessionName, \"history-limit\", String(DETACHED_TMUX_HISTORY_LIMIT)], true, true);\n              runDetachedLeaderMutation(authority, [\"set-option\", \"-pq\", \"-t\", authority.paneId, \"history-limit\", String(DETACHED_TMUX_HISTORY_LIMIT)]);\n              // #3266: the owned leader pane must close with its process so a normal\n              // child exit destroys the session naturally even when the user's tmux\n              // config inherits remain-on-exit=on/failed.\n              runDetachedLeaderMutation(authority, [\"set-option\", \"-pq\", \"-t\", authority.paneId, \"remain-on-exit\", \"off\"]);\n              continue;\n            }\n            if (step.name !== \"split-and-capture-hud-pane\") {\n              throw new Error(`unexpected detached bootstrap mutation: ${step.name}`);\n            }\n            detachedHudAuthority = runDetachedLeaderSplit(authority, step.args);","sourceCodeStart":6576,"sourceCodeEnd":6612,"githubUrl":"https://github.com/Yeachan-Heo/oh-my-codex/blob/3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2/src/cli/index.ts#L6576-L6612","documentation":"Inside the detached bootstrap step loop, a non-new-session step was reached before a leader authority had been captured. All owner-guarded tmux mutations require the captured authority (pane id, session name, PIDs) from the new-session step; reaching a mutation step without it means the state machine invariant broke.","triggerScenarios":"Practically reached when the new-session step failed to produce a leader pane id (see error 187) but the loop continued, or when the step list was constructed/reordered so a mutation step precedes new-session. It is a defensive invariant check for the detached bootstrap state machine.","commonSituations":"Almost never seen in normal use; appears in modified/forked code that reorders bootstrap steps, or as a downstream symptom when new-session output parsing failed but execution fell through.","solutions":["Treat this as a follow-on of error 187: fix why new-session did not yield a leader pane id (clean tmux config, modern tmux)","If you forked/modified the bootstrap steps, ensure new-session runs first and short-circuits on failure","Capture the full bootstrap log and tmux new-session output to see which step was reached without authority","Report upstream — this invariant firing indicates either corrupted step order or swallowed earlier errors"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const steps = buildDetachedBootstrapSteps();\nif (steps[0]?.name !== \"new-session\") throw new Error(\"step order corrupted\");","typeGuard":null,"tryCatchPattern":"try { runBootstrap(steps); } catch (e) { if (/leader authority missing/.test(e.message)) { /* inspect earlier step failures first */ } throw e; }","preventionTips":["Never reorder bootstrap steps in forks; new-session must come first","Fail fast when new-session yields no pane id instead of continuing","Rebuild all artifacts together after pulling changes"],"tags":["tmux","bootstrap","invariant","state-machine"],"backgroundTag":"state-machine-invariant-violated","analyzedSha":"3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2","analyzedAt":"2026-08-27T22:18:39.783Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}