Skip to content

feat(sandboxes): add application operations, v2 API, and CLI commands - #7442

Open
icecrasher321 wants to merge 7 commits into
stagingfrom
staging-v100
Open

feat(sandboxes): add application operations, v2 API, and CLI commands#7442
icecrasher321 wants to merge 7 commits into
stagingfrom
staging-v100

Conversation

@icecrasher321

Copy link
Copy Markdown
Collaborator

Summary

  • Bring sandboxes under the application-operation boundary: sandboxes.list|read|create|update|delete with authorized use cases, the Max-plan gate and the per-workspace build budget as domain admission, and semantic audit entries
  • Rewrite the internal settings routes on defineInternalJsonRoute and delete the route-local authorizer; wire the manage_sandbox tool through createCopilotApplicationAdapter
  • Add /api/v2/sandboxes (list, create, get, update, delete) with contracts and OpenAPI docs, which generates the sim sandboxes CLI commands
  • Add the sandboxes.use permission-group capability (hideSandboxesTab), declared on every operation, with the settings tab hidden for restricted cohorts
  • Gate execution on a terminal plan lapse only: a cancelled or downgraded payer fails the Function block, past_due keeps running; the check is cached per worker and fails open on a billing outage

Behavior changes:

  • Non-member reads of the internal routes answer 403 (collection) or 404 (item) instead of 401; non-admin writes get the shared role refusal
  • The manage_sandbox list runs at read role, is not plan-gated, and reports entitled
  • Function blocks with a sandbox on a workspace whose plan was cancelled or downgraded off Max/Enterprise now fail with the plan-required message

Type of Change

  • New feature

Testing

  • bunx turbo run type-check (all workspaces), bun run lint, bun run check:audits (45 audits, including check:openapi, check:api-validation:strict, check:permission-group-enforcement, check:cli-api, check:cli-docs), docs-manifest:check, check:migrations origin/staging
  • New and updated Vitest suites: operation registry and use cases, entitlement cache and resolution gate, billing retention check, internal and v2 route adapters, Copilot adapter and handler, permission-group fixtures, CLI package
  • Not exercised end to end against a running server

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercel Bot commented Sep 3, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
docs Ready Ready Preview Sep 3, 2026 9:47pm UTC

Request Review

@icecrasher321

Copy link
Copy Markdown
Collaborator Author

@greptile

@icecrasher321

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@greptile-apps

greptile-apps Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR moves sandbox management behind shared application operations and adds internal, V2 API, CLI, permission-group, audit, build-admission, and execution-entitlement support.

  • Adds authorized list, read, create, update, and delete sandbox use cases across settings, public API, and Copilot surfaces.
  • Adds generated CLI commands, API contracts, OpenAPI resources, and documentation.
  • Adds plan-retention checks for Function-block execution and per-workspace mutation admission.
  • Adds the sandboxes.use permission capability and hides restricted UI navigation.

Confidence Score: 5/5

The PR appears safe to merge because no blocking failure remains within the eligible follow-up-review scope.

No blocking failure remains.

Important Files Changed

Filename Overview
apps/sim/lib/sandboxes/application/use-cases.ts Defines the shared authorized sandbox operations, plan checks, build admission, and semantic audit projections.
apps/sim/lib/execution/remote-sandbox/workspace-sandboxes.ts Adds sorted cursor pagination, orchestration error classification, and write-admission hooks to sandbox persistence.
apps/sim/lib/execution/remote-sandbox/resolve.ts Enforces cached terminal-plan retention eligibility before resolving a selected workspace sandbox.
apps/sim/app/api/v2/sandboxes/route.ts Adds contracted V2 list and create adapters with cursor binding, authorization, and error policies.
apps/sim/app/api/v2/sandboxes/[sandboxId]/route.ts Adds contracted V2 get, update, and delete adapters with workspace-scoped application operations.
packages/sim-cli/src/runtime/request.ts Extends list argument coercion to support manifest files containing blank lines and comments.

Sequence Diagram

sequenceDiagram
  participant Client as Settings / V2 API / Copilot
  participant Route as Route Adapter
  participant UseCase as Authorized Sandbox Use Case
  participant Auth as Workspace Authorization
  participant Plan as Plan and Build Admission
  participant Store as Sandbox Store
  Client->>Route: list/read/create/update/delete
  Route->>UseCase: validated input and principal
  UseCase->>Auth: verify workspace role and capability
  Auth-->>UseCase: authorized context
  alt create, update, or delete
    UseCase->>Plan: enforce plan entitlement
  end
  alt create or update
    UseCase->>Plan: consume workspace build admission
  end
  UseCase->>Store: perform sandbox operation
  Store-->>UseCase: sandbox result
  UseCase-->>Route: result and semantic audit projection
  Route-->>Client: contracted response
