from research import *
s=begin(1409,'Validate the four-part release bundle','Do the embedded components match their final files and declared counts?',{},['deliverables/490d_Four_Part_Grammar_C1431.json'])
d=json.loads((ROOT/'deliverables/490d_Four_Part_Grammar_C1431.json').read_text());parts=d['components']
counts={'primitive_modules':len(parts[0]['content']['modules']),'operations':len(parts[1]['content']['operation_ids']),'relation_modules':len(parts[2]['content']['relations']),'reconstruction_families':len(parts[3]['content']['entries'])}
r={'counts':counts,'components':[{'component':x['component'],'matches_file':x['content']==json.loads((ROOT/x['path']).read_text()),'matches_hash':hashlib.sha256((ROOT/x['path']).read_bytes()).hexdigest()==x['sha256']} for x in parts]}
a=artifact('model/final_grammar_validation.json',json.dumps(r,indent=2)+'\n')
finish(s,{'validation':a},'The release bundle contains exactly the intended eight input modules, twelve operations, nine relation modules and six reconstruction families, each identical to its final component file.','Validate the reader navigation links.',{'counts':counts=={'primitive_modules':8,'operations':12,'relation_modules':9,'reconstruction_families':6},'identities':all(x['matches_file'] and x['matches_hash'] for x in r['components'])})
