Compare commits

..

No commits in common. "377cb41a3fc8beaa9afbdd191cb523f68bd57b83" and "7307870414ec195fc534202db951fda3a2ced28b" have entirely different histories.

19 changed files with 47 additions and 1440 deletions

View File

@ -180,58 +180,10 @@ mod tests {
use prometeu_hal::color::Color;
use prometeu_hal::primitives::Rect;
use prometeu_hal::syscalls::{Syscall, caps};
use prometeu_system::CrashReport;
use prometeu_system::process::ProcessState;
use prometeu_system::task::{TaskId, TaskState};
use prometeu_system::windows::WindowOwner;
use prometeu_system::{CrashReport, discover_games_root};
use std::fs;
use std::path::PathBuf;
use std::sync::atomic::{AtomicU64, Ordering};
static TEST_DIR_COUNTER: AtomicU64 = AtomicU64::new(0);
struct TestGameRoot {
path: PathBuf,
}
impl TestGameRoot {
fn new() -> Self {
let unique = TEST_DIR_COUNTER.fetch_add(1, Ordering::Relaxed);
let path = std::env::temp_dir().join(format!(
"prometeu-firmware-game-root-test-{}-{}",
std::process::id(),
unique
));
fs::create_dir_all(&path).expect("test game root should be created");
Self { path }
}
fn add_game(&self, name: &str, with_program: bool) -> PathBuf {
let cart = self.path.join(name);
fs::create_dir_all(&cart).expect("test cartridge should be created");
let manifest = r#"{
"magic": "PMTU",
"cartridge_version": 1,
"app_id": 42,
"title": "Stress",
"app_version": "1.0.0",
"app_mode": "Game"
}"#;
fs::write(cart.join("manifest.json"), manifest)
.expect("test manifest should be written");
if with_program {
fs::write(cart.join("program.pbx"), halting_program())
.expect("test program should be written");
}
cart
}
}
impl Drop for TestGameRoot {
fn drop(&mut self) {
let _ = fs::remove_dir_all(&self.path);
}
}
fn halting_program() -> Vec<u8> {
let code = assemble("HALT").expect("assemble");
@ -467,7 +419,7 @@ mod tests {
#[test]
fn hub_home_does_not_launch_shell_before_home_input_is_armed() {
let (mut firmware, mut platform) = hub_home_firmware();
let signals = InputSignals { f_signal: true, x_pos: 112, y_pos: 172, ..Default::default() };
let signals = InputSignals { f_signal: true, x_pos: 112, y_pos: 108, ..Default::default() };
firmware.tick(&signals, &mut platform);
@ -480,7 +432,7 @@ mod tests {
let (mut firmware, mut platform) = hub_home_firmware();
firmware.tick(&InputSignals::default(), &mut platform);
let signals = InputSignals { f_signal: true, x_pos: 112, y_pos: 172, ..Default::default() };
let signals = InputSignals { f_signal: true, x_pos: 112, y_pos: 108, ..Default::default() };
firmware.tick(&signals, &mut platform);
let task_id = match &firmware.state {
@ -503,7 +455,7 @@ mod tests {
let (mut firmware, mut platform) = hub_home_firmware();
firmware.tick(&InputSignals::default(), &mut platform);
let signals = InputSignals { f_signal: true, x_pos: 256, y_pos: 172, ..Default::default() };
let signals = InputSignals { f_signal: true, x_pos: 256, y_pos: 108, ..Default::default() };
firmware.tick(&signals, &mut platform);
let task_id = match &firmware.state {
@ -521,108 +473,6 @@ mod tests {
);
}
#[test]
fn hub_home_click_launches_game_library_entry_through_load_cartridge() {
let root = TestGameRoot::new();
root.add_game("stress", true);
let (mut firmware, mut platform) = hub_home_firmware();
firmware.hub.set_game_library(discover_games_root(&root.path));
firmware.tick(&InputSignals::default(), &mut platform);
let signals = InputSignals { f_signal: true, x_pos: 72, y_pos: 90, ..Default::default() };
firmware.tick(&signals, &mut platform);
match &firmware.state {
FirmwareState::LoadCartridge(step) => {
assert_eq!(step.cartridge.title, "Stress");
assert_eq!(step.cartridge.app_id, 42);
}
other => panic!("expected LoadCartridge state, got {:?}", other),
}
}
#[test]
fn games_root_home_click_reaches_game_running() {
let root = TestGameRoot::new();
root.add_game("stress", true);
let (mut firmware, mut platform) = hub_home_firmware();
firmware.hub.set_game_library(discover_games_root(&root.path));
firmware.tick(&InputSignals::default(), &mut platform);
let signals = InputSignals { f_signal: true, x_pos: 72, y_pos: 90, ..Default::default() };
firmware.tick(&signals, &mut platform);
firmware.tick(&InputSignals::default(), &mut platform);
assert!(matches!(firmware.state, FirmwareState::GameRunning(_)));
assert_eq!(firmware.os.vm().current_cartridge_title(), "Stress");
assert_eq!(firmware.os.windows().window_count(), 0);
}
#[test]
fn invalid_games_root_candidate_is_omitted_from_home_launch_boundary() {
let root = TestGameRoot::new();
root.add_game("broken", false);
let (mut firmware, mut platform) = hub_home_firmware();
let library = discover_games_root(&root.path);
assert!(library.is_empty());
assert!(!library.diagnostics().is_empty());
firmware.hub.set_game_library(library);
firmware.tick(&InputSignals::default(), &mut platform);
let signals = InputSignals { f_signal: true, x_pos: 72, y_pos: 90, ..Default::default() };
firmware.tick(&signals, &mut platform);
assert!(matches!(firmware.state, FirmwareState::HubHome(_)));
assert_eq!(firmware.os.vm().current_cartridge_title(), "");
}
#[test]
fn direct_boot_target_still_reaches_game_running_without_games_root() {
let root = TestGameRoot::new();
let cart = root.add_game("stress", true);
let mut firmware = Firmware::new(None);
let mut platform = TestPlatform::new();
firmware.boot_target = BootTarget::Cartridge {
path: cart.display().to_string(),
debug: false,
debug_port: 7777,
};
firmware.tick(&InputSignals::default(), &mut platform);
firmware.tick(&InputSignals::default(), &mut platform);
firmware.tick(&InputSignals::default(), &mut platform);
assert!(matches!(firmware.state, FirmwareState::GameRunning(_)));
assert_eq!(firmware.os.vm().current_cartridge_title(), "Stress");
}
#[test]
fn hub_home_failed_game_launch_remains_home_and_logs_error() {
let root = TestGameRoot::new();
let cart = root.add_game("stress", true);
let (mut firmware, mut platform) = hub_home_firmware();
firmware.hub.set_game_library(discover_games_root(&root.path));
fs::remove_file(cart.join("program.pbx")).expect("program should be removable");
firmware.tick(&InputSignals::default(), &mut platform);
let signals = InputSignals { f_signal: true, x_pos: 72, y_pos: 90, ..Default::default() };
firmware.tick(&signals, &mut platform);
assert!(matches!(firmware.state, FirmwareState::HubHome(_)));
assert!(
firmware
.os
.recent_logs(16)
.iter()
.any(|entry| entry.msg.contains("Failed to launch Home game"))
);
}
#[test]
fn shell_running_start_close_uses_lifecycle_and_returns_hub_home() {
let (mut firmware, mut platform, _signals, task_id) = load_shell_running_firmware();

View File

@ -1,8 +1,5 @@
use crate::firmware::firmware_state::{
AppCrashesStep, FirmwareState, LoadCartridgeStep, ShellRunningStep,
};
use crate::firmware::firmware_state::{AppCrashesStep, FirmwareState, ShellRunningStep};
use crate::firmware::prometeu_context::PrometeuContext;
use prometeu_hal::cartridge_loader::CartridgeLoader;
use prometeu_hal::log::{LogLevel, LogSource};
use prometeu_hal::primitives::Rect;
use prometeu_system::SystemProfileAction;
@ -24,32 +21,16 @@ impl HubHomeStep {
return Some(FirmwareState::AppCrashes(AppCrashesStep { report }));
}
match outcome.action {
Some(SystemProfileAction::LaunchNativeShell(app)) => {
let task_id = ctx.os.sessions().create_native_shell_task(app.app_id(), app.title());
let id = ctx.os.windows().add_window(
app.title().to_string(),
WindowOwner::Task(task_id),
Rect { x: 40, y: 20, w: 400, h: 220 },
app.color(),
);
ctx.os.windows().set_focus(id);
return Some(FirmwareState::ShellRunning(ShellRunningStep::new(task_id)));
}
Some(SystemProfileAction::LaunchGame { path }) => match CartridgeLoader::load(&path) {
Ok(cartridge) => {
return Some(FirmwareState::LoadCartridge(LoadCartridgeStep::new(cartridge)));
}
Err(error) => {
ctx.os.log(
LogLevel::Error,
LogSource::Hub,
0,
format!("Failed to launch Home game {}: {:?}", path.display(), error),
);
}
},
Some(SystemProfileAction::CloseShell) | None => {}
if let Some(SystemProfileAction::LaunchNativeShell(app)) = outcome.action {
let task_id = ctx.os.sessions().create_native_shell_task(app.app_id(), app.title());
let id = ctx.os.windows().add_window(
app.title().to_string(),
WindowOwner::Task(task_id),
Rect { x: 40, y: 20, w: 400, h: 220 },
app.color(),
);
ctx.os.windows().set_focus(id);
return Some(FirmwareState::ShellRunning(ShellRunningStep::new(task_id)));
}
None

View File

@ -297,7 +297,7 @@ pub enum Capability {
All,
}
#[derive(Debug, Clone, Deserialize)]
#[derive(Deserialize)]
pub struct CartridgeManifest {
pub magic: String,
pub cartridge_version: u32,

View File

@ -13,9 +13,6 @@ pub use services::async_work::{
AsyncWorkLaneController, AsyncWorkLaneError, AsyncWorkLaneTelemetry, AsyncWorkPriority,
};
pub use services::fs;
pub use services::game_library::{
GameLibrary, GameLibraryDiagnostic, GameLibraryEntry, discover_games_root,
};
pub use services::memcard::MemcardAsyncLaneOperation;
pub use services::process;
pub use services::task;

View File

@ -1,4 +1,4 @@
use crate::{CrashReport, GameLibrary, SystemOS};
use crate::{CrashReport, SystemOS};
use prometeu_hal::color::Color;
use prometeu_hal::primitives::Rect;
use prometeu_hal::{
@ -6,20 +6,13 @@ use prometeu_hal::{
ShellUiFramePacket,
};
use prometeu_vm::VirtualMachine;
use std::path::PathBuf;
const SHELL_A_BUTTON: Rect = Rect { x: 112, y: 172, w: 112, h: 32 };
const SHELL_B_BUTTON: Rect = Rect { x: 256, y: 172, w: 112, h: 32 };
const SHELL_A_BUTTON: Rect = Rect { x: 112, y: 108, w: 112, h: 48 };
const SHELL_B_BUTTON: Rect = Rect { x: 256, y: 108, w: 112, h: 48 };
const CLOSE_BUTTON: Rect = Rect { x: 420, y: 24, w: 16, h: 16 };
const VIEWPORT: Rect = Rect { x: 0, y: 0, w: 480, h: 270 };
const HOME_PANEL: Rect = Rect { x: 48, y: 58, w: 384, h: 154 };
const TITLE_PANEL: Rect = Rect { x: 72, y: 34, w: 336, h: 28 };
const GAME_ROW_X: i32 = 72;
const GAME_ROW_Y: i32 = 90;
const GAME_ROW_W: i32 = 336;
const GAME_ROW_H: i32 = 22;
const GAME_ROW_GAP: i32 = 6;
const MAX_HOME_GAME_ROWS: usize = 3;
#[cfg(test)]
const SHELL_FRAME: Rect = Rect { x: 40, y: 20, w: 400, h: 220 };
@ -36,7 +29,6 @@ const COLOR_BUTTON_ACTIVE: Color = Color::rgb(72, 91, 122);
/// PrometeuHub: Launcher and system UI environment.
pub struct PrometeuHub {
home_input_armed: bool,
game_library: GameLibrary,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
@ -80,10 +72,9 @@ impl NativeShellApp {
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum SystemProfileAction {
LaunchNativeShell(NativeShellApp),
LaunchGame { path: PathBuf },
CloseShell,
}
@ -100,21 +91,13 @@ impl Default for PrometeuHub {
impl PrometeuHub {
pub fn new() -> Self {
Self { home_input_armed: false, game_library: GameLibrary::empty() }
Self { home_input_armed: false }
}
pub fn init(&mut self) {
self.home_input_armed = false;
}
pub fn set_game_library(&mut self, game_library: GameLibrary) {
self.game_library = game_library;
}
pub fn game_library(&self) -> &GameLibrary {
&self.game_library
}
pub fn gui_update(
&mut self,
os: &mut SystemOS,
@ -137,7 +120,6 @@ impl PrometeuHub {
input.touch().x(),
input.touch().y(),
input.touch().f().pressed,
self.game_library.entries(),
) {
return Some(action);
}
@ -150,7 +132,7 @@ impl PrometeuHub {
let pointer_y = platform.input().touch().y();
let packet = if os.windows().window_count() == 0 {
render_home_packet(pointer_x, pointer_y, self.game_library.entries())
render_home_packet(pointer_x, pointer_y)
} else {
let mut commands = Vec::new();
for window in os.windows().windows() {
@ -195,13 +177,7 @@ impl PrometeuHub {
}
}
fn action_for_click(
in_shell: bool,
x: i32,
y: i32,
pressed: bool,
game_entries: &[crate::GameLibraryEntry],
) -> Option<SystemProfileAction> {
fn action_for_click(in_shell: bool, x: i32, y: i32, pressed: bool) -> Option<SystemProfileAction> {
if !pressed {
return None;
}
@ -210,31 +186,12 @@ fn action_for_click(
return rect_contains(CLOSE_BUTTON, x, y).then_some(SystemProfileAction::CloseShell);
}
if let Some(entry) = game_entries
.iter()
.take(MAX_HOME_GAME_ROWS)
.enumerate()
.find(|(index, _entry)| rect_contains(game_row_rect(*index), x, y))
.map(|(_index, entry)| entry)
{
return Some(SystemProfileAction::LaunchGame { path: entry.path.clone() });
}
HOME_BUTTONS
.iter()
.find(|button| rect_contains(button.rect, x, y))
.map(|button| SystemProfileAction::LaunchNativeShell(button.app))
}
fn game_row_rect(index: usize) -> Rect {
Rect {
x: GAME_ROW_X,
y: GAME_ROW_Y + (GAME_ROW_H + GAME_ROW_GAP) * index as i32,
w: GAME_ROW_W,
h: GAME_ROW_H,
}
}
fn rect_contains(rect: Rect, x: i32, y: i32) -> bool {
x >= rect.x && x < rect.x + rect.w && y >= rect.y && y < rect.y + rect.h
}
@ -246,11 +203,7 @@ fn activation_input_down(input: &dyn InputPlatform) -> bool {
|| input.pad().start().down
}
fn render_home_packet(
pointer_x: i32,
pointer_y: i32,
game_entries: &[crate::GameLibraryEntry],
) -> ShellUiFramePacket {
fn render_home_packet(pointer_x: i32, pointer_y: i32) -> ShellUiFramePacket {
let mut commands = Vec::new();
commands.push(GfxUiCommand::Clear { color: COLOR_BG });
fill_rect(&mut commands, VIEWPORT, COLOR_BG);
@ -264,26 +217,21 @@ fn render_home_packet(
);
draw_panel(&mut commands, HOME_PANEL, COLOR_PANEL, COLOR_BORDER);
draw_buffer_text(&mut commands, HOME_PANEL.x + 26, HOME_PANEL.y + 22, "Games", COLOR_TEXT);
draw_buffer_text(
&mut commands,
HOME_PANEL.x + 26,
HOME_PANEL.y + 22,
"Native Shell Apps",
COLOR_TEXT,
);
draw_buffer_text(
&mut commands,
HOME_PANEL.x + 26,
HOME_PANEL.y + 40,
"local library",
"first retro ui slice",
COLOR_MUTED,
);
if game_entries.is_empty() {
draw_buffer_text(&mut commands, GAME_ROW_X, GAME_ROW_Y + 6, "No games found", COLOR_MUTED);
} else {
for (index, entry) in game_entries.iter().take(MAX_HOME_GAME_ROWS).enumerate() {
let rect = game_row_rect(index);
let hovered = rect_contains(rect, pointer_x, pointer_y);
let text = format!("{} #{} {}", entry.title, entry.app_id, entry.app_version);
draw_game_row(&mut commands, rect, &text, hovered);
}
}
for button in HOME_BUTTONS {
let hovered = rect_contains(button.rect, pointer_x, pointer_y);
draw_button(&mut commands, button.rect, button.label, hovered);
@ -378,17 +326,9 @@ fn draw_button(commands: &mut Vec<GfxUiCommand>, rect: Rect, label: &str, hovere
Rect { x: rect.x + 3, y: rect.y + 3, w: rect.w - 6, h: rect.h - 6 },
COLOR_MUTED,
);
fill_rect(commands, Rect { x: rect.x + 12, y: rect.y + 8, w: 14, h: 16 }, border);
draw_rect(commands, Rect { x: rect.x + 34, y: rect.y + 8, w: 62, h: 16 }, COLOR_PANEL_DARK);
draw_buffer_text(commands, rect.x + 40, rect.y + 13, label, COLOR_TEXT);
}
fn draw_game_row(commands: &mut Vec<GfxUiCommand>, rect: Rect, label: &str, hovered: bool) {
let fill = if hovered { COLOR_BUTTON_ACTIVE } else { COLOR_PANEL_DARK };
let border = if hovered { COLOR_HILITE } else { COLOR_MUTED };
fill_rect(commands, rect, fill);
draw_rect(commands, rect, border);
draw_buffer_text(commands, rect.x + 8, rect.y + 7, label, COLOR_TEXT);
fill_rect(commands, Rect { x: rect.x + 12, y: rect.y + 12, w: 16, h: 24 }, border);
draw_rect(commands, Rect { x: rect.x + 34, y: rect.y + 12, w: 62, h: 24 }, COLOR_PANEL_DARK);
draw_buffer_text(commands, rect.x + 40, rect.y + 21, label, COLOR_TEXT);
}
fn draw_buffer_text(commands: &mut Vec<GfxUiCommand>, x: i32, y: i32, text: &str, color: Color) {
@ -402,7 +342,7 @@ mod tests {
#[test]
fn shell_a_button_click_emits_launch_action() {
assert_eq!(
action_for_click(false, HOME_BUTTONS[0].rect.x, HOME_BUTTONS[0].rect.y, true, &[]),
action_for_click(false, HOME_BUTTONS[0].rect.x, HOME_BUTTONS[0].rect.y, true),
Some(SystemProfileAction::LaunchNativeShell(NativeShellApp::ShellA))
);
}
@ -414,8 +354,7 @@ mod tests {
false,
SHELL_B_BUTTON.x + SHELL_B_BUTTON.w - 1,
SHELL_B_BUTTON.y,
true,
&[]
true
),
Some(SystemProfileAction::LaunchNativeShell(NativeShellApp::ShellB))
);
@ -424,30 +363,18 @@ mod tests {
#[test]
fn button_hit_test_excludes_right_and_bottom_edges() {
assert_eq!(
action_for_click(
false,
SHELL_A_BUTTON.x + SHELL_A_BUTTON.w,
SHELL_A_BUTTON.y,
true,
&[]
),
action_for_click(false, SHELL_A_BUTTON.x + SHELL_A_BUTTON.w, SHELL_A_BUTTON.y, true),
None
);
assert_eq!(
action_for_click(
false,
SHELL_A_BUTTON.x,
SHELL_A_BUTTON.y + SHELL_A_BUTTON.h,
true,
&[]
),
action_for_click(false, SHELL_A_BUTTON.x, SHELL_A_BUTTON.y + SHELL_A_BUTTON.h, true),
None
);
}
#[test]
fn held_pointer_does_not_emit_click_action() {
assert_eq!(action_for_click(false, SHELL_A_BUTTON.x, SHELL_A_BUTTON.y, false, &[]), None);
assert_eq!(action_for_click(false, SHELL_A_BUTTON.x, SHELL_A_BUTTON.y, false), None);
}
#[test]
@ -456,38 +383,13 @@ mod tests {
assert!(!hub.home_input_armed);
}
#[test]
fn game_row_click_emits_launch_game_action() {
let entry = crate::GameLibraryEntry {
manifest: prometeu_hal::cartridge::CartridgeManifest {
magic: "PMTU".to_string(),
cartridge_version: 1,
app_id: 42,
title: "Stress".to_string(),
app_version: "1.0.0".to_string(),
app_mode: prometeu_hal::app_mode::AppMode::Game,
capabilities: vec![],
},
title: "Stress".to_string(),
app_id: 42,
app_version: "1.0.0".to_string(),
path: PathBuf::from("test-cartridges/stress-console"),
discovered_at: std::time::SystemTime::UNIX_EPOCH,
};
assert_eq!(
action_for_click(false, GAME_ROW_X, GAME_ROW_Y, true, std::slice::from_ref(&entry)),
Some(SystemProfileAction::LaunchGame { path: entry.path.clone() })
);
}
#[test]
fn close_button_click_emits_close_only_in_shell() {
assert_eq!(
action_for_click(true, CLOSE_BUTTON.x, CLOSE_BUTTON.y, true, &[]),
action_for_click(true, CLOSE_BUTTON.x, CLOSE_BUTTON.y, true),
Some(SystemProfileAction::CloseShell)
);
assert_eq!(action_for_click(false, CLOSE_BUTTON.x, CLOSE_BUTTON.y, true, &[]), None);
assert_eq!(action_for_click(false, CLOSE_BUTTON.x, CLOSE_BUTTON.y, true), None);
}
#[test]
@ -501,7 +403,7 @@ mod tests {
#[test]
fn home_render_produces_shell_ui_packet_commands() {
let packet = render_home_packet(SHELL_A_BUTTON.x, SHELL_A_BUTTON.y, &[]);
let packet = render_home_packet(SHELL_A_BUTTON.x, SHELL_A_BUTTON.y);
assert!(matches!(packet.commands.first(), Some(GfxUiCommand::Clear { .. })));
assert!(packet.commands.iter().any(|command| {

View File

@ -1,270 +0,0 @@
use prometeu_hal::app_mode::AppMode;
use prometeu_hal::cartridge::CartridgeManifest;
use std::fs;
use std::path::{Path, PathBuf};
use std::time::SystemTime;
#[derive(Debug, Clone)]
pub struct GameLibraryEntry {
pub manifest: CartridgeManifest,
pub title: String,
pub app_id: u32,
pub app_version: String,
pub path: PathBuf,
pub discovered_at: SystemTime,
}
impl GameLibraryEntry {
fn new(path: PathBuf, manifest: CartridgeManifest, discovered_at: SystemTime) -> Self {
Self {
title: manifest.title.clone(),
app_id: manifest.app_id,
app_version: manifest.app_version.clone(),
manifest,
path,
discovered_at,
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct GameLibraryDiagnostic {
pub path: PathBuf,
pub reason: GameLibraryDiagnosticReason,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum GameLibraryDiagnosticReason {
RootNotDirectory,
CandidateReadFailed,
MissingManifest,
InvalidManifest,
UnsupportedVersion,
MissingProgram,
NonGameAppMode,
}
#[derive(Debug, Clone, Default)]
pub struct GameLibrary {
entries: Vec<GameLibraryEntry>,
diagnostics: Vec<GameLibraryDiagnostic>,
}
impl GameLibrary {
pub fn empty() -> Self {
Self::default()
}
pub fn entries(&self) -> &[GameLibraryEntry] {
&self.entries
}
pub fn diagnostics(&self) -> &[GameLibraryDiagnostic] {
&self.diagnostics
}
pub fn is_empty(&self) -> bool {
self.entries.is_empty()
}
}
pub fn discover_games_root(root: impl AsRef<Path>) -> GameLibrary {
let root = root.as_ref();
let discovered_at = SystemTime::now();
if !root.is_dir() {
return GameLibrary {
entries: Vec::new(),
diagnostics: vec![GameLibraryDiagnostic {
path: root.to_path_buf(),
reason: GameLibraryDiagnosticReason::RootNotDirectory,
}],
};
}
let read_dir = match fs::read_dir(root) {
Ok(read_dir) => read_dir,
Err(_) => {
return GameLibrary {
entries: Vec::new(),
diagnostics: vec![GameLibraryDiagnostic {
path: root.to_path_buf(),
reason: GameLibraryDiagnosticReason::CandidateReadFailed,
}],
};
}
};
let mut entries = Vec::new();
let mut diagnostics = Vec::new();
for item in read_dir {
let Ok(item) = item else {
diagnostics.push(GameLibraryDiagnostic {
path: root.to_path_buf(),
reason: GameLibraryDiagnosticReason::CandidateReadFailed,
});
continue;
};
let path = item.path();
if !path.is_dir() {
continue;
}
match discover_candidate(&path, discovered_at) {
Ok(entry) => entries.push(entry),
Err(reason) => diagnostics.push(GameLibraryDiagnostic { path, reason }),
}
}
entries.sort_by(|left, right| {
left.title
.cmp(&right.title)
.then_with(|| left.app_id.cmp(&right.app_id))
.then_with(|| left.path.cmp(&right.path))
});
GameLibrary { entries, diagnostics }
}
fn discover_candidate(
path: &Path,
discovered_at: SystemTime,
) -> Result<GameLibraryEntry, GameLibraryDiagnosticReason> {
let manifest_path = path.join("manifest.json");
if !manifest_path.exists() {
return Err(GameLibraryDiagnosticReason::MissingManifest);
}
let manifest_content = fs::read_to_string(manifest_path)
.map_err(|_| GameLibraryDiagnosticReason::InvalidManifest)?;
let manifest: CartridgeManifest = serde_json::from_str(&manifest_content)
.map_err(|_| GameLibraryDiagnosticReason::InvalidManifest)?;
if manifest.magic != "PMTU" {
return Err(GameLibraryDiagnosticReason::InvalidManifest);
}
if manifest.cartridge_version != 1 {
return Err(GameLibraryDiagnosticReason::UnsupportedVersion);
}
if manifest.app_mode != AppMode::Game {
return Err(GameLibraryDiagnosticReason::NonGameAppMode);
}
if !path.join("program.pbx").exists() {
return Err(GameLibraryDiagnosticReason::MissingProgram);
}
Ok(GameLibraryEntry::new(path.to_path_buf(), manifest, discovered_at))
}
#[cfg(test)]
mod tests {
use super::*;
use serde_json::json;
use std::sync::atomic::{AtomicU64, Ordering};
use std::time::UNIX_EPOCH;
static TEST_DIR_COUNTER: AtomicU64 = AtomicU64::new(0);
struct TestRoot {
path: PathBuf,
}
impl TestRoot {
fn new() -> Self {
let unique = TEST_DIR_COUNTER.fetch_add(1, Ordering::Relaxed);
let path = std::env::temp_dir().join(format!(
"prometeu-game-library-test-{}-{}",
std::process::id(),
unique
));
fs::create_dir_all(&path).expect("test root should be created");
Self { path }
}
fn add_candidate(&self, name: &str, manifest: serde_json::Value, with_program: bool) {
let candidate = self.path.join(name);
fs::create_dir_all(&candidate).expect("candidate should be created");
fs::write(candidate.join("manifest.json"), manifest.to_string())
.expect("manifest should be written");
if with_program {
fs::write(candidate.join("program.pbx"), [0_u8])
.expect("program should be written");
}
}
}
impl Drop for TestRoot {
fn drop(&mut self) {
let _ = fs::remove_dir_all(&self.path);
}
}
fn manifest(title: &str, app_id: u32, app_mode: &str) -> serde_json::Value {
json!({
"magic": "PMTU",
"cartridge_version": 1,
"app_id": app_id,
"title": title,
"app_version": "1.0.0",
"app_mode": app_mode
})
}
#[test]
fn discovery_returns_only_immediate_valid_game_directories() {
let root = TestRoot::new();
root.add_candidate("zeta", manifest("Zeta", 2, "Game"), true);
root.add_candidate("alpha", manifest("Alpha", 1, "Game"), true);
root.add_candidate("shell", manifest("Shell", 3, "Shell"), true);
root.add_candidate("missing-program", manifest("Missing Program", 4, "Game"), false);
fs::write(root.path.join("loose-file.txt"), "ignored").expect("file should be written");
let nested_parent = root.path.join("nested-parent");
fs::create_dir_all(nested_parent.join("nested-game")).expect("nested dir should exist");
fs::write(
nested_parent.join("nested-game").join("manifest.json"),
manifest("Nested", 5, "Game").to_string(),
)
.expect("nested manifest should be written");
fs::write(nested_parent.join("nested-game").join("program.pbx"), [0_u8])
.expect("nested program should be written");
let library = discover_games_root(&root.path);
assert_eq!(library.entries().len(), 2);
assert_eq!(library.entries()[0].title, "Alpha");
assert_eq!(library.entries()[0].app_id, 1);
assert_eq!(library.entries()[0].app_version, "1.0.0");
assert_eq!(library.entries()[0].manifest.app_mode, AppMode::Game);
assert!(library.entries()[0].path.ends_with("alpha"));
assert!(library.entries()[0].discovered_at >= UNIX_EPOCH);
assert_eq!(library.entries()[1].title, "Zeta");
assert!(library.diagnostics().iter().any(|diagnostic| {
diagnostic.path.ends_with("shell")
&& diagnostic.reason == GameLibraryDiagnosticReason::NonGameAppMode
}));
assert!(library.diagnostics().iter().any(|diagnostic| {
diagnostic.path.ends_with("missing-program")
&& diagnostic.reason == GameLibraryDiagnosticReason::MissingProgram
}));
assert!(library.diagnostics().iter().any(|diagnostic| {
diagnostic.path.ends_with("nested-parent")
&& diagnostic.reason == GameLibraryDiagnosticReason::MissingManifest
}));
}
#[test]
fn missing_root_returns_diagnostic_and_no_entries() {
let root = TestRoot::new();
let missing = root.path.join("missing");
let library = discover_games_root(&missing);
assert!(library.is_empty());
assert_eq!(library.diagnostics().len(), 1);
assert_eq!(library.diagnostics()[0].reason, GameLibraryDiagnosticReason::RootNotDirectory);
}
}

View File

@ -1,6 +1,5 @@
pub mod async_work;
pub mod fs;
pub mod game_library;
pub mod memcard;
pub mod process;
pub mod task;

View File

@ -33,10 +33,6 @@ struct Cli {
#[arg(long, value_name = "PATH")]
fs_root: Option<String>,
/// Root directory for local game cartridge discovery
#[arg(long, value_name = "PATH")]
games_root: Option<String>,
/// Path to the capability configuration file
#[arg(long, value_name = "PATH")]
cap: Option<String>,
@ -59,9 +55,6 @@ pub fn run() -> Result<(), Box<dyn std::error::Error>> {
let event_loop = EventLoop::new()?;
let mut runner = HostRunner::new(fs_root, cap_config);
if let Some(games_root) = cli.games_root {
runner.set_games_root(games_root);
}
runner.set_boot_target(boot_target);
event_loop.run_app(&mut runner)?;

View File

@ -12,7 +12,7 @@ use prometeu_drivers::{AudioCommand, LocalFramebufferRenderBackend, MemoryBanks}
use prometeu_firmware::{BootTarget, Firmware, FirmwareState};
use prometeu_hal::RuntimePlatform;
use prometeu_hal::telemetry::CertificationConfig;
use prometeu_system::{LatestRenderFrameStore, RenderWorkerConfig, discover_games_root};
use prometeu_system::{LatestRenderFrameStore, RenderWorkerConfig};
use std::sync::Arc;
use std::time::{Duration, Instant};
use winit::application::ApplicationHandler;
@ -151,18 +151,6 @@ impl HostRunner {
self.debugger.setup_boot_target(&boot_target, &mut self.firmware);
}
pub(crate) fn set_games_root(&mut self, games_root: String) {
let library = discover_games_root(&games_root);
for diagnostic in library.diagnostics() {
eprintln!(
"games-root: omitted candidate {}: {:?}",
diagnostic.path.display(),
diagnostic.reason
);
}
self.firmware.hub.set_game_library(library);
}
/// Creates a new desktop runner instance.
pub(crate) fn new(fs_root: Option<String>, cap_config: Option<CertificationConfig>) -> Self {
let target_fps = 60;

View File

@ -1,4 +1,4 @@
{"type":"meta","next_id":{"DSC":44,"AGD":46,"DEC":37,"PLN":136,"LSN":51,"CLSN":1}}
{"type":"meta","next_id":{"DSC":44,"AGD":45,"DEC":36,"PLN":132,"LSN":51,"CLSN":1}}
{"type":"discussion","id":"DSC-0043","status":"open","ticket":"system-os-cartridge-switch-orchestrator","title":"SystemOS Cartridge Switch Orchestrator","created_at":"2026-07-03","updated_at":"2026-07-03","tags":["runtime","os","lifecycle","game","cartridge","architecture"],"agendas":[{"id":"AGD-0044","file":"AGD-0044-systemos-cartridge-switch-orchestrator.md","status":"open","created_at":"2026-07-03","updated_at":"2026-07-03"}],"decisions":[],"plans":[],"lessons":[]}
{"type":"discussion","id":"DSC-0039","status":"abandoned","ticket":"render-pipeline-family-and-future-3d","title":"Render Pipeline Family and Future 3D","created_at":"2026-06-04","updated_at":"2026-06-04","tags":["gfx","renderer","runtime","architecture","pipeline"],"agendas":[{"id":"AGD-0039","file":"AGD-0039-render-pipeline-family-and-future-3d.md","status":"abandoned","created_at":"2026-06-04","updated_at":"2026-06-04","_override_reason":"User explicitly chose to close this agenda without a new decision because DSC-0038 already established enough architecture for future extension, and 3D is intentionally deferred."}],"decisions":[],"plans":[],"lessons":[],"_override_reason":"User explicitly chose to close this agenda without a new decision because DSC-0038 already established enough architecture for future extension, and 3D is intentionally deferred."}
{"type":"discussion","id":"DSC-0040","status":"done","ticket":"vm-render-parallel-execution-boundary","title":"VM and Render Parallel Execution Boundary","created_at":"2026-06-04","updated_at":"2026-06-06","tags":["runtime","renderer","vm","concurrency","architecture","perf"],"agendas":[],"decisions":[],"plans":[],"lessons":[{"id":"LSN-0048","file":"discussion/lessons/DSC-0040-vm-render-parallel-execution-boundary/LSN-0048-render-workers-need-a-closed-packet-contract.md","status":"done","created_at":"2026-06-06","updated_at":"2026-06-06"}]}
@ -14,7 +14,7 @@
{"type":"discussion","id":"DSC-0001","status":"done","ticket":"legacy-runtime-learn-import","title":"Import legacy runtime learn into discussion lessons","created_at":"2026-03-27","updated_at":"2026-03-27","tags":["migration","tech-debt"],"agendas":[],"decisions":[],"plans":[],"lessons":[{"id":"LSN-0001","file":"discussion/lessons/DSC-0001-runtime-learn-legacy-import/LSN-0001-prometeu-learn-index.md","status":"done","created_at":"2026-03-27","updated_at":"2026-03-27"},{"id":"LSN-0002","file":"discussion/lessons/DSC-0001-runtime-learn-legacy-import/LSN-0002-historical-asset-status-first-fault-and-return-contract.md","status":"done","created_at":"2026-03-27","updated_at":"2026-03-27"},{"id":"LSN-0003","file":"discussion/lessons/DSC-0001-runtime-learn-legacy-import/LSN-0003-historical-audio-status-first-fault-and-return-contract.md","status":"done","created_at":"2026-03-27","updated_at":"2026-03-27"},{"id":"LSN-0004","file":"discussion/lessons/DSC-0001-runtime-learn-legacy-import/LSN-0004-historical-cartridge-boot-protocol-and-manifest-authority.md","status":"done","created_at":"2026-03-27","updated_at":"2026-03-27"},{"id":"LSN-0005","file":"discussion/lessons/DSC-0001-runtime-learn-legacy-import/LSN-0005-historical-game-memcard-slots-surface-and-semantics.md","status":"done","created_at":"2026-03-27","updated_at":"2026-03-27"},{"id":"LSN-0006","file":"discussion/lessons/DSC-0001-runtime-learn-legacy-import/LSN-0006-historical-gfx-status-first-fault-and-return-contract.md","status":"done","created_at":"2026-03-27","updated_at":"2026-03-27"},{"id":"LSN-0007","file":"discussion/lessons/DSC-0001-runtime-learn-legacy-import/LSN-0007-historical-retired-fault-and-input-decisions.md","status":"done","created_at":"2026-03-27","updated_at":"2026-03-27"},{"id":"LSN-0008","file":"discussion/lessons/DSC-0001-runtime-learn-legacy-import/LSN-0008-historical-vm-core-and-assets.md","status":"done","created_at":"2026-03-27","updated_at":"2026-03-27"},{"id":"LSN-0009","file":"discussion/lessons/DSC-0001-runtime-learn-legacy-import/LSN-0009-mental-model-asset-management.md","status":"done","created_at":"2026-03-27","updated_at":"2026-03-27"},{"id":"LSN-0010","file":"discussion/lessons/DSC-0001-runtime-learn-legacy-import/LSN-0010-mental-model-audio.md","status":"done","created_at":"2026-03-27","updated_at":"2026-03-27"},{"id":"LSN-0011","file":"discussion/lessons/DSC-0001-runtime-learn-legacy-import/LSN-0011-mental-model-gfx.md","status":"done","created_at":"2026-03-27","updated_at":"2026-03-27"},{"id":"LSN-0012","file":"discussion/lessons/DSC-0001-runtime-learn-legacy-import/LSN-0012-mental-model-input.md","status":"done","created_at":"2026-03-27","updated_at":"2026-03-27"},{"id":"LSN-0013","file":"discussion/lessons/DSC-0001-runtime-learn-legacy-import/LSN-0013-mental-model-observability-and-debugging.md","status":"done","created_at":"2026-03-27","updated_at":"2026-03-27"},{"id":"LSN-0014","file":"discussion/lessons/DSC-0001-runtime-learn-legacy-import/LSN-0014-mental-model-portability-and-cross-platform.md","status":"done","created_at":"2026-03-27","updated_at":"2026-03-27"},{"id":"LSN-0015","file":"discussion/lessons/DSC-0001-runtime-learn-legacy-import/LSN-0015-mental-model-save-memory-and-memcard.md","status":"done","created_at":"2026-03-27","updated_at":"2026-03-27"},{"id":"LSN-0016","file":"discussion/lessons/DSC-0001-runtime-learn-legacy-import/LSN-0016-mental-model-status-first-and-fault-thinking.md","status":"done","created_at":"2026-03-27","updated_at":"2026-03-27"},{"id":"LSN-0017","file":"discussion/lessons/DSC-0001-runtime-learn-legacy-import/LSN-0017-mental-model-time-and-cycles.md","status":"done","created_at":"2026-03-27","updated_at":"2026-03-27"},{"id":"LSN-0018","file":"discussion/lessons/DSC-0001-runtime-learn-legacy-import/LSN-0018-mental-model-touch.md","status":"done","created_at":"2026-03-27","updated_at":"2026-03-27"}]}
{"type":"discussion","id":"DSC-0002","status":"done","ticket":"runtime-edge-test-plan","title":"Agenda - Runtime Edge Test Plan","created_at":"2026-03-27","updated_at":"2026-04-21","tags":[],"agendas":[],"decisions":[],"plans":[],"lessons":[{"id":"LSN-0037","file":"discussion/lessons/DSC-0002-runtime-edge-test-plan/LSN-0037-domain-gates-must-be-owned-by-the-repository.md","status":"done","created_at":"2026-04-21","updated_at":"2026-04-21"}]}
{"type":"discussion","id":"DSC-0003","status":"open","ticket":"packed-cartridge-loader-pmc","title":"Agenda - Packed Cartridge Loader PMC","created_at":"2026-03-27","updated_at":"2026-03-27","tags":[],"agendas":[{"id":"AGD-0002","file":"AGD-0002-packed-cartridge-loader-pmc.md","status":"open","created_at":"2026-03-27","updated_at":"2026-03-27"}],"decisions":[],"plans":[],"lessons":[]}
{"type":"discussion","id":"DSC-0004","status":"in_progress","ticket":"system-run-cart","title":"Agenda - System Run Cart","created_at":"2026-03-27","updated_at":"2026-07-03","tags":[],"agendas":[{"id":"AGD-0003","file":"AGD-0003-system-run-cart.md","status":"accepted","created_at":"2026-03-27","updated_at":"2026-07-03"},{"id":"AGD-0045","file":"AGD-0045-systemos-library-root-home-game-launch.md","status":"accepted","created_at":"2026-07-03","updated_at":"2026-07-03"}],"decisions":[{"id":"DEC-0035","file":"DEC-0035-remove-userland-system-run-cart-and-preserve-direct-boot.md","status":"accepted","created_at":"2026-07-03","updated_at":"2026-07-03","ref_agenda":"AGD-0003"},{"id":"DEC-0036","file":"DEC-0036-systemos-games-root-and-home-game-launch.md","status":"accepted","created_at":"2026-07-03","updated_at":"2026-07-03","ref_agenda":"AGD-0045"}],"plans":[{"id":"PLN-0129","file":"PLN-0129-remove-userland-run-cart-abi-surface.md","status":"done","created_at":"2026-07-03","updated_at":"2026-07-03","ref_decisions":["DEC-0035"]},{"id":"PLN-0130","file":"PLN-0130-remove-runtime-run-cart-stub-dispatch.md","status":"done","created_at":"2026-07-03","updated_at":"2026-07-03","ref_decisions":["DEC-0035"]},{"id":"PLN-0131","file":"PLN-0131-preserve-direct-cartridge-boot-coverage.md","status":"done","created_at":"2026-07-03","updated_at":"2026-07-03","ref_decisions":["DEC-0035"]},{"id":"PLN-0132","file":"PLN-0132-specify-games-root-home-launch-contract.md","status":"done","created_at":"2026-07-03","updated_at":"2026-07-03","ref_decisions":["DEC-0036"]},{"id":"PLN-0133","file":"PLN-0133-implement-games-root-library-discovery.md","status":"done","created_at":"2026-07-03","updated_at":"2026-07-03","ref_decisions":["DEC-0036"]},{"id":"PLN-0134","file":"PLN-0134-wire-home-game-list-launch-flow.md","status":"done","created_at":"2026-07-03","updated_at":"2026-07-03","ref_decisions":["DEC-0036"]},{"id":"PLN-0135","file":"PLN-0135-validate-games-root-launch-end-to-end.md","status":"done","created_at":"2026-07-03","updated_at":"2026-07-03","ref_decisions":["DEC-0036"]}],"lessons":[]}
{"type":"discussion","id":"DSC-0004","status":"in_progress","ticket":"system-run-cart","title":"Agenda - System Run Cart","created_at":"2026-03-27","updated_at":"2026-07-03","tags":[],"agendas":[{"id":"AGD-0003","file":"AGD-0003-system-run-cart.md","status":"accepted","created_at":"2026-03-27","updated_at":"2026-07-03"}],"decisions":[{"id":"DEC-0035","file":"DEC-0035-remove-userland-system-run-cart-and-preserve-direct-boot.md","status":"accepted","created_at":"2026-07-03","updated_at":"2026-07-03","ref_agenda":"AGD-0003"}],"plans":[{"id":"PLN-0129","file":"PLN-0129-remove-userland-run-cart-abi-surface.md","status":"done","created_at":"2026-07-03","updated_at":"2026-07-03","ref_decisions":["DEC-0035"]},{"id":"PLN-0130","file":"PLN-0130-remove-runtime-run-cart-stub-dispatch.md","status":"done","created_at":"2026-07-03","updated_at":"2026-07-03","ref_decisions":["DEC-0035"]},{"id":"PLN-0131","file":"PLN-0131-preserve-direct-cartridge-boot-coverage.md","status":"done","created_at":"2026-07-03","updated_at":"2026-07-03","ref_decisions":["DEC-0035"]}],"lessons":[]}
{"type":"discussion","id":"DSC-0005","status":"open","ticket":"system-fault-semantics-and-control-surface","title":"Agenda - System Fault Semantics and Control Surface","created_at":"2026-03-27","updated_at":"2026-03-27","tags":[],"agendas":[{"id":"AGD-0004","file":"AGD-0004-system-fault-semantics-and-control-surface.md","status":"open","created_at":"2026-03-27","updated_at":"2026-03-27"}],"decisions":[],"plans":[],"lessons":[]}
{"type":"discussion","id":"DSC-0006","status":"open","ticket":"vm-owned-random-service","title":"Agenda - VM-Owned Random Service","created_at":"2026-03-27","updated_at":"2026-03-27","tags":[],"agendas":[{"id":"AGD-0005","file":"AGD-0005-vm-owned-random-service.md","status":"open","created_at":"2026-03-27","updated_at":"2026-03-27"}],"decisions":[],"plans":[],"lessons":[]}
{"type":"discussion","id":"DSC-0007","status":"open","ticket":"app-home-filesystem-surface-and-semantics","title":"Agenda - App Home Filesystem Surface and Semantics","created_at":"2026-03-27","updated_at":"2026-03-27","tags":[],"agendas":[{"id":"AGD-0006","file":"AGD-0006-app-home-filesystem-surface-and-semantics.md","status":"open","created_at":"2026-03-27","updated_at":"2026-03-27"}],"decisions":[],"plans":[],"lessons":[]}

View File

@ -1,161 +0,0 @@
---
id: AGD-0045
ticket: system-run-cart
title: SystemOS Library Root and Home Game Launch
status: accepted
created: 2026-07-03
resolved:
decision:
tags: [runtime, os, hub, cartridge, launcher, library, game, architecture]
---
## Contexto
A `DEC-0035` fechou que `system.run_cart` nao deve existir como syscall
userland e que boot direto por host/CLI/debug deve permanecer.
Isso resolveu a autoridade negativa, mas ainda nao resolveu a experiencia
desejada para o SO: apontar o runtime para um diretorio raiz de biblioteca,
fazer a Home listar os cartuchos encontrados ali e permitir que o usuario clique
em um jogo para carrega-lo.
O objetivo pratico e um "Switch feio": uma lista simples na Home, sem UX final,
sem marketplace e sem catalogo rico, mas capaz de provar que o SO, e nao o
guest, escolhe e carrega um cartucho a partir de uma biblioteca local.
## Problema
Hoje temos dois caminhos separados:
- boot direto por `--run <cart>` funciona e carrega um cartucho unico;
- Hub/Home existe, mas mostra acoes fixas de Shell nativo e nao lista jogos de
uma biblioteca real.
Sem uma biblioteca de cartuchos visivel para o SO, o usuario nao consegue
iniciar jogos a partir da Home. Isso deixa a agenda `system-run-cart` incompleta
do ponto de vista de produto: removemos o `run_cart` userland, mas ainda falta a
alternativa correta, que e o SO iniciar cartuchos por acao de usuario.
## Pontos Criticos
- O root da biblioteca deve ser fornecido pelo host como `--games-root <dir>`.
- O scan inicial deve cobrir subdiretorios imediatos com `manifest.json`.
- O loader de diretorio existente deve continuar sendo a autoridade para validar
cartucho completo; a biblioteca pode ler metadados minimos para listagem.
- A Home pode mostrar uma lista feia/clicavel; polimento visual fica fora.
- O clique em um Game deve iniciar `LoadCartridge` pelo firmware/SystemOS, nao
por syscall guest.
- V1 nao precisa tratar retorno de um Game para Home, porque isso pertence a
`AGD-0041`.
- `.pmc`, outros tipos de app, catalogo remoto, marketplace, icones, busca e
metadados ricos ficam fora.
## Opcoes
### Opcao A - Biblioteca apenas para listagem
- **Abordagem:** adicionar `--games-root`, escanear manifestos e mostrar jogos
na Home, mas sem permitir launch ainda.
- **Pro:** baixa complexidade; prova descoberta/catalogo local.
- **Contra:** nao entrega o objetivo principal de carregar jogo pela Home.
- **Manutenibilidade:** boa, mas valor funcional limitado.
### Opcao B - Home lista biblioteca e carrega Game quando nao ha Game ativo
- **Abordagem:** adicionar `--games-root`, escanear cartuchos locais, renderizar
lista simples na Home e permitir clique para carregar um Game via
`LoadCartridge`. A primeira versao cobre Home inicial/sem Game residente.
- **Pro:** entrega o fluxo desejado sem abrir troca completa entre jogos.
- **Contra:** exige passar biblioteca/acao selecionada entre host, Hub,
firmware e loader.
- **Manutenibilidade:** boa se a fronteira ficar clara: biblioteca descobre,
Hub escolhe, firmware carrega.
### Opcao C - Biblioteca mais troca completa entre jogos
- **Abordagem:** Home lista biblioteca e tambem permite `Game A -> Home ->
Game B` ja no primeiro passo.
- **Pro:** cobre a experiencia final.
- **Contra:** mistura biblioteca com pausa, fechamento, cleanup e falha de load;
depende de `AGD-0041` e `AGD-0044`.
- **Manutenibilidade:** baixa para v1.
## Sugestao / Recomendacao
Recomendo a Opcao B.
O v1 deve permitir:
- host recebe `--games-root <dir>`;
- o SO/Hub recebe uma lista de cartuchos descobertos;
- a Home mostra uma lista simples/clicavel de jogos;
- clicar em um Game carrega o cartucho via firmware `LoadCartridge`;
- boot direto por `--run <cart>` continua separado e intacto;
- nenhum guest/app chama `run_cart`;
- o escopo v1 acontece na Home inicial; retorno de Game para Home fica para
`AGD-0041`, e troca `Game A -> Home -> Game B` fica para `AGD-0044`.
Detalhes aceitos para v1:
- scan apenas de subdiretorios imediatos;
- somente cartuchos `app_mode: Game`;
- `.pmc` fica para futuro;
- cartuchos invalidos sao logados e omitidos da lista;
- o modelo interno deve ser uma entry de biblioteca expansivel, nao apenas um
summary de UI. A entry pode manter o manifest carregado em memoria, path
interno necessario para launch e metadados operacionais como instante de
descoberta/instalacao. A UI v1 mostra apenas `title`, `app_id` e
`app_version`, mas futuros metadados ingeridos pela biblioteca poderao ser
usados pelo catalogo e pela propria UI;
- clique carrega imediatamente, sem confirmacao;
- falha de load volta para Home e registra log/erro.
Essa agenda deve produzir a alternativa correta ao `run_cart` userland: uma
acao de sistema, iniciada pela Home, que carrega cartucho escolhido pelo usuario
a partir de uma biblioteca local.
## Perguntas em Aberto
- [x] O argumento deve se chamar `--games-root`.
- [x] A biblioteca deve escanear apenas subdiretorios imediatos.
- [x] A listagem v1 deve incluir apenas `app_mode: Game`.
- [x] O scan deve logar cartuchos invalidos e omiti-los da lista.
- [x] O Hub/SystemOS deve receber uma entry de biblioteca expansivel, capaz de
manter o manifest carregado, path interno para launch e metadados
operacionais como timestamp de descoberta/instalacao. A UI v1 so precisa
mostrar `title`, `app_id` e `app_version`.
- [x] O clique deve carregar imediatamente, sem confirmacao.
- [x] Se um cartucho falha ao carregar, o sistema volta para Home e registra
erro/log.
- [x] Retorno de Game para Home nao pertence a esta agenda; fica para
`AGD-0041`.
- [x] O teste minimo deve provar o fluxo `games-root -> Home list -> click ->
LoadCartridge -> GameRunning`?
## Criterio para Encerrar
A agenda pode virar decisao quando estiver claro:
- nome e semantica do argumento de host para root da biblioteca;
- escopo do scan e metadados minimos;
- fronteira entre biblioteca, Hub, firmware e loader;
- politica v1 para cartuchos invalidos;
- regra v1 para launch quando nao ha Game ativo;
- fronteira explicita com `AGD-0041` e `AGD-0044`;
- testes minimos para discovery e launch pela Home.
## Discussao
- 2026-07-03: Agenda criada como continuacao da `DSC-0004` apos a `DEC-0035`.
A decisao anterior removeu `run_cart` userland; esta agenda define o caminho
correto para o SO/Home carregar jogos a partir de uma biblioteca local.
- 2026-07-03: Respostas aceitas: usar `--games-root`, escanear apenas
subdiretorios imediatos, listar somente Games, deixar `.pmc` e outros apps
para depois, logar/omitir invalidos, usar summary com `title`, `app_id` e
`app_version`, carregar imediatamente no clique, e deixar retorno para Home
sob responsabilidade da `AGD-0041`.
- 2026-07-03: Modelo de dados refinado: a biblioteca deve produzir entries
expansíveis, nao somente summaries de UI. Cada entry pode manter manifest em
memoria, path interno de launch e metadados operacionais como timestamp de
descoberta/instalacao; a UI v1 escolhe quais campos mostrar, mas o modelo
deve permitir que metadados futuros sejam ingeridos e usados pelo catalogo/UI.

View File

@ -1,156 +0,0 @@
---
id: DEC-0036
ticket: system-run-cart
title: SystemOS Games Root and Home Game Launch
status: accepted
created: 2026-07-03
ref_agenda: AGD-0045
tags: []
---
## Status
Accepted.
## Contexto
`DEC-0035` removed `system.run_cart` from the userland guest ABI and preserved
direct host/CLI/debug cartridge boot. That decision intentionally did not
deliver the Home/SO product flow: pointing PROMETEU at a local games directory,
listing available games in Home, and launching a selected game by user action.
This decision defines the first system-owned replacement for userland
`run_cart`: a local games-root library discovered by the host/SystemOS and
exposed through a simple Home UI.
## Decisao
PROMETEU MUST support a host-provided games library root through
`--games-root <dir>`.
The games root is a directory containing game cartridge directories as immediate
children. V1 MUST scan only immediate child directories. Recursive discovery is
out of scope.
The v1 games library MUST include only cartridges whose manifest declares
`app_mode: Game`. Shell/System apps, `.pmc` packages, remote catalogs,
marketplace/distribution metadata, rich icons, search, and non-game apps are out
of scope.
The library MUST produce expandable internal entries, not UI-only summaries.
Each entry MUST retain enough internal data to launch the cartridge and to grow
as a catalog model. At minimum, each entry MUST include:
- loaded manifest data;
- `title`;
- `app_id`;
- `app_version`;
- internal cartridge path;
- operational discovery metadata, including a timestamp or equivalent discovery
marker.
The Home UI v1 SHOULD display only `title`, `app_id`, and `app_version`. It MAY
hide path and operational metadata.
Invalid cartridge candidates MUST be logged and omitted from the Home game list.
Selecting a listed Game in Home MUST immediately request a system-owned launch
through firmware/SystemOS, resulting in `LoadCartridge` for that cartridge. This
MUST NOT use a guest syscall and MUST NOT reintroduce userland `run_cart`.
If launch fails, the machine MUST return to or remain in Home and record an
error/log. A polished error UI is out of scope.
Booting directly with `--run <cart>` MUST remain separate and unchanged.
Returning from a running Game to Home is outside this decision and belongs to
`AGD-0041`. Switching from `Game A -> Home -> Game B` after a game is already
active belongs to `DSC-0043 / AGD-0044`.
## Rationale
The previous `run_cart` surface was wrong because it made cartridge launch look
like an app/userland capability. The desired behavior is still valid, but the
authority must live in the system: Home presents available games and the
firmware/SystemOS loads the selected cartridge.
Using `--games-root` keeps the v1 product model honest: this is a local game
library, not a general app root. Other app types can be introduced later without
forcing the first launcher model to pretend it is a full marketplace.
Immediate child scanning keeps discovery deterministic and testable. `.pmc` and
recursive layouts can be added after the directory-cartridge path is proven.
An expandable entry model avoids prematurely freezing the UI shape as the data
model. The UI is intentionally simple, but the catalog model needs room for
future metadata such as package origin, installation/discovery timestamps, rich
presentation fields, and packaged cartridge details.
## Invariantes / Contrato
- `--games-root <dir>` is the v1 host argument for a local games library.
- The games root is Game-only in v1.
- Discovery scans immediate child directories only.
- Directory candidates without valid Game cartridge metadata are logged and
omitted.
- Library entries are internal catalog records, not direct UI DTOs.
- The UI v1 displays a simple clickable list and may show only `title`,
`app_id`, and `app_version`.
- The internal entry retains cartridge path and loaded manifest data for launch.
- Home selection is a system action that enters firmware/SystemOS loading. It is
not a guest syscall.
- `--run <cart>` direct boot remains independent from `--games-root`.
- Return-to-Home and game-to-game switching are not implemented by this
decision.
## Impactos
- **Host:** add a `--games-root <dir>` argument and pass the resolved root into
runtime/firmware/SystemOS initialization.
- **SystemOS / Hub:** add a local game library model and expose entries to Home.
Home must render a minimal clickable list and emit a system-owned launch
action for a selected entry.
- **Firmware:** consume the Home launch action and transition to
`LoadCartridge` with the selected cartridge path.
- **Loader:** continue to validate complete directory cartridges. Discovery may
read manifest metadata, but full launch still uses the existing loader.
- **Runtime / VM:** no userland ABI is added. No guest syscall participates in
launch.
- **Specs / Docs:** document `--games-root`, Game-only v1 discovery, and the
distinction between direct boot, games library launch, and future game
switching.
- **Tests:** cover discovery, invalid omission/logging, Home action emission,
and the end-to-end path from games root selection to `GameRunning`.
## Alternativas Descartadas
- **List only, no launch:** rejected because it does not satisfy the product
goal of starting games from Home.
- **General app root:** rejected for v1 because Shell/System apps need separate
lifecycle and UI contracts.
- **Recursive discovery:** rejected for v1 to keep semantics deterministic.
- **`.pmc` discovery:** rejected for v1 because packed cartridge loading is a
separate open agenda.
- **Game-to-game switch now:** rejected because it depends on foreground and
cartridge-switch orchestration work in `AGD-0041` and `AGD-0044`.
## Referencias
- Source agenda: `AGD-0045`
- Userland run-cart removal: `DEC-0035`
- Foreground/Home return scope: `AGD-0041`
- Future cartridge switch orchestration: `DSC-0043 / AGD-0044`
## Propagacao Necessaria
- Add or update runtime specs for games-root discovery and Home launch.
- Add host CLI argument plumbing for `--games-root`.
- Add a catalog/library entry model.
- Add Hub/Home list rendering and click handling.
- Add firmware/SystemOS action routing to `LoadCartridge`.
- Add tests for discovery, invalid candidates, action emission, and
`games-root -> Home click -> GameRunning`.
## Revision Log
- 2026-07-03: Initial draft from `AGD-0045`.

View File

@ -1,103 +0,0 @@
---
id: PLN-0132
ticket: system-run-cart
title: Specify Games Root Home Launch Contract
status: done
created: 2026-07-03
ref_decisions: [DEC-0036]
tags: []
---
## Briefing
`DEC-0036` establishes a new system-owned game library launch path:
the host receives `--games-root <dir>`, SystemOS/Home lists valid Game
directory cartridges from that root, and selecting one starts the cartridge
through firmware loading rather than a guest syscall.
This plan updates the normative specs before code is changed.
## Objective
Document the v1 games-root and Home launch contract in the canonical runtime
specs so implementation plans cannot drift back into userland `run_cart` or
general app-library semantics.
## Dependencies
- Source decision: `DEC-0036`.
- Prior decision: `DEC-0035`, which removed userland `system.run_cart` and
preserved direct `--run` boot.
- This plan must be completed before `PLN-0133`, `PLN-0134`, and `PLN-0135`.
## Scope
- Update the runtime specs to define `--games-root <dir>` as the v1 local games
library root.
- Specify that discovery scans only immediate child directories.
- Specify that v1 library discovery includes only valid directory cartridges
with `app_mode: Game`.
- Specify that `.pmc`, recursive discovery, Shell/System apps, marketplace
metadata, rich presentation, search, and non-game apps are out of scope.
- Specify the internal library entry contract: loaded manifest data, `title`,
`app_id`, `app_version`, internal cartridge path, and discovery metadata.
- Specify that Home v1 may display only `title`, `app_id`, and `app_version`.
- Specify that selecting a Home game emits a system-owned launch request that
transitions through firmware/SystemOS into `LoadCartridge`.
- Specify that invalid candidates are logged and omitted.
- Specify that launch failure remains or returns to Home and logs the failure.
- Reaffirm that direct `--run <cart>` boot remains independent and unchanged.
## Non-Goals
- No Rust implementation.
- No Home UI changes.
- No `.pmc` discovery or packaged-cartridge spec changes.
- No recursive library layout.
- No return-to-Home behavior for a running Game.
- No Game A -> Home -> Game B orchestration.
- No guest syscall or userland ABI addition.
## Execution Method
1. Update [docs/specs/runtime/14-boot-profiles.md](/Users/niltonconstantino/personal/workspace.personal/intrepid/prometeu/runtime/docs/specs/runtime/14-boot-profiles.md) with:
- direct `--run` boot remaining a single-cartridge boot profile;
- `--games-root <dir>` as a SystemOS/Home library profile;
- the distinction between direct boot, Home launch, and future game-switch
orchestration.
2. Update [docs/specs/runtime/12-firmware-pos-and-prometeuhub.md](/Users/niltonconstantino/personal/workspace.personal/intrepid/prometeu/runtime/docs/specs/runtime/12-firmware-pos-and-prometeuhub.md) with:
- Home's responsibility to display the local games library;
- the system-owned launch action boundary;
- failure handling that leaves the machine in Home and records an error.
3. Update [docs/specs/runtime/13-cartridge.md](/Users/niltonconstantino/personal/workspace.personal/intrepid/prometeu/runtime/docs/specs/runtime/13-cartridge.md) with:
- directory-cartridge discovery requirements for library candidates;
- Game-only filtering by manifest `app_mode`;
- invalid candidate omission and diagnostics.
4. Update [docs/specs/runtime/16-host-abi-and-syscalls.md](/Users/niltonconstantino/personal/workspace.personal/intrepid/prometeu/runtime/docs/specs/runtime/16-host-abi-and-syscalls.md) only if needed to reinforce that no guest syscall owns cartridge launch.
5. Keep all spec text in English.
## Acceptance Criteria
- The specs define `--games-root <dir>` and do not describe it as a generic app
root.
- The specs state that v1 scans immediate child directories only.
- The specs state that only valid Game directory cartridges enter the Home list.
- The specs state that Home launch is system-owned and enters `LoadCartridge`.
- The specs preserve `--run <cart>` as a separate direct boot path.
- The specs explicitly exclude `.pmc`, recursive discovery, return-to-Home, and
game-switch orchestration from this implementation slice.
- No spec reintroduces userland `run_cart`.
## Tests
- Run `discussion validate`.
- Run targeted text checks for `--games-root`, `LoadCartridge`, and absence of
`system.run_cart` as an active public launch mechanism in edited specs.
## Affected Artifacts
- `docs/specs/runtime/12-firmware-pos-and-prometeuhub.md`
- `docs/specs/runtime/13-cartridge.md`
- `docs/specs/runtime/14-boot-profiles.md`
- `docs/specs/runtime/16-host-abi-and-syscalls.md`
- `discussion/workflow/plans/PLN-0132-specify-games-root-home-launch-contract.md`

View File

@ -1,118 +0,0 @@
---
id: PLN-0133
ticket: system-run-cart
title: Implement Games Root Library Discovery
status: done
created: 2026-07-03
ref_decisions: [DEC-0036]
tags: []
---
## Briefing
`DEC-0036` requires a host-provided games root and an expandable internal
library model before Home can render or launch games. This plan implements the
library discovery and host plumbing only; UI launch wiring is handled by
`PLN-0134`.
## Objective
Add a tested games-root discovery model that scans immediate child directory
cartridges, filters to valid Game manifests, records diagnostics for invalid
candidates, and carries enough metadata for Home rendering and later launch.
## Dependencies
- Source decision: `DEC-0036`.
- `PLN-0132` should be completed first so code follows the documented contract.
- Existing cartridge manifest and directory loader behavior in the console
crates.
- Existing host CLI and `HostRunner` boot setup.
## Scope
- Add `--games-root <PATH>` to the desktop host CLI.
- Pass the optional games root into the host runner / firmware initialization
path without changing direct `--run` or `--debug` boot behavior.
- Add a SystemOS-owned games library model for directory cartridge discovery.
- Scan only immediate child directories of the root.
- Read and retain manifest data for each valid candidate.
- Include only candidates whose manifest declares `app_mode: Game`.
- Retain internal cartridge path and operational discovery metadata on each
entry.
- Emit diagnostics for invalid, unreadable, or non-Game candidates and omit
them from the returned entries.
- Keep discovery independent from full cartridge launch: discovery reads
metadata; launch still uses the existing loader in `PLN-0134`.
## Non-Goals
- No Home list rendering.
- No click handling or `LoadCartridge` transition.
- No `.pmc` discovery.
- No recursive scan.
- No Shell/System app catalog.
- No marketplace metadata, icons, search, sorting UI, or polished errors.
- No new guest syscall.
## Execution Method
1. Introduce a library/discovery module in the SystemOS side, preferably under
`crates/console/prometeu-system/src/services/` unless the existing module
layout has a more local owner.
2. Define an internal entry type with at least:
- loaded cartridge manifest data;
- `title`;
- `app_id`;
- `app_version`;
- internal cartridge path;
- discovery metadata, using `SystemTime` or another explicit discovery
marker.
3. Define discovery diagnostics that can be logged by the caller and asserted in
tests.
4. Implement a scanner that:
- accepts an optional root path;
- returns an empty library when no root is configured;
- iterates only immediate child directories;
- parses `manifest.json` using structured manifest types, not ad hoc string
matching;
- filters to `app_mode: Game`;
- sorts entries deterministically for stable Home presentation and tests.
5. Add `--games-root <PATH>` to
[crates/host/prometeu-host-desktop-winit/src/lib.rs](/Users/niltonconstantino/personal/workspace.personal/intrepid/prometeu/runtime/crates/host/prometeu-host-desktop-winit/src/lib.rs)
and pass the path into
[crates/host/prometeu-host-desktop-winit/src/runner.rs](/Users/niltonconstantino/personal/workspace.personal/intrepid/prometeu/runtime/crates/host/prometeu-host-desktop-winit/src/runner.rs).
6. Store or expose the discovered library to firmware/SystemOS in a way that
`PLN-0134` can consume without re-scanning inside the Home click path.
7. Add focused unit tests using temporary cartridge roots with:
- one valid Game directory cartridge;
- one valid non-Game cartridge;
- one invalid directory;
- one nested directory that must not be discovered.
## Acceptance Criteria
- `--games-root <PATH>` is accepted by the desktop host CLI.
- Absence of `--games-root` leaves existing Hub boot behavior unchanged.
- Direct `--run <cart>` and `--debug <cart>` behavior remains unchanged.
- Discovery returns only immediate valid Game directory cartridges.
- Each library entry retains manifest data, path, title, app id, app version,
and discovery metadata.
- Invalid candidates are represented in diagnostics and excluded from entries.
- Discovery does not fully load or boot cartridge programs.
## Tests
- Add and run focused games-library discovery tests in the owning console crate.
- Run `cargo test -p prometeu-system` if the library lives in
`prometeu-system`.
- Run `cargo test -p prometeu-host-desktop-winit` for CLI/runner plumbing.
- Run `discussion validate`.
## Affected Artifacts
- `crates/console/prometeu-system/src/services/`
- `crates/console/prometeu-system/src/lib.rs` or module exports as needed
- `crates/host/prometeu-host-desktop-winit/src/lib.rs`
- `crates/host/prometeu-host-desktop-winit/src/runner.rs`
- `discussion/workflow/plans/PLN-0133-implement-games-root-library-discovery.md`

View File

@ -1,104 +0,0 @@
---
id: PLN-0134
ticket: system-run-cart
title: Wire Home Game List Launch Flow
status: done
created: 2026-07-03
ref_decisions: [DEC-0036]
tags: []
---
## Briefing
After `PLN-0133`, SystemOS can discover a local Game library but Home still
does not present or launch those entries. This plan wires the discovered
library into Prometeu Hub/Home and routes a selected game to firmware
`LoadCartridge`.
## Objective
Make Home display a minimal clickable games list and launch the selected Game
through a system-owned firmware/SystemOS path, without reintroducing userland
`run_cart`.
## Dependencies
- Source decision: `DEC-0036`.
- `PLN-0132` for documented contract.
- `PLN-0133` for `--games-root` plumbing and the internal library entry model.
- Existing Prometeu Hub Home profile and firmware state transitions.
## Scope
- Provide the discovered games library to Prometeu Hub/Home.
- Render a minimal Home list showing `title`, `app_id`, and `app_version`.
- Add Home hit-testing/click handling for game entries.
- Extend the system profile action model with a system-owned game launch action.
- Handle that action in firmware/SystemOS by loading the selected cartridge via
the existing cartridge loader and entering `LoadCartridge`.
- On load failure, log/record the error and keep or return the machine to Home.
- Preserve existing native shell launch behavior.
## Non-Goals
- No polished launcher UI.
- No icons, screenshots, search, filtering, or marketplace metadata.
- No return-to-Home while a Game is running.
- No Game A -> Home -> Game B foreground orchestration.
- No `.pmc` launch support.
- No guest syscall.
- No direct-boot behavior changes.
## Execution Method
1. Extend the SystemOS/Hub action type currently represented by
`SystemProfileAction::LaunchNativeShell` with a game-launch action that
carries a stable reference to the selected library entry or cartridge path.
2. Update the Prometeu Hub state in
[crates/console/prometeu-system/src/programs/prometeu_hub.rs](/Users/niltonconstantino/personal/workspace.personal/intrepid/prometeu/runtime/crates/console/prometeu-system/src/programs/prometeu_hub.rs)
or its local modules to accept the discovered game entries.
3. Render the Home games list with stable dimensions and simple clickable rows.
Rows must display only `title`, `app_id`, and `app_version` for v1.
4. Add hit-testing so selecting a row emits the game-launch action immediately.
5. Update
[crates/console/prometeu-firmware/src/firmware/steps/firmware_step_hub_home.rs](/Users/niltonconstantino/personal/workspace.personal/intrepid/prometeu/runtime/crates/console/prometeu-firmware/src/firmware/steps/firmware_step_hub_home.rs)
to consume the new action.
6. In the firmware action handler:
- call the existing cartridge loader for the selected path;
- on success, return `FirmwareState::LoadCartridge(...)`;
- on failure, log/record the error and remain in the Home path.
7. Ensure shell launch still works exactly as before.
8. Add unit or integration tests for:
- Home list presentation data;
- click-to-action emission;
- firmware action handling success;
- firmware action handling failure.
## Acceptance Criteria
- Starting the host with `--games-root <dir>` exposes valid Game entries in
Home.
- The Home list displays `title`, `app_id`, and `app_version`.
- Clicking a listed Game routes through a system action and enters
`LoadCartridge`.
- The launch path does not use a guest syscall and does not mention
`system.run_cart`.
- Invalid or failing launch paths remain in Home and record an error.
- Existing native shell Home actions continue to work.
- Direct `--run` remains separate and unchanged.
## Tests
- Run `cargo test -p prometeu-system` for Hub action and presentation behavior.
- Run `cargo test -p prometeu-firmware` for firmware transition behavior.
- Run `cargo test -p prometeu-host-desktop-winit` if runner integration changes.
- Run `discussion validate`.
## Affected Artifacts
- `crates/console/prometeu-system/src/programs/prometeu_hub.rs`
- `crates/console/prometeu-system/src/services/`
- `crates/console/prometeu-firmware/src/firmware/steps/firmware_step_hub_home.rs`
- `crates/console/prometeu-firmware/src/firmware/firmware.rs`
- `crates/host/prometeu-host-desktop-winit/src/runner.rs`
- `discussion/workflow/plans/PLN-0134-wire-home-game-list-launch-flow.md`

View File

@ -1,99 +0,0 @@
---
id: PLN-0135
ticket: system-run-cart
title: Validate Games Root Launch End To End
status: done
created: 2026-07-03
ref_decisions: [DEC-0036]
tags: []
---
## Briefing
`PLN-0132` through `PLN-0134` specify, discover, display, and launch games
from a local games root. This plan closes the slice by adding end-to-end
validation evidence and manual smoke instructions for the product behavior the
user wants: point the SO at a directory, click a listed game, and boot it.
## Objective
Prove the complete `--games-root -> Home list -> click -> LoadCartridge ->
GameRunning` path while preserving direct `--run` boot and the absence of
userland `run_cart`.
## Dependencies
- Source decision: `DEC-0036`.
- `PLN-0132`, `PLN-0133`, and `PLN-0134` must be complete.
- Existing test cartridge fixtures, especially `test-cartridges/stress-console`.
## Scope
- Add automated integration coverage for the full games-root Home launch path
where the existing host/firmware test seams allow it.
- Add or document a minimal local games-root fixture using existing directory
cartridges.
- Validate invalid-candidate omission at the end-to-end boundary.
- Validate direct `--run` still works after games-root wiring.
- Capture manual smoke-test commands for release-mode functional verification.
## Non-Goals
- No new product UI polish.
- No screenshot automation unless the existing test harness already supports it
cleanly.
- No return-to-Home after a running Game.
- No Game A -> Home -> Game B orchestration.
- No `.pmc` validation.
- No broad performance tuning beyond confirming release-mode smoke behavior.
## Execution Method
1. Add an integration-style firmware or host test that constructs a games root
with a valid Game directory cartridge and boots to Hub/Home with that root.
2. Drive the Home selection path through the same action path used by user
input, not by calling the cartridge loader directly.
3. Assert that the machine reaches `LoadCartridge` or `GameRunning`, depending
on the most stable observable state available in the test harness.
4. Add a negative case with an invalid candidate and assert it is omitted or
reported as a diagnostic without appearing in Home.
5. Add a regression assertion that no public guest syscall named
`system.run_cart` is required by this path.
6. Re-run direct boot tests or add a small regression test proving
`--run test-cartridges/stress-console` remains independent from
`--games-root`.
7. Record manual smoke commands in the relevant spec or developer-facing doc:
- `cargo run --release -p prometeu-host-desktop-winit -- --games-root test-cartridges`
- `cargo run --release -p prometeu-host-desktop-winit -- --run test-cartridges/stress-console`
## Acceptance Criteria
- Automated tests cover a valid games-root Home launch path.
- Automated tests cover invalid candidate omission or diagnostics at the
end-to-end boundary.
- Automated or documented validation proves direct `--run` still works.
- Manual smoke instructions use release mode for realistic interactive speed.
- Validation evidence shows no guest syscall participates in launch.
- `discussion validate` passes.
## Tests
- Run `cargo test -p prometeu-system`.
- Run `cargo test -p prometeu-firmware`.
- Run `cargo test -p prometeu-host-desktop-winit`.
- Run `cargo test -p prometeu-hal syscalls` to keep the removed syscall surface
guarded.
- Manually smoke test:
`cargo run --release -p prometeu-host-desktop-winit -- --games-root test-cartridges`.
- Manually smoke test:
`cargo run --release -p prometeu-host-desktop-winit -- --run test-cartridges/stress-console`.
- Run `discussion validate`.
## Affected Artifacts
- `crates/console/prometeu-system/`
- `crates/console/prometeu-firmware/`
- `crates/host/prometeu-host-desktop-winit/`
- `crates/console/prometeu-hal/src/syscalls/tests.rs`
- Runtime specs or developer docs containing smoke commands
- `discussion/workflow/plans/PLN-0135-validate-games-root-launch-end-to-end.md`

View File

@ -39,10 +39,6 @@ The VM does not own the machine lifecycle. Firmware does.
`Hub`, `Task(TaskId)`, and `Overlay`.
- **Shell task window**: a `WindowManager` window whose owner is
`WindowOwner::Task(TaskId)`.
- **Games root**: a host-provided local directory used by Hub/Home to discover
Game directory cartridges.
- **Library entry**: an internal catalog record retained by Hub/SystemOS for a
discovered cartridge.
## 3 POS Responsibilities
@ -69,20 +65,9 @@ PrometeuHub is responsible for:
- reading cartridge metadata needed for launch decisions;
- deciding launch behavior based on `AppMode`;
- managing the system window surface for system-mode apps.
- presenting the host-provided local games library when `--games-root <dir>` is
configured;
- emitting system-owned launch actions for selected Home entries.
The Hub does not execute bytecode directly. It always delegates execution setup to POS.
For v1, the local games library is Game-only. Hub/Home must not expose Shell or
System cartridges from the games root. The internal library entry must retain
the loaded manifest data, `title`, `app_id`, `app_version`, the cartridge path,
and discovery metadata such as a timestamp or equivalent discovery marker.
The Home UI may display only `title`, `app_id`, and `app_version`. Path and
operational metadata may remain internal.
## 5 App Modes
### Game
@ -169,16 +154,6 @@ If VM initialization fails, firmware transitions to the crash path.
POS selects the cartridge and its execution context, but the cartridge's initial callable is not chosen by firmware metadata. Execution starts from the cartridge boot protocol defined in [`13-cartridge.md`](13-cartridge.md), currently `func_id = 0`.
When Home launches a discovered Game entry, the request is a system-owned action
from PrometeuHub to POS/firmware. Firmware must load the selected cartridge
through the normal cartridge loader and transition to `LoadCartridge` on
success. This path must not use a guest syscall and must not reintroduce
userland `run_cart`.
If the selected cartridge cannot be loaded, firmware must leave or return the
machine in the Hub/Home flow and record the failure through diagnostics or
logging. A polished Home error surface is not required by v1.
## 8 Firmware States
The current firmware state model includes:

View File

@ -175,30 +175,10 @@ Runtime loading policy:
This is the working runtime/dev form used by the current loader.
Directory cartridges are also the only form discovered by the v1 local Home
games library. When a host provides `--games-root <dir>`, discovery scans only
immediate child directories under that root. Each child directory is a candidate
cartridge.
For the v1 Home games library:
- a candidate must have a valid `manifest.json`;
- the manifest must declare `app_mode: "Game"`;
- the library retains the loaded manifest data, `title`, `app_id`,
`app_version`, the internal cartridge path, and discovery metadata;
- invalid candidates are logged or reported as diagnostics and omitted from the
Home list;
- valid non-Game cartridges are omitted from the Game library.
Discovery reads metadata for cataloging. It does not replace the normal
cartridge loader used when firmware starts the selected cartridge.
### Packaged `.pmc` form
This form is recognized conceptually by the loader boundary, but its actual load path is not implemented yet.
Packaged `.pmc` cartridges are not discovered by the v1 Home games library.
The cartridge spec therefore distinguishes:
- supported current load form;

View File

@ -18,9 +18,6 @@ enum BootTarget {
This is a firmware/host orchestration contract, not a guest-visible ABI.
The local Home games library is not a separate firmware boot target. It is host
configuration consumed by the Hub profile after boot.
## 2 Boot Modes
### Hub
@ -30,10 +27,6 @@ When the boot target is `Hub`:
- firmware boots into the Hub flow;
- no cartridge is auto-launched.
If the host also provides `--games-root <dir>`, the Hub may discover and render
valid Game cartridges from that root. Selecting one is a system-owned Home
action that requests cartridge loading after the Hub is already running.
### Cartridge
When the boot target is `Cartridge`:
@ -66,7 +59,6 @@ Typical host-facing boot intents are:
- default start -> enter Hub;
- run cartridge -> boot with cartridge target;
- debug cartridge -> boot with cartridge target plus debug mode parameters.
- games-root start -> enter Hub with a local Game library for Home.
The CLI is an entry surface for boot target selection; the firmware contract remains the same underneath.
@ -75,30 +67,6 @@ direct cartridge boot surfaces. Direct boot is not requested by guest bytecode
through a `system.run_cart` syscall or any other app-callable cartridge boot
ABI.
`--run <cart>` and `--debug <cart>` are direct cartridge boot profiles. They
select one cartridge before normal Hub/Home interaction and remain independent
from the local library.
`--games-root <dir>` is a Hub/Home library configuration. It does not
auto-launch a cartridge and does not create a guest-visible launch API.
The v1 games root contract is:
- the root contains directory cartridges as immediate child directories;
- recursive discovery is not performed;
- only valid cartridges whose manifest declares `app_mode: "Game"` are listed;
- Shell/System apps, packaged `.pmc` cartridges, remote catalogs, marketplace
metadata, search, icons, and rich presentation are outside this profile;
- invalid candidates are logged and omitted from the Home list;
- Home entries may display only `title`, `app_id`, and `app_version`;
- selecting a Home entry requests firmware/SystemOS loading for that cartridge
and transitions through `LoadCartridge`;
- launch failure leaves or returns the machine to Home and records an error.
Game-to-game switching after a game is already active is not part of this boot
profile. That orchestration belongs to the foreground/home and cartridge switch
contracts.
## 5 Firmware State Relationship
Boot target selection feeds into firmware states such as:
@ -127,22 +95,7 @@ When booting a cartridge in debug mode:
Debug mode changes orchestration, not the cartridge contract.
## 7 Smoke Validation
The local Home library path should be smoke tested in release mode for realistic
interactive speed:
```sh
cargo run --release -p prometeu-host-desktop-winit -- --games-root test-cartridges
```
Direct single-cartridge boot remains a separate validation path:
```sh
cargo run --release -p prometeu-host-desktop-winit -- --run test-cartridges/stress-console
```
## 8 Relationship to Other Specs
## 7 Relationship to Other Specs
- [`12-firmware-pos-and-prometeuhub.md`](12-firmware-pos-and-prometeuhub.md) defines the firmware state machine that consumes boot targets.
- [`13-cartridge.md`](13-cartridge.md) defines cartridge structure.