2026-07-20 21:16:08 +00:00
package cli
import (
"context"
"encoding/json"
"fmt"
"reflect"
"sort"
"strings"
"sync"
"testing"
"gitea.maximumdirect.net/eric/notarius/internal/core/source"
"gitea.maximumdirect.net/eric/notarius/internal/framework/contracts"
"gitea.maximumdirect.net/eric/notarius/internal/framework/pipeline"
"gitea.maximumdirect.net/eric/notarius/internal/modules/dnd"
2026-11-22 05:07:00 +00:00
spells "gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/extract/spells"
2026-07-20 21:16:08 +00:00
spellnormalize "gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/normalize/spells"
2026-11-22 05:07:00 +00:00
"go.maximumdirect.net/promptkit"
2026-07-20 21:16:08 +00:00
)
const assembledSpellExtractorKey = "test/dnd/spell-casts"
2026-08-27 01:06:17 +00:00
const assembledDirectSpellValidatorKey = "test/dnd/direct-spell-correction"
2026-07-20 21:16:08 +00:00
func TestAssembledSpellPipelineNormalizesMergedCasts ( t * testing . T ) {
2026-07-20 19:44:35 -05:00
registries , resolved , extractor := assembledSpellPipeline ( t , assembledSpellPipelineOptions { } )
2026-07-20 21:16:08 +00:00
prepared , err := pipeline . Prepare ( resolved , registries , pipeline . ModuleDependencies { } )
if err != nil {
t . Fatalf ( "Prepare() error = %v, want nil" , err )
}
output , err := pipeline . New ( ) . Run ( context . Background ( ) , pipeline . RunInput {
2026-11-22 05:07:00 +00:00
Prepared : prepared ,
RawInput : readRepositoryFile ( t , "examples" , "seriatim-minimal-transcript.json" ) ,
2026-07-20 21:16:08 +00:00
} )
if err != nil {
t . Fatalf ( "Run() error = %v, want nil" , err )
}
chunkIndexes := extractor . chunkIndexesSnapshot ( )
sort . Ints ( chunkIndexes )
if ! reflect . DeepEqual ( chunkIndexes , [ ] int { 0 , 1 } ) {
t . Fatalf ( "extractor chunk indexes = %#v, want two chunk-boundary calls" , chunkIndexes )
}
2026-11-22 05:07:00 +00:00
if len ( output . OutputFiles ) != 1 || output . FallbackCount != 0 {
t . Fatalf ( "output=%#v, want accepted spell artifact" , output )
2026-07-20 21:16:08 +00:00
}
2026-11-22 05:07:00 +00:00
normalized := decodeAssembledOutput [ dnd . SpellList ] ( t , output . OutputFiles , "lanes/spells.json" )
2026-07-20 21:16:08 +00:00
if len ( normalized . SpellCasts ) != 2 {
t . Fatalf ( "normalized casts = %#v, want collapsed duplicate plus distinct evidence" , normalized . SpellCasts )
}
first , distinct := normalized . SpellCasts [ 0 ] , normalized . SpellCasts [ 1 ]
2026-07-22 19:01:58 +00:00
if first . Spell != "Cure Wounds" || first . Caster != " Aria \t" {
t . Fatalf ( "retained cast = %#v, want canonical spell with first occurrence caster" , first )
2026-07-20 21:16:08 +00:00
}
if ! reflect . DeepEqual ( first . SourceRefs , [ ] source . SourceRef { { SourceID : "session-alpha" , StartUnitID : 1 , EndUnitID : 1 } , { SourceID : "session-alpha" , StartUnitID : 2 , EndUnitID : 2 } } ) {
t . Fatalf ( "retained refs = %#v, want sorted complete evidence" , first . SourceRefs )
}
if distinct . Spell != "Cure Wounds" || distinct . Caster != "aria" || ! reflect . DeepEqual ( distinct . SourceRefs , [ ] source . SourceRef { { SourceID : "session-alpha" , StartUnitID : 2 , EndUnitID : 2 } } ) {
t . Fatalf ( "distinct cast = %#v, want separate evidence event" , distinct )
}
2026-08-27 18:41:59 +00:00
wantDiagnosticReasons := [ ] string {
2026-07-20 21:16:08 +00:00
spellnormalize . ReasonCodeSpellNameCanonicalized ,
spellnormalize . ReasonCodeSourceReferencesNormalized ,
spellnormalize . ReasonCodeDuplicateSpellCastCollapsed ,
"spell_not_near_source" ,
}
2026-08-27 18:41:59 +00:00
gotDiagnosticReasons := make ( [ ] string , len ( output . Diagnostics . Groups ) )
2026-08-27 16:40:17 +00:00
for index , group := range output . Diagnostics . Groups {
2026-08-27 18:41:59 +00:00
gotDiagnosticReasons [ index ] = group . ReasonCode
2026-07-20 21:16:08 +00:00
}
2026-08-27 18:41:59 +00:00
if ! reflect . DeepEqual ( gotDiagnosticReasons , wantDiagnosticReasons ) {
2026-08-27 16:40:17 +00:00
t . Fatalf ( "diagnostics = %#v, want deterministic normalize and validation diagnostics" , output . Diagnostics )
2026-07-20 21:16:08 +00:00
}
2026-08-27 16:40:17 +00:00
if output . Diagnostics . Groups [ 2 ] . Samples [ 0 ] . Scope != "spell_casts[0]" || ! strings . Contains ( output . Diagnostics . Groups [ 2 ] . Samples [ 0 ] . Message , "retained input index 0" ) || ! strings . Contains ( output . Diagnostics . Groups [ 2 ] . Samples [ 0 ] . Message , "removed input indices [1]" ) {
t . Fatalf ( "duplicate diagnostic = %#v, want retained and removed merged indices" , output . Diagnostics . Groups [ 2 ] )
2026-07-20 21:16:08 +00:00
}
2026-11-22 05:07:00 +00:00
for _ , group := range output . Diagnostics . Groups {
if group . Disposition == contracts . DiagnosticDispositionWarning {
t . Fatalf ( "advisory-only normalization emitted a process warning: %#v" , group )
}
2026-07-20 21:16:08 +00:00
}
}
2026-08-27 01:06:17 +00:00
func TestAssembledSpellPipelineCorrectsRejectedDirectExtraction ( t * testing . T ) {
2026-11-22 05:07:00 +00:00
components := productionTestComponents ( t )
if err := pipeline . RegisterTypedValidator [ dnd . SpellList ] ( components . registries . Validators , dnd . SpellListKind , pipeline . ValidatorSpec { Key : assembledDirectSpellValidatorKey , ExecutionClass : contracts . ExecutionClassDeterministic } , func ( ) ( contracts . TypedValidator [ dnd . SpellList ] , error ) { return assembledDirectSpellValidator { } , nil } ) ; err != nil {
t . Fatal ( err )
}
turns := 1
extract := pipeline . Binding ( spells . Key )
extract . MaxAdditionalTurns = & turns
extract . Validators = pipeline . ValidatorOverride { Set : true , Validators : [ ] pipeline . ModuleBinding { pipeline . Binding ( assembledDirectSpellValidatorKey ) } }
resolved , err := pipeline . ResolvePipeline ( pipeline . PipelineProfile {
ID : "assembled-dnd-correcting-spells" , Input : pipeline . Binding ( "seriatim" ) , Chunk : pipeline . ModuleBinding { Module : "generic" , Options : map [ string ] any { "max_units" : 2 } } ,
Artifacts : map [ string ] pipeline . ArtifactLaneProfile { "spells" : { Extract : extract , Normalize : pipeline . Binding ( spellnormalize . Key ) } } , Output : pipeline . Binding ( "json" ) ,
} , pipeline . ResolveOptions { } , catalogFromRegistries ( components . registries ) )
2026-08-27 01:06:17 +00:00
if err != nil {
2026-11-22 05:07:00 +00:00
t . Fatal ( err )
2026-08-27 01:06:17 +00:00
}
2026-11-22 05:07:00 +00:00
client := & assembledSpellCorrectionClient { }
prepared , err := pipeline . Prepare ( resolved , components . registries , pipeline . ModuleDependencies { Engine : productionNativeEngine ( t , client ) } )
2026-08-27 01:06:17 +00:00
if err != nil {
2026-11-22 05:07:00 +00:00
t . Fatal ( err )
}
output , err := pipeline . New ( ) . Run ( context . Background ( ) , pipeline . RunInput { Prepared : prepared , RawInput : readRepositoryFile ( t , "examples" , "seriatim-minimal-transcript.json" ) } )
if err != nil {
t . Fatal ( err )
2026-08-27 01:06:17 +00:00
}
2026-11-22 05:07:00 +00:00
value := decodeAssembledOutput [ dnd . SpellList ] ( t , output . OutputFiles , "lanes/spells.json" )
if output . FallbackCount != 0 || len ( value . SpellCasts ) != 1 || value . SpellCasts [ 0 ] . Spell != "Cure Wounds" {
t . Fatalf ( "output=%#v spells=%#v" , output , value )
2026-08-27 01:06:17 +00:00
}
2026-11-22 05:07:00 +00:00
client . mu . Lock ( )
requests := append ( [ ] promptkit . GenerateRequest ( nil ) , client . requests ... )
client . mu . Unlock ( )
if len ( requests ) != 2 {
t . Fatalf ( "provider calls=%d, want rejected and revised candidates" , len ( requests ) )
}
initial , revised := requests [ 0 ] . Prompt . Messages , requests [ 1 ] . Prompt . Messages
if len ( revised ) != len ( initial ) + 2 || ! reflect . DeepEqual ( revised [ : len ( initial ) ] , initial ) {
t . Fatal ( "correction lost native growing history" )
}
assistant , guidance := revised [ len ( initial ) ] , revised [ len ( initial ) + 1 ]
if assistant . Role != promptkit . RoleAssistant || assistant . Content != assembledRejectedSpellResponse || guidance . Role != promptkit . RoleUser || ! strings . Contains ( guidance . Content , "use a known spell name" ) || ! strings . Contains ( guidance . Content , "complete replacement" ) {
t . Fatalf ( "native correction=%#v" , revised [ len ( initial ) : ] )
}
for _ , fragment := range [ ] string { "unknown_spell" , "spell is not in the catalog" , assembledDirectSpellValidatorKey } {
if strings . Contains ( guidance . Content , fragment ) {
t . Fatalf ( "correction contains diagnostic prose or identifier: %s" , guidance . Content )
}
2026-08-27 01:06:17 +00:00
}
}
2026-07-20 21:16:08 +00:00
func TestAssembledSpellPipelineHonorsNormalizeValidatorOverride ( t * testing . T ) {
2026-07-20 19:44:35 -05:00
registries , resolved , _ := assembledSpellPipeline ( t , assembledSpellPipelineOptions { normalizeValidatorOverride : true } )
2026-07-20 21:16:08 +00:00
var normalizeChain * pipeline . ResolvedValidatorChain
for index := range resolved . ValidatorChains {
chain := & resolved . ValidatorChains [ index ]
if chain . Stage == pipeline . StageNormalize && chain . ModuleKey == spellnormalize . Key && chain . LaneID == "spells" {
normalizeChain = chain
break
}
}
if normalizeChain == nil || len ( normalizeChain . Validators ) != 1 || normalizeChain . Validators [ 0 ] . Binding . Module != "generic/always_accept" {
t . Fatalf ( "normalize validator chain = %#v, want explicit always-accept override" , normalizeChain )
}
prepared , err := pipeline . Prepare ( resolved , registries , pipeline . ModuleDependencies { } )
if err != nil {
t . Fatalf ( "Prepare() error = %v, want nil" , err )
}
output , err := pipeline . New ( ) . Run ( context . Background ( ) , pipeline . RunInput {
2026-11-22 05:07:00 +00:00
Prepared : prepared ,
RawInput : readRepositoryFile ( t , "examples" , "seriatim-minimal-transcript.json" ) ,
2026-07-20 21:16:08 +00:00
} )
2026-11-22 05:07:00 +00:00
if err != nil || output . FallbackCount != 0 || len ( output . OutputFiles ) != 1 {
2026-07-20 21:16:08 +00:00
t . Fatalf ( "Run() error = %v output = %#v, want approved override run" , err , output )
}
2026-08-27 16:40:17 +00:00
for _ , group := range output . Diagnostics . Groups {
if group . ReasonCode == "spell_not_near_source" {
t . Fatalf ( "diagnostics = %#v, want explicit validator override to replace default relatedness chain" , output . Diagnostics )
2026-07-20 21:16:08 +00:00
}
}
}
2026-11-22 05:07:00 +00:00
func TestAssembledSpellPipelineRejectsUnknownSpellDuringNormalization ( t * testing . T ) {
2026-07-20 19:44:35 -05:00
registries , resolved , _ := assembledSpellPipeline ( t , assembledSpellPipelineOptions { unknownSpell : true } )
prepared , err := pipeline . Prepare ( resolved , registries , pipeline . ModuleDependencies { } )
if err != nil {
2026-11-22 05:07:00 +00:00
t . Fatal ( err )
2026-07-20 19:44:35 -05:00
}
2026-11-22 05:07:00 +00:00
output , err := pipeline . New ( ) . Run ( context . Background ( ) , pipeline . RunInput { Prepared : prepared , RawInput : readRepositoryFile ( t , "examples" , "seriatim-minimal-transcript.json" ) } )
for _ , fragment := range [ ] string { "normalize" , ` lane "spells" ` , "extract/dnd/spells/catalog" } {
if err == nil || ! strings . Contains ( err . Error ( ) , fragment ) {
t . Fatalf ( "error=%v, want scoped catalog rejection (%s)" , err , fragment )
}
2026-07-20 19:44:35 -05:00
}
2026-11-22 05:07:00 +00:00
if len ( output . OutputFiles ) != 0 || output . FallbackCount != 0 {
t . Fatalf ( "strict normalization failure published output: %#v" , output )
2026-07-20 19:44:35 -05:00
}
}
2026-08-27 18:41:59 +00:00
func TestAssembledSpellPipelinePromotesUnknownSpellAdvisoryWhenOverrideAccepts ( t * testing . T ) {
2026-07-20 19:44:35 -05:00
registries , resolved , _ := assembledSpellPipeline ( t , assembledSpellPipelineOptions { normalizeValidatorOverride : true , unknownSpell : true } )
prepared , err := pipeline . Prepare ( resolved , registries , pipeline . ModuleDependencies { } )
if err != nil {
t . Fatalf ( "Prepare() error = %v, want nil" , err )
}
output , err := pipeline . New ( ) . Run ( context . Background ( ) , pipeline . RunInput {
2026-11-22 05:07:00 +00:00
Prepared : prepared ,
RawInput : readRepositoryFile ( t , "examples" , "seriatim-minimal-transcript.json" ) ,
2026-07-20 19:44:35 -05:00
} )
if err != nil {
t . Fatalf ( "Run() error = %v, want nil" , err )
}
2026-11-22 05:07:00 +00:00
if output . FallbackCount != 0 || len ( output . OutputFiles ) != 1 {
t . Fatalf ( "output=%#v, want accepted explicit validator override" , output )
2026-07-20 19:44:35 -05:00
}
2026-11-22 05:07:00 +00:00
normalized := decodeAssembledOutput [ dnd . SpellList ] ( t , output . OutputFiles , "lanes/spells.json" )
2026-07-20 19:44:35 -05:00
if len ( normalized . SpellCasts ) != 1 || normalized . SpellCasts [ 0 ] . Spell != "Mysterious Burst" {
t . Fatalf ( "normalized casts = %#v, want unresolved name preserved" , normalized . SpellCasts )
}
2026-08-27 16:40:17 +00:00
if len ( output . Diagnostics . Groups ) != 1 || output . Diagnostics . Groups [ 0 ] . ReasonCode != spellnormalize . ReasonCodeSpellNameUnresolved || output . Diagnostics . Groups [ 0 ] . Samples [ 0 ] . Scope != "spell_casts[0]" {
t . Fatalf ( "diagnostics = %#v, want promoted scoped unresolved-name diagnostic" , output . Diagnostics )
2026-07-20 19:44:35 -05:00
}
2026-11-22 05:07:00 +00:00
if output . Diagnostics . Groups [ 0 ] . Disposition == contracts . DiagnosticDispositionWarning {
t . Fatal ( "unknown-spell advisory became a process warning" )
2026-08-27 16:43:09 +00:00
}
2026-07-20 19:44:35 -05:00
}
type assembledSpellPipelineOptions struct {
normalizeValidatorOverride bool
unknownSpell bool
}
func assembledSpellPipeline ( t * testing . T , options assembledSpellPipelineOptions ) ( pipeline . Registries , pipeline . ResolvedPipeline , * assembledSpellExtractor ) {
2026-07-20 21:16:08 +00:00
t . Helper ( )
components := productionTestComponents ( t )
2026-07-20 19:44:35 -05:00
extractor := & assembledSpellExtractor { unknownSpell : options . unknownSpell }
2026-07-20 21:16:08 +00:00
if err := pipeline . RegisterExtractor [ dnd . SpellList ] ( components . registries . Extractors , pipeline . ModuleSpec {
2026-08-03 17:00:08 +00:00
Key : assembledSpellExtractorKey ,
Stage : pipeline . StageExtract ,
ExecutionClass : contracts . ExecutionClassDeterministic ,
Requires : [ ] string { "chunks" , "source.transcript" } ,
Provides : [ ] string { "dnd.spell_casts" } ,
ArtifactKind : dnd . SpellListKind ,
2026-07-20 21:16:08 +00:00
} , func ( ) ( contracts . Extractor [ dnd . SpellList ] , error ) {
return extractor , nil
} ) ; err != nil {
t . Fatalf ( "register assembled extractor: %v" , err )
}
normalize := pipeline . Binding ( spellnormalize . Key )
2026-07-20 19:44:35 -05:00
if options . normalizeValidatorOverride {
2026-07-20 21:16:08 +00:00
normalize . Validators = pipeline . ValidatorOverride {
Set : true ,
Validators : [ ] pipeline . ModuleBinding { pipeline . Binding ( "generic/always_accept" ) } ,
}
}
resolved , err := pipeline . ResolvePipeline ( pipeline . PipelineProfile {
ID : "assembled-dnd-spells" ,
Input : pipeline . Binding ( "seriatim" ) ,
Chunk : pipeline . ModuleBinding { Module : "generic" , Options : map [ string ] any { "max_units" : 1 } } ,
Artifacts : map [ string ] pipeline . ArtifactLaneProfile {
"spells" : { Extract : pipeline . Binding ( assembledSpellExtractorKey ) , Normalize : normalize } ,
} ,
Output : pipeline . Binding ( "json" ) ,
} , pipeline . ResolveOptions { } , catalogFromRegistries ( components . registries ) )
if err != nil {
t . Fatalf ( "ResolvePipeline() error = %v, want nil" , err )
}
return components . registries , resolved , extractor
}
type assembledSpellExtractor struct {
mu sync . Mutex
chunkIndexes [ ] int
2026-07-20 19:44:35 -05:00
unknownSpell bool
2026-07-20 21:16:08 +00:00
}
2026-11-22 05:07:00 +00:00
const assembledRejectedSpellResponse = ` { "spell_casts":[ { "caster":"Aria","spell":"Mysterious Burst","source_refs":[ { "start_unit_id":1,"end_unit_id":1}]}]} `
2026-08-27 01:06:17 +00:00
2026-11-22 05:07:00 +00:00
type assembledSpellCorrectionClient struct {
mu sync . Mutex
requests [ ] promptkit . GenerateRequest
}
2026-08-27 01:06:17 +00:00
2026-11-22 05:07:00 +00:00
func ( client * assembledSpellCorrectionClient ) Generate ( ctx context . Context , request promptkit . GenerateRequest ) ( * promptkit . GenerateResponse , error ) {
if err := ctx . Err ( ) ; err != nil {
return nil , err
2026-08-27 01:06:17 +00:00
}
2026-11-22 05:07:00 +00:00
client . mu . Lock ( )
defer client . mu . Unlock ( )
if ! productionSchemaHasProperty ( request , "spell_casts" ) {
return nil , fmt . Errorf ( "unexpected native response contract" )
2026-08-27 01:06:17 +00:00
}
2026-11-22 05:07:00 +00:00
client . requests = append ( client . requests , request )
content := assembledRejectedSpellResponse
if len ( client . requests ) > 1 {
content = ` { "spell_casts":[ { "caster":"Aria","spell":"Cure Wounds","source_refs":[ { "start_unit_id":1,"end_unit_id":1}]}]} `
2026-08-27 01:06:17 +00:00
}
2026-11-22 05:07:00 +00:00
return & promptkit . GenerateResponse { Content : content } , nil
2026-08-27 01:06:17 +00:00
}
type assembledDirectSpellValidator struct { }
func ( assembledDirectSpellValidator ) Name ( ) string { return assembledDirectSpellValidatorKey }
func ( assembledDirectSpellValidator ) ExecutionClass ( ) contracts . ExecutionClass {
return contracts . ExecutionClassDeterministic
}
func ( assembledDirectSpellValidator ) Validate ( _ context . Context , req contracts . TypedValidationRequest [ dnd . SpellList ] ) ( contracts . ValidationResult , error ) {
for _ , cast := range req . Value . SpellCasts {
if cast . Spell == "Mysterious Burst" {
return contracts . ValidationResult { Approved : false , ReasonCode : "unknown_spell" , Message : "spell is not in the catalog" , CorrectionGuidance : "use a known spell name" } , nil
}
}
return contracts . ValidationResult { Approved : true } , nil
}
2026-07-20 21:16:08 +00:00
func ( e * assembledSpellExtractor ) Key ( ) string { return assembledSpellExtractorKey }
func ( * assembledSpellExtractor ) ReferenceSlots ( ) [ ] contracts . ReferenceSlot { return nil }
2026-11-22 05:07:00 +00:00
func ( e * assembledSpellExtractor ) Extract ( ctx context . Context , req contracts . TypedExtractionRequest [ dnd . SpellList ] ) ( contracts . TypedExtractionResult [ dnd . SpellList ] , error ) {
2026-07-20 21:16:08 +00:00
if err := ctx . Err ( ) ; err != nil {
return contracts . TypedExtractionResult [ dnd . SpellList ] { } , err
}
if req . Chunk == nil || req . Source == nil {
return contracts . TypedExtractionResult [ dnd . SpellList ] { } , fmt . Errorf ( "assembled extractor requires source and chunk" )
}
e . mu . Lock ( )
e . chunkIndexes = append ( e . chunkIndexes , req . Chunk . Index )
e . mu . Unlock ( )
refOne := source . SourceRef { SourceID : req . Source . ID , StartUnitID : 1 , EndUnitID : 1 }
refTwo := source . SourceRef { SourceID : req . Source . ID , StartUnitID : 2 , EndUnitID : 2 }
2026-07-20 19:44:35 -05:00
if e . unknownSpell {
if req . Chunk . Index == 0 {
return contracts . TypedExtractionResult [ dnd . SpellList ] { Value : dnd . SpellList { SpellCasts : [ ] dnd . SpellCast { {
2026-07-22 19:01:58 +00:00
Caster : "Aria" , Spell : "Mysterious Burst" , SourceRefs : [ ] source . SourceRef { refOne } ,
2026-07-20 19:44:35 -05:00
} } } } , nil
}
return contracts . TypedExtractionResult [ dnd . SpellList ] { Value : dnd . SpellList { SpellCasts : [ ] dnd . SpellCast { } } } , nil
}
2026-07-20 21:16:08 +00:00
switch req . Chunk . Index {
case 0 :
return contracts . TypedExtractionResult [ dnd . SpellList ] { Value : dnd . SpellList { SpellCasts : [ ] dnd . SpellCast { {
2026-07-22 19:01:58 +00:00
Caster : " Aria \t" , Spell : " cure wounds " , SourceRefs : [ ] source . SourceRef { refTwo , refOne } ,
2026-07-20 21:16:08 +00:00
} } } } , nil
case 1 :
return contracts . TypedExtractionResult [ dnd . SpellList ] { Value : dnd . SpellList { SpellCasts : [ ] dnd . SpellCast {
2026-07-22 19:01:58 +00:00
{ Caster : "aria" , Spell : "Cure Wounds" , SourceRefs : [ ] source . SourceRef { refOne , refTwo } } ,
{ Caster : "aria" , Spell : "Cure Wounds" , SourceRefs : [ ] source . SourceRef { refTwo } } ,
2026-07-20 21:16:08 +00:00
} } } , nil
default :
return contracts . TypedExtractionResult [ dnd . SpellList ] { } , fmt . Errorf ( "unexpected assembled chunk index %d" , req . Chunk . Index )
}
}
func ( e * assembledSpellExtractor ) chunkIndexesSnapshot ( ) [ ] int {
e . mu . Lock ( )
defer e . mu . Unlock ( )
return append ( [ ] int ( nil ) , e . chunkIndexes ... )
}
func decodeAssembledOutput [ T any ] ( t * testing . T , files [ ] contracts . OutputFile , name string ) T {
t . Helper ( )
for _ , file := range files {
if file . Name != name {
continue
}
var value T
if err := json . Unmarshal ( file . Bytes , & value ) ; err != nil {
t . Fatalf ( "decode %s: %v" , name , err )
}
return value
}
t . Fatalf ( "output files = %#v, want %q" , files , name )
return * new ( T )
}