feat(code reviewer) better workspace capacity handling - #4775
Merged
Conversation
jeanduplessis
approved these changes
Jul 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When a code review starts on a sandbox whose disk is full, the workspace admission check rejects it. That rejection was reaching the pending message queue as an unclassified error, so it got a single retry about two seconds later and then failed, and it was recorded with no distinct terminal reason. This classifies the rejection as a
workspace_setup_failed/sandbox_storage_fullfailure, gives it a longer backoff budget, and reports it under its own category.The admission check and stale workspace cleanup logic are unchanged. This only changes what happens after a rejection.
Changes
orchestrator.ts: translateWorkspaceCapacityAdmissionRejectedErrorinto a retryableExecutionError.workspaceSetupFailedwith subtypesandbox_storage_full, so it flows through the existing subtype classification instead of being wrapped as a generic wrapper start failure.pending-messages.ts: addWORKSPACE_CAPACITY_RETRY_DELAYS_MSof 10s, 30s, 60s for capacity failures, replacing the single 2s retry they previously got. Each retry re-enters sandbox setup, which runs another stale workspace cleanup pass.pending-messages.ts: extractisResetEligibleFailureand reset the flush attempt counter only when a message enters a reset-eligible mode from one that is not. Without this, failures alternating between sandbox connect and sandbox capacity would reset the counter each time and retry indefinitely.workspace_capacitytoCODE_REVIEW_TERMINAL_REASONS(packages/db),CloudAgentTerminalReason(packages/worker-utils), andInternalStatusTerminalReasonSchema(services/code-review-infra), with a comment on the last noting that a value missing there is silently coerced toundefinedby.catch(undefined).code-review-status/[reviewId]/route.ts: addisWorkspaceCapacityFailure, which prefers the structured failure code and subtype and falls back to matching the safe error message for payloads from workers that predate this change.admin-code-reviews-router.ts: addSandbox CapacityandSandbox Connectioncategories to both the review and attempt error category expressions, plusDelivery Failureand an additionalAction Requiredclause. These previously fell intoOtherorUnknown Error.Verification
Visual Changes
No component changes. The admin code reviews dashboard will show the new error categories in place of
Other/Unknown Errorfor these failures.Reviewer Notes
terminalization-pendingand terminalizes withworkspace_capacity.services/code-review-infra/src/index.tscreates a Durable Object per review and callsstart()immediately, so a burst of reviews against one sandbox still arrives at once. This makes that failure recoverable in some cases and legible in reporting, but does not prevent it.isWorkspaceCapacityFailureand theLIKEclauses in the admin router overlap on purpose, to cover reviews recorded before the structured subtype was available.