prometeu-runtime/discussion/workflow/plans/PLN-0114-add-deterministic-render-worker-test-harness.md
2026-06-15 16:11:34 +01:00

79 lines
2.6 KiB
Markdown

---
id: PLN-0114
ticket: real-render-worker-establishment
title: Add Deterministic Render Worker Test Harness
status: done
created: 2026-06-15
completed:
ref_decisions: [DEC-0033]
tags: [runtime, renderer, worker, tests, concurrency]
---
## Briefing
`DEC-0033` requires worker behavior to be proven without a native window and without fragile sleeps. This plan creates reusable deterministic test fixtures for the remaining worker plans.
## Decisions de Origem
- `DEC-0033`: Real Render Worker Contract.
## Alvo
Add a fake backend and synchronization harness capable of blocking render at controlled points, observing publication, and proving non-blocking VM/producer behavior.
## Escopo
- Create test-only synchronization helpers using barriers/condvars.
- Create a fake render backend shape that can block/fail/publish deterministically.
- Add helper functions for constructing owned render submissions and frames.
- Reuse the harness in later worker tests.
## Fora de Escopo
- No production worker lifecycle.
- No desktop host integration.
- No real GFX rasterization.
## Plano de Execucao
### Step 1 - Add test support module
**What:** Introduce deterministic worker test fixtures.
**How:** Add test-only helpers under `prometeu-system` worker tests or a local test module.
**File(s):** `crates/console/prometeu-system/src/services/vm_runtime/*`.
### Step 2 - Add controllable fake backend
**What:** Provide backend behavior for tests.
**How:** Fake backend can block at render start, unblock by test signal, return errors, and record published frames.
**File(s):** worker test module.
### Step 3 - Add submission/frame builders
**What:** Make tests concise and consistent.
**How:** Build Game/Shell submissions with explicit frame ids and ownership metadata; build `OwnedRgba8888Frame` fixtures.
**File(s):** worker test module.
### Step 4 - Add initial harness self-tests
**What:** Prove harness itself is deterministic.
**How:** Verify a test can block and release backend render without timing sleeps.
**File(s):** worker test module.
## Criterios de Aceite
- [ ] Tests can block worker backend render using deterministic synchronization.
- [ ] Tests can observe published `OwnedRgba8888Frame` values.
- [ ] Harness can inject backend errors.
- [ ] Harness helpers are scoped to tests or clearly internal.
## Tests / Validacao
- `cargo test -p prometeu-system render_worker`
- `rg "sleep\\(|thread::sleep" crates/console/prometeu-system/src/services/vm_runtime -n`
## Riscos
- Test harness code can become too coupled to implementation internals.
- Overly broad helpers can hide important assertions in later plans.