"""Source-derived experiment diagram. No simulated activity is depicted."""
from pathlib import Path
import json
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
from matplotlib.patches import Rectangle,FancyArrowPatch
ROOT=Path(__file__).resolve().parent
c=json.loads((ROOT/'run-contract.json').read_text());r=json.loads((ROOT/'checks/compatibility.json').read_text())
PAPER,INK,VIOLET,MUTED,LINE='#fcfaf7','#28222d','#6240ab','#776e7d','#d8cfdf'
plt.rcParams.update({'font.family':'STIXGeneral','text.color':INK,'font.size':14,'svg.fonttype':'none'})
f=plt.figure(figsize=(12.8,8),dpi=150,facecolor=PAPER)
f.text(.065,.94,'felisyn  /  research note 11',color=VIOLET,fontsize=15)
f.text(.065,.869,'Before the full cat-circuit experiment',fontsize=29)
f.text(.065,.817,'A fixed protocol, with explicit limits on what each check can establish.',color=MUTED,fontsize=15)
ax=f.add_axes([0,0,1,1]);ax.set(xlim=(0,1),ylim=(0,1));ax.axis('off')
ax.plot([.065,.935],[.778,.778],color=LINE,lw=1)
f.text(.065,.725,'01  Compatibility checked',fontsize=19,color=VIOLET)
f.text(.065,.679,f"{r['passed']}/{r['total']} parameter schemas pass",fontsize=22)
f.text(.065,.61,'Released self_connections = True retains the earlier\ndiagonal weight rule in the inspected source.',fontsize=15,linespacing=1.35)
f.text(.065,.532,'Four synthetic connector checks pass.\nThe authors’ exact runtime remains unknown.',fontsize=13,color=MUTED,linespacing=1.35)
ax.plot([.51,.51],[.545,.736],color=LINE,lw=1)
f.text(.56,.725,'02  Experiment specified',fontsize=19,color=VIOLET)
f.text(.56,.679,'40.32 seconds of model time',fontsize=22)
f.text(.56,.61,'Four cortical populations · six metrics\n4,032 bins × 10 ms · one declared seed pair',fontsize=15,linespacing=1.35)
f.text(.56,.532,'48 numerical analysis comparisons\n24 printed means for descriptive comparison',fontsize=13,color=MUTED,linespacing=1.35)
f.text(.065,.454,'Planned workflow',fontsize=19)
f.text(.935,.454,'Sequence diagram · widths not to scale',ha='right',fontsize=12,color=MUTED)
boxes=[(.065,.15,'Blank','150 ms',False),(.24,.41,'Measured spontaneous activity','40,320 ms',True),(.675,.12,'Reset blank','150 ms',False),(.82,.115,'End blank','150 ms',False)]
for x,w,title,duration,active in boxes:
 ax.add_patch(Rectangle((x,.285),w,.12,facecolor=VIOLET if active else PAPER,edgecolor=VIOLET if active else LINE,lw=1.2))
 color='white' if active else INK
 ax.text(x+w/2,.36,title,ha='center',va='center',fontsize=13,color=color)
 ax.text(x+w/2,.32,duration,ha='center',va='center',fontsize=14,color=color)
for x1,x2 in [(.215,.24),(.65,.675),(.795,.82)]:
 ax.add_patch(FancyArrowPatch((x1+.003,.345),(x2-.003,.345),arrowstyle='-|>',mutation_scale=11,color=MUTED))
f.text(.065,.235,'40,770 ms total, derived from the pinned workflow. Only the central window is analyzed.',fontsize=13,color=MUTED)
ax.plot([.065,.935],[.187,.187],color=LINE,lw=1)
f.text(.065,.135,'Full-model run: pending',fontsize=21,color=VIOLET)
f.text(.065,.09,'Software checks do not establish biological validation or autonomous token control.',fontsize=14)
f.text(.065,.047,'Sources: LSV1M v1.0 · Mozaik v0.4.0 + commit history · Antolík et al. (2024) · felisyn.com/journal',fontsize=11,color=MUTED)
out=ROOT/'figures';out.mkdir(exist_ok=True)
for ext in ['png','svg']:f.savefig(out/('full-model-protocol.'+ext),facecolor=PAPER,dpi=150)
