{"record":{"id":"049f2710eb224b4f","repo":"astrid-runtime/astrid","slug":"commands-daemon-unreachable-uplink-message","errorCode":null,"errorMessage":"commands::daemon::unreachable_uplink_message()","messagePattern":"commands::daemon::unreachable_uplink_message\\(\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-cli/src/bootstrap.rs","lineNumber":205,"sourceCode":"        .await\n        .context(\"Failed to check socket\")?;\n    let action = commands::daemon::decide_ensure_action(\n        &outcome,\n        commands::daemon::recorded_daemon_pid_is_alive(),\n    );\n    let needs_boot = match action {\n        commands::daemon::EnsureAction::UseExisting => {\n            if let astrid_core::local_transport::ConnectOutcome::Connected(stream) = outcome {\n                drop(stream);\n            }\n            println!(\n                \"{}\",\n                theme::Theme::info(\"Connecting to existing Astrid daemon...\")\n            );\n            false\n        },\n        commands::daemon::EnsureAction::RefuseSecondBoot => {\n            anyhow::bail!(commands::daemon::unreachable_uplink_message());\n        },\n        commands::daemon::EnsureAction::CleanStaleAndSpawn => {\n            println!(\n                \"{}\",\n                theme::Theme::warning(\"Found dead socket. Cleaning up and restarting daemon...\")\n            );\n            astrid_core::local_transport::remove_stale_endpoint(&socket_path)\n                .context(\"failed to clean up stale daemon endpoint\")?;\n            let _ = std::fs::remove_file(&ready_path);\n            true\n        },\n        commands::daemon::EnsureAction::Spawn => true,\n    };\n\n    let mut daemon_child: Option<std::process::Child> = None;\n\n    if needs_boot {\n        match commands::daemon::spawn_daemon(&ready_path, workspace_root.as_deref()).await {","sourceCodeStart":187,"sourceCodeEnd":223,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-cli/src/bootstrap.rs#L187-L223","documentation":"run_or_connect matches on the EnsureAction returned when ensuring a daemon is up. RefuseSecondBoot is an action that the current daemon bootstrap logic is not supposed to produce on this code path; hitting it indicates the daemon command layer returned an action that run_or_connect cannot meaningfully handle. The error uses a shared helper, commands::daemon::unreachable_uplink_message(), signaling an internal invariant violation (\"this branch should be unreachable\").","triggerScenarios":"Calling run_or_connect and receiving EnsureAction::RefuseSecondBoot from the daemon ensure routine — i.e. the ensure logic decided to refuse a second boot in a context where that decision should never be made (e.g. mismatch between the ensure-mode requested and the one implemented).","commonSituations":"Version skew between the CLI and daemon components where one emits an action the other doesn't expect; a bug in daemon state classification (mis-detecting an existing boot); manually crafted ensure configurations triggering the refuse path.","solutions":["Check CLI/daemon versions match; upgrade both from the same release.","Inspect daemon socket/state files for a stale or corrupted boot record causing the refuse classification, and clean the daemon state.","Report this as a bug with the reproduction — the branch is explicitly unreachable by design.","As a workaround, restart cleanly: remove the stale socket and re-run the command."],"exampleFix":"// before: ensure() can return RefuseSecondBoot to run_or_connect\nlet action = ensure_daemon(...)?;\n\n// after (fix): keep refuse-second-boot decisions inside spawn paths only\nmatch ensure_daemon(...)? {\n    EnsureAction::ConnectExisting | EnsureAction::CleanStaleAndSpawn => { /* as today */ }\n    EnsureAction::RefuseSecondBoot => unreachable!(\"handled inside ensure_daemon\"),\n}","handlingStrategy":"try-catch","validationCode":"// ensure CLI and daemon versions match before booting\nlet cli = env!(\"CARGO_PKG_VERSION\");\nif daemon_reported_version()? != cli {\n    eprintln!(\"version skew between CLI and daemon; upgrade both\");\n}","typeGuard":"fn is_handleable(action: &EnsureAction) -> bool {\n    !matches!(action, EnsureAction::RefuseSecondBoot)\n}","tryCatchPattern":"match run_or_connect(&config).await {\n    Ok(()) => { /* ... */ }\n    Err(e) if e.to_string().contains(\"unreachable_uplink_message\") ||\n              e.to_string().contains(\"RefuseSecondBoot\") => {\n        eprintln!(\"internal daemon-state bug; clean socket state and report\");\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Always upgrade CLI and daemon together from the same release.","Clean stale daemon sockets after crashes before re-running.","Add regression tests covering every EnsureAction variant in run_or_connect.","Treat this error as a bug report trigger, not an expected failure."],"tags":["daemon","internal-invariant","unreachable","bootstrap"],"backgroundTag":"internal-invariant-violation","analyzedSha":"affd8760f44190dbdfbec23403f4c4b642c33112","analyzedAt":"2026-09-09T21:28:12.402Z","contentChangedAt":"2026-09-09T21:28:12.402Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}