Conversation
…STORY-007] - `SandboxProvider` interface (one method: `run`) in `packages/sandbox/src/provider.ts`. - `PistonSandboxProvider` with injectable `PistonTransport` (clean unit-test seam, mirrors the LLM gateway pattern). - `PistonHttpTransport` — real fetch against a self-hosted Piston (default `http://localhost:2000`, abortable via `AbortController`). - Zod-validated boundary: `SandboxRunRequestSchema` (defaults: 5s timeout, 128MB memory, 64KB output limit) and `SandboxRunResponseSchema`. - Output truncation + `killed_by` classifier covers `timeout`, `memory`, `output-limit`, and `signal`. - Telemetry sinks: null + in-memory. - `buildSandboxProvider` factory + `loadSandboxConfigFromEnv` (`PISTON_URL` env override + `LEARNPRO_SANDBOX_CONFIG` JSON). - API: `GET /sandbox` (provider name) + `POST /sandbox/run` (zod-validated body → run result; 502 on `SandboxRequestError`). - Tests: 22 unit/registry pass with `FakePistonTransport`; integration test gated on `PISTON_URL`; 6 API tests cover the new endpoints. Hardening verification (no-net, ro rootfs, cgroups, seccomp, non-root) is deferred to STORY-010 by design — it owns `packages/sandbox/test/breakout/`.
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
SandboxProviderinterface (single method:run) andPistonSandboxProviderwith an injectablePistonTransportshim — same architectural pattern as the LLM gateway (interface + injectable transport + zod boundary + telemetry sink).PistonHttpTransport(realfetchagainsthttp://localhost:2000, abortable viaAbortController).GET /sandboxandPOST /sandbox/runon the API. The POST endpoint validates the body viaSandboxRunRequestSchemaand returns 400 on bad input, 502 onSandboxRequestError.buildSandboxProvider+loadSandboxConfigFromEnv(PISTON_URLenv override +LEARNPRO_SANDBOX_CONFIGJSON).FakePistonTransport; integration test gated onPISTON_URL; 6 API tests cover the new endpoints.Hardening verification (no-net, ro rootfs, cgroups, seccomp, non-root) is deferred to STORY-010 by design — that Story owns
packages/sandbox/test/breakout/and exercises the real Piston runtime.Acceptance criteria covered (STORY-007)
SandboxProviderinterface defined inpackages/sandbox/src/provider.ts(one method:run).print('hello')and returns the expected stdout.killed_by: 'timeout'.killed_by: 'output-limit'if exceeded.killed_by: 'memory'.socket.socket().connect((...))raises a network-blocked error → STORY-010.Test plan
pnpm --filter @learnpro/sandbox test— 22 pass, 2 skipped (integration gate)pnpm --filter @learnpro/api test— 6 passpnpm typecheck— all greenpnpm lint— all greenpnpm format:check— all greenPISTON_URL=http://localhost:2000 pnpm --filter @learnpro/sandbox testafterdocker compose -f infra/docker/docker-compose.dev.yaml up -d piston🤖 Generated with Claude Code