from research import *
family="covenant"
p=ROOT/'prep/manuscript_covenant.json'
packet=json.loads(p.read_text());modules=packet if isinstance(packet,list) else packet['modules'];m=modules[3]
textbody=m.get('text',m.get('body',''))
for old,new in [["Let B and D","For the full-state comparison, let B and D"],["and E the Exodus","and e the Exodus"],["B−E","B−e"],["(M−E)","(M−e)"]]:textbody=textbody.replace(old,new)
s=begin(1093,'Manuscript: '+m['title'],'Does this section accurately connect its complete source family to the shared explanation?',{'draft_sha256':hashlib.sha256(p.read_bytes()).hexdigest(),'module_index':3},['C1071','prep/manuscript_covenant.json'])
sources=m.get('sources',m.get('source_sections',m.get('citations',[])));source_notes=[]
for x in sources:
 if isinstance(x,str):source_notes.append(x)
 else:source_notes.append(x.get('file','')+' '+(', '.join(x.get('sections',[])) if 'sections' in x else x.get('section','')))
steps=m.get('steps',m.get('C_steps',[x for x in m.get('citations',[]) if x.startswith('C')]))
if not steps and family=='round':steps=['C932–C952','C1058–C1068']
content='### '+m['title']+'\n\n'+textbody+'\n\n*Sources:* '+'; '.join(source_notes)+'.\n\n*Research record:* '+', '.join('C'+str(x) if isinstance(x,int) else str(x) for x in steps)+'.\n'
rel='deliverables/sections/22_covenant_4.md'
a=artifact(rel,content)
checks={'full_state_named':'full-state comparison' in textbody,'symbol_distinct':'B−e' in textbody and '(M−e)' in textbody,'phase_policy':'one Nisan-derived clutch' in textbody}
finish(s,{'section':a,'body_words':len(textbody.split()),'source_references':len(source_notes)},"The clutch section specifies the full-state comparison, uses a distinct Exodus symbol, and separates the forced first two joins from the additional147 relation.",'Reassess the next explanatory section against its source roles and the sealed calculations.',checks)

