In error-prone paths, do not “pretend success.” Always make the failure mode explicit to callers, and ensure any returned/serialized status reflects what actually happened.
Practical standards:
Example (pattern to fix):
bool/Result and have the CLI fail when the target is still reachable after the timeout.fn stop_session(name: Option<&str>) -> Result<SessionInfo, String> {
let socket_path = api_socket_path_for(name);
// ... send stop request ...
// Must return whether the socket is actually stopped.
let stopped = wait_until_stopped(&socket_path, STOP_WAIT_TIMEOUT)
.map_err(|e| e.to_string())?;
if !stopped {
return Err(format!(
"session {} did not stop within {:?} (still reachable at {})",
name.unwrap_or(DEFAULT_SESSION_NAME),
STOP_WAIT_TIMEOUT,
socket_path.display()
));
}
Ok(session_info(name))
}
This standard prevents misleading “stopped”: true responses, avoids silent contract violations, and makes failures actionable for both users and automated tooling.