Skip to main content

qualia_core_db/sensing/
quin_index.rs

1//! Measurement index links and diagnostic validation of Quin parity.
2//!
3//! The index-link encoder uses zero metadata so both current parity contracts
4//! agree. It links a record to host-declared event/payload identities without
5//! encoding raw samples, granting trust or deciding measurement semantics.
6
7#[path = "quin_index/encode.rs"]
8mod encode;
9pub use encode::{
10    measurement_record_to_quins, proposed_predicates, MeasurementQuinError, MeasurementQuinMapping,
11    MAX_MEASUREMENT_LINK_QUINS,
12};
13
14use crate::{frame_layout, NQuin};
15
16/// Explicit results under the two currently conflicting parity conventions.
17#[derive(Clone, Copy, Debug, PartialEq, Eq)]
18pub struct MeasurementQuinParityValidation {
19    nquin_ecc_valid: bool,
20    frame_layout_valid: bool,
21}
22
23impl MeasurementQuinParityValidation {
24    pub const fn nquin_ecc_valid(self) -> bool {
25        self.nquin_ecc_valid
26    }
27
28    pub const fn frame_layout_valid(self) -> bool {
29        self.frame_layout_valid
30    }
31
32    /// A caller may proceed only after choosing the authoritative contract;
33    /// this helper makes no such choice and returns true only when both agree.
34    pub const fn conventions_agree_valid(self) -> bool {
35        self.nquin_ecc_valid && self.frame_layout_valid
36    }
37}
38
39/// Validate an existing Quin under both published parity implementations.
40///
41/// This is diagnostic only. It does not validate measurement semantics,
42/// identifiers, provenance, object tags, grants, or the meaning of metadata.
43pub fn validate_measurement_quin_parity(quin: &NQuin) -> MeasurementQuinParityValidation {
44    MeasurementQuinParityValidation {
45        nquin_ecc_valid: quin.verify_ecc_parity(),
46        frame_layout_valid: frame_layout::parity_valid(quin),
47    }
48}
49
50#[cfg(test)]
51#[path = "quin_index_tests.rs"]
52mod tests;