# spikes/wasm-phase5 — parity, audit, and performance harness

Phase 5's production exit requires the full network suite to pass on the WASM
worker and performance numbers to be published. The production worker is not in
this branch yet, so this spike builds the Phase 5 harness and records the native
baseline that the WASM worker must match.

Run on `k-uce`:

```bash
bash spikes/wasm-phase5/run_phase5.sh
```

Expected final line:

```text
PHASE5 HARNESS: PASS
```

The harness first runs a throwaway warmup pass to populate the unit cache after
binary rebuilds. The warmup excludes the stateful `site tests tasks` case so it
cannot perturb the measured task-lifecycle check. The measured full-suite and
starter-subset passes then become the gate.

Artifacts are written under `/tmp/uce/wasm-phase5/`:

- `native-network-warmup.json` — throwaway warmup result; allowed to fail on cold
  compile timeouts.
- `native-network.json` — measured full native network suite result. The harness
  fails if fewer than 80 cases run, so an empty or broken suite cannot pass.
- `native-starter.json` — measured starter-focused parity subset. The harness
  fails if fewer than 10 cases run, which protects against a vacuous
  `--match starter` exit gate.
- `site-static-audit.{json,md}` — candidate cross-request/static-state risks in
  `site/` for the §3.2 semantic change audit. By default it scans code-like
  `.uce` and `.h` files only; pass `--include-doc-text` to include `.txt` docs
  as `documentation` severity findings.
- `benchmark.{json,md}` — warmed native baseline for the three Phase 5 budget
  pages. The default is 20 samples per target; use a higher `--samples` value for
  noisy shared-host gate runs if needed:
  - `template-heavy-doc`: `/doc/singlepage.uce`
  - `sqlite-page`: `/demo/sqlite.uce`
  - `component-heavy-starter`: `/examples/uce-starter/?dashboard`

`benchmark.py` also accepts `--wasm-base-url` once a WASM worker endpoint exists.
When provided, it compares WASM medians against the Phase 5 budget of ≤2× native
page latency. Workspace birth and internal component call overhead budgets still
need worker-internal probes; this harness documents the gap rather than faking
those numbers.

A durable informational baseline snapshot is kept in `reports/`. Paired
native/WASM runs still recompute native medians for the actual budget decision.

Current scope:

- Native parity and baseline collection are automated.
- WASM parity/performance comparison is ready but blocked on the production WASM
  worker endpoint.
- The static-state audit is heuristic and intentionally conservative; findings
  must be reviewed by a human before migration work is scheduled.
