{"record":{"id":"292be6b3baae841a","repo":"Yeachan-Heo/oh-my-codex","slug":"tmux-source-authority-transaction-failed-result","errorCode":null,"errorMessage":"tmux source authority transaction failed: ${result.stderr}","messagePattern":"tmux source authority transaction failed: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/team/tmux-session.ts","lineNumber":373,"sourceCode":"  const firstFormatIndex = effect.indexOf(SPLIT_WINDOW_PANE_FORMAT);\n  if (firstFormatIndex < 0 || effect.indexOf(SPLIT_WINDOW_PANE_FORMAT, firstFormatIndex + SPLIT_WINDOW_PANE_FORMAT.length) >= 0) {\n    throw new Error('tmux_split_window_format_contract_invalid');\n  }\n  return `${effect.slice(0, firstFormatIndex)}-F '#{pane_id}:${receipt}'${effect.slice(firstFormatIndex + SPLIT_WINDOW_PANE_FORMAT.length)}`;\n}\n\nfunction bindSplitReceiptToPaneCommand(command: string, receipt: string): string {\n  return `${command} # ${receipt}`;\n}\n\n/** Queue an effect in the source pane's tmux server only when its exact pane/session/window incarnation still matches. */\nexport function runSourceAuthorizedTmux(source: SourcePaneAuthority, effect: string, receipt: string = sourceTransactionReceipt()): string {\n  const result = runTmux([\n    'if-shell', '-F', '-t', source.paneId, sourceAuthorityPredicate(source),\n    `${effect} ; display-message -p ${shellQuoteSingle(receipt)}`,\n    \"display-message -p ''\",\n  ]);\n  if (!result.ok) throw new Error(`tmux source authority transaction failed: ${result.stderr}`);\n  if (result.stdout !== receipt) throw new Error('tmux source authority changed before effect');\n  return receipt;\n}\n\nexport function runSourceAuthorizedSplit(\n  source: SourcePaneAuthority,\n  buildEffect: (receipt: string) => string,\n): string {\n  // Reconcile against the immutable window ID, not the mutable session:index\n  // target: a concurrent renumber between the guarded split and the after-read\n  // must never turn an unrelated window's pane into kill authority.\n  const windowTarget = source.windowId;\n  const beforeTopology = listPanesResult(windowTarget);\n  if (beforeTopology.error) {\n    throw new Error(`failed to read tmux pane topology before split: ${beforeTopology.error}`);\n  }\n  const beforePaneIds = new Set(beforeTopology.panes.map((pane) => pane.paneId));\n  const receipt = sourceTransactionReceipt();","sourceCodeStart":355,"sourceCodeEnd":391,"githubUrl":"https://github.com/Yeachan-Heo/oh-my-codex/blob/3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2/src/team/tmux-session.ts#L355-L391","documentation":"runSourceAuthorizedTmux wraps a tmux effect in `if-shell -F` against the source pane's authority predicate; the wrapper tmux invocation itself failed (non-zero). This is a transport/execution failure of the transaction, not an authority failure — that is reported separately as 'changed before effect'.","triggerScenarios":"Calling runSourceAuthorizedTmux/runSourceAuthorizedSplit when the tmux server dies mid-command, the target pane disappears before if-shell resolves, or quoting of the effect string breaks the tmux command line.","commonSituations":"tmux server restart or socket loss during a split/kill effect; malformed effect built by a custom buildEffect callback (unbalanced quotes); pane closed concurrently.","solutions":["Inspect embedded stderr: 'lost server' → re-establish tmux; 'no such pane' → re-capture authority","Retry the whole capture+effect sequence from a fresh captureSourcePaneAuthority","Sanitize any custom effect strings for shell/tmux quoting (shellQuoteSingle)"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"catch (e) { if (/source authority transaction failed/.test(e.message)) { if (/lost server|no such pane/.test(e.message)) recapture(); else retryOnce(); return; } throw e; }","preventionTips":["Quote effect strings with shellQuoteSingle","Re-capture authority before each retry; never blind-retry the effect"],"tags":["tmux","transaction","quoting"],"backgroundTag":"tmux-command-failed","analyzedSha":"3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2","analyzedAt":"2026-08-27T22:18:39.783Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}