跳转至

ADR-137:含证据引用与矛盾标记的融合引擎质量评分

字段 值
状态 已接受 — 部分(构建块已构建并通过测试;集成胶水待完成 — 参见实施状态,提交 4fa3847ac)
日期 2026-05-28
决策者 ruv
代码库目标 wifi-densepose-signal(ruvsense/multistatic.rs — fuse、attention_weighted_fusion);wifi-densepose-ruvector(viewpoint/fusion.rs — MultistaticArray);wifi-densepose-bfld(event.rs)
关联 ADR-029(RuvSense 多静态)、ADR-031(RuView 传感优先 RF 模式)、ADR-118(BFLD 波束赋形反馈层)、ADR-134(CSI→CIR 时域多径)、ADR-135(空房间基线校准)、ADR-136(RuView Rust 流式引擎)、ADR-138(WiFi-7 MLO LinkGroup / ArrayCoordinator 时钟质量门控)

1. 背景

1.1 现有差距

多静态融合阶段决定对每个传感节点的信任程度,并输出单个融合帧,但它丢弃了用于做出该决策的所有输入。对两个融合实现进行 grep 即可证实这一点:

  • v2/crates/wifi-densepose-signal/src/ruvsense/multistatic.rs(MultistaticFuser::fuse,第 196–282 行)返回一个 FusedSensingFrame,其唯一的质量字段是 cross_node_coherence: f32(第 80 行)。该标量由 compute_weight_coherence()(第 441–460 行)计算得出,是对 softmax 注意力权重上的归一化香农熵——这是一个单一数字,没有记录哪些权重产生了它、哪些子载波驱动了注意力 logits,也没有记录 CIR 门(cir_gate_coherence,第 292–327 行)是否真正发挥了作用,还是静默回退到了 CirError::UnsanitizedPhase。

  • v2/crates/wifi-densepose-ruvector/src/viewpoint/fusion.rs(MultistaticArray::fuse,第 358–436 行)更丰富——它会发出 ViewpointFusionEvent 值(第 183–219 行),并在 FusedEmbedding 上报告 gdi / n_effective——但其质量信号仍然分散在异构通道中:输出结构上的 coherence: f32、CoherenceGateTriggered { accepted } 事件,以及错误路径上的 FusionError::CoherenceGateClosed。没有一条可审计的记录能够说明这个融合输出值得信赖,因为 X、Y、Z,但请注意矛盾 C。

实际发生的验证被丢弃而非记录:

  • multistatic.rs::fuse 检查 timestamp_us 的散布情况与 guard_interval_us(第 205–215 行)的对比,并返回 MultistaticError::TimestampMismatch——但在成功路径上,时间戳通过(以及通过多少余量)的事实从未被向前传递。消费者无法区分一个由微秒级对齐节点融合的帧,与一个在 5000 µs 保护间隔的 4999 µs 边缘处融合的帧。

  • 两种实现都没有检查校准对齐。ADR-135 为每个节点确定了 BaselineCalibration,带有 captured_at_unix_s 和 tier,而 BaselineCalibration::subtract() 已经会返回 CalibrationError::TierMismatch。但融合阶段不知道每个节点帧应用了哪个基线(如果有的话),因此无法检测到危险情况:节点 A 的帧使用新鲜校准做了基线相减,而节点 B 的帧使用的是过时校准——产生了尺度不可比较的振幅,而 attention_weighted_fusion(第 364–435 行)中的注意力 softmax 会将这些振幅静默地平均在一起。

  • 振幅尺度可比性是假设的,而非强制执行的。 attention_weighted_fusion 计算每个节点的振幅向量与共识均值之间的余弦相似度(第 384–397 行)。余弦相似度按节点具有尺度不变性,这掩盖了问题:两个形状相同但增益相差 2× 的节点看起来完全一致,然而加权和融合(第 411–422 行)会累加原始的 w * amp[i],因此无论其注意力权重如何,幅度较大的节点都会主导融合后的振幅。§2.5 中的修复方案是在池化之前进行归一化,但目前代码库中没有任何地方显式地执行这一操作。

在下游,BFLD 隐私层完全无法对融合质量做出反应。wifi-densepose-bfld/src/event.rs 构造带有 privacy_class 的 BfldEvent(第 60 行),并通过 apply_privacy_gating()(第 112–117 行)在 Restricted 级别掩码身份字段;privacy_gate.rs::PrivacyGate::demote(第 31–75 行)是单调降级原语。但降级决策由策略驱动,而非传感证据。没有任何路径可以让“融合引擎检测到两个节点对世界的感知不一致”这一事实降低发出的隐私类别。一个存在矛盾的融合结果与一个干净的融合结果以相同的类别发布。

1.2 本 ADR 新增内容

一个单一、可序列化的 QualityScore,伴随每个融合帧传播,用证据而非标量回答四个问题:

  1. 这次融合有多好? — base_coherence 加上产生它的 per_node_weights。
  2. 为什么好(或坏)? — 一组 EvidenceRef 值,指明触发过的具体检查(相干门限被超过、CIR 主抽头比、权重熵、已应用的校准)。
  3. 它有什么问题? — 一组 ContradictionFlag 值,对应那些失败但被容忍的验证(时间戳处于保护间隔边缘、校准 ID 不一致、相位对齐失败、漂移轮廓冲突)。
  4. 是否可以以完整保真度发布? — 非空的矛盾集合会降低 BFLD 的 privacy_class 并发出一条见证记录,遵循项目规则:每个发出的语义状态都可追溯到信号证据 + 模型/校准版本 + 隐私决策。

