mirror of
https://github.com/ruvnet/RuView
synced 2026-08-06 19:51:43 +00:00
df617145d6
* feat(ADR-262 P3): live RuField surface — RuView sensing speaks RuField on /api/field + /ws/field Wire the P1 `wifi-densepose-rufield` bridge into the live `wifi-densepose-sensing-server` so the governed sensing cycle emits real signed RuField `FieldEvent`s on two additive endpoints. - Cargo: add the `wifi-densepose-rufield` path dep (the single coupling point, ADR-262 §5.4 — no new RuView-internal coupling). - New `src/rufield_surface.rs` (kept out of the 8k-line main.rs): `FieldSurface` holds a dedicated ed25519 `Signer` + a bounded ring of recent events + the `/ws/field` broadcast topic; `GET /api/field` and `GET /ws/field` handlers; a standalone `router()` for isolated testing. - Signer (defers the P2 key decision, ADR-262 §8 Q1): a STANDALONE dev/sensing key from `WDP_RUFIELD_SIGNING_SEED`, else a deterministic dev default with a logged WARN. Reusing the `cog-ha-matter` Ed25519 key is the deferred P2 call — P3 does not pre-empt it. - Tap: at the ESP32 governed-trust cycle (`main.rs` ~5886 observe_cycle / ~5938 SensingUpdate build), `emit_rufield_event` joins the cycle's features/classification/signal_field with the engine's effective_class/demoted trust state into a `SensingSnapshot` and surfaces it via the bridge. Existing endpoints (`/ws/sensing` etc.) are unchanged — purely additive. - Privacy egress: `network_egress_allowed` is fail-closed for an unattended live surface — only P1/P2 leave the box; P0 raw and P3/P4/P5 (identity/biometric/aggregate) are held edge-local. A `Derived` cycle maps to P4/P5 and never surfaces. - No-phantom: `emit` drops no-presence cycles (no fabricated events). Gates (tests/rufield_surface_test.rs, tower::oneshot, 4/0): well-formed signed event (WifiCsi, P2 not P1, is_fusable, real timestamp); empty cycle → no phantom; Derived trust never surfaces; mixed stream surfaces only egress-safe events. Honesty (ADR-262 §0/§6): real plumbing on a live endpoint, NOT accuracy. Single-link CSI with its existing caveats (no validated room-coordinate accuracy); dedicated dev signing key pending the P2 ownership decision; no accuracy claim. Co-Authored-By: claude-flow <ruv@ruv.net> * docs(ADR-262 P3): mark P1+P3 implemented; document /api/field + /ws/field; CHANGELOG - ADR-262 Status → "P1 + P3 implemented"; add a P3 implementation-status block (tap site, endpoints, dedicated dev signer deferring the §8 Q1 key decision, fail-closed egress, gates). Keep the honesty framing: real plumbing on a live endpoint, not accuracy. - CHANGELOG [Unreleased]: add the ADR-262 P3 entry. - user-guide: add `/api/field` to the REST table + a "RuField surface (ADR-262 P3)" section covering `/api/field` + `/ws/field`, the fail-closed P1/P2-only egress, the WDP_RUFIELD_SIGNING_SEED dev key, and the no-accuracy honesty note. Co-Authored-By: claude-flow <ruv@ruv.net> * ci: checkout submodules everywhere + Dockerfile copies vendor/rufield Making wifi-densepose-rufield (ADR-262 bridge) a v2 workspace member means EVERY cargo-on-workspace context must have the vendor/rufield submodule present (cargo loads all member manifests). P1 only fixed the rust-tests job; this adds `submodules: recursive` to all workflow checkouts that run cargo (mqtt-integration was failing on the missing submodule manifest), and makes Dockerfile.rust COPY vendor/rufield/ to /vendor/rufield (matches the bridge's ../../../vendor/rufield path-dep under the collapsed Docker layout). update-submodules.yml left alone (it manages submodules itself). Co-Authored-By: claude-flow <ruv@ruv.net> --------- Co-authored-by: ruv <ruvnet@gmail.com>
124 lines
5.3 KiB
Rust
124 lines
5.3 KiB
Rust
//! # wifi-densepose-rufield
|
|
//!
|
|
//! ADR-262 **anti-corruption bridge**: converts RuView's live WiFi-CSI sensing
|
|
//! output into signed RuField [`FieldEvent`](rufield_core::FieldEvent)s.
|
|
//!
|
|
//! This crate is the **single coupling point** (ADR-262 §5.4) between RuView and
|
|
//! the standalone RuField MFS spec (`vendor/rufield`, ADR-260). It depends on
|
|
//! the four pure-Rust rufield crates **via path** — `rufield-core`,
|
|
//! `-provenance`, `-privacy`, `-fusion` — and on **no** RuView internal crate.
|
|
//! Inputs are owned primitives ([`SensingSnapshot`]) that mirror what RuView's
|
|
//! sensing cycle produces, so the bridge never imports `SensingUpdate` /
|
|
//! `TrustedOutput` directly.
|
|
//!
|
|
//! ## What P1 ships (honesty — ADR-262 §0 / §6)
|
|
//!
|
|
//! This is **P1 plumbing**: a tested `SensingSnapshot → FieldEvent` conversion
|
|
//! plus the **fail-closed privacy mapping** that is the §3.3 correctness item.
|
|
//! It is **not** wired into the live server (that is P3) and makes **no accuracy
|
|
//! claim** — RuField v0.1 is synthetic end-to-end and RuView's single-link CSI
|
|
//! carries its own caveats. The gates here are round-trip / fusability /
|
|
//! privacy-safety / determinism, not validated F1.
|
|
//!
|
|
//! ## The critical correctness item: the privacy mapping (§3.3)
|
|
//!
|
|
//! RuView's `Derived` class has byte value `1` (below `Anonymous = 2`) yet
|
|
//! carries an identity embedding. The bridge maps it to **P4/P5 by information
|
|
//! content, never P1** — see [`map_privacy`]. Mapping off the byte would leak
|
|
//! identity as low-privacy; [`map_privacy`] (and its dedicated test
|
|
//! `derived_identity_never_maps_to_low_privacy`) exist specifically to prevent
|
|
//! that.
|
|
//!
|
|
//! ## Example
|
|
//!
|
|
//! ```
|
|
//! use wifi_densepose_rufield::{
|
|
//! snapshot_to_field_event, SensingSnapshot, SensingFeatures, SensingClass,
|
|
//! RuViewPrivacyClass,
|
|
//! };
|
|
//! use rufield_provenance::{Signer, is_fusable};
|
|
//!
|
|
//! let snap = SensingSnapshot {
|
|
//! timestamp_ns: 1_791_986_400_000_000_000,
|
|
//! features: SensingFeatures {
|
|
//! mean_rssi: -55.0,
|
|
//! variance: 0.4,
|
|
//! motion_band_power: 2.0,
|
|
//! breathing_band_power: 0.3,
|
|
//! dominant_freq_hz: 0.25,
|
|
//! change_points: 1,
|
|
//! spectral_power: 3.0,
|
|
//! },
|
|
//! classification: SensingClass {
|
|
//! motion_level: "low".into(),
|
|
//! presence: true,
|
|
//! confidence: 0.82,
|
|
//! },
|
|
//! signal_field: None,
|
|
//! trust_class: RuViewPrivacyClass::Anonymous,
|
|
//! demoted: false,
|
|
//! identity_bound: false,
|
|
//! node_id: "esp32_room_01".into(),
|
|
//! };
|
|
//!
|
|
//! let signer = Signer::from_seed(b"adr-262-bridge-seed-32-bytes-ok!");
|
|
//! let event = snapshot_to_field_event(&snap, &signer);
|
|
//! assert!(is_fusable(&event)); // ed25519-signed, non-synthetic ⇒ fusable
|
|
//! ```
|
|
|
|
#![forbid(unsafe_code)]
|
|
|
|
pub mod bridge;
|
|
pub mod privacy;
|
|
pub mod snapshot;
|
|
|
|
pub use bridge::{snapshot_egress_class, snapshot_to_field_event};
|
|
pub use privacy::{apply_demotion_floor, egress_class, map_privacy};
|
|
pub use snapshot::{
|
|
RuViewPrivacyClass, SensingClass, SensingFeatures, SensingSnapshot, SignalField,
|
|
};
|
|
|
|
// Re-export the rufield surface a bridge consumer needs, so callers depend on
|
|
// one crate.
|
|
pub use rufield_core::{Destination, FieldEvent, Modality, PrivacyClass, PrivacyDecision};
|
|
pub use rufield_fusion::RuFieldFusion;
|
|
pub use rufield_privacy::{DefaultPrivacyGuard, PrivacyPolicy};
|
|
pub use rufield_provenance::{is_fusable, verify_event, Signer};
|
|
|
|
/// Whether a mapped [`PrivacyClass`] may be surfaced on a **network** egress
|
|
/// (ADR-262 §4 P3 — the live `/api/field` / `/ws/field` surface must respect
|
|
/// the same default §10 network policy `/ws/sensing` honours, never emitting
|
|
/// above-policy data).
|
|
///
|
|
/// **Fail-closed for a live, unattended surface.** The live RuView surface has
|
|
/// **no per-event consent or identity-binding ceremony** — so this is *stricter*
|
|
/// than [`DefaultPrivacyGuard::authorize`]: it requires BOTH that the default
|
|
/// guard would `Allow` the class onto [`Destination::Network`] with **no consent
|
|
/// granted**, AND that the class is at or below the default network ceiling
|
|
/// ([`PrivacyClass::P2`]). The second clause deliberately drops P4/P5 even
|
|
/// though the guard's consent/identity *exceptions* would let an explicitly
|
|
/// consented/identity-bound P4/P5 through — because the live surface cannot
|
|
/// honestly assert that consent. Net effect: only **P1/P2** leave the box; P0
|
|
/// (raw) and P3/P4/P5 are held edge-local.
|
|
///
|
|
/// This is the privacy-safety pin for the live surface: a `Derived` cycle maps
|
|
/// to P4 (or P5 when identity-bound) via [`map_privacy`] and is therefore
|
|
/// **never** surfaced as a network event — neither as a low-privacy P1 (the
|
|
/// §3.3 mapping trap) nor at all.
|
|
#[must_use]
|
|
pub fn network_egress_allowed(class: PrivacyClass, identity_bound: bool) -> bool {
|
|
use rufield_core::PrivacyGuard;
|
|
let guard_allows = matches!(
|
|
DefaultPrivacyGuard::default().authorize(
|
|
class,
|
|
Destination::Network,
|
|
false, // no per-event consent on the live network surface (fail-closed)
|
|
identity_bound,
|
|
),
|
|
PrivacyDecision::Allow
|
|
);
|
|
// Additionally cap at the default network ceiling: an unattended live
|
|
// surface never asserts the P4-consent / P5-identity exception.
|
|
guard_allows && class <= PrivacyClass::P2
|
|
}
|