883 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
49 lines
2.5 KiB
Python
49 lines
2.5 KiB
Python
#!/usr/bin/env python3
|
|
"""Actual existing collector, corrected PIPE scope; no game/process/body IO."""
|
|
import json,sys
|
|
from pathlib import Path
|
|
sys.path.insert(0,str(Path(__file__).resolve().parents[1]/'ops'))
|
|
import native_world_trace as m
|
|
|
|
class Controller:
|
|
def __init__(self,error=0):self.calls=[];self.error=error
|
|
def rpc(self,operation,**args):
|
|
assert operation=='inspect-engine-pipe' and args=={'unit_fields_only':True}
|
|
self.calls.append((operation,args))
|
|
if len(self.calls)==1:return {'trace_count':0,'trace':[],'error':0,'closed':0,'world':{'trace_count':0,'trace':[]}}
|
|
return {'trace_count':3,'trace':[{'direction':3,'opcode':0x4b0001,'bytes':176},{'direction':2,'opcode':0x440011,'bytes':16},{'direction':3,'opcode':0x4b0003,'bytes':198018}],
|
|
'error':self.error,'closed':0,'world':{'trace_count':1,'trace':[{'direction':2,'opcode':0x4400ea,'bytes':0}]}}
|
|
class Thread:
|
|
def __init__(self,**kwargs):pass
|
|
def start(self):pass
|
|
def join(self,timeout):pass
|
|
def is_alive(self):return False
|
|
class Stop:
|
|
def __init__(self):self.calls=0
|
|
def wait(self,delay):self.calls+=1;return self.calls>1
|
|
def set(self):self.calls=100
|
|
|
|
def run(scope,error=0):
|
|
controller=Controller(error);trace=m.WorldTrace(controller,collect_fields=False,metadata_scope=scope)
|
|
trace.stop=Stop();trace.__enter__();trace._collect();trace.__exit__()
|
|
assert len(controller.calls)==2
|
|
return trace
|
|
|
|
def main():
|
|
m.threading.Thread=Thread
|
|
pipe=run('pipe');rows=pipe.report()['trace']
|
|
assert [x['opcode'] for x in rows]==[0x4b0001,0x440011,0x4b0003]
|
|
assert [x['bytes'] for x in rows]==[176,16,198018]
|
|
assert pipe.error is None and pipe.lost==0 and pipe.field_records==[] and pipe.action_records==[]
|
|
world=run('world');assert [x['opcode'] for x in world.report()['trace']]==[0x4400ea]
|
|
failed=run('pipe',1);assert failed.error=='Native pipe failed during observation'
|
|
for kwargs in ({'metadata_scope':'arbitrary','collect_fields':False},{'metadata_scope':'pipe','collect_fields':True}):
|
|
c=Controller()
|
|
try:m.WorldTrace(c,**kwargs)
|
|
except ValueError:pass
|
|
else:raise AssertionError('Header-only scope refusal missing')
|
|
assert c.calls==[]
|
|
print(json.dumps({'status':'PASS','actual_collector_pipe_ring_retains_advertisement_request_reply':True,'same_two_snapshots_only_no_extra_RPC':True,'default_World_ring_unchanged':True,'closed_error_guard_preserved':True,'source_fields_actions_bodies_auth_captured':False,'invalid_scope_zero_RPC':True}))
|
|
|
|
if __name__=='__main__':main()
|