这是 ADR-135 CalibrationDeviationScore 在融合层的对应物:ADR-135 将一个帧与一个基线进行评分,而 ADR-137 将一个融合与其所有贡献节点帧及其基线进行评分。

1.3 流水线位置

Per-node CSI (post phase_sanitizer, phase_align, ADR-135 subtract)
   → CalibratedFrame wrapper            ← NEW (carries calibration_id, capture_ns)
   → multistatic.rs::fuse()
        ├─ capture_ns epoch-alignment check  → ContradictionFlag::TimestampMismatch
        ├─ calibration_id agreement check     → ContradictionFlag::CalibrationIdMismatch
        ├─ normalize-then-concat (per §2.5)
        ├─ attention_weighted_fusion()        → EvidenceRef::WeightEntropy, per_node_weights
        └─ cir_gate_coherence()               → EvidenceRef::CirDominantTapRatio
   → (FusedSensingFrame, QualityScore)   ← NEW tuple return
   → ruvector MultistaticArray (embedding fusion, same QualityScore contract)
   → BFLD emitter
        └─ if !contradiction_flags.is_empty():
              privacy_class = privacy_class.max(Restricted)   (demote)
              emit witness record (ADR-134 proof chain)
   → BfldEvent

The QualityScore 是在 fuse 期间 计算的,而不是事后附加上去的,因为其所记录的证据(注意力权重、CIR 回退决策、时间戳裕量)目前只存在于该函数的作用域内。


2. 决策

2.1 QualityScore:统一融合质量记录

QualityScore 是每个融合阶段的规范输出,与现有的帧/嵌入类型一起返回。它定义在 ruvsense/multistatic.rs 中(从 ruvsense/mod.rs 重新导出),并被 viewpoint/fusion.rs 和 wifi-densepose-bfld 原样使用。

use num_complex::Complex32;

/// Identifies which sensing family produced a fused frame.  Lets a single
/// QualityScore be correlated across the signal-domain fuser
/// (`multistatic.rs`) and the embedding-domain fuser (`viewpoint/fusion.rs`).
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum FamilyId {
    /// `ruvsense/multistatic.rs` CSI/CIR-domain fusion.
    MultistaticCsi,
    /// `ruvector/viewpoint/fusion.rs` AETHER-embedding fusion.
    ViewpointEmbedding,
}

/// Auditable quality record for one fused frame.
///
/// Every semantic state downstream of fusion traces back to exactly one
/// `QualityScore`, which in turn names the signal evidence
/// (`evidence_refs`), the calibration version (`calibration_id`), and the
/// privacy-relevant disagreements (`contradiction_flags`) that informed it.
#[derive(Debug, Clone)]
pub struct QualityScore {
    /// Which fuser produced this score.
    pub family_id: FamilyId,
    /// Capture-clock timestamp (ns) of the fused cycle, derived from the
    /// median of the contributing node `capture_ns` values.
    pub capture_ns: u64,
    /// The calibration epoch all contributing frames agreed on, or `None`
    /// when frames disagreed (see `ContradictionFlag::CalibrationIdMismatch`).
    pub calibration_id: Option<CalibrationId>,
    /// Coherence in [0, 1] before any contradiction penalty is applied.
    /// For the CSI fuser this is the entropy-of-weights value currently
    /// returned as `cross_node_coherence`; for the embedding fuser it is the
    /// `CoherenceState::coherence()` value.
    pub base_coherence: f32,
    /// Per-contributing-node attention weight, node-index aligned with the
    /// fused frame's `node_frames` / viewpoint list.  Sums to ~1.0.
    pub per_node_weights: Vec<f32>,
    /// Concrete checks that fired *in support* of this fusion.
    pub evidence_refs: Vec<EvidenceRef>,
    /// Tolerated-but-recorded disagreements.  A non-empty set forces a BFLD
    /// privacy demotion (see §2.7).
    pub contradiction_flags: Vec<ContradictionFlag>,
    /// Monotonic capture-clock time at which this score was computed (ns).
    pub timestamp_computed_ns: u64,
}

/// Calibration epoch identifier.  Derived from the ADR-135
/// `BaselineCalibration::captured_at_unix_s` plus device id; stable across
/// reboots, changes only on recalibration.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct CalibrationId(pub u64);

QualityScore 有意镜像了 ADR-136 中引入的 QualityScored trait 的形状(流式引擎帧契约)。它实现该 trait,以便流式引擎可以从任意阶段获取统一的质量视图:

/// Defined in ADR-136 (`ruview-streaming-engine`); re-stated here for the
/// `impl`.  A stage that produces quality-scored output implements this so
/// the engine can route, gate, and log on quality uniformly.
pub trait QualityScored {
    fn quality(&self) -> &QualityScore;
}

