Hmbown/CodeWhale · error

lane exit receipt belongs to , expected

Error message

lane exit receipt {} belongs to {}, expected {}

What it means

read_lane_exit_receipt verifies that the parsed receipt's lane_id matches the lane being reconciled. A mismatch means the receipt file belongs to a different lane — a stale, reused, or mispointed path — and the library refuses to attribute the exit code to the wrong lane.

Solutions

  1. Remove the stale receipt file and rerun reconcile so state is re-derived from live sources.
  2. Ensure the same lane_id string is used to compute the receipt path as was used to write it.
  3. Clean up runtime directories when a lane id is retired or reused.
  4. Check for concurrent lifecycle operations on lanes sharing the same root directory.

Example fix

// before
let receipt = read_lane_exit_receipt(&path, &old_lane_id)?;
// after
let receipt = read_lane_exit_receipt(&path, &record.id)?;
Defensive patterns

Strategy: try-catch

Validate before calling

// read the receipt yourself and compare ids before trusting it
let r: LaneExitReceipt = serde_json::from_slice(&std::fs::read(&path)?)?;
if r.lane_id != lane_id { /* stale receipt: remove and re-derive */ }

Try / catch

if e.to_string().contains("belongs to") { fs::remove_file(&receipt_path).ok(); reconcile()?; } // stale receipt from a recycled lane id

Prevention

When it happens

Trigger: Calling reconcile() (or running the log-proxy ownership path) with a lane_id that does not match the lane_id recorded inside the receipt file at the expected path — e.g. a recycled runtime directory or a path computed for a different lane id.

Common situations: Lane id reuse across restarts where an old receipt was not cleaned; computing the receipt path from a different/normalized lane id than the writer used; concurrent lanes sharing a directory.

Understand the failure class

Background: Checksum mismatch errors: "checksum verification failed", "digest mismatch", "expected vs actual checksum" — what they mean and how to fix them — this error's family across 41 libraries.

Related errors


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

Appendix: source

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

fn read_lane_exit_receipt(log_path: &Path, lane_id: &str) -> Result<Option<LaneExitReceipt>> {
    let path = lane_exit_receipt_path(log_path);
    let metadata = match std::fs::metadata(&path) {
        Ok(metadata) => metadata,
        Err(err) if err.kind() == std::io::ErrorKind::NotFound => return Ok(None),
        Err(err) => return Err(err).with_context(|| format!("stat {}", path.display())),
    };
    if metadata.len() > MAX_EXIT_RECEIPT_BYTES {
        bail!(
            "lane exit receipt {} exceeds {} bytes",
            path.display(),
            MAX_EXIT_RECEIPT_BYTES
        );
    }
    let bytes = std::fs::read(&path).with_context(|| format!("read {}", path.display()))?;
    let receipt: LaneExitReceipt =
        serde_json::from_slice(&bytes).with_context(|| format!("parse {}", path.display()))?;
    if receipt.lane_id != lane_id {
        bail!(
            "lane exit receipt {} belongs to {}, expected {}",
            path.display(),
            receipt.lane_id,
            lane_id
        );
    }
    Ok(Some(receipt))
}

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
enum TmuxSessionState {
    Present,
    Absent,
}

fn tmux_command(socket: &Path) -> Command {
    let mut command = Command::new("tmux");
    command.arg("-S").arg(socket);

View on GitHub (pinned to 73e0f67d83)