883 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
23 lines
2.3 KiB
Python
23 lines
2.3 KiB
Python
import argparse,ast,struct,subprocess,tempfile
|
|
from pathlib import Path
|
|
p=argparse.ArgumentParser();p.add_argument('--native',type=Path,required=True);a=p.parse_args()
|
|
module=ast.parse(Path('ops/engine_pipe_host.py').read_text());node=next(n for n in module.body if isinstance(n,ast.FunctionDef)and n.name=='decode_motion_metadata');scope={'struct':struct};exec(compile(ast.Module(body=[node],type_ignores=[]),'<matching-motion-decoder>','exec'),scope);decode=scope['decode_motion_metadata']
|
|
with tempfile.TemporaryDirectory(prefix='warrior-action-boundary-')as directory:
|
|
output=Path(directory)/'motion.bin';native_run=subprocess.run([str(a.native.resolve()),str(output)],capture_output=True)
|
|
if native_run.returncode:raise AssertionError('Native fixture: '+native_run.stderr.decode(errors='replace')[:240])
|
|
data=output.read_bytes()
|
|
r=decode(data);assert r['abi']==2 and r['snapshot_bytes']==2208 and len(r['rows'])==1
|
|
assert r['rows'][0]['id']==99 and r['rows'][0]['start']==[1,2,3]and r['rows'][0]['destination']==[4,5,6]
|
|
rows=r['actions'];sequences=[int(x['sequence'])for x in rows];assert sequences==sorted(set(sequences))and len(rows)<=16
|
|
rejected=next(x for x in rows if x['kind']==5);assert rejected['source_flags']==0x400 and rejected['available']==31 and 'flags'in rejected['rejection']
|
|
unobserved=next(x for x in rows if x['kind']==5 and not x['available']);assert unobserved['source_mover']is None and unobserved['source_target']is None and unobserved['source_flags']is None
|
|
damage=next(x for x in rows if x['kind']==6);assert damage['spell']==20647 and damage['damage']==600 and damage['blocked']==17 and damage['match']==5
|
|
unrelated=next(x for x in rows if x['kind']==2 and x['spell']==20549);assert unrelated['action']=='0'and unrelated['source_target']=='0'and unrelated['match']==0
|
|
assert any(x['kind']==2 and x['spell']==20662 and x['match']==2 and x['action']=='0'for x in rows)
|
|
legacy=bytearray(data[:1056]);struct.pack_into('<2I',legacy,0,1,1056);struct.pack_into('<I',legacy,28,0);old=decode(legacy);assert old['rows']==r['rows']and old['actions']==[]
|
|
for bad in [data[:1056],bytes(31)]:
|
|
try:decode(bad)
|
|
except ValueError:pass
|
|
else:raise AssertionError('Invalid snapshot framing accepted')
|
|
print('PASS: native same-parse/writer + ABI1/2decoder, exact bounded attribution and stale/overlap guards.')
|