"""Export the observed startup frontier; never equates discovery with runnable code.""" import json import re from pathlib import Path bundle = json.loads(Path('evidence/factorio-functions-final.json').read_text()) record = next(r for r in bundle['records'] if r['operation'] == 'analyze_function' and r['parameters']['procedure'] == '0x100161584') native = record['normalized_result'] callees = [] for callee in native['callees']: symbol = callee['name'] route = 'exclude-optional-steam' if 'Steam' in symbol else 'host-abi-adapter' if symbol.startswith('imp___stubs') else 'pending-lift' callees.append({'address': callee['address'], 'symbol': symbol, 'planned_route': route, 'route_authority': 'analyst planning from symbol identity'}) indirect = [line for line in native['assembly'] if re.search(r': blr\s', line)] result = {'status': 'not-runnable', 'root': native['procedure']['name'], 'root_address': '0x100161584', 'evidence_id': record['evidence_id'], 'observed_direct_callees': len(callees), 'observed_basic_blocks': len(native['basic_blocks']), 'observed_indirect_call_sites': indirect, 'callees': callees, 'limitations': ['This is one observed function frontier, not a transitive closure.', 'Hopper does not expose complete body ranges or all indirect targets.', 'The straight-line lifter cannot yet compile this startup function.', 'Graphical startup includes inlined Steam initialization; changing the factory alone is insufficient.']} out = Path('build/startup'); out.mkdir(parents=True, exist_ok=True) (out / 'frontier.json').write_text(json.dumps(result, indent=2) + '\n') print(json.dumps({key: result[key] for key in ['status', 'root_address', 'evidence_id', 'observed_direct_callees', 'observed_basic_blocks']}, indent=2))