from research import *
s=begin(827,'Check final reading artifacts and their links','Are the synthesis and guide structurally complete and directly usable?',{},['C824–826'])
import re
files=['deliverables/490d_Chronological_Families_Integrated_Synthesis_C831.md','deliverables/490d_Chronological_Families_Reading_Guide_C831.md'];out={}
for rel in files:
    doc=(ROOT/rel).read_text();links=re.findall(r'\]\(sandbox:([^\)]+)\)',doc);widths=[];current=[]
    for line in doc.splitlines()+['']:
        if line.startswith('|'):current.append(len(line.split('|'))-2)
        elif current:widths.append(current);current=[]
    out[rel]={'sandbox_links':links,'all_links_exist':all(Path(x).is_file() for x in links),'table_column_counts':widths,'all_tables_rectangular':all(len(set(x))==1 for x in widths),'headings':len(re.findall(r'^#+ ',doc,re.M))}
finish(s,{'document_checks':out},'The synthesis and short guide have valid rectangular tables, working visual/document links, and complete section structure.','Verify the completed prefix and unchanged source bindings before the closing record.',{'links':all(x['all_links_exist'] for x in out.values()),'tables':all(x['all_tables_rectangular'] for x in out.values())})
