Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,8 @@ jobs:
go test -run='^$' -fuzz=FuzzParseMessage -fuzztime=60s ./internal/session
go test -run='^$' -fuzz=FuzzParseSessionMeta -fuzztime=60s ./internal/session
go test -run='^$' -fuzz=FuzzParseDeltaSpec -fuzztime=60s ./internal/spec
go test -run='^$' -fuzz=FuzzParseSearchReplace -fuzztime=60s ./internal/engine/diff
go test -run='^$' -fuzz=FuzzParseToolCallResult -fuzztime=60s ./internal/mcp

# -------------------------------------------------------------------------
# 10. Smoke — build rho and verify ecosystem CLI wiring.
Expand Down
26 changes: 26 additions & 0 deletions internal/engine/diff/searchreplace_fuzz_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package diff

import "testing"

// FuzzParseSearchReplace ensures the SEARCH/REPLACE parser and applier never
// panic on arbitrary model output.
func FuzzParseSearchReplace(f *testing.F) {
f.Add("<<<<<<< SEARCH\nold\n=======\nnew\n>>>>>>> REPLACE")
f.Add("")
f.Add("<<<<<<< SEARCH\nonly a search\n>>>>>>> REPLACE")
f.Add("prose before\n<<<<<<< SEARCH\na\n=======\nb\n>>>>>>> REPLACE\nprose after")

f.Fuzz(func(t *testing.T, text string) {
blocks := ParseSearchReplace(text)
_, _ = ApplySearchReplace("old\ncontent\n", blocks)
_, _ = ApplySearchReplace("", blocks)
})
}

func BenchmarkParseSearchReplace(b *testing.B) {
const in = "prose\n<<<<<<< SEARCH\nold\n=======\nnew\n>>>>>>> REPLACE\n"
b.ReportAllocs()
for i := 0; i < b.N; i++ {
_ = ParseSearchReplace(in)
}
}
19 changes: 19 additions & 0 deletions internal/mcp/mcp_fuzz_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package mcp

import (
"encoding/json"
"testing"
)

// FuzzParseToolCallResult ensures the MCP tool-result parser never panics on
// arbitrary server responses.
func FuzzParseToolCallResult(f *testing.F) {
f.Add([]byte(`{"content":[{"type":"text","text":"hi"}]}`))
f.Add([]byte(`{"content":[{"type":"image","data":"..."}],"isError":true}`))
f.Add([]byte(`not json`))
f.Add([]byte(`{"content":[{"type":"text","text":"a"},{"type":"text","text":"b"}]}`))

f.Fuzz(func(t *testing.T, b []byte) {
_, _ = parseToolCallResult(json.RawMessage(b))
})
}
Loading
Loading