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) } } }