Skip to content

feat: support Vercel sandbox resources#723

Merged
ColeMurray merged 2 commits into
mainfrom
feat/vercel-sandbox-resources
Jun 10, 2026
Merged

feat: support Vercel sandbox resources#723
ColeMurray merged 2 commits into
mainfrom
feat/vercel-sandbox-resources

Conversation

@ColeMurray

@ColeMurray ColeMurray commented Jun 10, 2026

Copy link
Copy Markdown
Owner

Summary

  • Map sandbox cpuCores and memoryMib settings to Vercel resources.vcpus on create and restore.
  • Serialize Vercel resources through the REST client and cover the provider/client behavior with tests.
  • Update shared setting docs and Vercel provider docs to describe provider-specific resource mapping.

Testing

  • npm test -w @open-inspect/control-plane -- src/sandbox/providers/vercel/provider.test.ts src/sandbox/providers/vercel/client.test.ts
  • npm run build -w @open-inspect/shared
  • npm run typecheck -w @open-inspect/control-plane

Created with Open-Inspect

Summary by CodeRabbit

  • New Features

    • Sandbox creation and restore now send CPU/memory resource requests to Vercel; requests are mapped to supported vCPU sizes and rounded up as needed.
    • Requests that exceed provider limits are rejected.
  • Tests

    • Added unit tests covering CPU/memory→vCPU conversion, omission when unset/null, restore behavior, and limit rejection.
  • Documentation

    • Updated docs clarifying CPU/memory semantics, mapping, rounding, and default behavior.

@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e987b61b-506f-4d2c-bfa3-d696ebfaf185

📥 Commits

Reviewing files that changed from the base of the PR and between fca6eb6 and fe11425.

📒 Files selected for processing (4)
  • docs/VERCEL_SANDBOX_PROVIDER.md
  • packages/control-plane/src/sandbox/providers/vercel/client.ts
  • packages/control-plane/src/sandbox/providers/vercel/provider.test.ts
  • packages/control-plane/src/sandbox/providers/vercel/provider.ts
✅ Files skipped from review due to trivial changes (1)
  • docs/VERCEL_SANDBOX_PROVIDER.md
🚧 Files skipped from review as they are similar to previous changes (3)
  • packages/control-plane/src/sandbox/providers/vercel/client.ts
  • packages/control-plane/src/sandbox/providers/vercel/provider.test.ts
  • packages/control-plane/src/sandbox/providers/vercel/provider.ts

📝 Walkthrough

Walkthrough

Adds Vercel Sandbox resource support: computes requested vCPUs from SandboxSettings.cpuCores and memoryMib, selects the nearest supported Vercel size (or errors if too large), and forwards resources.vcpus in create/restore requests; updates types, tests, and docs.

Changes

Vercel Sandbox Resource Configuration

Layer / File(s) Summary
Resource type contracts and documentation
packages/shared/src/types/integrations.ts, packages/control-plane/src/sandbox/providers/vercel/client.ts
Reworded SandboxSettings comments to clarify cpu/memory semantics and added exported VercelVcpus + optional resources?: { vcpus: VercelVcpus } on VercelCreateSandboxRequest.
Vercel resource constants and resolver
packages/control-plane/src/sandbox/providers/vercel/provider.ts
Introduce MiB-per-vCPU and supported vCPU constants and add resolveVercelResources(sandboxSettings) to compute requested vCPUs (ceil memory→vCPUs, max with cpuCores), pick smallest supported tier, or throw if request exceeds max.
Provider and client payload integration
packages/control-plane/src/sandbox/providers/vercel/provider.ts, packages/control-plane/src/sandbox/providers/vercel/client.ts
Wire resources: resolveVercelResources(config.sandboxSettings) into provider createSandbox and restoreFromSnapshot payloads and forward resources through the client's JSON body to Vercel.
Tests and documentation
packages/control-plane/src/sandbox/providers/vercel/client.test.ts, packages/control-plane/src/sandbox/providers/vercel/provider.test.ts, docs/VERCEL_SANDBOX_PROVIDER.md
Update client test to assert resources: { vcpus: 4 } in the payload, add provider tests for mapping/omission/error behavior, and rewrite docs to describe cpu/memory→vCPU mapping, rounding, omission, and out-of-range behavior.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • ColeMurray/background-agents#700: Earlier work on the Vercel sandbox provider that established default/no-resources behavior; this PR extends that flow to compute and send resources.vcpus.

Poem

🐰 I nibbled bytes and counted cores,

Rounded memory to vCPU scores,
I hop to sizes Vercel knows,
Send resources where the payload goes,
Sandboxes hum as scaling soars.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'feat: support Vercel sandbox resources' accurately and concisely describes the main change: adding support for specifying compute resources (vCPUs and memory) when creating Vercel sandboxes.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/vercel-sandbox-resources

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

Copy link
Copy Markdown

Terraform Validation Results

