ADR-138:WiFi-7 MLO LinkGroup 抽象与 ArrayCoordinator 时钟质量门控¶
| 字段 | 值 |
|---|---|
| 状态 | 已接受 — 部分实现(构建块已构建并通过测试;集成胶水待完成 — 参见“实现状态”,提交 fc7674bde) |
| 日期 | 2026-05-28 |
| 决策者 | ruv |
| 目标代码库 | wifi-densepose-signal(ruvsense/multiband.rs、ruvsense/multistatic.rs);wifi-densepose-ruvector(viewpoint/geometry.rs、viewpoint/coherence.rs、viewpoint/attention.rs、viewpoint/fusion.rs) |
| 关联 | ADR-008(CSI 帧原语)、ADR-029(RuvSense 多基地)、ADR-030(持久场模型)、ADR-031(RuView 感测优先 RF 模式)、ADR-110(ESP32-C6 固件扩展 / 802.15.4 同步)、ADR-136(RuView Rust 流式引擎 — 帧契约)、ADR-137(融合引擎质量评分 — 证据引用与矛盾标志) |
1. 背景¶
1.1 缺口¶
在这两个指定的 crate 中搜索 LinkGroup、ArrayCoordinator、clock_quality、DirectionalEvidence 和 FreqSet,找不到对应的生产模块。一个可感知 MLO 的协调器本应组合的这些部件都存在,但每个部件都只连接到单个 CSI 流、单个时钟域,并且输出的是硬融合结果,而非加权证据。具体来说:
-
ruvsense/multiband.rs包含MultiBandCsiFrame { node_id, timestamp_us, channel_frames: Vec<CanonicalCsiFrame>, frequencies_mhz: Vec<u32>, coherence }和一个MultiBandBuilder,用于融合来自跳频无线电(一个在 1/6/11 信道间循环的 ESP32-S3)的逐信道行。这是最接近按频段特征流的东西,但它建模的是单台无线电上的顺序信道跳变,而非 WiFi-7 多链路操作(MLO)中频段并发流式的同时传输。目前没有聚合体来跟踪哪些频段当前存活、哪些已经掉线;而且coherence只是一个 Pearson 标量(compute_cross_channel_coherence),并不具备带提升语义的频段间共识。 -
ruvsense/multistatic.rs包含MultistaticFuser::fuse(&[MultiBandCsiFrame]) -> FusedSensingFrame。它已经会验证guard_interval_us时间戳散布(MultistaticConfig.guard_interval_us,默认 5000 µs),并根据节点位置计算geometric_diversity(&[[f32;3]])。但:(a) 时间戳散布是硬性接受/拒绝——没有时钟质量的概念(时钟仅不确定的节点与时钟良好的节点被同等对待);(b)geometric_diversity()是一个返回裸f32的自由函数,并未接入融合决策的门控;(c) 输出FusedSensingFrame是一个既定的携带位姿的fused_amplitude/fused_phase产物,而不是带可信区间的定向证据。 -
viewpoint/geometry.rs包含GeometricDiversityIndex::compute(azimuths, node_ids) -> Option<Self>,提供value、n_effective、worst_pair、is_sufficient()(阈值value >= PI/N),以及返回crb_x、crb_y、rmse_lower_bound、gdop的CramerRaoBound::estimate(target, &[ViewpointPosition]) -> Option<Self>。这正是本 ADR 需要将其转化为门控和可信区间的 GDI + Cramér-Rao 机制——但目前没有任何代码从多站路径调用它。两个geometric_diversity实现(multistatic.rs中的自由函数和geometry.rs中的GeometricDiversityIndex)互不知晓对方的存在。 -
viewpoint/coherence.rs包含CoherenceState(带push/coherence()的滚动相量窗口)和CoherenceGate { threshold, hysteresis, evaluate() }。该门控已经实现了迟滞和占空比。但它只针对相位相干性做门控——没有时钟质量项,也没有“矛盾”概念:相干性下降只是关闭门控,并不会将频段/组降级为仅监控状态,也不会为下游标记这一矛盾。 -
viewpoint/fusion.rs包含MultistaticArray(DDD 聚合根),提供submit_viewpoint、push_phase_diff、fuse() -> FusedEmbedding、compute_gdi(),以及ViewpointFusionEvent枚举(ViewpointCaptured、TdmCycleCompleted、FusionCompleted、CoherenceGateTriggered、GeometryUpdated)。fuse()已经会按 SNR 过滤并按相干性门控,在环境不稳定时返回FusionError::CoherenceGateClosed。但该聚合以嵌入向量(AETHER 128 维向量)为键,产出的也是用于位姿输入的FusedEmbedding——没有按频段的生命周期,没有时钟质量输入,而且“门控关闭”路径会静默丢弃该周期,而不是降级为仍会输出证据的仅监控状态。 -
wifi-densepose-hardware/src/sync_packet.rs已完整实现:SyncPacket解码 ADR-110 §A0.12 的线上格式(魔数0xC511A110,32 字节小端),暴露local_minus_epoch_us()、apply_to_local()和mesh_aligned_us_for_sequence(frame_seq, fps_hz)。感知服务器(wifi-densepose-sensing-server/src/main.rs)已经按SYNC_PACKET_MAGIC分发,并应用 9 秒陈旧性门控(mesh_aligned_us_for_csi_frame)。所缺的是:从同步流推导出的时钟质量评分(偏移离散度 / 主从对比 / 陈旧性),供信号域融合查询。硬件 crate 恢复了mesh_aligned_us,但从未将该对齐的质量传播到multistatic.rs或viewpoint/。
其后果是:阵列把每个节点都当作时钟完美、几何足够的节点来对待,并且即使出现以下情况也提交融合位姿:(a) 只有一个 MLO 频段存活;(b) 贡献节点聚集在一起(GDI 低);或 (c) 某个节点的时钟漂移已超过其相位可与同类节点比较的程度。ADR-137(姊妹篇,提议中)要求每个融合输出都携带证据引用与矛盾标志;ADR-136(姊妹篇,提议中)定义了 FrameMeta 帧契约,每帧应携带 mesh_aligned_us 和时钟元数据。本 ADR 补上了缺失的中间层:一个感知哪些频段存活的、具备生命周期管理的 LinkGroup,以及一个基于几何和时钟质量进行门控并输出 DirectionalEvidence 而非硬决策的 ArrayCoordinator 服务。
1.2 此处 “LinkGroup” 和 “ArrayCoordinator” 的含义¶
-
LinkGroup 是一个生命周期管理的聚合,表示一条运行 WiFi-7 MLO 的物理链路:一组并发频段(2.4 / 5 / 6 GHz),无线电同时流式传输这些频段,每个频段各自产生一个
CanonicalCsiFrame。LinkGroup 封装一个FreqSet(声明的频段成员关系)以及每个频段一个滚动Vec<MultiBandCsiFrame>,并跟踪频段生命周期——频段可以enter(开始流式传输)、exit(掉线,例如 AP 重启时丢失 6 GHz),并在与其他频段达成一致后被promoted到共识集合。这与当前的MultiBandCsiFrame不同,后者是一个快照,对应一个跳周期,没有成员生命周期。 -
ArrayCoordinator 是一个服务(不是聚合)。它消费一组
LinkGroup以及已由multistatic.rs建模的每节点帧,应用两个门控——几何门控(来自viewpoint/geometry.rs的 GDI / Cramér-Rao)和时钟质量门控(ADR-110 同步离散度)——并返回DirectionalEvidence:每个视角的注意力权重,以及从 Cramér-Rao 界推导出的置信区间。它不决定位姿。位姿/语义决策在下游(ADR-137 融合引擎质量评分);协调器只说明“当前阵列能看到什么、不能看到什么,以及每个方向应信任多少”。
1.3 为什么不是单一硬门控¶
现有的 CoherenceGate::evaluate() 和 MultistaticConfig.guard_interval_us 都是二元的:更新 / 不更新,接受 / 拒绝。WiFi-7 MLO 和多节点阵列会优雅地降级——丢失 6 GHz 频段,或某个节点的时钟离散度从 40 µs 上升到 180 µs,并不会使阵列失效;它只会缩小可分辨范围并扩大置信区间。硬门控会丢弃可用证据。下面的决策用分级的协调器输出替代二元门控,该输出降级而不是丢弃,并将分级结果馈入 ADR-137 的矛盾机制。
1.4 流水线位置¶
Per-band CSI (MLO: 2.4 / 5 / 6 GHz concurrent)
→ multiband.rs MultiBandBuilder (per-band CanonicalCsiFrame rows)
→ LinkGroup::ingest() ← NEW (band enter/exit + consensus promote)
→ ArrayCoordinator::coordinate() ← NEW (service: GDI gate + clock-quality gate)
│ consumes: Vec<LinkGroup>, node_frames, Vec<SyncPacket> (ADR-110)
│ uses: GeometricDiversityIndex + CramerRaoBound (viewpoint/geometry.rs)
│ ClockQualityGate ← NEW (wraps viewpoint/coherence.rs CoherenceGate)
▼
→ DirectionalEvidence ← NEW (attention weights + credence intervals)
→ multistatic.rs MultistaticFuser.fuse() (consumes weights, NOT a re-decision)
→ ADR-137 FusionEngine quality scoring + contradiction flags
协调器位于每频段摄取和现有 MultistaticFuser 之间。它不替代 fuse();它提供 fuse() 已经需要的权重(目前 attention_weighted_fusion 仅从幅度相似度内部推导它们)以及 ADR-137 消费的矛盾标志。
2. 决策¶
2.1 LinkGroup:生命周期管理的 MLO 聚合¶
在 ruvsense/multiband.rs 中新增 LinkGroup(它组合现有的 MultiBandCsiFrame 和 CanonicalCsiFrame)。它是一个具有显式频段生命周期的聚合,而不是快照。
use crate::hardware_norm::CanonicalCsiFrame;
/// The declared set of MLO bands a link operates on (WiFi-7: up to 3).
/// Membership is *declared* at construction; liveness is tracked separately.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct FreqSet {
/// Center frequencies (MHz), sorted ascending. e.g. [2412, 5180, 5955].
pub bands_mhz: Vec<u32>,
}
impl FreqSet {
pub fn new(mut bands_mhz: Vec<u32>) -> Self {
bands_mhz.sort_unstable();
bands_mhz.dedup();
Self { bands_mhz }
}
pub fn contains(&self, freq_mhz: u32) -> bool { self.bands_mhz.contains(&freq_mhz) }
pub fn len(&self) -> usize { self.bands_mhz.len() }
pub fn is_empty(&self) -> bool { self.bands_mhz.is_empty() }
}
/// Lifecycle state of one band within a LinkGroup.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum BandState {
/// Declared in the FreqSet but no frame seen yet (warm-up).
Pending,
/// Streaming frames, but not yet agreeing with peers.
Live,
/// Live AND consensus-promoted: agrees with the group's other live bands.
Promoted,
/// Was Live, has missed `exit_after_missed` expected frames.
Exited,
}
/// Domain events emitted by a LinkGroup (event-sourced state changes, per house rule).
#[derive(Debug, Clone, PartialEq)]
pub enum LinkGroupEvent {
BandEntered { freq_mhz: u32, at_us: u64 },
BandExited { freq_mhz: u32, at_us: u64, missed: u32 },
BandPromoted { freq_mhz: u32, at_us: u64, consensus: f32 },
BandDemoted { freq_mhz: u32, at_us: u64, reason: DemotionReason },
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum DemotionReason {
/// Inter-band consensus dropped below threshold.
ConsensusLoss,
/// Coherence fell >2σ from the rolling mean (contradiction; §2.5).
CoherenceContradiction,
}
#[derive(Debug, thiserror::Error)]
pub enum LinkGroupError {
#[error("Frequency {freq_mhz} MHz is not a member of this LinkGroup's FreqSet")]
UnknownBand { freq_mhz: u32 },
#[error("Subcarrier count mismatch on band {freq_mhz}: expected {expected}, got {got}")]
SubcarrierMismatch { freq_mhz: u32, expected: usize, got: usize },
}
/// A WiFi-7 MLO physical link: a FreqSet plus per-band feature streams with
/// explicit enter/exit and consensus-promotion lifecycle.
///
/// # Concurrency
/// Requires `&mut self` for `ingest()`; not `Sync`. One ingest loop per link.
#[derive(Debug)]
pub struct LinkGroup {
node_id: u8,
freq_set: FreqSet,
/// Most recent frame per band, indexed parallel to `freq_set.bands_mhz`.
latest: Vec<Option<CanonicalCsiFrame>>,
/// Lifecycle state per band (parallel to `freq_set.bands_mhz`).
state: Vec<BandState>,
/// Rolling per-band inter-band consensus score (Pearson vs. the group mean).
consensus: Vec<f32>,
/// Frame count per band since last seen, for exit detection.
missed: Vec<u32>,
/// Config: promote/exit thresholds.
config: LinkGroupConfig,
/// Pending domain events (drained by the ArrayCoordinator).
events: Vec<LinkGroupEvent>,
}
#[derive(Debug, Clone)]
pub struct LinkGroupConfig {
/// Pearson consensus required to promote a Live band to Promoted. Default 0.6.
pub promote_consensus: f32,
/// Consecutive missed expected frames before a Live band Exits. Default 5.
pub exit_after_missed: u32,
}
impl Default for LinkGroupConfig {
fn default() -> Self { Self { promote_consensus: 0.6, exit_after_missed: 5 } }
}
impl LinkGroup {
pub fn new(node_id: u8, freq_set: FreqSet, config: LinkGroupConfig) -> Self;
/// Ingest one band's frame. Marks the band Live (emitting BandEntered on the
/// first frame), recomputes inter-band consensus against the current live
/// mean, promotes/demotes per thresholds, and ages out unseen bands toward
/// Exited. Bands not in `freq_set` are rejected with `UnknownBand`.
pub fn ingest(&mut self, freq_mhz: u32, frame: CanonicalCsiFrame, at_us: u64)
-> Result<(), LinkGroupError>;
/// Bands currently in the consensus (Promoted) set.
pub fn promoted_bands(&self) -> Vec<u32>;
/// Build a MultiBandCsiFrame from the currently Promoted bands only.
/// Returns None if fewer than 1 band is Promoted.
pub fn consensus_frame(&self, at_us: u64) -> Option<MultiBandCsiFrame>;
/// Drain pending domain events (the ArrayCoordinator forwards these to ADR-137).
pub fn drain_events(&mut self) -> Vec<LinkGroupEvent>;
}
带间共识复用 multiband.rs 中已有的 pearson_correlation_f32(当前为私有;提升为 pub(crate))。consensus_frame() 的输出有意为 MultiBandCsiFrame,因此现有的 MultistaticFuser 可以原样消费它。
为什么是聚合,而不是快照。 MLO 频段成员关系是有状态的:6 GHz 频段掉线 250 ms 后恢复,与节点永久失去 6 GHz 是不同的物理情形。快照(MultiBandCsiFrame)无法表示“该频段已退出,我们现在处于降级运行状态”。生命周期(Pending → Live → Promoted,并带有 → Exited 和 → Demoted 转换)是所需的最小状态,用于:(a) 向协调器提供优雅降级,(b) 发出 ADR-137 所需的频段级矛盾事件。
2.2 ClockQualityScore 与时钟质量门控¶
时钟质量项从 ADR-110 的 SyncPacket 流中导出,并与现有的相位相干门控一起并入一个门控。该分数位于 viewpoint/coherence.rs 中,紧邻 CoherenceState/CoherenceGate。
/// Per-node clock-quality summary derived from the ADR-110 sync stream.
///
/// All fields are computed by the host from the `SyncPacket` series for one
/// node (`wifi_densepose_hardware::sync_packet::SyncPacket`).
#[derive(Debug, Clone, Copy)]
pub struct ClockQualityScore {
/// EMA stdev of (local_us - epoch_us) over the recent sync window (µs).
/// This is the dispersion of the node's mesh-alignment offset.
pub offset_stdev_us: f32,
/// 802.15.4 stratum: 0 = leader, 1 = direct follower, etc.
pub stratum: u8,
/// Age of the most recent valid SyncPacket (µs); large = stale.
pub age_us: u64,
/// Whether the most recent packet had flags.is_valid set.
pub valid: bool,
}
impl ClockQualityScore {
/// Normalised quality in [0, 1]: 1.0 = leader-grade, 0.0 = unusable.
/// Combines offset dispersion (vs. the ADR-110 ±100 µs target), stratum
/// penalty, and staleness. 0.0 if `!valid`.
pub fn quality(&self) -> f32;
/// Convenience: the ADR-110 ±100 µs sync target as a hard usability floor.
/// `offset_stdev_us < 200.0` (2× the target) is the gate's default accept.
pub const SYNC_TARGET_US: f32 = 100.0;
}
/// Gate that admits a node's frames into directional fusion only when both
/// its phase coherence AND its clock quality are adequate. Wraps the existing
/// `CoherenceGate` (phase term) and adds the clock term.
#[derive(Debug, Clone)]
pub struct ClockQualityGate {
/// Existing phase-coherence gate (unchanged semantics).
pub coherence: CoherenceGate,
/// Reject when offset_stdev_us >= this. Default 200.0 (2× ADR-110 target).
pub max_offset_stdev_us: f32,
/// Reject when sync age exceeds this. Default 9_000_000 (the sensing-server
/// 9-second staleness gate already used in main.rs).
pub max_age_us: u64,
}
impl ClockQualityGate {
pub fn new(coherence: CoherenceGate, max_offset_stdev_us: f32, max_age_us: u64) -> Self;
pub fn default_params() -> Self {
Self::new(CoherenceGate::default_params(), 200.0, 9_000_000)
}
/// Evaluate both terms. Returns the gate decision for one node this cycle.
/// `coherence_value` is the rolling phasor coherence (CoherenceState::coherence()).
pub fn evaluate(&mut self, coherence_value: f32, clock: &ClockQualityScore)
-> ClockGateDecision;
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum ClockGateDecision {
/// Both terms pass: node admitted at full weight.
Admit,
/// Phase OK but clock degraded: admit at reduced weight (monitoring-only;
/// frame contributes to evidence but NOT to model/environment update).
MonitorOnly { clock_quality: f32 },
/// Either term fails hard: node excluded this cycle.
Reject { reason: ClockRejectReason },
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ClockRejectReason { Incoherent, ClockStale, ClockDispersed, ClockInvalid }
为什么默认下限是 200 µs。 ADR-110 §A0.10 在 EMA 平滑后测得 COM9↔COM12 跟随者偏移标准差约为 104 µs,而 802.15.4 目标为 ±100 µs。如果一个节点的离散度上升到测量基线的 2 倍(200 µs),在 5 GHz 下它大约失去了一个相位绕回的跨节点可比性(波长 ≈ 5 cm;在感知运动速度下,200 µs 的时钟偏差会破坏 attention_weighted_fusion 所依赖的节点间相位项)。低于 200 µs 时节点被接纳;在 200 µs 与陈旧度上限之间,它是 MonitorOnly(可贡献证据,但不更新环境);超过 9 s 年龄上限——即感知服务器已经执行的同一陈旧度门(main.rs::mesh_aligned_us_honors_9s_staleness_gate)——则被拒绝。
为什么专门门控环境更新。 时钟项不得阻止证据发射——时钟降级的节点仍然能看到真实运动,并应贡献加权证据。它必须阻止环境/模型更新(ADR-030 场模型、ADR-031 模型更新路径),因为这些更新假设了跨节点相位可比性,而离散时钟会破坏这种可比性。MonitorOnly 恰好编码了这一点:贡献到 DirectionalEvidence,但不提升为模型/环境变更。这与现有 CoherenceGate 语义(“仅当相干性超过阈值时才允许模型更新”)一致,并增加了时钟维度。
2.3 ArrayCoordinator:一个服务,而非聚合¶
ArrayCoordinator 被添加到 viewpoint/fusion.rs 中,与 MultistaticArray 并列。它自身不持有任何长生命周期的领域状态(生命周期状态位于 LinkGroups 和 MultistaticArray 中);它是一个每次调用无状态的领域服务,用于应用门控并投影证据。
use crate::viewpoint::geometry::{GeometricDiversityIndex, CramerRaoBound, ViewpointPosition, NodeId};
use crate::viewpoint::coherence::{ClockQualityGate, ClockQualityScore, ClockGateDecision};
/// Directional evidence: what the array can resolve right now, and how much to
/// trust each direction. This is the coordinator's output — NOT a pose decision.
///
/// Per the house rule that every semantic state traces to evidence, this struct
/// carries the geometry + clock provenance that ADR-137 attaches to any state
/// it derives downstream.
#[derive(Debug, Clone)]
pub struct DirectionalEvidence {
/// Per-viewpoint attention weight (softmax, sums to 1.0 over admitted nodes).
pub weights: Vec<(NodeId, f32)>,
/// Geometric Diversity Index at evaluation time.
pub gdi: GeometricDiversityIndex,
/// Cramér-Rao credence interval: RMSE lower bound (m) for a centroid target.
/// `None` when fewer than 3 admitted viewpoints (under-determined).
pub credence_rmse_m: Option<f32>,
/// Per-node gate decisions (Admit / MonitorOnly / Reject) — the audit trail.
pub gate_decisions: Vec<(NodeId, ClockGateDecision)>,
/// Contradiction flags forwarded to ADR-137 (see §2.5).
pub contradictions: Vec<ContradictionFlag>,
/// Number of viewpoints admitted at full weight (Admit).
pub n_admitted: usize,
/// Number admitted MonitorOnly (evidence-only, no environment update).
pub n_monitoring: usize,
}
// `ContradictionFlag` is NOT redefined here. It is the canonical enum owned by
// ADR-137 §2.3 (`wifi-densepose-signal::ruvsense::multistatic`). The coordinator
// imports it and emits only its array-origin variants:
//
// use wifi_densepose_signal::ruvsense::multistatic::ContradictionFlag;
//
// ContradictionFlag::CoherenceDrop { node_idx, sigma } // coherence > Nσ off rolling mean
// ContradictionFlag::GeometryInsufficient { gdi } // array GDI below the floor
//
// A previously-Promoted band being demoted (inter-band disagreement) is surfaced
// through the per-node `gate_decisions` audit trail above, not as a contradiction
// flag — it suppresses the model update without contradicting the observation.
// `NodeId` → `node_idx` resolution happens at the ADR-137 hand-off (ADR-137 §2.3).
#[derive(Debug, Clone)]
pub struct ArrayCoordinatorConfig {
/// Per-node clock+coherence gate.
pub gate: ClockQualityGate,
/// σ multiple defining a coherence contradiction. Default 2.0.
pub contradiction_sigma: f32,
/// Per-measurement noise std (m) for the Cramér-Rao credence estimate.
pub crb_noise_std_m: f32,
/// Attention temperature for the directional weight softmax. Default 1.0.
pub attention_temperature: f32,
}
/// Domain service: gates LinkGroups + node frames on geometry and clock quality,
/// returns DirectionalEvidence. Holds NO aggregate state.
pub struct ArrayCoordinator {
config: ArrayCoordinatorConfig,
}
impl ArrayCoordinator {
pub fn new(config: ArrayCoordinatorConfig) -> Self;
/// The single service operation. For each node:
/// 1. Take its LinkGroup consensus frame (Promoted bands only).
/// 2. Evaluate the clock-quality gate (coherence × clock).
/// 3. Admit / MonitorOnly / Reject.
/// Then over the admitted set:
/// 4. Compute GDI (geometry.rs); raise GeometryInsufficient if !is_sufficient().
/// 5. Compute Cramér-Rao credence RMSE for a centroid target.
/// 6. Build attention weights (softmax over admitted nodes, biased by clock
/// quality and inverse-CRB so well-placed, well-clocked nodes weigh more).
/// 7. Collect contradiction flags from LinkGroup demotions + coherence drops.
///
/// `coherence_per_node` and `clock_per_node` are parallel to `viewpoints`.
pub fn coordinate(
&mut self,
viewpoints: &[(NodeId, f32 /*azimuth*/, ViewpointPosition)],
coherence_per_node: &[f32],
clock_per_node: &[ClockQualityScore],
link_events: &[LinkGroupEventRef],
) -> DirectionalEvidence;
}
协调器有意复用而非重新实现:
- 使用 GeometricDiversityIndex::compute + is_sufficient() 作为几何门控。
- 使用 CramerRaoBound::estimate 计算可信度区间(其 rmse_lower_bound 就是 可信度半径)。
- 使用 ClockQualityGate::evaluate 进行每个节点的接纳/监控/拒绝决策。
- 复用 multistatic.rs::attention_weighted_fusion 中的 softmax 形状(数值稳定,减去最大值),但由时钟质量和逆 CRB 加权,而非仅由幅度-余弦决定。
为什么是服务,而不是将其并入 MultistaticArray。 MultistaticArray 是 ViewpointFusion 的聚合根——它拥有嵌入生命周期和相干窗口。协调器的职责跨越多个聚合(每个节点的 LinkGroup 以及阵列),并且以读为主:它检查状态并投影证据,但权威状态转换(频段提升、视点 upsert)属于聚合。将跨聚合门控逻辑放在无状态服务中,可保持聚合边界清晰(DDD),并使协调器能够轻松使用合成输入进行测试。
2.4 Wiring the ADR-110 SyncPacket Decoder Into the Pipeline¶
今天 SyncPacket 在 wifi-densepose-sensing-server/src/main.rs 中解码,并且仅用于恢复 mesh_aligned_us。本 ADR 扩展该路径,使恢复的对齐携带质量:
- 感知服务器已经维护
NodeState::latest_sync: Option<SyncPacket>和latest_sync_at: Option<Instant>。添加一个滚动缓冲区NodeState::sync_offsets: VecDeque<i64>,保存最近 N 个local_minus_epoch_us()值以及一个 EMA。基于这些,为每个节点每个周期构建ClockQualityScore { offset_stdev_us, stratum, age_us, valid }。 stratum由SyncPacketFlags::is_leader派生(leader = 0,follower = 1;更深层级保留)。age_us是 mesh 域中的now - latest_sync_at。valid是latest_sync.flags.is_valid。- 根据 ADR-136,每帧
FrameMeta契约新增mesh_aligned_us: Option<u64>和clock_quality: Option<ClockQualityScore>,在帧摄取时通过将(node_id, sequence)与最近的SyncPacket配对来填充(正是mesh_aligned_us_for_sequence已经实现的配对)。这使得信号 crate 不依赖任何 UDP/socket——它们接收FrameMeta,而不是原始数据包。 ArrayCoordinator::coordinate()调用接收从这些FrameMeta记录中提取的clock_per_node: &[ClockQualityScore]。wifi-densepose-signal或wifi-densepose-ruvector中不会新增 socket 代码;硬件 crate 仍然是线格式的唯一所有者(SYNC_PACKET_MAGIC = 0xC511A110)。
这保留了现有的 crate 依赖方向:hardware → (FrameMeta) → signal/ruvector。协调器从不导入 wifi-densepose-hardware;它只看到 ClockQualityScore 值对象。
2.5 Contradiction-to-Environment-Change Semantics¶
协调器将两个阵列级条件转换为 ADR-137 矛盾标志,并使用它们进行降级而不是提交:
-
相干性下降 > 2σ。 每个节点的
CoherenceState已经维护滚动相量相干性。协调器额外跟踪每个节点该相干性的滚动均值/标准差(Welford,与 ADR-135 对WelfordStats的复用一致)。当当前相干性低于滚动均值超过contradiction_sigma(默认 2.0)时,协调器 (a) 提升ContradictionKind::CoherenceDrop { magnitude },并且 (b) 该节点的ClockQualityGate在该周期最多返回MonitorOnly——其帧贡献证据,但不能触发环境/模型更新。这是LinkGroupEvent::BandDemoted { reason: CoherenceContradiction }的信号域对应物。 -
GDI 低于充分性下限。
GeometricDiversityIndex::is_sufficient()已经编码了value >= (2π/N) × 0.5下限。当接纳集合的 GDI 不足时,协调器提升ContradictionKind::GeometryInsufficient { magnitude: gdi.value }并加宽可信度区间(Cramér-Raormse_lower_bound会随着几何退化自动增大,因此该标志对 ADR-137 是咨询性的,而不是单独的加宽)。
LinkGroup 频段降级(BandDemoted)会原样转发为 ContradictionKind::BandDemoted。在所有三种情况下,规则相同,并且是本 ADR 的核心:矛盾降级为仅监控;它从不强制环境变更。 只有持续的共识(接纳节点在一个窗口内达成一致)才会提升环境更新——并且该提升由下游 ADR-137 拥有,它接收协调器的 DirectionalEvidence 及其完整的矛盾列表。
2.6 Provenance / Evidence Tracing¶
根据项目规则,每个语义状态都追溯到信号证据 + 模型版本 + 校准版本 + 隐私决策,DirectionalEvidence 结构体被设计为该链的证据部分:
- 信号证据:每个节点的
weights和gate_decisions是审计跟踪,记录哪些视点(以及通过LinkGroup共识的哪些 MLO 频段)贡献了多少。 - 校准版本:当为节点加载 ADR-135
BaselineCalibration时,其captured_at_unix_s/设备 ID 通过FrameMeta传递;协调器不重新推导校准,而是将其传递,以便 ADR-137 可以盖章。 - 模型 / 隐私版本:这些不是协调器关心的问题(它不做模型推理,也不做隐私决策);ADR-137 在消费
DirectionalEvidence时附加model_version和当前隐私决策。协调器的契约是使证据和矛盾集合足够完整,以便 ADR-137 无需重新读取原始帧即可构建完整的溯源元组。
2.7 Downstream Consumers and Interface Boundaries¶
| 消费者 | 接收内容 | 所需变更 |
|---|---|---|
multistatic.rs::MultistaticFuser::fuse() |
DirectionalEvidence.weights 而非内部推导的幅度-余弦权重 |
MultistaticConfig 新增 external_weights: Option<Vec<(u8, f32)>>;当存在时,attention_weighted_fusion 使用它们而不是重新计算。向后兼容(None = 当前行为)。 |
| 消费者 | 它接收什么 | 所需变更 |
|---|---|---|
multiband.rs::MultiBandBuilder |
不变;LinkGroup::consensus_frame() 生成它已经理解的 MultiBandCsiFrame |
MultiBandBuilder 无需变更;pearson_correlation_f32 提升为 pub(crate) 供 LinkGroup 复用 |
viewpoint/fusion.rs::MultistaticArray |
协调器在 fuse() 之前 运行;CoherenceGateClosed 路径被 MonitorOnly 证据替代 |
新增 ViewpointFusionEvent::DirectionalEvidenceEmitted { gdi, n_admitted, n_monitoring };fuse() 不再在相干性关闭时硬性丢弃——它返回零个被接纳节点的证据 |
viewpoint/geometry.rs |
由协调器调用(GeometricDiversityIndex、CramerRaoBound) |
无 API 变更;现有的 is_sufficient() 和 rmse_lower_bound 正是门控/置信度原语 |
viewpoint/coherence.rs |
在 CoherenceGate 旁边承载新的 ClockQualityScore / ClockQualityGate |
新增类型;现有 CoherenceGate/CoherenceState 不变并复用为相位项 |
| ADR-137 FusionEngine | DirectionalEvidence(权重 + 置信度 + contradictions) |
协调器是 ADR-137 的上游;ContradictionFlag 是约定的交接类型 |
| ADR-136 流式引擎 | 填充 FrameMeta.mesh_aligned_us + clock_quality |
协调器从 FrameMeta 读取这些;ADR-136 拥有帧契约 |
接口边界声明。 协调器唯一的输入是值对象(ViewpointPosition、f32 相干性、ClockQualityScore、LinkGroupEventRef);它唯一的输出是 DirectionalEvidence 值对象。它在同一 crate 内从 viewpoint::geometry 和 viewpoint::coherence 导入,并由组装输入的感知服务器 / 流式引擎调用。它不导入 wifi-densepose-hardware,不接触套接字,也不做出姿态或隐私决策。
2.8 测试计划 / 验收标准¶
T1 — LinkGroup 频段生命周期(单元测试)。 使用 FreqSet::new(vec![2412, 5180, 5955]) 构造一个 LinkGroup。摄入 2.4 + 5 GHz 帧,这些帧相关(共识 > 0.6)持续 10 个周期;摄入不相关的 6 GHz 帧。断言:2.4 和 5 GHz 达到 BandState::Promoted(发出 BandPromoted);6 GHz 保持 Live;promoted_bands() == [2412, 5180];consensus_frame() 产生一个 2 频段 MultiBandCsiFrame。
T2 — 频段退出与重新进入(单元测试)。 对同一组,停止馈送 6 GHz 达 exit_after_missed(5)个周期 → 断言发出 BandExited 且状态为 Exited。恢复 6 GHz → 断言发出 BandEntered 且状态返回 Live。
T3 — 时钟质量门控阈值(单元测试)。 构造 ClockQualityScore:(a) offset_stdev_us = 50, valid = true, age_us = 1_000_000 → quality() > 0.8 且门控为 Admit;(b) offset_stdev_us = 250(> 200 下限)但相干 → 门控为 MonitorOnly;(c) age_us = 10_000_000(> 9 s)→ 门控为 Reject { ClockStale };(d) valid = false → Reject { ClockInvalid } 且 quality() == 0.0。
T4 — ArrayCoordinator 几何门控 + 置信度(单元测试)。 四个节点位于 5×5 m 房间的四个角落(复用 geometry.rs::gdi_four_corners 布局),全部 Admit。断言:gdi.is_sufficient();credence_rmse_m 为 Some,并且在添加第 5 个位置良好的节点时减小(对应 crb_decreases_with_more_viewpoints);weights 总和为 1.0;n_admitted == 4。
T5 — 聚集节点触发 GeometryInsufficient(单元测试)。 四个节点聚集在 0.12 rad 内(复用 gdi_clustered_viewpoints_have_low_value)。断言存在 ContradictionKind::GeometryInsufficient,且 credence_rmse_m 远大于 T4。
T6 — 相干性下降矛盾降级,而非决定(单元测试)。 向一个节点馈送稳定相干性(~0.8)30 个周期以初始化滚动均值,然后单次 0.2 相干性(> 2σ 下降)。断言:为该节点触发 ContradictionKind::CoherenceDrop;其门控决定至多为 MonitorOnly;该节点仍出现在 weights 中(证据保留);n_monitoring >= 1。
T7 — SyncPacket → ClockQualityScore(单元测试,复用硬件 crate 测试)。 使用来自 sync_packet.rs 的规范 COM9 从属数据包(local_minus_epoch_us() == 1_163_565)和 COM12 主数据包,构建偏移序列并断言:主节点 → stratum == 0,高 quality();低离散度的从属节点 → Admit。断言没有 wifi-densepose-hardware 符号泄漏到协调器的公共 API 中(编译围栏测试)。
T8 — 确定性证明(兼容 CI,扩展 ADR-028 链)。 将一个固定的合成 3 频段、4 节点场景驱动通过 LinkGroup::ingest → ArrayCoordinator::coordinate,序列化 DirectionalEvidence.weights(舍入到 f32)和排序后的矛盾类型,并对结果进行 SHA-256。记录到 archive/v1/data/proof/expected_features.sha256 下,名称为 array_coordinator_evidence_v1;verify.py 重新生成并断言该哈希。
验收门控:cargo test -p wifi-densepose-signal -p wifi-densepose-ruvector --no-default-features 通过 T1–T8 全部测试;没有新增 unsafe;协调器的公共 API 不包含来自 wifi-densepose-hardware 的类型。
3. 影响¶
3.1 积极影响¶
- MLO 优雅降级。 失去 6 GHz 频段会降低分辨率并扩大置信区间,而不是使链路失效。
LinkGroup生命周期使“降级但仍运行”成为一等状态,而不是未被检测到的静默故障。 - 时钟质量变得可观察且可操作。 如今,漂移节点在越过 9 s 陈旧性悬崖之前,与良好节点被同等对待。
ClockQualityScore暴露了连续谱,MonitorOnly允许时钟降级的节点仍能提供证据,而不会破坏环境更新。 - 证据,而非过早决定。 协调器发出带有注意力权重和 Cramér-Rao 置信区间的
DirectionalEvidence,为 ADR-137 提供所需的来源信息,并移除当前丢弃可用周期的硬性CoherenceGateClosed丢弃。 - 复用而非重新发明。 GDI、Cramér-Rao、相干性门控、同步数据包解码和 Pearson 共识已经存在并经过测试;本 ADR 组合它们。两个重复的
geometric_diversity概念收敛到viewpoint/geometry.rs。 - 保持干净的 crate 边界。 没有套接字或线格式代码进入 signal/ruvector crate;
FrameMeta契约(ADR-136)是唯一的耦合点。
3.2 负面因素¶
- 需要管理更多状态。
LinkGroup增加了每个频段的生命周期状态和一个事件缓冲区。对于一个 4 节点、3 频段的阵列,这意味着 12 个频段状态机加上协调器——规模不大,但并非为零,并且事件必须被消费,否则会累积(像MultistaticArray::max_events一样有界)。 - 两个门控而不是一个。 运维人员和测试必须同时推理相干性以及时钟质量。
MonitorOnly中间状态虽然有用,但它是下游代码(ADR-137)必须显式处理的第三种结果,而不是简单的布尔值。 - 依赖尚未落地的兄弟 ADR。
FrameMeta(ADR-136)和矛盾消费者(ADR-137)目前均为 Proposed。在它们落地之前,协调器可以使用合成的ClockQualityScore进行测试,但无法端到端接线。mesh_aligned_us的管道目前仅存在于感知服务器中,而不是共享的FrameMeta中。
3.3 风险¶
| 风险 | 概率 | 影响 | 缓解措施 |
|---|---|---|---|
offset_stdev_us 在小同步窗口上噪声较大,导致门控在 Admit/MonitorOnly 之间抖动 |
中 | 权重逐周期抖动 | 对时钟项也使用 CoherenceGate 的迟滞模式:在 200 µs 打开,仅在高于 240 µs 时关闭;对偏移序列进行 EMA(固件已经进行 EMA 平滑,见 smoothed_used 标志) |
| 跨频段共识错误地降级了一个确实观察到不同多径的频段(在 2.4 GHz 与 6 GHz 之间合理地失去相关) | 中 | 一个有用频段退出共识 | promote_consensus 默认值 0.6 故意宽松;频段间频率相关的去相关是预期行为,因此降级需要持续丢失,且被降级的频段仍会流式传输(它不是 Exited) |
| Cramér-Rao 置信度假设质心目标;偏离质心的真实目标具有不同的界 | 低 | 偏离中心时置信区间略微乐观/悲观 | 文档中将其记录为以质心为参考的界;如果需要目标特定的置信度,ADR-137 可以按假设重新计算 |
ADR-136 的 FrameMeta 结构在其自身设计期间发生变化,破坏 clock_quality 字段 |
中 | 重新接线协调器的输入提取 | 协调器消费 ClockQualityScore 值对象,而不是直接消费 FrameMeta;只有薄的提取适配器会变化 |
4. 已考虑的替代方案¶
4.1 就地扩展 MultiBandCsiFrame 而不是新建 LinkGroup¶
已拒绝。MultiBandCsiFrame 是一个值类型快照,在 multistatic.rs 和感知服务器中到处被消费;将可变频段生命周期状态附加到它会破坏其 Clone 廉价、按值传递的契约,并使每个消费者与生命周期逻辑纠缠在一起。一个独立的聚合通过 consensus_frame() 产生 MultiBandCsiFrame,保持快照类型不可变,并将生命周期隔离。
4.2 将 ArrayCoordinator 作为 MultistaticArray 的一部分¶
已拒绝。MultistaticArray 是一个具有单一聚合不变量边界的聚合根(其视点、其相干窗口)。读取每个节点 LinkGroup 的跨聚合门控应属于领域服务,而不是聚合内部——将其折叠进去会迫使聚合持有对其他聚合的引用,违反 DDD 边界,并使其无法独立测试。该服务每次调用无状态,并且可以轻易进行单元测试。
4.3 保留二元相干门控,并将时钟作为第二个二元门控¶
已拒绝。两个与运算的二元门控仍然会丢弃分级信息:一个 90% 相干且时钟为 210 µs 的节点会被硬性拒绝,从而丢弃真实证据。MonitorOnly 中间状态正是重点——它接纳证据,同时暂缓环境更新。纯二元设计无法表达“将其用于运动证据,但不用于重新学习房间”。
4.4 在 ESP32 上推导时钟质量并发送单个字节¶
暂时拒绝。ESP32 固件已经计算 EMA 偏移(smoothed_used 标志),发送预计算的质量字节可以节省主机工作。但主机拥有完整的跨所有节点的偏移序列,并且可以计算单个节点无法计算的比较性分层和离散度。逐节点自我评估也无法检测自信地错误的节点。从现有 SyncPacket 流在主机侧推导可以保持固件不变(无需重新刷写),并集中进行跨节点比较。一旦 ADR-110 固件暴露更丰富的同步遥测字段,可以重新考虑。
4.5 使用原始 guard_interval_us 拒绝机制处理时钟¶
已拒绝。现有的 MultistaticConfig.guard_interval_us(5 ms 扩展)是一个时间戳对齐合理性检查,而不是时钟质量度量——它能捕获严重失步,但对破坏跨节点相位的亚毫秒级离散度没有任何说明。两者是互补的:guard_interval_us 保持为粗粒度对齐前置条件;ClockQualityScore.offset_stdev_us 是馈送到门控的细粒度质量项。
5. 相关 ADR¶
| ADR | 关系 |
|---|---|
| ADR-008(CSI 帧基元) | 基础:CsiFrame/CanonicalCsiFrame 是 LinkGroup 聚合的每频段帧类型 |
| ADR-029(RuvSense 多静态) | 扩展:LinkGroup::consensus_frame() 馈送现有的 MultistaticFuser;协调器提供 fuse() 先前内部推导的注意力权重 |
| ADR-030(持久场模型) | 门控:环境/模型更新正是时钟质量退化时 MonitorOnly 所暂缓的内容 |
| ADR-031(RuView 感知优先 RF 模式) | 扩展:本 ADR 直接构建在 ADR-031 引入的 viewpoint/geometry.rs、coherence.rs、attention.rs、fusion.rs 之上 |
| ADR-110(ESP32-C6 固件扩展) | 基础:SyncPacket(魔数 0xC511A110)及其 local_minus_epoch_us/mesh_aligned_us_for_sequence 是 ClockQualityScore 的来源;±100 µs 目标定义了 200 µs 门控下限 |
| ADR-136(RuView Rust 流式引擎) | 契约:FrameMeta 携带 mesh_aligned_us + clock_quality;协调器读取这些而不是原始数据包 |
| ADR | 关系 |
|---|---|
| ADR-137(融合引擎质量评分) | 下游消费者:DirectionalEvidence.contradictions(ContradictionFlag)是约定的交接点;ADR-137 附加模型/隐私版本以补全溯源元组 |
6. 参考资料¶
生产代码¶
v2/crates/wifi-densepose-signal/src/ruvsense/multiband.rs—MultiBandCsiFrame、MultiBandBuilder、compute_cross_channel_coherence、pearson_correlation_f32(共识复用);LinkGroup将在此落地v2/crates/wifi-densepose-signal/src/ruvsense/multistatic.rs—MultistaticFuser、FusedSensingFrame、attention_weighted_fusion、geometric_diversity、MultistaticConfig.guard_interval_usv2/crates/wifi-densepose-ruvector/src/viewpoint/geometry.rs—GeometricDiversityIndex::compute/is_sufficient、CramerRaoBound::estimate、ViewpointPosition、NodeIdv2/crates/wifi-densepose-ruvector/src/viewpoint/coherence.rs—CoherenceState、CoherenceGate(相位项);ClockQualityScore/ClockQualityGate将在此落地v2/crates/wifi-densepose-ruvector/src/viewpoint/attention.rs—CrossViewpointAttention、GeometricBias(softmax 形状参考)v2/crates/wifi-densepose-ruvector/src/viewpoint/fusion.rs—MultistaticArray聚合、ViewpointFusionEvent、FusionError::CoherenceGateClosed;ArrayCoordinator将在此落地v2/crates/wifi-densepose-hardware/src/sync_packet.rs—SyncPacket、SYNC_PACKET_MAGIC = 0xC511A110、local_minus_epoch_us、apply_to_local、mesh_aligned_us_for_sequencev2/crates/wifi-densepose-sensing-server/src/main.rs—NodeState::latest_sync、mesh_aligned_us_for_csi_frame、9 秒陈旧门限(ClockQualityScore.age_us上限的来源)docs/adr/ADR-110-esp32-c6-firmware-extension.md— §A0.10 实测 104 µs 偏移标准差,§A0.12 同步报文线格式archive/v1/data/proof/expected_features.sha256— 待添加哈希条目array_coordinator_evidence_v1;verify.py中array_coordinator_check()扩展
外部参考资料¶
- Mardia, K.V. & Jupp, P.E. (2000). Directional Statistics. Wiley. — 支撑
CoherenceState与 >2σ 矛盾检验的圆形相量一致性。 - Van Trees, H.L. (2002). Optimum Array Processing. Wiley. 第 8 章。 —
CramerRaoBound用于可信区间的 Cramér-Rao 界与 Fisher 信息矩阵。 - IEEE 802.11be(WiFi-7)多链路操作。 —
LinkGroupFreqSet 抽象所针对的并发多频段流模型。 - IEEE 802.15.4 时间同步。 — ADR-110 的
SyncPacket与ClockQualityScore.stratum字段所基于的层级/网格纪元模型。
实现状态与集成(2026-05-29)¶
属于 ADR-136 流式引擎系列 -- 骨架/脚手架,信任优先,大部分尚未进入实时 20 Hz 路径。系列定位参见 ADR-136(实现状态)。
已构建 -- 经过测试的构建块(提交 fc7674bde,问题 #842):ClockQualityGate(位于 wifi-densepose-ruvector)以及 ArrayCoordinator + DirectionalEvidence(位于 wifi-densepose-signal,放置于此以避免依赖循环)。8 个测试。
集成胶水 -- 尚未进入实时路径: LinkGroup 每频段共识聚合;ADR-110 SyncPacket UDP 解码 -> FrameMeta.mesh_aligned_us;以及每个节点的实时一致性/时钟质量数据流。
信任贡献: 只有同步良好、部署位置良好的节点才被允许改变世界模型;时钟退化节点仍会提供证据,但被置于仅观察模式。
本页原文 Markdown:在 AtomGit 查看·内容源自开源项目 wi/RuView