# Dynamic specialists slice 1: a Design specialist that shows its work

Spec: `docs/superpowers/specs/2026-11-28-dynamic-specialists.md` (rev 3.2,
approved, Paul's rulings in its section 7). Build branch
`specialists-slice-1` from `design-dynamic-specialists` with current main
merged. Two halves on one branch: **1a** the renderer and a static
`render_page`; **1b** `design-v1` with scope, routing and screenshots.
Revision 3.1: Astra plan rounds 1 (NOT READY, 11 findings), 2 and 3
(READY AFTER FIXES, 1 finding each) are folded in.

Finish line (after a release, Paul's): Paul asks the coordinator for a
Patrix design overhaul. A card proposes "Design for Patrix"; he taps Add;
the coordinator records an explore task and starts it with Design; Design
writes up to four mockup options under `mockups/<task>/` on the task's
branch, renders them, and the task page and direction card show the
screenshots. He taps Build this with a note naming the option he wants.

Not in slice 1: taste notes, reviewer profiles, running-app renders,
`.equipo/render.json`, fonts, Mac and Linux arm64 renderers, Engineering
using `render_page`, `suggest_note`, a continuation after a team-wide Add.

## Facts the plan rests on (main 55e192cf)

- Protocol is 35 (`ProtocolChangeDiffs`); the next migration is 0115.
  Whoever lands second renumbers.
- `Authorize` (`internal/equipo/chat/runners.go:595`) is every lease's
  start and purpose check; `authorizeResearch` sits there.
  `AuthorizePublication` (`transfers.go:283`) confirms a worker commit's
  push. `startTask` (`tasks.go:1017`) refuses a task that has any step.
- `researchGrant` finds the one active `research-v1` row; `cancelResearch`
  cancels every Research step and is the only revocation path.
- The thin runner commits and pushes Engineering's work itself; its
  `submit_candidate` and `ask_person` are fixed-text tools
  (`thin/mcp.go:219`). Provider profiles fix an exact tool list
  (`provider/actions.go:91`, with the old `submit_render`), Claude's
  launcher accepts only those (`claude/launcher.go:140`), and native file
  permissions are per specialist (`claude/answers.go:249`).
  `specialistRun.research` binds kept images read only at `/research`.
- Engineering runs under bubblewrap with `--unshare-pid` and
  `--new-session` (`provider/policy.go:686`). Processes inside may start
  nested namespaces (Claude's own Bash sandbox), all descendants of the
  sandbox's first process.
- `exportPreview` (`thin/preview.go:236`) exports `release/preview.json`'s
  output from git objects; `scanPreview` runs the pinned gitleaks over an
  export.
- `gitleaksSHA256` is linked by ldflags (`Makefile:290`).
  `build-instance-release.sh` embeds a fixed asset list, and the asset
  reader caps a file at 128 MiB (`install_assets.go:77`).
- `scripts/ci-chromium.json` pins `chromium-headless-shell`
  156.0.8078.79-1~deb13u1 and only what a Debian image lacks: essential
  packages such as `libc6` come from the CI image
  (`ci-chromium-pin.py:117`).
- Research uploads are staged and marked kept only after the final report
  validates them (`research_results.go:244`, `:547`); the task-file route
  serves only kept, complete files.
- Turn kinds are person, `move_in`, `explore` and `housekeeping`;
  `propose_specialist` runs only in a live person turn.
- The direction card's answers are Build, Try again (with a note) and
  Drop; Build creates a change task (`explore.go:281`).

## Rules for every task

Tests first: write the failing test, run it, see it fail for the right
reason. Then the code. Then a mutation check for each guard: break the
guard, see its test fail, restore it. The commit body records the test
command, the failure seen, and each mutation and its result. Targeted
`go test ./pkg/... -run TestX` while working; `make ci` once at the end.
`CGO_ENABLED=0`, Go caches at their defaults, scratch in on-disk
`$TMPDIR`, servers on 127.0.0.1. New strings go into `copy.go` marked
pending. Migrations are additive.

## Half 1a: the renderer (Linux amd64 only)

1. **Spike first, on docs-t1.** Build a throwaway tree from the full
   runtime closure (task 2's list, including the loader and libc) and run
   the headless shell, its own sandbox on, inside a bubblewrap launch
   shaped like task 5 with no host `/usr`. It must render a fixture page.
   If Chromium's sandbox cannot start there, stop and report: the spec
   forbids `--no-sandbox`, and that is Paul's call. Record the result and
   the exact bubblewrap arguments in the commit.
2. **Pin the full closure.** `scripts/ci-chromium-pin.py` also writes
   `internal/release/renderer.json` for amd64: the browser packages of
   `ci-chromium.json` at the same versions plus every essential package
   they need (no pruning of the base), so the tree runs with nothing from
   the host. A test fails when a browser package or version differs
   between the two files. Nothing at runtime downloads anything.
3. **Tree and manifest (release build).** `scripts/build-renderer-tree.py`
   fetches the pinned debs (sha256 checked), unpacks them into one tree,
   and writes `MANIFEST`: one sorted line per entry, `file <path> <sha256>
   <mode>`, `link <path> <target>` or `dir <path>`. Links must be relative
   and resolve inside the tree. A deterministic gzip `renderer.tar.gz`
   holds both. The Makefile links the manifest's sha256 into the runner as
   `release.rendererSHA256`; the release manifest's Linux target gains
   `RendererSHA256`. Tests: same inputs give the same bytes; a bad deb
   hash, an escaping or absolute link fails; no pin linked means
   `unpinned`.
4. **Verify.** `release.VerifyRenderer(dir, pin)`: `MANIFEST`'s sha256 is
   the pin; every entry exists with that type, hash and mode; links as
   listed; nothing extra; nothing group or world writable. Tests: tampered
   byte, extra file, missing file, link retargeted, mode widened, manifest
   swapped with a matching tree. Astra reviews this task.
5. **Sandbox launch.** Package `internal/runner/render`, `launch_linux.go`,
   with the spike's arguments: `--unshare-all` (never `--share-net`),
   `--die-with-parent`, `--new-session`, `--clearenv`, `--cap-drop ALL`;
   the verified tree read only as the root's `/usr` and loader paths, the
   export read only at `/site`, `/out` read-write, a tmpfs `/tmp`, a fresh
   `/proc`, a minimal `/dev`; no home, runner state or credentials; every
   inherited descriptor closed except the browser and status pipes. Inside,
   `equipo-runner render-sandbox` serves `/site` on 127.0.0.1 and starts
   the browser with `--remote-debugging-pipe` and `--host-resolver-rules`
   mapping every other host to not found. Tests (Linux, skipped without
   bubblewrap): from inside, a public IP, the host's tailnet address and a
   listener the test opens on the host's 127.0.0.1 are unreachable; a
   parent descriptor is not visible; the environment is empty; `/site` is
   read only; an external redirect is reported, not followed. Astra
   reviews this task.
6. **Browser driver.** A small CDP client over the pipe (stdlib only).
   Per page: viewport (phone 390x844, tablet 834x1194, desktop 1440x900),
   navigate, wait for load then network idle (at most 5 s), capture (full
   page clipped at 10,000 px), console errors (20), failed loads (30:
   external blocked, not found, font), same-site anchors answering 404
   (30), the accessibility tree outlined to 8 KiB, the title. Output: a
   JSON report and PNGs in `/out`. 60 s and 2 GiB per call, killed on
   overrun. Fixture sites: console error, CDN script, web font, broken
   link, a very tall page, a script that never ends (`timeout`), a page
   that kills the renderer (`crashed`).
7. **Release delivery, install and verify-installed.**
   `build-instance-release.sh` embeds `renderer.tar.gz` (amd64); the asset
   reader allows that one name up to 384 MiB and the usual 128 MiB for the
   rest. Install assets serve it on Linux. `setup/install.go`,
   `install-v1.sh`, `upgrade-thin.sh`, `cutover-thin.sh` and
   `cutover-finish-thin.sh` unpack it to `<runner dir>/renderer/<first 12
   of pin>/` through a temporary directory and a rename, verify it, render
   the fixture page with tasks 5 and 6, and refuse on any failure.
   `verify-installed` does the same check and fixture render. Mac and
   arm64 installs neither need nor check one. Old trees are removed by
   name. Tests: as `scanner_install_test.go` and
   `verify_installed_test.go`, plus one install from a release built by
   the real script into `$TMPDIR` (Linux, skipped without bubblewrap).
8. **Health.** The runner reports `ToolHealth.Renderer` on Linux amd64:
   `ok` only when `VerifyRenderer` passes and a fixture render has
   succeeded with this tree since the runner started; `missing`,
   `mismatch` or `unpinned` otherwise. It rechecks the files before each
   render. Mac and arm64 send nothing. `status` says a bad renderer needs
   the runner updated, not another try. Tests: each state; a tree that
   verifies but cannot render is not `ok`.
9. **Workspace snapshot.** For `tree: work` the runner pauses the step,
   then does everything inside the pause: it reads the workspace's
   `release/preview.json` with `readPreviewConfig`'s rules and copies the
   output directory into a runner-private stage by `exportStatic`'s rules,
   opening every path with `openat2` and `RESOLVE_BENEATH |
   RESOLVE_NO_SYMLINKS` from the workspace root, regular files only, caps
   applied. The pause: SIGSTOP to every descendant of the step sandbox's
   first process (which covers nested namespaces), rescanning until every
   one reads stopped in `/proc/<pid>/stat` and no new one appears; then
   the copy; then SIGCONT to all on every exit path, panics included. The
   10-second bound covers stopping and copying; past it the runner
   resumes and refuses with `busy`. No git index is used and nothing is
   written to the workspace or branch, a simplification of the spec's
   private index with the same guarantees. No cgroup is frozen. Tests: a
   writer that appends a counter every millisecond, from a nested
   namespace too, makes no progress between pause and resume; a link at
   any depth is not followed; files outside the output are not copied;
   SIGCONT after an injected panic and after the bound; mutation: skip one
   descendant and the writer test fails. Astra reviews this task.
10. **`render_page` (runner side, no profile yet).** Strict input (`tree`,
    up to 6 `pages` of path, viewport, `full_page`, and `compare`). `base`
    exports the task's base commit with `exportPreview` (`no_site` without
    `release/preview.json`); `work` uses task 9. `scanPreview` runs over
    every export first: a finding refuses with `secrets`, an unusable
    scanner with `scanner` (two codes the spec did not list; both refuse
    before any render). One render at a time per runner; per step 20 calls
    and 60 captures (`too_many`), counted in the step's state so a restart
    keeps them. Each PNG is decoded and re-encoded by the runner
    (downscaled until at most 2 MB). `compare` pairs the trees' captures
    with a changed-pixel ratio and a diff PNG. Captures go to the step's
    render directory. The text reply lists captures and reports, every
    page string quoted under a "from the rendered page" label, bounded,
    control characters stripped. Tests: each code, bounds, the label, a
    hostile PNG re-encoded.

Checkpoint: half 1a ends green on its own (`go test` of the touched
packages) and is pushed before 1b starts.

## Half 1b: Design

11. **Wire, protocol 36 (`ProtocolDesign`).** `DispatchCommand` gains
    `SpecialistID`, `SpecialistRevision`, `SpecialistProject`, `Profile`
    and `Capabilities`; `LeasePurposeRender`; the final report's `Options`
    [{name, captures [{id, sha256, tree_digest}]}] (at most 4 options, 12
    captures); a `render_file` chunk frame (as `research_file`);
    `AnswerCard.Note` on Build; `Specialist.Project`; `propose_specialist`'s
    `project`. Encode refuses a dispatch with a specialist id, and a render
    lease check, below 36. Tests: round trips, refusals below 36, bounds.
12. **Menu and pack.** `design-v1`: capabilities `branch.edit` and
    `page.render`, tools `render_page`, `submit_candidate`, `ask_person`,
    a `Pack` digest. `web.research` stays exclusive. `Describe` words for
    the two capabilities. The pack `internal/specialist/packs/design-v1.md`
    is our own discipline drawing on impeccable's method (its licence
    checked and recorded in the commit), plus reading the project's
    `DESIGN.md` as quoted context and the mockup layout (`mockups/<task>/`,
    one page per option, `release/preview.json` naming the folder). Paul
    reviews the pack once (task 21).
13. **Executable policy for Design.** A `design` action profile in
    `provider/actions.go` with exactly `render_page`, `submit_candidate`
    and `ask_person` (no `submit_render`); Claude's launcher and allowlist
    accept it; native file permissions add read-only access to `/render`
    and nothing else beyond Engineering's. The golden test of task 12 also
    pins this policy. Tests: a real Claude launch with a fake model (as the
    step tests do) lists exactly those tools and reads a capture from
    `/render`; a write there is refused; Engineering's policy is unchanged.
14. **Storage, migration 0115.** `chat_specialists.project_id` ("" team);
    `chat_tasks.maker_specialist_id`; `chat_steps.specialist_id`,
    `specialist_revision`, `specialist_project`, `specialist_caps`,
    `design_runs` (see task 17); `chat_task_files.source` (`research` or
    `render`), `option` and `tree_digest`. Models, schema, migration check.
    Team records, never `scope.Owned`.
15. **Proposal, scope and continuation.** `propose_specialist` takes
    `design-v1` and an optional `project` (a project the person already
    has; "" is the team). One open proposal and one active row per profile
    and scope. A Not now on that profile and scope in the last 7 days
    refuses (an owner can still add from the team page). The card shows
    name, scope and each capability's words. A project-scoped Add, in its
    transaction, queues one turn of a new kind `specialist_added` in the
    proposing turn's lane, keyed by the card (a second Add or a retry
    queues nothing). Its opening carries the instance's record ("Paul added
    Design for Patrix") under Equipo's label and quotes the person's
    message from the proposing turn under the person's label. That turn
    is bound to the card: `record_task` only in the card's project (no
    `add_project`, `create_project` or implicit add), `start_task` only for
    a task this turn recorded and only with the card's specialist, whose
    grant `grantFor` still finds; every other mutation is refused. A
    team-wide Add queues nothing (the coordinator's reply says it was
    added). Tests: member can't add; stale revision; double tap; decline
    window; the labels; the bound tools called with another project,
    another task, another specialist, and after a revoke. Astra reviews
    this task.
