prometeu-runtime/discussion/workflow/plans/PLN-0116-implement-fake-local-render-backend.md
2026-06-15 16:17:16 +01:00

79 lines
2.7 KiB
Markdown

---
id: PLN-0116
ticket: real-render-worker-establishment
title: Implement Fake Local Render Backend
status: done
created: 2026-06-15
completed:
ref_decisions: [DEC-0033]
tags: [runtime, renderer, worker, backend, drivers]
---
## Briefing
`DEC-0033` requires fake/local backend behavior before desktop integration so worker semantics can be proven without a window.
## Decisions de Origem
- `DEC-0033`: Real Render Worker Contract.
## Alvo
Implement backend contracts that consume `RenderSubmission` plus read-only resources and produce `OwnedRgba8888Frame`.
## Escopo
- Define or finalize a backend trait for worker rendering.
- Add a fake backend for deterministic tests.
- Add a local framebuffer backend that can rasterize through existing driver/GFX logic without exposing mutable `Hardware` as the worker contract.
- Verify output frame ownership and pixels.
## Fora de Escopo
- No desktop upload/present.
- No runtime tick integration.
- No resource mutation policy changes.
## Plano de Execucao
### Step 1 - Define backend trait
**What:** Encode backend consumption contract.
**How:** Trait consumes `RenderSubmission` and read-only resource access and returns `OwnedRgba8888Frame` or `RenderWorkerError`.
**File(s):** HAL if shared, or system if internal; prefer HAL if host/drivers implement it.
### Step 2 - Implement fake backend
**What:** Provide test backend.
**How:** Fake backend returns deterministic frames, can block through harness, and can return typed errors.
**File(s):** system test module or driver test utility.
### Step 3 - Implement local framebuffer backend
**What:** Provide non-window raster backend.
**How:** Use existing GFX rendering internally to turn submissions into `OwnedRgba8888Frame`, but expose only the backend trait and read-only resources.
**File(s):** `prometeu-drivers` rendering modules, possibly a new backend module.
### Step 4 - Add output tests
**What:** Prove frame content and metadata.
**How:** Render simple Game2D and ShellUi submissions and compare `OwnedRgba8888Frame` pixels/metadata.
**File(s):** driver/system tests.
## Criterios de Aceite
- [ ] Backend trait does not expose mutable `Hardware`, `Gfx`, `FrameComposer`, or VM state.
- [ ] Fake backend supports deterministic blocking/error behavior.
- [ ] Local backend produces `OwnedRgba8888Frame`.
- [ ] Game2D and ShellUi submissions can produce frame output without a native window.
## Tests / Validacao
- `cargo test -p prometeu-drivers -p prometeu-system`
- `rg "&mut Hardware|&mut Gfx|FrameComposer" crates/console/prometeu-hal crates/console/prometeu-system/src/services/vm_runtime -n`
## Riscos
- Local backend may be tempted to reuse `Hardware` directly as the public worker contract.
- Resource access gaps may surface when moving from fake to local rasterization.