Retain all diagnostic groups without capacity caps

This commit is contained in:
2026-11-26 01:59:34 +00:00
parent 6133902b9b
commit b0dc84a479
16 changed files with 146 additions and 116 deletions

View File

@@ -3,8 +3,9 @@
**Status:** Accepted in part. Durable warning/diagnostic files and receipt
presentation are superseded by
[ADR-0024](0024-publish-artifacts-with-native-reports-and-debug-evidence.md).
Process-warning classification, module-owned meaning, and bounded origin-aware
aggregation remain accepted.
Diagnostic group caps are superseded by
[ADR-0028](0028-retain-all-diagnostic-groups.md). Process-warning classification,
module-owned meaning, origin-aware aggregation, and sample limits remain accepted.
**Date:** 2026-08-27
## Context

View File

@@ -2,7 +2,8 @@
**Status:** Accepted; the requirement for one native invocation ExecutionGroup is
partially superseded by [ADR-0025](0025-use-consumer-owned-execution-observation.md),
and whole-source evidence representation by [ADR-0027](0027-share-whole-source-capture-evidence.md).
whole-source evidence representation by [ADR-0027](0027-share-whole-source-capture-evidence.md),
and diagnostic group caps by [ADR-0028](0028-retain-all-diagnostic-groups.md).
All other decisions remain accepted.
**Date:** 2026-11-22

View File

@@ -0,0 +1,35 @@
# ADR-0028: Retain all diagnostic groups
**Status:** Accepted
**Date:** 2026-11-25
## Context
Fixed local and final diagnostic group caps could fail otherwise valid work or
discard non-warning groups. The caps did not represent selected input limits,
and truncated collections could not preserve every completed finding.
## Decision
Retain all valid diagnostic groups in stable origin-aware order, without local
or final group-count caps. Preserve exact checked occurrence totals, at most
three distinct samples per group, and the per-group omitted-sample count.
Invalid diagnostics and arithmetic overflow still fail. No replacement limit,
exhaustive occurrence ledger, or durable report sidecar is introduced.
This supersedes only the group-cap and collection-truncation portions of
[ADR-0015](0015-separate-process-warnings-from-quality-diagnostics.md) and
[ADR-0024](0024-publish-artifacts-with-native-reports-and-debug-evidence.md).
Their diagnostic classifications and other accepted decisions remain in force.
## Alternatives considered
- Increase or configure the caps: this retains the arbitrary failure or loss
boundary without establishing a selected resource policy.
- Record every occurrence: this adds an exhaustive ledger that is not needed
for grouped diagnostic presentation.
## Consequences
Group memory grows with distinct findings. Samples remain bounded per group,
but the application makes no global group-count or diagnostic-memory guarantee.

View File

@@ -164,6 +164,10 @@ it projects selected citations in source order, not a second typed output channe
[Evidence internals](../../internal/framework/pipeline/evidence_output.go) and
the [evidence contract](../integrations/evidence-context.md) define those owners.
Diagnostic aggregation retains every valid origin-aware group in stable order,
checks occurrence-count overflow, and keeps up to three representative samples
per group with an omitted-sample count.
The encoder receives owned normalized/auxiliary values and returns logical files.
It does not choose a directory, publish a report, or serialize execution ledgers.
[JSON output](../integrations/json-output.md) owns logical paths and payloads;

View File

