# Equipo: exploration tasks

Status: 2026-11-12, revision 2.1, built. Revision 1 (33afeb9) drew NOT
READY from Astra round 1 (§11); the coordinator approved the cuts in §10.
Revision 2 drew READY AFTER FIXES from round 2, all eight findings
mechanical; they are folded in (§12). Drafted by
Claude (Opus 5.5) on `exploration-tasks` from main 7140df3. Builds on
thin v1, merge authority, release preview (protocol 9) and needs-you
triage.

## 0. Why

Paul, on the barber mockups task: "Why is it trying to merge mockups
anyway?" Equipo has one kind of task, a change that ends in a merge.
Mockups, prototypes, design options and spikes are exploration: they end
at a preview and Paul's choice, never a merge.

Staging's `tk5fen4uajpn` (paulca/threatmin, "Create two clickable barber
app mockups") is Ready to merge: checks passed, Review approved with a
preview config, its preview failed `preview_failed` (no credential) and
its merge failed `merge_failed`. Not merged.

## 1. The kind

- `chat_tasks.kind`: `change` ("" reads as change; today's behaviour) or
  `explore`. Each step records the kind it was dispatched under
  (`chat_steps.kind`).
- **The coordinator sets it** on `record_task` (`kind`, optional,
  default `change`). Its house rule: mockups, prototypes, design options
  and spikes are `explore`; anything meant to ship is `change`.
- **Paul switches it** on the task page (`POST /api/v1/tasks/{id}/kind
  {kind, revision}` and the page form). Only the creator, an owner, at
  the task's current revision, and only **at rest**: the task is not
  ended, cancel-requested or merging, no step of it is queued or running
  (previews included), and no merge step is unfinished. One transaction:
  - to `explore`: open merge cards withdrawn; `merge_asked`, `ready_sha`
    and `merge_eligible` cleared; Ready to merge goes back to In review;
  - to `change`: open direction cards withdrawn;
  - either way `direction_asked` is cleared, a thread note says what
    changed, and `advance` runs.
- **Judgements count only for their kind.** `progressFor` takes a Review
  verdict only from a Review dispatched under the task's kind, or under
  `change` (a change Review is at least as strict). So a task switched to
  `change` gets checks and a change Review on its candidate before the
  gate ever decides; switched to `explore`, an earlier change approval
  stands.

## 2. The explore flow

`advanceTask` routes an exploration to `advanceExplore` **first**, before
the merge handling, so merge steps (the barber task's failed one
included) never steer it, and nothing of it reaches Ready to merge.

1. **Engineering** builds. Its brief (instance-written) says this is an
   exploration and requires `release/preview.json` (`{"output":
   "<dir>"}`) naming committed static output.
2. **No checks.** Review reads the candidate next. Its brief says it is
   an exploration: judge whether it does what was asked and is safe to
   publish as a static preview, not production readiness. Changes
   requested take the ordinary fix rounds, then needs-you triage asks as
   for any task.
3. **Approved:** the release preview is scheduled as today (approval
   with `has_preview`, protocol 9; previews stay ancillary), and at once,
   without waiting for it, the **direction card**: one per candidate
   (`direction_asked`), in the creator's conversation, "Which direction
   for %s?", answers **Build this one**, **Try again** (with a note) and
   **Drop it**. `NeedsYou` is `direction`. The preview line is filled in
   when the card or task is shown: the candidate's deployed preview link;
   else the branch on Amadan with "Previews aren't set up yet" (the
   primary, at protocol 10, reports previews off) or "There's no preview
   of this version" (anything else).
4. **An answer** is valid only on an open card at its revision, for the
   creator, while the task is an exploration, its newest candidate is
   `direction_asked`, approved under the rules of §1, the branch is at it,
   and no step is queued or running; else 409 with the card. A new
   candidate, a branch move, an ending and a kind switch withdraw the
   card.
   - **Build this one**, in the answer's transaction: a new `change` task
     of the creator in the same project (inserted directly: no
     similarity check, no housekeeping pass), title "Build: %s", brief
     this task's brief and a paragraph naming the explored branch and
     commit to read for the design. It starts **from the default
     branch**, like any task, and is started at once (its Engineering
     step dispatched). `explored_from` on it, `built_as` on this task,
     which ends `done`. A second answer finds the card answered (409);
     `built_as` set also refuses.
   - **Try again**, with Paul's note (required, at most 1,000 bytes):
     another Engineering round on the candidate with the note in its
     brief (`chat_steps.note`). Paul's tap: never budgeted.
   - **Drop it:** the ordinary cancel of a task at rest. The branch stays.
5. **Never a merge.** `mergegate.Decide` returns `never` for an
   exploration first, a person's Merge included (`Inputs.Explore`);
   `startMerge` refuses one too; `mergeOffered` is false for one.

## 3. Triage, the sweep and duplicates

- `direction` is a genuine decision: `triage.Classify` leaves it in
  Needs you with no recommendation. The stall sweep's kick runs
  `advance`, which for an exploration is `advanceExplore`.
- **Kinds never meet as duplicates.** `similarTasks` (record_task's own
  check and its `DuplicateOf`), the duplicate detectors' view and the
  combine and link actions (`foldable`, `hkLink`, checked again in the
  transaction) only pair tasks of the same kind.

## 4. The barber task, once

`Store.ExploreOnce(ctx, "tk5fen4uajpn")` at start-up, after re-triage:
one transaction, a trusted bootstrap entry (no person principal):
- a ledger row (`chat_housekeeping`, detector `kind_switch`, key
  `explore:<task>`) exists: nothing (it already ran);
- the task is missing, ended or merged: the row is written (`expired`,
  reason `ended`), nothing else;
- the task is merging, cancel-requested, or a step is queued or running:
  nothing is written (transient; the next start looks again);
- otherwise the same internal switch as Paul's (§1, without the person
  and revision checks) and the row (`done`), together.
Paul switching it back later is never undone: the row exists.

## 5. Wire: protocol 10

`wire.ProtocolExplore` (10) becomes `ProtocolCurrent`:
- `Capabilities.previews` (bool, omitempty): the primary loaded a
  preview credential.
- `record_task`'s `kind`.

**Downgrade** (its own step; `Encode` accumulates every step's flag):
- a hello's `previews` is dropped below 10, and the runner's first hello
  never carries it (it is sent before the welcome): the next hello does
  once the welcome says 10, as for empty repositories;
- below 10, `record_task`'s `kind: "change"` is dropped; `kind:
  "explore"` is **kept**, so an older instance's strict decoder refuses
  the whole call (an exploration never becomes a change). The runner,
  knowing its spoken protocol, answers such a call itself first with a
  tool error saying Equipo needs an update before it can record an
  exploration.

| Combination | Behaviour |
|---|---|
| new instance, runner at 9 | no `kind` arrives: changes; Paul's switch works; previews unknown, so the card says there is no preview unless one deployed |
| old instance, new runner | spoken 9: explorations are refused with the update message; changes as today |
| new both | as specified |

`schedulePreview` skips a primary at 10 that reports previews off.

## 6. Data

Migration 0067 (additive): `chat_tasks.kind`, `explored_from`,
`built_as`, `direction_asked`; `chat_steps.kind`, `note`. `wire.Task`
gains `kind` (omitempty), `explored_from`, `built_as` (task refs) and
`direction` (`{preview_url, branch_url, previews_off}`); `AnswerCard`
gains an optional `note`.

## 7. Tests, failing first

Contracts (`internal/thintest`):
- `TestExploreFlow`: record with `kind: explore`; Engineering's brief
  requires the preview config; no checks; Review's brief says
  exploration; approval with a preview schedules it and raises the
  direction card at once; the card shows the preview once deployed; no
  merge step ever.
- `TestExploreBuildThisOne`: a linked change task, from the default
  branch, its brief naming the branch and commit, started; this task
  done; a replayed answer 409.
- `TestExploreTryAgain`: a round with the note; no note refused; a new
  candidate withdraws the card and asks again.
- `TestExploreDropIt`: cancelled; nothing sent to the forge.
- `TestExploreNeverMerges`: the gate, the task page's Merge and a merge
  card answer: refused.
- `TestExploreKindSwitch`: change at Ready to merge to explore (merge card
  withdrawn, direction asked); explore to change (checks and a change
  Review before the gate); refused while a step runs, merging, ended,
  for a teammate, at a stale revision; a round trip asks again.
- `TestExplorePreviewsOff`: a primary at 10 without previews: no preview
  step, the card says previews aren't set up and links the branch.
- `TestExploreBarberOnce`: the failed-merge state switches once and
  raises the direction card; Paul switches it back; another start leaves
  it; merged, ended and missing write the row; running writes nothing.
- `TestExploreKindsNotDuplicates`: record_task's similarity, combine and
  link never pair an exploration with a change.
- `TestExploreDirectionStays`: triage and the sweep leave it in Needs you.
- Mixed versions: a runner at 9; the record_task downgrade both ways.

Unit: `Decide` with `Explore`; `Encode` at 10 and below; the first hello
without previews. Every guard broken once and its test watched failing.

## 8. Copy (delegated Astra pass)

The direction card's question, three answers and the note field and its
notes after answering; the preview, branch, "previews aren't set up"
and "no preview" lines; the kind label, the two switch actions and their
thread notes; "Build: %s" and the build brief's paragraph; Needs you
`direction`.

## 9. Out of scope

Choosing between several explorations side by side; deleting previews
or branches; waiting for a preview before asking.

## 10. Round 1 and where it went

1. Downgrade into a change: `kind: explore` is never stripped; an old
   instance refuses the call and the runner says why (§5).
2. First hello: `previews` withheld until the welcome; flags accumulate
   (§5).
3. The barber's failed merge: explorations route before merge handling
   (§2).
4. Running work: switches only at rest; judgements count only for their
   kind (§1).
5. Card validity: bound to the candidate, revalidated on answer,
   withdrawn on every change, reset on a switch (§2.4).
6. Inherited changes: "Build this one" starts from the default branch
   and names the explored branch in its brief (§2.4).
7. Atomic, replay-safe build: one transaction, a direct insert, the card
   and `built_as` as guards (§2.4).
8. Duplicates: kind equality in every pairing and in the transaction
   (§3).
9. Bootstrap: a trusted entry, row and switch together, transient states
   write nothing (§4).
10. Previews: nothing waits for them; the card fills the line in when
    shown (§2.3).

## 12. Round 2 (revision 2): READY AFTER FIXES, folded in

1. Kind-aware progress everywhere: a Review that does not count for the
   kind, and an exploration's checks and merges, are skipped by
   `progressOfKind` altogether (never `last`), and triage's last word and
   the fix round's feedback read only what counts.
2. Rest needs proof: a step withdrawn, or failed or cancelled without
   its termination proof, is not at rest (`busy`), for the switch, the
   answers and the start-up switch (which then writes nothing).
3. Owners only: the direction answer checks the creator is a current
   owner in its transaction.
4. Asked afresh: a branch move and Try again clear `direction_asked`, so
   the same commit is asked about again with a new card.
5. Previews advertised later: when the primary's hello first says
   previews are on, each open approved candidate without a preview gets
   one (`reschedulePreviews`, once per candidate).
6. Replays: `exploreRefused` answers an exploration on a connection below
   10, before sending, and in place of an older instance's strict
   refusal of a call queued at 10; a stored success is never replaced.
7. Resumed sessions: an exploration's fix round puts its rule in the
   dispatch's feedback too, and Try again's note is in both.
8. The person API's fold (`MarkDuplicate`) checks kinds too.

Copy (delegated Astra pass, verdicts applied verbatim): "What next for
%s?", "Build this one", "Try again", "Drop it", "What should change? A
note is required to try again.", "Equipo is waiting for your choice.",
"Previews aren't set up yet.", "There's no preview of this version.",
"Open the branch on Amadan", "Exploration", "Make it an exploration",
"Make it a change", the two thread notes, "Build: %s", the build brief's
paragraph and the answered notes.

Migration 0067.

## 11. Astra round 1 (revision 1): NOT READY

`gpt-6-astra`, effort high, read-only, against revision 1 and main
7140df3. Findings as given, shortened; revision 2 must answer each.

1. **Critical, §5.** Dropping `kind: explore` below 10 turns an
   exploration into a mergeable change on an older instance. Fix: never
   downgrade an exploration; the runner refuses to record one below 10
   (a tool error asking for an update); only plain changes pass.
2. **Important, §§5, 7.** The runner's first hello is encoded before the
   welcome, so `previews: true` would reach an older strict decoder and
   force protocol 1. And `Encode` assigns `changed =
   downgradePreview(body)`, which would drop an earlier step's flag.
   Fix: withhold `previews` until the welcome says 10 (as empty
   repositories do); accumulate the flags; test the real handshake.
3. **Important, §§1, 2, 4.** `advanceTask` handles a failed merge
   (`mergeFailed`) before judging, so the barber task, whose merge
   failed, would go back to Ready to merge, and a conflict would start a
   rebase. Fix: route explorations before the merge handling and ignore
   old merge failures in their Needs you and triage.
4. **Important, §§1, 2, 7.** A switch does not settle running work: an
   exploration Review finishing after a switch to change keeps a weaker
   approval. Fix: record the kind each step was dispatched under; a
   switched-to-change task needs a change Review; check merges in flight
   inside the switch; interleaving tests.
5. **Important, §§1, 2.4, 6.** The direction card is not invalidated by
   a new candidate, a branch move, a cancel, another round or a kind
   round trip (`direction_asked` would suppress the new card). Fix: bind
   to candidate and a decision generation; revalidate on answer; reset
   on every change.
6. **Critical, §2.4.** Basing "Build this one" on the explored SHA hides
   the inherited mockup changes from Review and the merge facts (both
   measure from `BaseSHA`), though merging brings them to the default
   branch. Fix: keep Engineering's start apart from the review and merge
   baseline, or start from the default branch.
7. **Important, §§2.4, 7.** "Build this one" needs one atomic,
   replay-safe creation (child, both links, answered card, parent done,
   dispatch, one key), outside `record_task`'s similarity and
   housekeeping; and a fetchable source when the explore branch moves or
   goes.
8. **Important, §3.** `record_task`'s own similarity (`similarTasks`,
   `DuplicateOf`) and the combine and link guards (`hkLink`, `foldable`)
   also need kind equality, not only the detectors.
9. **Important, §§4, 7.** The one-time barber switch needs a trusted
   bootstrap path (not the creator's switch with a made-up actor), the
   conversion and its consumed row in one transaction, and defined
   outcomes for merging (transient) versus merged or missing (final).
10. **Important, §§2.3-2.4, 7.** Waiting for the preview makes previews
    drive progress though they are ancillary, and `RetryTask` can retry a
    failed preview after the card opened. Fix: track preview readiness
    per candidate on every settlement path, or do not wait for it.
