Skip to main content

presolve_compiler/
ordinary_template_integrity.rs

1//! Internal-only J1-P integrity allocation.
2//!
3//! These findings are deliberately not public compiler diagnostics. J19 is the
4//! first slice authorized to project Phase-J products into public diagnostics.
5
6/// The first contiguous Phase-J internal allocation, in the amendment's
7/// required order. J2 begins after this closed J1-P range.
8#[derive(Clone, Copy, Debug, Eq, PartialEq)]
9pub enum OrdinaryTemplateIntegrityCode {
10    MissingTarget,
11    DuplicateTarget,
12    DuplicateBinding,
13    TargetConstructorMismatch,
14    BindingConstructorMismatch,
15    TargetComponentMismatch,
16    DeclarationOwnershipMismatch,
17    EventActionBatchOwnershipMismatch,
18    ArtifactManifestDrift,
19    DomMarkerProjectionMismatch,
20    FormTargetReciprocityMismatch,
21    StructuralProjectionMismatch,
22    VersionPairMismatch,
23    LegacyRecordInPhaseJPath,
24    MissingRuntimeComponentInstance,
25    StaleRegistry,
26}
27
28impl OrdinaryTemplateIntegrityCode {
29    #[must_use]
30    pub const fn as_str(self) -> &'static str {
31        match self {
32            Self::MissingTarget => "PSASM1289",
33            Self::DuplicateTarget => "PSASM1290",
34            Self::DuplicateBinding => "PSASM1291",
35            Self::TargetConstructorMismatch => "PSASM1292",
36            Self::BindingConstructorMismatch => "PSASM1293",
37            Self::TargetComponentMismatch => "PSASM1294",
38            Self::DeclarationOwnershipMismatch => "PSASM1295",
39            Self::EventActionBatchOwnershipMismatch => "PSASM1296",
40            Self::ArtifactManifestDrift => "PSASM1297",
41            Self::DomMarkerProjectionMismatch => "PSASM1298",
42            Self::FormTargetReciprocityMismatch => "PSASM1299",
43            Self::StructuralProjectionMismatch => "PSASM1300",
44            Self::VersionPairMismatch => "PSASM1301",
45            Self::LegacyRecordInPhaseJPath => "PSASM1302",
46            Self::MissingRuntimeComponentInstance => "PSASM1303",
47            Self::StaleRegistry => "PSASM1304",
48        }
49    }
50}
51
52/// J1-C consumes the next reserved integrity codes before State addressing.
53#[derive(Clone, Copy, Debug, Eq, PartialEq)]
54pub enum ComputedInstanceSlotIntegrityCode {
55    MissingProjection,
56    DuplicateCacheSlot,
57    DuplicateDirtySlot,
58    ConstructorMismatch,
59    OwnershipMismatch,
60    StaleRegistry,
61    ArtifactProjectionDrift,
62}
63
64impl ComputedInstanceSlotIntegrityCode {
65    #[must_use]
66    pub const fn as_str(self) -> &'static str {
67        match self {
68            Self::MissingProjection => "PSASM1305",
69            Self::DuplicateCacheSlot => "PSASM1306",
70            Self::DuplicateDirtySlot => "PSASM1307",
71            Self::ConstructorMismatch => "PSASM1308",
72            Self::OwnershipMismatch => "PSASM1309",
73            Self::StaleRegistry => "PSASM1310",
74            Self::ArtifactProjectionDrift => "PSASM1311",
75        }
76    }
77}
78
79/// J1-A consumes the next reserved integrity codes before J2 liveness.
80#[derive(Clone, Copy, Debug, Eq, PartialEq)]
81pub enum StateInstanceStorageIntegrityCode {
82    MissingProjection,
83    DuplicateSlot,
84    ConstructorMismatch,
85    OwnershipMismatch,
86    StaleRegistry,
87    ArtifactProjectionDrift,
88    DeclarationRuntimeKey,
89    UnknownResumeSlot,
90}
91
92impl StateInstanceStorageIntegrityCode {
93    #[must_use]
94    pub const fn as_str(self) -> &'static str {
95        match self {
96            Self::MissingProjection => "PSASM1312",
97            Self::DuplicateSlot => "PSASM1313",
98            Self::ConstructorMismatch => "PSASM1314",
99            Self::OwnershipMismatch => "PSASM1315",
100            Self::StaleRegistry => "PSASM1316",
101            Self::ArtifactProjectionDrift => "PSASM1317",
102            Self::DeclarationRuntimeKey => "PSASM1318",
103            Self::UnknownResumeSlot => "PSASM1319",
104        }
105    }
106}
107
108#[cfg(test)]
109mod tests {
110    use super::{
111        ComputedInstanceSlotIntegrityCode, OrdinaryTemplateIntegrityCode,
112        StateInstanceStorageIntegrityCode,
113    };
114
115    #[test]
116    fn reserves_j1p_codes_before_j2_in_amendment_order() {
117        let codes = [
118            OrdinaryTemplateIntegrityCode::MissingTarget,
119            OrdinaryTemplateIntegrityCode::DuplicateTarget,
120            OrdinaryTemplateIntegrityCode::DuplicateBinding,
121            OrdinaryTemplateIntegrityCode::TargetConstructorMismatch,
122            OrdinaryTemplateIntegrityCode::BindingConstructorMismatch,
123            OrdinaryTemplateIntegrityCode::TargetComponentMismatch,
124            OrdinaryTemplateIntegrityCode::DeclarationOwnershipMismatch,
125            OrdinaryTemplateIntegrityCode::EventActionBatchOwnershipMismatch,
126            OrdinaryTemplateIntegrityCode::ArtifactManifestDrift,
127            OrdinaryTemplateIntegrityCode::DomMarkerProjectionMismatch,
128            OrdinaryTemplateIntegrityCode::FormTargetReciprocityMismatch,
129            OrdinaryTemplateIntegrityCode::StructuralProjectionMismatch,
130            OrdinaryTemplateIntegrityCode::VersionPairMismatch,
131            OrdinaryTemplateIntegrityCode::LegacyRecordInPhaseJPath,
132            OrdinaryTemplateIntegrityCode::MissingRuntimeComponentInstance,
133            OrdinaryTemplateIntegrityCode::StaleRegistry,
134        ];
135        assert_eq!(codes.first().map(|code| code.as_str()), Some("PSASM1289"));
136        assert_eq!(codes.last().map(|code| code.as_str()), Some("PSASM1304"));
137    }
138
139    #[test]
140    fn reserves_j1c_codes_before_state_storage_in_amendment_order() {
141        let codes = [
142            ComputedInstanceSlotIntegrityCode::MissingProjection,
143            ComputedInstanceSlotIntegrityCode::DuplicateCacheSlot,
144            ComputedInstanceSlotIntegrityCode::DuplicateDirtySlot,
145            ComputedInstanceSlotIntegrityCode::ConstructorMismatch,
146            ComputedInstanceSlotIntegrityCode::OwnershipMismatch,
147            ComputedInstanceSlotIntegrityCode::StaleRegistry,
148            ComputedInstanceSlotIntegrityCode::ArtifactProjectionDrift,
149        ];
150        assert_eq!(codes.first().map(|code| code.as_str()), Some("PSASM1305"));
151        assert_eq!(codes.last().map(|code| code.as_str()), Some("PSASM1311"));
152    }
153
154    #[test]
155    fn reserves_j1a_codes_before_j2_in_amendment_order() {
156        let codes = [
157            StateInstanceStorageIntegrityCode::MissingProjection,
158            StateInstanceStorageIntegrityCode::DuplicateSlot,
159            StateInstanceStorageIntegrityCode::ConstructorMismatch,
160            StateInstanceStorageIntegrityCode::OwnershipMismatch,
161            StateInstanceStorageIntegrityCode::StaleRegistry,
162            StateInstanceStorageIntegrityCode::ArtifactProjectionDrift,
163            StateInstanceStorageIntegrityCode::DeclarationRuntimeKey,
164            StateInstanceStorageIntegrityCode::UnknownResumeSlot,
165        ];
166        assert_eq!(codes.first().map(|code| code.as_str()), Some("PSASM1312"));
167        assert_eq!(codes.last().map(|code| code.as_str()), Some("PSASM1319"));
168    }
169}