feat(runtime): add host wall clock and administrative UTC timestamps
Intrepid/Prometeu/Runtime/pipeline/pr-master This commit looks good

This commit is contained in:
2026-10-13 09:16:15 +01:00
parent 3e39a90083
commit 23dc6fc66d
21 changed files with 603 additions and 51 deletions
@@ -20,6 +20,48 @@ const BLUE: u32 = Color::BLUE.raw();
const GREEN: u32 = Color::GREEN.raw();
const BLACK: u32 = Color::BLACK.raw();
#[test]
fn controlled_civil_time_is_independent_of_frames_pause_and_reset() {
let cartridge = color_cartridge();
for _ in 0..2 {
let mut host = HeadlessHost::new();
assert_eq!(host.wall_clock().utc_unix_seconds(), 0);
host.controlled_wall_clock().unwrap().set(1_000);
host.boot(&cartridge).expect("boot");
host.advance_frames(3).expect("frames");
assert_eq!(host.wall_clock().utc_unix_seconds(), 1_000);
host.pause().expect("pause");
host.controlled_wall_clock().unwrap().advance(60);
host.resume().expect("resume");
assert_eq!(host.wall_clock().utc_unix_seconds(), 1_060);
host.controlled_wall_clock().unwrap().set(10);
host.advance_frame().expect("frame after clock adjustment");
assert_eq!(host.wall_clock().utc_unix_seconds(), 10);
host.reset();
assert_eq!(host.wall_clock().utc_unix_seconds(), 10);
host.boot(&cartridge).expect("reboot");
assert_eq!(host.wall_clock().utc_unix_seconds(), 10);
}
}
#[test]
fn injected_civil_clock_remains_the_runtime_source_across_lifecycle() {
use prometeu_drivers::ControlledWallClock;
use std::sync::Arc;
let clock = Arc::new(ControlledWallClock::new(u64::MAX));
let mut host = HeadlessHost::new_with_wall_clock(clock.clone());
assert!(host.controlled_wall_clock().is_none());
host.boot(color_cartridge()).expect("boot");
host.advance_frame().expect("frame");
assert_eq!(host.wall_clock().utc_unix_seconds(), u64::MAX);
clock.set(42);
assert_eq!(host.wall_clock().utc_unix_seconds(), 42);
host.reset();
clock.advance(3);
assert_eq!(host.wall_clock().utc_unix_seconds(), 45);
}
#[test]
fn headless_source_has_no_timing_wait_or_interactive_backend_dependency() {
let source = include_str!("../src/host.rs");