import 'dart:ffi'; import 'package:flutter/material.dart'; /// Expected hash for seed 42, recorded on x86_64 host. /// Must match on arm64 (cross-target determinism, ADR 0002). const hostHash = '6237310299140737418'; typedef _SelftestC = Uint64 Function(Uint64); typedef _SelftestDart = int Function(int); typedef _MarkerC = Uint32 Function(); typedef _MarkerDart = int Function(); typedef _VersionC = Uint32 Function(); typedef _VersionDart = int Function(); class Probe { final String status; final String marker; final String version; final String hash; const Probe(this.status, this.marker, this.version, this.hash); static Probe run() { try { final lib = DynamicLibrary.open('libffi.so'); final selftest = lib.lookupFunction<_SelftestC, _SelftestDart>('iron_arc_selftest'); final marker = lib.lookupFunction<_MarkerC, _MarkerDart>('iron_arc_abi_marker'); final version = lib.lookupFunction<_VersionC, _VersionDart>( 'iron_arc_sim_version_code'); return Probe( 'RUST OK', marker().toRadixString(16).padLeft(8, '0'), (version() / 100).toStringAsFixed(2), BigInt.from(selftest(42)).toUnsigned(64).toString(), ); } catch (e) { return Probe('RUST FAIL', '-', '-', '$e'); } } } void main() => runApp(const IronArcApp()); class IronArcApp extends StatelessWidget { const IronArcApp({super.key}); @override Widget build(BuildContext context) { final probe = Probe.run(); final matches = probe.hash == hostHash; return MaterialApp( debugShowCheckedModeBanner: false, theme: ThemeData.dark(useMaterial3: true), home: Scaffold( backgroundColor: const Color(0xFF101418), body: SafeArea( child: Padding( padding: const EdgeInsets.all(24), child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.center, children: [ const Text('IRON ARC', style: TextStyle( fontSize: 34, fontWeight: FontWeight.w800, letterSpacing: 4)), const SizedBox(height: 4), const Text('M0 pipeline probe', style: TextStyle(color: Colors.white54)), const SizedBox(height: 32), _Row('FFI status', probe.status), _Row('ABI marker', probe.marker), _Row('sim version', probe.version), _Row('device hash', probe.hash), _Row('host hash', hostHash), const SizedBox(height: 24), Container( padding: const EdgeInsets.symmetric( horizontal: 16, vertical: 10), decoration: BoxDecoration( color: matches ? Colors.green.shade900 : Colors.red.shade900, borderRadius: BorderRadius.circular(8), ), child: Text( matches ? 'DETERMINISM PASS (arm64 == x86_64)' : 'DETERMINISM MISMATCH', style: const TextStyle(fontWeight: FontWeight.bold), ), ), ], ), ), ), ), ); } } class _Row extends StatelessWidget { const _Row(this.label, this.value); final String label; final String value; @override Widget build(BuildContext context) { return Padding( padding: const EdgeInsets.symmetric(vertical: 6), child: Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ SizedBox( width: 120, child: Text(label, style: const TextStyle(color: Colors.white60, fontSize: 13))), Expanded( child: Text(value, style: const TextStyle(fontFamily: 'monospace', fontSize: 13)), ), ], ), ); } }