4.1 KiB
4.1 KiB
| id | ticket | title | status | created | ref_decisions | tags | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| PLN-0057 | system-os-lifecycle-process-task-contract | Lifecycle Tests and Invariants | done | 2026-05-15 |
|
|
Briefing
Add focused test coverage and invariant checks for the lifecycle contract
introduced by PLN-0055 and consumed by PLN-0056.
Source Decisions
DEC-0025: first-wave lifecycle maps task states to process states throughSystemOSand keepsBackgroundoutside the public lifecycle contract.
Target
Make the lifecycle contract executable through unit tests and regression tests, without expanding scope into background execution, UI behavior, or service ownership.
Scope
- Add
SystemOSunit tests for all first-wave lifecycle operations. - Add negative tests for missing task, missing process, and invalid transition.
- Add firmware-level regression coverage for lifecycle delegation where the existing test harness can observe it.
- Keep manager tests focused on local storage and simple transitions.
Out of Scope
- End-to-end UX tests for suspend/resume.
- Hub/Home navigation after lifecycle changes.
- Background services.
- Docking.
- App switching.
- Diagnostics persistence.
- WindowManager behavior changes.
Execution Plan
-
Add core lifecycle mapping tests.
- Target file:
crates/console/prometeu-system/src/os/system_os.rsor a dedicatedostest module following existing crate style. - Verify:
set_foreground_task: task becomesForeground, process becomesRunning.suspend_task: task becomesSuspended, process becomesSuspended.resume_task: suspended task becomesForeground, process becomesRunning.close_task: task becomesClosed, process becomesStopped.crash_task: task becomesCrashed, process becomesCrashed.
- Target file:
-
Add error tests.
- Verify missing task returns
LifecycleError::TaskNotFound. - Verify a task whose process no longer exists returns
LifecycleError::ProcessNotFound. - Verify invalid resume from non-suspended task returns
LifecycleError::InvalidTransitionwith operationResume.
- Verify missing task returns
-
Add non-removal tests.
- Verify
close_taskleaves the closed task available throughTaskManager::get. - Verify
close_taskleaves the stopped process available throughProcessManager::get. - Do not call
remove_closedorremove_stoppedas part of lifecycle API tests.
- Verify
-
Add background exclusion tests.
- Assert there is no
SystemOS::background_taskAPI added by this wave. - Keep any existing
TaskState::Backgroundbehavior in manager-level tests documented as manager behavior, not first-wave lifecycle semantics.
- Assert there is no
-
Add firmware regression tests after
PLN-0056.- Target file:
crates/console/prometeu-firmware/src/firmware/firmware.rsor the relevant step test module. - Verify game launch still enters
GameRunningStep. - Verify shell launch still enters
SystemRunningStep. - Verify a game crash path marks the active task as crashed when the test
harness can observe
ctx.os.task_manager.
- Target file:
Acceptance Criteria
- Every lifecycle method from
DEC-0025has a positiveSystemOStest. - Missing task and missing process return typed lifecycle errors.
- Invalid resume transition is covered by a test.
close_taskis tested as mark-only, not removal.- No test encodes
Backgroundas a normative first-wave lifecycle operation. - Firmware regression tests still pass for game and shell launch.
Tests / Validation
- Run
cargo test -p prometeu-system. - Run
cargo test -p prometeu-firmware. - If workspace-level tests are practical after these changes, run the relevant workspace command used by this repository.
Risks
- Some negative tests may require test-only helpers to create an inconsistent task/process relationship. Prefer narrow test fixtures over making corruption APIs public.
- Compile-time absence of
background_taskmay not be directly testable without compile-fail infrastructure. In that case, validate it by code review and keep runtime tests focused on the exposed first-wave methods.