Step Status
Format
Init
Validate

Note: Terraform plan was skipped because secrets are not configured. This is expected for external contributors. See docs/GETTING_STARTED.md for setup instructions.

Pushed by: @ColeMurray, Action: pull_request

Comment thread packages/control-plane/src/sandbox/providers/vercel/provider.ts
Comment thread packages/control-plane/src/sandbox/providers/vercel/provider.ts Outdated
open-inspect[bot]
open-inspect Bot previously requested changes Jun 10, 2026

@open-inspect open-inspect Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Summary

PR #723 (feat: support Vercel sandbox resources) by @ColeMurray adds Vercel sandbox resource serialization plus provider mapping from cpuCores/memoryMib to resources.vcpus. The implementation is mostly clean and well-tested for normal supported sizes, but one edge case can send unsupported Vercel resource values.

Files changed: 6, +78/-14.

Critical Issues

  • [Functionality] packages/control-plane/src/sandbox/providers/vercel/provider.ts:638 - Requests above Vercel's documented maximum can serialize unsupported resources.vcpus values such as 9, instead of rejecting clearly or using a supported shape. I left an inline comment with an example and suggested fixes.

Suggestions

  • Add a test covering resource requests above the maximum supported Vercel size so the intended behavior is explicit.

Nitpicks

  • None.

Positive Feedback

  • The create and restore paths both use the same resource mapping, which keeps behavior consistent.
  • The client test verifies resources is serialized through the REST payload.
  • The docs were updated to explain the provider-specific CPU/memory mapping and default behavior.

Questions

  • None beyond the inline comment on the above-max resource behavior.

Verdict

Request Changes.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/control-plane/src/sandbox/providers/vercel/provider.ts (1)

625-639: 💤 Low value

Consider removing redundant ?? undefined on lines 628-629.

The expressions sandboxSettings?.cpuCores ?? undefined and sandboxSettings?.memoryMib ?? undefined are redundant because when the left-hand side is nullish (including null), the result is already undefined without the explicit coalescing. You could simplify to:

const requestedCpuCores = sandboxSettings?.cpuCores;
const requestedMemoryMib = sandboxSettings?.memoryMib;

This doesn't change behavior since both are later coalesced to 0 on line 634, but it's slightly cleaner.

The overall logic correctly handles all edge cases:

  • Fractional cpuCores values
  • Combined CPU and memory constraints (using the higher derived vCPU count)
  • Explicit null values (treated as unset, returning undefined to omit resources)
  • Out-of-range requests (fallback to Math.ceil, letting Vercel enforce limits per the documented design)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/control-plane/src/sandbox/providers/vercel/provider.ts` around lines
625 - 639, In resolveVercelResources, remove the redundant "?? undefined" on the
sandboxSettings?.cpuCores and sandboxSettings?.memoryMib assignments and simply
assign requestedCpuCores = sandboxSettings?.cpuCores and requestedMemoryMib =
sandboxSettings?.memoryMib; this preserves existing semantics (they later
coalesce to defaults) and cleans up the code while leaving the rest of the
function (vcpusForMemory calculation, requestedVcpus, supportedVcpus lookup, and
return) unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@packages/control-plane/src/sandbox/providers/vercel/provider.ts`:
- Around line 625-639: In resolveVercelResources, remove the redundant "??
undefined" on the sandboxSettings?.cpuCores and sandboxSettings?.memoryMib
assignments and simply assign requestedCpuCores = sandboxSettings?.cpuCores and
requestedMemoryMib = sandboxSettings?.memoryMib; this preserves existing
semantics (they later coalesce to defaults) and cleans up the code while leaving
the rest of the function (vcpusForMemory calculation, requestedVcpus,
supportedVcpus lookup, and return) unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 45e622ac-6377-4293-846c-2e1206f4e9e4

📥 Commits

Reviewing files that changed from the base of the PR and between 095b115 and fca6eb6.

📒 Files selected for processing (6)
  • docs/VERCEL_SANDBOX_PROVIDER.md
  • packages/control-plane/src/sandbox/providers/vercel/client.test.ts
  • packages/control-plane/src/sandbox/providers/vercel/client.ts
  • packages/control-plane/src/sandbox/providers/vercel/provider.test.ts
  • packages/control-plane/src/sandbox/providers/vercel/provider.ts
  • packages/shared/src/types/integrations.ts

@github-actions

Copy link
Copy Markdown

Terraform Validation Results

Step Status
Format
Init
Validate

Note: Terraform plan was skipped because secrets are not configured. This is expected for external contributors. See docs/GETTING_STARTED.md for setup instructions.

Pushed by: @open-inspect[bot], Action: pull_request

@ColeMurray ColeMurray merged commit 4e90645 into main Jun 10, 2026
18 checks passed
@ColeMurray ColeMurray deleted the feat/vercel-sandbox-resources branch June 10, 2026 06:59
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