4.4 KiB
4.4 KiB
| id | ticket | title | status | created | ref_decisions | tags | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| PLN-0156 | foreground-stack-game-pause-shell-vm-backed | Harden VM Session Lifecycle Error Boundaries | done | 2026-07-05 |
|
|
Briefing
DEC-0038 makes VM session services part of the runtime ownership boundary. Some current session creation paths still use expect for lifecycle failures and missing task/process/session invariants. That is acceptable for short-term scaffolding, but session services should expose typed errors at operational boundaries so callers can choose controlled crash, rejection, or recovery behavior.
Objective
Replace operational expect/panic paths in VM session creation/loading with typed errors and controlled firmware outcomes. Keep internal invariant assertions only where impossible states have already been proven by prior checks.
Dependencies
- Source decision: DEC-0038.
- Builds on PLN-0148 through PLN-0152.
- Can be implemented before or after PLN-0154.
- Should be implemented before broadening VM session scheduling or adding background-capable processes.
Scope
- Add or extend typed errors for session/lifecycle operations:
- lifecycle rejection while creating Game/Shell task;
- missing task for session creation;
- missing process for session creation;
- duplicate session;
- VM-backed session missing during cartridge initialization;
- foreground Shell already exists.
- Convert
SessionsFacade::create_vm_shell_taskto a fallible equivalent and keep an infallible wrapper only for test/setup code if needed. - Convert
create_vm_session_for_taskto avoidexpectfor task/process lookup. - Convert
initialize_session_cartridgeto return typed missing-session errors instead of panicking. - Map session/lifecycle errors into controlled
CrashReportor launch rejection behavior in firmware. - Preserve existing V1 policy:
- one resident Game;
- one foreground Shell;
- no Game-to-Game switching;
- native Shell creates no VM session.
Non-Goals
- Do not change DEC-0038 ownership semantics.
- Do not add background execution.
- Do not redesign the foreground stack.
- Do not hide programmer invariants behind overly broad error swallowing.
Execution Method
- Introduce a
SessionErroror extendVmSessionErrorwith operational cases that cross facade boundaries. - Update
SessionsFacademethods:try_create_vm_game_task;- new
try_create_vm_shell_task; load_vm_cartridge;create_vm_session_for_task;initialize_session_cartridge.
- Update firmware loading paths to map typed session errors into:
- controlled
CrashReport::VmPanicfor unrecoverable internal failures; - logged rejection and no state transition for unsupported lifecycle transitions where appropriate.
- controlled
- Update tests that currently rely on panics or infallible creation.
- Add focused tests for:
- duplicate foreground Shell rejection during VM Shell load;
- missing task/process session creation errors;
- missing VM session during initialization;
- native Shell still creates no VM session.
- Run system, firmware, host tests and clippy.
Acceptance Criteria
- VM session facade operational failures are represented by typed errors.
create_vm_shell_taskhas a fallible path used by production cartridge loading.- VM Shell load does not panic when lifecycle rejects the Shell; it returns a controlled error/outcome.
- Missing task/process/session conditions in session services return typed errors.
- Existing tests for resident Game, native Shell, VM Shell, and Game/Shell coexistence still pass.
- No new broad
unwrap/expectappears in production session/lifecycle paths.
Tests
cargo test -p prometeu-systemcargo test -p prometeu-firmwarecargo test -p prometeu-host-desktop-winitcargo clippy -p prometeu-system -p prometeu-firmware -p prometeu-host-desktop-winit --all-targets -- -D warnings- Add tests for controlled errors from session creation/loading edge cases.
Affected Artifacts
crates/console/prometeu-system/src/os/facades/sessions.rscrates/console/prometeu-system/src/services/vm_session.rscrates/console/prometeu-system/src/os/lifecycle.rscrates/console/prometeu-firmware/src/firmware/firmware_step_load_cartridge.rscrates/console/prometeu-firmware/src/firmware/firmware_step_hub_home.rs- Related system and firmware tests