Share edit location and check protected names in full segments

This commit is contained in:
2026-11-16 04:09:25 +00:00
parent 43ce620122
commit 475557e4de
23 changed files with 488 additions and 269 deletions

View File

@@ -171,13 +171,14 @@ func TestGenerateCandidatesInvalidCorrectionIsPreservedForLaterValidation(t *tes
responses: []StructuredCorrectionSet{
{
Corrections: []StructuredCorrectionProposal{
{SegmentReference: 0, OriginalText: "x", CorrectedText: ""},
{SegmentReference: 9, OriginalText: "x", CorrectedText: ""},
},
},
},
}
req := defaultRequest(t)
req.LLMClient = client
req.Interactions = llm.NewDiagnosticsWriter(t.TempDir())
result, err := GenerateCandidates(context.Background(), req)
if err != nil {
@@ -189,6 +190,20 @@ func TestGenerateCandidatesInvalidCorrectionIsPreservedForLaterValidation(t *tes
if result.Corrections[0].TargetSegmentID != 0 {
t.Fatalf("unexpected preserved correction: %+v", result.Corrections[0])
}
raw, err := os.ReadFile(result.Artifacts.ResponsePayloadPath)
if err != nil {
t.Fatal(err)
}
var evidence struct {
Decoded StructuredCorrectionSet `json:"decoded"`
}
if err := json.Unmarshal(raw, &evidence); err != nil {
t.Fatal(err)
}
if len(result.SegmentReferences) != 1 || result.SegmentReferences[0] != 9 ||
len(evidence.Decoded.Corrections) != 1 || evidence.Decoded.Corrections[0].SegmentReference != 9 {
t.Fatalf("lost model reference: result=%v artifact=%s", result.SegmentReferences, raw)
}
if len(result.Operations) != 1 || !result.Operations[0].Succeeded {
t.Fatalf("invalid individual correction should remain a usable response: %+v", result.Operations)
}