367 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
111 lines
7.1 KiB
Python
111 lines
7.1 KiB
Python
#!/usr/bin/env python3
|
|
"""Capture one real local release lifecycle, leaving the original UI intact.
|
|
|
|
The existing authorized GM fixture supplies one controlled death only. Release
|
|
uses the original button. This phase records adapter witnesses, not a claim that
|
|
the original resurrection popup works. Inspect its screenshot, then reclaim
|
|
through the original UI/API and persist the diagnostic table. No forced events.
|
|
"""
|
|
import argparse
|
|
import json
|
|
from pathlib import Path
|
|
import subprocess
|
|
import sys
|
|
|
|
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_authenticated_turtle_realm,
|
|
require_local_turtle_ports, require_native_gameplay_policy, require_solo_test_character)
|
|
from native_world_trace import WorldTrace
|
|
|
|
STAGES={'source_player_state','original_release_serialized','source_corpse_reply',
|
|
'source_owned_transfer','graveyard_cleared','graveyard_published'}
|
|
KEYS={'sequence','source_packet','stage','health_known','health','ghost',
|
|
'request_sent','corpse_valid','transfer_seen'}
|
|
|
|
|
|
def lifecycle_rows(path,offset):
|
|
"""Export only our fixed scalar diagnostic, never arbitrary client output."""
|
|
if path.stat().st_size<offset:raise RuntimeError('Diagnostic log rotated; preserve test')
|
|
with path.open('rb')as f:
|
|
f.seek(offset);data=f.read(1048576)
|
|
if len(data)==1048576:raise RuntimeError('Bounded diagnostic log slice exceeded')
|
|
rows=[]
|
|
for line in data.splitlines(keepends=True):
|
|
if not line.startswith(b'GWCorpse ')or not line.endswith(b'\n'):continue
|
|
row=json.loads(line[len(b'GWCorpse '):])
|
|
if set(row)!=KEYS or row['stage']not in STAGES:raise RuntimeError('Corpse diagnostic schema changed')
|
|
if any(type(row[k])is not bool for k in ('health_known','request_sent','corpse_valid','transfer_seen')):
|
|
raise RuntimeError('Corpse diagnostic boolean schema changed')
|
|
if any(type(row[k])is not int or not 0<=row[k]<2**32 for k in ('sequence','source_packet','health'))or row['ghost']not in(-1,0,1):
|
|
raise RuntimeError('Corpse diagnostic scalar bounds changed')
|
|
rows.append(row)
|
|
if len(rows)>64:raise RuntimeError('Corpse diagnostic row bound')
|
|
return rows
|
|
|
|
|
|
def main():
|
|
parser=argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument('--evidence',type=Path,required=True)
|
|
parser.add_argument('--fixture',type=Path,default=ROOT/'build/native-recovery-source-20261019/build/local-fixture-recovery')
|
|
parser.add_argument('--allow-archived-praxiscopy-4518-fixture',action='store_true',
|
|
help='Explicit developer-only opt-in for the archived fixed4518 fixture; never current user characters')
|
|
args=parser.parse_args()
|
|
if not args.allow_archived_praxiscopy_4518_fixture:
|
|
parser.error('Archived mutation fixture disabled; require --allow-archived-praxiscopy-4518-fixture and the exact historical actor guards')
|
|
out=args.evidence.resolve()
|
|
if not out.is_relative_to(ROOT/'runtime')or out.exists():parser.error('Require new runtime evidence')
|
|
require_local_turtle_ports(local_listeners())
|
|
require_solo_test_character(4518,db('SELECT guid FROM tw_char.characters WHERE online<>0;'))
|
|
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'))
|
|
log=ROOT/'runtime/engine-session-client.log';offset=log.stat().st_size
|
|
r=dict(pid=c.pid,character=4518,external_gateway_running=False,engine_popup_verified=False,
|
|
recovery_pending=False,log_offset=offset)
|
|
trace=WorldTrace(c);old=ui.KEY_DELAY
|
|
try:
|
|
with trace:
|
|
with Session(c.pid)as s:
|
|
s.wait_world(5);ui.KEY_DELAY=.02
|
|
for command in (
|
|
'/run GatewayDiagnosticsSaved.deathReleaseLoc={run="bounded-release-log",events={}};GWD=GatewayDiagnosticsSaved.deathReleaseLoc',
|
|
'/run GWDF=CreateFrame("Frame");for _,e in ipairs({"PLAYER_DEAD","PLAYER_ALIVE","PLAYER_UNGHOST","CORPSE_IN_RANGE","CORPSE_OUT_OF_RANGE"}) do GWDF:RegisterEvent(e) end',
|
|
'/run GWDF:SetScript("OnEvent",function(_,e) if #GWD.events<64 then GWD.events[#GWD.events+1]={event=e,time=GetTime()} end end)'):
|
|
s.macro(command)
|
|
fixture=out.with_name(out.stem+'-fixture.json')
|
|
child=subprocess.run([sys.executable,str(ROOT/'ops/local_fixture_recovery.py'),
|
|
'--action','die','--executable',str(args.fixture),'--evidence',str(fixture),
|
|
'--allow-archived-praxiscopy-4518-fixture'],
|
|
capture_output=True,timeout=65)
|
|
r['fixture_returncode']=child.returncode;r['recovery_pending']=True
|
|
if child.returncode:raise RuntimeError('Fixture stopped; no death/release command replay')
|
|
rows=trace.report().get('source_unit_fields',{}).get('rows',[])
|
|
health=[v for v in rows if v.get('legacy_guid')=='4518'and v.get('field')==22]
|
|
if not health or health[-1]['value']!=0:raise RuntimeError('Require actual source HP0 before original release click')
|
|
g=s.win.get_geometry()
|
|
if g.width*9!=g.height*16:raise RuntimeError('Unverified original dialog aspect')
|
|
anchor=trace.bookmark();ui.click_at(s.d,s.win,round(960*g.width/2048),round(174*g.height/1152))
|
|
r['release_request']=trace.wait(2,0x3f00cb,3,after_index=anchor)
|
|
try:c.wait(lambda:any(v['stage']=='source_owned_transfer'for v in lifecycle_rows(log,offset)),10)
|
|
except RuntimeError as error:r['transfer_wait_failure']=str(error)
|
|
r['lifecycle']=lifecycle_rows(log,offset)
|
|
r['adapter_graveyard_published']=any(v['stage']=='graveyard_published'for v in r['lifecycle'])
|
|
s.macro('/run GWD.released={ghost=UnitIsGhost("player"),popup=not not StaticPopup_FindVisible("RECOVER_CORPSE"),delay=GetCorpseRecoveryDelay(),position={UnitPosition("player")}}')
|
|
s.macro('/run local m=C_Map.GetBestMapForUnit("player");local ok,p=pcall(C_DeathInfo.GetDeathReleasePosition,m);GWD.graveyard={map=m,ok=ok,found=ok and not not p};if ok and p then GWD.graveyard.x,GWD.graveyard.y=p:GetXY() end')
|
|
s.shot(out.with_suffix('.png'))
|
|
# No /reload: preserve the real popup and original observer for
|
|
# the next original recovery action instead of destroying them.
|
|
except Exception as error:r['failure']=str(error)
|
|
finally:
|
|
ui.KEY_DELAY=old;r.update(trace.report());r['lifecycle']=lifecycle_rows(log,offset)
|
|
r['pipe_error']=c.rpc('inspect-engine-pipe').get('error')
|
|
out.write_text(json.dumps(r,indent=2)+'\n');out.chmod(0o600)
|
|
print(json.dumps({k:r.get(k)for k in ('fixture_returncode','release_request','adapter_graveyard_published','lifecycle','failure','pipe_error')}))
|
|
return 0 if r.get('adapter_graveyard_published')else 2
|
|
|
|
|
|
if __name__=='__main__':raise SystemExit(main())
|