# Brief: write Equipo plan 2b (direct provider launching)

You are writing an implementation plan, and running one short feasibility
check first. Work in this worktree (branch `plan-2b`, from `runner`
ce02b38, which holds plan 2 as built plus trial mode).

## Paul's decision (2026-11-03)

Replace the Paseo layer. The runner launches Claude Code headless
(`claude -p --output-format stream-json`, `--input-format stream-json` as
needed) and Codex through its **app-server** (`codex exec --json` alone
omits tool visibility, per the probe) **directly**, each harness inside a
**bubblewrap** process namespace, with **our own durable event journal**.
Goal: real guarantees for the try-out instead of trial labels.

## Read first

- The direct-CLI probe: `docs/superpowers/specs/2026-11-03-direct-cli-probe.md`
  (commands that worked are in its appendices; its gap table is binding).
- The Paseo probe and equipo discussion 3 (`amadan discuss show oficina/equipo 3`).
- Spec `docs/superpowers/specs/2026-11-01-equipo-design.md` sections 6 and 9.
- Plan 2 and its rulings: `docs/superpowers/plans/2026-11-02-equipo-plan-2-runner.md`.
- The runner code as built: `internal/runner/...`, `runner/paseo/...`, the
  core under `internal/equipo/team`.
- Amadan now serves `GET /api/v1/repos/{ns}/{repo}/branches/{name}/description`
  (live on amadan.net since bcc0e66): verbatim channels, `by`, `at`,
  `agent`, `content_hash` = `sha256:` + hex of, for each of description,
  human, summary, notes in order, an 8-byte big-endian length then the
  UTF-8 bytes; `empty: true` with 200 when none. Plan 2b wires the
  publisher's production readback to it.

## Step 1: bubblewrap nesting check (run it, record it)

On docs-t1 (bubblewrap is installed; unprivileged user namespaces are on),
prove or disprove, with exact commands and output:
1. A harness started as the init of `bwrap --unshare-pid --die-with-parent
   --new-session` (plus the binds it needs: workspace read-write, its own
   config home, the provider CLI, `/usr`, `/etc` read-only, network as
   needed for the provider API, nothing else of `$HOME`) runs a turn.
2. **Claude Code's own sandbox works nested inside it** (Claude's Linux
   sandbox also uses bubblewrap), with `settings.sandbox` enabled,
   `failIfUnavailable: true` and `denyRead` on a sentinel; and Codex's
   deny profile works inside it.
3. A detached `setsid` child, a double-forked child, and a process that
   tries to move itself to another cgroup all die when the namespace init
   is killed, and nothing outside the namespace can be reached (no user
   systemd socket, no `/run/user/<uid>/bus`).
4. The account home binds in and out cleanly, with no other homes visible.

Use the cheapest models, tiny prompts, at most six provider runs. Two
Claude homes are at their weekly limit; use a home that works (the probe
used `/home/paulca/.paseo/zerosub/homes/claude-2b21c7944303`). Write the
result to `docs/superpowers/specs/2026-11-03-bwrap-nesting.md`. If nesting
fails for a provider, the plan must say what replaces it (for example
Claude's sandbox off and bubblewrap's own read binds as the isolation),
and why that is equivalent.

## Step 2: write the plan

Follow
`/home/paulca/.claude/plugins/cache/claude-plugins-official/superpowers/7.0.0/skills/writing-plans/SKILL.md`
exactly. Save to `docs/superpowers/plans/2026-11-03-equipo-plan-2b-direct.md`.
Scope:
- A provider launcher interface with Claude-headless and Codex-app-server
  implementations, version-pinned, replacing the Paseo adapter and bridge.
- Bubblewrap containment per attempt, replacing `/proc` sampling as the
  containment proof; cancel kills the namespace and records it.
- Explicit account homes per connection, with an identity check before the
  first prompt and no failover; connection discovery from configured
  homes, not Paseo.
- Effective isolation by construction (`--setting-sources ''`,
  `--strict-mcp-config`, `--ignore-user-config`, exact settings files)
  recorded and hashed per attempt; the verified-tuple list keyed on it.
- Our own durable event journal from the harness's stdout, per-turn usage
  deltas, resume after runner restart; mid-turn crash leaves the step
  waiting for a person, never redispatched.
- Per-run tool server and permission/question relay through each CLI's
  supported hook (`--permission-prompt-tool`, app-server approvals).
- The Amadan readback wired to the live endpoint.
- Remove what no longer has a reason to exist: supervised trial mode, the
  dedicated-user requirement, the Paseo adapter, bridge and Node bridge
  tests, `/proc` coverage as a gate. Codex becomes confined through its
  deny profile; keep the owner acknowledgement path only if Step 1 shows
  Codex cannot be confined, and say so.
- The live gate becomes: Paul enrols docs-t1 and runs the first bug fix.
  No sudo.

Interfaces, test names and assertions, commands; not code bodies. Keep it
proportionate. End with the self-review and "Questions for Paul" only for
what genuinely needs him.

## Rules

Do not write product code, commit or push. Do not spawn Anthropic-model
reviewers or other agents; no Paseo. No `.claude/HANDOFF.md`. Do not start a
copy-review server. Scratch under `$TMPDIR`, removed; stop every process
you start. Print a five-line summary: nesting verdict per provider, task
count, questions for Paul.
