aorecomp

Anarchy Online classic in the browser

git clone https://aorecomp.ubeagle.com/code/aorecomp.git


commit 4bad3548480b5b0bc7f169668ac016951153adc7
parent 9eab7e45061098eb8020a89b28acf81825d3f099
Author: anon <anon@example.com>
Date:   Sat, 17 Oct 2026 00:18:06 +0000

Resume interrupted playfield coverage runs

Diffstat:
Mdocs/playfield-validation.md | 12++++++++++++
Mtools/client/sweep_playfields.py | 77+++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------
2 files changed, 63 insertions(+), 26 deletions(-)

diff --git a/docs/playfield-validation.md b/docs/playfield-validation.md @@ -26,6 +26,18 @@ Preferences and diagnostics are private to the run; large immutable assets are shared. Results remain under `local/playfield-sweep/playfield-sweep-*`. Ctrl-C stops the owned processes and keeps completed results. +Resume a stopped run by passing its directory: + +```sh +python3 tools/client/sweep_playfields.py local/playfield-sweep/playfield-sweep-20261016-165029 +``` + +Resumption requires the same client executable digest and playfield catalog. +It preserves logs and completed results, records the current source state in +`resume-*.json`, and reloads the preceding scene before the next transition. +Each resumed client starts with fresh caches: its PID and `run_started` identify +that boundary. A resumed tour is not one uninterrupted memory-growth test. + `catalog.json` reconciles server entries with actual 14.9.1 database definitions. There are 370 definitions: 363 scenes in the sweep, six dependency/developer entries, and one empty bunker definition (1673). The server catalog also lists diff --git a/tools/client/sweep_playfields.py b/tools/client/sweep_playfields.py @@ -20,8 +20,11 @@ import tools.data.ao_database work = root / 'local/playfield-sweep' work.mkdir(parents=True, exist_ok=True) -output = work / ('playfield-sweep-' + time.strftime('%Y%m%d-%H%M%S')) -output.mkdir() +assert len(sys.argv) <= 2, 'usage: sweep_playfields.py [previous-run-directory]' +resuming = len(sys.argv) == 2 +output = pathlib.Path(sys.argv[1]).resolve() if resuming else work / ('playfield-sweep-' + time.strftime('%Y%m%d-%H%M%S')) +if not resuming: + output.mkdir() # Build only the small test adapter and server; use the existing native game. subprocess.run(['cc', '-shared', '-fPIC', '-O2', str(root / 'tools/client/sweep_capture.c'), @@ -30,25 +33,26 @@ subprocess.run(['go', 'build', '-o', str(work / 'server'), './server'], cwd=root # Share immutable assets while isolating preferences and diagnostic output. assets = output / 'assets' -assets.mkdir() -for source in (root / 'anarchy-assets-14.9.1').iterdir(): - if source.name in ['cd_image', 'fonts']: - (assets / source.name).symlink_to(source) - elif source.is_dir(): - shutil.copytree(source, assets / source.name) - else: - shutil.copy2(source, assets / source.name) active = output / 'active' -active.mkdir() fixture = output / 'server' -(fixture / 'data').mkdir(parents=True) -for name in ['terrain.bin', 'zone_links.yaml', 'npc_spawns.yaml', 'maps']: - (fixture / 'data' / name).symlink_to(root / 'data' / name) -for name in ['runtime', 'client']: - (fixture / name).symlink_to(root / name) -(fixture / 'anarchy-assets-14.9.1').symlink_to(assets) -(fixture / '.runtime-bundle').write_text(hashlib.sha256((root / 'runtime/manifest.json').read_bytes()).hexdigest() + '\n') -(fixture / 'data/users.yaml').write_text('- id: 73\n name: Playfield Sweep\n playfield: 705\n position: [960, 16.5, 510]\n rotation: [0, 0, 0, 1]\n appearance: 789\n monster_data: 0\n level: 1\n') +if not resuming: + assets.mkdir() + for source in (root / 'anarchy-assets-14.9.1').iterdir(): + if source.name in ['cd_image', 'fonts']: + (assets / source.name).symlink_to(source) + elif source.is_dir(): + shutil.copytree(source, assets / source.name) + else: + shutil.copy2(source, assets / source.name) + active.mkdir() + (fixture / 'data').mkdir(parents=True) + for name in ['terrain.bin', 'zone_links.yaml', 'npc_spawns.yaml', 'maps']: + (fixture / 'data' / name).symlink_to(root / 'data' / name) + for name in ['runtime', 'client']: + (fixture / name).symlink_to(root / name) + (fixture / 'anarchy-assets-14.9.1').symlink_to(assets) + (fixture / '.runtime-bundle').write_text(hashlib.sha256((root / 'runtime/manifest.json').read_bytes()).hexdigest() + '\n') + (fixture / 'data/users.yaml').write_text('- id: 73\n name: Playfield Sweep\n playfield: 705\n position: [960, 16.5, 510]\n rotation: [0, 0, 0, 1]\n appearance: 789\n monster_data: 0\n level: 1\n') for port in [7520, 7521, 8082]: with socket.socket() as connection: assert connection.connect_ex(('127.0.0.1', port)) != 0, port @@ -79,7 +83,10 @@ for kind, identity in database.records: row['skip'] = 'not in server catalog; investigate arrival' catalog.append(row) database.close() -(output / 'catalog.json').write_text(json.dumps(catalog, indent=2) + '\n') +if resuming: + assert json.loads((output / 'catalog.json').read_text()) == catalog, 'catalog changed; start a new sweep' +else: + (output / 'catalog.json').write_text(json.dumps(catalog, indent=2) + '\n') priority = [120, 127, 1931, 4107, 152, 124, 641, 706, 4704, 705, 695] zones = sorted([row for row in catalog if 'skip' not in row], key=lambda row: (priority.index(row['id']) if row['id'] in priority else len(priority), row['id'])) with (root / 'src/build/linux/game').open('rb') as executable: @@ -92,11 +99,20 @@ metadata = { 'client': 'native Linux', 'coverage': 'arrival loading and rendered frames; screenshots require visual review', } -(output / 'build.json').write_text(json.dumps(metadata, indent=2) + '\n') +completed = {} +if resuming: + assert json.loads((output / 'build.json').read_text())['executable_sha256'] == executable_hash, 'client changed; start a new sweep' + if (output / 'results.jsonl').exists(): + for line in (output / 'results.jsonl').read_text().splitlines(): + row = json.loads(line) + completed[row['phase'], row['id']] = row + (output / ('resume-' + time.strftime('%Y%m%d-%H%M%S') + '.json')).write_text(json.dumps(metadata, indent=2) + '\n') +else: + (output / 'build.json').write_text(json.dumps(metadata, indent=2) + '\n') print(output, flush=True) client = None client_log = None -process_number = 0 +process_number = max([int(path.stem[7:]) for path in output.glob('client-*.log')], default=0) def request(path, fields=None): @@ -128,7 +144,7 @@ def run_zone(zone, phase): request('/teleport/73', {'playfield': zone['id']}) request('/time', {'hour': 13, 'minute': 30}) started = time.monotonic() - result = {'phase': phase, 'id': zone['id'], 'name': zone['name'], 'started': time.time(), 'status': 'timeout', 'previous_pid': previous_pid} + result = {'phase': phase, 'id': zone['id'], 'name': zone['name'], 'started': time.time(), 'status': 'timeout', 'previous_pid': previous_pid, 'run_started': metadata['started']} if client is None: process_number += 1 client_log = (output / f'client-{process_number}.log').open('w') @@ -195,7 +211,7 @@ def run_zone(zone, phase): # Own all test processes, character data and logs; preserve the user's server state. -with (output / 'server.log').open('w') as server_log: +with (output / 'server.log').open('a') as server_log: inhibitor = subprocess.Popen(['gnome-session-inhibit', '--reason', 'AO playfield coverage', '--inhibit-only'], stdout=server_log, stderr=server_log) server = subprocess.Popen([str(work / 'server'), '-login-port', '7520', '-world-port', '7521', '-http-port', '8082'], cwd=fixture, stdout=server_log, stderr=server_log) try: @@ -207,10 +223,19 @@ with (output / 'server.log').open('w') as server_log: break time.sleep(1) for phase in ['transition', 'cold']: + previous_zone = None for zone in zones: - result = run_zone(zone, phase) + result = completed.get((phase, zone['id'])) + if result is None: + # Restore the preceding scene, but do not claim its old cache history. + if resuming and phase == 'transition' and previous_zone is not None: + run_zone(previous_zone, 'resume-warmup') + resuming = False + result = run_zone(zone, phase) if phase == 'transition' and result['status'] != 'ready-and-rendering': - run_zone(zone, 'cold-repro') + if ('cold-repro', zone['id']) not in completed: + run_zone(zone, 'cold-repro') + previous_zone = zone if result['status'] == 'ready-and-rendering' else None finally: stop_client() server.terminate()