from research import *
s=begin(768,'Compare row rounding with date-grid rounding','Can rounding already calculated dates reproduce the source chronology?',{'grid_anchor':1406},['File51a §16.2; C754–757'])
f=json.loads((ROOT/'model/all_rounding_fields.json').read_text());q=lambda n:5*((n+2)//5);out={}
for t,rows in f.items():
    out[t]={n:{'grid':1406+q(x['actual']-1406),'row':x['rounded']} for n,x in rows.items() if 1406+q(x['actual']-1406)!=x['rounded']}
a=artifact('model/date_grid_diagnostic.json',json.dumps(out,indent=2)+'\n')
finish(s,{'diagnostic':a,'mismatch_counts':{t:len(x) for t,x in out.items()},'MT_examples':{n:out['MT_native_OFF'][n] for n in ['Noah','Abraham']}},'A nearest1/6 date-grid projection fails at11 of26 MT boundaries. Rounded chronology depends on the source path, not just the final Actual date.','Test subdivision dependence over an informative complete source subpath.',{'counts':[len(x) for x in out.values()]==[11,7,17],'Noah':out['MT_native_OFF']['Noah']=={'grid':6381,'row':6386}})
