Repository navigation
Description
Goal
One command on a laptop that demonstrates the SandboxTransport headline — a sandbox
outside the cluster, with zero inbound rules, executing a leaf's tool calls — and that
someone can run without a cluster account, a VPN to OpenShift, or any hand-patching.
Today that story is only reachable by someone willing to deploy to a cluster and edit
several manifests by hand. I did exactly that to validate it (see the walkthrough below);
it works, but it took a dozen steps and two traps that are not written down anywhere.
Shape
laptop
├─ kind cluster: Knative + Redis + harness (ksvc) + sandbox-relay
└─ docker run: remote-worker ──dials out──▶ relay
The worker runs as a plain docker run on the host, not as a pod. That is the whole
point: it is outside the cluster, it has no inbound ports, and it reaches the relay by
dialing out. A worker deployed as a pod (which is what worker-example.yaml does)
demonstrates the plumbing but not the driver.
The proof it must show
Verdict text that could only come from the container's own filesystem. The trick that
worked well when I validated this: the in-cluster sandbox-N pods are Alpine and the
worker image is RHEL, so a leaf grepping /etc/os-release gives opposite answers
depending on which backend ran:
| Backend | pattern Alpine |
model's stated reason |
|---|---|---|
| kubectl sandbox pod | FLAGGED |
"…running Alpine Linux" |
| remote worker | CLEAR |
"…this system is running Red Hat Enterprise Linux 9.8" |
An A/B in one script — same request, opposite verdicts — is far more convincing than a
single green run, because the model names the OS it actually read.
Features worth surfacing (each is already implemented and tested)
- Inverted connectivity —
docker runwith no-p, no inbound rules at all. - Live streaming — a long
bashwhose chunks arrive as produced, not batched. - Abort mid-stream — kill a runaway; the process group dies (a backgrounded
grandchild stops too, which is the part that is easy to get wrong). - Dual-ended timeout —
timeout_senforced worker-side,timeout:<n>surfaced. - Reconnect → dedup —
docker stopthe worker mid-flight, restart it, watch it
reattach and not re-run the redelivered exec. - Presence mirror —
redis-cli HGETALL sh:sandbox:recordsbefore/after, showing
registration is the live stream. - Trust model —
docker inspectthe worker: a bearer token and nothing else. No LLM
key, no kubeconfig, no orchestration. - Transport swappability — flip
SH_REMOTE_SANDBOXand rerun; identical contract,
different machine.
Two traps the script must handle (both cost me a failed run)
1. Enabling SH_REMOTE_SANDBOX=1 does not route to the worker. select-sandbox
builds candidates = [...pods, ...grpcRecs] and picks least-loaded-first, so with idle
in-cluster sandbox pods present a pod wins and the demo silently proves nothing — my
first remote run returned "Alpine" and looked like a success. This is correct behavior
(the remote worker is a pool peer, not a replacement), so the demo must either point
KAGENTI_SANDBOX_POOL_SELECTOR at a label matching no pods, or stand up a cluster with no
local sandboxes. Worth stating loudly in the README too.
2. deploy/knative/relay-deployment.yaml omits SH_RELAY_TOKEN. Relay auth is
fail-closed, so applying that manifest as-is yields a relay that rejects every Attach.
Either add the env to the manifest or have the script set it. (Small enough to fix
independently of this issue.)
Also note kubectl set env does not work on a Knative Service ("no kind Service is
registered") — the script needs a merge patch, and the patch must preserve the container's
volumeMounts or Knative's webhook rejects it.
Networking
The worker is on the host and the relay is in kind, so the script needs one of:
kubectl port-forward svc/sandbox-relay 8443:8443and run the worker with
RELAY_ADDR=host.docker.internal:8443— simplest, works on Docker Desktop and Podman.- attach the worker container to kind's docker network and address the node directly.
Port-forward is probably the right default: it is the same mechanism remote-worker/DESIGN.md
already documents for the laptop-worker flow, and it makes the "dials out through a tunnel"
story explicit.
Acceptance
-
make demo-remote-sandbox(ordeploy/kind/demo-remote-worker.sh) goes from no
cluster to a passing A/B in one invocation, and prints what it is proving at each step. - Teardown is one command and leaves no kind cluster, container, or loaded image behind.
- The A/B assertion fails loudly if the exec landed on a pod instead of the worker —
it must not be possible to get a green demo from the wrong backend (trap 1). - README section with the architecture sketch, the one-liner, and the trust-model note.
- Works with the worker image built locally; no registry push required.
Prerequisites and honest limits
- Needs an LLM reachable from the cluster for the leaf's model call. In my validation that
was an internal LiteLLM endpoint; the demo should fail with a clear message when the
configured model is unreachable rather than timing out mysteriously. - Docker/Podman + kind + kubectl + jq.
remote-worker/build-image.shcurrently targets an OpenShift internal-registry build;
the demo needs a plain local build pluskind load docker-image(I did this by hand with
a 6-line Dockerfile over a cross-compiledlinux/arm64binary — worth folding into the
script, and note the binary arch must match the kind node).
Validated end-to-end already (2026-08-27)
For the avoidance of doubt, the path this issue automates has been run manually and works:
worker pod attached to an in-cluster relay via ClusterIP DNS, presence mirrored into Redis,
harness on SH_REMOTE_SANDBOX=1, and a leaf returning CLEAR for "Alpine" with the reason
"this system is running Red Hat Enterprise Linux 9.8" — i.e. the leaf's file tools ran on
the remote worker, with no kubectl exec anywhere in the path. The gated relay-interop test
(SH_LIVE_RELAY=1) also passes against the real TypeScript relay, and the real
GrpcRelayTransport has been driven against the real relay and real worker.
What this issue adds is not new capability — it is making that reproducible in one command
on a laptop, which is what turns it into a demo.
Part of the SandboxTransport epic #89; complements the live gate in #88 (which covers
Kind → OCP conformance rather than a laptop showcase). Worker follow-ups: #173.
Assisted-By: Claude Code
Activity
pdettori commentedon Aug 31, 2026
Research findings — three assumptions in the issue have moved
Before planning, I traced the current state of
main. Three things the issue describes areno longer accurate, and they shrink the work considerably.
1. Trap 2 is already fixed.
deploy/knative/relay-deployment.yaml:45setsSH_RELAY_TOKEN: dev-token, with a comment explaining fail-closed auth and flagging that thesame file is included unpatched by the OCP overlay (so it is a live credential there —
secretKeyRef, #173, is still the real fix). Nothing for this issue to do.2.
relay-leaf-smoke.shalready implements most of the proof. The gated live smoke from #88already does the Alpine/RHEL A/B, verifies the discriminator holds before relying on it
(refusing to assert otherwise), defends trap 1 with a non-matching pool selector, snapshots the
ksvc env and restores it from an
EXITtrap, asserts Redis presence withtransport=grpc, andruns a control pass on the pod path afterwards.
So the delta for this issue is not the A/B. It is:
3. No hand-rolled Dockerfile is needed.
remote-worker/Dockerfilealready buildsself-contained from the repo root (
golang:1.25-alpine→ubi9/ubi-minimal, with bash +coreutils + file). One
docker buildat host arch. And because the worker runs as a hostcontainer, there is no
kind loadand no arch-matching against the kind node at all — thatcaveat only ever applied to the pod path. The RHEL base doubles as the discriminator for free.
One new trap, resolved empirically
The issue proposes
port-forward+RELAY_ADDR=host.docker.internal:8443.kubectl port-forwardbinds
127.0.0.1only, so whether a container can reach it depends on the runtime:host.docker.internal→--add-host=...:host-gateway)docker0bridge IP, not loopback--address 0.0.0.0Measured on Podman 5.7.1 behind the docker CLI:
host.docker.internalresolves to192.168.127.254and the default bind is reachable, with a no-listener control confirming theprobe is real. So the common laptop case needs no
0.0.0.0bind and no LAN exposure. The scriptwill probe reachability from a throwaway container and only widen the bind if the probe fails,
printing which path it took — portable without exposing the relay by default.
Plan
Landing this in two PRs. PR 1 closes every acceptance box; PR 2 adds the showcase vignettes,
which are the bulk of the line count and none of the acceptance criteria.
flowchart TD A[preflight: docker/kind/kubectl/jq + model creds] --> B{cluster?} B -->|--reuse-cluster and healthy| D B -->|else| C[kind create + setup-kind.sh] C --> D[build worker image at host arch<br/>no kind load: it runs on the host] D --> E[apply relay-deployment.yaml] E --> F[port-forward 8443 + probe from a container<br/>widen bind only if probe fails] F --> G["docker run -d --name sh-demo-worker<br/>NO -p flags — dials out"] G --> H[assert Redis presence transport=grpc] H --> I[validate discriminator:<br/>pod=Alpine vs worker=RHEL] I --> J["run A — pod path: 'Alpine' must be FLAGGED"] J --> K[flip ksvc: SH_REMOTE_SANDBOX=1<br/>+ selector matching ZERO pods] K --> L["run B — remote: 'Alpine' CLEAR and 'Red Hat' FLAGGED"] L --> M[restore env via EXIT trap] M --> N[print A/B table with the model's own stated reason]PR 1 — the acceptance criteria
deploy/knative/demo-remote-worker.sh(matching the existing convention;deploy/kind/does not exist and its one file would depend on
deploy/knative/lib.shanyway).deploy/knative/lib-relay.sh— extract the worker-agnostic A/B logic so the demo and theST5: integration & live gate — cross-transport conformance + end-to-end leaf (Kind → OCP) #88 gate cannot drift:
dispatch_pattern,assert_verdict,validate_discriminator,the env snapshot/flip/restore, and the presence assertion.
validate_discriminatortakes thetwo
os-releasestrings rather than fetching them, since the gate reads the worker viakubectl execand the demo viadocker exec— shared assertion, local fetch.relay-leaf-smoke.shre-pointed at the shared lib, behaviour unchanged.Makefile:demo-remote-sandboxanddemo-remote-sandbox-teardown.README-worker.md: architecture sketch, the one-liner, the trust-modelnote, and trap 1 stated loudly.
How trap 1 is made structurally impossible, rather than merely detected: before dispatching
the remote runs, the script asserts the configured pool selector matches zero Running pods.
select-sandbox.ts:103buildscandidates = [...pods, ...grpcRecs], so with zero pods the workeris the only candidate and no lease ordering can route around it. The double-pattern assertion
(
AlpineCLEAR andRed HatFLAGGED) then catches a pod-landed exec either way, and thesummary prints the model's own stated reason so the OS it actually read is visible, not inferred.
Teardown removes the container, the relay, the kind cluster and the built image.
PR 2 — the vignettes (deferred)
Live streaming · abort mid-stream (process group death) · dual-ended timeout · reconnect→dedup ·
presence mirror before/after ·
docker inspecttrust model · transport swappability.Honest limits
Unchanged from the issue: needs an LLM reachable from the cluster. The script fails with an
explicit message when the model is unreachable rather than timing out mysteriously — the existing
assert_verdictalready distinguishes "empty response, likely model unreachable" from a wrongverdict, and that behaviour comes along with the extraction.
Assisted-By: Claude Code
fix(deploy): make the zero-pods assertion fail closed
fix(deploy): scope the demo's relay token to a single run
fix(deploy): keep --teardown and --help to what they claim
test(deploy): run the deploy shell tests in CI, and lock lib-relay.sh…
feat(deploy): one-command laptop demo, worker as a host container
pdettori commentedon Sep 1, 2026
Closing: PR #195 satisfies all five acceptance criteria. Verified against the merged commit
fc757a7rather than the PR branch.make demo-remote-sandbox, 12 narrated stepsREADME-worker.md:289–376docker build --load, neverkind loadedThe cold-start path is now verified. PR #195 flagged it as its one unvalidated path
("worth one clean run before merge"). That run has now happened, from scratch with no cluster
present, on
fc757a7:setup-kind.shcreated the cluster (Creating kind cluster: sh-knative), so theCREATED_CLUSTER=1branch and its exit hint were both exercised. The model's own statedreasons name the OS it actually read — "confirming the system is running Alpine Linux" for the
pod, "the system is Red Hat Enterprise Linux 9.8" for the remote container — which is the
proof this issue asked for rather than a bare green check. Afterwards: no worker container, no
relay, no leaked port-forward, and the harness env restored to its pre-flip
KAGENTI_SANDBOX_POOL_SELECTORexactly.Criterion 2, honestly: teardown is one command, but it asks before deleting the kind
cluster and keeps it when there is no terminal to ask on. That is a deliberate deviation
from "leaves no kind cluster behind," and the right one:
--reuse-clusterexists so the democan run against a long-lived dev cluster, and a fresh
--teardownprocess cannot tell whichkind of cluster it is looking at. Deleting unconditionally would make a cleanup command
destructive to something the demo never owned. It is unit-tested in both directions
(
tests/demo-teardown-scope.test.sh, cases 1 and 2) and documented in the README. Recordingit here so a later reader does not mistake the prompt for an oversight.
Two of this issue's stated assumptions had already moved by the time #195 was written, and I
confirmed both:
relay-deployment.yamlalready setSH_RELAY_TOKENat the merge base, sotrap 2 was fixed on
main; andremote-worker/Dockerfilebuilds the binary in agolang:1.25-alpinebuilder stage from the repo root, so the hand-rolled Dockerfile and localGo toolchain this issue anticipated are both unnecessary.
Deferred, now tracked in #198: this issue's "Features worth surfacing" list. Four of the
eight bullets are already delivered by the demo (inverted connectivity, transport
swappability, and half each of the presence mirror and trust model), so #198 lists only the
four genuine gaps — live streaming, abort mid-stream, reconnect→dedup, dual-ended timeout —
plus two one-line fixes found while auditing: the demo asserts a presence record appears but
never that it vanishes (
assert_presence_goneexists and the gate calls it; the demo doesnot), and the
docker inspecttrust-model check is documented but never executed.Assisted-By: Claude Code
docs(demos): add the remote-sandbox laptop demo, and index the folder