impl QualityScored for (FusedSensingFrame, QualityScore) {
    fn quality(&self) -> &QualityScore {
        &self.1
    }
}

为什么使用结构体,而不是在 FusedSensingFrame 上增加更多字段: 两个融合器(multistatic.rs 和 viewpoint/fusion.rs)产生不同的载荷(FusedSensingFrame 与 FusedEmbedding),但应产生相同的质量契约。共享的 QualityScore 是唯一能让 BFLD 层统一处理二者的方式。将质量字段内联到每个载荷中,会迫使隐私逻辑按载荷类型分支。

2.2 EvidenceRef:融合为何被信任

EvidenceRef 记录正面证据。每个变体携带的是越过阈值的值,而不仅仅是一个布尔值,因此见证记录(§2.7)可复现。

/// A single piece of positive evidence supporting a fusion decision.
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum EvidenceRef {
    /// The coherence-gate threshold was met. `coherence` is the value,
    /// `threshold` the configured gate (mirrors ADR-031 coherence gate and
    /// `viewpoint/coherence.rs::CoherenceGate`).
    CoherenceGateThreshold { coherence: f32, threshold: f32 },
    /// The ADR-134 CIR dominant-tap ratio contributed to the gate. `ratio`
    /// is `Cir::dominant_tap_ratio`; `blended` is true when it was actually
    /// folded into `base_coherence` (false on `UnsanitizedPhase` fallback).
    CirDominantTapRatio { ratio: f32, blended: bool },
    /// Attention-weight entropy supported a balanced (multi-node) fusion.
    /// `normalized_entropy` is the `compute_weight_coherence` output.
    WeightEntropy { normalized_entropy: f32, n_nodes: usize },
    /// An ADR-135 baseline was applied to every contributing frame at a
    /// single agreed calibration epoch before pooling.
    CalibrationApplied { calibration_id: CalibrationId, n_frames: usize },
}

CirDominantTapRatio { blended: false } 本身也是有用的证据:它记录了 CIR 门控被尝试但发生了回退,而这一点目前是不可见的(multistatic.rs 第 321 行的 Err(CirError::UnsanitizedPhase) 分支会静默返回 freq_coherence)。

2.3 ContradictionFlag:出现错误但被容忍的情况

ContradictionFlag 记录那些失败但并非致命的校验。这些情况中,当前代码要么直接报错(失去优雅降级的机会),要么静默通过(失去发出警告的机会)。

/// A tolerated disagreement detected during fusion.  A non-empty set lowers
/// the emitted BFLD privacy_class (§2.7) and produces a witness record.
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum ContradictionFlag {
    /// Node capture_ns values spread within the guard interval but beyond a
    /// stricter "comparable" sub-threshold.  Carries the observed spread.
    TimestampMismatch { spread_ns: u64, soft_guard_ns: u64 },
    /// Contributing frames carried different calibration_id values.  `expected`
    /// is the modal (most common) id; `seen` counts the disagreeing frames.
    CalibrationIdMismatch { expected: CalibrationId, disagreeing: usize },
    /// Phase alignment (LO offset estimation, `phase_align.rs`) did not
    /// converge for at least one node, so its phase contribution is suspect.
    PhaseAlignmentFailed { node_idx: usize },
    /// A node's ADR-135 drift_score / DriftProfile conflicts with the array
    /// consensus (e.g., one node reports a static environment while the
    /// majority report motion), suggesting that node is mis-calibrated.
    DriftProfileConflict { node_idx: usize, drift_score: f32 },
    /// Raised upstream by the ADR-138 `ArrayCoordinator`: a node's coherence
    /// dropped beyond `sigma`σ of its rolling mean, so its observation
    /// contradicts the array's rolling expectation.
    CoherenceDrop { node_idx: usize, sigma: f32 },
    /// Raised upstream by the ADR-138 `ArrayCoordinator`: the array's Geometric
    /// Diversity Index fell below the geometry-sufficiency floor, so directional
    /// estimates are under-determined. Carries the observed GDI.
    GeometryInsufficient { gdi: f32 },
}

ContradictionFlag 是融合路径中容忍分歧的唯一规范类型;它在此处定义,并由 ADR-138 复用(而非重新声明)。前四个变体源自 multistatic.rs::fuse(§2.4)内部;最后两个(CoherenceDrop、GeometryInsufficient)源自上游一级的 ADR-138 ArrayCoordinator,并通过 DirectionalEvidence.contradictions 到达,fuse 会将其折叠到同一个 QualityScore.contradiction_flags 向量中。node_idx 是融合帧节点顺序中的索引;协调器的 NodeId 会在交接时解析为该索引。

MultistaticError::TimestampMismatch(硬错误,第 47 行)与 ContradictionFlag::TimestampMismatch 之间的区分是有意为之:

  • 硬错误在 spread > guard_interval_us 时触发——这些帧根本不属于同一个感知周期,因此不得融合。
  • 软标志在 soft_guard_ns < spread <= guard_interval_us 时触发——这些帧可以融合(它们位于 TDMA 周期内),但对齐足够松散,融合输出不应以完整身份保真度发布。默认 soft_guard_ns = guard_interval_us / 5(当 guard 为 5 µs 时为 1000 ns)。

