Files
WoW-Hybrid-gateway/ops/native_equip_aura_visual_test.py
praxisandClaude Fable 5.2 8a24c445b0 Content pipeline and operator tools
367 files, from working commit b1a079a.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-19 01:32:48 +02:00

87 lines
7.9 KiB
Python

#!/usr/bin/env python3
"""Reversible empty-neck equip-aura control through the actual private client.
GM grants one source-defined fixture; the real inventory UI equips/unequips it.
No fabricated aura, visual packet, forced alpha, SQL write or engine call.
Screenshots require review; this tool never asserts that a visual rendered.
"""
import argparse,json
from pathlib import Path
import client_ui as ui
from client_session import Session
from local_tortoise import db
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,require_solo_test_character
from native_vendor_buy_test import inventory
from native_world_trace import WorldTrace
def main():
p=argparse.ArgumentParser(description=__doc__);p.add_argument('--item',type=int,required=True);p.add_argument('--output',type=Path,required=True);p.add_argument('--keep-equipped',action='store_true',help='Explicit operator request to retain the real fixture as new equipment baseline');a=p.parse_args();out=a.output.resolve()
if not 0<a.item<65536 or not out.is_relative_to(ROOT/'runtime') or out.suffix!='.json' or out.exists():p.error('Require bounded source item and new runtime report')
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'));require_solo_test_character(4509,db('SELECT guid FROM tw_char.characters WHERE online<>0 ORDER BY guid;'))
template=db(f'SELECT class,inventory_type,required_level,spellid_1,spelltrigger_1 FROM tw_world.item_template WHERE entry={a.item};').split('\t')
if len(template)!=5 or template[0:2]!=['4','2'] or template[4]!='1' or int(template[2])>int(db('SELECT level FROM tw_char.characters WHERE guid=4509;')):raise RuntimeError('Require authentic eligible neck item with equip spell')
spell=int(template[3]);profile=json.loads((ROOT/'docs/evidence/data/aura-profile/profile.json').read_text())
if spell not in [r['spell'] for r in profile['definitions']]:raise RuntimeError('Source equip aura not in reviewed profile')
def items():
v=c.rpc('inspect-engine-pipe')
if v['error'] or v['closed'] or v['inventory'].get('truncated'):raise RuntimeError('Native inventory unavailable')
return [r for r in v['inventory']['rows'] if r['entry']==a.item]
neck=lambda:db('SELECT item FROM tw_char.character_inventory WHERE guid=4509 AND bag=0 AND slot=1;')
state=lambda:db('SELECT health,power2,money,extra_flags FROM tw_char.characters WHERE guid=4509;')
if items() or neck():raise RuntimeError('Preserve existing owned item/neck equipment; no input')
r=dict(pid=c.pid,item=a.item,spell=spell,source_item=template,external_gateway_running=False,cleanup_pending=False,source_equipment_verified=False,source_equipped_aura_verified=False,model_effect_verified=False,ui_review_required=True,keep_equipped=a.keep_equipped)
def save():out.write_text(json.dumps(r,indent=2)+'\n');out.chmod(0o600)
old=ui.KEY_DELAY
with Session(c.pid) as s,WorldTrace(c) as trace:
try:
s.wait_world();ui.KEY_DELAY=.06;ui.key(s.d,'F1');s.macro('/s .save');before=state();baseline=inventory(4509);flags=int(before.split('\t')[3])
if flags&17!=17:raise RuntimeError('Require original GM-on/invisible baseline')
r.update(before_state=before,before_inventory=baseline,cleanup_pending=True);save()
s.macro('/s .gm visible on');c.wait(lambda:int(state().split('\t')[3])==flags&~16,8);s.shot(out.with_name(out.stem+'-before.png'))
s.macro(f'/s .additem {a.item} 1');c.wait(lambda:len(items())==1,8);s.macro('/s .save')
row=db(f'SELECT ci.bag,ci.slot,ci.item FROM tw_char.character_inventory ci JOIN tw_char.item_instance ii ON ii.guid=ci.item WHERE ci.guid=4509 AND ii.itemEntry={a.item};').split('\t')
if len(row)!=3 or row[0]!='0' or not 23<=int(row[1])<39:raise RuntimeError('Require one fixture in actual backpack')
root=int(row[1]);guid=row[2];r.update(fixture_guid=guid,fixture_root=root);save()
s.macro('/use 0 '+str(root-22));s.macro('/s .save');c.wait(lambda:neck()==guid,8)
r['source_equipment_verified']=True
r['source_saved_aura']=db(f'SELECT spell,maxduration,remaintime,effIndexMask FROM tw_char.character_aura WHERE guid=4509 AND spell={spell};')
r['saved_aura_limit']='Player::SaveAura excludes passive spells; no saved row does not establish live absence'
save();s.shot(out.with_name(out.stem+'-equipped.png'))
s.macro('/run local a=C_UnitAuras.GetPlayerAuraBySpellID('+str(spell)+');print("GW equip aura",a and(issecretvalue and issecretvalue(a.spellId)and"restricted"or a.spellId)or"absent")');s.shot(out.with_name(out.stem+'-native-aura.png'))
s.macro('/s .list auras')
s.macro('/run local t={}for i=1,ChatFrame1:GetNumMessages()do local m=ChatFrame1:GetMessageInfo(i)if m and m:find("id: '+str(spell)+' ",1,true)then t[#t+1]=m end end for _,m in ipairs(t)do print("GW source",m)end')
s.shot(out.with_name(out.stem+'-source-live-aura.png'))
except Exception as error:r['failure']=type(error).__name__+': '+str(error)
finally:
try:
if r['cleanup_pending']:
s.wait_world();ui.key(s.d,'F1')
retain=a.keep_equipped and r['source_equipment_verified'] and not r.get('failure')
if neck() and not retain:
if neck()!=r.get('fixture_guid'):raise RuntimeError('Unexpected neck equipment; preserve journal')
# Original player inventory slot2 -> empty actual backpack slot.
s.macro('/run PickupInventoryItem(2);C_Container.PickupContainerItem(0,'+str(r['fixture_root']-22)+')');s.macro('/s .save');c.wait(lambda:not neck(),8)
remaining=items()
if remaining and not retain:
if len(remaining)!=1 or remaining[0]['count']!=1:raise RuntimeError('Unexpected item quantity')
s.macro(f'/s .additem {a.item} -1');c.wait(lambda:not items(),8)
if not retain:s.shot(out.with_name(out.stem+'-removed.png'))
s.macro('/s .gm visible off');s.macro('/s .whispers '+('on' if flags&4 else 'off'));s.macro('/s .save')
if retain:
expected=set(baseline.splitlines())|{'0\t1\t'+r['fixture_guid']+'\t'+str(a.item)+'\t1'}
c.wait(lambda:neck()==r['fixture_guid'] and set(inventory(4509).splitlines())==expected and state().split('\t')[1:]==before.split('\t')[1:],8)
r.update(fixture_retained=True,previous_inventory_preserved=True,after_inventory=inventory(4509))
s.shot(out.with_name(out.stem+'-retained.png'))
else:
c.wait(lambda:state()==before and inventory(4509)==baseline,8)
if db(f'SELECT spell FROM tw_char.character_aura WHERE guid=4509 AND spell={spell};'):raise RuntimeError('Equip effect persisted after unequip; preserve journal')
r['inventory_unchanged']=True
r.update(cleanup_pending=False,after_state=state())
except Exception as error:r['cleanup_error']=type(error).__name__+': '+str(error)
ui.KEY_DELAY=old;r.update(trace.report());save()
print(json.dumps({k:r.get(k) for k in ('pid','item','spell','source_equipment_verified','source_equipped_aura_verified','model_effect_verified','cleanup_pending','inventory_unchanged','fixture_retained','previous_inventory_preserved','failure','cleanup_error')}))
return 0 if r['source_equipment_verified'] and not r['cleanup_pending'] and not r.get('failure') else 2
if __name__=='__main__':raise SystemExit(main())