367 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
86 lines
6.0 KiB
Python
86 lines
6.0 KiB
Python
#!/usr/bin/env python3
|
|
"""Bounded native attack/error probe, with legitimate temporary GM-mode control.
|
|
|
|
Not a damage/death acceptance test. Never moves the character or grants items.
|
|
Only the designated disposable4509 character; local Turtle and gateway-off guards.
|
|
Run as the FIRST attack after login: Tortoise intentionally deduplicates identical
|
|
swing errors until the error condition changes (Unit::UpdateMeleeAttackingState).
|
|
"""
|
|
import argparse,json,re
|
|
from pathlib import Path
|
|
from native_world_trace import WorldTrace
|
|
from native_engine_character_test import Controller,ROOT,local_listeners
|
|
from native_test_guard import require_authenticated_turtle_realm,require_local_turtle_ports,require_native_gameplay_policy
|
|
from client_session import Session
|
|
from local_tortoise import db
|
|
import client_ui as ui
|
|
|
|
def state():
|
|
row=db('SELECT guid,level,extra_flags,health,position_x,position_y,position_z FROM tw_char.characters WHERE guid=4509;').split('\t')
|
|
if len(row)!=7 or int(row[0])!=4509:raise RuntimeError('Disposable character state missing')
|
|
return dict(zip(('guid','level','extra_flags','health','x','y','z'),[int(v) if i<4 else float(v) for i,v in enumerate(row)]))
|
|
|
|
def main():
|
|
p=argparse.ArgumentParser(description=__doc__);p.add_argument('--allow-temporary-gm-off',action='store_true');p.add_argument('--target',default='Young Wolf');p.add_argument('--output',type=Path,required=True);a=p.parse_args()
|
|
output=a.output.resolve()
|
|
if not output.is_relative_to(ROOT/'runtime') or not output.parent.is_dir() or output.exists() or not re.fullmatch('[A-Za-z ]{1,60}',a.target):p.error('Require new runtime evidence path and bounded plain creature name')
|
|
baseline=state();toggled=bool(baseline['extra_flags']&1)
|
|
if toggled and not a.allow_temporary_gm_off:p.error('GM baseline requires explicit controlled-test flag')
|
|
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'))
|
|
trace=WorldTrace(c);trace.__enter__()
|
|
def mark():
|
|
return trace.bookmark()
|
|
def observed(after,opcodes,direction):
|
|
if trace.error:raise RuntimeError(trace.error)
|
|
with trace.lock:return any(t['index']>after and t['direction']==direction and t['opcode'] in opcodes for t in trace.records)
|
|
report={'pid':c.pid,'baseline':baseline,'target':a.target,'external_gateway_running':False,'gm_temporarily_changed':toggled,'restored':False};failure=None
|
|
old=ui.KEY_DELAY;ui.KEY_DELAY=.03
|
|
try:
|
|
with Session(c.pid) as s:
|
|
if s.state()!='world':raise RuntimeError('Require existing world session')
|
|
s.macro('/run GWCombatErrorProbe=CreateFrame("Frame");GWCombatErrorProbe:RegisterEvent("UI_ERROR_MESSAGE");GWCombatErrorProbe:SetScript("OnEvent",function(_,_,id,text)print("GW combat error",id,text)end)')
|
|
s.macro('/targetexact '+a.target)
|
|
s.macro('/stopattack')
|
|
if toggled:s.macro('/s .gm off')
|
|
anchor=mark();s.macro('/startattack')
|
|
c.wait(lambda:observed(anchor,{0x145,0x146},1),5)
|
|
c.wait(lambda:observed(anchor,{0x4d0026},3),3)
|
|
report['normal_server_combat_response']=observed(anchor,{0x143},1)
|
|
if not report['normal_server_combat_response']:raise RuntimeError('Server attack-start missing from observed critical chain')
|
|
report['server_range_or_facing_error_queued']=True
|
|
s.shot(output.with_suffix('.png'))
|
|
if toggled:
|
|
s.macro('/stopattack');s.macro('/s .gm on')
|
|
anchor=mark();s.macro('/startattack')
|
|
c.wait(lambda:observed(anchor,{0x143},1),3)
|
|
report['gm_server_attack_accepted']=True
|
|
except Exception as e:failure=type(e).__name__+': '+str(e)
|
|
finally:
|
|
# Restore through real client commands, even when the expectation fails.
|
|
# Focus errors are not bypassed; explicit unrestored report is preserved.
|
|
try:
|
|
with Session(c.pid) as s:
|
|
if s.state()!='world':raise RuntimeError('World lost before restoration')
|
|
s.macro('/stopattack')
|
|
if toggled:s.macro('/s .gm on')
|
|
s.macro('/run if GWCombatErrorProbe then GWCombatErrorProbe:UnregisterAllEvents();GWCombatErrorProbe:SetScript("OnEvent",nil);GWCombatErrorProbe=nil end')
|
|
s.macro('/s .save')
|
|
after=c.wait(lambda:(r if (r:=state())['extra_flags']==baseline['extra_flags'] else False),8)
|
|
report['after']=after;report['restored']=after==baseline
|
|
if not report['restored']:raise RuntimeError('Fixture differs from recorded baseline; no blind state overwrite')
|
|
except Exception as e:report['restoration_error']=type(e).__name__+': '+str(e)
|
|
ui.KEY_DELAY=old;trace.__exit__(None,None,None)
|
|
report.update(trace.report())
|
|
try:pipe=c.rpc('inspect-engine-pipe')
|
|
except Exception as e:
|
|
pipe={'error':-1,'closed':1};report['pipe_inspection_error']=type(e).__name__+': '+str(e)
|
|
report.update(pipe_error=pipe['error'],pipe_closed=pipe['closed'],ui_presentation_requires_review=True)
|
|
if failure:report['failure']=failure
|
|
output.write_text(json.dumps(report,indent=2)+'\n');output.chmod(0o600)
|
|
wanted={0x141,0x142,0x143,0x144,0x145,0x146,0x148,0x149,0x14a,0x3e011e,0x3e011f,0x4d0017,0x4d0018,0x4d0026,0x4d002c}
|
|
print(json.dumps({k:report.get(k) for k in ('pid','gm_server_attack_accepted','normal_server_combat_response','server_range_or_facing_error_queued','restored','pipe_error','pipe_closed','lost_metadata_rows','observer_error','ui_presentation_requires_review','failure','restoration_error')}))
|
|
print('Public combat trace:',json.dumps([t for t in report['trace'] if t['opcode'] in wanted]))
|
|
return 0 if report['restored'] and not failure and not trace.error and not trace.lost and not pipe['error'] and not pipe['closed'] else 2
|
|
if __name__=='__main__':raise SystemExit(main())
|