2.4 fuse() 重构:验证-记录-融合

multistatic.rs::fuse 改为返回 Result<(FusedSensingFrame, QualityScore), MultistaticError>。硬错误前置条件(NoFrames、InsufficientNodes、DimensionMismatch 以及硬 TimestampMismatch)保持不变。新逻辑会在现有遍历过程中构建证据列表和矛盾列表。

pub fn fuse(
    &self,
    node_frames: &[CalibratedFrame],   // §2.5: wrapper, was &[MultiBandCsiFrame]
) -> Result<(FusedSensingFrame, QualityScore), MultistaticError> {
    if node_frames.is_empty() {
        return Err(MultistaticError::NoFrames);
    }

    let mut evidence = Vec::new();
    let mut contradictions = Vec::new();

    // ---- capture_ns epoch alignment (hard + soft) -----------------------
    if node_frames.len() > 1 {
        let min = node_frames.iter().map(|f| f.capture_ns).min().unwrap();
        let max = node_frames.iter().map(|f| f.capture_ns).max().unwrap();
        let spread = max - min;
        let guard_ns = self.config.guard_interval_us * 1000;
        if spread > guard_ns {
            return Err(MultistaticError::TimestampMismatch {
                spread_us: spread / 1000,
                guard_us: self.config.guard_interval_us,
            });
        }
        let soft = guard_ns / 5;
        if spread > soft {
            contradictions.push(ContradictionFlag::TimestampMismatch {
                spread_ns: spread,
                soft_guard_ns: soft,
            });
        }
    }

    // ---- calibration_id agreement ---------------------------------------
    let calibration_id = resolve_calibration_id(node_frames, &mut evidence, &mut contradictions);

    // ---- normalize then attention-pool (§2.5) ---------------------------
    let (amps, phases) = normalize_by_calibration(node_frames);
    let (fused_amp, fused_ph, base_coherence, weights) =
        attention_weighted_fusion(&amps, &phases, self.config.attention_temperature);
    evidence.push(EvidenceRef::WeightEntropy {
        normalized_entropy: base_coherence,
        n_nodes: weights.len(),
    });

    // ---- CIR gate (records blended/fallback as evidence) ----------------
    let coherence = self.cir_gate_coherence_recorded(base_coherence, node_frames, &mut evidence);

    // ---- phase-alignment + drift conflicts ------------------------------
    record_phase_and_drift_conflicts(node_frames, &mut contradictions);

    let now = monotonic_capture_ns();
    let quality = QualityScore {
        family_id: FamilyId::MultistaticCsi,
        capture_ns: median_capture_ns(node_frames),
        calibration_id,
        base_coherence,
        per_node_weights: weights,
        evidence_refs: evidence,
        contradiction_flags: contradictions,
        timestamp_computed_ns: now,
    };
    let frame = FusedSensingFrame { /* existing fields, coherence = coherence */ };
    Ok((frame, quality))
}

attention_weighted_fusion 仅改为返回其 weights 向量(它已在第 401–408 行计算该向量),而不是丢弃它——per_node_weights 正是该向量,将其暴露出来不会带来额外成本。

接口边界: FusedSensingFrame 保留 cross_node_coherence 以向后兼容,并设置为门控后的 coherence。新消费者读取 QualityScore.base_coherence;帧上的标量现在是派生值,而非权威值。

2.5 先归一化再拼接:显式 CalibratedFrame

目前 fuse 消费 &[MultiBandCsiFrame],并依赖隐藏在 hardware_norm.rs::CanonicalCsiFrame 中的隐式 z-score 归一化。ADR-137 通过引入一个薄包装器使校准显式化,该包装器将 ADR-135 的校准来源携带到融合器:

/// A node frame whose amplitude/phase have been baseline-subtracted and
/// normalized by a *named* ADR-135 calibration.  The wrapper makes the
/// calibration provenance an explicit fusion input rather than an implicit
/// property of CanonicalCsiFrame.
#[derive(Debug, Clone)]
pub struct CalibratedFrame {
    /// The underlying multi-band frame (per-channel amplitude/phase).
    pub inner: MultiBandCsiFrame,
    /// Capture-clock timestamp (ns).  Promoted from `timestamp_us * 1000`
    /// when the source only has microsecond resolution.
    pub capture_ns: u64,
    /// Which ADR-135 baseline normalized this frame, or `None` if the node
    /// is running uncalibrated (ADR-135 fallback mode).
    pub calibration_id: Option<CalibrationId>,
    /// Per-subcarrier gain applied during normalization (from the ADR-135
    /// `amp_mean` / `amp_variance`), retained so the fuser can renormalize
    /// onto a common scale before pooling.
    pub norm_gain: Vec<f32>,
    /// Per-subcarrier phase offset removed (from the ADR-135 circular mean).
    pub norm_phase_offset: Vec<f32>,
}

normalize_by_calibration 将每个节点的幅度除以其自身的 norm_gain RMS,使得归一化后,无论每个节点的硬件增益如何,所有节点的幅度都变为单位尺度。只有在这之后,注意力池才会运行。这弥补了 §1.1 中描述的尺度可比性漏洞:余弦相似度注意力 logits 和加权求和现在在同一尺度上运行,因此决定节点贡献的是注意力权重(而非响度)。

