Skip to content

P1: FS-free harness — leaf envelope off the filesystem (inline + Redis) #45

Closed

Description

@pdettori

P1 — FS-free harness: move the leaf envelope off the filesystem

Part of the two-tier architecture epic (see epic issue). This is the foundation phase — brainstorm this first.

Problem

The credentialed harness performs filesystem I/O for the leaf envelope, violating the head/hands invariant (only the sandbox should touch a filesystem):

  • harness/src/run-leaf.ts:116 — readItem() reads inputsRef via node:fs (readFileSync).
  • harness/src/run-leaf.ts:160-161 — writes the verdict via node:fs (mkdirSync + writeFileSync(resultRef, …)).
  • Async path (packages/knative-server/src/leaf-job-runner.ts) also writes the verdict + a done-marker to the shared /work PVC — no Redis.

Model tool ops are already fully delegated to the sandbox (all 7 Pi ops: read/write/edit/ls/find/grep/bash — packages/k8s-sandbox/src/extension.ts:39-79). Only the envelope leaks to the harness.

Goal

The harness performs no filesystem access — only network I/O (LLM, Redis, sandbox exec API). Concretely:

  • Inputs (LeafItem = {item_id, file, pattern, require_approval?}) arrive inline in the /runs POST body (drop the inputsRef file read).
  • Sync verdict returned inline in the /runs response body (today LeafResult returns only {status, resultRef}; return the verdict value).
  • Async verdict + done-marker stored in Redis (already a dependency: RedisSessionBackend, RedisWorkQueue); /runs/status returns the verdict from Redis instead of a PVC file.
  • Sandbox working set (repo, worktrees) moves from emptyDir → a durable PVC (crash-safe). Single sandbox still fine on RWO at this phase (no RWX yet).
  • Remove the /work PVC mount from the harness Service and the async worker.

Non-goals (this phase)

  • Sandbox pool / routing (P2). Single sandbox is fine here.
  • RWX / multi-sandbox storage (P2).
  • Kata (P3, deferred).

Acceptance

  • Harness/worker pods mount no shared writable volume; a red-team grep finds no /work mount and no writeFileSync in the envelope path.
  • leaf-smoke.sh passes with inputs inline + verdict from response/Redis (repo still only in the sandbox → Claim 0 still holds).
  • Async path drains via Redis; verdict retrievable via /runs/status.
  • Sandbox repo survives a sandbox pod restart (durable PVC).

Touches

harness/src/run-leaf.ts, packages/knative-server/src/server.ts, leaf-job.ts, leaf-job-runner.ts, packages/work-queue, deploy/knative/service.yaml, leaf-scaledjob.yaml, sandbox.yaml/overlays, smoke drivers, and the external-orchestrator client. Updates the MVP leaf-session contract (docs/specs/2026-06-26-mvp-leaf-session-contract-design.md) and async-leaf (2026-06-27-async-leaf-completion-design.md).

Next step

Brainstorm P1 → spec (docs/specs/) → plan (docs/superpowers/plans/).

Activity

  1. pdettori commented on Jul 2, 2026

    @pdettori
    MemberAuthor

    Part of epic #49

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