367 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
59 lines
4.1 KiB
Python
59 lines
4.1 KiB
Python
#!/usr/bin/env python3
|
|
"""Actual root -> equipped bag move/use -> root restoration, native gateway off."""
|
|
import json,os
|
|
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_gameplay_policy
|
|
from native_world_trace import WorldTrace
|
|
from local_tortoise import db
|
|
import client_ui as ui
|
|
|
|
def main():
|
|
os.umask(0o077);require_local_turtle_ports(local_listeners())
|
|
c=Controller(int((ROOT/'runtime/native-client.pid').read_text()));require_authenticated_turtle_realm(c.rpc('inspect-wire-account'));require_native_gameplay_policy(c.rpc('inspect-native-channel-policy'))
|
|
def inspect():
|
|
p=c.rpc('inspect-engine-pipe')
|
|
if p['error'] or p['closed']:raise RuntimeError('Native bag session lost; preserve recovery evidence')
|
|
return p
|
|
def food():
|
|
rows=[i for i in inspect()['inventory']['rows'] if i['entry']==117]
|
|
if len(rows)!=1 or rows[0]['count'] not in (3,4):raise RuntimeError('Unexpected food state; no blind restoration')
|
|
return rows[0]
|
|
baseline=food()
|
|
if baseline['count']!=4 or baseline['contained']!='4509':raise RuntimeError('Require original food4 at root')
|
|
bag=db('SELECT item FROM tw_char.character_inventory WHERE guid=4509 AND bag=0 AND slot=19;')
|
|
if not bag.isdecimal():raise RuntimeError('First equipped bag missing')
|
|
bag=int(bag);bag_guid=str((0x4000<<48)|bag)
|
|
sql='SELECT ci.item,ci.bag,ci.slot,ii.count FROM tw_char.character_inventory ci JOIN tw_char.item_instance ii ON ii.guid=ci.item WHERE ci.guid=4509 AND ii.itemEntry=117;'
|
|
saved=db(sql)
|
|
if saved!=f"{int(baseline['guid'])&0xffffffff}\t0\t23\t4":raise RuntimeError('Food source differs')
|
|
if db(f'SELECT item FROM tw_char.character_inventory WHERE guid=4509 AND bag={bag} AND slot=0;'):raise RuntimeError('Bag destination occupied')
|
|
path=ROOT/'runtime/native-equipped-bag.json'
|
|
if path.exists():raise RuntimeError('Previous evidence preserved')
|
|
report={'pid':c.pid,'external_gateway_running':False,'baseline':baseline,'saved_before':saved,'bag_item':bag,'restored':False}
|
|
with Session(c.pid) as s,WorldTrace(c) as trace:
|
|
c.wait(lambda:s.state()=='world',15);s.focus();old=ui.KEY_DELAY;ui.KEY_DELAY=.03
|
|
try:
|
|
s.macro('/run C_Container.PickupContainerItem(0,1);C_Container.PickupContainerItem(1,1)')
|
|
c.wait(lambda:food()['contained']==bag_guid,6);s.macro('/s .save')
|
|
report['saved_in_bag']=c.wait(lambda:(v if (v:=db(sql)).split('\t')[1:3]==[str(bag),'0'] else None),6)
|
|
ui.key(s.d,'b');s.shot(ROOT/'runtime/native-equipped-bag-moved.png')
|
|
before=inspect()['cast_result']['count'];s.macro('/use 1 1')
|
|
def used():
|
|
p=inspect();r=p['cast_result'];return p if food()['count']==3 and r['count']>before and r['spell']==433 and r['status']==0 else None
|
|
p=c.wait(used,7);report['used']={'food':food(),'cast_result':p['cast_result'],'item_request':p['item_request']}
|
|
s.shot(ROOT/'runtime/native-equipped-bag-used.png')
|
|
except Exception as error:report['error']=str(error);raise
|
|
finally:
|
|
try:
|
|
current=food()
|
|
if current['count']==3:s.macro('/s .additem 117 1');c.wait(lambda:food()['count']==4,6)
|
|
if food()['contained']==bag_guid:
|
|
s.macro('/run C_Container.PickupContainerItem(1,1);C_Container.PickupContainerItem(0,1)');c.wait(lambda:food()['contained']=='4509',6)
|
|
elif food()['contained']!='4509':raise RuntimeError('Unexpected food container; preserve, no blind move')
|
|
s.macro('/stand');s.macro('/s .save');report['saved_after']=c.wait(lambda:(v if (v:=db(sql))==saved else None),6);report['restored']=True
|
|
s.shot(ROOT/'runtime/native-equipped-bag-restored.png')
|
|
finally:ui.KEY_DELAY=old;report['trace']=trace.report();path.write_text(json.dumps(report,indent=2)+'\n')
|
|
print('Actual equipped-bag movement/use evidence requires review:',path)
|
|
if __name__=='__main__':main()
|