feat(sandboxes): add Ruby session and execution facade - #316
shawnwu-kong wants to merge 5 commits into
Conversation
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 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".
| end | ||
|
|
||
| def call(request, status: 200) | ||
| token = @client.current_session&.access_token || @client.service_token |
There was a problem hiding this comment.
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 👍 / 👎.
|
|
||
| def call(request, status: 200) | ||
| token = @client.current_session&.access_token || @client.service_token | ||
| response = Transport.invoke { @transport.sandbox_request(authorization: token, request: request) } |
There was a problem hiding this comment.
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 👍 / 👎.
| def use | ||
| yield self | ||
| ensure | ||
| terminate unless @state == 'terminated' |
There was a problem hiding this comment.
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 👍 / 👎.
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.useexits. 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.