Skip to main content

rustysnes_cart/
tier.rs

1//! Board accuracy-tiering — the honesty marker (ADR 0003, the RustyNES ADR 0011 port).
2//!
3//! The headline claim ("N boards / coprocessors, accuracy-battery 100%") is only honest if no
4//! `BestEffort`-tier board (register-decode-only, NOT covered by the accuracy/commercial
5//! oracle) silently backs an oracle ROM. The tier is an honesty marker, NOT a behavioural
6//! one: a board's runtime behaviour is identical regardless of tier. [`board_tier`] is the
7//! single source of truth the harness honesty gate reads. See `docs/adr/0003`.
8
9use crate::header::Coprocessor;
10
11/// Accuracy-evidence tier for a board / coprocessor family.
12#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
13pub enum BoardTier {
14    /// Spec-implemented + accuracy/commercial-oracle-gated (the base map modes, DSP-1).
15    Core,
16    /// Curated long-tail: demand + a redistributable fixture/spec; unit + boot-smoke tested.
17    Curated,
18    /// Best-effort: reference-ported, register-decode tested only, NEVER accuracy-gated.
19    BestEffort,
20}
21
22impl BoardTier {
23    /// Human-readable tier name (docs / UI badges / logs).
24    #[must_use]
25    pub const fn name(self) -> &'static str {
26        match self {
27            Self::Core => "Core",
28            Self::Curated => "Curated",
29            Self::BestEffort => "BestEffort",
30        }
31    }
32
33    /// Whether this tier is covered by the accuracy / commercial-ROM oracle gate.
34    /// `Core` and `Curated` are; `BestEffort` is structurally never gated.
35    #[must_use]
36    pub const fn is_accuracy_gated(self) -> bool {
37        matches!(self, Self::Core | Self::Curated)
38    }
39}
40
41/// Classify a coprocessor family into a [`BoardTier`].
42///
43/// The base map modes ([`Coprocessor::None`] LoROM/HiROM/ExHiROM) are `Core`. As real
44/// coprocessor boards land they move from `BestEffort` → `Curated`/`Core` once a
45/// redistributable fixture or the accuracy battery backs them. The honesty gate reads THIS
46/// classifier, so it can never be the case that a `BestEffort` board sits in the oracle set.
47#[must_use]
48pub const fn board_tier(copro: Coprocessor) -> BoardTier {
49    match copro {
50        // Base ROM mapping + DSP-1 are the well-understood, oracle-gated families.
51        Coprocessor::None | Coprocessor::Dsp => BoardTier::Core,
52        // The big well-documented enhancement chips: curated as fixtures land.
53        Coprocessor::SuperFx | Coprocessor::Sa1 => BoardTier::Curated,
54        // The decompression / niche chips: best-effort until a fixture + oracle exist.
55        Coprocessor::SDd1
56        | Coprocessor::Spc7110
57        | Coprocessor::Cx4
58        | Coprocessor::Obc1
59        | Coprocessor::Srtc
60        | Coprocessor::St018 => BoardTier::BestEffort,
61    }
62}
63
64#[cfg(test)]
65mod tests {
66    use super::*;
67
68    #[test]
69    fn base_mapping_is_core_and_gated() {
70        assert_eq!(board_tier(Coprocessor::None), BoardTier::Core);
71        assert!(board_tier(Coprocessor::None).is_accuracy_gated());
72    }
73
74    #[test]
75    fn best_effort_is_never_gated() {
76        assert!(!BoardTier::BestEffort.is_accuracy_gated());
77        assert!(!board_tier(Coprocessor::Cx4).is_accuracy_gated());
78    }
79}