Report correction repair operations and outcomes
This commit is contained in:
@@ -21,6 +21,7 @@ type RepairAttempt struct {
|
||||
Counts outcomes.ExecutionCounts
|
||||
FailureReason outcomes.ReasonCode
|
||||
Succeeded bool
|
||||
Approved bool
|
||||
Operations []outcomes.Operation
|
||||
}
|
||||
|
||||
@@ -137,6 +138,11 @@ func repairCandidates(ctx context.Context, input validateSectionCandidatesInput,
|
||||
record.Revision = &revisionSnapshot
|
||||
record.Decisions = validated.decisions
|
||||
record.Rejected = validated.rejected
|
||||
for i := range validated.operations {
|
||||
proposalIndex, attemptNumber := original.ProposalIndex, attempt+1
|
||||
validated.operations[i].Reference.ProposalIndex = &proposalIndex
|
||||
validated.operations[i].Reference.RepairAttempt = &attemptNumber
|
||||
}
|
||||
record.Operations = validated.operations
|
||||
branch.Attempts = append(branch.Attempts, record)
|
||||
initial.operations = append(initial.operations, validated.operations...)
|
||||
@@ -146,6 +152,7 @@ func repairCandidates(ctx context.Context, input validateSectionCandidatesInput,
|
||||
return initial, branches, validationErr
|
||||
}
|
||||
if len(validated.approved) == 1 {
|
||||
branch.Attempts[len(branch.Attempts)-1].Approved = true
|
||||
branch.Outcome = "approved"
|
||||
initial.approved = append(initial.approved, current)
|
||||
retained := initial.filtered[:0]
|
||||
@@ -177,3 +184,25 @@ func repairCandidates(ctx context.Context, input validateSectionCandidatesInput,
|
||||
}
|
||||
return initial, branches, nil
|
||||
}
|
||||
|
||||
func repairOperations(input validateSectionCandidatesInput, branches []RepairOutcome) []outcomes.Operation {
|
||||
var result []outcomes.Operation
|
||||
section := 0
|
||||
if input.SectionIndex != nil {
|
||||
section = *input.SectionIndex
|
||||
}
|
||||
for _, branch := range branches {
|
||||
for i, attempt := range branch.Attempts {
|
||||
index, number := branch.ProposalIndex, i+1
|
||||
operation := outcomes.Operation{Reference: outcomes.Reference{StageIndex: &input.Spec.Index, StageID: input.Spec.ID, ModuleKey: input.Spec.ModuleKey, ModuleInstance: input.Spec.InstanceName, SectionIndex: section, Kind: outcomes.OperationCorrectionRepair, ProposalIndex: &index, RepairAttempt: &number}, Counts: attempt.Counts, Succeeded: attempt.Succeeded, FailureReason: attempt.FailureReason, ProposalIndices: []int{index}}
|
||||
if attempt.Succeeded {
|
||||
operation.RecoveryReasons = outcomes.ExecutionRecoveries(attempt.Counts)
|
||||
if attempt.Approved {
|
||||
operation.RecoveryReasons = append(operation.RecoveryReasons, outcomes.RecoveryCorrectionRevised)
|
||||
}
|
||||
}
|
||||
result = append(result, operation)
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
@@ -121,6 +121,9 @@ func TestRunnerAppliesRevisionsInOriginalOrder(t *testing.T) {
|
||||
if out.FinalTranscript.Segments[0].Text != "dog" || len(out.WorkUnits) != 1 || len(out.WorkUnits[0].Repairs) != 1 || out.WorkUnits[0].Repairs[0].Outcome != "approved_skipped" || out.WorkUnits[0].CorrectionsApplied != 1 || len(out.ModuleResults[0].SkippedChanges) != 1 || out.ModuleResults[0].SkippedChanges[0].ProposalIndex != 1 {
|
||||
t.Fatalf("output=%+v section=%d", out, sectionIndex)
|
||||
}
|
||||
if len(out.WorkUnits[0].Operations) != 1 || out.WorkUnits[0].Operations[0].Reference.Kind != outcomes.OperationCorrectionRepair || len(out.WorkUnits[0].Operations[0].RecoveryReasons) != 1 || out.WorkUnits[0].Operations[0].RecoveryReasons[0] != outcomes.RecoveryCorrectionRevised {
|
||||
t.Fatalf("repair operations: %+v", out.WorkUnits[0].Operations)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRepairRevalidatesEarlierApprovalAndRetainsUnrelatedApprovalOnFailure(t *testing.T) {
|
||||
|
||||
@@ -564,6 +564,7 @@ func runModulePipeline(ctx context.Context, input collectSectionProposalsInput)
|
||||
}
|
||||
repairInput := validateSectionCandidatesInput{Spec: input.Spec, Policy: input.Policy, WorkingTranscript: transcriptFromSection(sectionResult.section), SectionIndex: §ionMetadata.Index, Validators: validatorsOrdered, SectionEnriched: enriched, Exchange: sectionResult.exchange, ValidationLLMClient: input.ValidationClient, DiagnosticsDir: input.ValidationDiagnosticsDir, GlossaryView: input.GlossaryView, ReportDiagnosticError: input.ReportDiagnosticError}
|
||||
validated, repairs, err = repairCandidates(runCtx, repairInput, sectionResult.references, validated, promptID)
|
||||
validated.operations = append(validated.operations, repairOperations(repairInput, repairs)...)
|
||||
}
|
||||
setErr(err)
|
||||
validationResults <- sectionValidationResult{
|
||||
|
||||
Reference in New Issue
Block a user