Drop no-op suggestions where replacement equals original
The checkpoint model sometimes "flags" a correct sentence and echoes it verbatim as the replacement, producing a card whose before/after are identical and whose explanation says it's already fine — a suggestion that suggests nothing. ParseCheckpoint already dropped empty-original items; also drop these no-ops. Awareness-only families (voice) carry an empty replacement, so the guard only fires on the edit families. Claude-Session: https://claude.ai/code/session_016Yr6jELuRc7hyzYLccQKZd
This commit is contained in:
@@ -89,6 +89,14 @@ func ParseCheckpoint(raw string) ([]RawSuggestion, error) {
|
|||||||
if s.Original == "" {
|
if s.Original == "" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
// Drop no-ops: the model sometimes "flags" a correct sentence and echoes
|
||||||
|
// it verbatim as the replacement, producing a card whose before/after are
|
||||||
|
// identical and whose explanation says it's already fine — a suggestion
|
||||||
|
// that suggests nothing. Awareness-only families (voice) carry an empty
|
||||||
|
// replacement, so this only ever fires on the edit families.
|
||||||
|
if s.Replacement != "" && s.Original == s.Replacement {
|
||||||
|
continue
|
||||||
|
}
|
||||||
out = append(out, s)
|
out = append(out, s)
|
||||||
}
|
}
|
||||||
return out, nil
|
return out, nil
|
||||||
|
|||||||
@@ -37,6 +37,25 @@ func TestParseCheckpoint(t *testing.T) {
|
|||||||
raw: "I could not find any issues!",
|
raw: "I could not find any issues!",
|
||||||
wantErr: true,
|
wantErr: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
// A correct sentence echoed verbatim as its own replacement is a card
|
||||||
|
// that suggests nothing — dropped. The second item is a real edit.
|
||||||
|
name: "drops no-op where replacement equals original",
|
||||||
|
raw: `{"suggestions":[{"original":"It wasn't the most graceful morning.","replacement":"It wasn't the most graceful morning.","explanation":"used correctly here","type":"idiom"},{"original":"teh","replacement":"the","explanation":"typo","type":"grammar"}]}`,
|
||||||
|
want: 1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// Whitespace-only difference is still a no-op once both are trimmed.
|
||||||
|
name: "drops no-op after whitespace trim",
|
||||||
|
raw: `{"suggestions":[{"original":"the cat sat","replacement":" the cat sat ","explanation":"already fine","type":"grammar"}]}`,
|
||||||
|
want: 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// Awareness-only voice flags carry an empty replacement and must survive.
|
||||||
|
name: "keeps awareness-only flag with empty replacement",
|
||||||
|
raw: `{"suggestions":[{"original":"a long run-on passage","replacement":"","explanation":"this drifts from your voice","type":"voice"}]}`,
|
||||||
|
want: 1,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "braces inside string values",
|
name: "braces inside string values",
|
||||||
raw: `{"suggestions":[{"original":"use {x}","replacement":"use x","explanation":"drop the braces","type":"clarity"}]}`,
|
raw: `{"suggestions":[{"original":"use {x}","replacement":"use x","explanation":"drop the braces","type":"clarity"}]}`,
|
||||||
|
|||||||
Reference in New Issue
Block a user