| 1 | package thintest |
| 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | |
| 6 | "amadan.net/oficina/equipo/internal/wire" |
| 7 | ) |
| 8 | |
| 9 | // An Engineering step whose tool requests Equipo refused reaches the |
| 10 | // instance as tools_refused, recorded as sent (not unknown); a step that |
| 11 | // changed nothing stays no_changes on the wire, whatever the task's |
| 12 | // candidate (the instance chooses the words). |
| 13 | func TestContractToolsRefusedIsDelivered(t *testing.T) { |
| 14 | r := newToolRig(t) |
| 15 | for i, reason := range []string{"tools_refused", "no_changes"} { |
| 16 | key := "r" + itoa(i) |
| 17 | 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})) |
| 18 | if res := r.call(key+"-start", wire.ToolStartTask, map[string]string{"task": id, "brief": "Fix it."}); res.IsError { |
| 19 | t.Fatalf("start: %+v", res) |
| 20 | } |
| 21 | _, body := r.expect(wire.FrameDispatch) |
| 22 | d := body.(*wire.DispatchCommand) |
| 23 | r.step(key+"-run", wire.StepReport{TaskID: id, StepID: d.StepID, Attempt: 1, State: wire.StepRunning, Family: "claude", Account: "claude-a"}) |
| 24 | 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"}) |
| 25 | k, err := r.client.Task(r.ctx, id) |
| 26 | if err != nil || len(k.Steps) == 0 || k.Steps[len(k.Steps)-1].Reason != reason || k.Steps[len(k.Steps)-1].State != wire.StepFailed { |
| 27 | t.Fatalf("%s recorded as %+v (%v)", reason, k.Steps, err) |
| 28 | } |
| 29 | } |
| 30 | } |
| 31 | |