Reuse validation facts when attributing skipped edits
This commit is contained in:
@@ -762,13 +762,19 @@ func validateSectionCandidates(ctx context.Context, input validateSectionCandida
|
||||
feedback := input.Spec.Settings.LLM.CorrectionRepairAttempts > 0
|
||||
var blocked, noEffect map[int]bool
|
||||
evidence := validators.Request{WorkingTranscript: input.WorkingTranscript, Section: input.Section, ReplacementPolicy: input.Policy, IndependentEvidence: feedback}
|
||||
if feedback {
|
||||
blocked, noEffect = make(map[int]bool), make(map[int]bool)
|
||||
evidence.Previews = make(map[int]proposals.SegmentPreviewResult)
|
||||
if evidence.Section == nil && len(input.SectionEnriched) > 0 {
|
||||
if len(input.SectionEnriched) > 0 && len(input.Validators) > 0 {
|
||||
if feedback {
|
||||
evidence.Previews = make(map[int]proposals.SegmentPreviewResult)
|
||||
} else {
|
||||
evidence.PreviewApplicability = make(map[int]bool)
|
||||
}
|
||||
if evidence.Section == nil {
|
||||
evidence.Section = validators.NewSectionLookup(input.WorkingTranscript)
|
||||
}
|
||||
}
|
||||
if feedback {
|
||||
blocked, noEffect = make(map[int]bool), make(map[int]bool)
|
||||
}
|
||||
|
||||
for validatorOrder, validator := range input.Validators {
|
||||
if err := ctx.Err(); err != nil {
|
||||
@@ -782,7 +788,7 @@ func validateSectionCandidates(ctx context.Context, input validateSectionCandida
|
||||
vResult, err := validator.Validate(ctx, validators.Request{
|
||||
StageIndex: &input.Spec.Index, StageID: input.Spec.ID,
|
||||
WorkingTranscript: input.WorkingTranscript,
|
||||
Section: evidence.Section, Previews: evidence.Previews,
|
||||
Section: evidence.Section, Previews: evidence.Previews, PreviewApplicability: evidence.PreviewApplicability,
|
||||
CandidateProposal: submitted,
|
||||
ModuleKey: input.Spec.ModuleKey,
|
||||
ModuleInstance: input.Spec.InstanceName,
|
||||
@@ -899,6 +905,19 @@ func validateSectionCandidates(ctx context.Context, input validateSectionCandida
|
||||
}
|
||||
}
|
||||
}
|
||||
for i := range eligible {
|
||||
index := eligible[i].ProposalIndex
|
||||
applicable, checked := evidence.PreviewApplicability[index]
|
||||
if preview, ok := evidence.Previews[index]; ok {
|
||||
applicable, checked = preview.Applicable, true
|
||||
}
|
||||
if checked {
|
||||
eligible[i].OriginalApplicability = proposals.Inapplicable
|
||||
if applicable {
|
||||
eligible[i].OriginalApplicability = proposals.Applicable
|
||||
}
|
||||
}
|
||||
}
|
||||
return validateSectionCandidatesResult{
|
||||
approved: eligible,
|
||||
decisions: decisions,
|
||||
@@ -947,14 +966,19 @@ func findApplyFiltering(sections []chunking.Section, approved []proposals.Enrich
|
||||
if len(skipped) == 0 {
|
||||
return nil
|
||||
}
|
||||
byIndex := make(map[int]proposals.EnrichedCorrectionProposal, len(approved))
|
||||
byIndex := make(map[int]proposals.EnrichedCorrectionProposal)
|
||||
for _, proposal := range approved {
|
||||
if proposal.OriginalApplicability != proposals.Applicable {
|
||||
byIndex[proposal.ProposalIndex] = proposal
|
||||
}
|
||||
}
|
||||
if len(byIndex) == 0 {
|
||||
return nil
|
||||
}
|
||||
sectionPosition := make(map[int]int, len(sections))
|
||||
for pos, section := range sections {
|
||||
sectionPosition[section.Index] = pos
|
||||
}
|
||||
for _, proposal := range approved {
|
||||
byIndex[proposal.ProposalIndex] = proposal
|
||||
}
|
||||
lookups := make(map[int]*validators.SectionLookup)
|
||||
filtered := make(map[int][]outcomes.FilteredProposal)
|
||||
for _, skip := range skipped {
|
||||
@@ -967,18 +991,20 @@ func findApplyFiltering(sections []chunking.Section, approved []proposals.Enrich
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
lookup := lookups[pos]
|
||||
if lookup == nil {
|
||||
lookup = validators.NewSectionLookup(transcriptFromSection(sections[pos]))
|
||||
lookups[pos] = lookup
|
||||
}
|
||||
var segment *schema.Segment
|
||||
if i, found := lookup.Position(proposal.TargetSegmentID); found {
|
||||
segment = §ions[pos].Segments[i]
|
||||
}
|
||||
// A previously applicable proposal can become stale during application.
|
||||
if proposals.PreviewProposalForSegment(segment, proposal.CorrectionProposal, policy).Applicable {
|
||||
continue
|
||||
if proposal.OriginalApplicability == proposals.ApplicabilityUnknown {
|
||||
lookup := lookups[pos]
|
||||
if lookup == nil {
|
||||
lookup = validators.NewSectionLookup(&schema.Transcript{Segments: sections[pos].Segments})
|
||||
lookups[pos] = lookup
|
||||
}
|
||||
var segment *schema.Segment
|
||||
if i, found := lookup.Position(proposal.TargetSegmentID); found {
|
||||
segment = §ions[pos].Segments[i]
|
||||
}
|
||||
// A previously applicable proposal can become stale during application.
|
||||
if proposals.PreviewProposalForSegment(segment, proposal.CorrectionProposal, policy).Applicable {
|
||||
continue
|
||||
}
|
||||
}
|
||||
filtered[pos] = append(filtered[pos], outcomes.FilteredProposal{ProposalIndex: skip.ProposalIndex, Reason: reason, Count: 1})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user