Skip to content

persistentExecInPod is an uncapped third SandboxTransport, and it serves the file-reading tools #180

Closed

Description

@pdettori

Problem

Spec §8 states the total-output-per-exec cap as a seam-level guarantee: every SandboxTransport enforces it, so Pi cannot tell which backend served a flood. Two of the three implementations do. The third does not.

persistentExecInPod (packages/k8s-sandbox/src/persistent-exec.ts) returns a SandboxTransport with no cap, and it is the transport wired to the file-reading tools — Read, Write, Edit, Ls, Find (packages/k8s-sandbox/src/extension.ts:53-59). Only bash and grep go through the capped KubectlTransport (extension.ts:62-64). The shared conformance battery runs against the two per-call transports only (transport-conformance.test.ts, grpc-relay-transport.test.ts).

Consequence today: cat a 20 MiB file and the persistent channel returns 20 MiB, while the same read through either per-call transport returns 8 MiB plus \n[output truncated] with exitCode: null. Pi can distinguish the backends, which is precisely what the guarantee exists to prevent.

Found by the whole-branch review of the epic-closing work (#89). The spec, ADR-0024, and transport.ts's comment have been corrected to name this exception rather than claim a guarantee that does not hold — this issue is about whether to close the gap in code.

Why it is not simply "add the cap"

persistentExecInPod serves whole-file reads. Capping it means a >8 MiB read fails rather than silently truncating — because createPodReadOps.readFile now rejects any read it cannot vouch for (packages/k8s-sandbox/src/operations.ts:22-38, added in the same review's fix wave, after we found a truncated read could be written back into the file through Edit).

That is the safe behavior, but it is a behavior change on the Read path: files above the cap become unreadable through the sandbox tools rather than partially readable.

The decision

  1. Cap it and add it to runConformance. The honest close: the seam guarantee becomes true, all three implementations are held to one contract, and the battery covers what it claims. Cost: >8 MiB files become unreadable through Read/Edit.
  2. Leave it uncapped by design, on the grounds that the file-reading path wants whole files and the poisoned-output threat is about streamed command output. Cost: the seam guarantee stays qualified, and the docs keep carrying the exception.

Option 1 also wants a decision on what the cap should be for reads specifically — 8 MiB is tuned to the streaming case and is pinned to the Go worker's BufferCap (now enforced by packages/k8s-sandbox/test/output-cap-coupling.test.ts).

Refs

Epic #89 · found in the whole-branch review of the epic-closing branch · related: the truncated-read guard in operations.ts:22-38.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions