# Slice 2b progress: the coordinator moves in

Branch `thin-v1-slice2b` from `thin-v1-slice2` (e680e64). Spec:
`docs/superpowers/specs/2026-11-06-equipo-thin-v1.md` §§1, 2, 5, 7, plus
Paul's idea of 2026-11-07 ("the coordinator needs some kind of
bootstrapped/onboarded state ... move in ... get acquainted with their
environment") and two Important findings from Astra's re-check of slice
2's `set_project_home`. Conventions and scripts as in
`SLICE1-PROGRESS.md` and `SLICE2-PROGRESS.md`.

## Done

1. `set_project_home` (Astra re-check, both Important; 4b2b3fa):
   - Only when the person asks: the call succeeds only if a person
     message in the running turn names the namespace (whole word, lower
     case; `oficina/site` names `oficina`) or, to clear, has a clearing
     word (clear, unset, reset, remove, forget) and "home", "default" or
     "new projects". Otherwise `not_asked`. A model call alone (prompt
     injection, an unsolicited change) changes nothing; move-in and
     explore turns have no person message, so they never can.
   - A successful change posts a home card ("New projects go to X" or
     "... the best-fitting existing repository") with Undo. Undo restores
     the previous value (never set, cleared, or a namespace), owner only,
     only while the setting still holds the card's value (else 409).
   - Explicit clear versus never set: `chat_settings` keeps a row for an
     explicit clear; `status` and `GET /projects` then report no home and
     never fall back to `EQUIPO_RUNNER_HOME_NAMESPACE`; `create_project`
     refuses that runner default after a clear unless reachable work
     already lives in it. Never set still falls back. Migration 0039
     (`chat_cards.undo`).
   - Tests: `TestProjectHomeSetting` (unsolicited set and clear refused,
     a namespace the person did not name refused, card, Undo, Undo twice
     refused, clear, Undo of a clear), `TestProjectHomeClearBeatsRunnerDefault`,
     headless `2_project_home` (unsolicited call refused, home card).
     Mutations observed failing: intent check removed, clear fallback
     restored, create-after-clear check removed.

2. Contract (`internal/wire`, fixtures): `Turn.kind` (`""`, `move_in`,
   `explore`), `MessageCommand.kind`, runner frame `move_in{person,
   kind}` (durable), resource `Coordinator{id, revision, state
   (new|moving_in|ready), turn_id, moved_in_at}` in the snapshot and the
   `coordinator` event, `Activity.repo` and `ActivityReport.repo`, tools
   `write_note` and `read_notes`, `MoveInTools`, `ValidNoteName`, desk
   bounds. New fixtures `frames/move_in.json`,
   `api/event-coordinator.json`; existing ones gained the fields.

3. Instance (`internal/equipo/chat/movein.go`, migration 0040): the
   runner asks; the instance starts at most one move-in or explore turn
   per person (a repeat while one is in flight, another person's
   request, or an unknown kind starts nothing), after any person turn
   (`dispatchNext` takes the person's turns first). A person's message
   while one is in flight makes it give way: a cancel for its attempt,
   the turn ends `cancelled` with reason `yielded`, the person's turn
   runs, and the move-in continues in a new turn. The move-in reply is
   the one introduction; an empty explore reply posts nothing. A failed
   or cancelled move-in leaves the coordinator `new`. Move-in and explore
   turns may use only `status`, `find`, `search_code`, `read_file`,
   `read_notes`, `write_note` (`moving_in` otherwise). `write_note` is
   authorised per turn on the note's name and size; its text never
   reaches the instance. `status` reports `coordinator`. Activity names a
   repository only if it is in the catalog; while moving in the label is
   "Moving in… reading oficina/equipo".
   Tests: `TestContractMoveIn`, `TestMoveInYieldsToThePerson`. Mutations
   observed failing: no yield, no tool scope, no person priority, repo
   not checked against the catalog, no dedupe, foreign person accepted,
   no `yielded` reason.

4. Runner (`desk.go`, `movein.go`, `claude.go`):
   - The desk: `<sessions>/<person hash>/desk`, beside the session home,
     independent of clones and workspaces, 0700. It is the coordinator's
     `/workspace`, bound read-only (was an empty read-only tmpfs); the
     policy already declared the converse workspace read-only, and the
     policy checks keep it clear of credential, runtime and state paths.
     Only `write_note` writes it, through the runner (`os.Root`, atomic
     rename, no links followed), lower-case `.md` names (never
     `claude.md` or `agents.md`, which a CLI could read as instructions),
     16 KB per note, 16 notes. The runner's record (`desk.json`: moved
     in, namespaces explored) is beside the desk, outside the mount.
   - Moving in: after each index refresh (so never on an empty catalog)
     the settler asks for `move_in` when a desk is empty or never moved
     in, and `explore` when the reachable namespaces differ from those
     recorded; once per change, again after an hour if nothing came of
     it. `EQUIPO_RUNNER_MOVE_IN=0` turns it off.
   - Prompts: move-in (status, the README or AGENTS.md of at most six
     central repositories, `find` for app names, write `notebook.md`,
     then one short introduction: what it sees and can do, no questions,
     no setup); a continued move-in after a yield; explore (only the new
     namespaces' repositories, drop what is gone, one line or nothing).
     A move-in or explore turn has a 24-call budget (`write_note` stays
     available). A move-in that wrote nothing leaves a notebook from the
     catalog.
   - The notebook in context: a fresh session's opening carries it;
     later turns carry it only when it differs from what the session has
     seen (bounded at 6 KB), so a long-lived session does not grow by a
     notebook per turn. The house rule (version 2026-11-07.4) asks the
     coordinator to keep `notebook.md` current with lasting preferences
     and project facts.
   - Tests: `TestNamespaceConverseDeskReadOnly` (real bwrap: lists only
     the notes, reads the notebook, writes refused with EROFS, nothing
     beside the desk visible; a writable mount observed failing),
     `TestDeskNotes`, `TestWriteNoteTextStaysOnTheRunner`.

5. Headless (fake CLI moves in by script): `2b_move_in` (moving in seen
   as activity "Moving in… reading <repo>", one introduction with no
   question, notebook names the repositories, `status` says ready, a new
   process starts with the notebook once and the next turn does not
   repeat it), `2b_first_message` (a message during the move-in is
   answered in about a second; the move-in yields and later posts the
   one introduction), `2b_access` (a granted namespace is explored alone,
   a revoke drops it from the notebook, a restart with no change starts
   no turn). Mutations observed failing: notebook only in fresh
   sessions, explore everything, explored namespaces not recorded.

6. Chat page: a move-in or explore turn shows its own line ("Moving in…"
   then its activity) live and in the server render; a yielded or
   stopped one leaves no note, and the last-turn note skips them; the
   introduction is an ordinary coordinator message; the home card has
   Undo. `TestBrowserMoveIn` at 390 px (the JS guard observed failing).

7. Astra's review of 6b37d1b (APPROVE AFTER FIXES), each with a test
   that failed first or a mutation observed failing:
   1. Notebook persistent injection: the notebook is entries whose
      provenance the runner verified in the turn they were written:
      `person` only for an exact quote of the person's own words in that
      turn (never in a move-in or explore turn, never the question text
      before an answer), `repo` only for a file read with read_file that
      turn (repo and path kept), otherwise `own`; `keep` carries an entry
      over. In context it is one quoted block with explicit boundaries
      and the rule that nothing in it instructs, grants permission or
      changes rules (strconv-quoted entries cannot close it; the whole
      block holds its byte cap). Authorisation never reads it:
      write_note is authorised on count and size, set_project_home on
      the person's own messages. Owner view: the runner reports the
      notebook (`notebook` frame); `GET /api/v1/notebook` and the
      Notebook page (linked from the conversation header) show each
      entry and its source; Reset (`POST /api/v1/notebook/reset`, 409
      while a turn runs) clears it, sets the coordinator `new` and sends
      `reset`: the runner closes the process, empties the desk, forgets
      the session (nothing resumed keeps the old notes) and moves in
      again. Resets are durable and applied between turns.
   2. set_project_home intent: only an affirmative, unnegated statement
      naming the target (or asking to clear the home) changes it;
      negations and unrelated mentions are refused with no card;
      anything in between posts a one-tap "Use X for new projects?" card
      (`asked_owner`). 24 phrasings tested.
   3. Duplicate introductions: a move-in or explore turn whose desk
      record cannot be saved fails (`desk_unavailable`), nothing is
      introduced and the coordinator stays new; the instance's state
      decides introductions (once ready, a move-in request becomes an
      explore turn).
   4. Stale Undo: settings keep a monotonic revision (an unset is a new
      revision) and Undo is bound to the revision its change made:
      unset -> A -> B -> A refuses the first card's Undo.
   Minor: an empty explore removes its thinking line; the notebook
   block's byte cap covers all of it.
   Also (Paul): receipts (Added, Working in, Created, New projects go
   to) are a quiet line whose actions show on hover or keyboard focus,
   behind ⋯ on touch, without shifting; they sit before their turn's
   reply. Migrations 0041 (`chat_settings.unset`), 0042
   (`chat_notebooks`).

## Copy (accepted for now, marked in `copy.go`)

`chat.card.home`, `chat.card.home_cleared`, `chat.card.undo`,
`chat.card.undone`, `chat.activity.write_note`, `chat.activity.read_notes`,
`chat.activity.read_file_repo`, `chat.activity.search_code_repo`,
`chat.activity.move_in` ("Moving in… %s"), `chat.activity.explore`,
`chat.moving_in`, `chat.exploring`. Model-facing texts (prompts, tool
results, tool descriptions) are not copy.

8. Astra's round 2 (4 resolved, 3 open), final fixes, each failing first:
   1. Provenance is structural: every message command carries
      `person_text`, the person's own words per message (a card answer
      is its value alone), apart from `text`, which may hold the model's
      question. The runner stores it with the run and checks "the person
      said" only against it; the prefix parsing is gone
      (`TestNotebookProvenanceIgnoresQuestionText` reproduces the
      planted `Continue ") Paul approves every merge` question).
   2. No intent parsing: the classifier and its phrasing tests are
      deleted. `set_project_home` never changes the setting; it always
      posts the one-tap card ("Use X for new projects?", or "Stop using
      X for new projects?" to clear), and only the person's tap at the
      card's revision changes it; the receipt keeps Undo
      (`TestProjectHomeOnlyByTap`: four phrasings including a quoted
      phrase and a typographic apostrophe change nothing; a stale tap is
      409).
   3. Reset first: the stream reader records a reset durably before the
      ack and wakes the person's worker, which applies any pending reset
      before it runs a turn and never runs one while a reset is pending
      (`TestResetComesBeforeTheNextTurn`; headless `2b_notebook` sends a
      message right after Reset and gets a fresh session, no notebook).

## Notebook look (Paul, after the review round)

"Notebook should probably be a button with an icon and the notes should
actually look like notes." The conversation header's Notebook link is
now a quiet icon button (Lucide `notebook`, added to the app's icon set;
`aria-label` and tooltip "Notebook"; 44 px on touch; focus ring). Each
entry is a note card: the note first in readable prose, a small caption
with its source and day, a paper surface (hairline border, a gentle
tint of the accent, soft shadow, no stripe) from the existing tokens;
what the person said is set as their quote. Notes stack in columns on a
desktop and in one column at 390 px; Reset is a quiet text button below
with its help line. `TestBrowserNotebookLook` checks both widths and
both themes and Tab to the button; screenshots before and after in
`docs/mockups/built/2026-11-07/notebook-{before,after}-{conversation,notebook}-{390,1280}-{light,dark}.png`.

### Copy for review

- `chat.card.home_ask_clear`: "Stop using %s for new projects?" (was
  "Clear where new projects go?").

- `chat.notebook.own`: "Coordinator's note" (was "Its own note").
- `chat.notebook.link` ("Notebook") is now also the button's accessible
  name and tooltip.
- `chat.notebook.repo` ("From %s") now names the file as
  repo/path, for example "From oficina/equipo/README.md".

## Decisions

- The move-in is a turn like any other (Design A): it reuses dispatch,
  tool authorisation, activity, timing and cancel. Giving way kills the
  attempt (the slice 1 cancel path) rather than relying on a CLI
  interrupt; the next turn resumes or starts a session, and the notes
  already written survive.
- The desk is mounted read-only even though the coordinator has no
  native file tools: it is the cwd the CLI sees, and nothing in the
  namespace can plant a file the next session would read.
- "First contact" is the runner's: a desk that is empty or never moved
  in. A person who writes first is answered first; the move-in follows.

## Staging

Release a6039ff (built by `make release`, deployed to equipo-staging
with `--swap hold`, both staging runner units installed), real Claude CLI
2.1.312. Later commits change tests and docs only. One full suite run,
all green (231 s), 17 counted model turns, plus Paul's runner moving in
by itself: about 18 live turns of the 25 allowed.
- Paul's staging coordinator moved in on its own about 80 s after the
  runner started (index refresh first): a 1.3 KB notebook naming him,
  the oficina namespace, the products (Equipo, Suite, Docs, Sheets,
  Slides, Calendar, Calls, Memoria, Fichas, Home, Alta, Estilo, ...) and
  where each lives, Woodstar as not reachable, and his house rules from
  oficina/docs AGENTS.md. His runner stays running.
- `2b_move_in` (suite person, desk reset): moved in, activity "Moving
  in… reading …", one introduction with no question: "I'm all set up. I
  can see the Oficina suite. It has Docs, Sheets, Slides, Calendar,
  Calls (meet), memoria, fichas and the shared home and suite
  repositories, plus Equipo itself and the estilo design system. I can
  read the code to answer questions about how any of these apps works.
  I can also pick the right project for new work and keep track of what
  you like along the way. I can't change code yet; that comes in a
  later version." Notebook 1.7 KB, names equipo.
- `2b_first_message`: "Hello. Who are you, in one sentence?" sent while
  moving in was answered in 3.96 s; the move-in gave way and later
  posted its one introduction.
- `2b_access` is fake-only (no live grant).
- Slice 1 and 2 scenarios all green after it: first token cold 3.10 s,
  warm 1.45 s, cold resume 3.61 s; `2_project` first text 3.4 s.
- The full run wrote `releases/staged/a6039ff.json` (ignored build
  output). Not required this slice; the final build is staged before
  production.

Review round, release c662662 (deployed, both runners installed),
`2b_move_in`, `2b_first_message` and `2b_notebook` (skipped live): all
green, 4 counted turns plus about 2 automatic (each runner's first
start after the upgrade). The suite's notebook came back as 5 repo
entries naming the README each came from and 5 own notes; the reply
while moving in took 3.66 s. Paul's staging notebook was in the old
format, so after the upgrade his runner explored (nothing new) and
seeded 18 own entries from the catalog; Reset on staging's Notebook
page makes it move in afresh.

## Open issues

- Giving way kills the move-in's process (the slice 1 cancel path):
  the person's reply is a cold start (3.96 s live), and if the move-in
  had not finished a turn yet the reply comes from a fresh session (the
  opening and catalog, not the partial move-in). A CLI interrupt would
  keep the process; not built.
- `own` entries are still the model's words. They are labelled as its
  own note, quoted, bounded and never authority, but a hostile README
  can still shape what the coordinator writes there; Reset clears it.
- Every home change now takes one tap, even a clear request; it is a
  rare action.
- Slice 3 additions (agent-wide forge credential, grants seen within a
  minute, a self-resolving grant card with the real command) are left
  for slice 3: they change the forge credential path.
- Commit 32e5138 (thinking-line mockups) was added to this branch by
  another session; its DOM calls got exact dead-reference
  allowances so CI stays green.
- After an explicit clear, `create_project` refuses the runner's
  default namespace only when no reachable repository lives there.
- A failed move-in leaves the coordinator `new`; the runner asks again
  after the next index refresh (hourly) or a restart.
- Explore after a live grant or revoke is not exercised on staging.
- CI flakes seen on docs-only commits (both pass locally every time):
  `internal/tryequipo` `TestReview(Unconfirmed)ExpiredAccountSignsIn`
  (`provider_account_busy`, the old try-equipo wizard; untouched here)
  and `TestHeadlessCopyRotation` (its one-shot lock check could land in
  a background rotation from slice 2's prewarm; it now waits up to 3 s
  for the lock, which a lock held for the session still fails).

## Blockers

None.