Loading

Reviews (7): Last reviewed commit: "fix(cli): state inline list semantics be..." | Re-trigger Greptile

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@icecrasher321 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai 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.

All reported issues were addressed across 60 files

Not reviewed (too large): apps/docs/openapi-v2-resources.json (~1,834 lines) - if these are generated or fixture files, add them to ignored paths to exclude them from future reviews.

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread apps/sim/lib/api/contracts/v2/openapi/resources.ts Outdated
Comment thread packages/sim-cli/src/contract/commands.ts Outdated
Comment thread apps/sim/lib/sandboxes/application/use-cases.ts Outdated
Comment thread apps/sim/app/api/workspaces/[id]/sandboxes/error-policy.ts Outdated
@icecrasher321

Copy link
Copy Markdown
Collaborator Author

@greptile

@icecrasher321

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@icecrasher321 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai 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.

All reported issues were addressed across 65 files

Not reviewed (too large): apps/docs/openapi-v2-resources.json (~1,834 lines) - if these are generated or fixture files, add them to ignored paths to exclude them from future reviews.

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread apps/docs/content/docs/cli/reference.mdx Outdated
Comment thread apps/sim/lib/sandboxes/application/use-cases.ts Outdated
Comment thread apps/sim/lib/sandboxes/application/use-cases.ts
@icecrasher321

Copy link
Copy Markdown
Collaborator Author

@greptile

@icecrasher321

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@icecrasher321 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai 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.

All reported issues were addressed across 65 files

Not reviewed (too large): apps/docs/openapi-v2-resources.json (~1,834 lines) - if these are generated or fixture files, add them to ignored paths to exclude them from future reviews.

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread apps/docs/content/docs/cli/sandboxes.mdx Outdated
Comment thread apps/sim/lib/api/contracts/v2/openapi/resources.ts
Comment thread apps/sim/lib/execution/remote-sandbox/workspace-sandboxes.ts
@icecrasher321

Copy link
Copy Markdown
Collaborator Author

@greptile

@icecrasher321

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@icecrasher321 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai 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.

All reported issues were addressed across 65 files

Not reviewed (too large): apps/docs/openapi-v2-resources.json (~1,836 lines) - if these are generated or fixture files, add them to ignored paths to exclude them from future reviews.

You've manually re-run cubic several times on this PR. Each manual re-review checks the full PR again and counts toward your usage quota. To preserve your usage limits, we recommend letting cubic automatically review new commits.

Fix all with cubic | Re-trigger cubic

Comment thread apps/docs/content/docs/cli/reference.mdx Outdated
Comment thread apps/sim/lib/api/contracts/v2/openapi/resources.ts
Comment thread apps/sim/lib/api/contracts/v2/openapi/resources.ts Outdated
@icecrasher321

Copy link
Copy Markdown
Collaborator Author

@greptile

@icecrasher321

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@icecrasher321 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai 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.

All reported issues were addressed across 65 files

Not reviewed (too large): apps/docs/openapi-v2-resources.json (~1,836 lines) - if these are generated or fixture files, add them to ignored paths to exclude them from future reviews.

You've manually re-run cubic several times on this PR. Each manual re-review checks the full PR again and counts toward your usage quota. To preserve your usage limits, we recommend letting cubic automatically review new commits.

Fix all with cubic | Re-trigger cubic

Comment thread apps/docs/content/docs/cli/reference.mdx Outdated
Comment thread apps/docs/content/docs/cli/reference.mdx
@icecrasher321

Copy link
Copy Markdown
Collaborator Author

@greptile

@icecrasher321

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@icecrasher321 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai 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.

No issues found across 65 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Not reviewed (too large): apps/docs/openapi-v2-resources.json (~1,836 lines) - if these are generated or fixture files, add them to ignored paths to exclude them from future reviews.

You've manually re-run cubic several times on this PR. Each manual re-review checks the full PR again and counts toward your usage quota. To preserve your usage limits, we recommend letting cubic automatically review new commits.

Re-trigger cubic

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