v0.7 design round scoping — loopback reverse-injection listener

Status: implemented 2026-12-01 — grammar candidate 1 as recommended. Acceptance test passed: fx completes real agentic tasks (file edit tool use) through the listener with zero credentials in the jail. Harness 63/63 with six reverse-injection pins. Deviations from the scoping, honestly recorded:

  • egress-only interaction decided: injection never widens egress — a reverse upstream absent from –egress-only is denied with 403 and deny-only evidence. Consistency won over convenience; operator error is loud.
  • absolute-form requests arriving at the reverse listener are tolerated by normalizing to origin form — some clients speak proxy style everywhere
  • the first implementation lost evidence records: the reverse handler bypassed the active-connection tracking the exit-grace loop waits on. Fixed with a tracked wrapper, same failure family as the v0.6 drain race
  • one surprise in the positive direction: the DNS problem (cell-4dx) did NOT block fx through the listener — a loopback base_url needs no resolution, and fx’s connectivity probe apparently follows the configured endpoint. 4dx stays open for clients that resolve directly for other reasons.

The measured problem

Evidence, not theory (spikes/real-harness/VERDICT.md): v0.6 forward-mode injection requires the payload to speak plain HTTP to the loopback proxy. Cooperative clients do this trivially (curl, python-openai, git with insteadOf). But serious agent harnesses validate base URLs: fx refuses outright — base_url uses https, or http only for localhost, 127.0.0.1, or [::1]. For these clients, credential injection — the feature that makes autonomous write-side agents possible — is unreachable.

The same clients all share one deliberate exception: loopback http is fine. They allow it because local model servers (Ollama, vLLM) are a legitimate deployment shape. The injection endpoint is already on loopback. What is missing is a way for the client to address it as an origin server: today the forward proxy answers origin-form requests with 405 CONNECT or absolute-http only, and even if it didn’t, a Host header of localhost cannot identify the intended upstream.

The shape

A per-run loopback listener bound to a configured upstream+credential:

cell run --net proxy \
  --reverse-inject "9000=openrouter.ai:Authorization=Bearer env:ORKEY" \
  -- fx ask "..."

with fx configured (operator-controlled settings) as:

{ "base_url": "http://127.0.0.1:9000/api/v1", "auth": { "type": "none" } }

The listener accepts origin-form requests, injects the credential host-side, rewrites the Host header to the upstream (virtual-hosted upstreams break otherwise — CDNs route on Host), dials the upstream over verified TLS, and relays the response. The credential never exists inside the jail — exactly the v0.6 guarantee, extended to clients whose only cooperation is pointing at loopback.

Repeatable flag for multi-upstream runs (LLM on 9000, git-forge on 9001).

Grammar decision needed

Three candidates:

  1. --reverse-inject "PORT=HOST:HEADER=[PREFIX]env:VAR" (above) — one flag, self-contained, reuses the v0.6 credential grammar verbatim after the =
  2. --credential extension: existing spec plus +listen PORT suffix — fewer flags, but overloads an already subtle grammar
  3. separate listener spec + reference: --listen 9000:openrouter.ai with credentials matched by host from existing --credential entries — composable with forward-mode runs sharing one credential, but two flags where a typo silently mismatches

Recommendation: candidate 1. Self-containedness beats elegance here — each listener is one audited unit, and the grammar after = is literally the proven v0.6 spec, parser reusable.

Hard requirements (harness-pinning)

  1. credential value never appears in any audit record, argv of jail processes, or payload-readable memory — same invariant as v0.6
  2. Host header rewritten to the upstream host before dialing; TLS SNI and certificate verification against the upstream name, not loopback
  3. keep-alive force-disabled, inherited from v0.6 injection semantics
  4. listener binds loopback ONLY, inside the jail netns — unreachable from the host or other jails
  5. upstream dial parent-side: no DNS needed inside the jail (the reverse listener does not inherit the cell-4dx problem)
  6. evidence: egress records carry action:"allow-inject" plus a marker distinguishing reverse from forward (e.g. via:"reverse") — operators must be able to tell which path a credential traveled
  7. egress-only policy interaction decided explicitly: the upstream is operator-configured per-listener, so requiring a matching –egress-only entry is arguably redundant — but consistency argues for it. Decide in the design round; document either way
  8. stripping: payload-supplied credential headers are removed before injection, same as v0.6

Non-goals

  • MITM of CONNECT tunnels — fork B remains rejected; this is still fork A, extended to a second cooperation style
  • load-balancing, multi-upstream fanout per listener, health checking — one listener, one upstream
  • HTTP/2 origin-form — payloads speak HTTP/1.1 to loopback; h2 is upstream’s business behind TLS

Sizing

Small-to-medium, mostly reuse: TLS upgrade, injection rebuild, pump and teardown semantics all exist and are battle-tested from v0.6. New code: the listener itself (socket accept loop per configured port), origin-form parsing (simplest possible request shape — the forward parser already produces rewrite in exactly this form), Host rewrite, the flag plumbing, evidence marker. Risks concentrated in: header edge cases (duplicate Host, absolute-form arriving at a reverse listener — should still work or be cleanly rejected), and the interactions of multiple listeners in one run.

Estimate: one implementation session plus harness work, given the v0.6 machinery is reused. The fx end-to-end validation is the acceptance test: fx ask completing a real task through the listener with zero credential in jail.

Sequencing note

cell-4dx (DNS story) is independent but synergistic: fx ALSO dies on its direct-resolution connectivity preflight, so even with reverse-injection the harness may not survive proxy mode. The two issues together are the native-binary-agent unlock; neither alone suffices. Consider implementing as one v0.7 batch.