Add module correction repair prompts
This commit is contained in:
23
internal/framework/proposal_generation/repair_request.go
Normal file
23
internal/framework/proposal_generation/repair_request.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package proposal_generation
|
||||
|
||||
import "encoding/json"
|
||||
|
||||
// RepairFinding contains safe validator feedback for the current correction.
|
||||
type RepairFinding struct {
|
||||
Status string `json:"status,omitempty"`
|
||||
Validator string `json:"validator"`
|
||||
Reason string `json:"reason"`
|
||||
Explanation string `json:"explanation,omitempty"`
|
||||
}
|
||||
|
||||
// RepairRequest identifies the proposal version and its ordered findings.
|
||||
type RepairRequest struct {
|
||||
ProposalRef int `json:"proposal_ref"`
|
||||
Correction StructuredCorrectionProposal `json:"correction"`
|
||||
Findings []RepairFinding `json:"findings"`
|
||||
}
|
||||
|
||||
func (r RepairRequest) JSON() (string, error) {
|
||||
data, err := json.Marshal(r)
|
||||
return string(data), err
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package proposal_generation
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestRepairRequestJSONPreservesCurrentVersionAndFindings(t *testing.T) {
|
||||
request := RepairRequest{ProposalRef: 3, Correction: StructuredCorrectionProposal{SegmentReference: 2, OriginalText: " ", CorrectedText: "", Confidence: 0.7}, Findings: []RepairFinding{{Validator: "first", Reason: "rejected", Explanation: "detail"}, {Validator: "second", Status: "unavailable", Reason: "provider_failed"}}}
|
||||
text, err := request.JSON()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var got RepairRequest
|
||||
if err := json.Unmarshal([]byte(text), &got); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got.ProposalRef != 3 || got.Correction != request.Correction || len(got.Findings) != 2 || got.Findings[0] != request.Findings[0] || got.Findings[1] != request.Findings[1] {
|
||||
t.Fatalf("request: %+v", got)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user