{"record":{"id":"ddeca9ee332c9961","repo":"Hmbown/CodeWhale","slug":"lane-exit-receipt-belongs-to-expected","errorCode":null,"errorMessage":"lane exit receipt {} belongs to {}, expected {}","messagePattern":"lane exit receipt (.+?) belongs to (.+?), expected (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/lane/src/runtime.rs","lineNumber":534,"sourceCode":"fn read_lane_exit_receipt(log_path: &Path, lane_id: &str) -> Result<Option<LaneExitReceipt>> {\n    let path = lane_exit_receipt_path(log_path);\n    let metadata = match std::fs::metadata(&path) {\n        Ok(metadata) => metadata,\n        Err(err) if err.kind() == std::io::ErrorKind::NotFound => return Ok(None),\n        Err(err) => return Err(err).with_context(|| format!(\"stat {}\", path.display())),\n    };\n    if metadata.len() > MAX_EXIT_RECEIPT_BYTES {\n        bail!(\n            \"lane exit receipt {} exceeds {} bytes\",\n            path.display(),\n            MAX_EXIT_RECEIPT_BYTES\n        );\n    }\n    let bytes = std::fs::read(&path).with_context(|| format!(\"read {}\", path.display()))?;\n    let receipt: LaneExitReceipt =\n        serde_json::from_slice(&bytes).with_context(|| format!(\"parse {}\", path.display()))?;\n    if receipt.lane_id != lane_id {\n        bail!(\n            \"lane exit receipt {} belongs to {}, expected {}\",\n            path.display(),\n            receipt.lane_id,\n            lane_id\n        );\n    }\n    Ok(Some(receipt))\n}\n\n#[derive(Debug, Clone, Copy, PartialEq, Eq)]\nenum TmuxSessionState {\n    Present,\n    Absent,\n}\n\nfn tmux_command(socket: &Path) -> Command {\n    let mut command = Command::new(\"tmux\");\n    command.arg(\"-S\").arg(socket);","sourceCodeStart":516,"sourceCodeEnd":552,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/lane/src/runtime.rs#L516-L552","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Remove the stale receipt file and rerun reconcile so state is re-derived from live sources.","Ensure the same lane_id string is used to compute the receipt path as was used to write it.","Clean up runtime directories when a lane id is retired or reused.","Check for concurrent lifecycle operations on lanes sharing the same root directory."],"exampleFix":"// before\nlet receipt = read_lane_exit_receipt(&path, &old_lane_id)?;\n// after\nlet receipt = read_lane_exit_receipt(&path, &record.id)?;","handlingStrategy":"try-catch","validationCode":"// read the receipt yourself and compare ids before trusting it\nlet r: LaneExitReceipt = serde_json::from_slice(&std::fs::read(&path)?)?;\nif r.lane_id != lane_id { /* stale receipt: remove and re-derive */ }","typeGuard":null,"tryCatchPattern":"if e.to_string().contains(\"belongs to\") { fs::remove_file(&receipt_path).ok(); reconcile()?; } // stale receipt from a recycled lane id","preventionTips":["Always derive the receipt path and lane_id from the same record.","Remove receipt files when a lane is retired or its id reused.","Avoid sharing one runtime directory across multiple lane ids."],"tags":["exit-receipt","identity-mismatch","stale-state"],"backgroundTag":"checksum-mismatch","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"}