16. **Grants for every specialist.** `grantFor(profile, project)`
    generalises `researchGrant`: the active row for that profile and
    project, else the team row; grants exactly the profile's capabilities,
    unrevoked, at its revision, given by its approver, an owner now.
    Research resolves against the task's project the same way. Dispatch
    writes the step's full binding (id, revision, project, capabilities)
    and appends a `specialist.used` audit row. `Authorize` refuses a step
    whose binding no longer equals `grantFor` for its task's project
    (start and `LeasePurposeRender`); `authorizePublication` does the same
    before a push. `RevokeSpecialist` cancels the steps bound to that
    specialist only (Research ones as today, maker ones as an ordinary
    cancel) and withdraws their pending publications. Tests: revoke
    between dispatch and start, between two renders, between commit and
    push; approver demoted; profile missing from the menu; project row
    over team row; revoking one project's Design leaves another's running.
    Astra reviews this task.
17. **Routing, the autonomy limit and recovery.** `status` lists active
    specialists (id, profile, name, brief, scope) and
    `runner.tools.renderer`. `start_task` takes an optional `specialist`
    id: active, grant usable, scope the task's project or the team,
    profile a maker. The task records `maker_specialist_id`; fix rounds,
    retries, Try again and the task Build this creates use it (the step
    kind stays `engineering`). Placement sends a Design step only to a
    runner at 36 with the renderer `ok` and a Claude connection, else it
    waits with `design_runner`. **Limit:** the task counts Design attempts
    (first runs, retries, fix rounds) since the person last acted on it (a
    message in its thread or an answer on its cards), stored on the task;
    the fourth is not dispatched and the step is held for the person
    through the existing held-step card. **Recovery:** after a revoke, once
    every attempt of the task's Design steps is terminal and has its
    termination proof (`Terminated`, whatever its state, done included)
    and the task is not `busy` (`explore.go:175`), the task's creator
    gets one card, "Design was removed. Hand this task to
    Engineering?"; their tap, checked against both again in its
    transaction, clears the maker and queues Engineering. Coordinator
    surface as places did:
    schemas and descriptions, the Claude allowlist,
    `provider.ConverseTools`, `MutationKinds`, the opening's sentence and a
    new `houseRule`. Tests: each refusal; Try again keeps Design; Build's
    task inherits it; the fourth attempt held; the counter reset by a
    message; a terminal attempt (cancelled or done) without its termination
    proof blocks the recovery card and the tap, and allows them once the
    proof arrives.
18. **The Design step (runner).** A dispatch with profile `design-v1` runs
    Engineering's step with task 13's policy, the pack and brief as the
    prompt, `/render` bound read only, and the tools live: `render_page`
    (each call first a `LeasePurposeRender` check), `submit_candidate`
    (records options; the runner still commits and pushes at the end),
    `ask_person` (as today). Before the final report, the named captures go
    up as `render_file` chunks. Claude only. Tests: a refused render lease
    stops rendering and says why; uploads are bound to the attempt.
19. **Captures, task page and direction card (instance).** As Research:
    chunks for the step's current attempt are staged, never served; the
    final report's options, capture ids, hashes and tree digests are
    validated against the staged files, the PNG fully decoded within
    bounds, and the binding checked with `grantFor` in that transaction;
    only then are the files kept. The task page shows kept captures by
    option; the direction card shows them too. With more than one option,
    Build needs a note (the person's words, at most `MaxDirectionNote`)
    that goes into the new task's brief quoted as theirs. Web UI: day
    theme, token colours, attribute grammar, scriptless forms, no split
    screen, no coloured left-border accents. Native: check how direction
    cards render; a multi-option Build without a note is refused as a card
    conflict telling them to open it on the web. Tests: revoke during
    upload, a foreign capture id, an incomplete upload, a PNG that passes
    its signature but not decoding, Build with and without a note.
20. **End to end.** A thintest contract: a primary at 36 with the
    renderer `ok` (a fake renderer) and a Claude connection. The person
    asks for a Patrix design overhaul; the fake coordinator proposes
    `design-v1` for Patrix; the owner taps Add; the continuation records an
    explore task and starts it with Design; the dispatch carries the
    binding; the fake model renders, writes options and submits; captures
    are kept; the task page and direction card show them; Build with a
    note creates the change task with Design as maker. Refusals: revoke
    mid-step, runner at 35, renderer not `ok`, member tap, decline window.
21. **Copy.** See below.

## Copy

New strings (the Design card, capability and scope words, the
continuation's record line, `design_runner`, the held limit, the recovery
card, the Build note prompt and refusal, gallery labels, renderer status
words) go into `copy.go` marked pending and into
`/home/paulca/.cache/specialists-1-copy.json` as copy-review entries,
with the evidence file
`docs/superpowers/plans/2026-11-28-dynamic-specialists-slice-1-copy.md`, as
places slice 1 did. Luna reviews them all and its text is applied; the
cards and the pack go to Paul. The builder never marks copy accepted:
acceptance happens only through the repository's own copy flow, and the
pending-copy gate stays red until then.

## Reviews and the round limit

Astra (`gpt-6-astra`, effort high, read-only) reviews this plan, tasks 4,
5, 9, 15 and 16 as they finish, and the whole branch at the end. Each
review gets at most three rounds. After a third round's findings are
fixed, the fix is recorded here and not reviewed again; a finding that
needs a product decision goes to Paul.

## Verification and handoff

`make ci` once at the end, after the branch review. Push
`specialists-slice-1`; no merge, release or deploy. The controller report
lists the commits, the mutation checks, Astra's verdicts, the copy file
and what happens after release: an agent-run upgrade (whose
verify-installed renders the fixture page on the production runner), then
Paul asks for the Patrix design overhaul and taps Add.

## Astra plan round 1: NOT READY (11 findings, all taken)

Full closure pinned and the spike moved first (1); the pause covers every
descendant, is verified, and holds the config read and rooted copy (2);
a Design executable policy (3); release delivery with a size bound and a
real-build install test (4); the continuation bound to the card (5); the
full binding stored and cancellation by specialist (6); a recovery card
(7); staged captures validated by the final report (8); the three-attempt
limit (9); `ok` needs a fixture render and verify-installed renders one
(10); no delegated acceptance by the builder (11).

## Astra plan round 2: READY AFTER FIXES (1 finding, taken)

Recovery waits for the task to be not `busy`, so a cancelled Design
attempt must have its termination proof before Engineering can start,
checked again at the tap.

## Astra plan round 3: READY AFTER FIXES (1 finding, taken; round limit)

A Design attempt that completed (not only one cancelled) also needs its
termination proof before the recovery card or its tap. Fixed in task 17
and not reviewed again.

## Build notes (2026-11-29)

Built on `specialists-slice-1` from `design-dynamic-specialists` with main
8bd40ed1 merged. Protocol 36; migrations 0115 to 0118.

- Task 1 gate: PASS. Chromium's own sandbox runs inside the render sandbox
  on docs-t1 with nothing from the host's `/usr` (commit 79b79d7c records
  the arguments and the 98 packages).
- Astra task reviews (round limit three): task 4 READY at round 2; tasks
  5, 9, 15 and 16 READY at round 3. Whole branch: NOT READY (7 Important,
  2 Minor), then NOT READY (2 open), then READY at round 3.
- Task 9 ruling: the pause is defence in depth, not a boundary against a
  hostile process inside the step (it already chooses what the work tree
  renders). No seccomp in slice 1; after the copy, while still paused, every
  copied path is checked again and any change refuses with `busy`.
- Copy: Luna reviewed all 27 strings (6 changed). Everything stays COPY
  REVIEW PENDING; the cards and the Design pack wait for Paul
  (`2026-11-28-dynamic-specialists-slice-1-copy.md`).
- `make ci` once, then fixes for its three findings of ours; still red on
  pending copy (by design) and on `TestBrowserGitHubManifestCSP`, which
  fails the same way at the branch base on docs-t1.
- Not built here: the Swift changes were not compiled (no Xcode on
  docs-t1); native screenshots on the task page; a team page Add.

## Merge with main (2026-11-30)

Main cfe54cfc merged (b320a698). Main took protocol 36 (lookups) and 37
(Mac Engineering, slice F) and migrations 0115-0117 and 0120, so Design
is now **protocol 38** (`ProtocolDesign`, the current protocol) and its
migrations are **0121-0124**. Read 38 for 36 and 0121-0124 for 0115-0118
above. A Mac worker refuses a specialist-bound dispatch; a Design task on
a Mac-only project would wait on the renderer (untested). Copy: Paul’s 15
strings and the pack approved unchanged, Luna's 12 accepted by delegation
(see the copy file).
