367 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
113 lines
6.9 KiB
Python
113 lines
6.9 KiB
Python
#!/usr/bin/env python3
|
|
"""Request actual Forever world entry through its existing character UI.
|
|
|
|
Requires an already authenticated native character screen, stopped gateway and
|
|
an explicitly selected disposable character. Never injects a login packet or
|
|
modifies positions/progression. The native owned-roster validator handles GUIDs.
|
|
"""
|
|
import argparse,json,time
|
|
from pathlib import Path
|
|
from native_engine_character_test import ROOT,Controller,local_listeners
|
|
from client_session import Session
|
|
import client_ui as ui
|
|
from native_test_guard import require_authenticated_turtle_realm,require_local_turtle_ports,require_native_gameplay_policy
|
|
from native_test_guard import require_native_world_observation
|
|
from native_world_trace import WorldTrace
|
|
|
|
|
|
def observe_world(controller,session,timeout):
|
|
"""Retain a native fatal/modal observation without sending further input."""
|
|
deadline=time.monotonic()+timeout;state='loading-or-unknown'
|
|
while time.monotonic()<deadline:
|
|
pipe=controller.rpc('inspect-engine-pipe')
|
|
if pipe['error']:break
|
|
if pipe.get('world', {}).get('self_create') == 1:
|
|
engine = controller.rpc('inspect-engine-session')
|
|
try:
|
|
require_native_world_observation(pipe, engine, 'loading-or-unknown')
|
|
except RuntimeError:
|
|
pass
|
|
else:
|
|
return 'world', None
|
|
try:state=session.state()
|
|
except ui.ClientWindowBlocked as error:
|
|
return 'blocked-'+error.kind,dict(kind=error.kind,message=str(error),further_input_sent=False)
|
|
if state=='world':break
|
|
time.sleep(.1)
|
|
return state,None
|
|
|
|
|
|
def enable_gameplay(controller, timeout=8):
|
|
"""Arm the existing verified route once, then await its real safepoint.
|
|
|
|
This is explicit because read-only world-entry tests may leave gameplay
|
|
disabled. Input tests must never mistake that state for an enabled session.
|
|
"""
|
|
if type(timeout)not in(int,float)or not 1<=timeout<=120:raise ValueError('Gameplay readiness bound1..120seconds')
|
|
before=controller.rpc('inspect-native-channel-policy')
|
|
if before.get('error')!=0:raise RuntimeError('Existing native channel policy failed; preserve session')
|
|
armed=before.get('enabled')is not True
|
|
if armed:controller.rpc('request-native-channel-policy')
|
|
def ready():
|
|
policy=controller.rpc('inspect-native-channel-policy')
|
|
if policy.get('error')!=0:raise RuntimeError('Native channel policy failed while becoming ready')
|
|
return policy if policy.get('enabled')is True and policy.get('owner_matches')is True else None
|
|
after=controller.wait(ready,timeout)
|
|
require_native_gameplay_policy(after)
|
|
return dict(armed_once=armed,policy=after)
|
|
|
|
|
|
def main():
|
|
parser=argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument('--timeout',type=float,default=20)
|
|
parser.add_argument('--enable-gameplay',action='store_true',help='After verified world entry, enable and await the existing native outgoing channel policy; no new engine patch')
|
|
parser.add_argument('--evidence',type=Path,default=ROOT/'runtime/native-world-entry.json')
|
|
args=parser.parse_args();path=args.evidence.resolve()
|
|
if not 1<=args.timeout<=120 or not path.is_relative_to(ROOT/'runtime'):parser.error('Bound timeout1..120 and keep raw evidence in runtime')
|
|
require_local_turtle_ports(local_listeners())
|
|
pid=int((ROOT/'runtime/native-client.pid').read_text());controller=Controller(pid)
|
|
with Session(pid) as session:
|
|
if session.state()!='characters':raise RuntimeError('Require actual character selection and prior verification of disposable selection')
|
|
require_authenticated_turtle_realm(controller.rpc('inspect-wire-account'))
|
|
# Observe before the original UI action so startup packets are not
|
|
# reduced to the engine ring's final32 rows. Gaps remain explicit.
|
|
# Entity-field counters restart for each genuine selected world. This
|
|
# character-screen boundary records transport metadata only, rather
|
|
# than splicing old/new self fields. In-world tests start fresh traces.
|
|
with WorldTrace(controller,collect_fields=False) as trace:
|
|
# Original CharacterSelectFrameMixin.OnKeyDown maps ENTER to the same
|
|
# guarded action as the button, without long relative-pointer travel.
|
|
started=time.monotonic();ui.key(session.d,'Return')
|
|
state,blocked=observe_world(controller,session,args.timeout)
|
|
# Keep the actual readiness observation that ended the loop. A
|
|
# redundant OCR read here could replace verified world readiness
|
|
# with an unknown frame while the screenshot still shows the world.
|
|
if state!='login' and blocked is None:
|
|
try:session.shot(path.with_suffix('.png'))
|
|
except ui.ClientWindowBlocked as error:
|
|
state='blocked-'+error.kind
|
|
blocked=dict(kind=error.kind,message=str(error),further_input_sent=False)
|
|
pipe=controller.rpc('inspect-engine-pipe');world=pipe['world']
|
|
observation=trace.report()
|
|
complete=bool(state=='world' and not pipe['error'] and not pipe['closed'] and pipe['world_auth'] and world['login_sent']==1 and world['self_create'])
|
|
gameplay=None;gameplay_failure=None
|
|
if complete and args.enable_gameplay:
|
|
try:gameplay=enable_gameplay(controller)
|
|
except RuntimeError as error:gameplay_failure=str(error)
|
|
if gameplay is not None:
|
|
pipe=controller.rpc('inspect-engine-pipe');world=pipe['world']
|
|
complete=bool(complete and not pipe['error']and not pipe['closed']and pipe['world_auth'])
|
|
report=dict(pid=pid,ui=state,pipe=pipe,engine=controller.rpc('inspect-engine-session'),account=controller.rpc('inspect-wire-account'),
|
|
elapsed_seconds=round(time.monotonic()-started,3),external_gateway_running=False,native_world_entry_verified=complete,
|
|
native_player_movement_verified=False,native_npc_population_verified=False,character_or_database_modified=False,
|
|
native_gameplay_policy=gameplay,
|
|
gameplay_readiness_failure=gameplay_failure,
|
|
blocked_window=blocked,
|
|
packet_observation=observation)
|
|
path.write_text(json.dumps(report,indent=2)+'\n');path.chmod(0o600)
|
|
summary={k:world.get(k)for k in('login_sent','received','queued','self_create','ignored','realm_context_bound','move_init_active_mover_complete')}
|
|
print(json.dumps(dict(ui=state,adapter_error=pipe['error'],world=summary,native_world_entry_verified=complete,elapsed_seconds=report['elapsed_seconds'],evidence=str(path),
|
|
blocked_window=blocked,gameplay_enabled=gameplay is not None,gameplay_readiness_failure=gameplay_failure,trace_records=len(observation['trace']),trace_lost_metadata_rows=observation['lost_metadata_rows'],trace_observer_error=observation['observer_error'])))
|
|
return 0 if complete and not gameplay_failure else 2
|
|
if __name__=='__main__':raise SystemExit(main())
|