为什么显式优于隐式: hardware_norm.rs 中的 z-score 归一化使用从包含任何占用者的实时信号中计算得到的总体统计量。ADR-135 的基线统计量是从一个已知为空的房间计算得到的。按基线进行归一化(a)使节点在一个具有物理意义的零点上可比,(b)为融合器提供其检测跨节点校准不一致所需的 calibration_id。该包装器每个节点帧额外消耗 O(K) 内存(两个 Vec<f32>),相对于它所包装的 MultiBandCsiFrame 可忽略不计。

2.6 嵌入域融合器:相同契约

viewpoint/fusion.rs::MultistaticArray::fuse 被修改为返回 Result<(FusedEmbedding, QualityScore), FusionError>,其中 family_id: FamilyId::ViewpointEmbedding。其现有机制到统一记录的映射如下:

QualityScore 字段 viewpoint/fusion.rs 中的来源
base_coherence self.coherence_state.coherence()(第 382 行)
per_node_weights 来自 self.attention.fuse(...) 的注意力权重(第 408 行)——已暴露,目前位于 CrossViewpointAttention 内部
evidence_refs → CoherenceGateThreshold CoherenceGate::evaluate(第 383 行)以及已配置的 coherence_threshold
contradiction_flags → DriftProfileConflict 某个 snr_db 通过过滤但其相位差序列偏离一致多数派的视角
calibration_id 来自每个 ViewpointEmbedding 的源 CalibratedFrame

现有的 ViewpointFusionEvent::CoherenceGateTriggered 和 FusionError::CoherenceGateClosed 被保留——它们仍然是控制流信号——而 QualityScore 成为随帧传输的数据信号。CoherenceGateClosed 错误仍然中止融合;QualityScore 只在成功路径上产生。一个开启但接近阈值的门会记录带有裕量的 EvidenceRef::CoherenceGateThreshold,因此一个勉强开启的门是可审计的。

2.7 将矛盾接入 BFLD 隐私边界

这就是融合质量成为隐私决策的地方。BFLD 发射器(wifi-densepose-bfld)增加一条规则:

具有非空 contradiction_flags 集合的 QualityScore 会强制使发出的 BfldEvent.privacy_class 至少为 Restricted。

因为 PrivacyClass 是有序的(Raw=0 < Derived=1 < Anonymous=2 < Restricted=3,lib.rs 第 84–94 行),且降级是单调的(privacy_gate.rs::demote 拒绝任何类别编号的降低),"至少 Restricted" 就是 privacy_class.max(Restricted)——即降级,而不是升级:

// In the BFLD emitter, before BfldEvent::with_privacy_gating(...):
let effective_class = if quality.contradiction_flags.is_empty() {
    policy_class                       // normal policy decision
} else {
    policy_class.max(PrivacyClass::Restricted)   // demote on contradiction
};

在 Restricted 级别,BfldEvent::apply_privacy_gating(event.rs 第 112–117 行)已经会将 identity_risk_score 和 rf_signature_hash 置空。因此,一次矛盾的融合——两个节点在校准、时间戳、相位或漂移上不一致——会自动停止泄露身份表面字段。理由:矛盾意味着系统不确定它融合的是谁的信号;在不可信融合上发出身份风险分数或 RF 签名哈希,正是隐私层旨在防止的失败。

非空矛盾集合还会通过 ADR-134 证明链发出一个见证记录(verify.py / expected_features.sha256 / source-hashes.txt 见证模式,ADR-134 §2.10)。该记录捕获:capture_ns、family_id、contradiction_flags(及其携带的值)、得到的 effective_class,以及 per_node_weights 的哈希。这使得每次隐私降级都可复现且可审计——满足项目不变量:每个发出的语义状态都可追溯到信号证据 + 校准版本 + 已记录的隐私决策。

QualityScore.contradiction_flags non-empty
   ├─ effective_class = policy_class.max(Restricted)   (demote, monotonic)
   ├─ BfldEvent gated → identity_risk_score = None, rf_signature_hash = None
   └─ witness record { capture_ns, family_id, flags, effective_class,
                       blake3(per_node_weights) } → ADR-134 proof chain

接口边界: BFLD crate 仅依赖 QualityScore(一个从 wifi-densepose-signal 重新导出的普通数据结构体),而不依赖融合器本身。没有引入新的控制耦合;发射器读取两个字段(contradiction_flags、calibration_id)和一个策略类别。

2.8 提议的 Rust API 表面(摘要)

项目 位置 类型
QualityScore, FamilyId, CalibrationId ruvsense/multistatic.rs,重新导出的 ruvsense/mod.rs 结构体 / 枚举
EvidenceRef, ContradictionFlag ruvsense/multistatic.rs 枚举
CalibratedFrame ruvsense/multistatic.rs 结构体
impl QualityScored for (FusedSensingFrame, QualityScore) ruvsense/multistatic.rs trait 实现(ADR-136 trait)
MultistaticFuser::fuse → Result<(FusedSensingFrame, QualityScore), _> ruvsense/multistatic.rs 修改后的签名
MultistaticArray::fuse → Result<(FusedEmbedding, QualityScore), _> viewpoint/fusion.rs 修改后的签名
BFLD 发射器矛盾→降级规则 wifi-densepose-bfld 发射器 新逻辑

