Hmbown/CodeWhale · error

running tmux lane ` ` has incomplete pinned session…

Error message

running tmux lane `{}` has incomplete pinned session metadata; refusing unsafe stop

What it means

`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.

Solutions

  1. Inspect the lane record and fill in or repair the missing tmux_socket/tmux_session values to match the live session, then retry stop.
  2. If no tmux session actually exists anymore, mark the record stopped/stale directly so stop's unsafe-stop guard no longer applies.
  3. 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>`).
  4. Do not hand-set the record to stopped while a session may be live — find and kill the session first.

Example fix

// before (record missing session pin)
{ "id": "lane-42", "status": "Running", "tmux_socket": "/tmp/lane.sock", "tmux_session": null }

// after: repair the pin before stopping
{ "id": "lane-42", "status": "Running", "tmux_socket": "/tmp/lane.sock", "tmux_session": "lane-42" }
Defensive patterns

Strategy: validation

Validate before calling

fn safe_to_stop(rec: &LaneRecord) -> Result<(), String> {
    if rec.status == LaneStatus::Running
        && (rec.tmux_socket.is_none() || rec.tmux_session.is_none())
    {
        return Err(format!("lane {} lacks pinned tmux metadata", rec.id));
    }
    Ok(())
}

Type guard

fn has_pinned_tmux(rec: &LaneRecord) -> bool {
    rec.tmux_socket.is_some() && rec.tmux_session.is_some()
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/f95db5ebd7925fac. Report an issue: GitHub.

Appendix: source

Thrown at crates/lane/src/runtime.rs:852

        &self,
        registry: &LaneRegistry,
        record: &mut LaneRecord,
        fence: Option<u64>,
    ) -> Result<TerminalTransition> {
        let dry_run = std::env::var_os("CODEWHALE_LANE_TMUX_DRY_RUN").is_some();
        let transition = registry.mark_terminal_if_active_fenced(
            record,
            LaneStatus::Stopped,
            fence,
            |current| {
                if !dry_run {
                    match (
                        current.tmux_socket.as_deref(),
                        current.tmux_session.as_deref(),
                    ) {
                        (Some(socket), Some(session)) => stop_tmux_session(socket, session)?,
                        _ if current.status == LaneStatus::Running => {
                            bail!(
                                "running tmux lane `{}` has incomplete pinned session metadata; refusing unsafe stop",
                                current.id
                            );
                        }
                        _ => {}
                    }
                }
                Ok(())
            },
        )?;
        if transition.transitioned() {
            append_log_event(
                &record.log_path,
                serde_json::json!({
                    "type": "lane_stopped",
                    "lane_id": record.id,
                    "session": record.tmux_session,
                }),

View on GitHub (pinned to 73e0f67d83)