Skip to content

ST2: backend — SandboxTransport seam + KubectlTransport rename (pure refactor) #85

Closed

Description

@pdettori

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 SandboxTransport verbatim from spec §3 — exec(command, opts?: { stdin?, onData?, signal?, timeout? }) => Promise<{ stdout: Buffer; exitCode: number | null }> plus close(). This is today's ExecInPod surface (streaming via onData, abort via signal, timeout, stdin) plus close().
  • Rename kubectlExecInPod → KubectlTransport implementing SandboxTransport — the local/in-cluster fast path (§3 component table).
  • Make converge.ts, run-leaf.ts, run-turn.ts, select-sandbox.ts transport-blind: they receive a SandboxTransport and 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 kubectlExecInPod directly; all go through SandboxTransport.
  • close() is honored on leaf completion; single-in-flight / ordered-exec semantics preserved (mirrors today's persistent-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

  1. added a commit that references this issue on Jul 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions