Skip to content

fix(cli): wait for hosted setup handoff - #542

Closed
alongubkin wants to merge 1 commit into
mainfrom
alon/alien-618-wait-for-hosted-setup-handoff
Closed

alongubkin wants to merge 1 commit into
mainfrom
alon/alien-618-wait-for-hosted-setup-handoff

Conversation

@alongubkin

Copy link
Copy Markdown
Member

Summary

  • wait for hosted release authority after setup reconciliation hands execution back to Platform
  • preserve immediate corrective compute updates when failed deployments already retain release authority
  • fail clearly on terminal lifecycle states or a bounded handoff timeout

Test

  • cargo test -p alien-deploy-cli commands::up::tests -- --nocapture

@alongubkin

Copy link
Copy Markdown
Member Author

Closing pending a first-principles correction: live staging shows the post-setup handoff can remain in provisioning with neither desired nor current release, so polling would only turn the API error into a timeout. The fix must preserve/restore release authority across setup reconciliation.

@alongubkin alongubkin closed this Aug 30, 2026
@greptile-apps

greptile-apps Bot commented Aug 30, 2026

Copy link
Copy Markdown

Greptile Summary

This PR adds bounded polling after hosted setup reconciliation so compute updates wait for release authority, while preserving immediate retries where authority already exists.

  • Polls deployment state for up to five minutes during the hosted setup handoff.
  • Stops on failed or deletion states and reports explicit handoff errors.
  • Adds helpers and tests for release-authority and terminal-state classification.

Confidence Score: 4/5

The PR should be fixed before merging because a failed handoff response that already contains release authority can be rejected before the corrective compute update runs.

The polling loop prioritizes the failed-status return over the release-authority success condition, allowing a valid corrective-update state to terminate as an error and leave hosted compute unapplied.

Files Needing Attention: crates/alien-deploy-cli/src/commands/up.rs

Important Files Changed

Filename Overview
crates/alien-deploy-cli/src/commands/up.rs Adds hosted handoff polling and lifecycle helpers, but failure status is evaluated before newly established release authority, which can suppress the corrective compute retry.

Sequence Diagram

sequenceDiagram
    participant CLI
    participant Manager
    participant Platform
    CLI->>Manager: Final setup reconciliation
    Manager-->>CLI: Deployment without release authority
    loop Up to 150 attempts
        CLI->>Manager: Refresh deployment
        Manager-->>CLI: Status and release IDs
        alt Release authority established
            CLI->>Platform: Submit corrective compute update
        else Terminal lifecycle state
            CLI-->>CLI: Return handoff error
        else Still handing off
            CLI-->>CLI: Wait two seconds
        end
    end
Loading

Fix all with Greploop Fix All in Codex

Prompt To Fix All With AI
### Issue 1
crates/alien-deploy-cli/src/commands/up.rs:1554-1567
**Authority Check Follows Failure**

When a handoff poll returns a failed deployment with a newly populated release ID, the loop returns before checking that authority, preventing the corrective compute update and potentially leaving hosted capacity stale.

```suggestion
                if deployment_has_release_authority(
                    current_deployment.desired_release_id.as_deref(),
                    current_deployment.current_release_id.as_deref(),
                ) {
                    break;
                }
                if deployment_handoff_failed(&current_deployment.status) {
                    return Err(AlienError::new(ErrorData::ConfigurationError {
                        message: format!(
                            "Setup reconciliation handed off, but the hosted deployment entered '{}' before release authority was established",
                            current_deployment.status
                        ),
                    }));
                }
```

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Reviews (1): Last reviewed commit: "fix(cli): wait for hosted setup handoff" | Re-trigger Greptile

Comment on lines +1554 to +1567
if deployment_handoff_failed(&current_deployment.status) {
return Err(AlienError::new(ErrorData::ConfigurationError {
message: format!(
"Setup reconciliation handed off, but the hosted deployment entered '{}' before release authority was established",
current_deployment.status
),
}));
}
if deployment_has_release_authority(
current_deployment.desired_release_id.as_deref(),
current_deployment.current_release_id.as_deref(),
) {
break;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Authority Check Follows Failure

When a handoff poll returns a failed deployment with a newly populated release ID, the loop returns before checking that authority, preventing the corrective compute update and potentially leaving hosted capacity stale.

Suggested change
if deployment_handoff_failed(&current_deployment.status) {
return Err(AlienError::new(ErrorData::ConfigurationError {
message: format!(
"Setup reconciliation handed off, but the hosted deployment entered '{}' before release authority was established",
current_deployment.status
),
}));
}
if deployment_has_release_authority(
current_deployment.desired_release_id.as_deref(),
current_deployment.current_release_id.as_deref(),
) {
break;
}
if deployment_has_release_authority(
current_deployment.desired_release_id.as_deref(),
current_deployment.current_release_id.as_deref(),
) {
break;
}
if deployment_handoff_failed(&current_deployment.status) {
return Err(AlienError::new(ErrorData::ConfigurationError {
message: format!(
"Setup reconciliation handed off, but the hosted deployment entered '{}' before release authority was established",
current_deployment.status
),
}));
}

Knowledge Base Used: Retry hosted compute updates after failed apply

Prompt To Fix With AI
This is a comment left during a code review.
Path: crates/alien-deploy-cli/src/commands/up.rs
Line: 1554-1567

Comment:
**Authority Check Follows Failure**

When a handoff poll returns a failed deployment with a newly populated release ID, the loop returns before checking that authority, preventing the corrective compute update and potentially leaving hosted capacity stale.

```suggestion
                if deployment_has_release_authority(
                    current_deployment.desired_release_id.as_deref(),
                    current_deployment.current_release_id.as_deref(),
                ) {
                    break;
                }
                if deployment_handoff_failed(&current_deployment.status) {
                    return Err(AlienError::new(ErrorData::ConfigurationError {
                        message: format!(
                            "Setup reconciliation handed off, but the hosted deployment entered '{}' before release authority was established",
                            current_deployment.status
                        ),
                    }));
                }
```

**Knowledge Base Used:** [Retry hosted compute updates after failed apply](https://app.greptile.com/alien/-/custom-context/knowledge-base/alienplatform/alien/-/reverts/incident-mitigation_531-20260830-hosted-compute-retry-edf7b32.md)

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Fix in Codex

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant