oficina / equipo Public

retry_step: the coordinator runs a failed preview, checks or review again

Stuck tasks (b). retry_step {task, step} runs the task's newest step of
a kind in wire.RetryStepKinds (preview, checks, review) again, through
exactly the person's Retry: personRetry's checks for the turn's person
(an owner, the task's creator, the task not ended) and retryStepOf's
(failed and ended, the newest step, or a failed preview behind a merge
through retryPreview), then the same dispatch, placement, scheduler and
budget path. Never a merge, a publish or the work itself: the tool
refuses any other kind, and retryStepOf refuses the coordinator any
step outside RetryStepKinds as a second guard. The attempt it starts is
recorded on the step (chat_steps.coordinator_attempt, migration 0107),
shown on the wire as retried_by "coordinator" only while that attempt
is current, said on the task timeline, and audited (task.retry). One
retry per task and step kind in a turn (ledger task_retry); a second
call while it runs is not_retryable; an older link refuses it locally.

Also here: the OpenAPI schemas for ToolHealth, Capabilities.tools (from
(a)) and Step.retried_by, regenerated from internal/wire; size budgets
re-measured for the four items.

Copy, pending Paul's review (COPY REVIEW PENDING, inventory rows added):
chat.activity.retry_step, work.tl.coordinator_retried. plan3test's
copy inventory gate (TestPlan3ReleaseBoundaries/inventory) stays red,
by design, until the four pending strings of this branch are reviewed.

Tests: thintest TestContractCoordinatorRetryStep (refused while queued
and for merge, publish, engineering or anything else with nothing
dispatched; attempt 2 of the same checks step, retried_by, timeline
line, audit; once; replay; the person's later Retry is not credited to
the coordinator), TestContractCoordinatorRetryNeverMerges (a failed
preview behind the queued merge runs again as the coordinator's; a
failed merge is refused and nothing merges); wire
TestProtocol30StuckTools covers retry_step's protocol and kinds.

Mutation checks (each observed failing, then restored):
- tool's kind check removed: the inner guard still refuses (not_yours);
  both removed: TestContractCoordinatorRetryNeverMerges sees retry_step
  merge answer "retrying" (rule 2 broken), TestContractCoordinatorRetryStep
- attempt not recorded as the coordinator's: TestContractCoordinatorRetryStep
- recorded on the preview path skipped: TestContractCoordinatorRetryNeverMerges
- timeline line missing, audit missing: TestContractCoordinatorRetryStep
- retried_by ignoring the attempt: same test (the person's credited)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by paul@keymail.dev 974e0cebad8dc8fb81eef9302cf531e61e97ce0e parent f17a3fc
19 files changed, +270 −27
  • .rastrillo/budgets.txt +5 −5
  • docs/api/equipo-v1.openapi.json +22 −0
  • docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md +2 −0
  • internal/equipo/chat/handoff.go +1 −1
  • internal/equipo/chat/stuck.go +60 −1
  • internal/equipo/chat/tasks.go +35 −9
  • internal/equipo/chat/tools.go +6 −1
  • internal/equipo/copy.go +2 −0
  • internal/equipo/migrations/0107_coordinator_attempt.sql +3 −0
  • internal/equipo/migrations/schema.sql +1 −0
  • internal/equipo/work_views.go +4 −0
  • internal/runner/provider/actions.go +1 −1
  • internal/runner/provider/claude/launcher.go +1 −1
  • internal/runner/thin/mcp.go +1 −0
  • internal/thintest/stuck_contract_test.go +96 −0
  • internal/wire/frames.go +4 −2
  • internal/wire/stuck.go +16 −4
  • internal/wire/stuck_test.go +7 −2
  • internal/wire/tasks.go +3 −0

CI cancelled — superseded by a newer push — run details

diff --git a/.rastrillo/budgets.txt b/.rastrillo/budgets.txt
index 48456cfa..34001245 100644
--- a/.rastrillo/budgets.txt
+++ b/.rastrillo/budgets.txt
@@ -14,8 +14,8 @@ perf GET /* skip Unknown private paths render 404; this fallback contains no scr
time internal/equipo/team 60s Plan 3 loaded CI measured 45.985s; niced serial reruns measured 18.079s and 22.031s. Keep migration, recovery, accounting and concurrency assertions; 60s leaves 30 percent headroom above loaded CI.
time internal/equipotest 300s Final fix package rerun measured 187.035s (review 172.4s); 300s gives 60 percent headroom for HTTP, sandbox, authority and final regression coverage.
-size internal/equipo 22564 - Paused work: the report card and task page lead, stop and Run now, in the person's zone (2026-11-24); measured 22564 source lines.
-size internal/wire 6946 - StepPaused, RunNowOffer, the paused job state, CarryOn, TimeZone and protocol 29's pinned release (2026-11-24); measured 6946 source lines.
+size internal/equipo 22598 - Stuck tasks: the task page Retry on a failed preview and the coordinator's retried attempt on the timeline (2026-11-25); measured 22598 source lines.
+size internal/wire 7060 - Protocol 30: the runner's tool health, offer_retry and retry_step, a step's retried_by (2026-11-25); measured 7060 source lines.
size internal/equipotest - 12017 Task 21 repairs historical migration and conversation fixtures after Plan 3, and the Rastrillo upgrade contract comparing served assets with what Assets serves; measured 0/12017 source/test lines.
time internal/runner/checks 90s CI worker measured 44.553s (44.6s rounded);
time internal/runner 330s Plan 3 CI repair measured 292.120s for the full package (controller CI 472.184s).
@@ -38,7 +38,7 @@ time internal/runner/provider 15s Plan 3 CI repair measured 10.346s for the full
perf GET /releases/* skip Verified runner release file downloads, not browser GET screens.
perf GET /install.sh skip Mac runners: the one-line bootstrap a terminal pipes to sh, not a browser screen.
time internal/runner/containment 15s Plan 3 loaded CI measured 10.817s;
-size internal/runner/thin 28478 22713 Forge review fixes, fileForge router coverage, authority and proposal regressions, and protocol 29's pinned release (2026-11-24); measured 28478/22713.
+size internal/runner/thin 28530 22894 Protocol 30: the preview scanner's health in the capability report, the stuck-task tools refused on an older link (2026-11-25); measured 28530/22894.
time internal/thintest 240s Thin contract and page tests, the Assistant's and the models' included, share one harness. Measured 202s on a shared 16 CPU box (2026-11-13); CI runs two lanes.
time internal/runner/mac 30s Mac runners (Darwin worker): real process groups killed after a grace and proven gone (SIGTERM, SIGKILL, the marker sweep), and the probes run end to end with fake srt and xcodebuild, P6 killing.
time internal/runner/thin 45s Thin v1 slice 4 review: real git repositories for the merge and squash checks, a stalled fetch, and a 16 MiB candidate streamed through the review diff and the checks pack (about 5s).
@@ -56,7 +56,7 @@ perf GET /api/v1/tasks/{id} skip Thin v1 person API: bearer-only JSON for device
perf GET /api/v1/assistant/snapshot skip Assistant person API: bearer-only JSON for Base's chat, not a browser screen.
perf GET /api/v1/assistant/messages skip Assistant person API: bearer-only JSON for Base's chat, not a browser screen.
perf GET /api/v1/assistant/events skip Assistant event stream (Server-Sent Events), bearer-only and long-lived; not a screen.
-size internal/equipo/chat 34507 9500 Paused work: zone, Run now prediction, pinned release checked against the tap, paused job card, carry_on, per-card sweep (2026-11-24); measured 34507/9500.
+size internal/equipo/chat 34809 9500 Stuck tasks: offer_retry, retry_step, a failed preview run again behind a merge, the scanner health in status (2026-11-25); measured 34809/9500.
perf GET /api/v1/questions/{id} skip Thin v1 person API: bearer-only JSON for devices; the browser reads questions on /tasks/{id}.
perf GET /api/v1/steps/{id}/log skip Thin v1 person API: bearer-only JSON for devices; the browser shows the log tail on /tasks/{id}.
perf GET /api/v1/connections/preference skip Connections slice 1 person API: bearer-only JSON for devices; the browser shows the preference on /conversation/connections.
@@ -71,7 +71,7 @@ perf GET /tasks/{id}/files/{file} skip Research kept images: the bytes of one im
perf GET /api/v1/runners skip Mac runners person API: bearer-only JSON for devices; the browser shows runners in the Team section.
time cmd/equipo-runner 60s TestReleaseRunnerHasNoFakeWorker builds the release runner and the thin package under testbuild (about 12s locally).
size internal/headless - 11437 Grant scenarios for a named repository (hub #48); the sign-in's account email at 1280 and 390; measured 11437 test lines.
-size internal/thintest - 34650 Paused work: the paused job contract, the paused card in the browser, housekeeping and day boxes on Madrid's clock (2026-11-24); measured 34650 test lines.
+size internal/thintest - 35017 Stuck tasks: offer_retry, retry_step, the preview retry behind a merge and the status tool health contracts (2026-11-25); measured 35017 test lines.
perf GET /api/v1/projects/{id}/merge-policy skip Merge authority person API: bearer-only JSON for devices; the browser reads the policy on /projects/{id}.
perf GET /api/v1/usage skip Thin v1 person API: bearer-only JSON for devices; the browser reads usage through /usage.
diff --git a/docs/api/equipo-v1.openapi.json b/docs/api/equipo-v1.openapi.json
index ba9e4d2c..83cc183e 100644
--- a/docs/api/equipo-v1.openapi.json
+++ b/docs/api/equipo-v1.openapi.json
@@ -18802,6 +18802,9 @@
},
"sites": {
"type": "boolean"
+ },
+ "tools": {
+ "$ref": "#/components/schemas/ToolHealth"
}
},
"required": [
@@ -22328,6 +22331,9 @@
},
"publish": {
"$ref": "#/components/schemas/PublishResult"
+ },
+ "retried_by": {
+ "type": "string"
}
},
"required": [
@@ -24123,6 +24129,22 @@
"time_zone"
],
"additionalProperties": false
+ },
+ "ToolHealth": {
+ "type": "object",
+ "properties": {
+ "scanner": {
+ "type": "string"
+ },
+ "renderer": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "scanner"
+ ],
+ "additionalProperties": false,
+ "x-go-type": "wire.ToolHealth"
}
},
"responses": {
diff --git a/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md b/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md
index 80c2f1d7..ae955767 100644
--- a/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md
+++ b/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md
@@ -6906,6 +6906,8 @@ records remain unchanged.
| `work.pause.run_now_may_bill` | This may use a plan that bills per use. | Under plain Run it now anyway, for an older runner, when a pay-per-use connection could take it (re-review R1) | COPY ACCEPTED BY DELEGATION (Luna, 2026-11-24) |
| `chat.merge.retry_offer` | Merging %s didn’t go through. Try the merge again? | Copy specialist | COPY REVIEW PENDING |
| `chat.activity.offer_retry` | Offering to try the merge again… | Copy specialist | COPY REVIEW PENDING |
+| `chat.activity.retry_step` | Trying it again… | Copy specialist | COPY REVIEW PENDING |
+| `work.tl.coordinator_retried` | The coordinator started %s again. | Copy specialist | COPY REVIEW PENDING |
## Task 21
diff --git a/internal/equipo/chat/handoff.go b/internal/equipo/chat/handoff.go
index 6af94afd..6e9a300d 100644
--- a/internal/equipo/chat/handoff.go
+++ b/internal/equipo/chat/handoff.go
@@ -482,7 +482,7 @@ func (t *txn) handoffOf(turnID, taskID string) (handoffRecord, bool, error) {
// workTools create, start or change work: once the person cancels a
// request (stopping or cancelled), its turns may run none of them.
-var workTools = []string{wire.ToolRecordTask, wire.ToolStartTask, wire.ToolAddFinding, wire.ToolAddReport, wire.ToolHoldMerge, wire.ToolSetMergePolicy, wire.ToolProposeSpecialist, wire.ToolResearch, wire.ToolOfferRetry}
+var workTools = []string{wire.ToolRecordTask, wire.ToolStartTask, wire.ToolAddFinding, wire.ToolAddReport, wire.ToolHoldMerge, wire.ToolSetMergePolicy, wire.ToolProposeSpecialist, wire.ToolResearch, wire.ToolOfferRetry, wire.ToolRetryStep}
// handoffFenced: the turn belongs to a request the person cancelled and
// the tool would create or start work. Checked in the tool's own
diff --git a/internal/equipo/chat/stuck.go b/internal/equipo/chat/stuck.go
index 48396e3c..6742300b 100644
--- a/internal/equipo/chat/stuck.go
+++ b/internal/equipo/chat/stuck.go
@@ -2,6 +2,11 @@ package chat
import (
"encoding/json"
+ "errors"
+ "fmt"
+ "slices"
+
+ "gorm.io/gorm"
"amadan.net/oficina/equipo/internal/equipo/mergegate"
"amadan.net/oficina/equipo/internal/wire"
@@ -102,7 +107,7 @@ func (t *txn) offerRetry(r turnRecord, args json.RawMessage) (wire.ToolResult, e
// afresh and every publish is decided for that export (authorizePreview),
// a public one only under the project's own setting. A preview is
// ancillary, so the task's stage and its other steps are untouched.
-func (t *txn) retryPreview(k *taskRecord, st *stepRecord, person string) (int64, error) {
+func (t *txn) retryPreview(k *taskRecord, st *stepRecord, person string, coordinator bool) (int64, error) {
if st.State != wire.StepFailed || !st.Terminated {
return 0, ErrNotRetryable
}
@@ -147,8 +152,62 @@ func (t *txn) retryPreview(k *taskRecord, st *stepRecord, person string) (int64,
st.State, st.Reason, st.Terminated, st.Summary, st.LogTail, st.StartedAt, st.FinishedAt, st.Headline, st.Activity = wire.StepQueued, "", false, "", "", nil, nil, "", ""
// Recomputed: no export recorded until this attempt reports one.
st.Preview, st.Withdrawn, st.RefusedBy = "", false, ""
+ if coordinator {
+ st.CoordinatorAttempt = st.Attempt
+ }
if err := t.dispatchStep(k, st); err != nil {
return 0, err
}
return st.Attempt, t.saveStep(st, k)
}
+
+// More of what the model reads back for retry_step.
+const (
+ toolRetryKinds = "retry_step runs again only a failed preview, checks or review (step: preview, checks or review). A merge is the person's: use offer_retry. Engineering's work is theirs to ask for."
+ toolRetryStarted = "Started again as attempt %d. Tell the person in one line; the task shows it."
+ toolStepNotRetried = "Not started: that step has not failed and ended, is not the task's newest (a preview may be behind a merge), or its candidate is no longer the one to judge. read_task shows where it stands."
+)
+
+// retryStepTool is the coordinator's retry_step: the person's Retry
+// (personRetry, its checks for the turn's person), for the task's newest
+// step of a kind in wire.RetryStepKinds, recorded as the coordinator's
+// (CoordinatorAttempt) and audited. It never runs a merge or a publish.
+func (t *txn) retryStepTool(r turnRecord, args json.RawMessage) (wire.ToolResult, error) {
+ var in struct {
+ Task string `json:"task"`
+ Step string `json:"step"`
+ }
+ if wire.Strict(args, &in) != nil {
+ return refused("invalid", toolBadInput), nil
+ }
+ if !slices.Contains(wire.RetryStepKinds, in.Step) {
+ return refused("invalid", toolRetryKinds), nil
+ }
+ k, res, err := t.ownTask(r.Person, in.Task)
+ if res != nil || err != nil {
+ return deref(res), err
+ }
+ var st stepRecord
+ if err := t.db.Where("task_id = ? AND specialist = ? AND coalesce(retired, 0) = 0", k.ID, in.Step).Order("idx DESC").First(&st).Error; errors.Is(err, gorm.ErrRecordNotFound) {
+ return refused("not_retryable", toolStepNotRetried), nil
+ } else if err != nil {
+ return wire.ToolResult{}, err
+ }
+ attempt, err := t.personRetry(r.Person, k.ID, st.ID, true)
+ switch {
+ case errors.Is(err, ErrNotRetryable):
+ return refused("not_retryable", toolStepNotRetried), nil
+ case errors.Is(err, ErrTaskEnded):
+ return refused("task_ended", toolTaskEnded), nil
+ case errors.Is(err, ErrForbidden):
+ return refused("not_yours", toolNotYours), nil
+ case err != nil:
+ return wire.ToolResult{}, err
+ }
+ if t.s.authority.Audit != nil {
+ if err := t.s.authority.Audit(t.db, "coordinator:"+r.Person, "task.retry", k.ID+"/"+st.ID+"/"+itoa64(attempt)); err != nil {
+ return wire.ToolResult{}, err
+ }
+ }
+ return wire.ToolResult{Code: "retrying", Text: fmt.Sprintf(toolRetryStarted, attempt)}, nil
+}
diff --git a/internal/equipo/chat/tasks.go b/internal/equipo/chat/tasks.go
index fee99237..1c19fc41 100644
--- a/internal/equipo/chat/tasks.go
+++ b/internal/equipo/chat/tasks.go
@@ -278,6 +278,9 @@ type stepRecord struct {
// as low and never spends, wherever and whenever it is placed.
Hold string
HousekeepingAttempt int64
+ // CoordinatorAttempt is the attempt the coordinator's retry_step
+ // started (0: none), for the task's timeline (RetriedBy).
+ CoordinatorAttempt int64
// HeldAt is when the runner first held the step without a break (nil
// while it is not held): advice's "waited a week".
HeldAt *time.Time
@@ -463,7 +466,16 @@ func (t *txn) latestStep(taskID string) (stepRecord, bool, error) {
func stepView(s stepRecord) wire.Step {
return wire.Step{RunnerID: s.RunnerID, Needs: decodeList(s.Needs), Placement: s.Placement, Publication: s.Publication, TerminationKind: s.TerminationKind, ChecksSandbox: s.ChecksSandbox, ID: s.ID, Revision: s.Revision, TaskID: s.TaskID, Index: s.Idx, Specialist: s.Specialist, State: s.State, Reason: s.Reason, Attempt: s.Attempt, BaseSHA: s.BaseSHA, CandidateSHA: s.CandidateSHA, Pushed: s.Pushed, Terminated: s.Terminated, Summary: s.Summary, Headline: s.Headline, LogTail: s.LogTail, StartedAt: s.StartedAt, FinishedAt: s.FinishedAt,
Round: s.Round, Family: s.Family, Account: s.Account, Model: s.Model, Verdict: s.Verdict, ReviewLabel: s.ReviewLabel, Findings: decodeFindings(s.Findings), BaseChecks: s.BaseChecks, Checks: s.Checks, Gate: s.Gate, ExitCode: s.ExitCode, Askable: s.Askable,
- Rebase: s.Rebase, MergeSHA: s.MergeSHA, Into: s.MergeInto, Strategy: s.MergeStrategy, WithoutChecks: s.WithoutChecks, Activity: decodeActivity(s.Activity), Preview: decodePreview(s.Preview), Publish: decodePublish(s.Publish)}
+ Rebase: s.Rebase, MergeSHA: s.MergeSHA, Into: s.MergeInto, Strategy: s.MergeStrategy, WithoutChecks: s.WithoutChecks, Activity: decodeActivity(s.Activity), Preview: decodePreview(s.Preview), Publish: decodePublish(s.Publish), RetriedBy: retriedBy(s)}
+}
+
+// retriedBy says who started the step's current attempt, when it was the
+// coordinator (retry_step).
+func retriedBy(s stepRecord) string {
+ if s.CoordinatorAttempt != 0 && s.CoordinatorAttempt == s.Attempt {
+ return wire.RetriedByCoordinator
+ }
+ return ""
}
// stepViewSwitched adds the switched line, when the step moved, and the
@@ -747,7 +759,7 @@ func (t *txn) writeStep(s *stepRecord) error {
}
s.Revision++
s.UpdatedAt = t.now()
- if err := t.db.Model(&stepRecord{}).Where("id = ?", s.ID).Select("base_checks", "base_checks_sha", "copy_owner", "copy_revision", "copy_result", "failure_signature", "state", "reason", "attempt", "base_sha", "candidate_sha", "pushed", "terminated", "summary", "log_tail", "started_at", "finished_at", "revision", "updated_at", "headline", "family", "account", "verdict", "review_label", "findings", "checks", "gate", "exit_code", "output", "republish", "from_attempt", "askable", "rebase", "from_base", "from_candidate", "merge_sha", "merge_into", "merge_strategy", "without_checks", "switched", "activity", "runner_id", "needs", "placement", "waiting_since", "refused_by", "withdrawn", "termination_kind", "publication", "publication_id", "apple", "checks_sandbox", "change_facts", "decided_by", "merge_source", "merge_parents", "hosted_ci", "kind", "note", "sandbox_runner", "unsandboxed_by", "unsandboxed_at", "unsandboxed_attempt", "unsandboxed_runner", "has_preview", "preview", "boundary", "question", "request_turn", "sources_card", "sources_hash", "research_grant", "research_grant_revision", "hold", "housekeeping_attempt", "held_at", "publish", "model").Updates(s).Error; err != nil {
+ if err := t.db.Model(&stepRecord{}).Where("id = ?", s.ID).Select("base_checks", "base_checks_sha", "copy_owner", "copy_revision", "copy_result", "failure_signature", "state", "reason", "attempt", "base_sha", "candidate_sha", "pushed", "terminated", "summary", "log_tail", "started_at", "finished_at", "revision", "updated_at", "headline", "family", "account", "verdict", "review_label", "findings", "checks", "gate", "exit_code", "output", "republish", "from_attempt", "askable", "rebase", "from_base", "from_candidate", "merge_sha", "merge_into", "merge_strategy", "without_checks", "switched", "activity", "runner_id", "needs", "placement", "waiting_since", "refused_by", "withdrawn", "termination_kind", "publication", "publication_id", "apple", "checks_sandbox", "change_facts", "decided_by", "merge_source", "merge_parents", "hosted_ci", "kind", "note", "sandbox_runner", "unsandboxed_by", "unsandboxed_at", "unsandboxed_attempt", "unsandboxed_runner", "has_preview", "preview", "boundary", "question", "request_turn", "sources_card", "sources_hash", "research_grant", "research_grant_revision", "hold", "housekeeping_attempt", "coordinator_attempt", "held_at", "publish", "model").Updates(s).Error; err != nil {
return err
}
if s.Retired {
@@ -1950,15 +1962,17 @@ func (s *Store) retryTask(ctx context.Context, person, id, step string) (attempt
if err := s.authority.CurrentPerson(ctx, t.db); err != nil {
return err
}
- attempt, err = t.personRetry(person, id, step)
+ attempt, err = t.personRetry(person, id, step, false)
return err
})
return attempt, err
}
// personRetry is the person's Retry of the task's step ("" for its newest
-// step): an owner, the task's creator, a task that has not ended.
-func (t *txn) personRetry(person, id, step string) (int64, error) {
+// step): an owner, the task's creator, a task that has not ended. The
+// coordinator's retry_step makes exactly these checks for its person
+// (coordinator), on RetryStepKinds only.
+func (t *txn) personRetry(person, id, step string, coordinator bool) (int64, error) {
if err := t.isOwner(person); err != nil {
return 0, err
}
@@ -1973,7 +1987,7 @@ func (t *txn) personRetry(person, id, step string) (int64, error) {
if wire.FinalStage(k.Stage) || k.CancelRequested {
return 0, ErrTaskEnded
}
- return t.retryStepOf(&k, person, step)
+ return t.retryStepOf(&k, person, step, coordinator)
}
// retryStep runs the task's newest step again as its next attempt, once
@@ -1981,13 +1995,17 @@ func (t *txn) personRetry(person, id, step string) (int64, error) {
// (RetryTask) and needs-you triage's automatic retry of a passing stop,
// under the housekeeping principal, which refuses a merge step.
func (t *txn) retryStep(k *taskRecord, person string) (attempt int64, err error) {
- return t.retryStepOf(k, person, "")
+ return t.retryStepOf(k, person, "", false)
}
// retryStepOf is retryStep for a named step: the newest step, or a failed
// preview behind it (retryPreview). "" is the newest step. A preview, the
// newest or not, runs again only as retryPreview says.
-func (t *txn) retryStepOf(k *taskRecord, person, step string) (attempt int64, err error) {
+//
+// coordinator is the coordinator's retry_step: the same checks, never on
+// a step outside wire.RetryStepKinds (a merge, a publish, the work), and
+// the attempt it starts is recorded as its own (CoordinatorAttempt).
+func (t *txn) retryStepOf(k *taskRecord, person, step string, coordinator bool) (attempt int64, err error) {
st, found, err := t.latestStep(k.ID)
if err != nil {
return 0, err
@@ -2004,8 +2022,11 @@ func (t *txn) retryStepOf(k *taskRecord, person, step string) (attempt int64, er
}
st, found = named, true
}
+ if coordinator && (!found || !slices.Contains(wire.RetryStepKinds, st.Specialist)) {
+ return 0, ErrForbidden
+ }
if found && st.Specialist == wire.SpecialistPreview {
- return t.retryPreview(k, &st, person)
+ return t.retryPreview(k, &st, person, coordinator)
}
if found && st.Specialist == wire.SpecialistEngineering && st.State == wire.StepDone && st.Publication == wire.PublicationFailed {
// A worker's commit the primary could not push: publish the
@@ -2088,6 +2109,9 @@ func (t *txn) retryStepOf(k *taskRecord, person, step string) (attempt int64, er
st.MergeSHA, st.MergeInto, st.MergeStrategy, st.MergeSource, st.MergeParents = "", "", "", "", ""
}
st.Withdrawn, st.RefusedBy = false, ""
+ if coordinator {
+ st.CoordinatorAttempt = st.Attempt
+ }
// Run again under the task's kind as it is now.
st.Kind = wire.NormalKind(k.Kind)
if err := t.dispatchStep(k, &st); err != nil {
@@ -2229,6 +2253,8 @@ func (t *txn) runTaskTool(r turnRecord, v *wire.ToolCall) (wire.ToolResult, erro
return t.setMergePolicy(r, v.Args)
case wire.ToolOfferRetry:
return t.offerRetry(r, v.Args)
+ case wire.ToolRetryStep:
+ return t.retryStepTool(r, v.Args)
case wire.ToolAddFinding:
return t.addFinding(r, v.Args)
case wire.ToolStartTask:
diff --git a/internal/equipo/chat/tools.go b/internal/equipo/chat/tools.go
index 36213ec5..d43d3208 100644
--- a/internal/equipo/chat/tools.go
+++ b/internal/equipo/chat/tools.go
@@ -299,6 +299,7 @@ func (t *txn) mutationOp(person string, v *wire.ToolCall) (string, error) {
Project string `json:"project"`
Starred bool `json:"starred"`
Profile string `json:"profile"`
+ Step string `json:"step"`
}
_ = json.Unmarshal(v.Args, &a)
switch kind {
@@ -320,6 +321,8 @@ func (t *txn) mutationOp(person string, v *wire.ToolCall) (string, error) {
return kind + ":" + strings.TrimSpace(a.Task), nil
case "retry_offer":
return kind + ":" + strings.TrimSpace(a.Task), nil
+ case "task_retry":
+ return kind + ":" + strings.TrimSpace(a.Task) + ":" + strings.TrimSpace(a.Step), nil
}
return "", nil
}
@@ -475,6 +478,8 @@ var madeCodes = map[string][]string{
wire.ToolResearch: {"requested"},
// A refused offer made nothing; only a raised card is in the ledger.
wire.ToolOfferRetry: {"offered"},
+ // A refused retry started nothing.
+ wire.ToolRetryStep: {"retrying"},
}
func mutated(tool, code string) bool {
@@ -642,7 +647,7 @@ func (t *txn) runTool(l Lease, v *wire.ToolCall) (wire.ToolResult, error) {
return refused("invalid", toolBadInput), nil
}
return t.starProject(r, in.Project, *in.Starred)
- case wire.ToolRecordTask, wire.ToolAddFinding, wire.ToolStartTask, wire.ToolReadTask, wire.ToolCancelTask, wire.ToolAddReport, wire.ToolHoldMerge, wire.ToolSetMergePolicy, wire.ToolOfferRetry:
+ case wire.ToolRecordTask, wire.ToolAddFinding, wire.ToolStartTask, wire.ToolReadTask, wire.ToolCancelTask, wire.ToolAddReport, wire.ToolHoldMerge, wire.ToolSetMergePolicy, wire.ToolOfferRetry, wire.ToolRetryStep:
return t.taskTool(r, v)
case wire.ToolProposeSpecialist:
return t.toolProposeSpecialist(l, r, v)
diff --git a/internal/equipo/copy.go b/internal/equipo/copy.go
index 4005fb03..c8e87cc5 100644
--- a/internal/equipo/copy.go
+++ b/internal/equipo/copy.go
@@ -1424,6 +1424,7 @@ var pageCopy = map[string]string{
"chat.activity.hold_merge": "Holding the merge…", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11)
"chat.activity.set_merge_policy": "Setting this project's merge rules…", // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-11)
"chat.activity.offer_retry": "Offering to try the merge again…", // COPY REVIEW PENDING
+ "chat.activity.retry_step": "Trying it again…", // COPY REVIEW PENDING
// Thinking words: the sets a person picks for the thinking line
// (Settings, Thinking words). One line per set and situation, phrases
// separated by " | ". Edit them here; ids and situations are in
@@ -1643,6 +1644,7 @@ var pageCopy = map[string]string{
"work.tl.looked": "Coordinator looked into it", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
"work.tl.attempt": "%s, attempt %d", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
"work.tl.stopped": "%s stopped", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
+ "work.tl.coordinator_retried": "The coordinator started %s again.", // COPY REVIEW PENDING
"work.tl.cancelled": "%s cancelled", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
"work.tl.pushed": "Pushed %s", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
"work.tl.on": "%s on %s", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)
diff --git a/internal/equipo/migrations/0107_coordinator_attempt.sql b/internal/equipo/migrations/0107_coordinator_attempt.sql
new file mode 100644
index 00000000..86202a11
--- /dev/null
+++ b/internal/equipo/migrations/0107_coordinator_attempt.sql
@@ -0,0 +1,3 @@
+-- The attempt the coordinator's retry_step started (stuck tasks, protocol
+-- 30); 0 or NULL is none.
+ALTER TABLE chat_steps ADD COLUMN coordinator_attempt integer;
diff --git a/internal/equipo/migrations/schema.sql b/internal/equipo/migrations/schema.sql
index f82d00aa..b766173e 100644
--- a/internal/equipo/migrations/schema.sql
+++ b/internal/equipo/migrations/schema.sql
@@ -776,3 +776,4 @@ CREATE TABLE chat_person_zones (person text PRIMARY KEY, zone text NOT NULL, sou
ALTER TABLE chat_cards ADD COLUMN carry_on numeric;
ALTER TABLE chat_cards ADD COLUMN carry_on_connection text;
ALTER TABLE chat_releases ADD COLUMN connection text;
+ALTER TABLE chat_steps ADD COLUMN coordinator_attempt integer;
diff --git a/internal/equipo/work_views.go b/internal/equipo/work_views.go
index 9b23b6b0..49195a39 100644
--- a/internal/equipo/work_views.go
+++ b/internal/equipo/work_views.go
@@ -1095,6 +1095,10 @@ func timelineOf(t wire.Task, v taskLine) []timelineItem {
out = append(out, researchItem(t, s, v, title))
continue
}
+ if s.RetriedBy == wire.RetriedByCoordinator {
+ // The coordinator's retry_step started this attempt.
+ out = append(out, timelineItem{Kind: "note", What: fmt.Sprintf(copyText("work.tl.coordinator_retried"), name)})
+ }
if s.Specialist == wire.SpecialistMerge && (s.State == wire.StepQueued || s.State == wire.StepRunning || s.State == wire.StepDone) {
// The merging and merged lines say it.
continue
diff --git a/internal/runner/provider/actions.go b/internal/runner/provider/actions.go
index 17f0bf89..79f7f809 100644
--- a/internal/runner/provider/actions.go
+++ b/internal/runner/provider/actions.go
@@ -177,7 +177,7 @@ func ResearchReaderAction(action string) bool { return action == "implement" ||
// ConverseTools is the thin coordinator's tool set (wire.ConverseTools
// plus create_project, which the runner carries out itself).
func ConverseTools() []string {
- return []string{"request_access", "status", "find", "search_code", "read_file", "add_project", "create_project", "set_project_home", "star_project", "ask_person", "write_note", "read_notes", "record_task", "add_finding", "start_task", "read_task", "cancel_task", "add_report", "hold_merge", "set_merge_policy", "propose_specialist", "research", "offer_retry"}
+ return []string{"request_access", "status", "find", "search_code", "read_file", "add_project", "create_project", "set_project_home", "star_project", "ask_person", "write_note", "read_notes", "record_task", "add_finding", "start_task", "read_task", "cancel_task", "add_report", "hold_merge", "set_merge_policy", "propose_specialist", "research", "offer_retry", "retry_step"}
}
// AssistTools is the Assistant's tool set (wire.AssistTools).
diff --git a/internal/runner/provider/claude/launcher.go b/internal/runner/provider/claude/launcher.go
index 9198b430..3b80d2c8 100644
--- a/internal/runner/provider/claude/launcher.go
+++ b/internal/runner/provider/claude/launcher.go
@@ -140,7 +140,7 @@ func PolicyInputs(b provider.Binding, in provider.PolicyInputs, specialist, mode
}
tools := append(append([]string{}, native...), "mcp__equipo__permission")
for _, tool := range in.Tools {
- converse := in.Action == "converse" && slices.Contains([]string{"mcp__equipo__request_access", "mcp__equipo__status", "mcp__equipo__find", "mcp__equipo__search_code", "mcp__equipo__read_file", "mcp__equipo__add_project", "mcp__equipo__create_project", "mcp__equipo__set_project_home", "mcp__equipo__star_project", "mcp__equipo__write_note", "mcp__equipo__read_notes", "mcp__equipo__record_task", "mcp__equipo__add_finding", "mcp__equipo__start_task", "mcp__equipo__read_task", "mcp__equipo__cancel_task", "mcp__equipo__add_report", "mcp__equipo__hold_merge", "mcp__equipo__set_merge_policy", "mcp__equipo__propose_specialist", "mcp__equipo__research", "mcp__equipo__offer_retry"}, tool)
+ converse := in.Action == "converse" && slices.Contains([]string{"mcp__equipo__request_access", "mcp__equipo__status", "mcp__equipo__find", "mcp__equipo__search_code", "mcp__equipo__read_file", "mcp__equipo__add_project", "mcp__equipo__create_project", "mcp__equipo__set_project_home", "mcp__equipo__star_project", "mcp__equipo__write_note", "mcp__equipo__read_notes", "mcp__equipo__record_task", "mcp__equipo__add_finding", "mcp__equipo__start_task", "mcp__equipo__read_task", "mcp__equipo__cancel_task", "mcp__equipo__add_report", "mcp__equipo__hold_merge", "mcp__equipo__set_merge_policy", "mcp__equipo__propose_specialist", "mcp__equipo__research", "mcp__equipo__offer_retry", "mcp__equipo__retry_step"}, tool)
assist := in.Action == "assist" && slices.Contains([]string{"mcp__equipo__look", "mcp__equipo__describe", "mcp__equipo__use", "mcp__equipo__write_note", "mcp__equipo__read_notes"}, tool)
answer := in.Action == "answer" && slices.Contains([]string{"mcp__equipo__git_log", "mcp__equipo__git_diff", "mcp__equipo__git_show"}, tool)
research := provider.ResearchAction(in.Action) && slices.Contains([]string{"mcp__equipo__submit_findings", "mcp__equipo__keep_image"}, tool)
diff --git a/internal/runner/thin/mcp.go b/internal/runner/thin/mcp.go
index 7128526a..a37cd600 100644
--- a/internal/runner/thin/mcp.go
+++ b/internal/runner/thin/mcp.go
@@ -172,6 +172,7 @@ var converseTools = []any{
map[string]any{"name": "propose_specialist", "description": "Ask the person to add a specialist to their team, from Equipo's fixed menu. Only when the person wants something researched on the public web. The one profile is research-v1: it reads public web pages Equipo fetches for a task and reports what they say; it never reaches repositories. Pass profile research-v1, a short name (for example Research), a brief of at most 2 KB on what it should look for, capabilities [\"web.research\"] and tools [\"submit_findings\", \"keep_image\"], exactly those. Nothing is added until an owner taps Add on the card it raises; do not ask again in your reply. If they tap Not now, propose it again only when they ask.", "inputSchema": toolSchema(map[string]any{"profile": map[string]any{"type": "string", "enum": []string{"research-v1"}}, "name": str, "brief": str, "capabilities": map[string]any{"type": "array", "items": str}, "tools": map[string]any{"type": "array", "items": str}}, "profile", "name", "brief", "capabilities", "tools")},
map[string]any{"name": "research", "description": "Ask Research (once it is on the team; see propose_specialist) to read public web pages for one of the person's tasks. Use it when an exploration or change names an outside site, brand, API or docs, or the person asking (their business, their own site), and the work needs what those pages say. task is the task id; question (at most 1,000 bytes) is what to look for, for example colours, logo, fonts, opening hours and services; urls are pages you propose (https or http, no query string, a path of at most 100 characters, at most 10), or []. URLs and bare domains the person typed on the task are read without asking; your urls are shown to the person in full on a card and read only if they tap Allow, so propose only pages the task needs and never put anything from a repository in them. This only requests a run: Equipo starts it only at the task's start (call it before start_task) or after a review round, before Engineering's next round, and Engineering waits until Research ends. At most one run per start or round and 3 per task, and Equipo never retries a run for you. Research's findings reach Engineering and Review; do not wait for them in your reply.", "inputSchema": toolSchema(map[string]any{"task": str, "question": str, "urls": map[string]any{"type": "array", "items": str, "maxItems": 10}}, "task", "question", "urls")},
map[string]any{"name": wire.ToolOfferRetry, "description": "When a task's merge failed and it waits at Ready to merge (read_task shows the failed merge step), put a card in front of the person asking whether to try the merge again. You cannot merge: only their tap merges, through Equipo's merge rules, and it is offered only when that tap could merge now. One card per task; do not ask again in your reply, and never say it is merged.", "inputSchema": toolSchema(map[string]any{"task": str}, "task")},
+ map[string]any{"name": wire.ToolRetryStep, "description": "Run a task's failed preview, checks or review again, as the person's own Retry would (step: preview, checks or review). Only when read_task shows that step failed and why, and another try could help: a preview that failed for its scanner (status runner.tools) needs the runner fixed first. Never a merge (use offer_retry: only the person's tap merges) and never Engineering's work. The task shows that you started it. Call it once per step.", "inputSchema": toolSchema(map[string]any{"task": str, "step": map[string]any{"type": "string", "enum": wire.RetryStepKinds}}, "task", "step")},
}
// stepTools are the tools the implement profile pins for an Engineering
diff --git a/internal/thintest/stuck_contract_test.go b/internal/thintest/stuck_contract_test.go
index dd1a5a97..bb10f78c 100644
--- a/internal/thintest/stuck_contract_test.go
+++ b/internal/thintest/stuck_contract_test.go
@@ -269,3 +269,99 @@ func TestContractRetryPreviewOnlyForTheCandidate(t *testing.T) {
t.Fatalf("a preview of a candidate the branch left %+v", again)
}
}
+
+// TestContractCoordinatorRetryStep (stuck tasks b): retry_step runs a
+// failed preview, checks or review again with exactly the person's Retry
+// (the creator's task, an owner, ended and failed, the newest step), as
+// the next attempt, and the task page says the coordinator started it.
+// Never a merge, a publish or the work itself: those are refused and
+// nothing is dispatched.
+func TestContractCoordinatorRetryStep(t *testing.T) {
+ r := newToolRigAt(t, wire.ProtocolCurrent)
+ base, cand := strings.Repeat("1", 40), strings.Repeat("2", 40)
+ id, _ := r.pushed("b", "Fix the README typo", base, cand)
+ r.expect(wire.FrameWatchMerge)
+ c := r.dispatched(wire.SpecialistChecks, base, cand, 0)
+ if res := r.call("b0", wire.ToolRetryStep, map[string]string{"task": id, "step": wire.SpecialistChecks}); !res.IsError || res.Code != "not_retryable" {
+ t.Fatalf("retry of queued checks %+v", res)
+ }
+ r.step("b-c-fail", wire.StepReport{TaskID: id, StepID: c.StepID, Attempt: 1, State: wire.StepFailed, Reason: "provider_failed", BaseSHA: base, CandidateSHA: cand, Termination: true, Findings: []wire.Finding{}})
+ for _, kind := range []string{wire.SpecialistMerge, wire.SpecialistPublish, wire.SpecialistEngineering, "anything"} {
+ if res := r.call("b-"+kind, wire.ToolRetryStep, map[string]string{"task": id, "step": kind}); !res.IsError || res.Code != "invalid" {
+ t.Fatalf("retry_step %s: %+v", kind, res)
+ }
+ }
+ if refused := r.lease(r.runner, "b-ping", wire.LeaseCheck{}); refused != "" || r.heldKinds(wire.FrameDispatch) != 0 {
+ t.Fatal("a refused retry dispatched something")
+ }
+ res := r.call("b1", wire.ToolRetryStep, map[string]string{"task": id, "step": wire.SpecialistChecks})
+ if res.IsError || res.Code != "retrying" {
+ t.Fatalf("retry_step %+v", res)
+ }
+ _, body := r.expect(wire.FrameDispatch)
+ if d := body.(*wire.DispatchCommand); d.Specialist != wire.SpecialistChecks || d.StepID != c.StepID || d.Attempt != 2 || d.CandidateSHA != cand {
+ t.Fatalf("dispatch %+v", d)
+ }
+ k, _ := r.client.Task(r.ctx, id)
+ if s := k.Steps[len(k.Steps)-1]; s.ID != c.StepID || s.Attempt != 2 || s.RetriedBy != wire.RetriedByCoordinator {
+ t.Fatalf("the step %+v", s)
+ }
+ if page := r.get(r.inst.Cookie(), "/tasks/"+id, 200); !strings.Contains(page, "The coordinator started Checks again.") {
+ t.Fatal("the timeline does not say the coordinator started it")
+ }
+ if r.audits("task.retry") != 1 {
+ t.Fatalf("audits %d", r.audits("task.retry"))
+ }
+ // Once: asked again (any wording) while it runs, nothing more.
+ if again := r.call("b2", wire.ToolRetryStep, map[string]string{"task": id, "step": wire.SpecialistChecks}); !again.IsError || again.Code != "not_retryable" {
+ t.Fatalf("second retry_step %+v", again)
+ }
+ if same := r.call("b1", wire.ToolRetryStep, map[string]string{"task": id, "step": wire.SpecialistChecks}); same != res {
+ t.Fatalf("replay %+v", same)
+ }
+ if refused := r.lease(r.runner, "b-ping2", wire.LeaseCheck{}); refused != "" || r.heldKinds(wire.FrameDispatch) != 0 {
+ t.Fatal("a second dispatch")
+ }
+ // The person's own Retry later is theirs: the page no longer credits
+ // the coordinator.
+ r.step("b-c2-fail", wire.StepReport{TaskID: id, StepID: c.StepID, Attempt: 2, State: wire.StepFailed, Reason: "provider_failed", BaseSHA: base, CandidateSHA: cand, Termination: true, Findings: []wire.Finding{}})
+ if acc, err := r.client.RetryTask(r.ctx, id); err != nil || acc.Attempt != 3 {
+ t.Fatalf("the person's Retry %+v %v", acc, err)
+ }
+ if k, _ := r.client.Task(r.ctx, id); k.Steps[len(k.Steps)-1].RetriedBy != "" {
+ t.Fatal("the person's attempt credited to the coordinator")
+ }
+}
+
+// TestContractCoordinatorRetryNeverMerges: a failed merge is not the
+// coordinator's to retry (offer_retry is); a failed preview behind the
+// queued merge is, as the person's Retry would run it.
+func TestContractCoordinatorRetryNeverMerges(t *testing.T) {
+ r := publicPreviewRig(t)
+ base, cand := strings.Repeat("1", 40), strings.Repeat("2", 40)
+ id, pv, m := r.previewedAndMerging("x", base, cand)
+ res := r.call("x1", wire.ToolRetryStep, map[string]string{"task": id, "step": wire.SpecialistPreview})
+ if res.IsError || res.Code != "retrying" {
+ t.Fatalf("retry_step preview %+v", res)
+ }
+ if again := r.previewDispatch(cand); again == nil || again.StepID != pv.StepID || again.Attempt != 2 {
+ t.Fatalf("the preview again %+v", again)
+ }
+ k, _ := r.client.Task(r.ctx, id)
+ for _, s := range k.Steps {
+ if s.ID == pv.StepID && s.RetriedBy != wire.RetriedByCoordinator {
+ t.Fatalf("the preview's attempt is not the coordinator's %+v", s)
+ }
+ }
+ r.step("x-m-fail", wire.StepReport{TaskID: id, StepID: m.StepID, Attempt: 1, State: wire.StepFailed, Reason: "merge_failed", BaseSHA: base, CandidateSHA: cand, Termination: true})
+ r.wait("ready again", func(c *Conversation) bool { return c.Tasks[id].Stage == wire.StageReadyToMerge })
+ if res := r.call("x2", wire.ToolRetryStep, map[string]string{"task": id, "step": wire.SpecialistMerge}); !res.IsError || res.Code != "invalid" {
+ t.Fatalf("retry_step merge %+v", res)
+ }
+ if refused := r.lease(r.runner, "x-ping", wire.LeaseCheck{}); refused != "" || r.heldKinds(wire.FrameDispatch) != 0 {
+ t.Fatal("the coordinator's call dispatched a merge")
+ }
+ if k, _ := r.client.Task(r.ctx, id); k.Stage != wire.StageReadyToMerge || k.Merged != nil {
+ t.Fatalf("after retry_step merge %+v", k)
+ }
+}
diff --git a/internal/wire/frames.go b/internal/wire/frames.go
index c6d03912..0f09798a 100644
--- a/internal/wire/frames.go
+++ b/internal/wire/frames.go
@@ -583,7 +583,7 @@ const (
)
// ConverseTools is the coordinator's tool set in a conversation.
-var ConverseTools = []string{ToolRequestAccess, ToolStatus, ToolFind, ToolSearchCode, ToolReadFile, ToolAddProject, ToolCreateProject, ToolSetProjectHome, ToolStarProject, ToolAskPerson, ToolWriteNote, ToolReadNotes, ToolRecordTask, ToolAddFinding, ToolStartTask, ToolReadTask, ToolCancelTask, ToolAddReport, ToolHoldMerge, ToolSetMergePolicy, ToolProposeSpecialist, ToolResearch, ToolOfferRetry}
+var ConverseTools = []string{ToolRequestAccess, ToolStatus, ToolFind, ToolSearchCode, ToolReadFile, ToolAddProject, ToolCreateProject, ToolSetProjectHome, ToolStarProject, ToolAskPerson, ToolWriteNote, ToolReadNotes, ToolRecordTask, ToolAddFinding, ToolStartTask, ToolReadTask, ToolCancelTask, ToolAddReport, ToolHoldMerge, ToolSetMergePolicy, ToolProposeSpecialist, ToolResearch, ToolOfferRetry, ToolRetryStep}
// MoveInTools are the tools a move_in or explore turn may use: it looks
// around and takes notes, and never acts for the person.
@@ -678,12 +678,14 @@ var MutationKinds = map[string]string{
ToolResearch: "research",
// One offer of a failed merge per task in a turn.
ToolOfferRetry: "retry_offer",
+ // One retry per task and step kind in a turn.
+ ToolRetryStep: "task_retry",
}
// WriteTools change something outside the coordinator's session: the
// runner replays an exact repeat of one in a later attempt from its own
// record.
-var WriteTools = []string{ToolRequestAccess, ToolAddProject, ToolCreateProject, ToolSetProjectHome, ToolStarProject, ToolAskPerson, ToolWriteNote, ToolRecordTask, ToolAddFinding, ToolStartTask, ToolCancelTask, ToolAddReport, ToolHoldMerge, ToolSetMergePolicy, ToolProjectCreated, ToolProposeSpecialist, ToolResearch, ToolOfferRetry}
+var WriteTools = []string{ToolRequestAccess, ToolAddProject, ToolCreateProject, ToolSetProjectHome, ToolStarProject, ToolAskPerson, ToolWriteNote, ToolRecordTask, ToolAddFinding, ToolStartTask, ToolCancelTask, ToolAddReport, ToolHoldMerge, ToolSetMergePolicy, ToolProjectCreated, ToolProposeSpecialist, ToolResearch, ToolOfferRetry, ToolRetryStep}
// ActivityReport is what the coordinator started doing: thinking, or a
// tool by name. Sent once, never acked, like a delta.
diff --git a/internal/wire/stuck.go b/internal/wire/stuck.go
index 02012568..6d930a7a 100644
--- a/internal/wire/stuck.go
+++ b/internal/wire/stuck.go
@@ -8,16 +8,28 @@ import (
// Stuck tasks (coordinator powers, Paul 2026-11-25): ProtocolStuckTasks
// adds the runner's tool health to its capabilities, so the coordinator's
// status can say why a preview could not be scanned, and the
-// coordinator's offer_retry. Below it Encode drops a hello's tool health
+// coordinator's offer_retry and retry_step. Below it Encode drops a hello's tool health
// and refuses the tools' calls: an older instance decodes a hello
// strictly and has no words for either.
// ToolOfferRetry puts a card in front of the person to try a failed merge
-// again; only their tap merges (the merge card's Merge).
-const ToolOfferRetry = "offer_retry"
+// again; only their tap merges (the merge card's Merge). ToolRetryStep
+// runs a failed step of RetryStepKinds again, as the person's Retry would.
+const (
+ ToolOfferRetry = "offer_retry"
+ ToolRetryStep = "retry_step"
+)
// StuckTools are ProtocolStuckTasks's coordinator tools.
-var StuckTools = []string{ToolOfferRetry}
+var StuckTools = []string{ToolOfferRetry, ToolRetryStep}
+
+// RetryStepKinds are the steps retry_step may run again: never a merge, a
+// publish, or the work itself (Engineering, Copy).
+var RetryStepKinds = []string{SpecialistPreview, SpecialistChecks, SpecialistReview}
+
+// RetriedByCoordinator is a step's RetriedBy when the coordinator's
+// retry_step started its current attempt.
+const RetriedByCoordinator = "coordinator"
// ToolHealth is whether the runner's pinned tools are installed and
// match their pins, one fixed state each (ToolHealthy and the rest):
diff --git a/internal/wire/stuck_test.go b/internal/wire/stuck_test.go
index 0b30f073..337db477 100644
--- a/internal/wire/stuck_test.go
+++ b/internal/wire/stuck_test.go
@@ -68,8 +68,13 @@ func TestProtocol30StuckTools(t *testing.T) {
t.Fatalf("%s at 30: %v", name, err)
}
}
- if !slices.Contains(wire.StuckTools, wire.ToolOfferRetry) {
- t.Fatal("offer_retry is not a stuck-task tool")
+ if !slices.Contains(wire.StuckTools, wire.ToolOfferRetry) || !slices.Contains(wire.StuckTools, wire.ToolRetryStep) {
+ t.Fatal("offer_retry and retry_step are not stuck-task tools")
+ }
+ // retry_step runs these again, never a merge, a publish or the work
+ // itself.
+ if !slices.Equal(wire.RetryStepKinds, []string{wire.SpecialistPreview, wire.SpecialistChecks, wire.SpecialistReview}) {
+ t.Fatalf("retry_step kinds %v", wire.RetryStepKinds)
}
// Any other tool call goes to an older instance as it was.
other, _ := wire.NewFrame("c", wire.FrameToolCall, wire.ToolCall{CallID: "c", TurnID: "t", Attempt: 1, Name: wire.ToolReadTask, Args: json.RawMessage(`{"task":"tk"}`)})
diff --git a/internal/wire/tasks.go b/internal/wire/tasks.go
index 2d8ed289..3cd955cf 100644
--- a/internal/wire/tasks.go
+++ b/internal/wire/tasks.go
@@ -319,6 +319,9 @@ type Step struct {
Paused *StepPaused `json:"paused,omitempty"`
// Publish: a publish step's export and, once done, its outcome.
Publish *PublishResult `json:"publish,omitempty"`
+ // RetriedBy is "coordinator" when the coordinator's retry_step
+ // started the current attempt (protocol 30), else empty.
+ RetriedBy string `json:"retried_by,omitempty"`
}
// Task is one piece of work under a project. Branch is the task's own