MCPcopy Index your code
hub / github.com/codehamr/codehamr / TestVerifyNudgeFiresOnceAtMinRounds

Function TestVerifyNudgeFiresOnceAtMinRounds

internal/tui/tui_test.go:2024–2065  ·  view source on GitHub ↗

TestVerifyNudgeFiresOnceAtMinRounds: the finish re-grounding nudge trips one soft system note only once a turn has done real work (toolRounds >= verifyNudgeMinRounds), and never below it; the latch keeps it to once per turn.

(t *testing.T)

Source from the content-addressed store, hash-verified

2022 m.maybeRunawayNudge()
2023 if n := countSystem(m.history); n != 1 {
2024 t.Fatalf("overshooting the cap must still fire once, got %d system notes", n)
2025 }
2026 // A later drain in the same turn must not re-fire.
2027 m.toolRounds = maxToolRounds + 10
2028 m.maybeRunawayNudge()
2029 if n := countSystem(m.history); n != 1 {
2030 t.Fatalf("latch must prevent a second nudge in the same turn, got %d", n)
2031 }
2032}
2033
2034// TestEndTurnResetsToolRounds: the runaway counter is per-turn, so endTurn must
2035// zero it or the next turn inherits a head start toward the cap.
2036func TestEndTurnResetsToolRounds(t *testing.T) {
2037 m := newTestModel(t, func(http.ResponseWriter, *http.Request) {})
2038 m.installTurnContext()
2039 m.toolRounds = 42
2040 m.endTurn()
2041 if m.toolRounds != 0 {
2042 t.Fatalf("endTurn must reset toolRounds, got %d", m.toolRounds)
2043 }
2044}
2045
2046// TestVerifyNudgeFiresOnceAtMinRounds: the finish re-grounding nudge trips one
2047// soft system note only once a turn has done real work (toolRounds >=
2048// verifyNudgeMinRounds), and never below it; the latch keeps it to once per turn.
2049func TestVerifyNudgeFiresOnceAtMinRounds(t *testing.T) {
2050 m := newTestModel(t, func(http.ResponseWriter, *http.Request) {})
2051
2052 m.toolRounds = verifyNudgeMinRounds - 1
2053 if m.maybeVerifyNudge() {
2054 t.Fatal("below the min-rounds gate must not nudge")
2055 }
2056 if n := countSystem(m.history); n != 0 {
2057 t.Fatalf("a trivial turn must not be re-grounded, got %d system notes", n)
2058 }
2059
2060 m.toolRounds = verifyNudgeMinRounds
2061 if !m.maybeVerifyNudge() {
2062 t.Fatal("at the min-rounds gate the nudge must fire and report it nudged")
2063 }
2064 if n := countSystem(m.history); n != 1 {
2065 t.Fatalf("at the gate expected one re-grounding note, got %d:\n%+v", n, m.history)
2066 }
2067 last := m.history[len(m.history)-1]
2068 if !strings.Contains(last.Content, "unverified") || !strings.Contains(last.Content, "acceptance criteria") {

Callers

nothing calls this directly

Calls 3

newTestModelFunction · 0.85
countSystemFunction · 0.85
maybeVerifyNudgeMethod · 0.80

Tested by

no test coverage detected