2.9 测试 / 验收

T1 — 在干净融合上记录证据(单元测试,multistatic.rs)。 两个 CalibratedFrame,具有相同的 calibration_id,capture_ns 在 soft_guard_ns 内,相位已净化。断言返回的 QualityScore 满足 contradiction_flags.is_empty(),包含 EvidenceRef::WeightEntropy 和 EvidenceRef::CalibrationApplied,并且 per_node_weights.len() == 2,总和约为 1.0。

T2 — CIR 回退被记录而非隐藏(单元测试)。 输入一个相位未净化的帧(相位方差 > 10 rad²,触发 CirError::UnsanitizedPhase)。断言 evidence_refs 包含 EvidenceRef::CirDominantTapRatio { blended: false, .. },并且 base_coherence 等于门控前的频率相干性(保留优雅回退)。

T3 — 软时间戳矛盾(单元测试)。 两个帧的 capture_ns 间隔 > soft_guard_ns 但 <= guard_interval。断言成功(没有 MultistaticError),并且 contradiction_flags 包含 TimestampMismatch { spread_ns, .. }。

T4 — 校准 ID 不匹配(单元测试)。 两个帧具有不同的 calibration_id。断言 QualityScore.calibration_id == None,并且 contradiction_flags 包含 CalibrationIdMismatch { expected, disagreeing: 1 }。

T5 — 硬时间戳错误仍然为硬错误(单元测试、回归)。 间隔 > guard_interval。断言 Err(MultistaticError::TimestampMismatch) —— 不产生 QualityScore。确认现有测试 timestamp_mismatch_error(multistatic.rs 第 585 行)在新签名下仍然通过。

T6 — 先归一化再拼接的尺度不变性(单元测试)。 两个节点,幅度形状相同,节点 B 放大 2×。断言在 normalize_by_calibration 之后,融合幅度与单节点结果相差在 1% 以内(响度不再占主导),并且 per_node_weights 大致相等。

T7 — 矛盾时隐私降级(单元测试,wifi-densepose-bfld)。 构造一个包含一个 ContradictionFlag 且策略类为 Derived 的 QualityScore。断言发出的 BfldEvent.privacy_class == Restricted,并且 identity_risk_score 和 rf_signature_hash 序列化为缺失(复用 event.rs 中的门控断言)。

T8 — 干净融合保留策略类(单元测试)。 与 T7 相同,但 contradiction_flags 为空。断言 privacy_class == Derived(不降级),并且身份字段存在。

T9 — 见证确定性(CI 证明链)。 一个固定的两节点矛盾融合产生一个 QualityScore,其见证记录哈希到 expected_features.sha256 中键 fusion_quality_contradiction_v1 下的已记录值。verify.py 扩展 fusion_quality_check() 可复现该值。对应 ADR-135 §2.12 Tier 7 和 ADR-134 §2.10。

T10 — QualityScored trait 往返(单元测试)。 断言 (frame, quality).quality() 按引用返回内嵌的 QualityScore,满足 ADR-136 契约。

验收标准: 所有现有 multistatic.rs 测试(第 546–697 行)和 viewpoint/fusion.rs 测试(第 564–743 行)在签名更改后通过(适配为解构元组);T1–T10 通过;cargo test --workspace --no-default-features 报告 0 个失败;verify.py 使用新键打印 VERDICT: PASS。


3. 后果

3.1 正面影响

  • 融合决策变得可审计。 每个融合帧现在都携带产生其相干性的证据以及被容忍的不一致。现场工程师无需重新运行融合器即可读取某个帧为何被信任。
  • 校准不一致会被捕获。 CalibrationIdMismatch 矛盾会暴露此前不可见的故障:节点针对不同版本的基线进行归一化——即 §1.1 中无声的幅度尺度损坏。
  • CIR 回退不再无声。 EvidenceRef::CirDominantTapRatio { blended: false } 会记录当前在 multistatic.rs 第 321 行消失的 UnsanitizedPhase 回退。
  • 隐私在不确定性下安全降级。 矛盾融合不再能发布身份暴露字段;降级是单调的且有见证。
  • 一份契约,两个融合器。 信号域和嵌入域融合器暴露相同的质量语义,因此流式引擎(ADR-136)和 BFLD 层以统一方式对待它们。
  • 满足可追溯性不变量。 每个 BfldEvent 可追溯到 QualityScore → EvidenceRefs(信号证据)+ calibration_id(校准版本)+ 已记录的 effective_class(隐私决策)。

3.2 负面影响

  • 破坏性签名更改。 两个 fuse 函数的返回类型都改为元组。每个调用点和每个现有测试(multistatic.rs 和 viewpoint/fusion.rs)都必须解构。这是机械性的,但涉及约 25 个测试函数。
  • CalibratedFrame 包装器变动。 fuse 不再直接接受 &[MultiBandCsiFrame];调用方必须包装,并将 ADR-135 校准传递下去。未校准节点传入 calibration_id: None,并失去 CalibrationApplied 证据(但仍会融合)。
  • 每帧分配。 evidence_refs 和 contradiction_flags 是 Vec。在常见的干净融合情况下,它们持有 2–3 个小型 Copy 枚举;分配是有界的,但在热路径上非零。缓解措施:如果剖析显示压力,可以替换为 SmallVec(推迟——并非过早)。

