367 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
61 lines
3.9 KiB
Python
61 lines
3.9 KiB
Python
#!/usr/bin/env python3
|
|
"""Reversible real-client carried stack split/merge; no item grants or stat edits.
|
|
|
|
Requires the established food117 count4 in backpack root23 and empty root25.
|
|
Original C_Container APIs perform actions; authoritative native cache and saved
|
|
server rows verify results. Capture Lua API availability before using this tool.
|
|
"""
|
|
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 session lost; preserve stack recovery evidence')
|
|
return p
|
|
def food(p):return [i for i in p['inventory']['rows'] if i['entry']==117]
|
|
original=food(inspect())
|
|
saved=db('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;')
|
|
if len(original)!=1 or original[0]['count']!=4 or saved!=f"{int(original[0]['guid'])&0xffffffff}\t0\t23\t4":raise RuntimeError('Actual food baseline differs; no action taken')
|
|
if db('SELECT item FROM tw_char.character_inventory WHERE guid=4509 AND bag=0 AND slot=25;'):raise RuntimeError('Destination not empty; no action taken')
|
|
path=ROOT/'runtime/native-stack-test.json'
|
|
if path.exists():raise RuntimeError('Earlier evidence preserved')
|
|
report={'pid':c.pid,'external_gateway_running':False,'baseline':original,'saved_before':saved,'restored':False,'ui_review_required':True}
|
|
def restored(p):
|
|
f=food(p);return len(f)==1 and f[0]['guid']==original[0]['guid'] and f[0]['count']==4
|
|
def split(p):
|
|
f=food(p);return len(f)==2 and sorted(i['count'] for i in f)==[1,3] and any(i['guid']==original[0]['guid'] and i['count']==3 for i in f)
|
|
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.SplitContainerItem(0,1,1);C_Container.PickupContainerItem(0,3)')
|
|
p=c.wait(lambda:(p if split(p:=inspect()) else None),6);report['split']=food(p)
|
|
ui.key(s.d,'b');s.shot(ROOT/'runtime/native-stack-split.png')
|
|
s.macro('/run C_Container.PickupContainerItem(0,3);C_Container.PickupContainerItem(0,1)')
|
|
p=c.wait(lambda:(p if restored(p:=inspect()) else None),6);report['merged']=food(p)
|
|
s.shot(ROOT/'runtime/native-stack-merged.png')
|
|
except Exception as error:report['error']=str(error);raise
|
|
finally:
|
|
try:
|
|
p=inspect()
|
|
if split(p):
|
|
s.macro('/run C_Container.PickupContainerItem(0,3);C_Container.PickupContainerItem(0,1)')
|
|
c.wait(lambda:restored(inspect()),6)
|
|
elif not restored(p):raise RuntimeError('Unexpected food state; preserve evidence, no blind cleanup')
|
|
s.macro('/s .save')
|
|
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;'
|
|
report['saved_after']=c.wait(lambda:(v if (v:=db(sql))==saved else None),6)
|
|
report['restored']=True
|
|
finally:
|
|
ui.KEY_DELAY=old;report['trace']=trace.report();path.write_text(json.dumps(report,indent=2)+'\n')
|
|
print('Real native stack evidence requires review:',path)
|
|
if __name__=='__main__':main()
|