Skip to main content

mingli_contract/
declare.rs

1//! 一片叶对自己的声明:属于哪个计算家族、哪些地方算得准、有哪些流派。
2//!
3//! 这一组是「供给侧」的自述——与 [`crate::intent`] 的需求侧对偶:
4//! 那边说「有哪几类问局」,这边说「这片叶答得起什么、答到什么程度」。
5
6use serde::Serialize;
7
8
9/// 计算家族。
10#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize)]
11pub enum Family {
12    /// A 循环群 / CRT(时间→模运算)。
13    Cyclic,
14    /// B 角度量化(星历→黄经→分段)。
15    Angular,
16    /// C 抽样 / 二进制(熵→有限格)。
17    Sampling,
18    /// D 哈希环(字符串→数→约化)。
19    Hashing,
20    /// ⟂ 飞布 / 横切(群作用)。
21    CrossCutting,
22}
23
24impl Family {
25    /// 家族中文标签(承接层展示用)。
26    #[must_use]
27    pub fn label(self) -> &'static str {
28        match self {
29            Family::Cyclic => "循环群/CRT",
30            Family::Angular => "角度量化",
31            Family::Sampling => "抽样/二进制",
32            Family::Hashing => "哈希环",
33            Family::CrossCutting => "飞布/横切",
34        }
35    }
36}
37
38/// 确定性谱:标注一项计算是确定算的、随机可复现的、还是流派欠定。
39#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)]
40pub enum Determinism {
41    /// 🟢 确定:由 Rust 确定性算出(多校验权威值/已知量)。
42    Det,
43    /// 🎲 随机·种子可复现:抽样/起卦,给定种子可复现。
44    Sto,
45    /// 🟡 欠定:流派分歧 / 待权威校验 / 大查表未取证——引擎诚实留空而非臆造。
46    Und,
47}
48
49impl Determinism {
50    /// 中文标签。
51    #[must_use]
52    pub fn label(self) -> &'static str {
53        match self {
54            Determinism::Det => "确定",
55            Determinism::Sto => "随机·种子可复现",
56            Determinism::Und => "欠定",
57        }
58    }
59}
60
61/// 确定性谱的一项:某计算方面的确定性等级与说明。
62#[derive(Debug, Clone, Copy, Serialize)]
63pub struct DetItem {
64    /// 计算方面(如「四柱」「Asc/MC」「三传」)。
65    pub aspect: &'static str,
66    /// 确定性等级。
67    pub status: Determinism,
68    /// 一句说明(校验依据 / 为何欠定)。
69    pub note: &'static str,
70}
71
72/// 构造 [`DetItem`] 的简写。
73#[must_use]
74pub const fn d(aspect: &'static str, status: Determinism, note: &'static str) -> DetItem {
75    DetItem { aspect, status, note }
76}
77
78/// 叶的一个流派。
79#[derive(Debug, Clone, Copy, Serialize)]
80pub struct SchoolItem {
81    /// 流派稳定 id(代码内使用,小写英数)。
82    pub id: &'static str,
83    /// 显示名(承接层展示)。
84    pub name: &'static str,
85    /// 是否默认流派(每叶应恰有一个默认)。
86    pub default: bool,
87    /// 一句说明:差异点 / 校验依据 / 流派归属。
88    pub note: &'static str,
89}
90
91/// 构造 [`SchoolItem`] 的简写。
92#[must_use]
93pub const fn s(id: &'static str, name: &'static str, default: bool, note: &'static str) -> SchoolItem {
94    SchoolItem { id, name, default, note }
95}