Merge main into native Projects preserving reviewed copy
Keep native/API and Engineering stop-reason acceptance inventories and guards. Combine measured size budgets for both changes.
Co-Authored-By: Codex GPT-6-Astra <noreply@openai.com>
20 files changed,
+340
−25
.rastrillo/budgets.txt+6 −6docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md+2 −0internal/equipo/copy.go+2 −0internal/equipo/work_pages.go+1 −1internal/equipo/work_views.go+28 −3internal/equipo/work_views_test.go+64 −0internal/headless/engineering_test.go+17 −0internal/headless/scenarios_test.go+1 −0internal/plan3test/plan3_release_test.go+3 −1internal/runner/thin/codex.go+6 −4internal/runner/thin/codexstep.go+9 −4internal/runner/thin/codexstep_test.go+6 −1internal/runner/thin/engineer.go+41 −3internal/runner/thin/pistep.go+3 −1internal/runner/thin/stop_reasons_test.go+67 −0internal/thintest/stop_reasons_contract_test.go+30 −0internal/wire/stop_reasons_test.go+32 −0internal/wire/tasks.go+4 −0native/PROJECTS-REPORT.md+17 −0scripts/ci-test.py+1 −1
diff --git a/.rastrillo/budgets.txt b/.rastrillo/budgets.txt| index e9f9615d..28b7d3e4 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 22074 - Canonical copy adds 18 reviewed API errors and two native Projects labels; measured 22074 source lines. |
| -size internal/wire 6824 - Project list cursor and typed placement marker; measured 6824 source lines. |
| +size internal/equipo 22101 - Reviewed native Projects and API copy plus Engineering stop reasons; measured 22101 source lines. |
| +size internal/wire 6828 - Project cursor, typed placement marker and Engineering stop reasons; measured 6828 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). |
| @@ -30,7 +30,7 @@ size internal/runner/provider 5715 - Fable follow-up: base and diagnostic gates, |
| time internal/plan3test 300s Initial cap for combined browser and runner acceptance; measure at both usable stops. |
| -size internal/plan3test - 11896 Luna acceptance lists for API errors and native Projects labels; measured 11896 test lines. |
| +size internal/plan3test - 11898 Reviewed API, native Projects and Engineering stop reason acceptance lists; measured 11898 test lines. |
| time internal/runner/forge 20s Plan 3 CI repair measured 10.527s for the full package (controller CI 10.407s). |
| time internal/runner/provider 15s Plan 3 CI repair measured 10.346s for the full package (controller CI 10.709s); |
| @@ -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 28197 22000 Fable follow-up gates and guards, then main started at repo creation; measured 28197/22000 source/test lines (checks hold Go to the base; needs-network only from their own stage). |
| +size internal/runner/thin 28244 22072 Fable follow-up gates and guards, main started at repo creation, refused tool requests counted per step; measured 28244/22072 source/test lines. |
| 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). |
| @@ -70,8 +70,8 @@ perf GET /api/v1/tasks/{id}/files/{file} skip Research kept images: bearer-only |
| perf GET /tasks/{id}/files/{file} skip Research kept images: the bytes of one image, shown on the task page; a file, not a screen. |
| 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 - 11319 Fable follow-up: base and diagnostic gates, preview isolation and provenance guards; live staging witnesses; measured 0/11319 source/test lines (live first-stage check). |
| -size internal/thintest - 33989 Device project cards, exact negation and old-runner pass-through regressions; measured 33989 test lines. |
| +size internal/headless - 11337 Fable follow-up gates, preview isolation and provenance guards; live staging witnesses; refused step requests stop tools_refused; measured 0/11337 test lines. |
| +size internal/thintest - 34019 Device project cards, exact negation and old-runner pass-through regressions, and tools_refused delivery; measured 34019 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/superpowers/plans/CONTROLLER-REPORT-plan-3.md b/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md| index 85c47d43..724dd0b8 100644 |
| --- a/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md |
| +++ b/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md |
| @@ -6841,6 +6841,8 @@ records remain unchanged. |
| | `api.turn_ended` | This reply has ended. | Copy specialist | COPY ACCEPTED BY DELEGATION (Luna, 2026-11-23) | |
| | `projects.new_request` | New request | Copy specialist | COPY ACCEPTED BY DELEGATION (Luna, 2026-11-23) | |
| | `projects.remove_selection` | Remove project | Copy specialist | COPY ACCEPTED BY DELEGATION (Luna, 2026-11-23) | |
| +| `work.reason.no_further_changes` | it made no further changes to the candidate | Task page: fills "Engineering stopped: %s" when an Engineering step ended no_changes and an earlier round already pushed a candidate (stop reasons, 2026-11-23) | Runtime; COPY APPROVED (Paul, 2026-11-23, copy-review eavqvil43jg2zs3wxx3kxp3bpm, unchanged) | |
| +| `work.reason.tools_refused` | Equipo refused the commands it needed to run | Task page: fills "Engineering stopped: %s" when an Engineering step committed nothing after Equipo refused tool requests it made (stop reasons, 2026-11-23) | Runtime; COPY APPROVED (Paul, 2026-11-23, copy-review eavqvil43jg2zs3wxx3kxp3bpm, unchanged) | |
| ## Task 21 |
diff --git a/internal/equipo/copy.go b/internal/equipo/copy.go| index f412f76f..b5a1e9f9 100644 |
| --- a/internal/equipo/copy.go |
| +++ b/internal/equipo/copy.go |
| @@ -921,6 +921,8 @@ var pageCopy = map[string]string{ |
| "work.stopped": "Stopped: %s", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| "work.reason.runner_restarted": "the runner restarted", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| "work.reason.no_changes": "nothing needed changing", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| + "work.reason.no_further_changes": "it made no further changes to the candidate", // COPY APPROVED (Paul, 2026-11-23, copy-review eavqvil43jg2zs3wxx3kxp3bpm, unchanged) |
| + "work.reason.tools_refused": "Equipo refused the commands it needed to run", // COPY APPROVED (Paul, 2026-11-23, copy-review eavqvil43jg2zs3wxx3kxp3bpm, unchanged) |
| "work.reason.push_failed": "the push to Amadan failed", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| "work.reason.push_conflict": "the branch changed on Amadan", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| "work.reason.step_timeout": "it ran out of time", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
diff --git a/internal/equipo/work_pages.go b/internal/equipo/work_pages.go| index 63391a68..39fdf8fb 100644 |
| --- a/internal/equipo/work_pages.go |
| +++ b/internal/equipo/work_pages.go |
| @@ -204,7 +204,7 @@ func taskLineOf(t wire.Task, viewer string) taskLine { |
| } |
| } |
| if s.State == wire.StepFailed && !wire.FinalStage(t.Stage) { |
| - reason := copyText("work.reason." + s.Reason) |
| + reason := copyText("work.reason." + stopReason(t, s)) |
| if reason == "" { |
| reason = copyText("work.reason.other") |
| } |
diff --git a/internal/equipo/work_views.go b/internal/equipo/work_views.go| index fad87e35..2b2f626f 100644 |
| --- a/internal/equipo/work_views.go |
| +++ b/internal/equipo/work_views.go |
| @@ -221,6 +221,31 @@ func stoppedStep(t wire.Task) *wire.Step { |
| return nil |
| } |
| +// stopReason is the reason whose words say why s stopped: an Engineering |
| +// step that changed nothing after an earlier step pushed a candidate |
| +// made no further changes to it (no_further_changes, the instance's |
| +// own words: never a runner's reason); otherwise s's own reason. |
| +func stopReason(t wire.Task, s wire.Step) string { |
| + if s.Reason == "no_changes" && candidateBefore(t, s.ID) { |
| + return "no_further_changes" |
| + } |
| + return s.Reason |
| +} |
| + |
| +// candidateBefore reports whether a step before the step id pushed a |
| +// candidate: an Engineering round, or a Copy review applied to one. |
| +func candidateBefore(t wire.Task, id string) bool { |
| + for _, s := range t.Steps { |
| + if s.ID == id { |
| + return false |
| + } |
| + if s.Pushed && s.CandidateSHA != "" && (s.Specialist == wire.SpecialistEngineering || s.Specialist == wire.SpecialistCopy && s.State == wire.StepDone) { |
| + return true |
| + } |
| + } |
| + return false |
| +} |
| + |
| // needsViewer reports whether the task waits on viewer's own decision: |
| // a stopped step, a review without verdict, the fix-round cap, a branch |
| // that moved, a conflict, or an open merge card. |
| @@ -714,7 +739,7 @@ func decisionOf(t wire.Task, v taskLine) *decisionView { |
| d.Tone = "attention" |
| reason, attempt := "", int64(1) |
| if v.Stopped != nil { |
| - reason, attempt = copyText("work.reason."+v.Stopped.Reason), v.Stopped.Attempt |
| + reason, attempt = copyText("work.reason."+stopReason(t, *v.Stopped)), v.Stopped.Attempt |
| } |
| if reason == "" { |
| reason = copyText("work.reason.other") |
| @@ -870,7 +895,7 @@ func summaryOf(t wire.Task, v taskLine) string { |
| case triageLine(t.Triage) != "": |
| return triageLine(t.Triage) |
| case v.Stopped != nil: |
| - reason := copyText("work.reason." + v.Stopped.Reason) |
| + reason := copyText("work.reason." + stopReason(t, *v.Stopped)) |
| if reason == "" { |
| reason = copyText("work.reason.other") |
| } |
| @@ -1089,7 +1114,7 @@ func timelineOf(t wire.Task, v taskLine) []timelineItem { |
| out = append(out, it) |
| continue |
| case wire.StepFailed: |
| - reason := copyText("work.reason." + s.Reason) |
| + reason := copyText("work.reason." + stopReason(t, s)) |
| if reason == "" { |
| reason = copyText("work.reason.other") |
| } |
diff --git a/internal/equipo/work_views_test.go b/internal/equipo/work_views_test.go| index f15e8ef0..fa9393e7 100644 |
| --- a/internal/equipo/work_views_test.go |
| +++ b/internal/equipo/work_views_test.go |
| @@ -129,3 +129,67 @@ func TestRosterCancelledHoldIsReport(t *testing.T) { |
| t.Fatal("cancelled task still asks about its old Copy hold") |
| } |
| } |
| + |
| +// An Engineering step that ends with no change says why in the words |
| +// that fit: nothing needed changing on a first pass; no further changes |
| +// to the candidate once an earlier round pushed one; and Equipo's refusal |
| +// when the step's tool requests were refused. The summary, the decision |
| +// card, the stage line and the timeline agree. |
| +func TestStoppedEngineeringNoChangeWords(t *testing.T) { |
| + now := time.Now() |
| + cand := strings.Repeat("c", 40) |
| + pushed := wire.Step{ID: "s1", Specialist: wire.SpecialistEngineering, State: wire.StepDone, CandidateSHA: cand, Pushed: true, Attempt: 1, Terminated: true, FinishedAt: &now} |
| + checked := wire.Step{ID: "s2", Specialist: wire.SpecialistChecks, State: wire.StepDone, CandidateSHA: cand, Attempt: 1, Terminated: true, FinishedAt: &now} |
| + stopped := func(id, reason string) wire.Step { |
| + return wire.Step{ID: id, Specialist: wire.SpecialistEngineering, State: wire.StepFailed, Reason: reason, Attempt: 1, Terminated: true, FinishedAt: &now} |
| + } |
| + for _, tc := range []struct { |
| + name string |
| + steps []wire.Step |
| + candidate string |
| + words string |
| + }{ |
| + {"first pass, nothing to change", []wire.Step{stopped("s1", "no_changes")}, "", "nothing needed changing"}, |
| + {"a later round, a candidate already", []wire.Step{pushed, checked, stopped("s3", "no_changes")}, cand, "it made no further changes to the candidate"}, |
| + {"tools refused, first pass", []wire.Step{stopped("s1", "tools_refused")}, "", "Equipo refused the commands it needed to run"}, |
| + {"tools refused, a candidate already", []wire.Step{pushed, checked, stopped("s3", "tools_refused")}, cand, "Equipo refused the commands it needed to run"}, |
| + } { |
| + t.Run(tc.name, func(t *testing.T) { |
| + k := wire.Task{ID: "tk1", Creator: "a@example.com", Stage: wire.StageInProgress, Steps: tc.steps, CandidateSHA: tc.candidate, NeedsYou: wire.NeedsRetry} |
| + v := taskLineOf(k, "a@example.com") |
| + v.richOf(k, "a@example.com", nil, now) |
| + if got, want := summaryOf(k, v), "Engineering stopped: "+tc.words+". It waits on you."; got != want { |
| + t.Errorf("summary %q, want %q", got, want) |
| + } |
| + if d := decisionOf(k, v); d == nil || d.Why != "Engineering stopped: "+tc.words+", on attempt 1." { |
| + t.Errorf("decision %+v", d) |
| + } |
| + if v.StageLine != "Stopped: "+tc.words { |
| + t.Errorf("stage line %q", v.StageLine) |
| + } |
| + found := false |
| + for _, it := range timelineOf(k, v) { |
| + if it.Kind == "stopped" { |
| + found = true |
| + if it.Headline != sentenceCase(tc.words)+"." { |
| + t.Errorf("timeline %q", it.Headline) |
| + } |
| + } |
| + } |
| + if !found { |
| + t.Errorf("no stopped entry in %+v", timelineOf(k, v)) |
| + } |
| + }) |
| + } |
| + // The timeline words follow the candidate as it stood when that step |
| + // stopped: a first pass that changed nothing still says nothing |
| + // needed changing after a later round pushed a candidate. |
| + k := wire.Task{ID: "tk1", Creator: "a@example.com", Stage: wire.StageInReview, CandidateSHA: cand, Steps: []wire.Step{stopped("s0", "no_changes"), pushed, checked}} |
| + v := taskLineOf(k, "a@example.com") |
| + v.richOf(k, "a@example.com", nil, now) |
| + for _, it := range timelineOf(k, v) { |
| + if it.Kind == "stopped" && it.Headline != "Nothing needed changing." { |
| + t.Errorf("earlier stop %q", it.Headline) |
| + } |
| + } |
| +} |
diff --git a/internal/headless/engineering_test.go b/internal/headless/engineering_test.go| index 77520395..4b041d0b 100644 |
| --- a/internal/headless/engineering_test.go |
| +++ b/internal/headless/engineering_test.go |
| @@ -290,6 +290,23 @@ func scenarioStepContained(t *testing.T, env *Env) { |
| } |
| } |
| +// A step whose only requests the permission callback denied commits |
| +// nothing and stops tools_refused, not no_changes: the person reads that |
| +// Equipo refused the commands it needed, not that nothing needed changing. |
| +func scenarioStepRefused(t *testing.T, env *Env) { |
| + if env.Live { |
| + t.Skip("local only: the fake CLI asks to write outside /workspace; a live model is never steered to") |
| + } |
| + s := open(t, env) |
| + s.keep() |
| + sent := s.send(t, "tool:record_task:oficina/sample|Refused|x\ntool:start_task:$task|escape:/etc/hostname") |
| + id := s.taskOf(t, sent.Turn.ID) |
| + st := s.step(t, id, 2*time.Minute, wire.StepDone, wire.StepFailed) |
| + if st.State != wire.StepFailed || st.Reason != "tools_refused" || st.Pushed { |
| + t.Fatalf("step %+v", st) |
| + } |
| +} |
| + |
| // A grant shows up at once when the person acts on the grant card: the |
| // card names the namespace, the runner checks its reach, indexes only |
| // the new repository, and the card resolves itself. |
diff --git a/internal/headless/scenarios_test.go b/internal/headless/scenarios_test.go| index 655eee63..ea1b8b5d 100644 |
| --- a/internal/headless/scenarios_test.go |
| +++ b/internal/headless/scenarios_test.go |
| @@ -471,6 +471,7 @@ var scenarios = []struct { |
| {"3_engineering", scenarioEngineering}, |
| {"3_step_cancel", scenarioStepCancel}, |
| {"3_step_contained", scenarioStepContained}, |
| + {"3_step_refused", scenarioStepRefused}, |
| {"4_step_crash", scenarioStepCrash}, |
| {"3_grant", scenarioGrant}, |
| {"3_empty_repo", scenarioEmptyRepo}, |
diff --git a/internal/plan3test/plan3_release_test.go b/internal/plan3test/plan3_release_test.go| index ce2a93ac..c6788077 100644 |
| --- a/internal/plan3test/plan3_release_test.go |
| +++ b/internal/plan3test/plan3_release_test.go |
| @@ -181,6 +181,8 @@ func plan3CopyInventory(t *testing.T) { |
| approvedOficina := strings.HasSuffix(strings.TrimSuffix(cells[3], " |"), "COPY APPROVED (Paul, 2026-11-16, copy-review arfnqquz6wks4vdyxptv6ditju, unchanged)") |
| // Paul's own review of the failed-reply lines and Try again, and of the sign-in door's refusal. |
| approvedFailedReplies := strings.HasPrefix(key, "chat.failed.") && strings.HasSuffix(strings.TrimSuffix(cells[3], " |"), "COPY APPROVED (Paul, 2026-11-22, copy-review ipgtz3lqoo3rj6rpiodpekh6vu, unchanged)") || key == "signin.refused" && strings.HasSuffix(strings.TrimSuffix(cells[3], " |"), "COPY APPROVED (Paul, 2026-11-22, copy-review smart-door-copy-5, unchanged)") |
| + // Paul's own review of the Engineering stop reasons. |
| + approvedStopReasons := slices.Contains([]string{"work.reason.no_further_changes", "work.reason.tools_refused"}, key) && strings.HasSuffix(strings.TrimSuffix(cells[3], " |"), "COPY APPROVED (Paul, 2026-11-23, copy-review eavqvil43jg2zs3wxx3kxp3bpm, unchanged)") |
| acceptedRoster := strings.HasPrefix(key, "roster.") && strings.HasSuffix(strings.TrimSuffix(cells[3], " |"), "COPY ACCEPTED BY DELEGATION (Astra, 2026-11-14)") |
| acceptedPlacement := strings.HasPrefix(key, "placement.") && strings.HasSuffix(strings.TrimSuffix(cells[3], " |"), "COPY ACCEPTED BY DELEGATION (Astra, 2026-11-15)") |
| acceptedAccess := slices.Contains([]string{"access.waiting", "access.reopen", "access.not_owned", "access.already", "access.unconfirmed", "access.missing", "access.uncheckable", "access.authority", "access.confirm_namespace", "access.namespace", "access.granted_note", "access.title", "access.confirm", "access.ask", "access.approve", "access.aside", "access.reason", "access.role", "access.confirmation", "access.filing", "access.pending", "access.approved", "access.declined", "access.expired", "access.limited", "access.failed", "access.operator", "access.continue"}, key) && strings.HasSuffix(strings.TrimSuffix(cells[3], " |"), "COPY ACCEPTED BY DELEGATION (Astra, 2026-11-17)") |
| @@ -200,7 +202,7 @@ func plan3CopyInventory(t *testing.T) { |
| acceptedProjects := slices.Contains([]string{"projects.amadan", "projects.yours", "projects.can_add", "projects.add_reachable", "projects.names", "projects.names_hint", "projects.details", "projects.title", "projects.description", "projects.save", "projects.context", "projects.found", "projects.selected", "projects.owner_add", "projects.selection_lost", "projects.other", "projects.name_question", "projects.personal_names", "projects.forget_name", "docs/api/equipo-v1.md / Projects and starting a request"}, key) && strings.HasSuffix(strings.TrimSuffix(cells[3], " |"), "COPY ACCEPTED BY DELEGATION (Luna, 2026-11-22)") |
| acceptedAgentAccess := slices.Contains([]string{"copyAgentConfig", "copyAgentForbidden", "copyAgentNotFound", "copyAgentUnavailable", "copyAgentTooLarge", "copyAgentInvalid", "copyAgentMedia", "copyAgentUnauthenticated", "agent.equipo_projects_list", "agent.equipo_tasks_list", "agent.equipo_task_get", "agent.equipo_needs_you", "docs/api/equipo-v1.md / Delegated read-only operations"}, key) && strings.HasSuffix(strings.TrimSuffix(cells[3], " |"), "COPY ACCEPTED BY DELEGATION (Luna, 2026-11-20)") |
| acceptedCopy := strings.TrimSuffix(cells[3], " |") == "COPY ACCEPTED BY DELEGATION (Copy, record-bound) sha256:"+copydesk.Hash(rows[key]) |
| - if !acceptedAPIErrors && !acceptedNativeProjects && !acceptedInjection && !acceptedMail && !acceptedPush && !acceptedAgentAccess && !acceptedProjects && !acceptedCardNames && !acceptedAccess && !acceptedPlacementEdges && !acceptedPlacement && !acceptedReportActions && !acceptedRoster && !acceptedCopy && !strings.Contains(cells[3], "COPY REVIEW REQUIRED") && !acceptedAll && !acceptedGuide && !acceptedRound2 && !acceptedStarter && !acceptedDelegation && !approvedPublish && !approvedAssistant && !approvedJobs && !approvedOficina && !approvedFailedReplies { |
| + if !acceptedAPIErrors && !acceptedNativeProjects && !acceptedInjection && !acceptedMail && !acceptedPush && !acceptedAgentAccess && !acceptedProjects && !acceptedCardNames && !acceptedAccess && !acceptedPlacementEdges && !acceptedPlacement && !acceptedReportActions && !acceptedRoster && !acceptedCopy && !strings.Contains(cells[3], "COPY REVIEW REQUIRED") && !acceptedAll && !acceptedGuide && !acceptedRound2 && !acceptedStarter && !acceptedDelegation && !approvedPublish && !approvedAssistant && !approvedJobs && !approvedOficina && !approvedFailedReplies && !approvedStopReasons { |
| t.Fatal("entry has no copy review status or applicable acceptance", key) |
| } |
| } |
diff --git a/internal/runner/thin/codex.go b/internal/runner/thin/codex.go| index 6070ff6f..28c151a8 100644 |
| --- a/internal/runner/thin/codex.go |
| +++ b/internal/runner/thin/codex.go |
| @@ -379,22 +379,24 @@ func (c *codexCoordinator) answer(p *codexProcess, m connect.Message, items map[ |
| // answerApproval replies to a request the app-server makes. Only an |
| // approval to call one of names on the Equipo server, correlated with the |
| // tool call Codex started, is accepted; every other request (shell, |
| -// patch, questions, anything new) is refused. |
| -func answerApproval(rpc *connect.AppServer, m connect.Message, items map[string]codexItem, names []string) { |
| +// patch, questions, anything new) is refused. It reports whether it |
| +// accepted. |
| +func answerApproval(rpc *connect.AppServer, m connect.Message, items map[string]codexItem, names []string) bool { |
| if m.Method == "mcpServer/elicitation/request" { |
| server, args, ok := codex.ToolApproval(m.Params) |
| if ok && server == "equipo" { |
| for _, it := range items { |
| if it.Server == "equipo" && slices.Contains(names, it.Tool) && codex.SameArguments(it.Arguments, args) { |
| _ = rpc.Answer(m.ID, map[string]any{"action": "accept", "content": map[string]any{}}) |
| - return |
| + return true |
| } |
| } |
| } |
| _ = rpc.Answer(m.ID, map[string]any{"action": "decline"}) |
| - return |
| + return false |
| } |
| _ = rpc.Refuse(m.ID) |
| + return false |
| } |
| func (c *codexCoordinator) interrupt(p *codexProcess, turn string) { |
diff --git a/internal/runner/thin/codexstep.go b/internal/runner/thin/codexstep.go| index 17485a41..af2df6a4 100644 |
| --- a/internal/runner/thin/codexstep.go |
| +++ b/internal/runner/thin/codexstep.go |
| @@ -103,7 +103,9 @@ func (e *Engineer) runCodex(ctx context.Context, r stepRow, tree workspace.TaskT |
| } |
| defer logFile.Close() |
| rpc := connect.NewAppServer(proc.Stdout(), proc.Stdin()) |
| - res := e.codexStep(ctx, rpc, b, policy, limit, spec, logFile) |
| + refused := int64(0) |
| + res := e.codexStep(ctx, rpc, b, policy, limit, spec, logFile, &refused) |
| + res.refused = refused |
| res.terminated = stopStep(func() { proc.Stdin().Close() }, exited, kill, ctx.Err() == nil && res.reason == "", 10*time.Second, 30*time.Second) |
| if !res.terminated { |
| // The namespace record stays: a restarted runner verifies it. |
| @@ -116,8 +118,9 @@ func (e *Engineer) runCodex(ctx context.Context, r stepRow, tree workspace.TaskT |
| // codexStep checks the app-server it talks to (pinned version, runtime |
| // home, the expected account, the effective configuration, the thread's |
| -// policy), then runs the step as one turn and reads it to its end. |
| -func (e *Engineer) codexStep(ctx context.Context, rpc *connect.AppServer, b runner.AccountBinding, policy provider.Policy, limit time.Duration, spec specialistRun, logFile io.Writer) stepResult { |
| +// policy), then runs the step as one turn and reads it to its end, |
| +// counting in refused each request it refuses. |
| +func (e *Engineer) codexStep(ctx context.Context, rpc *connect.AppServer, b runner.AccountBinding, policy provider.Policy, limit time.Duration, spec specialistRun, logFile io.Writer, refused *int64) stepResult { |
| tail := &stepTail{} |
| cancelled := func() stepResult { |
| if ctx.Err() != nil { |
| @@ -205,7 +208,9 @@ func (e *Engineer) codexStep(ctx context.Context, rpc *connect.AppServer, b runn |
| written += n |
| } |
| if len(m.ID) > 0 { |
| - answerApproval(rpc, m, items, spec.names) |
| + if !answerApproval(rpc, m, items, spec.names) { |
| + *refused++ |
| + } |
| continue |
| } |
| var n struct { |
diff --git a/internal/runner/thin/codexstep_test.go b/internal/runner/thin/codexstep_test.go| index f9ef3143..100f96c8 100644 |
| --- a/internal/runner/thin/codexstep_test.go |
| +++ b/internal/runner/thin/codexstep_test.go |
| @@ -43,10 +43,15 @@ func TestCodexStepApprovals(t *testing.T) { |
| } { |
| t.Run(tc.name, func(t *testing.T) { |
| out.Reset() |
| - answerApproval(rpc, connect.Message{ID: json.RawMessage(`"s1"`), Method: tc.method, Params: tc.params}, items, names) |
| + accepted := answerApproval(rpc, connect.Message{ID: json.RawMessage(`"s1"`), Method: tc.method, Params: tc.params}, items, names) |
| if !strings.Contains(out.String(), tc.want) || tc.want == `"decline"` && strings.Contains(out.String(), `"accept"`) { |
| t.Fatalf("answer %s, want %s", out.String(), tc.want) |
| } |
| + // A refusal is counted by the step (its reason when it then |
| + // commits nothing is tools_refused). |
| + if accepted != (tc.want == `"accept"`) { |
| + t.Fatalf("accepted %v for %s", accepted, out.String()) |
| + } |
| }) |
| } |
| } |
diff --git a/internal/runner/thin/engineer.go b/internal/runner/thin/engineer.go| index 8334008c..06770d02 100644 |
| --- a/internal/runner/thin/engineer.go |
| +++ b/internal/runner/thin/engineer.go |
| @@ -15,6 +15,7 @@ import ( |
| "slices" |
| "strings" |
| "sync" |
| + "sync/atomic" |
| "time" |
| "amadan.net/oficina/equipo/internal/runner" |
| @@ -344,7 +345,7 @@ func (e *Engineer) Exec(ctx context.Context, r stepRow, progress func(wire.StepR |
| sha, err := tree.Commit(ctx, commitMessage(r, summary), commitName, commitEmail) |
| switch { |
| case errors.Is(err, workspace.ErrNoChanges): |
| - return fail("no_changes", true) |
| + return fail(emptyStepReason(res), true) |
| case err != nil: |
| e.log("step commit", err) |
| return fail("workspace_refused", true) |
| @@ -740,6 +741,41 @@ type stepResult struct { |
| // modelGone: the provider said the step's model does not exist |
| // (§16.4, "After a step fails"). |
| modelGone bool |
| + // refused counts the tool requests Equipo refused during the run |
| + // (the permission callback's denials, Pi's asks, Codex's approvals). |
| + refused int64 |
| +} |
| + |
| +// emptyStepReason is why an Engineering step that committed nothing |
| +// stopped: tools_refused when Equipo refused tool requests the step |
| +// made, else no_changes. An older instance records tools_refused as |
| +// unknown (wire.StepReasons). |
| +func emptyStepReason(res stepResult) string { |
| + if res.refused > 0 { |
| + return "tools_refused" |
| + } |
| + return "no_changes" |
| +} |
| + |
| +// countRefusals is a permission callback that counts in n each request |
| +// perm denies. |
| +func countRefusals(perm func(json.RawMessage, provider.Policy) json.RawMessage, n *atomic.Int64) func(json.RawMessage, provider.Policy) json.RawMessage { |
| + return func(raw json.RawMessage, policy provider.Policy) json.RawMessage { |
| + out := perm(raw, policy) |
| + if denied(out) { |
| + n.Add(1) |
| + } |
| + return out |
| + } |
| +} |
| + |
| +// denied reports whether a permission callback's answer denies the |
| +// request (any answer that does not allow it). |
| +func denied(out json.RawMessage) bool { |
| + var a struct { |
| + Behavior string `json:"behavior"` |
| + } |
| + return json.Unmarshal(out, &a) != nil || a.Behavior != "allow" |
| } |
| // usage is the run's usage rows for the step attempt. |
| @@ -888,7 +924,9 @@ func (e *Engineer) run(ctx context.Context, r stepRow, tree workspace.TaskTree, |
| } |
| defer os.RemoveAll(scratch) |
| var policy provider.Policy |
| - set := toolSet{list: spec.tools, names: spec.names, permission: func(raw json.RawMessage) string { return string(spec.permission(raw, policy)) }} |
| + var refused atomic.Int64 |
| + permission := countRefusals(spec.permission, &refused) |
| + set := toolSet{list: spec.tools, names: spec.names, permission: func(raw json.RawMessage) string { return string(permission(raw, policy)) }} |
| tool, err := openToolSet(context.Background(), o.Runner.StateDir, set, spec.call) |
| if err != nil { |
| return stepResult{reason: "provider_failed", terminated: true} |
| @@ -965,7 +1003,7 @@ func (e *Engineer) run(ctx context.Context, r stepRow, tree workspace.TaskTree, |
| } |
| defer logFile.Close() |
| res := e.converse(ctx, proc, session, policy, b.Model, frames, logFile, limit, spec.prompt, spec.images, spec.stream, spec.activity) |
| - res.session = session |
| + res.session, res.refused = session, refused.Load() |
| res.terminated = stopStep(func() { proc.Stdin().Close() }, exited, kill, ctx.Err() == nil && res.reason == "", 10*time.Second, 30*time.Second) |
| if !res.terminated { |
| // The namespace record stays: a restarted runner verifies it. |
diff --git a/internal/runner/thin/pistep.go b/internal/runner/thin/pistep.go| index 04c4c313..3f902d96 100644 |
| --- a/internal/runner/thin/pistep.go |
| +++ b/internal/runner/thin/pistep.go |
| @@ -329,8 +329,9 @@ func (e *Engineer) piRun(ctx context.Context, l meteredLauncher, sess provider.S |
| tally := &pi.Tally{} |
| tctx, cancel := context.WithTimeout(ctx, limit) |
| defer cancel() |
| + refused := int64(0) |
| finish := func(res stepResult) stepResult { |
| - res.tail = tail.String() |
| + res.tail, res.refused = tail.String(), refused |
| // One row per model the provider reported (§16.5): a later |
| // request on another model is its own row, mismatch and price. |
| res.tokens = tally.Rows() |
| @@ -428,6 +429,7 @@ func (e *Engineer) piRun(ctx context.Context, l meteredLauncher, sess provider.S |
| } |
| case pi.KindAsk: |
| tail.add("Refused a call Equipo does not allow") |
| + refused++ |
| _ = l.Respond(tctx, sess, provider.Answer{RequestID: ev.RequestID, Behavior: "deny"}) |
| case pi.KindDone: |
| var d pi.Done |
diff --git a/internal/runner/thin/stop_reasons_test.go b/internal/runner/thin/stop_reasons_test.go| new file mode 100644 |
| index 00000000..c5704940 |
| --- /dev/null |
| +++ b/internal/runner/thin/stop_reasons_test.go |
| @@ -0,0 +1,67 @@ |
| +package thin |
| + |
| +import ( |
| + "encoding/json" |
| + "sync/atomic" |
| + "testing" |
| + |
| + "amadan.net/oficina/equipo/internal/runner/provider" |
| + "amadan.net/oficina/equipo/internal/runner/provider/claude" |
| + "amadan.net/oficina/equipo/internal/wire" |
| +) |
| + |
| +// An Engineering step that commits nothing ends no_changes, unless Equipo |
| +// refused tool requests the step made: then it ends tools_refused, so |
| +// the person reads why nothing changed. |
| +func TestEmptyStepReason(t *testing.T) { |
| + if got := emptyStepReason(stepResult{}); got != "no_changes" { |
| + t.Fatalf("no refusals: %q", got) |
| + } |
| + if got := emptyStepReason(stepResult{refused: 2}); got != "tools_refused" { |
| + t.Fatalf("refusals: %q", got) |
| + } |
| +} |
| + |
| +// Claude's permission callback counts each request it denies (here a |
| +// shell command under a policy that keeps none in the sandbox, and a |
| +// request with a field the step does not accept), and never one it |
| +// allows. |
| +func TestClaudeStepCountsRefusals(t *testing.T) { |
| + var n atomic.Int64 |
| + answer := countRefusals(claude.StepPermission, &n) |
| + policy := provider.Policy{} |
| + for _, raw := range []string{ |
| + `{"tool_name":"Bash","input":{"command":"go test ./..."}}`, |
| + `{"tool_name":"Read","input":{"file_path":"/workspace/README.md"},"extra":1}`, |
| + } { |
| + if out := answer(json.RawMessage(raw), policy); !denied(out) { |
| + t.Fatalf("%s allowed: %s", raw, out) |
| + } |
| + } |
| + if n.Load() != 2 { |
| + t.Fatalf("counted %d refusals, want 2", n.Load()) |
| + } |
| + allow := countRefusals(func(json.RawMessage, provider.Policy) json.RawMessage { |
| + return json.RawMessage(`{"behavior":"allow","updatedInput":{"file_path":"/workspace/README.md"}}`) |
| + }, &n) |
| + if out := allow(json.RawMessage(`{"tool_name":"Read","input":{"file_path":"/workspace/README.md"}}`), policy); denied(out) { |
| + t.Fatalf("allowed read counted as refused: %s", out) |
| + } |
| + if n.Load() != 2 { |
| + t.Fatalf("an allowed request counted: %d", n.Load()) |
| + } |
| +} |
| + |
| +// Pi asks Equipo about a call its extension does not allow; the step |
| +// refuses it. An Engineering step that then commits nothing ends |
| +// tools_refused; one that simply changed nothing ends no_changes. |
| +func TestPiEngineeringRefusedToolsReason(t *testing.T) { |
| + r := newPiRig(t, fakePiInstall(t), bigBudget) |
| + r.urgent() |
| + if rep := r.engineering("tk1", "e1", "read:/etc/hostname"); rep.State != wire.StepFailed || rep.Reason != "tools_refused" { |
| + t.Fatalf("refused: %+v", rep) |
| + } |
| + if rep := r.engineering("tk2", "e2", "nothing to do"); rep.State != wire.StepFailed || rep.Reason != "no_changes" { |
| + t.Fatalf("no changes: %+v", rep) |
| + } |
| +} |
diff --git a/internal/thintest/stop_reasons_contract_test.go b/internal/thintest/stop_reasons_contract_test.go| new file mode 100644 |
| index 00000000..9daf1f87 |
| --- /dev/null |
| +++ b/internal/thintest/stop_reasons_contract_test.go |
| @@ -0,0 +1,30 @@ |
| +package thintest |
| + |
| +import ( |
| + "testing" |
| + |
| + "amadan.net/oficina/equipo/internal/wire" |
| +) |
| + |
| +// An Engineering step whose tool requests Equipo refused reaches the |
| +// instance as tools_refused, recorded as sent (not unknown); a step that |
| +// changed nothing stays no_changes on the wire, whatever the task's |
| +// candidate (the instance chooses the words). |
| +func TestContractToolsRefusedIsDelivered(t *testing.T) { |
| + r := newToolRig(t) |
| + for i, reason := range []string{"tools_refused", "no_changes"} { |
| + key := "r" + itoa(i) |
| + id := taskID(r.t, r.call(key+"-rec", wire.ToolRecordTask, map[string]any{"repo": "oficina/sample", "title": "Task " + key, "brief": "The README says teh.", "separate": true})) |
| + if res := r.call(key+"-start", wire.ToolStartTask, map[string]string{"task": id, "brief": "Fix it."}); res.IsError { |
| + t.Fatalf("start: %+v", res) |
| + } |
| + _, body := r.expect(wire.FrameDispatch) |
| + d := body.(*wire.DispatchCommand) |
| + r.step(key+"-run", wire.StepReport{TaskID: id, StepID: d.StepID, Attempt: 1, State: wire.StepRunning, Family: "claude", Account: "claude-a"}) |
| + r.step(key+"-end", wire.StepReport{TaskID: id, StepID: d.StepID, Attempt: 1, State: wire.StepFailed, Reason: reason, Termination: true, Family: "claude", Account: "claude-a"}) |
| + k, err := r.client.Task(r.ctx, id) |
| + if err != nil || len(k.Steps) == 0 || k.Steps[len(k.Steps)-1].Reason != reason || k.Steps[len(k.Steps)-1].State != wire.StepFailed { |
| + t.Fatalf("%s recorded as %+v (%v)", reason, k.Steps, err) |
| + } |
| + } |
| +} |
diff --git a/internal/wire/stop_reasons_test.go b/internal/wire/stop_reasons_test.go| new file mode 100644 |
| index 00000000..3110330e |
| --- /dev/null |
| +++ b/internal/wire/stop_reasons_test.go |
| @@ -0,0 +1,32 @@ |
| +package wire_test |
| + |
| +import ( |
| + "encoding/json" |
| + "testing" |
| + |
| + "amadan.net/oficina/equipo/internal/wire" |
| +) |
| + |
| +// A runner reports an Engineering step whose tool requests Equipo |
| +// refused as tools_refused, a reason on the wire beside no_changes. |
| +// no_further_changes is the instance's own reading of no_changes (a |
| +// candidate from an earlier round) and never travels: a runner that |
| +// sent it would be recorded as unknown. An older instance records |
| +// tools_refused as unknown rather than refusing the report; an older |
| +// runner never sends it, and its no_changes reads as before. |
| +func TestToolsRefusedIsAStepReason(t *testing.T) { |
| + if !wire.StepReasons["tools_refused"] || !wire.StepReasons["no_changes"] { |
| + t.Fatal("tools_refused and no_changes are step reasons") |
| + } |
| + if wire.StepReasons["no_further_changes"] { |
| + t.Fatal("no_further_changes is the instance's words, not a runner's reason") |
| + } |
| + raw, err := json.Marshal(wire.StepReport{TaskID: "tk1", StepID: "s1", Attempt: 1, State: wire.StepFailed, Reason: "tools_refused", Termination: true}) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + var back wire.StepReport |
| + if err := json.Unmarshal(raw, &back); err != nil || back.Reason != "tools_refused" { |
| + t.Fatalf("round trip %+v %v", back, err) |
| + } |
| +} |
diff --git a/internal/wire/tasks.go b/internal/wire/tasks.go| index 186cd024..d4247d56 100644 |
| --- a/internal/wire/tasks.go |
| +++ b/internal/wire/tasks.go |
| @@ -998,6 +998,10 @@ var StepReasons = map[string]bool{ |
| "push_conflict": true, |
| "superseded": true, |
| "interrupted": true, |
| + // An Engineering step that committed nothing after Equipo refused |
| + // tool requests it made (no_changes otherwise). An older instance |
| + // records it as unknown. |
| + "tools_refused": true, |
| // Checks and review. |
| "candidate_unavailable": true, |
| "no_verdict": true, |
diff --git a/native/PROJECTS-REPORT.md b/native/PROJECTS-REPORT.md| index 48de95d7..8f1ab775 100644 |
| --- a/native/PROJECTS-REPORT.md |
| +++ b/native/PROJECTS-REPORT.md |
| @@ -268,3 +268,20 @@ The typed marker and list cursor add five chat source lines and two wire source |
| lines; their 51-line server regression is accounted for in measured budgets. |
| The 390-point normal-size SwiftUI host capture was inspected. Accessibility |
| sizes were checked for layout; those hidden-host images did not render reliably. |
| + |
| +## Main merge and final P3 follow-up |
| + |
| +Merged origin/main a697cde9 into native/projects after Fable approved a37ce08a. |
| +The three conflicted files were resolved as follows: |
| + |
| +- `.rastrillo/budgets.txt`: combined the native Projects/API copy and new |
| + Engineering stop-reason additions. Combined measured caps are 22101 source |
| + lines for equipo, 6828 for wire, and 11898 test lines for plan3test. |
| +- `docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md`: retained both appended |
| + acceptance inventories, including all native/API strings and main's two |
| + Engineering stop-reason strings, with their existing review markers. |
| +- `internal/plan3test/plan3_release_test.go`: retained the native/API acceptance |
| + predicates and main's approvedStopReasons predicate in the release guard. |
| + |
| +The merge's copy-release regression and size gate pass. Main's stop-reason |
| +implementation, tests and CI lane changes were retained by the automatic merge. |
diff --git a/scripts/ci-test.py b/scripts/ci-test.py| index 31824d94..581256d7 100755 |
| --- a/scripts/ci-test.py |
| +++ b/scripts/ci-test.py |
| @@ -78,7 +78,7 @@ LANES = [ |
| ("headless-review", [HEADLESS], ["TestHeadless/4_review", "TestHeadless/2b_access", "TestHeadless/runner_crash", "TestHeadless/2b_first_message", "TestHeadless/4_checks_honest", "TestHeadless/7_stream_resume", "TestHeadless/2b_notebook", "TestHeadless/2b_move_in", "TestHeadless/2b_desk_failure", "TestHeadless/cancel"]), # 76 |
| ("headless-connections", [HEADLESS], ["TestHeadlessConnections", "TestHeadlessTokenPasteEndToEnd", "TestHeadlessTokenConnection"]), # 76 without the quarantined |
| ("headless-mac", [HEADLESS], ["TestMacWorker", "TestHeadlessAttachments", "TestHeadlessPrewarm", "TestHeadless/1_first_token", "TestHeadless/6_quick_messages", "TestHeadless/8_instance_restart", "TestHeadless/3_runner_offline"]), # 77 |
| - ("headless-guards", [HEADLESS], ["TestHeadlessCopyRotation", "TestHeadlessPolicyGuards", "TestHeadlessRunnerKillLeavesNoCopies", "TestHeadlessNewHouseRuleStartsFresh", "TestHeadless/3_engineering", "TestHeadless/3_step_cancel", "TestHeadless/3_step_contained", "TestHeadless/3_empty_repo", "TestHeadless/3_empty_engineering", "TestHeadless/3_empty_merge", "TestHeadless/3_empty_merge_rebuilt", "TestHeadless/3_empty_fix_round"]), # 76 |
| + ("headless-guards", [HEADLESS], ["TestHeadlessCopyRotation", "TestHeadlessPolicyGuards", "TestHeadlessRunnerKillLeavesNoCopies", "TestHeadlessNewHouseRuleStartsFresh", "TestHeadless/3_engineering", "TestHeadless/3_step_cancel", "TestHeadless/3_step_contained", "TestHeadless/3_step_refused", "TestHeadless/3_empty_repo", "TestHeadless/3_empty_engineering", "TestHeadless/3_empty_merge", "TestHeadless/3_empty_merge_rebuilt", "TestHeadless/3_empty_fix_round"]), # 76 |
| # TestHeadlessAssistant (18 s on a shared 16 CPU box, 2026-11-13; its |
| # quick_website runs only where the site hosts are set) stays here: |
| # the lane was 115 s on that box with it, about 70 s hosted. |