@@ -159,8 +159,10 @@ fallbacks. A hit does not establish fresh acceptance under changed policy.
Consumers needing new inference/assessment deliberately choose bypass/refresh.
Process warnings retain native visibility; quality advisories are not promoted
to warnings. [Configuration](config.md#producer-controls) owns selected modes,
turn allowances, defaults, and precedence.
to warnings. All diagnostic groups are retained, with representative samples
per group rather than an exhaustive occurrence ledger.
[Configuration](config.md#producer-controls) owns selected modes, turn allowances,
defaults, and precedence.
## Output Bundles

View File

@@ -194,8 +194,8 @@ admission before returning.
Warnings are process signals: configuration degradation, qualified fallback,
or incomplete configured work. Quality and grounding findings are advisories;
accepted cleanup is observation. Modules own classification, while the framework
adds origin and aggregates bounded groups. A non-degraded successful run has no
actionable warnings. Retain
adds origin and aggregates all groups with bounded samples. A non-degraded
successful run has no actionable warnings. Retain
[ADR-0015](../adr/0015-separate-process-warnings-from-quality-diagnostics.md)'s
classification decision, not its retired durable reporting contracts.

View File

@@ -244,7 +244,8 @@ and failure semantics rather than silently truncating warnings into success.
**Subsequent decision:** [Discussion Item 1](discussion.md#1-diagnostic-capacity-and-pipeline-success)
selects removal of diagnostic group-count caps while retaining per-group sampling
and genuine failure causes. That accepted design replaces the warning-bound
preservation recommendation above; implementation remains pending.
preservation recommendation above. Group caps and truncation are removed; the
single failure-finalization boundary and preservation of causes remain pending.
### CAT-010 — Process Signals Do Not Reach Cooperative Cancellation

View File

@@ -446,6 +446,13 @@ accepted bodies. Update state/LLM/operations and affected evidence tests.
## Stage 14 — Remove Group Caps, Retain Sampling And Overflow Checks
**Completed.** Local and final group-count caps and collection-only truncation
metadata are removed; origin-aware ordering, three samples, omitted-sample
counts, validation, and checked occurrence totals remain. Many-group collector,
aggregator, and runner regressions pass, as do overflow and the prescribed
contracts, diagnostics, pipeline, and CLI suites. ADR-0028 records the capacity
decision. CAT-009's single finalization and failure-cause work remains pending.
**Coverage:** CAT-009 capacity policy. **Prerequisites:** none.
In contracts/diagnostics, collector, aggregator, and CLI consumers, remove local/

View File

@@ -72,7 +72,4 @@ func reportRunDiagnostics(reporter *commandkit.Reporter, collection contracts.Di
_ = reporter.AtEnd().Info(heading, detail)
}
}
if collection.Truncated {
_ = reporter.AtEnd().Info("Additional pipeline diagnostics were omitted.")
}
}

View File

@@ -12,7 +12,6 @@ const (
MaxDiagnosticScopeBytes = 512
MaxDiagnosticMessageBytes = 4 * 1024
MaxDiagnosticSamples = 3
MaxProducerDiagnosticGroups = 64
)
// DiagnosticDisposition identifies the operator significance of a producer
@@ -97,9 +96,7 @@ type DiagnosticGroup struct {
// and presentation boundaries. Global aggregation policy is applied by the
// framework before it reaches those boundaries.
type DiagnosticCollection struct {
Groups []DiagnosticGroup `json:"groups"`
Truncated bool `json:"truncated"`
UnrepresentedOccurrenceCount int `json:"unrepresented_occurrence_count"`
Groups []DiagnosticGroup `json:"groups"`
}
// DiagnosticProjection is the validated warning/non-warning view used by
@@ -129,9 +126,6 @@ func (diagnostic ProducerDiagnostic) Validate() error {
// ValidateProducerDiagnostics validates the complete set returned by one
// producer or validator result.
func ValidateProducerDiagnostics(diagnostics []ProducerDiagnostic) error {
if len(diagnostics) > MaxProducerDiagnosticGroups {
return errors.New("producer diagnostics exceed maximum group count")
}
for index, diagnostic := range diagnostics {
if err := diagnostic.Validate(); err != nil {
return fmt.Errorf("producer diagnostic %d: %w", index, err)
@@ -179,15 +173,8 @@ func (group DiagnosticGroup) Validate() error {
)
}
// Validate checks the collection shape without imposing later global
// aggregation limits.
// Validate checks the collection shape and group identities.
func (collection DiagnosticCollection) Validate() error {
if collection.UnrepresentedOccurrenceCount < 0 {
return errors.New("diagnostic collection unrepresented occurrence count must not be negative")
}
if !collection.Truncated && collection.UnrepresentedOccurrenceCount != 0 {
return errors.New("diagnostic collection has unrepresented occurrences without truncation")
}
seen := make(map[diagnosticGroupKey]struct{}, len(collection.Groups))
for index, group := range collection.Groups {
if err := group.Validate(); err != nil {
@@ -203,7 +190,7 @@ func (collection DiagnosticCollection) Validate() error {
}
// ProjectDiagnosticCollection validates, partitions, and totals one finalized
// collection. Unrepresented occurrences belong to the non-warning projection.
// collection.
func ProjectDiagnosticCollection(collection DiagnosticCollection) (DiagnosticProjection, error) {
if err := collection.Validate(); err != nil {
return DiagnosticProjection{}, err
@@ -229,11 +216,6 @@ func ProjectDiagnosticCollection(collection DiagnosticCollection) (DiagnosticPro
projection.DiagnosticOccurrenceCount = count
projection.Diagnostics = append(projection.Diagnostics, cloneDiagnosticGroup(group))
}
count, err := addDiagnosticOccurrences(projection.DiagnosticOccurrenceCount, collection.UnrepresentedOccurrenceCount)
if err != nil {
return DiagnosticProjection{}, fmt.Errorf("diagnostic occurrences: %w", err)
}
projection.DiagnosticOccurrenceCount = count
return projection, nil
}

View File

@@ -1,6 +1,7 @@
package contracts
import (
"fmt"
"strings"
"testing"
)
@@ -75,19 +76,15 @@ func TestProducerDiagnosticValidationRejectsInvalidFieldsAndCounts(t *testing.T)
}
}
func TestValidateProducerDiagnosticsEnforcesLocalGroupBound(t *testing.T) {
diagnostics := make([]ProducerDiagnostic, MaxProducerDiagnosticGroups)
func TestValidateProducerDiagnosticsAcceptsManyGroups(t *testing.T) {
diagnostics := make([]ProducerDiagnostic, 400)
for index := range diagnostics {
diagnostics[index] = validProducerDiagnostic()
diagnostics[index].ReasonCode = "reason-" + string(rune('a'+index))
diagnostics[index].ReasonCode = fmt.Sprintf("reason-%d", index)
}
if err := ValidateProducerDiagnostics(diagnostics); err != nil {
t.Fatalf("ValidateProducerDiagnostics() error = %v", err)
}
diagnostics = append(diagnostics, validProducerDiagnostic())
if err := ValidateProducerDiagnostics(diagnostics); err == nil {
t.Fatal("ValidateProducerDiagnostics() error = nil, want excessive-group error")
}
}
func TestDiagnosticGroupValidationPreservesChunkIndexZero(t *testing.T) {
@@ -149,16 +146,12 @@ func TestCloneDiagnosticCollectionOwnsGroupsAndChunkIndex(t *testing.T) {
func TestProjectDiagnosticCollectionPartitionsAndChecksTotals(t *testing.T) {
warning := validDiagnosticGroup(DiagnosticDispositionWarning, DiagnosticCategoryFallback, "fallback", 2)
diagnostic := validDiagnosticGroup(DiagnosticDispositionAdvisory, DiagnosticCategoryDataQuality, "quality", 3)
collection := DiagnosticCollection{
Groups: []DiagnosticGroup{warning, diagnostic},
Truncated: true,
UnrepresentedOccurrenceCount: 4,
}
collection := DiagnosticCollection{Groups: []DiagnosticGroup{warning, diagnostic}}
projection, err := ProjectDiagnosticCollection(collection)
if err != nil {
t.Fatal(err)
}
if len(projection.Warnings) != 1 || len(projection.Diagnostics) != 1 || projection.WarningOccurrenceCount != 2 || projection.DiagnosticOccurrenceCount != 7 {
if len(projection.Warnings) != 1 || len(projection.Diagnostics) != 1 || projection.WarningOccurrenceCount != 2 || projection.DiagnosticOccurrenceCount != 3 {
t.Fatalf("projection = %#v, want partitioned exact totals", projection)
}
collection.Groups[0].Samples[0].Message = "mutated"

View File

@@ -7,26 +7,16 @@ import (
"gitea.maximumdirect.net/eric/notarius/internal/framework/contracts"
)
const (
MaxWarningGroups = 128
MaxNonWarningGroups = 256
)
// Aggregator merges origin-enriched diagnostics in caller-supplied canonical
// order. Its zero value is ready for use.
type Aggregator struct {
groups []contracts.DiagnosticGroup
indices map[groupKey]int
warningGroups int
nonWarningGroups int
warningOccurrences int
nonWarningOccurrences int
unrepresentedOccurrences int
groups []contracts.DiagnosticGroup
indices map[groupKey]int
warningOccurrences int
nonWarningOccurrences int
}
// Add validates and incorporates one final diagnostic group. Actionable
// warnings cannot overflow; later non-warning groups are represented by exact
// unrepresented-occurrence metadata once their fixed bound is reached.
// Add validates and incorporates one final diagnostic group.
func (aggregator *Aggregator) Add(group contracts.DiagnosticGroup) error {
if err := group.Validate(); err != nil {
return fmt.Errorf("diagnostic group: %w", err)
@@ -45,25 +35,9 @@ func (aggregator *Aggregator) Add(group contracts.DiagnosticGroup) error {
aggregator.addOccurrenceTotal(group.Disposition, group.OccurrenceCount)
return nil
}
if group.Disposition == contracts.DiagnosticDispositionWarning {
if aggregator.warningGroups >= MaxWarningGroups {
return errors.New("diagnostic warning groups exceed maximum count")
}
} else if aggregator.nonWarningGroups >= MaxNonWarningGroups {
if err := aggregator.checkOccurrenceTotal(group.Disposition, group.OccurrenceCount); err != nil {
return err
}
aggregator.addOccurrenceTotal(group.Disposition, group.OccurrenceCount)
return aggregator.addUnrepresented(group.OccurrenceCount)
}
if err := aggregator.checkOccurrenceTotal(group.Disposition, group.OccurrenceCount); err != nil {
return err
}
if group.Disposition == contracts.DiagnosticDispositionWarning {
aggregator.warningGroups++
} else {
aggregator.nonWarningGroups++
}
aggregator.addOccurrenceTotal(group.Disposition, group.OccurrenceCount)
aggregator.indices[key] = len(aggregator.groups)
aggregator.groups = append(aggregator.groups, contracts.CloneDiagnosticCollection(contracts.DiagnosticCollection{Groups: []contracts.DiagnosticGroup{group}}).Groups[0])
@@ -96,9 +70,7 @@ func (aggregator *Aggregator) Collection() contracts.DiagnosticCollection {
return contracts.DiagnosticCollection{}
}
return contracts.CloneDiagnosticCollection(contracts.DiagnosticCollection{
Groups: aggregator.groups,
Truncated: aggregator.unrepresentedOccurrences > 0,
UnrepresentedOccurrenceCount: aggregator.unrepresentedOccurrences,
Groups: aggregator.groups,
})
}
@@ -118,14 +90,6 @@ func (aggregator *Aggregator) merge(index int, incoming contracts.DiagnosticGrou
return nil
}
func (aggregator *Aggregator) addUnrepresented(count int) error {
if count > maximumInt()-aggregator.unrepresentedOccurrences {
return errors.New("diagnostic unrepresented occurrence count overflow")
}
aggregator.unrepresentedOccurrences += count
return nil
}
func containsGroupSample(samples []contracts.DiagnosticSample, candidate contracts.DiagnosticSample) bool {
for _, sample := range samples {
if sample.Scope != candidate.Scope || sample.Message != candidate.Message || sample.ChunkID != candidate.ChunkID {

View File

@@ -1,6 +1,7 @@
package diagnostics
import (
"fmt"
"testing"
"gitea.maximumdirect.net/eric/notarius/internal/framework/contracts"
@@ -32,30 +33,39 @@ func TestAggregatorMergesByOriginAndPreservesFirstOccurrenceOrder(t *testing.T)
}
}
func TestAggregatorEnforcesWarningBoundAndTruncatesOnlyNonWarnings(t *testing.T) {
warnings := Aggregator{}
for index := 0; index < MaxWarningGroups; index++ {
group := groupForAggregation("scope", "message", contracts.DiagnosticDispositionWarning, contracts.DiagnosticCategoryFallback, "module")
group.ReasonCode = "warning-" + string(rune('a'+index))
if err := warnings.Add(group); err != nil {
t.Fatalf("warning Add(%d) error = %v", index, err)
func TestAggregatorRetainsManyWarningAndNonWarningGroups(t *testing.T) {
aggregator := Aggregator{}
for index := 0; index < 400; index++ {
for _, kind := range []struct {
disposition contracts.DiagnosticDisposition
category contracts.DiagnosticCategory
}{
{contracts.DiagnosticDispositionWarning, contracts.DiagnosticCategoryFallback},
{contracts.DiagnosticDispositionAdvisory, contracts.DiagnosticCategoryDataQuality},
} {
group := groupForAggregation("scope", "message", kind.disposition, kind.category, "module")
group.ReasonCode = fmt.Sprintf("reason-%d", index)
if err := aggregator.Add(group); err != nil {
t.Fatalf("Add(%d) error = %v", index, err)
}
}
}
if err := warnings.Add(groupForAggregation("overflow", "overflow", contracts.DiagnosticDispositionWarning, contracts.DiagnosticCategoryFallback, "overflow")); err == nil {
t.Fatal("warning overflow error = nil, want error")
if got := len(aggregator.Collection().Groups); got != 800 {
t.Fatalf("group count = %d, want 800", got)
}
}
nonWarnings := Aggregator{}
for index := 0; index < MaxNonWarningGroups+3; index++ {
group := groupForAggregation("scope", "message", contracts.DiagnosticDispositionAdvisory, contracts.DiagnosticCategoryDataQuality, "module")
group.ReasonCode = "advisory-" + string(rune('a'+index))
if err := nonWarnings.Add(group); err != nil {
t.Fatalf("non-warning Add(%d) error = %v", index, err)
func TestAggregatorSamplesRepeatedOccurrences(t *testing.T) {
aggregator := Aggregator{}
for i := 0; i < 5; i++ {
group := groupForAggregation(fmt.Sprintf("scope-%d", i), "message", contracts.DiagnosticDispositionAdvisory, contracts.DiagnosticCategoryDataQuality, "module")
if err := aggregator.Add(group); err != nil {
t.Fatal(err)
}
}
collection := nonWarnings.Collection()
if len(collection.Groups) != MaxNonWarningGroups || !collection.Truncated || collection.UnrepresentedOccurrenceCount != 3 {
t.Fatalf("collection = %#v, want bounded non-warning groups and three unrepresented occurrences", collection)
groups := aggregator.Collection().Groups
if len(groups) != 1 || groups[0].OccurrenceCount != 5 || len(groups[0].Samples) != 3 || groups[0].OmittedSampleCount != 2 {
t.Fatalf("groups = %#v, want five occurrences and three samples", groups)
}
}

View File

@@ -1,4 +1,4 @@
// Package diagnostics provides bounded local grouping for producer and
// Package diagnostics provides local grouping for producer and
// validator diagnostic results.
package diagnostics
@@ -33,9 +33,6 @@ func (collector *Collector) Add(diagnostic contracts.ProducerDiagnostic) error {
diagnosticKey := key{disposition: diagnostic.Disposition, category: diagnostic.Category, reasonCode: diagnostic.ReasonCode}
index, exists := collector.indices[diagnosticKey]
if !exists {
if len(collector.diagnostics) >= contracts.MaxProducerDiagnosticGroups {
return errors.New("producer diagnostics exceed maximum group count")
}
collector.indices[diagnosticKey] = len(collector.diagnostics)
collector.diagnostics = append(collector.diagnostics, contracts.CloneProducerDiagnostics([]contracts.ProducerDiagnostic{diagnostic})[0])
return nil

View File

@@ -1,6 +1,7 @@
package diagnostics
import (
"fmt"
"testing"
"gitea.maximumdirect.net/eric/notarius/internal/framework/contracts"
@@ -33,7 +34,7 @@ func TestCollectorCountsOccurrencesAndRetainsDistinctSamplesInOrder(t *testing.T
}
}
func TestCollectorSeparatesGroupsAndRejectsInvalidOrExcessiveGroups(t *testing.T) {
func TestCollectorSeparatesGroupsAndRejectsInvalidGroups(t *testing.T) {
collector := NewCollector()
if err := collector.Add(advisory("one", "first")); err != nil {
t.Fatalf("Add() error = %v", err)
@@ -54,16 +55,16 @@ func TestCollectorSeparatesGroupsAndRejectsInvalidOrExcessiveGroups(t *testing.T
t.Fatal("Add() error = nil, want invalid diagnostic error")
}
limited := NewCollector()
for index := 0; index < contracts.MaxProducerDiagnosticGroups; index++ {
many := NewCollector()
for index := 0; index < 400; index++ {
diagnostic := advisory("scope", "message")
diagnostic.ReasonCode = "reason-" + string(rune('a'+index))
if err := limited.Add(diagnostic); err != nil {
diagnostic.ReasonCode = fmt.Sprintf("reason-%d", index)
if err := many.Add(diagnostic); err != nil {
t.Fatalf("Add(%d) error = %v", index, err)
}
}
if err := limited.Add(advisory("overflow", "overflow")); err == nil {
t.Fatal("Add() error = nil, want local group limit error")
if got := len(many.Diagnostics()); got != 400 {
t.Fatalf("group count = %d, want 400", got)
}
}
@@ -80,6 +81,22 @@ func TestCollectorReturnsIndependentSnapshots(t *testing.T) {
}
}
func TestCollectorRejectsOccurrenceOverflow(t *testing.T) {
collector := NewCollector()
first := advisory("scope", "message")
first.OccurrenceCount = maximumInt()
first.OmittedSampleCount = maximumInt() - 1
if err := collector.Add(first); err != nil {
t.Fatal(err)
}
if err := collector.Add(advisory("other", "message")); err == nil {
t.Fatal("Add() accepted occurrence count overflow")
}
if got := collector.Diagnostics(); len(got) != 1 || got[0].OccurrenceCount != maximumInt() {
t.Fatalf("collector changed after overflow: %#v", got)
}
}
func advisory(scope string, message string) contracts.ProducerDiagnostic {
return contracts.ProducerDiagnostic{
Disposition: contracts.DiagnosticDispositionAdvisory,

View File

@@ -1,6 +1,8 @@
package pipeline
import (
"context"
"fmt"
"testing"
"gitea.maximumdirect.net/eric/notarius/internal/framework/contracts"
@@ -17,6 +19,23 @@ func TestPromoteProducerDiagnosticsPreservesValidatorOrigin(t *testing.T) {
}
}
func TestRunnerRetainsManyDiagnosticGroups(t *testing.T) {
diagnostics := make([]contracts.ProducerDiagnostic, 0, 600)
for i := 0; i < 300; i++ {
warning := producerDiagnostic("scope", "warning")
warning.Disposition = contracts.DiagnosticDispositionWarning
warning.Category = contracts.DiagnosticCategoryDegradation
warning.ReasonCode = fmt.Sprintf("warning-%d", i)
advisory := producerDiagnostic("scope", "advisory")
advisory.ReasonCode = fmt.Sprintf("advisory-%d", i)
diagnostics = append(diagnostics, warning, advisory)
}
output, err := New().Run(context.Background(), RunInput{Prepared: preparedConcurrentPipeline(t, 1), RawInput: []byte("input"), Diagnostics: diagnostics})
if err != nil || len(output.Diagnostics.Groups) != len(diagnostics) {
t.Fatalf("Run() error = %v, groups = %d, want %d", err, len(output.Diagnostics.Groups), len(diagnostics))
}
}
func TestAppendDiagnosticGroupsRetainsOnlyStructuredDiagnostics(t *testing.T) {
output := RunOutput{}
appendDiagnosticGroups(&output, []contracts.DiagnosticGroup{{