from research import *
s=begin(759,'Test Cainan residual neutrality','Does insertion change existing rounding discrepancies?',{'Cainan':{'b':130,'r':330,'L':460}},['File18 Cainan; C754–758'])
q=lambda n:5*((n+2)//5)
p=json.loads((ROOT/'model/rounding_inputs.json').read_text()); results={}
for t,rows in p['native_rows'].items():
    base=[x for x in rows if x['name']!='2nd Cainan']
    at=next(i for i,x in enumerate(base) if x['name']=='Shelah')
    added=base[:at]+[{'name':'2nd Cainan','lifespan':460}]+base[at:]
    def field(rr):return {x['name']:sum(q(z['lifespan'])-z['lifespan'] for z in rr[i:]) for i,x in enumerate(rr)}
    a,b=field(base),field(added)
    results[t]={'all_common_residuals_equal':all(a[n]==b[n] for n in a),'new_node_D':b['2nd Cainan'],'Shelah_D':b['Shelah']}
finish(s,{'results':results,'duration_residuals':[q(n)-n for n in [130,330,460]]},'Cainan insertion changes admitted durations but preserves every corresponding residual. Its new boundary inherits the local plateau; zero row residual does not imply zero boundary displacement.','Prove rounding compatibility with admitted multiples-of-five changes.',{'common_fields':all(x['all_common_residuals_equal'] for x in results.values()),'new_boundary_plateau':all(x['new_node_D']==x['Shelah_D'] for x in results.values())})
