Retain processing evidence only for selected outputs
This commit is contained in:
78
internal/framework/runner/work_totals.go
Normal file
78
internal/framework/runner/work_totals.go
Normal file
@@ -0,0 +1,78 @@
|
||||
package runner
|
||||
|
||||
import (
|
||||
"slices"
|
||||
|
||||
"gitea.maximumdirect.net/eric/audita/v3/internal/framework/contracts"
|
||||
"gitea.maximumdirect.net/eric/audita/v3/internal/framework/outcomes"
|
||||
)
|
||||
|
||||
func newWorkUnit(spec contracts.ModuleRunSpec, section contracts.SectionMetadata, moduleIndex int) WorkUnitOutcome {
|
||||
return WorkUnitOutcome{
|
||||
ModuleIndex: moduleIndex, StageIndex: spec.Index, StageID: spec.ID, ModuleKey: spec.ModuleKey,
|
||||
ModuleInstance: spec.InstanceName, Section: section, State: outcomes.WorkNotStarted,
|
||||
}
|
||||
}
|
||||
|
||||
type proposalRecovery struct {
|
||||
recovered bool
|
||||
filtered bool
|
||||
}
|
||||
|
||||
// Application can discover additional defects. Keep only the proposal operation
|
||||
// flags needed to update totals and the identities of approved revisions.
|
||||
func (p *modulePipelineResult) rememberProposalRecovery(unit *WorkUnitOutcome) {
|
||||
for _, operation := range unit.Operations {
|
||||
if operation.Reference.Kind == outcomes.OperationProposal && operation.Succeeded {
|
||||
if p.proposalFacts == nil {
|
||||
p.proposalFacts = make(map[int]proposalRecovery)
|
||||
}
|
||||
p.proposalFacts[unit.Section.Index] = proposalRecovery{
|
||||
recovered: len(operation.RecoveryReasons) > 0, filtered: len(operation.Filtered) > 0,
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
for _, repair := range unit.Repairs {
|
||||
if repair.Outcome == "approved" {
|
||||
if p.revised == nil {
|
||||
p.revised = make(map[int]struct{})
|
||||
}
|
||||
p.revised[repair.ProposalIndex] = struct{}{}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (p *modulePipelineResult) recordApplyFiltering(filters map[int][]outcomes.FilteredProposal, reports bool) {
|
||||
for pos, items := range filters {
|
||||
original := items[:0]
|
||||
for _, item := range items {
|
||||
if _, repaired := p.revised[item.ProposalIndex]; !repaired {
|
||||
original = append(original, item)
|
||||
continue
|
||||
}
|
||||
if reports {
|
||||
operations := p.WorkUnits[pos].Operations
|
||||
for i := range operations {
|
||||
op := &operations[i]
|
||||
if op.Reference.Kind == outcomes.OperationCorrectionRepair && op.Reference.ProposalIndex != nil &&
|
||||
*op.Reference.ProposalIndex == item.ProposalIndex && slices.Contains(op.RecoveryReasons, outcomes.RecoveryCorrectionRevised) {
|
||||
mergeOperationFiltering(op, []outcomes.FilteredProposal{item})
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if facts, ok := p.proposalFacts[pos]; ok && len(original) != 0 {
|
||||
if !facts.recovered {
|
||||
p.Totals.Recoveries++
|
||||
}
|
||||
if !facts.filtered {
|
||||
p.Totals.FilteringResponses++
|
||||
}
|
||||
if reports {
|
||||
mergeFilteredProposals(&p.WorkUnits[pos], original)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user