883 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
43 lines
2.7 KiB
Python
43 lines
2.7 KiB
Python
#!/usr/bin/env python3
|
|
"""Source exploration bitmap against independent typed native UF goldens."""
|
|
import struct,subprocess,sys
|
|
from pathlib import Path
|
|
P=struct.pack;CLI=Path(sys.argv[1]);FIRST=1111;SELF=4509
|
|
def call(mode,wire,ok=True):
|
|
r=subprocess.run([str(CLI),mode],input=wire,capture_output=True)
|
|
assert (r.returncode==0)==ok,(mode,r.stderr.decode(errors='replace'))
|
|
return r.stdout
|
|
def source_values(words):
|
|
fields={FIRST+i:v for i,v in enumerate(words)};n=(FIRST+63)//32+1;mask=[0]*n
|
|
for index in fields:mask[index//32]|=1<<(index%32)
|
|
body=P('<IBB',1,0,0)+bytes.fromhex('039d11')+bytes([n])+P('<'+'I'*n,*mask)+b''.join(P('<I',v)for v in words)
|
|
return P('<HIQI',70,0,SELF,0xa9)+body
|
|
for areas in ((),(0,31,32,63,64,1582,2047),(31,63),(32,64,1582),(2047,)):
|
|
words=[0]*64;native=[0]*32
|
|
for area in areas:words[area//32]|=1<<(area%32);native[area//64]|=1<<(area%64)
|
|
actual=call('--unit-values',source_values(words))
|
|
expected=call('--native-explored-zone-values',P('<HIQ32Q',70,0,SELF,*native))
|
|
assert actual==expected,('native BitVectors slot1/mask/dynamic32 mismatch',areas)
|
|
# The stateless writer refuses incomplete values; Entity supplies the full
|
|
# cached Source bitmap and cannot zero an absent counterpart by accident.
|
|
n=FIRST//32+1;mask=[0]*n;mask[FIRST//32]=1<<(FIRST%32)
|
|
body=P('<IBB',1,0,0)+bytes.fromhex('039d11')+bytes([n])+P('<'+'I'*n,*mask)+P('<I',1)
|
|
call('--unit-values',P('<HIQI',70,0,SELF,0xa9)+body,False)
|
|
# Full SELF creates use known zeros for absent source fields, retain every
|
|
# bit in the same native dynamic32-word layout, and never copy these to peers.
|
|
words=[0]*64
|
|
for area in (31,32,63,64,1582,2047):words[area//32]|=1<<(area%32)
|
|
fields={22:80,28:80,34:1,35:1,36:0x01000101,**{FIRST+i:v for i,v in enumerate(words)}}
|
|
n=max(fields)//32+1;mask=[0]*n
|
|
for index in fields:mask[index//32]|=1<<(index%32)
|
|
body=P('<IBB',1,0,3)+bytes.fromhex('039d11')+bytes([4,0x21])+P('<II4fI',0,100,1,2,3,0,0)+P('<6f',2.5,7,4.5,4.72,2.5,3.14)
|
|
body+=bytes([n])+P('<'+'I'*n,*mask)+b''.join(P('<I',fields[i])for i in sorted(fields))
|
|
header=P('<QHIIIII',SELF,70,0x46010046,0,12,0,0)+b'ExplorationFixture\0'+bytes([1,1,0])+P('<I',0xa9)
|
|
r=subprocess.run([str(CLI)],input=header+body,capture_output=True);assert r.returncode==0,r.stderr.decode(errors='replace')
|
|
assert (P('<I',32)+b''.join(P('<II',words[i],words[i+1])for i in range(0,64,2))) in r.stdout
|
|
for area,xp in ((2040,123),(5561,0),(0x7fffffff,0x7fffffff)):
|
|
assert call('--native-exploration-experience',P('<II',area,xp))==P('<II',area,xp)
|
|
for wire in (b'',bytes(7),bytes(9),P('<II',0x80000000,0),P('<II',1,0x80000000)):
|
|
call('--native-exploration-experience',wire,False)
|
|
print('Exploration typed native BitVector32 goldens, full SELF, incomplete snapshot refusal and XP framing pass.')
|