# Slice 4 progress: Review and checks

Branch `thin-v1-slice4` from `thin-v1-slice3` (8d87205), with
`thin-v1-thinking` merged at 71ce51b (a fast-forward: it already held
slice 3). Spec: `docs/superpowers/specs/2026-11-06-equipo-thin-v1.md`
§§0-5, 7, 8 row 4, plus the coordinator's additions of 2026-11-07 (Paul's
staging feedback): task links in replies, a live receipt line, the
sidebar on API v1, the outcome-level coordinator voice, and a details
view with "ask the implementer". Conventions and scripts as in
`SLICE1-PROGRESS.md` to `SLICE3-PROGRESS.md`.

## Done

1. Contracts (`internal/wire/tasks.go`, fixtures): specialists
   `checks` and `review`; checks outcomes `passed`, `failed`, `none`
   ("No checks found", not a failure) and `cannot_run` (with a reason:
   `needs_macos`, `needs_network`, `checks_timeout`,
   `checks_unavailable`; never a pass); verdicts `approve` and
   `changes_requested`; review labels `other_family`, `same_family`,
   `same_account`; `Task.NeedsYou` (`merge`, `fix_rounds`,
   `review_blocked`, `retry`); `wire.MaxFixRounds` 2. `Step` gained
   `round`, `family`, `account`, `verdict`, `review_label`, `findings`,
   `checks`, `gate`, `exit_code`; `Task` gained `candidate_sha`,
   `checks`, `checks_reason`, `verdict`, `review_label`, `needs_you`,
   `fix_rounds`, all computed from the steps beside the newest pushed
   SHA. Dispatch gained `candidate_sha` (the SHA a checks or review step
   judges, or the commit a republish pushes), `republish`,
   `from_attempt`, `avoid_account`, `round`; step reports gained the
   results and `output` (the checks' last 200 lines). Frames
   `watch_merge` (instance to runner, durable) and `merged` (runner to
   instance, durable). `GET /api/v1/needs-you` (`TaskList`). New
   fixtures: `api/task-ready.json`, `api/needs-you.json`,
   `frames/watch_merge.json`, `frames/merged.json`; the native apps
   build against them.

2. Instance (`internal/equipo/chat/review.go`, migration 0044):
   `advance` runs after every step report and on every sync. A pushed
   candidate gets a checks step, then a review step, each dispatched
   with the exact SHA; a judgement counts only for the SHA it was asked
   to judge and only when whole (checks: outcome, gate and exit agree;
   review: verdict and label). Checks that fail or review that asks for
   changes send an automatic Engineering fix round on top of the
   candidate (same branch, base the candidate) with the output tail or
   the findings, at most two; then Needs you. Ready to merge only when
   branch, SHA, checks (or an honest "not run, reason") and approval
   refer to one SHA; a new candidate leaves the old judgements behind
   (`progressOf` resets them). The runner is asked to watch every newest
   pushed candidate; a `merged` report for it makes the task Done (an
   older candidate's is ignored; a cancel stops the watch). Retry of a
   failed review or checks step judges the same SHA again; Retry of a
   failed push republishes the recorded commit (`republish`, chained to
   the attempt that made it) instead of running Engineering again. Task
   slugs are cut at a word boundary. Tests: `TestContractReviewAndChecks`,
   `TestContractFixRoundsCap`, `TestContractReviewBlockedAndRetry`,
   `TestContractSyncJudgesOldCandidates`; `TestTaskBranch` gained the
   word-boundary cases.

3. Runner (`internal/runner/thin/judge.go`, `merge.go`):
   - Checks: a fresh task tree of the exact SHA; the gate in Amadan's
     own order (`.amadan/ci.d/` steps in order, else `.amadan/ci`, else
     a `make ci` target, else "No checks found"), read without following
     links out of the tree; a change touching Swift, Objective-C or Xcode
     files (or a gate calling Xcode's tools) on a Linux runner is
     `cannot_run`/`needs_macos` without running anything; otherwise the
     tree gets a `.git` of its own at exactly the SHA (shallow, one
     commit, no remote, no hooks) and the gate runs in the containment's
     check profile (no network, no provider home, private `/tmp`, the Go
     toolchain and module cache read-only, `GOPROXY=off`), with exit code
     and last 200 lines recorded. A failure that is the network missing
     is `needs_network`, a timeout `checks_timeout`; neither is a pass or
     a fail. `BuildCheckPolicy` takes the Codex binary and the Go trees
     as optional.
   - Review: a fresh read-only tree of the exact SHA, action `inspect`
     (specialist Reviewer: Read, Glob and Grep only, no shell or write
     tools; the read-only mount and `ReadPermission` behind it), fresh
     session, the diff from the task's base in the prompt, the verdict
     through `submit_review` (verdict, summary, findings with file and
     line). No verdict is `no_verdict`. Account: another family when
     the runner can run one (none yet: the Codex step path is slice 5),
     else another Claude account (`same_family`), else a fresh session on
     Engineering's account (`same_account`).
   - Engineering, Review and checks share one launch path
     (`specialistRun`); the step reports family and account.
   - Merge watch: `watch_merge` is recorded per task; about once a
     minute the runner reads each watched repository's default branch
     tip (one `ls-remote --symref`), and only when it moved fetches and
     checks the candidate is an ancestor of the tip, or (a squash) that
     every path the task changed reads at the tip as at the candidate.
   - A failed push keeps its private repository until an attempt of that
     step publishes, so a republish finds the commit.
   Tests: `TestFindGate`, `TestNeedsMacOS`,
   `TestLineTailKeepsTheLast200Lines`, `TestVerdictOf`,
   `TestReviewerAccount`.

4. Fake CLI: `[Equipo: review]` steps call `submit_review`
   (`review:approve`, `review:changes:`, `review:need:`, `review:silent`,
   `review:write:`, `reviewsleep:`).

5. Headless (fake CLI in real bwrap, local forge; the sample repository
   has a `make ci` gate and an iOS file): `4_review` (scenario 2
   complete: Engineering pushes, the repository's checks fail on that
   SHA, a fix round mends it from their output, review asks for one more
   change, a second round makes it, checks pass and review approves the
   newest SHA: ready to merge, Needs you; the checks' log holds the SHA
   from `git rev-parse HEAD` inside the namespace; the person updates
   main in the forge and the task is Done about a second later) and
   `4_checks_honest` (an iOS change: checks `cannot_run`/`needs_macos`,
   no exit code; review approves and its attempt to write was denied;
   ready to merge, honest about the checks). `4_witness` is staging
   only.

6. Coordinator voice and task links (Paul, 2026-11-07): `record_task`,
   `start_task` and `read_task` results carry the task's title and its
   link (`/tasks/<id>`); the standing prompt (house rule 2026-11-07.7)
   asks for outcome-level replies ("Got it, I've logged [Swipe back
   doesn't work](/tasks/tk...) and Engineering is on it."), no file
   paths, line numbers or code mechanics unless asked, the diagnosis on
   the task with `add_finding`, and a task always named as a markdown
   link, never "the task card". The chat renderer allows only task and
   project pages as same-origin links (`TestSiteLinksOnlyTasksAndProjects`);
   `TestOpeningOutcomeLevelVoice`; the contract test checks the links in
   the tool results.

7. UI:
   - Task card (receipt): the stage moves live (In progress, Pushed
     branch at SHA, In review with "Running checks…" and "Reviewing…",
     then Ready to merge with "Checks passed (make ci)" or the honest
     "Checks can't run here (needs macOS)", "Approved (same family, same
     account)", and one prominent button "Open on Amadan to merge" for
     the task's creator only); Needs you lines for the fix-round cap and
     a blocked review; Retry and Cancel stay behind hover, focus or ⋯.
   - Task page: each step by specialist and attempt (fix rounds named),
     its result, summary, review findings with file and line, and log
     tail; the checks' 200 lines through `GET /api/v1/steps/{id}/log`.
   - Tasks page `?needs=you` is Needs you.
   - Sidebar on API v1 (`rail.go`, `nav-stream.js`): Conversation, Tasks
     (active count), Projects, Needs you, then Specialists: Engineering
     and Review (checks show under Review) say "working" with the task's
     title linked while a step runs, else "idle"; Product, Design and
     Copy are hidden; Team: People. Counts are quiet (nothing at zero).
     Journey, Playbooks, Templates, Preferences, the old "Your
     coordinator", Connections and Settings (old accounts and budgets)
     are out of the nav. It follows the event stream on every page and
     swaps in `GET /nav/rail` on task, step and project events.
   Tests: `TestPagesTasksAndProjects` (judged card, merge decision only
   for the creator, Needs you page, steps on the task page),
   `TestPagesRail` (no old page linked from any page's sidebar;
   Engineering working on a linked task with the count),
   `TestChatNavigationStatus`; browser `TestBrowserReceiptFollowsReview`
   (390 touch: In progress, pushed, In review, checks and review lines,
   Ready to merge and the button, no reload) and
   `TestBrowserRailFollowsWork` (1280 and 390: Engineering working with
   the title and Tasks 1, then Review, then idle and Needs you 1, no
   reload).

8. Mutation checks (five, risky paths): candidate reset on a new SHA,
   the judged-SHA check, the fix-round cap and the macOS rule were each
   observed failing a test. `ReadPermission` replaced by the Engineering
   callback survived: the Reviewer policy has no Write or Edit tool, so
   the permission layer refuses it first; `ReadPermission` is defence in
   depth.

9. Staging (releases 2e53061, then fe298b5; built by `make release`,
   deployed with `--swap hold`, both staging runner units installed,
   about a minute of change-over each time), real Claude CLI 2.1.312:
   - Woodstar witness, suite task `tklkbx5vid3y` (branch
     `equipo/tklkbx5vid3y-ios-edge-swipe-to-go-back-doesn-t-work-o`, no
     new message): judged on its own after the upgrade's first sync.
     Checks on 82a4a0cc: `cannot_run`/`needs_macos` ("Checks can't run
     here (needs macOS)", nothing run, never a pass), at once. Review on
     82a4a0cc (claude-a, `same_account`, 29.6 s): approve ("The
     Coordinator now acts as the outer controller's pop-gesture delegate
     and allows the swipe only when the timeline is pushed..."). Ready to
     merge, Needs you `merge`, everything on 82a4a0cc; about 40 s after
     the runner restarted.
   - Paul's task `tks6kwzzdngr` (his runner): checks `needs_macos` on
     ad2432e2; review asked for changes; the automatic fix round pushed
     4f0cfe4a in about 10 s; its checks then failed `clone_failed` (the
     hub refused the fetch while both restarted runners re-indexed; the
     fetch now retries with backoff, in fe298b5). It waits at Needs you
     `retry` for Paul's Retry; I did not act on his task.
   - `oficina/suite` scenario (`4_review` live, suite person, one
     message: "In the oficina/suite README, the paragraph under "What is
     built, and what is not" breaks mid-sentence after "S6 is step 4,".
     Please fix that line break."): task `tk2jhc6z46ar`, branch
     `equipo/tk2jhc6z46ar-fix-line-break-in-readme-what-is-built` (cut at
     a word). Engineering 8.5 s, candidate b9bc2406; checks ran the
     repository's own `.amadan/ci.d` gate (gofmt, vet, build, test) in
     the containment on b9bc2406: passed, exit 0, 9.5 s; review 7.7 s
     (`same_account`): approve. Ready to merge 38.9 s after the send, all
     on b9bc2406. The reply: "I've logged [Fix line break in README "What
     is built" paragraph](/tasks/tk2jhc6z46ar) in suite, and Engineering
     is fixing it now. You were right: "step 4," sits alone on its own
     line, so they're rejoining the paragraph without changing any
     words." (outcome level, linked, no path or line).
   - Nothing was merged and no pull request opened; the person merges on
     Amadan.

CI: green at fe298b5 (the code; this log's commit changes docs only),
after two red runs fixed on the way: the old engine suites asserted the
old sidebar, then a variable left unused.

10. Review round 1 (Astra, REQUEST CHANGES, six Important). Each fix has
    a test that failed first:
    1. Readiness holds only while the task branch is at the judged SHA.
       The runner's watch reads the task branch's head with the default
       branch's tip (one `ls-remote`), on the minute check and after every
       sync, and reports any change (`branch` frame, durable). Away from
       the newest candidate (or gone), the task leaves Ready to merge, its
       checks, verdict and label are empty, `branch_head` names the new
       head and Needs you is `branch_moved` ("Needs you: the branch moved
       on Amadan after it was checked"); the card shows none of the old
       judgements beside the branch's link. Back at the SHA, it is ready
       again. A report about an older candidate is ignored.
       `TestContractBranchMovedInvalidatesReadiness`; headless `4_review`
       pushes over the approved SHA in the forge and back.
    2, 3. The squash check reads paths NUL-delimited and compares whole
       tree entries (`diff-tree` of the candidate against the tip: mode,
       type, object, or absence); any git failure is unknown, never
       merged. `TestMergedSquashCheckIsConservative` (Astra's `café.txt`
       and executable-bit reproductions, squashed and unmerged deletes,
       an unreadable base).
    4. `needs_network` is a known step reason. `TestRunnerReasonsAreKnown`
       reads every reason literal the step code emits (fail, done,
       reason fields, `reasonFor`) from the source and checks it against
       `wire.StepReasons` (observed failing without `needs_network`).
       Fallback (decided): a reason the instance does not know is recorded
       as `unknown`, never refused, so a newer runner's durable report is
       acked once instead of closing the connection on every replay.
       `TestContractCannotRunReasonsAreDelivered` (delivery, ack, review
       follows, for `needs_network` and an unknown reason).
    5. Fetches have deadlines: two minutes per attempt (four attempts with
       backoff), ten minutes for a judge's preparation as a whole and for
       Engineering's fetch; git and its remote helper run in their own
       process group, killed together, with a bounded wait.
       `TestJudgeFetchHasDeadlines` (a remote that accepts and never
       answers: `clone_failed` in under a second instead of hanging).
    6. The review diff is read through a bound (the command is stopped
       past 48 KiB), and the checks tree's objects stream `rev-list |
       pack-objects | index-pack` with a 2 GiB bound; `ls-remote` and the
       merge check's git output are bounded too.
       `TestOversizedCandidateStaysOutOfMemory` (a 16 MiB candidate: under
       8 MiB allocated for each; before, the diff alone allocated 642 MiB
       for 96 MiB), and the pack bound refuses an oversized candidate.
    Size exemptions: `internal/runner/thin` 7200, `internal/equipo/chat`
    5300; time record for `internal/runner/thin` 30s.

## Live runs (budget: 10 coordinator turns, 4 Engineering steps, 6 Review steps)

Used: 1 coordinator turn (the suite scenario), 2 Engineering steps (the
automatic fix round on Paul's `tks6kwzzdngr`, the suite's
`tk2jhc6z46ar`), 3 Review steps (`tklkbx5vid3y`, `tks6kwzzdngr`,
`tk2jhc6z46ar`). No automatic move-in or explore turn ran.

## Decisions

- The automatic fix round is sent by the instance, not by a coordinator
  model turn: deterministic, no turn spent; the coordinator sees it with
  `read_task`. Checks run before review; failed checks go straight to a
  fix round (no review spent on a failing SHA).
- Checks that cannot run here still lead to review, and a task may be
  ready to merge with "Checks can't run here (needs macOS)": the person
  decides. It never shows as a pass.
- Gate order follows Amadan (`.amadan/ci.d/`, `.amadan/ci`, `make ci`):
  several Oficina repositories (suite, sheets, home, docs, estilo) have
  only `ci.d`, which the brief's two-item list would call "No checks
  found".
- The checks tree carries its own `.git` at the exact SHA because gates
  ask git (`git ls-files` in oficina/suite's gate); the namespace may
  change it, and the tree is thrown away after.
- Checks output is recorded raw (last 200 lines): it comes only from
  inside the namespace, which sees no credential or host path.
- Another family: the thin runner runs Claude only until slice 5 builds
  the Codex step path and proves a live Codex refresh, so Review labels
  are `same_family` or `same_account` for now.
- Needs you is computed from the stage and the steps, so every client
  derives the same; `merge` (ready) is a Needs you item.
- The rail's Review line also covers checks.
- Merge detection watches every newest pushed candidate (not only ready
  ones), so a merge at Needs you also ends the task.
- Size exemptions raised: `internal/runner/thin` to 7000 (judge and
  merge share the Engineer's launch internals), `internal/equipo` to
  12000 (sidebar and card lines), until the slice 7 sweep.

## Open issues

- Version skew at deploy: for about a minute between the instance
  deploy and the runner install, the old runners refused the new
  `watch_merge` frame and reconnected in a loop (the frame stays
  durable and is delivered once the new runner connects). The
  production cutover installs the runner right after the instance, as
  it does; a runner that skips unknown durable frames would remove the
  loop.
- The hub refuses bursts of git requests from one agent; both staging
  runners re-index every repository after a restart, and checks or
  review fetching then can fail. The judge fetch retries four times
  with backoff; Paul's `tks6kwzzdngr` needs his Retry.

- Ask the implementer (Paul, 2026-11-07): the task page shows the
  findings, each step's summary, review findings and checks output. A
  question from the task thread that resumes the step's own session
  read-only is not built: it needs step sessions kept per task (today a
  step's session is a fresh `--session-id` per attempt, its runtime home
  deleted on exit), a read-only resume action, and thread replies as a
  new runner frame. First item for the next slice.
- Squash merges are detected by comparing the changed paths at the tip;
  a later commit that touches the same files before the minute check can
  hide it until the next change of the tip.
- A gate needing modules the runner's module cache lacks reports
  `needs_network`, not a result.

## Copy for review

Accepted for now with the existing marker in `copy.go` and listed in
the plan 3 inventory:
- `nav.working` "working", `nav.more` "+%d more"
- `work.specialist.engineering` "Engineering", `.checks` "Checks",
  `.review` "Review"
- `work.step` "%s, attempt %d: %s" (was "Engineering, attempt %d: %s"),
  `work.steps` "Steps" (was "Engineering"), `work.round` "fix round %d"
- `work.checks.passed` "Checks passed (%s)", `.failed` "Checks failed
  (%s, exit %d)", `.none` "No checks found", `.needs_macos` "Checks
  can't run here (needs macOS)", `.needs_network` "Checks can't run here
  (they need the network)", `.checks_timeout` "Checks didn't finish in
  time", `.checks_unavailable` "Checks can't run on this runner",
  `.running` "Running checks…"
- `work.review.approve` "Approved (%s)", `.changes_requested` "Changes
  requested (%s)", `.running` "Reviewing…", `.other_family` "another
  model family", `.same_family` "same family", `.same_account` "same
  family, same account"
- `work.merge` "Open on Amadan to merge"
- `work.needs.fix_rounds` "Needs you: still not approved after two fix
  rounds", `work.needs.review_blocked` "Needs you: the review ended
  without a verdict"
- `work.reason.no_verdict` "the review gave no verdict",
  `.candidate_unavailable` "the commit was not on Amadan",
  `.account_unavailable` "no model account was ready"
- `work.needs.branch_moved` "Needs you: the branch moved on Amadan
  after it was checked" (review round 1)
- `work.review_findings` "Review found", `work.needs_empty` "Nothing
  needs you right now."

## Blockers

None.
