Skip to content

fix(cli): retry transient sandbox sync disconnects - #2258

Open
elezar wants to merge 1 commit into
mainfrom
codex/cli-sync-retry
Open

fix(cli): retry transient sandbox sync disconnects#2258
elezar wants to merge 1 commit into
mainfrom
codex/cli-sync-retry

Conversation

@elezar

@elezar elezar commented Jul 14, 2026

Copy link
Copy Markdown
Member

Summary

Retry sandbox upload and download operations when a gateway handoff interrupts the underlying transport. Retries rebuild the SSH session for each attempt and remain limited to typed transient failures; validation, local permission, remote command, and other permanent failures still return immediately.

Related Issue

Extracted from #1868 so the generally applicable CLI behavior can be reviewed independently.

Changes

  • Retry complete upload and download attempts up to four times after transient disconnects.
  • Preserve typed gRPC connection/status, SSH exit, and tar-stream I/O errors for classification.
  • Retry only gRPC Unavailable, connection transport errors, BrokenPipe, ConnectionReset, UnexpectedEof, and SSH exit 255.
  • Add deterministic async coverage for retry-then-success, retry exhaustion, and immediate permanent failure.

Testing

  • mise run pre-commit passes
    • Attempted, but the local task failed during environment setup: grpc_tools was unavailable while the new venv was still being populated, and workspace Clippy could not find z3.h outside the Nix environment. Format, license, Helm, and Markdown checks passed.
  • nix develop -c cargo test -p openshell-cli --lib (195 tests)
  • nix develop -c cargo clippy -p openshell-cli --all-targets -- -D warnings
  • E2E tests added/updated (not applicable; deterministic unit coverage exercises the retry policy)

Checklist

  • Follows Conventional Commits
  • Commits are signed off (DCO)

@copy-pr-bot

copy-pr-bot Bot commented Jul 14, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

Signed-off-by: Evan Lezar <elezar@nvidia.com>
@elezar
elezar force-pushed the codex/cli-sync-retry branch from 64fbab8 to 15fdeab Compare July 27, 2026 13:25
@elezar
elezar marked this pull request as ready for review July 27, 2026 14:13

@elezar elezar left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

gator-agent

PR Review Status

Validation: This is a focused maintainer-authored CLI reliability fix extracted from #1868, scoped to sandbox sync retry behavior.
Head SHA: 15fdeab3ca3969d2152b5c9bb146066a76b1f0d7

Review findings:

  • Two warning-level correctness findings remain. Both are about preserving the remote SSH exit status when local tar streaming fails early, so permanent remote failures are not retried as transient local pipe/EOF errors.

Docs: Not needed; this changes sync resilience and failure classification, not documented CLI syntax or workflow semantics.

Checks: Required status contexts are currently green; E2E is not applied.

Next state: gator:in-review

return Err(miette::miette!(
"ssh tar extract exited with status {status}"
));
return Err(Report::new(SshCommandExitError::from_status(

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

gator-agent

Warning: If the remote command fails permanently before consuming stdin, for example a mkdir -p permission failure, the local tar writer can see BrokenPipe before this status path is reached, and the new retry policy treats that as transient. Please capture the archive-write result, always wait for the SSH child, and prefer a non-255 SSH exit status over the retryable pipe error so permanent remote failures are reported once instead of retried four times.

.unpack(&extract_into)
.into_diagnostic()
.wrap_err("failed to extract tar archive from sandbox")?;
.with_sync_context("failed to extract tar archive from sandbox")?;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

gator-agent

Warning: The download path has the same failure-ordering issue: archive.unpack() can hit UnexpectedEof before the child status is collected, so a permanent remote tar failure can be retried as a transient stream EOF. Please wait for the SSH child after extraction fails and classify using the SSH status when it is available.

@elezar elezar added the gator:in-review Gator is reviewing or awaiting PR review feedback label Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gator:in-review Gator is reviewing or awaiting PR review feedback

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant