Retain processing evidence only for selected outputs
This commit is contained in:
@@ -45,8 +45,6 @@ type ModuleResult struct {
|
||||
ModuleInstance string `json:"module_instance"`
|
||||
ReplacementPolicy proposals.ReplacementPolicy `json:"replacement_policy"`
|
||||
Status string `json:"status"`
|
||||
ProposalCount int `json:"proposal_count"`
|
||||
Operations []outcomes.Operation `json:"operations,omitempty"`
|
||||
ValidatorDecisions []ValidatorDecisionRecord `json:"validator_decisions,omitempty"`
|
||||
ValidatorRejected []ValidatorRejectedChange `json:"validator_rejected,omitempty"`
|
||||
AppliedChanges []proposals.AppliedChange `json:"applied_changes,omitempty"`
|
||||
@@ -95,13 +93,32 @@ type ValidatorRejectedChange struct {
|
||||
Message string `json:"message"`
|
||||
}
|
||||
|
||||
// EvidenceSelection selects the detailed views consumed by the invocation.
|
||||
type EvidenceSelection struct {
|
||||
Reports bool
|
||||
Debug bool
|
||||
}
|
||||
|
||||
type evidenceNeeds struct {
|
||||
reports bool
|
||||
decisions bool
|
||||
candidates bool
|
||||
}
|
||||
|
||||
func selectEvidence(selection *EvidenceSelection) evidenceNeeds {
|
||||
if selection == nil {
|
||||
return evidenceNeeds{reports: true, decisions: true}
|
||||
}
|
||||
return evidenceNeeds{reports: selection.Reports, decisions: selection.Debug, candidates: selection.Debug}
|
||||
}
|
||||
|
||||
// RunInput is the deterministic runner input.
|
||||
type RunInput struct {
|
||||
Config *config.Config
|
||||
Transcript *schema.Transcript
|
||||
ModuleSpecs []contracts.ModuleRunSpec
|
||||
Interactions structuredoutput.InteractionSink
|
||||
CaptureCandidates bool
|
||||
Config *config.Config
|
||||
Transcript *schema.Transcript
|
||||
ModuleSpecs []contracts.ModuleRunSpec
|
||||
Interactions structuredoutput.InteractionSink
|
||||
Evidence *EvidenceSelection
|
||||
}
|
||||
|
||||
// RunOutput is the deterministic runner output.
|
||||
@@ -109,6 +126,7 @@ type RunOutput struct {
|
||||
FinalTranscript *schema.Transcript `json:"-"`
|
||||
ModuleResults []ModuleResult `json:"module_results"`
|
||||
Sections []contracts.SectionMetadata `json:"sections"`
|
||||
Totals *outcomes.WorkTotals `json:"-"`
|
||||
InventoryAvailable bool `json:"-"`
|
||||
WorkUnits []WorkUnitOutcome `json:"work_units"`
|
||||
Candidates []proposals.EnrichedCorrectionProposal `json:"-"`
|
||||
@@ -132,54 +150,70 @@ func (r *Runner) Run(ctx context.Context, input RunInput) (RunOutput, error) {
|
||||
if err != nil {
|
||||
return RunOutput{FinalTranscript: working}, &ExecutionFailure{Phase: "chunking", Cause: fmt.Errorf("chunk normalized transcript: %w", err)}
|
||||
}
|
||||
inventory := make([]contracts.SectionMetadata, len(sections))
|
||||
workUnits := make([]WorkUnitOutcome, 0, len(input.ModuleSpecs)*len(sections))
|
||||
evidence := selectEvidence(input.Evidence)
|
||||
totals := outcomes.WorkTotals{Total: len(input.ModuleSpecs) * len(sections)}
|
||||
var inventory []contracts.SectionMetadata
|
||||
var workUnits []WorkUnitOutcome
|
||||
var candidates []proposals.EnrichedCorrectionProposal
|
||||
for i, section := range sections {
|
||||
inventory[i] = contracts.SectionMetadataFromSection(section)
|
||||
}
|
||||
for moduleIndex, spec := range input.ModuleSpecs {
|
||||
for _, section := range inventory {
|
||||
workUnits = append(workUnits, WorkUnitOutcome{
|
||||
ModuleIndex: moduleIndex, StageIndex: spec.Index, StageID: spec.ID, ModuleKey: spec.ModuleKey,
|
||||
ModuleInstance: spec.InstanceName, Section: section,
|
||||
State: outcomes.WorkNotStarted,
|
||||
})
|
||||
if evidence.reports {
|
||||
inventory = make([]contracts.SectionMetadata, len(sections))
|
||||
for i, section := range sections {
|
||||
inventory[i] = contracts.SectionMetadataFromSection(section)
|
||||
}
|
||||
workUnits = make([]WorkUnitOutcome, 0, totals.Total)
|
||||
for moduleIndex, spec := range input.ModuleSpecs {
|
||||
for _, section := range inventory {
|
||||
workUnits = append(workUnits, newWorkUnit(spec, section, moduleIndex))
|
||||
}
|
||||
}
|
||||
}
|
||||
snapshot := func() RunOutput {
|
||||
return RunOutput{
|
||||
FinalTranscript: transcriptFromSections(sections), ModuleResults: results,
|
||||
Sections: inventory, InventoryAvailable: true, WorkUnits: workUnits, Candidates: candidates,
|
||||
Sections: inventory, InventoryAvailable: true, Totals: &totals, WorkUnits: workUnits, Candidates: candidates,
|
||||
}
|
||||
}
|
||||
|
||||
for moduleIndex, spec := range input.ModuleSpecs {
|
||||
execution, err := r.executeModule(ctx, spec, sections, input.Interactions)
|
||||
units := workUnits[moduleIndex*len(sections) : (moduleIndex+1)*len(sections)]
|
||||
copy(units, execution.pipeline.WorkUnits)
|
||||
if err == nil && ctx.Err() != nil {
|
||||
err = locateFailure(ctx.Err(), "application", failureReference(spec, nil, ""), false, nil)
|
||||
var reportUnits []WorkUnitOutcome
|
||||
if evidence.reports {
|
||||
reportUnits = workUnits[moduleIndex*len(sections) : (moduleIndex+1)*len(sections)]
|
||||
}
|
||||
execution, err := r.executeModule(ctx, spec, sections, input.Interactions, evidence, reportUnits)
|
||||
units := execution.pipeline.WorkUnits
|
||||
if err == nil {
|
||||
previous := sections
|
||||
sections = execution.updated
|
||||
attributeApplyFiltering(previous, execution.pipeline.Approved, execution.skipped, execution.policy, units)
|
||||
filters := findApplyFiltering(sections, execution.pipeline.Approved, execution.skipped, execution.policy)
|
||||
if canceled := ctx.Err(); canceled != nil {
|
||||
err = locateFailure(canceled, "application", failureReference(spec, nil, ""), false, nil)
|
||||
} else {
|
||||
execution.pipeline.recordApplyFiltering(filters, evidence.reports)
|
||||
sections = execution.updated
|
||||
execution.pipeline.Totals.Started = len(sections)
|
||||
execution.pipeline.Totals.Completed = len(sections)
|
||||
execution.pipeline.Totals.Corrections = len(execution.applied)
|
||||
}
|
||||
}
|
||||
|
||||
var failure *ExecutionFailure
|
||||
applicationInterrupted := errors.As(err, &failure) && failure.Phase == "application"
|
||||
appliedIndices := make(map[int]struct{}, len(execution.applied))
|
||||
for _, change := range execution.applied {
|
||||
appliedIndices[change.ProposalIndex] = struct{}{}
|
||||
if applicationInterrupted {
|
||||
execution.pipeline.Totals.Completed = 0
|
||||
}
|
||||
totals.Add(execution.pipeline.Totals)
|
||||
|
||||
appliedIndices := make(map[int]struct{})
|
||||
if evidence.reports || evidence.candidates {
|
||||
for _, change := range execution.applied {
|
||||
appliedIndices[change.ProposalIndex] = struct{}{}
|
||||
}
|
||||
}
|
||||
var operations []outcomes.Operation
|
||||
for i := range units {
|
||||
unit := &units[i]
|
||||
unit.ModuleIndex = moduleIndex
|
||||
if err == nil {
|
||||
unit.State = outcomes.WorkCompleted
|
||||
unit.CorrectionsApplied = execution.appliedBySection[i]
|
||||
if evidence.reports {
|
||||
unit.CorrectionsApplied = execution.appliedBySection[unit.Section.Index]
|
||||
}
|
||||
} else if applicationInterrupted && unit.State != outcomes.WorkNotStarted {
|
||||
unit.State = outcomes.WorkInterrupted
|
||||
}
|
||||
@@ -196,16 +230,14 @@ func (r *Runner) Run(ctx context.Context, input RunInput) (RunOutput, error) {
|
||||
branch.Outcome = "approved_skipped"
|
||||
}
|
||||
}
|
||||
operations = append(operations, unit.Operations...)
|
||||
}
|
||||
|
||||
if input.CaptureCandidates {
|
||||
candidates = append(candidates, execution.pipeline.Candidates...)
|
||||
if !evidence.reports && evidence.candidates {
|
||||
workUnits = append(workUnits, units...)
|
||||
}
|
||||
candidates = append(candidates, execution.pipeline.Candidates...)
|
||||
result := ModuleResult{
|
||||
StageIndex: spec.Index, StageID: spec.ID, ModuleKey: spec.ModuleKey,
|
||||
ModuleInstance: spec.InstanceName, ReplacementPolicy: execution.policy,
|
||||
ProposalCount: execution.pipeline.ProposalCount, Operations: operations,
|
||||
ValidatorDecisions: execution.pipeline.ValidatorDecisions, ValidatorRejected: execution.pipeline.ValidatorRejected,
|
||||
}
|
||||
if err != nil {
|
||||
@@ -213,8 +245,10 @@ func (r *Runner) Run(ctx context.Context, input RunInput) (RunOutput, error) {
|
||||
result.ErrorMessage = err.Error()
|
||||
} else {
|
||||
result.Status = ModuleStatusSuccess
|
||||
result.AppliedChanges = execution.applied
|
||||
result.SkippedChanges = execution.skipped
|
||||
if evidence.decisions {
|
||||
result.AppliedChanges = execution.applied
|
||||
result.SkippedChanges = execution.skipped
|
||||
}
|
||||
}
|
||||
results = append(results, result)
|
||||
if err != nil {
|
||||
@@ -237,7 +271,7 @@ type moduleExecution struct {
|
||||
appliedBySection []int
|
||||
}
|
||||
|
||||
func (r *Runner) executeModule(ctx context.Context, spec contracts.ModuleRunSpec, sections []chunking.Section, interactions structuredoutput.InteractionSink) (moduleExecution, error) {
|
||||
func (r *Runner) executeModule(ctx context.Context, spec contracts.ModuleRunSpec, sections []chunking.Section, interactions structuredoutput.InteractionSink, evidence evidenceNeeds, reportUnits []WorkUnitOutcome) (moduleExecution, error) {
|
||||
var execution moduleExecution
|
||||
origin := failureReference(spec, nil, "")
|
||||
if err := ctx.Err(); err != nil {
|
||||
@@ -253,6 +287,8 @@ func (r *Runner) executeModule(ctx context.Context, spec contracts.ModuleRunSpec
|
||||
}
|
||||
execution.pipeline, err = runModulePipeline(ctx, collectSectionProposalsInput{
|
||||
Module: module,
|
||||
Evidence: &evidence,
|
||||
ReportUnits: reportUnits,
|
||||
Spec: spec,
|
||||
Policy: execution.policy,
|
||||
Sections: sections,
|
||||
@@ -323,6 +359,8 @@ func applyWithinSections(sections []chunking.Section, approved []proposals.Enric
|
||||
}
|
||||
|
||||
type collectSectionProposalsInput struct {
|
||||
Evidence *evidenceNeeds
|
||||
ReportUnits []WorkUnitOutcome
|
||||
Interactions structuredoutput.InteractionSink
|
||||
Module contracts.TranscriptModule
|
||||
Spec contracts.ModuleRunSpec
|
||||
@@ -356,16 +394,18 @@ type sectionValidationResult struct {
|
||||
}
|
||||
|
||||
type sectionWork struct {
|
||||
unit WorkUnitOutcome
|
||||
candidates []proposals.EnrichedCorrectionProposal
|
||||
validation *sectionValidationResult
|
||||
finished bool
|
||||
}
|
||||
|
||||
type modulePipelineResult struct {
|
||||
ProposalCount int
|
||||
Totals outcomes.WorkTotals
|
||||
proposalFacts map[int]proposalRecovery
|
||||
revised map[int]struct{}
|
||||
Candidates []proposals.EnrichedCorrectionProposal
|
||||
Approved []proposals.EnrichedCorrectionProposal
|
||||
Operations []outcomes.Operation
|
||||
WorkUnits []WorkUnitOutcome
|
||||
ValidatorDecisions []ValidatorDecisionRecord
|
||||
ValidatorRejected []ValidatorRejectedChange
|
||||
@@ -410,17 +450,16 @@ func proposeSection(ctx context.Context, input collectSectionProposalsInput, sec
|
||||
}
|
||||
|
||||
func runModulePipeline(ctx context.Context, input collectSectionProposalsInput) (modulePipelineResult, error) {
|
||||
out := modulePipelineResult{
|
||||
Approved: make([]proposals.EnrichedCorrectionProposal, 0),
|
||||
Operations: make([]outcomes.Operation, 0),
|
||||
WorkUnits: make([]WorkUnitOutcome, len(input.Sections)),
|
||||
ValidatorDecisions: make([]ValidatorDecisionRecord, 0),
|
||||
ValidatorRejected: make([]ValidatorRejectedChange, 0),
|
||||
var out modulePipelineResult
|
||||
evidence := selectEvidence(nil)
|
||||
if input.Evidence != nil {
|
||||
evidence = *input.Evidence
|
||||
}
|
||||
for i, section := range input.Sections {
|
||||
out.WorkUnits[i] = WorkUnitOutcome{
|
||||
ModuleKey: input.Spec.ModuleKey, ModuleInstance: input.Spec.InstanceName, StageIndex: input.Spec.Index, StageID: input.Spec.ID,
|
||||
Section: contracts.SectionMetadataFromSection(section), State: outcomes.WorkNotStarted,
|
||||
out.WorkUnits = input.ReportUnits
|
||||
if evidence.reports && out.WorkUnits == nil {
|
||||
out.WorkUnits = make([]WorkUnitOutcome, len(input.Sections))
|
||||
for i, section := range input.Sections {
|
||||
out.WorkUnits[i] = newWorkUnit(input.Spec, contracts.SectionMetadataFromSection(section), 0)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -487,17 +526,17 @@ func runModulePipeline(ctx context.Context, input collectSectionProposalsInput)
|
||||
return sectionEnriched
|
||||
}
|
||||
|
||||
recordCandidates := func(sectionPos int, enriched []proposals.EnrichedCorrectionProposal) {
|
||||
unit := &out.WorkUnits[sectionPos]
|
||||
recordCandidates := func(unit *WorkUnitOutcome, enriched []proposals.EnrichedCorrectionProposal) {
|
||||
unit.ProposalIndexOffset = nextProposalIndex
|
||||
for _, candidate := range enriched {
|
||||
candidate.ProposalIndex += nextProposalIndex
|
||||
out.Candidates = append(out.Candidates, candidate)
|
||||
if evidence.candidates {
|
||||
for _, candidate := range enriched {
|
||||
candidate.ProposalIndex += nextProposalIndex
|
||||
out.Candidates = append(out.Candidates, candidate)
|
||||
}
|
||||
}
|
||||
out.ProposalCount += len(enriched)
|
||||
for operationIndex := range unit.Operations {
|
||||
operation := &unit.Operations[operationIndex]
|
||||
if operation.Reference.Kind == outcomes.OperationProposal && operation.Succeeded {
|
||||
if evidence.reports && operation.Reference.Kind == outcomes.OperationProposal && operation.Succeeded {
|
||||
for _, proposal := range enriched {
|
||||
operation.ProposalIndices = append(operation.ProposalIndices, nextProposalIndex+proposal.ProposalIndex)
|
||||
}
|
||||
@@ -516,16 +555,17 @@ func runModulePipeline(ctx context.Context, input collectSectionProposalsInput)
|
||||
interactions = capture
|
||||
}
|
||||
validationInput := validateSectionCandidatesInput{
|
||||
Spec: input.Spec,
|
||||
Policy: input.Policy,
|
||||
WorkingTranscript: transcriptFromSection(sectionResult.section),
|
||||
SectionIndex: §ionMetadata.Index,
|
||||
Validators: validatorsOrdered,
|
||||
SectionEnriched: enriched,
|
||||
Exchange: sectionResult.proposal.Exchange,
|
||||
ValidationLLMClient: input.ValidationClient,
|
||||
GlossaryView: input.GlossaryView,
|
||||
Interactions: interactions,
|
||||
Spec: input.Spec,
|
||||
SuppressDecisionHistory: !evidence.decisions,
|
||||
Policy: input.Policy,
|
||||
WorkingTranscript: transcriptFromSection(sectionResult.section),
|
||||
SectionIndex: §ionMetadata.Index,
|
||||
Validators: validatorsOrdered,
|
||||
SectionEnriched: enriched,
|
||||
Exchange: sectionResult.proposal.Exchange,
|
||||
ValidationLLMClient: input.ValidationClient,
|
||||
GlossaryView: input.GlossaryView,
|
||||
Interactions: interactions,
|
||||
}
|
||||
if input.Spec.Settings.LLM.CorrectionRepairAttempts > 0 && len(enriched) > 0 {
|
||||
validationInput.Section = validators.NewSectionLookup(validationInput.WorkingTranscript)
|
||||
@@ -555,8 +595,7 @@ func runModulePipeline(ctx context.Context, input collectSectionProposalsInput)
|
||||
failure: failure,
|
||||
}
|
||||
}
|
||||
recordValidation := func(res sectionValidationResult) {
|
||||
unit := &out.WorkUnits[res.sectionPos]
|
||||
recordValidation := func(unit *WorkUnitOutcome, res sectionValidationResult) {
|
||||
unit.Operations = append(unit.Operations, res.operations...)
|
||||
unit.Repairs = res.repairs
|
||||
mergeFilteredProposals(unit, res.filtered)
|
||||
@@ -567,18 +606,30 @@ func runModulePipeline(ctx context.Context, input collectSectionProposalsInput)
|
||||
unit.State = outcomes.WorkInterrupted
|
||||
}
|
||||
out.Approved = append(out.Approved, res.approved...)
|
||||
out.ValidatorDecisions = append(out.ValidatorDecisions, res.decisions...)
|
||||
out.ValidatorRejected = append(out.ValidatorRejected, res.rejected...)
|
||||
if evidence.decisions {
|
||||
out.ValidatorDecisions = append(out.ValidatorDecisions, res.decisions...)
|
||||
out.ValidatorRejected = append(out.ValidatorRejected, res.rejected...)
|
||||
}
|
||||
if len(res.approved) > 0 {
|
||||
out.rememberProposalRecovery(unit)
|
||||
}
|
||||
}
|
||||
|
||||
nextAdmission, active := 0, 0
|
||||
for {
|
||||
for work := pending[nextSectionToRecord]; work != nil && work.finished; work = pending[nextSectionToRecord] {
|
||||
offset := nextProposalIndex
|
||||
recordCandidates(nextSectionToRecord, work.candidates)
|
||||
recordCandidates(&work.unit, work.candidates)
|
||||
if work.validation != nil {
|
||||
work.validation.assignProposalIndices(offset)
|
||||
recordValidation(*work.validation)
|
||||
recordValidation(&work.unit, *work.validation)
|
||||
}
|
||||
out.Totals.Record(work.unit.State, work.unit.Operations)
|
||||
if evidence.reports {
|
||||
out.WorkUnits[nextSectionToRecord] = work.unit
|
||||
} else if evidence.candidates && len(work.unit.Repairs) > 0 {
|
||||
work.unit.Operations = nil
|
||||
out.WorkUnits = append(out.WorkUnits, work.unit)
|
||||
}
|
||||
delete(pending, nextSectionToRecord)
|
||||
nextSectionToRecord++
|
||||
@@ -586,7 +637,7 @@ func runModulePipeline(ctx context.Context, input collectSectionProposalsInput)
|
||||
for len(pending) < moduleWorkWindow && nextAdmission < len(input.Sections) && runCtx.Err() == nil {
|
||||
sectionPos := nextAdmission
|
||||
nextAdmission++
|
||||
pending[sectionPos] = §ionWork{}
|
||||
pending[sectionPos] = §ionWork{unit: newWorkUnit(input.Spec, contracts.SectionMetadataFromSection(input.Sections[sectionPos]), 0)}
|
||||
active++
|
||||
workers.Go(func() {
|
||||
proposed := proposeSection(runCtx, input, sectionPos)
|
||||
@@ -600,13 +651,13 @@ func runModulePipeline(ctx context.Context, input collectSectionProposalsInput)
|
||||
select {
|
||||
case result := <-proposalResults:
|
||||
active--
|
||||
unit := &out.WorkUnits[result.sectionPos]
|
||||
work := pending[result.sectionPos]
|
||||
unit := &work.unit
|
||||
unit.Operations = append(unit.Operations, result.proposal.Operations...)
|
||||
if result.started {
|
||||
unit.State = outcomes.WorkInterrupted
|
||||
}
|
||||
unit.Failure = result.failure
|
||||
work := pending[result.sectionPos]
|
||||
if result.started && result.failure == nil {
|
||||
work.candidates = makeCandidates(result)
|
||||
if runCtx.Err() == nil {
|
||||
@@ -633,10 +684,6 @@ func runModulePipeline(ctx context.Context, input collectSectionProposalsInput)
|
||||
return out.Approved[i].ProposalIndex < out.Approved[j].ProposalIndex
|
||||
})
|
||||
|
||||
for _, unit := range out.WorkUnits {
|
||||
out.Operations = append(out.Operations, unit.Operations...)
|
||||
}
|
||||
|
||||
sort.SliceStable(out.ValidatorDecisions, func(i, j int) bool {
|
||||
if out.ValidatorDecisions[i].ProposalIndex != out.ValidatorDecisions[j].ProposalIndex {
|
||||
return out.ValidatorDecisions[i].ProposalIndex < out.ValidatorDecisions[j].ProposalIndex
|
||||
@@ -668,19 +715,20 @@ func runModulePipeline(ctx context.Context, input collectSectionProposalsInput)
|
||||
}
|
||||
|
||||
type validateSectionCandidatesInput struct {
|
||||
Section *validators.SectionLookup
|
||||
RepairProposalIndex *int
|
||||
RepairAttempt *int
|
||||
Exchange *structuredoutput.Exchange
|
||||
Spec contracts.ModuleRunSpec
|
||||
Policy proposals.ReplacementPolicy
|
||||
WorkingTranscript *schema.Transcript
|
||||
SectionIndex *int
|
||||
Validators []validators.Validator
|
||||
SectionEnriched []proposals.EnrichedCorrectionProposal
|
||||
ValidationLLMClient contracts.StructuredLLMClient
|
||||
Interactions structuredoutput.InteractionSink
|
||||
GlossaryView *validators.GlossaryView
|
||||
SuppressDecisionHistory bool
|
||||
Section *validators.SectionLookup
|
||||
RepairProposalIndex *int
|
||||
RepairAttempt *int
|
||||
Exchange *structuredoutput.Exchange
|
||||
Spec contracts.ModuleRunSpec
|
||||
Policy proposals.ReplacementPolicy
|
||||
WorkingTranscript *schema.Transcript
|
||||
SectionIndex *int
|
||||
Validators []validators.Validator
|
||||
SectionEnriched []proposals.EnrichedCorrectionProposal
|
||||
ValidationLLMClient contracts.StructuredLLMClient
|
||||
Interactions structuredoutput.InteractionSink
|
||||
GlossaryView *validators.GlossaryView
|
||||
}
|
||||
|
||||
type validateSectionCandidatesResult struct {
|
||||
@@ -781,16 +829,18 @@ func validateSectionCandidates(ctx context.Context, input validateSectionCandida
|
||||
noEffect[d.ProposalIndex] = true
|
||||
}
|
||||
}
|
||||
decisions = append(decisions, ValidatorDecisionRecord{
|
||||
ValidatorName: validator.Name(),
|
||||
ExecutionClass: class,
|
||||
ProposalIndex: d.ProposalIndex,
|
||||
Approved: approved,
|
||||
Disposition: disposition,
|
||||
ReasonCode: d.ReasonCode,
|
||||
Message: d.Message,
|
||||
DiagnosticArtifactPath: d.DiagnosticArtifactPath,
|
||||
})
|
||||
if !input.SuppressDecisionHistory {
|
||||
decisions = append(decisions, ValidatorDecisionRecord{
|
||||
ValidatorName: validator.Name(),
|
||||
ExecutionClass: class,
|
||||
ProposalIndex: d.ProposalIndex,
|
||||
Approved: approved,
|
||||
Disposition: disposition,
|
||||
ReasonCode: d.ReasonCode,
|
||||
Message: d.Message,
|
||||
DiagnosticArtifactPath: d.DiagnosticArtifactPath,
|
||||
})
|
||||
}
|
||||
if approved {
|
||||
nextEligible = append(nextEligible, byIndex[d.ProposalIndex])
|
||||
continue
|
||||
@@ -800,19 +850,21 @@ func validateSectionCandidates(ctx context.Context, input validateSectionCandida
|
||||
filtered = append(filtered, outcomes.FilteredProposal{ProposalIndex: d.ProposalIndex, Reason: reason, Count: 1})
|
||||
}
|
||||
}
|
||||
p := byIndex[d.ProposalIndex]
|
||||
rejected = append(rejected, ValidatorRejectedChange{
|
||||
ValidatorName: validator.Name(),
|
||||
ProposalIndex: p.ProposalIndex,
|
||||
ModuleKey: p.ModuleKey,
|
||||
ModuleInstance: p.ModuleInstance,
|
||||
TargetSegmentID: p.TargetSegmentID,
|
||||
OriginalText: p.OriginalText,
|
||||
CorrectedText: p.CorrectedText,
|
||||
Disposition: disposition,
|
||||
ReasonCode: d.ReasonCode,
|
||||
Message: d.Message,
|
||||
})
|
||||
if feedback || !input.SuppressDecisionHistory {
|
||||
p := byIndex[d.ProposalIndex]
|
||||
rejected = append(rejected, ValidatorRejectedChange{
|
||||
ValidatorName: validator.Name(),
|
||||
ProposalIndex: p.ProposalIndex,
|
||||
ModuleKey: p.ModuleKey,
|
||||
ModuleInstance: p.ModuleInstance,
|
||||
TargetSegmentID: p.TargetSegmentID,
|
||||
OriginalText: p.OriginalText,
|
||||
CorrectedText: p.CorrectedText,
|
||||
Disposition: disposition,
|
||||
ReasonCode: d.ReasonCode,
|
||||
Message: d.Message,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
@@ -877,9 +929,9 @@ func mergeOperationFiltering(operation *outcomes.Operation, filtered []outcomes.
|
||||
}
|
||||
}
|
||||
|
||||
func attributeApplyFiltering(sections []chunking.Section, approved []proposals.EnrichedCorrectionProposal, skipped []proposals.SkippedChange, policy proposals.ReplacementPolicy, units []WorkUnitOutcome) {
|
||||
func findApplyFiltering(sections []chunking.Section, approved []proposals.EnrichedCorrectionProposal, skipped []proposals.SkippedChange, policy proposals.ReplacementPolicy) map[int][]outcomes.FilteredProposal {
|
||||
if len(skipped) == 0 {
|
||||
return
|
||||
return nil
|
||||
}
|
||||
byIndex := make(map[int]proposals.EnrichedCorrectionProposal, len(approved))
|
||||
sectionPosition := make(map[int]int, len(sections))
|
||||
@@ -916,26 +968,7 @@ func attributeApplyFiltering(sections []chunking.Section, approved []proposals.E
|
||||
}
|
||||
filtered[pos] = append(filtered[pos], outcomes.FilteredProposal{ProposalIndex: skip.ProposalIndex, Reason: reason, Count: 1})
|
||||
}
|
||||
for pos, items := range filtered {
|
||||
unit := &units[pos]
|
||||
revisions := make(map[int]*outcomes.Operation)
|
||||
for i := range unit.Operations {
|
||||
op := &unit.Operations[i]
|
||||
if op.Reference.Kind == outcomes.OperationCorrectionRepair && op.Succeeded && op.Reference.ProposalIndex != nil &&
|
||||
slices.Contains(op.RecoveryReasons, outcomes.RecoveryCorrectionRevised) {
|
||||
revisions[*op.Reference.ProposalIndex] = op
|
||||
}
|
||||
}
|
||||
original := items[:0]
|
||||
for _, item := range items {
|
||||
if op := revisions[item.ProposalIndex]; op != nil {
|
||||
mergeOperationFiltering(op, []outcomes.FilteredProposal{item})
|
||||
} else {
|
||||
original = append(original, item)
|
||||
}
|
||||
}
|
||||
mergeFilteredProposals(unit, original)
|
||||
}
|
||||
return filtered
|
||||
}
|
||||
|
||||
func reorderValidatorsForPipeline(in []validators.Validator) ([]validators.Validator, map[string]int) {
|
||||
|
||||
Reference in New Issue
Block a user