883 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
76 lines
4.1 KiB
Python
76 lines
4.1 KiB
Python
#!/usr/bin/env python3
|
|
"""Exact original-registry lookup boundary; no process, engine or auth IO."""
|
|
import importlib.util,json,struct
|
|
from pathlib import Path
|
|
|
|
ROOT=Path(__file__).resolve().parents[1]
|
|
spec=importlib.util.spec_from_file_location('engine_session_inspect',ROOT/'ops/engine_session_inspect.py')
|
|
m=importlib.util.module_from_spec(spec);spec.loader.exec_module(m)
|
|
|
|
class Memory:
|
|
def __init__(self,capacity=128,entries=0x200000,tombstones=1):
|
|
self.cells={};self.reads=[]
|
|
self.put(*m.MAP_AREA_GETTER_ANCHOR)
|
|
self.put(m.MAP_AREA_REGISTRY,struct.pack('<4Q',capacity,entries,0,tombstones))
|
|
self.entries=entries
|
|
def put(self,address,data):
|
|
for n,value in enumerate(data):self.cells[address+n]=value
|
|
def read(self,address,size):
|
|
self.reads.append((address,size))
|
|
if any(address+n not in self.cells for n in range(size)):raise ValueError('Unreadable fixed fixture mapping')
|
|
return bytes(self.cells[address+n] for n in range(size))
|
|
def key(self,index,value):self.put(self.entries+index*16,struct.pack('<I',value))
|
|
def descriptor(self,index,pointer,vtable,method,gate):
|
|
self.put(self.entries+index*16+8,struct.pack('<Q',pointer))
|
|
self.put(pointer,struct.pack('<Q',vtable))
|
|
self.put(pointer+0x20d,bytes([gate]))
|
|
self.put(vtable+0x48,struct.pack('<Q',method))
|
|
def run(self):return m.inspect_map_area_descriptors(self.read,lambda address,size:address in (0x140123000,0x140234000))
|
|
|
|
def main():
|
|
# Original 655770 vectors at capacity128: Map initial56, Area initial19.
|
|
# Collision56 -> tombstone57 -> match59 tests triangular rather than linear.
|
|
memory=Memory()
|
|
memory.key(56,0x12345678);memory.key(57,1);memory.key(59,0xbd84cd62)
|
|
memory.descriptor(59,0x300000,0x145000000,0x140123000,0)
|
|
memory.key(19,0x7253eb43)
|
|
memory.descriptor(19,0x301000,0x145001000,0x140234000,1)
|
|
result=memory.run();a,b=result['tables']
|
|
assert a['probes']==3 and b['probes']==1
|
|
assert [x['status'] for x in (a,b)]==['exact-key-descriptor-observed']*2
|
|
assert a['notify_gate_20d']==0 and b['notify_gate_20d']==1
|
|
assert all(x['row_admission_or_reindex_semantics_proven'] is False for x in (a,b))
|
|
assert (memory.entries+56*16+8,8) not in memory.reads
|
|
assert (memory.entries+57*16+8,8) not in memory.reads
|
|
assert all(size<=32 for address,size in memory.reads)
|
|
checks=1
|
|
for capacity,entries,tombstones in [(0,0x200000,0),(3,0x200000,0),(0x200000,0x200000,0),(128,0x200001,0),(128,0xfffffffffffffff0,0),(128,0x200000,129)]:
|
|
memory=Memory(capacity,entries,tombstones)
|
|
assert memory.run()['status']=='registry-held'
|
|
assert len(memory.reads)==2
|
|
checks+=1
|
|
memory=Memory();memory.put(m.MAP_AREA_GETTER_ANCHOR[0],b'X')
|
|
assert memory.run()['status']=='registry-held' and len(memory.reads)==1;checks+=1
|
|
original=m.MAP_AREA_TABLE_KEYS
|
|
m.MAP_AREA_TABLE_KEYS=(('Map',123),)
|
|
memory=Memory()
|
|
assert memory.run()['status']=='registry-held' and memory.reads==[]
|
|
m.MAP_AREA_TABLE_KEYS=original;checks+=1
|
|
memory=Memory();memory.key(56,0);memory.key(19,0)
|
|
assert all(x['status']=='no-matching-key' for x in memory.run()['tables']);checks+=1
|
|
memory=Memory();memory.key(56,0xbd84cd62);memory.put(memory.entries+56*16+8,struct.pack('<Q',0xdead000));memory.key(19,0)
|
|
assert memory.run()['tables'][0]['status']=='matching-key-or-mapping-held';checks+=1
|
|
memory=Memory()
|
|
# No matching descriptor may be followed after the bounded 32 key probes.
|
|
for start in (56,19):
|
|
index=start
|
|
for step in range(32):
|
|
memory.key(index,0x12345678);index=(index+step+1)&127
|
|
bounded=memory.run()
|
|
assert all(x['status']=='probe-bound-held' and x['probes']==32 for x in bounded['tables'])
|
|
assert len(memory.reads)==66;checks+=1
|
|
assert m.ENABLE_MAP_AREA_DESCRIPTOR_LOOKUP is False
|
|
print(json.dumps({'status':'PASS','checks':checks,'actual_original_hash_vectors':2,'max_probes_per_key':32,'unrelated_descriptor_reads':0,'native_or_auth_io':False,'default_lookup_enabled':False}))
|
|
|
|
if __name__=='__main__':main()
|