Files
WoW-Hybrid-gateway/ops/native_constant_aura_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

135 lines
8.1 KiB
Python

#!/usr/bin/env python3
"""Observe a genuine known constant self-aura through the actual local client.
No spell grant, forced aura, synthetic packet or stat API replacement. A normal
server save supplies diagnostic evidence only; runtime compatibility never reads
the database. Partial results and trace losses remain explicit in the journal.
"""
import argparse
import json
import secrets
import struct
import time
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_talent_apply_test import persisted
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
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--spell', type=int, required=True)
parser.add_argument('--output', type=lambda p: (ROOT / p).resolve(), required=True)
args = parser.parse_args()
out = args.output
if (not 0 < args.spell < 65536 or not out.is_relative_to(ROOT / 'runtime')
or out.suffix != '.json' or out.exists() or not out.parent.is_dir()):
parser.error('Require a bounded source spell and new runtime journal')
require_local_turtle_ports(local_listeners())
require_solo_test_character(4509, db('SELECT guid FROM tw_char.characters WHERE online<>0 ORDER BY guid;'))
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'))
# This acceptance scenario covers the reviewed detection/crit self-aura
# family. Other cast/target/resource semantics require their own scenario.
source = db(f'SELECT name,durationIndex,recoveryTime,effect1,effect2,effect3,'
f'effectApplyAuraName1,effectApplyAuraName2,effectApplyAuraName3,'
f'effectBasePoints2,effectBaseDice2 FROM tw_world.spell_template WHERE entry={args.spell};').split('\t')
if (len(source) != 11 or source[1:9] != ['18','180000','6','6','6','17','52','57']
or not source[0].isascii() or not all(ch.isalpha() or ch == ' ' for ch in source[0])):
raise RuntimeError('Require reviewed source constant self-aura family')
run = secrets.token_hex(4)
report = dict(pid=c.pid, spell=args.spell, run=run, character=4509,
external_gateway_running=False, verified=False, cast_verified=False,
source_definition=source, source_mask_not_inferred=True)
def save():
out.write_text(json.dumps(report, indent=2) + '\n'); out.chmod(0o600)
def inspect():
return c.rpc('inspect-engine-pipe', unit_fields_only=True)
save()
old = ui.KEY_DELAY
with WorldTrace(c) as trace:
try:
with Session(c.pid) as s:
s.wait_world(); ui.KEY_DELAY = .03
# Provider is server-acknowledged, not the client definition or
# character_spell table (which omits default dependent spells).
state = persisted(s).get('turtleLastAcknowledgedState', {})
if (state.get('guid') != 4509 or not state.get('known', {}).get(args.spell,
state.get('known', {}).get(str(args.spell)))):
raise RuntimeError('Require genuine server-acknowledged known spell')
if db(f'SELECT spell FROM tw_char.character_spell_cooldown WHERE guid=4509 AND spell={args.spell} AND time>UNIX_TIMESTAMP();'):
raise RuntimeError('Genuine source cooldown active; no reset or retry')
s.macro(f'/gwdiag aura-test {args.spell} {run} before')
before = inspect()['cast_result']['count']
bookmark = trace.bookmark(); started = time.monotonic()
s.macro('/cast ' + source[0])
def cast_finished():
result = inspect()['cast_result']
if result['count'] <= before or result['spell'] != args.spell:
return False
if result['status'] != 0:
report['cast_result'] = result
raise RuntimeError('Genuine spell cast rejected; no replay')
return result
report['cast_result'] = c.wait(cast_finished, 8)
report['cast_verified'] = True
s.macro(f'/gwdiag aura-test {args.spell} {run} active')
s.macro('/s .save')
report['saved_active_aura'] = db(f'SELECT spell,maxduration,remaintime,effIndexMask FROM tw_char.character_aura WHERE guid=4509 AND spell={args.spell};')
report['saved_cooldown'] = db(f'SELECT spell,CAST(time AS SIGNED)-UNIX_TIMESTAMP() FROM tw_char.character_spell_cooldown WHERE guid=4509 AND spell={args.spell};')
s.shot(out.with_name(out.stem + '-active.png')); save()
# Source duration index18 is the reviewed20s interval. Wait for
# that genuine duration, not a local cancel or forced removal.
until = started + 22
while time.monotonic() < until:
if inspect()['closed']:
raise RuntimeError('Native world disconnected during effect')
time.sleep(min(.2, max(0, until-time.monotonic())))
s.macro(f'/gwdiag aura-test {args.spell} {run} expired')
data = persisted(s).get('nativeAuraAcceptance')
report['client_samples'] = data
if not data or data.get('run') != run:
raise RuntimeError('Fresh original API samples unavailable')
phases = {row['phase']: row for row in data['samples']}
if set(phases) != {'before','active','expired'}:
raise RuntimeError('Require all three actual-client samples')
b, a, e = (phases[k] for k in ('before','active','expired'))
amount = int(source[9]) + int(source[10])
report['melee_crit_delta_verified'] = bool(all(x.get('meleeCritStatus') == 'ok' for x in (b,a,e))
and abs(a['meleeCrit']-b['meleeCrit']-amount)<.001
and abs(e['meleeCrit']-b['meleeCrit'])<.001)
report['spell_crit_delta_verified'] = bool(all(x.get('spellCritStatus') == 'ok' for x in (b,a,e))
and abs(a['spellCrit']-b['spellCrit']-amount)<.001
and abs(e['spellCrit']-b['spellCrit'])<.001)
report['cooldown_verified'] = bool(a.get('cooldownStatus') == 'ok'
and abs(a['cooldown'].get('duration',0)-180)<.01)
report['aura_ui_verified'] = bool(a.get('auraStatus') == 'ok'
and a.get('aura',{}).get('duration') == 20 and e.get('auraStatus') == 'nil')
from engine_pipe_host import SOURCE_UNIT_FIELDS
report['source_crit_capture_supported'] = 1109 in SOURCE_UNIT_FIELDS
report['source_crit_updates'] = [dict(row, decoded=struct.unpack('<f',struct.pack('<I',row['value']))[0])
for row in trace.report()['source_unit_fields']['rows']
if row.get('legacy_guid') == '4509' and row.get('field') == 1109]
report['action_bookmark'] = bookmark
report['verified'] = bool(report['saved_active_aura'] and report['saved_cooldown']
and all(report[k] for k in ('melee_crit_delta_verified','spell_crit_delta_verified','cooldown_verified','aura_ui_verified')))
except Exception as error:
report['failure'] = type(error).__name__ + ': ' + str(error)
finally:
ui.KEY_DELAY = old
report.update(trace.report()); save()
print(json.dumps({k:report.get(k) for k in ('spell','cast_verified','verified','melee_crit_delta_verified',
'spell_crit_delta_verified','cooldown_verified','aura_ui_verified','lost_metadata_rows','observer_error','failure')}))
return 0 if report['verified'] and not trace.error else 2
if __name__ == '__main__':
raise SystemExit(main())