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

85 lines
3.7 KiB
Python

#!/usr/bin/env python3
"""Real local WowB/Turtle object lifecycle probe; screenshots require visual review.
Requires an already authenticated, in-world WowB.exe and GO-enabled gateway.
Creates only a temporary mailbox through the client's authorized GM command.
No direct database writes, process restarts or credentials are involved.
"""
import argparse
import datetime
import json
import os
from pathlib import Path
import re
import subprocess
import time
from local_tortoise import db
ROOT = Path(__file__).resolve().parents[1]
CREATE = re.compile(r'Decoded Turtle create guid=(\d+) type=5 self=0 fields=\d+')
DESTROY = re.compile(r'Translated Turtle game-object destruction guid=(\d+)')
def ui(action, *args):
subprocess.run(['python3', str(ROOT/'ops/client_ui.py'), action, *args], check=True)
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--deadline', type=int, default=360)
args = parser.parse_args()
if not 30 <= args.deadline <= 600:
parser.error('deadline must be 30..600 seconds')
os.umask(0o077)
stamp = datetime.datetime.now(datetime.timezone.utc).strftime('%Y%m%dT%H%M%SZ')
output = ROOT/'runtime'/('object-lifecycle-'+stamp)
output.mkdir(mode=0o700)
count_sql = 'SELECT COUNT(*) FROM tw_world.gameobject WHERE id=144131;'
before = int(db(count_sql))
with (ROOT/'runtime/relay.log').open() as log:
log.seek(0, 2)
started = time.monotonic()
ui('temporary-mailbox-test')
guid = None
created = None
last_report = started
removed = False
while time.monotonic()-started <= args.deadline:
for line in log:
match = CREATE.search(line)
if match and guid is None:
candidate = int(match[1])
if candidate >> 48 == 0xF110 and (candidate >> 24) & 0xFFFFFF == 144131:
guid = candidate
created = time.monotonic()-started
time.sleep(2) # Allow the real client to finish its birth animation.
ui('shot', '--output', str(output/'created.png'))
print('Observed temporary Turtle mailbox create:', guid, flush=True)
match = DESTROY.search(line)
if match and guid is not None and int(match[1]) == guid:
removed = True
break
if removed:
break
if time.monotonic()-last_report >= 30:
print('Waiting for matching Turtle destruction; elapsed seconds:',
round(time.monotonic()-started), flush=True)
last_report = time.monotonic()
time.sleep(1)
elapsed = time.monotonic()-started
if removed:
time.sleep(2) # Finish the client's despawn fade before capturing evidence.
ui('shot', '--output', str(output/('removed.png' if removed else 'timeout.png')))
after = int(db(count_sql))
result = dict(utc=stamp, legacy_guid=guid, create_seconds=created,
observation_seconds=elapsed, matching_destroy_translated=removed,
persistent_rows_before=before, persistent_rows_after=after,
requested_lifetime_seconds=10,
screenshot_review_required=True,
scope='Actual client command and Turtle create/destroy packets; visual removal requires review')
(output/'result.json').write_text(json.dumps(result, indent=2)+'\n')
print('Local integration evidence:', output, flush=True)
if not removed or before != after:
raise SystemExit('Lifecycle verification failed or persistent row count changed; inspect evidence')
if __name__ == '__main__':
main()