Classify remaining D&D producer diagnostics

This commit is contained in:
2026-08-27 16:04:32 +00:00
parent 6a1fd7bdb6
commit 480680b257
22 changed files with 202 additions and 182 deletions

View File

@@ -25,7 +25,6 @@ const (
ReasonCodeSourceRefsNormalized = "source_references_normalized"
ReasonCodeEventsReordered = "enemy_events_reordered"
ReasonCodeDuplicateCollapsed = "duplicate_enemy_event_collapsed"
ReasonCodeWarningsOmitted = "enemy_event_normalization_warnings_omitted"
)
const (
@@ -106,7 +105,11 @@ func (n *Normalizer) Normalize(ctx context.Context, req contracts.TypedNormalize
index := source.NewDocumentIndex(req.Source)
order := shared.NewSourceRefOrderFromIndex(index)
value, warnings := normalizeList(req.MergeOutput.Value, order, registry)
return contracts.TypedNormalizeResult[dnd.EnemyEventList]{Value: value, Warnings: warnings}, nil
diagnosticGroups, err := diagnostics.NormalizationDiagnostics(warnings)
if err != nil {
return contracts.TypedNormalizeResult[dnd.EnemyEventList]{}, normalizerErrorf("collect diagnostics: %w", err)
}
return contracts.TypedNormalizeResult[dnd.EnemyEventList]{Value: value, Diagnostics: diagnosticGroups}, nil
}
type normalizedRecord struct {
@@ -163,7 +166,7 @@ func normalizeList(input dnd.EnemyEventList, order shared.SourceRefOrder, regist
output, duplicateWarnings := collapseDuplicates(records)
warnings = append(warnings, duplicateWarnings...)
return dnd.EnemyEventList{Events: output}, diagnostics.LimitWarnings(warnings, "enemy_events", ReasonCodeWarningsOmitted)
return dnd.EnemyEventList{Events: output}, warnings
}
func normalizeEvent(input dnd.EnemyEvent, order shared.SourceRefOrder, registry *npcregistry.Registry) (dnd.EnemyEvent, *nameCanonicalization, bool) {