implements PLN-0032

This commit is contained in:
2026-04-19 08:44:09 +01:00
parent 52785b5a8c
commit 33dd6d008b
4 changed files with 192 additions and 58 deletions
@@ -58,7 +58,8 @@ pub struct HostRunner {
/// Performance metrics collector.
stats: HostStats,
/// Remote debugger interface.
/// Remote debugger interface. It consumes host-owned telemetry and runtime state
/// directly instead of depending on guest-visible inspection syscalls.
debugger: HostDebugger,
/// Flag to enable/disable the technical telemetry display.
@@ -225,7 +226,8 @@ impl ApplicationHandler for HostRunner {
// 1. Process pending debug commands from the network.
self.debugger.check_commands(&mut self.firmware, &mut self.hardware);
// Sync inspection mode state.
// Sync inspection mode state. This is host-owned overlay/debugger control,
// not a guest-visible debug ABI switch.
self.firmware.os.inspection_active = self.overlay_enabled || self.debugger.stream.is_some();
// 2. Maintain filesystem connection if it was lost (e.g., directory removed).
@@ -307,9 +309,117 @@ mod tests {
use super::*;
use prometeu_firmware::BootTarget;
use prometeu_hal::debugger_protocol::DEVTOOLS_PROTOCOL_VERSION;
use prometeu_hal::telemetry::{CertificationConfig, TelemetryFrame};
use std::io::{Read, Write};
use std::net::TcpStream;
#[test]
fn host_debugger_maps_cert_events_from_host_owned_sources() {
let telemetry = TelemetryFrame {
glyph_slots_used: 3,
heap_used_bytes: 4096,
logs_count: 7,
..Default::default()
};
let config = CertificationConfig {
enabled: true,
max_glyph_slots_used: Some(2),
max_heap_bytes: Some(2048),
max_logs_per_frame: Some(5),
..Default::default()
};
match HostDebugger::cert_event_from_snapshot(0xCA04, telemetry, &config, 12) {
Some(prometeu_hal::debugger_protocol::DebugEvent::Cert {
rule,
used,
limit,
frame_index,
}) => {
assert_eq!(rule, "max_glyph_slots_used");
assert_eq!(used, 3);
assert_eq!(limit, 2);
assert_eq!(frame_index, 12);
}
other => panic!("unexpected glyph cert event: {:?}", other),
}
match HostDebugger::cert_event_from_snapshot(0xCA06, telemetry, &config, 12) {
Some(prometeu_hal::debugger_protocol::DebugEvent::Cert {
rule,
used,
limit,
frame_index,
}) => {
assert_eq!(rule, "max_heap_bytes");
assert_eq!(used, 4096);
assert_eq!(limit, 2048);
assert_eq!(frame_index, 12);
}
other => panic!("unexpected heap cert event: {:?}", other),
}
match HostDebugger::cert_event_from_snapshot(0xCA07, telemetry, &config, 12) {
Some(prometeu_hal::debugger_protocol::DebugEvent::Cert {
rule,
used,
limit,
frame_index,
}) => {
assert_eq!(rule, "max_logs_per_frame");
assert_eq!(used, 7);
assert_eq!(limit, 5);
assert_eq!(frame_index, 12);
}
other => panic!("unexpected logs cert event: {:?}", other),
}
}
#[test]
fn host_debugger_maps_telemetry_from_atomic_snapshot_fields() {
let telemetry = TelemetryFrame {
frame_index: 8,
vm_steps: 123,
syscalls: 9,
cycles_used: 456,
cycles_budget: 789,
host_cpu_time_us: 321,
violations: 2,
glyph_slots_used: 1,
glyph_slots_total: 16,
sound_slots_used: 0,
sound_slots_total: 8,
..Default::default()
};
match HostDebugger::telemetry_event_from_snapshot(telemetry) {
prometeu_hal::debugger_protocol::DebugEvent::Telemetry {
frame_index,
vm_steps,
syscalls,
cycles,
cycles_budget,
host_cpu_time_us,
violations,
glyph_slots_used,
glyph_slots_total,
sound_slots_used,
sound_slots_total,
} => {
assert_eq!(frame_index, 8);
assert_eq!(vm_steps, 123);
assert_eq!(syscalls, 9);
assert_eq!(cycles, 456);
assert_eq!(cycles_budget, 789);
assert_eq!(host_cpu_time_us, 321);
assert_eq!(violations, 2);
assert_eq!(glyph_slots_used, 1);
assert_eq!(glyph_slots_total, 16);
assert_eq!(sound_slots_used, 0);
assert_eq!(sound_slots_total, 8);
}
other => panic!("unexpected telemetry event: {:?}", other),
}
}
#[test]
#[ignore = "requires localhost TCP bind/connect; run via `cargo test -p prometeu-host-desktop-winit --lib -- --ignored`"]
fn test_debug_port_opens() {