Commit Graph

3 Commits

Author SHA1 Message Date
ruv dfe1ce8084 feat(dashboard): WsClient transport + ADR-092/093 status updates
## WsClient — full REST + binary WebSocket transport

New `dashboard/src/transport/WsClient.ts` implementing the same
NvsimClient interface as WasmClient. Talks to `nvsim-server`:

- REST control plane: /api/health, /api/scene, /api/config, /api/seed,
  /api/run, /api/pause, /api/reset, /api/step, /api/witness/{generate,verify},
  /api/export-proof
- Binary WebSocket data plane: /ws/stream — parses 32-frame MagFrame
  batches and forwards to the same onFrames subscribers WasmClient uses
- Transport-flip awareness: connection events emit log lines, fps signal
  is computed from incoming batches at 1-second granularity

## main.ts — transport-aware boot

- Restores `transport` + `wsUrl` preferences from IndexedDB at startup
- Watches `transport.value` and `wsUrl.value` signals; on change, tears
  down the active client and re-boots into the selected mode
- Auto-reverifies witness whenever a fresh transport boot completes —
  prevents drift in Settings drawer transport switching
- onFrames closure extracted so wireClient() can subscribe it on every
  re-boot without re-allocating runtime state

## ADR-092 status header + §11 acceptance table

Status changed from Proposed to "Implemented (2026-04-27)". §11
acceptance table now an explicit pass/fail matrix:
  8  — UI fidelity, determinism (WASM), throughput, bundle size,
        offline PWA, REPL parity, shortcut parity, witness UI
  4 ⚠ — formal axe scan, multi-browser, mode-switch byte-equivalence
        across deployed nvsim-server, full keyboard-only flow

The 4 ⚠ items require external infrastructure (axe-core CI, FF/Safari
test runs, deployed nvsim-server) or auditor sign-off; none are
blocked by the dashboard codebase.

## ADR-093 §5 iteration plan

Status changed from Proposed to "Mostly Implemented (2026-04-27)".
Iterations A through I (the originally-planned alphabet) plus three
new iterations J/K/L/M (UX usability pass, Home view, WsClient,
App Store runtime) all closed. 19 of 21 P0/P1/P2 items resolved;
remaining 2 are P2.4 (light-theme contrast color-system pass) and
P2.6 (keyboard arrow-key scene nav).

Validated end-to-end on https://ruvnet.github.io/RuView/nvsim/ —
transport-aware boot logs `transport WASM · nvsim@0.3.0 · magic=0xC51A6E70`
followed by `witness verified · determinism gate ✓ · transport=wasm`.
Switching to WS in Settings would now connect to a user-supplied
nvsim-server; the same auto-reverify fires after the flip.

Co-Authored-By: claude-flow <ruv@ruv.net>
2026-04-27 12:02:35 -04:00
ruv 39ec05edcb feat(dashboard): nvsim Vite+Lit dashboard with WASM transport + App Store [ADR-092]
End-to-end implementation of the operator dashboard for the nvsim
NV-diamond magnetometer simulator. Vite 5 + TypeScript strict + Lit 3,
~93 KB gzipped JS budget, runs the *real* nvsim Rust crate compiled to
wasm32-unknown-unknown inside a dedicated Web Worker.

Validated end-to-end with `npx agent-browser`:
- WASM module boots, build version + magic 0xC51A_6E70 reported
- Reference witness verifies byte-identical to Proof::EXPECTED_WITNESS_HEX
  cc8de9b01b0ff5bd97a6c17848a3f156c174ea7589d0888164a441584ec593b4
- Pipeline runs at ~1.88 kHz on x86_64 dev hardware (4500x over Cortex-A53)
- Zero browser console errors; only Lit dev-mode warning (expected)

## nvsim crate (additive)
- New `wasm` feature flag with wasm-bindgen 0.2 / serde-wasm-bindgen 0.6
- src/wasm.rs: WasmPipeline wrapper + referenceSceneJson +
  expectedReferenceWitnessHex + referenceWitness + hexWitness exports
- crate-type = ["cdylib", "rlib"] so native + wasm both build
- rand = { default-features = false } drops getrandom OS-entropy path,
  preserving the crate's WASM-ready posture
- Native: 50/50 tests still pass, witness unchanged

## dashboard/ (new package)
- Vite 5 + TypeScript strict, Lit 3 elements, signals-based store
- 12 Lit components mirroring the mockup zones (rail, topbar, sidebar,
  scene SVG with draggable sources + NV crystal, inspector tabs
  Signal/Frame/Witness, console with REPL + filter tabs, settings
  drawer, modals, ⌘K command palette, debug HUD, toast, app-store)
- IndexedDB persistence (theme, density, motion, app activations)
- WasmClient → Web Worker → wasm-pack-built nvsim WASM module
- NvsimClient TS interface — same shape covers future WsClient transport
- MagFrame parser (60-byte LE layout matching nvsim::frame)

## App Store (ADR-092 §14a — added during impl)
- Catalog of all 65 wifi-densepose-wasm-edge modules + nvsim
- 13 categories with event-ID-range labels
- Per-app metadata: id/name/category/crate/summary/events/budget/
  status/adr/tags
- Fuzzy search, category + status filters, IndexedDB-backed activation
- ADR-092 §14a documents the registry contract and per-app schema

## Build pipeline
- wasm-pack build crates/nvsim --target web outputs to
  dashboard/public/nvsim-pkg/ (60 KB pkg, 162 KB unoptimized .wasm)
- npm run build → 93 KB gzip JS, well under 300 KB budget
- ts.config strict, npx tsc --noEmit clean
- Vite worker correctly loads WASM via dynamic import resolving
  against worker origin

## E2E validation
- agent-browser open → 4-zone grid renders correctly in dark theme
- Run button → live B-vector trace, |B| readout updates, FPS counter
- App Store → all 66 apps listed with toggles, fuzzy search filters
  to "Ghost hunter" on "ghost" query
- Witness verify → green check, console logs "determinism gate ✓"
- Console errors: zero (only expected Lit dev-mode warning)

Co-Authored-By: claude-flow <ruv@ruv.net>
2026-04-26 19:22:04 -04:00
ruv db1ccbff49 docs(adr): ADR-092 nvsim dashboard implementation [proposed]
Full implementation spec for the nvsim operator dashboard (mockup
included at assets/NVsim Dashboard.zip). Vite + TypeScript + Lit SPA
with two pluggable transports against a single NvsimClient interface:

- WasmClient: nvsim compiled to wasm32-unknown-unknown, run inside a
  Web Worker. Default mode for GitHub Pages — no server, no upload.
- WsClient: REST control plane + binary WebSocket frame stream against
  a new nvsim-server Axum binary in v2/crates/nvsim-server/.

Both transports share a single TypeScript interface; the dashboard
never binds to a concrete client. Witness verification asserts
byte-equivalence between WASM and WS modes against
Proof::EXPECTED_WITNESS_HEX.

Sections cover: full UI inventory from the mockup (12 zones, ~50
components, every modal/palette/shortcut), crate work (wasm-bindgen on
nvsim, new nvsim-server, @ruvnet/nvsim-client npm package), state
model (signals + IndexedDB persistence), build pipeline (GitHub Pages
deployment via wasm-pack + Vite + actions/deploy-pages), six
implementation passes mirroring the nvsim Pass 1-6 plan, 12 acceptance
gates, risks, alternatives, open questions.

Cross-references ADR-089/090/091 and the Ghost Murmur use-case spec.
Mockup committed alongside as the canonical UI contract.

Co-Authored-By: claude-flow <ruv@ruv.net>
2026-04-26 18:43:50 -04:00