import json
from pathlib import Path
from starter import evaluate
P=Path(__file__).parent
cases=json.loads((P/'fixtures/cases.json').read_text(encoding='utf-8'))['cases']
required={'envelope_state','cpu_state','memory_state','io_state','primary_state','effective_state','decision','reason'}
for c in cases:
    try:r=evaluate(c)
    except NotImplementedError:
        print('STARTER_NOT_IMPLEMENTED: implement evaluate(case), then rerun checks.'); raise SystemExit(2)
    assert isinstance(r,dict) and required<=set(r)
    assert r['decision'] in {'RUN','DEGRADED','PAUSE','BLOCKED','UNKNOWN'}
    assert isinstance(r['reason'],str) and r['reason'].strip()
print(f'PASS learner shape/safety checks for {len(cases)} cases')
