Retain only reportable operation details
This commit is contained in:
@@ -84,6 +84,7 @@ and the recorded validator execution class.
|
|||||||
|
|
||||||
The invocation selects retained evidence once. Summary-only processing
|
The invocation selects retained evidence once. Summary-only processing
|
||||||
accumulates counters as completed sections leave the work window. Ordinary
|
accumulates counters as completed sections leave the work window. Ordinary
|
||||||
reports retain the full work matrix and operation facts. Debug retains
|
reports retain the full work matrix and the operation facts that contribute to
|
||||||
|
errors and recoveries. Debug retains
|
||||||
candidate and decision history, repair lineage, and native observations.
|
candidate and decision history, repair lineage, and native observations.
|
||||||
Without debug, the runtime skips prepared message snapshots.
|
Without debug, the runtime skips prepared message snapshots.
|
||||||
|
|||||||
@@ -434,6 +434,12 @@ successful write.
|
|||||||
|
|
||||||
### R13 — Retain Only Operations Used by Ordinary Reports (P3)
|
### R13 — Retain Only Operations Used by Ordinary Reports (P3)
|
||||||
|
|
||||||
|
**Complete.** After totals and application attribution are settled, the
|
||||||
|
runner keeps only reportable errors and recoveries. Successful proposal
|
||||||
|
index lists and per-operation causes no longer persist through the run.
|
||||||
|
Runner, report, and CLI tests cover totals, filtering, interrupted origin,
|
||||||
|
and evidence across output modes.
|
||||||
|
|
||||||
**Affected plan:** Stages 12, 17, and 18.
|
**Affected plan:** Stages 12, 17, and 18.
|
||||||
|
|
||||||
**Evidence:** [Ordered collection](../../internal/framework/runner/runner.go#L632)
|
**Evidence:** [Ordered collection](../../internal/framework/runner/runner.go#L632)
|
||||||
|
|||||||
@@ -82,9 +82,15 @@ func TestFatalBatchRetainsEarlierDecisionsInLedger(t *testing.T) {
|
|||||||
if result.FinalTranscript.Segments[0].Text != "hello" || len(result.ModuleResults[0].AppliedChanges) != 0 {
|
if result.FinalTranscript.Segments[0].Text != "hello" || len(result.ModuleResults[0].AppliedChanges) != 0 {
|
||||||
t.Fatal("fatal partial approvals changed transcript")
|
t.Fatal("fatal partial approvals changed transcript")
|
||||||
}
|
}
|
||||||
if len(result.WorkUnits[0].Operations) != 3 || result.WorkUnits[0].State != outcomes.WorkInterrupted {
|
if len(result.WorkUnits[0].Operations) != 1 || result.WorkUnits[0].Operations[0].FailureReason != outcomes.ReasonValidationDecisionsInvalid ||
|
||||||
|
result.WorkUnits[0].State != outcomes.WorkInterrupted || result.Totals.ModelOperations != 3 {
|
||||||
t.Fatalf("partial facts: %+v", result.WorkUnits)
|
t.Fatalf("partial facts: %+v", result.WorkUnits)
|
||||||
}
|
}
|
||||||
|
snapshot := Build(BuildInput{RunOutput: &result, ProcessingError: err})
|
||||||
|
if len(snapshot.Errors) != 2 || snapshot.Errors[0].Scope != "work_unit" || snapshot.Errors[1].Scope != "run" ||
|
||||||
|
snapshot.Errors[1].BatchIndex == nil || *snapshot.Errors[1].BatchIndex != 2 {
|
||||||
|
t.Fatalf("report lost either failure: %+v", snapshot.Errors)
|
||||||
|
}
|
||||||
ledger := BuildCorrectionLedger(CorrectionLedgerInput{RunOutput: &result})
|
ledger := BuildCorrectionLedger(CorrectionLedgerInput{RunOutput: &result})
|
||||||
candidates := make(map[int]CorrectionLedgerEntry)
|
candidates := make(map[int]CorrectionLedgerEntry)
|
||||||
for _, entry := range ledger {
|
for _, entry := range ledger {
|
||||||
|
|||||||
@@ -222,7 +222,7 @@ func TestRunnerRetainsLaterProposalEvidenceWhenEarlierSectionFails(t *testing.T)
|
|||||||
candidate := out.Candidates[0]
|
candidate := out.Candidates[0]
|
||||||
later := out.WorkUnits[1]
|
later := out.WorkUnits[1]
|
||||||
if candidate.ProposalIndex != 0 || candidate.TargetSegmentID != 93 || later.State != outcomes.WorkInterrupted || later.Failure == nil || !errors.Is(later.Failure, context.Canceled) ||
|
if candidate.ProposalIndex != 0 || candidate.TargetSegmentID != 93 || later.State != outcomes.WorkInterrupted || later.Failure == nil || !errors.Is(later.Failure, context.Canceled) ||
|
||||||
len(later.Operations) != 1 || len(later.Operations[0].ProposalIndices) != 1 || later.Operations[0].ProposalIndices[0] != candidate.ProposalIndex ||
|
candidate.SectionIndex == nil || *candidate.SectionIndex != later.Section.Index ||
|
||||||
out.FinalTranscript.Segments[1].Text != "other text" {
|
out.FinalTranscript.Segments[1].Text != "other text" {
|
||||||
t.Fatalf("later candidate or association lost: candidate=%+v work=%+v", candidate, later)
|
t.Fatalf("later candidate or association lost: candidate=%+v work=%+v", candidate, later)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -213,6 +213,7 @@ func (r *Runner) Run(ctx context.Context, input RunInput) (RunOutput, error) {
|
|||||||
for i := range units {
|
for i := range units {
|
||||||
unit := &units[i]
|
unit := &units[i]
|
||||||
unit.ModuleIndex = moduleIndex
|
unit.ModuleIndex = moduleIndex
|
||||||
|
unit.Operations = reportOperations(unit.Operations)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
unit.State = outcomes.WorkCompleted
|
unit.State = outcomes.WorkCompleted
|
||||||
if evidence.reports {
|
if evidence.reports {
|
||||||
@@ -545,14 +546,6 @@ func runModulePipeline(ctx context.Context, input collectSectionProposalsInput)
|
|||||||
out.Candidates = append(out.Candidates, candidate)
|
out.Candidates = append(out.Candidates, candidate)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for operationIndex := range unit.Operations {
|
|
||||||
operation := &unit.Operations[operationIndex]
|
|
||||||
if evidence.reports && operation.Reference.Kind == outcomes.OperationProposal && operation.Succeeded {
|
|
||||||
for _, proposal := range enriched {
|
|
||||||
operation.ProposalIndices = append(operation.ProposalIndices, nextProposalIndex+proposal.ProposalIndex)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
nextProposalIndex += len(enriched)
|
nextProposalIndex += len(enriched)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ func TestRunnerStopsOnContradictoryValidatorDecision(t *testing.T) {
|
|||||||
|
|
||||||
func TestRunnerRecoverableProposalFailureAllowsLaterModule(t *testing.T) {
|
func TestRunnerRecoverableProposalFailureAllowsLaterModule(t *testing.T) {
|
||||||
failed := outcomeModule{fakeModule: fakeModule{key: "first", policy: proposals.ReplacementPolicyRequireUnique}, proposeResult: func(req contracts.ProposalRequest) (contracts.ProposalResult, error) {
|
failed := outcomeModule{fakeModule: fakeModule{key: "first", policy: proposals.ReplacementPolicyRequireUnique}, proposeResult: func(req contracts.ProposalRequest) (contracts.ProposalResult, error) {
|
||||||
return contracts.ProposalResult{Operations: []outcomes.Operation{{Reference: outcomes.Reference{ModuleKey: "first", ModuleInstance: "first", Kind: outcomes.OperationProposal}, FailureReason: outcomes.ReasonTransportFailed}}}, nil
|
return contracts.ProposalResult{Operations: []outcomes.Operation{{Reference: outcomes.Reference{ModuleKey: "first", ModuleInstance: "first", Kind: outcomes.OperationProposal}, FailureClass: outcomes.FailureRecoverable, FailureReason: outcomes.ReasonTransportFailed}}}, nil
|
||||||
}}
|
}}
|
||||||
second := fakeModule{key: "second", policy: proposals.ReplacementPolicyRequireUnique, proposeF: func(req contracts.ProposalRequest) ([]proposals.CorrectionProposal, error) {
|
second := fakeModule{key: "second", policy: proposals.ReplacementPolicyRequireUnique, proposeF: func(req contracts.ProposalRequest) ([]proposals.CorrectionProposal, error) {
|
||||||
return []proposals.CorrectionProposal{{TargetSegmentID: 1, OriginalText: "teh", CorrectedText: "the"}}, nil
|
return []proposals.CorrectionProposal{{TargetSegmentID: 1, OriginalText: "teh", CorrectedText: "the"}}, nil
|
||||||
@@ -110,8 +110,8 @@ func TestRunnerOnlyFullyValidatedCandidatesApplyAndRecoveriesMerge(t *testing.T)
|
|||||||
{ProposalIndex: req.CandidateProposal[0].ProposalIndex, Approved: false, Disposition: validators.DispositionUnavailable, ReasonCode: string(outcomes.ReasonTransportFailed)},
|
{ProposalIndex: req.CandidateProposal[0].ProposalIndex, Approved: false, Disposition: validators.DispositionUnavailable, ReasonCode: string(outcomes.ReasonTransportFailed)},
|
||||||
{ProposalIndex: req.CandidateProposal[1].ProposalIndex, Approved: true, Disposition: validators.DispositionApproved},
|
{ProposalIndex: req.CandidateProposal[1].ProposalIndex, Approved: true, Disposition: validators.DispositionApproved},
|
||||||
}, Operations: []outcomes.Operation{
|
}, Operations: []outcomes.Operation{
|
||||||
{Reference: outcomes.Reference{Kind: outcomes.OperationValidation}, FailureReason: outcomes.ReasonTransportFailed},
|
{Reference: outcomes.Reference{Kind: outcomes.OperationValidation}, FailureClass: outcomes.FailureRecoverable, FailureReason: outcomes.ReasonTransportFailed, Cause: errors.New("transport")},
|
||||||
{Reference: outcomes.Reference{Kind: outcomes.OperationValidation}, FailureReason: outcomes.ReasonProviderFailed},
|
{Reference: outcomes.Reference{Kind: outcomes.OperationValidation}, FailureClass: outcomes.FailureRecoverable, FailureReason: outcomes.ReasonProviderFailed, Cause: errors.New("provider")},
|
||||||
}}, nil
|
}}, nil
|
||||||
}}
|
}}
|
||||||
last := fakeValidator{name: "last", validateF: func(req validators.Request) (validators.Result, error) {
|
last := fakeValidator{name: "last", validateF: func(req validators.Request) (validators.Result, error) {
|
||||||
@@ -143,6 +143,10 @@ func TestRunnerOnlyFullyValidatedCandidatesApplyAndRecoveriesMerge(t *testing.T)
|
|||||||
if len(proposal.RecoveryReasons) != 2 || proposal.RecoveryReasons[0] != outcomes.RecoveryOutputRepaired || proposal.RecoveryReasons[1] != outcomes.RecoveryProposalsFiltered || len(proposal.Filtered) != 1 || proposal.Filtered[0].ProposalIndex != 0 {
|
if len(proposal.RecoveryReasons) != 2 || proposal.RecoveryReasons[0] != outcomes.RecoveryOutputRepaired || proposal.RecoveryReasons[1] != outcomes.RecoveryProposalsFiltered || len(proposal.Filtered) != 1 || proposal.Filtered[0].ProposalIndex != 0 {
|
||||||
t.Fatalf("repair and filtering must share one recovery: %+v", proposal)
|
t.Fatalf("repair and filtering must share one recovery: %+v", proposal)
|
||||||
}
|
}
|
||||||
|
if len(proposal.ProposalIndices) != 0 || unit.Operations[1].Cause != nil || unit.Operations[2].Cause != nil ||
|
||||||
|
out.Totals.ModelOperations != 3 || out.Totals.WithErrors != 1 || out.Totals.Recoveries != 1 {
|
||||||
|
t.Fatalf("report detail or counts: operations=%+v totals=%+v", unit.Operations, out.Totals)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestFatalValidatorNeverReturnsUncheckedCandidates(t *testing.T) {
|
func TestFatalValidatorNeverReturnsUncheckedCandidates(t *testing.T) {
|
||||||
@@ -774,17 +778,8 @@ func TestRunnerApplyConflictAfterTwoInitiallyValidDeletions(t *testing.T) {
|
|||||||
if len(out.ModuleResults[0].ValidatorRejected) != 0 || len(out.WorkUnits) != 1 || out.WorkUnits[0].CorrectionsApplied != 1 {
|
if len(out.ModuleResults[0].ValidatorRejected) != 0 || len(out.WorkUnits) != 1 || out.WorkUnits[0].CorrectionsApplied != 1 {
|
||||||
t.Fatalf("unexpected validation or application outcome: %+v", out)
|
t.Fatalf("unexpected validation or application outcome: %+v", out)
|
||||||
}
|
}
|
||||||
foundProposal := false
|
if len(out.WorkUnits[0].Operations) != 0 || out.Totals.ProposalResponses != 1 || out.Totals.WithErrors != 0 || out.Totals.Recoveries != 0 {
|
||||||
for _, operation := range out.WorkUnits[0].Operations {
|
t.Fatalf("apply-time conflict changed report facts: operations=%+v totals=%+v", out.WorkUnits[0].Operations, out.Totals)
|
||||||
if operation.Reference.Kind == outcomes.OperationProposal && operation.Succeeded {
|
|
||||||
foundProposal = true
|
|
||||||
}
|
|
||||||
if operation.FailureReason != "" || len(operation.RecoveryReasons) != 0 || len(operation.Filtered) != 0 {
|
|
||||||
t.Fatalf("apply-time conflict must not count as model error or filtering recovery: %+v", operation)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if !foundProposal {
|
|
||||||
t.Fatalf("expected successful proposal operation: %+v", out.WorkUnits[0].Operations)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -933,7 +928,7 @@ func TestRunnerReconciledSurvivorsCompleteLaterValidation(t *testing.T) {
|
|||||||
t.Fatalf("survivor routing: text=%q later=%v calls=%d err=%v", out.FinalTranscript.Segments[0].Text, laterIndices, client.calls, err)
|
t.Fatalf("survivor routing: text=%q later=%v calls=%d err=%v", out.FinalTranscript.Segments[0].Text, laterIndices, client.calls, err)
|
||||||
}
|
}
|
||||||
unit := out.WorkUnits[0]
|
unit := out.WorkUnits[0]
|
||||||
if unit.CorrectionsApplied != 1 || len(unit.Operations) != 2 || !unit.Operations[0].Succeeded || unit.Operations[1].FailureReason != outcomes.ReasonValidationDecisionsInvalid || len(unit.Operations[1].ProposalIndices) != 1 || unit.Operations[1].ProposalIndices[0] != 1 || len(unit.Operations[1].RecoveryReasons) != 0 {
|
if unit.CorrectionsApplied != 1 || out.Totals.ProposalResponses != 1 || len(unit.Operations) != 1 || unit.Operations[0].FailureReason != outcomes.ReasonValidationDecisionsInvalid || len(unit.Operations[0].ProposalIndices) != 1 || unit.Operations[0].ProposalIndices[0] != 1 || len(unit.Operations[0].RecoveryReasons) != 0 {
|
||||||
t.Fatalf("operation accounting: %+v", unit)
|
t.Fatalf("operation accounting: %+v", unit)
|
||||||
}
|
}
|
||||||
moduleResult := out.ModuleResults[0]
|
moduleResult := out.ModuleResults[0]
|
||||||
@@ -1139,16 +1134,6 @@ func TestRunnerProposalIndexOrderingIsDeterministicAcrossParallelSections(t *tes
|
|||||||
t.Fatalf("change %d lost response order or segment identity: %+v", i, change)
|
t.Fatalf("change %d lost response order or segment identity: %+v", i, change)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wantIndices := [][]int{{0, 1}, {2}}
|
|
||||||
if len(out.WorkUnits) != len(wantIndices) {
|
|
||||||
t.Fatalf("work units: %+v", out.WorkUnits)
|
|
||||||
}
|
|
||||||
for i, unit := range out.WorkUnits {
|
|
||||||
if len(unit.Operations) != 1 || !reflect.DeepEqual(unit.Operations[0].ProposalIndices, wantIndices[i]) {
|
|
||||||
t.Fatalf("section %d lost proposal indices: %+v", i, unit.Operations)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
paths, err := filepath.Glob(filepath.Join(dir, "grammar", "*response-payload.json"))
|
paths, err := filepath.Glob(filepath.Join(dir, "grammar", "*response-payload.json"))
|
||||||
if err != nil || len(paths) != len(responses) {
|
if err != nil || len(paths) != len(responses) {
|
||||||
t.Fatalf("proposal diagnostic paths=%v error=%v", paths, err)
|
t.Fatalf("proposal diagnostic paths=%v error=%v", paths, err)
|
||||||
|
|||||||
@@ -7,6 +7,23 @@ import (
|
|||||||
"gitea.maximumdirect.net/eric/audita/v3/internal/framework/outcomes"
|
"gitea.maximumdirect.net/eric/audita/v3/internal/framework/outcomes"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// reportOperations selects report detail after counting and application
|
||||||
|
// attribution. Use a new slice so discarded operations can be released.
|
||||||
|
func reportOperations(operations []outcomes.Operation) []outcomes.Operation {
|
||||||
|
var report []outcomes.Operation
|
||||||
|
for _, operation := range operations {
|
||||||
|
if operation.FailureClass != outcomes.FailureRecoverable {
|
||||||
|
if !operation.Succeeded || len(operation.RecoveryReasons) == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
operation.ProposalIndices = nil
|
||||||
|
}
|
||||||
|
operation.Cause = nil
|
||||||
|
report = append(report, operation)
|
||||||
|
}
|
||||||
|
return report
|
||||||
|
}
|
||||||
|
|
||||||
func newWorkUnit(spec contracts.ModuleRunSpec, section contracts.SectionMetadata, moduleIndex int) WorkUnitOutcome {
|
func newWorkUnit(spec contracts.ModuleRunSpec, section contracts.SectionMetadata, moduleIndex int) WorkUnitOutcome {
|
||||||
return WorkUnitOutcome{
|
return WorkUnitOutcome{
|
||||||
ModuleIndex: moduleIndex, StageIndex: spec.Index, StageID: spec.ID, ModuleKey: spec.ModuleKey,
|
ModuleIndex: moduleIndex, StageIndex: spec.Index, StageID: spec.ID, ModuleKey: spec.ModuleKey,
|
||||||
|
|||||||
Reference in New Issue
Block a user