Trace Carl lifecycle and add read-only original state observer

This commit is contained in:
UnixNight committed 2026-11-06 10:27:10 -05:00
1 parent c642b69849
commit 4cd62d3627
28 files changed
+2387 -5

No files matched your search

+17 -3
View File
@@ -7,6 +7,7 @@ writable inside the namespace, and the original directory is not mounted.
"""
import argparse
import ctypes
import hashlib
import json
import os
from pathlib import Path
@@ -41,12 +42,14 @@ def inside(args):
if args.port_smoke: (work/'port-frame.ppm').unlink(missing_ok=True)
with (work/'xvfb.log').open('w') as xlog, (work/'wine.log').open('w') as wlog:
display = subprocess.Popen(['/native/usr/bin/Xvfb', ':89', '-screen', '0', '1024x768x24', '-nolisten', 'tcp'], stdout=xlog, stderr=xlog)
wine = None
wine = manager = None
try:
for _ in range(30):
if Path('/tmp/.X11-unix/X89').exists(): break
if display.poll() is not None: raise RuntimeError('Xvfb failed; see xvfb.log')
time.sleep(0.1)
if args.managed_desktop:
manager = subprocess.Popen(['dbus-run-session', '--', 'xfwm4', '--compositor=off'], stdout=xlog, stderr=xlog)
wine_env = dict(os.environ, LIBGL_DRIVERS_PATH='/native/usr/lib/i386-linux-gnu/dri')
application = ['/opt/wine-stable/bin/wine', args.game]
if args.port_smoke:
@@ -79,7 +82,7 @@ def inside(args):
'--assets', r'Z:\port\assets', '--cutscene-audio-smoke',
r'Z:\port\scenes\level1b\entities\entities.json']
if args.asset_probe:
application = ['/opt/wine-stable/bin/wine', r'Z:\probe.exe', args.probe_model]
application = ['/opt/wine-stable/bin/wine', r'Z:\probe.exe', args.probe_model, *args.probe_arg]
wine = subprocess.Popen(application, cwd='/work' if args.port_smoke else '/work/game', stdout=wlog, stderr=wlog, env=wine_env)
captures = []
for index in range(3):
@@ -102,6 +105,7 @@ def inside(args):
finally:
subprocess.run(['/opt/wine-stable/bin/wineserver', '-k'], timeout=10, check=False)
if wine and wine.poll() is None: wine.terminate()
if manager and manager.poll() is None: manager.terminate()
display.terminate()
display.wait(timeout=5)
@@ -113,6 +117,7 @@ def main():
p.add_argument('--seconds', type=int, default=24)
p.add_argument('--enter', action='store_true', help='Send Return after each screenshot')
p.add_argument('--debug', action='store_true', help='Record Wine process and exception diagnostics')
p.add_argument('--managed-desktop', action='store_true', help='Run an isolated xfwm4 desktop for original focus/fullscreen diagnostics')
p.add_argument('--wine-renderer', choices=['gl','vulkan'], default='gl')
p.add_argument('--port-smoke', action='store_true', help='Preliminary Windows port check under Wine64; not native Windows validation')
p.add_argument('--port-window', action='store_true', help='Windows port SDL window/input/resize/animation smoke under Wine64')
@@ -124,6 +129,7 @@ def main():
p.add_argument('--port-regression', choices=['objectives', 'carl'], help='Windows lab popup or conversation runtime regression under Wine64')
p.add_argument('--asset-probe', action='store_true', help='Run compiled read-only OMT shape probe inside isolated copy')
p.add_argument('--probe-model', default=r'ASE\jimstop.ase')
p.add_argument('--probe-arg', action='append', default=[], help='Additional explicit argument for the generated component probe (repeatable)')
p.add_argument('--probe-executable', type=Path, help='Local probe executable to mount read-only for --asset-probe')
p.add_argument('--probe-success', default='VERTICES ', help='Required output marker for an isolated component probe')
p.add_argument('--output', type=Path)
@@ -136,6 +142,7 @@ def main():
if args.port_cutscene_audio and (args.port_practice or args.port_story or args.port_walk or args.port_window or args.port_jetpack): p.error('Select audio lifecycle or rendering check')
if args.port_jetpack and (args.port_practice or args.port_story or args.port_walk or args.port_window): p.error('Select one jetpack or other port check')
if args.probe_executable and not args.asset_probe: p.error('--probe-executable requires --asset-probe')
if args.probe_arg and not args.asset_probe: p.error('--probe-arg requires --asset-probe')
if not 3 <= args.seconds <= 120: p.error('--seconds must be 3..120')
if args.inside: return inside(args)
project = Path(__file__).resolve().parents[2]
@@ -163,6 +170,9 @@ def main():
if args.asset_probe:
probe = (args.probe_executable or project/'artifacts/binary/omt_shape_probe.exe').resolve(strict=True)
if probe.is_relative_to(source.resolve()): p.error('Probe must be a generated executable outside originals')
probe_identity = {'path': str(probe), 'sha256': hashlib.sha256(probe.read_bytes()).hexdigest(),
'arguments': [args.probe_model, *args.probe_arg]}
(work/'probe-identity.json').write_text(json.dumps(probe_identity, indent=2)+'\n')
cmd += ['--ro-bind', str(probe), '/probe.exe']
for key,value in {'HOME':'/work/home', 'WINEPREFIX':'/work/prefix', 'WINEARCH':'win64' if args.port_smoke else 'win32',
'DISPLAY':':89', 'PATH':'/opt/wine-stable/bin:/usr/bin:/bin', 'LANG':'C.UTF-8',
@@ -180,6 +190,7 @@ def main():
cmd += ['--setenv', 'VK_DRIVER_FILES', '/native/usr/share/vulkan/icd.d/lvp_icd.json']
cmd += ['/usr/bin/python3', '/capture.py', '--inside', '--game', args.game, '--seconds', str(args.seconds)]
if args.enter: cmd += ['--enter']
if args.managed_desktop: cmd += ['--managed-desktop']
if args.port_smoke: cmd += ['--port-smoke']
if args.port_window: cmd += ['--port-window']
if args.port_walk: cmd += ['--port-walk']
@@ -188,7 +199,8 @@ def main():
if args.port_cutscene_audio: cmd += ['--port-cutscene-audio']
if args.port_jetpack: cmd += ['--port-jetpack']
if args.port_regression: cmd += ['--port-regression', args.port_regression]
if args.asset_probe: cmd += ['--asset-probe', '--probe-model', args.probe_model]
if args.asset_probe: cmd += ['--asset-probe', '--probe-model='+args.probe_model]
for argument in args.probe_arg: cmd += ['--probe-arg='+argument]
print('Running isolated Windows port' if args.port_smoke else 'Running copied original', 'with no network and no original-directory mount:', work, flush=True)
subprocess.run(cmd, check=True, timeout=args.seconds + 40)
print('Capture metadata:', work/'capture.json')
@@ -201,6 +213,8 @@ def main():
print('Windows port audio lifecycle passed under Wine; native Windows validation is still required' if args.port_cutscene_audio
else 'Windows port rendered under Wine; native Windows validation is still required')
if args.asset_probe:
if hashlib.sha256(probe.read_bytes()).hexdigest() != probe_identity['sha256']:
raise SystemExit('Probe executable changed during capture; observation identity is invalid')
result = json.loads((work/'capture.json').read_text())
if result['captures'][-1]['wineExit'] != 0 or args.probe_success not in (work/'wine.log').read_text():
raise SystemExit('Original component probe did not complete; inspect wine.log')