TestVerifyNudgeEndToEndRePromptsThenFinishes drives a full turn that does real work (8 bash rounds) then "finishes" with a confident summary. The finish re-grounding nudge must inject one note and re-prompt exactly once, and the turn must then complete idle: the false-green-finish path, end to end.
(t *testing.T)
| 2177 | m.installTurnContext() |
| 2178 | m.phase = phaseStreaming |
| 2179 | m.toolRounds = verifyNudgeMinRounds + 20 |
| 2180 | m.history = []chmctx.Message{ |
| 2181 | {Role: chmctx.RoleUser, Content: "build galaxy.html"}, |
| 2182 | {Role: chmctx.RoleAssistant, Content: "Built galaxy.html. unverified: browser runtime - no browser in this sandbox to load it."}, |
| 2183 | } |
| 2184 | out, cmd := m.handleStreamClosed() |
| 2185 | mm := out.(Model) |
| 2186 | if cmd != nil { |
| 2187 | t.Fatal("an honest unverified finish must not be re-prompted") |
| 2188 | } |
| 2189 | if mm.phase != phaseIdle { |
| 2190 | t.Fatalf("an honest unverified finish must finalize, got phase %v", mm.phase) |
| 2191 | } |
| 2192 | if mm.verifyNudged { |
| 2193 | t.Fatal("a suppressed nudge must not latch verifyNudged") |
| 2194 | } |
| 2195 | if n := countSystem(mm.history); n != 0 { |
| 2196 | t.Fatalf("an honest unverified finish must not be re-grounded, got %d system notes", n) |
| 2197 | } |
| 2198 | } |
| 2199 | |
| 2200 | // TestVerifyNudgeEndToEndRePromptsThenFinishes drives a full turn that does real |
| 2201 | // work (8 bash rounds) then "finishes" with a confident summary. The finish |
| 2202 | // re-grounding nudge must inject one note and re-prompt exactly once, and the |
| 2203 | // turn must then complete idle: the false-green-finish path, end to end. |
| 2204 | func TestVerifyNudgeEndToEndRePromptsThenFinishes(t *testing.T) { |
| 2205 | var round int |
| 2206 | handler := func(w http.ResponseWriter, _ *http.Request) { |
| 2207 | w.Header().Set("Content-Type", "text/event-stream") |
| 2208 | round++ |
| 2209 | if round <= verifyNudgeMinRounds { |
| 2210 | // A real tool call so toolRounds climbs to the gate. |
| 2211 | fmt.Fprintf(w, "data: {\"choices\":[{\"delta\":{\"tool_calls\":[{\"index\":0,\"id\":\"c%d\",\"function\":{\"name\":\"bash\",\"arguments\":\"{\\\"cmd\\\":\\\"echo step\\\"}\"}}]}}]}\n\n", round) |
| 2212 | fmt.Fprint(w, "data: {\"choices\":[{\"delta\":{},\"finish_reason\":\"tool_calls\"}],\"usage\":{\"completion_tokens\":5}}\n\n") |
| 2213 | fmt.Fprint(w, "data: [DONE]\n\n") |
| 2214 | return |
| 2215 | } |
| 2216 | // A confident, toolless summary, what the galaxy runs shipped. |
| 2217 | fmt.Fprint(w, "data: {\"choices\":[{\"delta\":{\"content\":\"Done - galaxy.html built with all features.\"}}]}\n\n") |
| 2218 | fmt.Fprint(w, "data: {\"choices\":[{\"delta\":{},\"finish_reason\":\"stop\"}],\"usage\":{\"completion_tokens\":6}}\n\n") |
| 2219 | fmt.Fprint(w, "data: [DONE]\n\n") |
nothing calls this directly
no test coverage detected