Skip to content

cli: wait out a busy workspace in railgrid app sync - #1192

Merged
railgrid-prow[bot] merged 1 commit into
mainfrom
cli-app-sync-retry
Nov 18, 2026
Merged

railgrid-prow[bot] merged 1 commit into
mainfrom
cli-app-sync-retry

Conversation

@cwilhit

@cwilhit cwilhit commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator

Why

railgrid app sync makes two calls: hydrate-workspace, then sync-development. The hydrate already schedules App Studio's own background dev sync, which holds the workspace for a few seconds. The CLI's explicit sync regularly loses that race with a 409, so the command reports a failure even though dev received the tree. On railgrid-dev this happened on most runs; a retry about 15 seconds later succeeded. #1191 fixes the server side: the 409 now names the real cause and carries Retry-After: 5. This PR is the client side, and it doesn't depend on #1191.

What

The sync step retries a busy-workspace 409:

  • What counts as busy:
  • Waits:
    • follow Retry-After (3 seconds without one);
    • each wait is capped at 15 seconds;
    • all waits together stay within 60 seconds.
  • Progress goes to stderr: railgrid app: another workspace operation (usually the sync the hydrate started) is still running; retrying in 5s…
  • Not retried: "resolve or stop the active assistant run…", which means a run really is active. It still fails at once.
  • hubAPIError gains RetryAfter. It accepts both delay-seconds and an HTTP date, and is filled on REST errors from doWithHeaders.

The skill's CLI reference describes the retry.

Testing

New pkg/cli/cmd/app_sync_retry_test.go, against the fake hub, with an injected sleep:

Test Checks
TestAppSyncWaitsOutABusyWorkspace Two busy 409s with Retry-After: 5, then success: three sync calls, waits [5s 5s]
TestAppSyncWaitsOutALegacyBusyAnswer The old wording with no header: retried after 3 seconds
TestAppSyncDoesNotRetryAnActiveAssistantRun One call, no wait, and the active-run error is returned
TestAppSyncGivesUpOnAWorkspaceThatStaysBusy Retry-After: 30 is capped to 15 seconds; four waits use up the 60-second budget, then the 409 is returned
TestWithRetryAfter Seconds, HTTP date, past date, zero, negative, garbage, absent, and a non-API error
  • Negative check: with the single call restored, the three retry tests fail.
  • Gates:
    • go test ./pkg/cli/cmd/ (the whole package, including the existing app sync tests): passes.
    • golangci-lint: 0 issues.
    • make verify-boilerplate: passes.

🤖 Generated with Claude Code

`app sync` hydrates the workspace and then asks for sync-development. The
hydrate has already scheduled App Studio's own background dev sync, which
holds the workspace for a few seconds, so the explicit sync regularly lost
with a 409 and the command failed even though dev did get the tree.

The sync step now retries that conflict: a 409 carrying Retry-After (App
Studio's busy-workspace answer) or, from a hub that predates it, the old
"wait for or stop the active assistant run" wording. Each wait follows
Retry-After (3 s without one), is capped at 15 s, and the waits total at
most 60 s; progress goes to stderr. "resolve or stop the active assistant
run", a run that really is active, still fails at once.

hubAPIError now carries the Retry-After the hub sent on REST errors.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@cwilhit

cwilhit commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator Author

/approve

@railgrid-prow

railgrid-prow Bot commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cwilhit

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@railgrid-prow
railgrid-prow Bot merged commit 5aca2e3 into main Nov 18, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant