prometeu-runtime/discussion/workflow/plans/PLN-0104-migrate-vm-runtime-hostcontext-to-platform.md

80 lines
2.2 KiB
Markdown

---
id: PLN-0104
ticket: real-render-worker-establishment
title: Migrate VM Runtime HostContext to Platform Services
status: done
created: 2026-06-06
completed:
ref_decisions: [DEC-0032]
tags: [runtime, vm, platform, hostcontext]
---
## Objective
Change VM runtime execution from receiving `&mut dyn HardwareBridge` to receiving explicit platform services.
## Background
`HostContext` currently carries `Option<&mut dyn HardwareBridge>`. That shape lets every syscall see the entire bridge. `DEC-0032` requires explicit services instead.
## Scope
### Included
- Introduce a platform-aware `HostContext` shape.
- Migrate VM runtime tick/dispatch to use platform services.
- Preserve VM tests and fault behavior.
### Excluded
- Do not migrate firmware/Hub in this plan.
- Do not remove `HardwareBridge` yet.
## Execution Steps
### Step 1 - Add platform host context
**What:** Extend or replace `HostContext` with platform-service access.
**How:** Add methods for required VM syscall domains instead of `require_hw()`.
**File(s):** `crates/console/prometeu-hal/src/host_context.rs`.
### Step 2 - Migrate runtime tick
**What:** Tick uses platform services for begin-frame, composer frame closure, render sink, audio clear, and telemetry reads.
**How:** Replace direct bridge access with explicit facade calls.
**File(s):** `crates/console/prometeu-system/src/services/vm_runtime/tick.rs`.
### Step 3 - Migrate dispatch
**What:** VM syscall dispatch uses explicit facade methods.
**How:** Remove `ctx.require_hw()` as the central dispatch dependency.
**File(s):** `crates/console/prometeu-system/src/services/vm_runtime/dispatch.rs`.
## Test Requirements
### Unit Tests
- VM dispatch tests pass with platform context.
### Integration Tests
- `cargo test -p prometeu-system`.
### Manual Verification
- `rg "require_hw|HardwareBridge" vm_runtime` shows no production VM runtime dependency except temporary compatibility adapters explicitly marked.
## Acceptance Criteria
- [ ] VM runtime dispatch no longer depends on the monolithic bridge.
- [ ] Tick uses explicit platform services.
- [ ] Existing VM fault behavior remains unchanged.
## Dependencies
- `PLN-0103`.
## Risks
- `HostContext` is used in VM unit tests. Migration must keep no-hardware test contexts ergonomic.