Hmbown/CodeWhale · error

; additionally

Error message

{start_error:#}; additionally {rollback_error}

What it means

When a task start fails after the worker was already registered in coordination state, the manager rolls back the registration by restoring a pre-registration snapshot. If the rollback itself also fails, both errors are chained into one message: the original start error plus 'additionally <rollback error>'. This preserves the primary cause while surfacing that coordination state may now hold a stale registration.

Solutions

  1. Inspect the chained message: fix the primary start_error first, it is the root cause
  2. Reconcile the worker's coordination registration (unregister stale record) before retrying
  3. Stop and re-lease the task cleanly instead of retrying the start in place
  4. Reduce concurrency on the run so cancellation cannot race the start transition

Example fix

// before
return Err(anyhow!("{start_error:#}; additionally {rollback_error}"));
// after
return Err(anyhow!(
    "start failed and registration rollback also failed; \
     manually unregister worker before retrying: {start_error:#}; rollback: {rollback_error}"
));
Defensive patterns

Strategy: try-catch

Validate before calling

// Avoid the race upstream: check the task is still enqueued right before starting.
if manager.task_status(&run_id, &task_id) != Some(FleetTaskStatus::Enqueued) {
    return Ok(false);
}

Try / catch

// The message chains root cause first: "{start_error:#}; additionally {rollback_error}"
match result {
    Err(e) if e.to_string().contains("additionally") => {
        let (start_err, rollback_err) = split_chain(&e);
        reconcile_worker_registration(worker_id); // clean stale registration
        Err(anyhow!("start failed: {start_err}"))
    }
    other => other,
}

Prevention

When it happens

Trigger: start_task_if_enqueued fails (ledger race, cancellation won, constraint violated) after register_worker_with_coordination succeeded, and restore_coordination_registration_snapshot also errors.

Common situations: High contention between operator commands and the scheduler so the ledger claim fails mid-start; concurrent cancellation between registration and ledger transition; lock/state drift in SubAgentManager.

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/85ddd9a3d1472c0f. Report an issue: GitHub.

Appendix: source

Thrown at crates/tui/src/fleet/manager.rs:1401

                if let Some(guard) = coordination_guard.as_mut() {
                    guard
                        .register_worker_with_coordination(sub_agent_worker)
                        .map_err(anyhow::Error::msg)?;
                    registration_succeeded = true;
                }
                Ok(())
            },
        );
        let started = match start_result {
            Ok(started) => started,
            Err(start_error) => {
                if registration_succeeded
                    && let (Some(guard), Some(snapshot)) =
                        (coordination_guard.as_mut(), registration_snapshot)
                    && let Err(rollback_error) =
                        guard.restore_coordination_registration_snapshot(snapshot)
                {
                    return Err(anyhow!("{start_error:#}; additionally {rollback_error}"));
                }
                return Err(start_error);
            }
        };
        if !started {
            return Ok(false);
        }

        Ok(true)
    }

    fn start_leased_workers(
        &self,
        run_id: &FleetRunId,
        executor: &mut FleetExecutor,
        codewhale_binary: &str,
        model: Option<&str>,
    ) -> Result<usize> {

View on GitHub (pinned to 73e0f67d83)