Skip to content

feat(sandboxes): add Ruby session and execution facade - #316

Draft
shawnwu-kong wants to merge 5 commits into
mainfrom
codex/sandbox-hosting-p7
Draft

shawnwu-kong wants to merge 5 commits into
mainfrom
codex/sandbox-hosting-p7

Conversation

@shawnwu-kong

@shawnwu-kong shawnwu-kong commented Sep 24, 2026 •

Copy link
Copy Markdown

Adds the Ruby Sandbox facade coordinated with Hosting P7 (#1354) and JavaScript SDK #270: one-shot commands, sessions, lifecycle operations, binary files, scoped HTTP access, and backend-managed user grants.

Uses generated operations from Hosting's bundled public OpenAPI. Preserves caller request IDs without replaying uncertain commands, omits named-template memory overrides, keeps nonzero command exits as data, and requests termination when session.use exits. Includes public signatures and examples. Existing shared scenarios remain unchanged; this ports the P7 facade to Ruby.

Validation: native lint, both strict type targets, all 1,922 examples with 100% line/branch coverage, exact annotation-necessity checks, five injected defects, contract binding dry run, deterministic generation, dependency audit, and isolated gem installation pass. The Sandbox reader uses the existing exact-method Steep accessor annotation with its diagnostic recorded and tested. Remote Ruby 3.2/3.4 checks and Quality Gate pass. Live Sandbox acceptance remains pending.

Coordinate with https://github.com/Kong/volcano-hosting/pull/1354 and Kong/volcano-sdk-python#372. No gem publication.

First review fixes cover operation-scoped credentials, user refresh with stable command identity, and preserving block errors during cleanup. Native behavior and accessor-annotation gates pass.

@shawnwu-kong

Copy link
Copy Markdown
Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-24T18:26:26.183005Z a7b8b79 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a7b8b79eea

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread lib/volcano/sandbox_request.rb Outdated
end

def call(request, status: 200)
token = @client.current_session&.access_token || @client.service_token

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Use service credentials for sandbox management calls

When a client has both a service key and an active project-user session, this always selects the auth user's access token. The bundled contract permits AuthUserAccessToken only for granted-user operations such as get, exec, files, and access; create, one-shot execution, lifecycle changes, and grant/revoke accept only owner/service credentials. Those management calls therefore receive 401/403 despite a valid configured service key, with no way to override the selection except using a separate client or signing out. Route credentials according to the requested operation instead.

AGENTS.md reference: AGENTS.md:L10-L11

Useful? React with 👍 / 👎.

Comment thread lib/volcano/sandbox_request.rb Outdated

def call(request, status: 200)
token = @client.current_session&.access_token || @client.service_token
response = Transport.invoke { @transport.sandbox_request(authorization: token, request: request) }

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Refresh expired auth sessions before retrying sandbox requests

For granted project users, this dispatch bypasses Client#session_request, so an ordinary access-token expiry immediately makes get, exec, file, and access operations fail with 401 even when the client holds a valid refresh token. Other session-authenticated facades use that wrapper to refresh once and preserve session-lineage checks; sandbox user operations need the same path rather than sending the captured token directly.

Useful? React with 👍 / 👎.

Comment thread lib/volcano/sandbox_session.rb Outdated
def use
yield self
ensure
terminate unless @state == 'terminated'

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve the block exception when termination fails

If the block raises and the termination request also fails—for example because of a transient network error—the exception raised from this ensure replaces the block's original exception. Callers then lose the actual application failure they were trying to diagnose; cleanup should still be attempted, but its error should not mask an already-active block exception.

Useful? React with 👍 / 👎.

This branch has not been deployed

No deployments
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