3.3 风险

风险 概率 影响 缓解措施
过度激进的降级:在保护边缘处一个良性的宽松时间戳会将每个帧降级为 Restricted,抑制部署合法需要的身份特征 中等 在时钟同步勉强的节点阵列中,身份风险评分实际上被禁用 soft_guard_ns 可配置(默认 guard/5);ADR-138 的 ArrayCoordinator 时钟质量门控可以提高门槛,使时间戳矛盾仅在时钟确实退化时触发
DriftProfileConflict 误报:当一个节点合法地看到其他节点无法看到的运动时(遮挡几何) 中等 在多房间阵列中,由于部分视距导致虚假的隐私降级 冲突要求多数不一致,而不是任何单个异议节点;阈值可按部署调整
见证记录量:一个抖动的矛盾每个周期(20 Hz)产生一条见证记录 低 见证日志增长 合并相同的连续矛盾集合;仅在矛盾集合转换时发出见证记录,而不是每帧都发出
calibration_id 派生在两台设备于同一秒重新校准时发生碰撞 低 两个节点看似在校准上一致,但实际上并不一致 CalibrationId 是 hash(device_id, captured_at_unix_s),而不仅仅是时间戳
风险 概率 影响 缓解措施

4. 已考虑的替代方案

4.1 保留标量 cross_node_coherence,并添加独立的日志通道

已否决。旁路日志会将质量记录与其所描述的帧解耦;消费者无法原子地获取“该帧以及恰好产生它的确切证据”。BFLD 隐私决策必须基于产生该帧的同一数据,并在同一次调用中做出。在元组中返回的 QualityScore 保证了这种耦合;日志不能保证。

4.2 使用布尔标志而非携带证据的枚举

已否决。passed_coherence: bool 无法在见证记录中复现——阈值和数值都会丢失。ADR-135 和 ADR-134 都将“按记录值确定”作为证明链(expected_features.sha256)的要求。布尔值会破坏该链。枚举携带跨越值,正是为了让见证哈希可复现。

4.3 对所有矛盾都硬错误(无优雅降级)

已否决。将 CalibrationIdMismatch 和软性 TimestampMismatch 提升为致命 MultistaticError,会使阵列变得脆弱:任何瞬时时钟偏移或会话中途重新校准都会丢弃整个融合帧。矛盾标志的核心意义在于融合结果可用但不可完全信任——应降低保真度(隐私降级),而不是丢弃数据。真正不可融合的情况(扩散超出保护范围、维度不匹配)仍保持为硬错误。

4.4 将降级逻辑放在融合器中,而不是 BFLD 发射器中

已否决。融合器产生证据;它不应知道隐私策略。隐私类别排序和 Restricted 语义位于 wifi-densepose-bfld(PrivacyClass、PrivacyGate)中。将 max(Restricted) 决策保留在发射器中,可以保持限界上下文分离:信号处理 crate 计算什么是真实的以及置信度有多高,BFLD crate 决定什么可以被发射。融合器导出一个数据结构;发射器拥有策略。

4.5 复用 ViewpointFusionEvent 作为证据

已否决。ViewpointFusionEvent(viewpoint/fusion.rs 第 183–219 行)是 MultistaticArray 聚合的内部事件溯源日志,仅存在于 ruvector crate 中;它不会随帧传输,信号域融合器或 BFLD crate 也不了解它。QualityScore 是共享的、附加到帧上的契约,两个融合器和隐私层都认可它。


ADR 关系
ADR-029 (RuvSense Multistatic) 扩展:MultistaticFuser::fuse 获得 (FusedSensingFrame, QualityScore) 返回值;注意力/一致性机制保持不变,但其副产品现在被暴露出来
ADR-031 (Sensing-First RF Mode) 扩展:MultistaticArray::fuse 采用相同的 QualityScore 契约;一致性门控事件作为控制流保留
ADR-118 (BFLD Beamforming Feedback Layer) 消费者:BFLD 发射器读取 contradiction_flags 以降级 privacy_class;复用 PrivacyClass、PrivacyGate::demote 和 BfldEvent::apply_privacy_gating
ADR-134 (CSI→CIR) 证据来源 + 见证链:EvidenceRef::CirDominantTapRatio 记录 Cir::dominant_tap_ratio;矛盾见证记录使用 ADR-134 的 verify.py 证明模式
ADR-135 (Empty-Room Baseline Calibration) 前置条件:CalibratedFrame.calibration_id / norm_gain / norm_phase_offset 来自 BaselineCalibration;CalibrationIdMismatch 和 DriftProfileConflict 针对 ADR-135 校准和 drift_score 定义
ADR-136 (RuView Streaming Engine) 契约:QualityScore 实现 ADR-136 的 QualityScored trait,使流式引擎能够基于融合质量统一进行路由/门控
ADR-138 (LinkGroup / ArrayCoordinator Clock-Quality Gating) 细化矛盾敏感度:ArrayCoordinator 时钟质量用于确定 soft_guard_ns 阈值,使 TimestampMismatch 标志在真正退化的时钟上触发,而不是在健康的 WiFi-7 MLO 阵列上触发

