4.6 KiB
4.6 KiB
| id | ticket | title | status | created | ref_decisions | tags | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| PLN-0055 | system-os-lifecycle-process-task-contract | SystemOS Lifecycle Core API | done | 2026-05-15 |
|
|
Briefing
Implement the first-wave SystemOS lifecycle API required by DEC-0025.
SystemOS becomes the semantic coordinator for TaskState and ProcessState;
TaskManager and ProcessManager remain storage and simple transition
mechanisms.
Source Decisions
DEC-0025:SystemOSis the lifecycle authority for tasks and processes.
Target
Add typed lifecycle operations to prometeu-system without changing firmware
behavior, WindowManager ownership, Hub UI, background services, docking, app
switching, or VM ownership.
Scope
- Add
LifecycleErrorandLifecycleOperationinprometeu-system. - Add lifecycle methods on
SystemOS:set_foreground_task(task_id)suspend_task(task_id)resume_task(task_id)close_task(task_id)crash_task(task_id, report?)
- Coordinate task and process state changes inside
SystemOS. - Preserve
TaskManagerandProcessManageras internal state managers. - Keep
Backgroundreserved and out of public lifecycle semantics.
Out of Scope
- Background semantics.
- Docking.
- Background services.
- App switcher.
- WindowManager migration.
- PrometeuHub redesign.
- Game suspend/resume UX.
- ProcessManager owning VM execution.
- Collection/removal of closed or stopped entities.
Execution Plan
-
Add lifecycle types.
- Create a lifecycle module or colocate the types under
crates/console/prometeu-system/src/os/. - Define
LifecycleOperationwithSetForeground,Suspend,Resume,Close, andCrash. - Define
LifecycleErrorwithTaskNotFound(TaskId),ProcessNotFound(ProcessId), andInvalidTransition { task_id, from, operation }. - Re-export the types through
prometeu-systemonly if the existing public module style requires it.
- Create a lifecycle module or colocate the types under
-
Add the
SystemOScoordination helpers.- Target file:
crates/console/prometeu-system/src/os/system_os.rs. - Resolve the task first through
task_manager. - Extract the task's associated
ProcessId. - Validate that the process exists before mutating state.
- Return typed errors instead of
bool.
- Target file:
-
Implement first-wave operations.
set_foreground_task: calltask_manager.set_foreground(task_id)andprocess_manager.mark_running(process_id).suspend_task: setTaskState::SuspendedandProcessState::Suspended.resume_task: require a suspended task, then setTaskState::ForegroundandProcessState::Running.close_task: setTaskState::ClosedandProcessState::Stopped.crash_task: setTaskState::CrashedandProcessState::Crashed.
-
Keep manager APIs mechanical.
- Target files:
crates/console/prometeu-system/src/services/task/task_manager.rsandcrates/console/prometeu-system/src/services/process/process_manager.rs. - Do not remove existing manager methods in this plan.
- Add only narrow helpers if needed to support the
SystemOSAPI cleanly.
- Target files:
-
Update task creation to use the lifecycle API internally.
- In
SystemOS::create_vm_game_task,create_vm_shell_task, andcreate_native_shell_task, replace direct foreground manager calls withset_foreground_task. - Keep the constructors returning
TaskId; handle impossible internal errors with explicit debug/assert behavior or an internal helper that cannot fail after creation.
- In
Acceptance Criteria
SystemOSexposes all five first-wave lifecycle methods fromDEC-0025.- All five methods coordinate both task and process state.
- Missing task returns
LifecycleError::TaskNotFound. - Missing associated process returns
LifecycleError::ProcessNotFound. - Invalid resume from a non-suspended task returns
InvalidTransition. Backgroundis not exposed through a new lifecycle API.- Closed and stopped entities are not removed by
close_task.
Tests / Validation
- Add or update unit tests in
prometeu-systemfor each lifecycle mapping. - Add tests for missing task, missing process, and invalid resume transition.
- Run the affected Rust test suite for
prometeu-system.
Risks
- Existing direct manager access is public enough that callsites may keep using
it. This plan does not remove those methods; enforcement continues in
PLN-0056. TaskManager::set_foregroundcurrently moves the previous foreground task toBackground. SinceBackgroundis out of first-wave semantics, tests must avoid treating that transition as normative lifecycle policy.