MCPcopy Create free account
hub / github.com/codehamr/codehamr / TestHamrpassRejectsControlChars

Function TestHamrpassRejectsControlChars

internal/tui/tui_test.go:3049–3079  ·  view source on GitHub ↗

TestHamrpassRejectsControlChars: a key with an embedded escape / NUL / DEL must be rejected by hamrpassValidate, not persisted, else every dial-out errors with net/http's cryptic "invalid header field value for Authorization". Real hamrpass keys are ASCII-printable.

(t *testing.T)

Source from the content-addressed store, hash-verified

3047func TestFailureStreakSurvivesBatchedSuccess(t *testing.T) {
3048 m := newTestModel(t, func(http.ResponseWriter, *http.Request) {})
3049 for range maxToolFailStreak {
3050 m.lastToolKey = "edit_file|src/app.js"
3051 m.recordToolOutcome(tools.EditFileName, "(not found: old_string does not appear in src/app.js)")
3052 m.lastToolKey = "read_file|src/app.js"
3053 m.recordToolOutcome(tools.ReadFileName, "some file content")
3054 }
3055 if m.failStreak < maxToolFailStreak {
3056 t.Fatalf("interleaved READ success reset the streak: got %d, want >= %d", m.failStreak, maxToolFailStreak)
3057 }
3058 m.maybeFailureNudge()
3059 if n := countSystem(m.history); n != 1 {
3060 t.Fatalf("a same target failure streak must nudge, got %d system notes", n)
3061 }
3062 // A success on the FAILING target still clears it: that is real recovery.
3063 m.lastToolKey = "edit_file|src/app.js"
3064 m.failKey, m.failStreak = "edit_file|src/app.js", 3
3065 m.recordToolOutcome(tools.EditFileName, "edited src/app.js")
3066 if m.failStreak != 0 {
3067 t.Fatalf("a success on the failing target must clear the streak, got %d", m.failStreak)
3068 }
3069}
3070
3071// TestVerifyNudgeSkipsReadOnlyTurn: a turn that only read files produced no
3072// artifact that could be falsely called green, so re grounding it is a wasted
3073// round trip on every research question.
3074func TestVerifyNudgeSkipsReadOnlyTurn(t *testing.T) {
3075 m := newTestModel(t, func(http.ResponseWriter, *http.Request) {})
3076 m.toolRounds = verifyNudgeMinRounds + 20
3077 m.llmRounds = verifyNudgeMinRounds + 20
3078 m.turnActed = false
3079 m.history = []chmctx.Message{
3080 {Role: chmctx.RoleUser, Content: "how does packing work?"},
3081 {Role: chmctx.RoleAssistant, Content: "Pack walks newest-first into Budget()."},
3082 }

Callers

nothing calls this directly

Calls 3

newTestModelFunction · 0.85
hamrpassValidateFunction · 0.85
runSlashMethod · 0.80

Tested by

no test coverage detected