from pathlib import Path
import json,ast
P=Path(__file__).resolve().parent
cases=json.loads((P/'fixtures/cases.json').read_text(encoding='utf-8'))['cases']
assert len(cases)==8 and len({c['id'] for c in cases})==8
ast.parse((P/'starter.py').read_text(encoding='utf-8'))
required=['command_name','registered_commands','frontend_origin','window_label','capability_allows','permission_allows','input_schema','input','domain_authorized','allowed_resource_prefix','resource','side_effect_class','prior_idempotency_keys','audit_event_id']
for c in cases:
    for k in required: assert k in c,(c['id'],k)
assert any(c['command_name']=='admin_action' for c in cases)
assert any(c['capability_allows'] is False for c in cases)
assert any(c['capability_allows'] is None for c in cases)
assert any(c['resource'] and not c['resource'].startswith(c['allowed_resource_prefix']) for c in cases)
assert any(c.get('idempotency_key') in c.get('prior_idempotency_keys',[]) for c in cases if c.get('idempotency_key'))
assert any(c.get('transfer') for c in cases)
print('PASS learner structural checks: 8 synthetic cases, generic-dispatcher negative, runtime denial/unknown, resource-scope negative, idempotent replay, transfer fixture')
