feat(runtime): preserve structured Play v2 diagnostics
Intrepid/Prometeu/Runtime/pipeline/head This commit looks good

Confirm loaded PBX identity, emit bounded fault envelopes and retain the primary crash report through teardown. Start background IO before audio initialization and update native protocol and process fixtures.
This commit is contained in:
2026-11-26 08:55:32 +00:00
parent f480b755ed
commit 7fd6fef1c8
19 changed files with 431 additions and 39 deletions
@@ -7,6 +7,7 @@ license.workspace = true
[dependencies]
serde = { version = "1.0.228", features = ["derive"] }
serde_json = "1.0.149"
sha2 = "0.10.9"
prometeu-vm = { path = "../prometeu-vm" }
prometeu-bytecode = { path = "../prometeu-bytecode" }
prometeu-hal = { path = "../prometeu-hal" }
@@ -11,6 +11,22 @@ pub enum CrashReport {
}
impl CrashReport {
/// Canonical machine facts; presentation and transport envelopes remain host-owned.
pub fn diagnostic(&self) -> serde_json::Value {
use serde_json::json;
let mut result = json!({"kind":self.kind(),"pc":self.pc(),"summary":self.summary()});
match self {
Self::VmTrap { trap } => {
result["trap"] = json!({"code":trap.code,"opcode":trap.opcode,
"message":trap.message,"pc":trap.pc,"span":trap.span,"resource":trap.resource})
}
Self::VmPanic { message, .. } => result["message"] = json!(message),
Self::VmInit { .. } => {
result["initError"] = self.init_diagnostic().expect("initialization report")
}
}
result
}
/// The same machine fields serve headless and desktop transports.
pub fn init_diagnostic(&self) -> Option<serde_json::Value> {
match self {
@@ -425,6 +425,12 @@ impl<'a> VmFacade<'a> {
.unwrap_or(self.os.vm_runtime.current_app_id)
}
pub fn loaded_program_sha256(&self) -> Option<[u8; 32]> {
self.active_session()
.and_then(|session| session.runtime.loaded_program_sha256)
.or(self.os.vm_runtime.loaded_program_sha256)
}
pub fn current_cartridge_title(&self) -> String {
self.active_session()
.map(|session| session.runtime.current_cartridge_title.clone())
@@ -35,6 +35,7 @@ impl VirtualMachineRuntime {
game_lifecycle_events_delivered: Vec::new(),
atomic_telemetry,
last_crash_report: None,
loaded_program_sha256: None,
certifier: Certifier::new(cap_config.unwrap_or_default()),
paused: false,
debug_step_request: false,
@@ -139,6 +140,7 @@ impl VirtualMachineRuntime {
self.game_lifecycle_events_delivered.clear();
self.last_crash_report = None;
self.loaded_program_sha256 = None;
self.paused = false;
self.debug_step_request = false;
@@ -226,6 +228,8 @@ impl VirtualMachineRuntime {
) -> Result<(), CrashReport> {
self.clear_cartridge_state();
vm.set_capabilities(cartridge.capabilities);
use sha2::Digest;
self.loaded_program_sha256 = Some(sha2::Sha256::digest(&cartridge.program).into());
match vm.initialize(cartridge.program.clone()) {
Ok(_) => {
@@ -53,6 +53,8 @@ pub struct VirtualMachineRuntime {
pub game_lifecycle_events_delivered: Vec<GameLifecycleEvent>,
pub atomic_telemetry: Arc<AtomicTelemetry>,
pub last_crash_report: Option<CrashReport>,
/// Digest of the exact bounded PBX input supplied to initialization.
pub loaded_program_sha256: Option<[u8; 32]>,
pub certifier: Certifier,
pub paused: bool,
pub debug_step_request: bool,