367 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
65 lines
4.8 KiB
Python
65 lines
4.8 KiB
Python
#!/usr/bin/env python3
|
|
"""Capture a natural, already-submitted native NPC spline in the actual client.
|
|
|
|
No client launch, packet injection, actor movement, credential entry or database
|
|
writes. Requires an active world session and manual review of captured frames.
|
|
"""
|
|
import argparse,datetime,json,math,os,time
|
|
from pathlib import Path
|
|
from client_session import Session
|
|
from native_engine_character_test import Controller,ROOT,local_listeners
|
|
from native_test_guard import require_local_turtle_ports,require_authenticated_turtle_realm,require_native_world_observation
|
|
|
|
def main():
|
|
p=argparse.ArgumentParser(description=__doc__)
|
|
p.add_argument('--guid',type=int,required=True)
|
|
p.add_argument('--deadline',type=float,default=120)
|
|
p.add_argument('--min-duration',type=int,default=4000)
|
|
p.add_argument('--near',type=float,nargs=3,metavar=('X','Y','Z'),help='Observe only paths beginning near this known stationary viewing position')
|
|
p.add_argument('--max-distance',type=float,default=25)
|
|
p.add_argument('--facing',type=float,help='Known stationary camera/player orientation; require path start within60 degrees')
|
|
args=p.parse_args()
|
|
if not 10<=args.deadline<=600 or not 1<=args.min_duration<=600000 or not 0<args.guid<2**64:p.error('Bound observation to local actor identity and10..600seconds')
|
|
if not math.isfinite(args.max_distance) or not 1<=args.max_distance<=200 or (args.near and any(not math.isfinite(v) or abs(v)>100000 for v in args.near)):p.error('Require finite bounded observation coordinates/distance')
|
|
if args.facing is not None and (not args.near or not math.isfinite(args.facing)):p.error('Facing filter requires finite orientation and known viewing position')
|
|
require_local_turtle_ports(local_listeners());os.umask(0o077)
|
|
folder=ROOT/'runtime'/('native-npc-motion-'+datetime.datetime.now().strftime('%Y%m%d-%H%M%S'))
|
|
folder.mkdir(mode=0o700)
|
|
pid=int((ROOT/'runtime/native-client.pid').read_text());c=Controller(pid)
|
|
began=time.monotonic();seen=set();last_report=began
|
|
result={'pid':pid,'guid':str(args.guid),'external_gateway_running':False,'visual_movement_verified':False,'review_required':True,'frames':[]}
|
|
result['view_filter']={'near':args.near,'max_distance':args.max_distance,'facing':args.facing}
|
|
with Session(pid) as session,(folder/'events.jsonl').open('w') as events:
|
|
require_authenticated_turtle_realm(c.rpc('inspect-wire-account'))
|
|
pipe=c.rpc('inspect-engine-pipe');engine=c.rpc('inspect-engine-session')
|
|
require_native_world_observation(pipe,engine,session.state())
|
|
result['engine_self_create_consumed']=True
|
|
initial=pipe['motion']
|
|
seen.update((row['legacy_guid'],row['id']) for row in initial['rows'])
|
|
while time.monotonic()-began<args.deadline:
|
|
pipe=c.rpc('inspect-engine-pipe')
|
|
if pipe['closed'] or pipe['error']:raise RuntimeError('Actual native connection failed; evidence retained')
|
|
for row in pipe['motion']['rows']:
|
|
key=(row['legacy_guid'],row['id'])
|
|
if key in seen:continue
|
|
if len(seen)>=16384:raise RuntimeError('Observation event bound reached')
|
|
seen.add(key);events.write(json.dumps(dict(elapsed=round(time.monotonic()-began,3),**row))+'\n');events.flush()
|
|
if int(row['legacy_guid'])!=args.guid or row['duration']<args.min_duration:continue
|
|
if args.near and math.dist(row['start'],args.near)>args.max_distance:continue
|
|
if args.facing is not None:
|
|
dx=row['start'][0]-args.near[0];dy=row['start'][1]-args.near[1]
|
|
if dx*math.cos(args.facing)+dy*math.sin(args.facing)<.5*math.hypot(dx,dy):continue
|
|
result['spline']=row;result['counters']={k:v for k,v in pipe['motion'].items() if k!='rows'}
|
|
print('Observed actual native spline:',json.dumps(row),flush=True)
|
|
for index in range(5):
|
|
at=time.monotonic();name=f'frame-{index}.png';session.shot(folder/name)
|
|
result['frames'].append({'file':name,'elapsed_seconds':round(time.monotonic()-began,3),'capture_seconds':round(time.monotonic()-at,3)})
|
|
(folder/'result.json').write_text(json.dumps(result,indent=2)+'\n')
|
|
print('Actual-client frames require visual review:',folder,flush=True);return
|
|
if time.monotonic()-last_report>=15:
|
|
print('Waiting for new natural matching spline; elapsed_seconds=',round(time.monotonic()-began,1),'submitted=',pipe['motion']['sent'],flush=True);last_report=time.monotonic()
|
|
time.sleep(.1)
|
|
result['timeout']=True;(folder/'result.json').write_text(json.dumps(result,indent=2)+'\n')
|
|
raise SystemExit('No matching natural spline before deadline; no visual success claimed. Evidence: '+str(folder))
|
|
if __name__=='__main__':main()
|