{"record":{"id":"f95db5ebd7925fac","repo":"Hmbown/CodeWhale","slug":"running-tmux-lane-has-incomplete-pinned-sessi","errorCode":null,"errorMessage":"running tmux lane `{}` has incomplete pinned session metadata; refusing unsafe stop","messagePattern":"running tmux lane `(.+?)` has incomplete pinned session metadata; refusing unsafe stop","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/lane/src/runtime.rs","lineNumber":852,"sourceCode":"        &self,\n        registry: &LaneRegistry,\n        record: &mut LaneRecord,\n        fence: Option<u64>,\n    ) -> Result<TerminalTransition> {\n        let dry_run = std::env::var_os(\"CODEWHALE_LANE_TMUX_DRY_RUN\").is_some();\n        let transition = registry.mark_terminal_if_active_fenced(\n            record,\n            LaneStatus::Stopped,\n            fence,\n            |current| {\n                if !dry_run {\n                    match (\n                        current.tmux_socket.as_deref(),\n                        current.tmux_session.as_deref(),\n                    ) {\n                        (Some(socket), Some(session)) => stop_tmux_session(socket, session)?,\n                        _ if current.status == LaneStatus::Running => {\n                            bail!(\n                                \"running tmux lane `{}` has incomplete pinned session metadata; refusing unsafe stop\",\n                                current.id\n                            );\n                        }\n                        _ => {}\n                    }\n                }\n                Ok(())\n            },\n        )?;\n        if transition.transitioned() {\n            append_log_event(\n                &record.log_path,\n                serde_json::json!({\n                    \"type\": \"lane_stopped\",\n                    \"lane_id\": record.id,\n                    \"session\": record.tmux_session,\n                }),","sourceCodeStart":834,"sourceCodeEnd":870,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/lane/src/runtime.rs#L834-L870","documentation":"`stop` refuses to stop a tmux lane whose record says it is Running but whose pinned tmux metadata (tmux_socket / tmux_session) is incomplete. Without both values the runtime cannot address the session it created, and blindly proceeding would leak a live tmux session while marking the lane stopped. It therefore fails loudly rather than performing an unsafe stop.","triggerScenarios":"Calling `stop` on a lane whose record has status Running but only one (or neither) of tmux_socket/tmux_session set — e.g. a record written by an older version before socket pinning existed, a partially written record after a crash during start, or hand-edited registry state.","commonSituations":"Upgrading codewhale over lanes created by a version that did not pin tmux metadata; a start that crashed after marking Running but before persisting both pins; manual registry edits removing the fields; a non-tmux runtime's record mishandled by the tmux stop path.","solutions":["Inspect the lane record and fill in or repair the missing tmux_socket/tmux_session values to match the live session, then retry stop.","If no tmux session actually exists anymore, mark the record stopped/stale directly so stop's unsafe-stop guard no longer applies.","For records from an older schema, run the registry migration or recreate the lane (stop the orphan tmux session manually with `tmux -S <socket> kill-session -t <name>`).","Do not hand-set the record to stopped while a session may be live — find and kill the session first."],"exampleFix":"// before (record missing session pin)\n{ \"id\": \"lane-42\", \"status\": \"Running\", \"tmux_socket\": \"/tmp/lane.sock\", \"tmux_session\": null }\n\n// after: repair the pin before stopping\n{ \"id\": \"lane-42\", \"status\": \"Running\", \"tmux_socket\": \"/tmp/lane.sock\", \"tmux_session\": \"lane-42\" }","handlingStrategy":"validation","validationCode":"fn safe_to_stop(rec: &LaneRecord) -> Result<(), String> {\n    if rec.status == LaneStatus::Running\n        && (rec.tmux_socket.is_none() || rec.tmux_session.is_none())\n    {\n        return Err(format!(\"lane {} lacks pinned tmux metadata\", rec.id));\n    }\n    Ok(())\n}","typeGuard":"fn has_pinned_tmux(rec: &LaneRecord) -> bool {\n    rec.tmux_socket.is_some() && rec.tmux_session.is_some()\n}","tryCatchPattern":null,"preventionTips":["Never hand-edit registry records' tmux fields.","After upgrading versions, run registry migration before operating on old lanes.","Alert on records whose status is Running with null tmux pins."],"tags":["tmux","metadata","data-integrity"],"backgroundTag":"internal-invariant-violation","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}