Repository navigation
Description
ST2 — Backend: SandboxTransport seam + KubectlTransport rename
Part of the SandboxTransport epic (see epic #89). Backend track (TypeScript / in-cluster). Pure refactor — ships first, provably inert.
Spec: docs/specs/2026-07-08-sandbox-transport-grpc-design.md §3, §13.1.
Problem
Today the harness executes every Pi tool call via kubectlExecInPod (packages/k8s-sandbox/src/exec.ts, ExecInPod = (command, opts) => Promise<{ stdout, exitCode }>). Call sites (converge.ts, run-leaf.ts, run-turn.ts, select-sandbox.ts) reach the kube-exec path directly, so a second transport can't be slotted below them without touching them all.
Goal
Introduce the one seam the rest of the harness sees and make today's path an implementation of it — zero behavior change.
- Define
interface SandboxTransportverbatim from spec §3 —exec(command, opts?: { stdin?, onData?, signal?, timeout? }) => Promise<{ stdout: Buffer; exitCode: number | null }>plusclose(). This is today'sExecInPodsurface (streaming viaonData, abort viasignal,timeout,stdin) plusclose(). - Rename
kubectlExecInPod→KubectlTransportimplementingSandboxTransport— the local/in-cluster fast path (§3 component table). - Make
converge.ts,run-leaf.ts,run-turn.ts,select-sandbox.tstransport-blind: they receive aSandboxTransportand never learn how bytes reach the sandbox (§3 invariants).
Non-goals (this task)
- No relay, no
GrpcRelayTransport, no proto usage yet (ST3). - No worker (ST4).
- No new behavior — this is a behavior-preserving extraction.
Acceptance
- Pure refactor: the shared conformance battery (introduced/anchored in ST5) is green against
KubectlTransport, and the existing leaf e2e (leaf-smoke.sh) passes unchanged. - No call site references
kubectlExecInPoddirectly; all go throughSandboxTransport. close()is honored on leaf completion; single-in-flight / ordered-exec semantics preserved (mirrors today'spersistent-exec.ts, §3 invariants).
Touches
packages/k8s-sandbox/src/exec.ts (rename → KubectlTransport), packages/k8s-sandbox/src/extension.ts, and the transport-blind call sites harness/src/converge.ts, harness/src/run-leaf.ts, harness/src/run-turn.ts, harness/src/select-sandbox.ts (paths per spec §3).
Next step
With the seam in place, ST3 adds the remote implementation behind it. Backend plan lives locally in docs/plans/.
Activity
Merge pull request #92 from pdettori/feat/sandbox-transport-seam