6. 参考资料

生产代码

  • v2/crates/wifi-densepose-signal/src/ruvsense/multistatic.rs — MultistaticFuser::fuse (196–282), attention_weighted_fusion (364–435), compute_weight_coherence (441–460), cir_gate_coherence (292–327), MultistaticError (36–56), FusedSensingFrame (62–81)
  • v2/crates/wifi-densepose-ruvector/src/viewpoint/fusion.rs — MultistaticArray::fuse (358–436), FusedEmbedding (54–66), ViewpointFusionEvent (183–219), FusionError (109–136)
  • v2/crates/wifi-densepose-bfld/src/event.rs — BfldEvent (28–73), with_privacy_gating (79–107), apply_privacy_gating (112–117)
  • v2/crates/wifi-densepose-bfld/src/privacy_gate.rs — PrivacyGate::demote (31–75),单调降级不变量
  • v2/crates/wifi-densepose-bfld/src/lib.rs — PrivacyClass (84–94), as_u8 (114)
  • v2/crates/wifi-densepose-signal/src/ruvsense/cir.rs — Cir (265), dominant_tap_ratio (275), CirEstimator::estimate (380), CirConfig::ht20 (164)
  • v2/crates/wifi-densepose-signal/src/ruvsense/multiband.rs — MultiBandCsiFrame (47–57),由 CalibratedFrame 包装
  • v2/crates/wifi-densepose-signal/src/ruvsense/calibration.rs (ADR-135) — BaselineCalibration, CalibrationDeviationScore, drift_score
  • archive/v1/data/proof/verify.py — 见证证明链;fusion_quality_check() 扩展
  • archive/v1/data/proof/expected_features.sha256 — 待添加的哈希键 fusion_quality_contradiction_v1

外部

  • Vaswani, A. et al. (2017). "Attention Is All You Need." NeurIPS. — 在 attention_weighted_fusion 中复用了 softmax 注意力加权;per_node_weights 是暴露用于审计的注意力分布。
  • Mardia, K.V. & Jupp, P.E. (2000). Directional Statistics. Wiley. — 支撑 PhaseAlignmentFailed 检测的圆形相位共识(attention_weighted_fusion 中的 sin/cos 池化)。

实现状态与集成(2026-05-29)

属于 ADR-136 流式引擎系列的一部分——骨架/脚手架,信任优先,大部分尚未接入实时 20 Hz 路径。系列框架参见 ADR-136(实现状态)。

已构建 —— 经过测试的构建块(提交 4fa3847ac,问题 #841):QualityScore、EvidenceRef 以及规范的 ContradictionFlag;MultistaticFuser::fuse_scored() 以增量方式添加(不会破坏 fuse() 或其调用方)。6 个测试。

集成胶水 —— 尚未接入实时路径: 一旦 calibration_id 传播和相位对齐收敛信号被传递到帧上,就发出 CalibrationIdMismatch / DriftProfileConflict / PhaseAlignmentFailed;在隐私降级时发出 BFLD 见证记录。

信任贡献: 传感器一致性被显式化 —— 融合记录其所依赖的证据,任何不一致都会自动收紧下游隐私级别。


见证完整性审查(2026-06-14)—— 域分离修复

对 wifi-densepose-engine 的一次超越 SOTA 的安全审查(该组合根在 witness_of 中构建 §2.7 信任见证)发现了一个真实的见证域分离缺口,现已修复。

发现(witness-gap,HIGH)。 witness_of 将 model_version、calibration_version 和 privacy_decision 逐边界拼接,且可变长度的 evidence 列表没有携带显式计数。因此,跨越字段边界的字符串会与不同的信任决策发生碰撞——例如,一个每房间适配器 ID(ADR-150 §3.4,可受操作员影响)吸收了校准纪元的前导字节(model="…cal:00a",cal="b"),会产生与 model="…"、cal="cal:00ab" 相同的见证。两个不同的隐私相关输入元组 → 一个见证,破坏了本 ADR §2.7 见证旨在提供的“任何隐私相关差异 → 不同见证”保证。

修复。 见证现在 (a) 前置域标签 ruview.engine.witness.v1,(b) 写入显式的 8 字节证据计数,并且 (c) 为每个字段添加长度前缀(8 字节 LE 长度 ‖ 字节),因此无论内容如何,字段定界都是无歧义的。这是一次见证布局变更(按设计,所有先前见证字节均被作废);下游消费者只断言见证关系(跨运行的 assert_ne/assert_eq),而不是绝对字节,因此不会有任何破坏。

由 witness_distinguishes_model_calibration_boundary 和 witness_distinguishes_evidence_model_boundary 固定(两者在旧的 拼接方式下都会失败)。见证确定性已审查并确认无问题:没有 HashMap 迭代,也没有浮点数格式化参与哈希(浮点数仅出现在 SemanticState 语句中,而该语句位于见证之外)。

本页原文 Markdown:在 AtomGit 查看·内容源自开源项目 wi/RuView