Skip to main content

bijux_cli/contracts/
query.rs

1#![forbid(unsafe_code)]
2//! Read-only contract schema inventory interfaces for maintainer tooling.
3
4/// Structured schema inventory queried from durable contracts.
5#[derive(Debug, Clone, PartialEq, Eq)]
6pub struct ContractsSchemaQuery {
7    /// Stable schema ids exposed by contract types.
8    pub schema_ids: Vec<String>,
9    /// Schema inventory version marker.
10    pub schema_version: String,
11}
12
13/// Structured compatibility lanes for durable schema/versioned surfaces.
14#[derive(Debug, Clone, PartialEq, Eq)]
15pub struct VersionCompatibilityLaneQuery {
16    /// Compatibility lane inventory format version.
17    pub schema_version: String,
18    /// Version-compatibility lanes per product surface.
19    pub surfaces: Vec<VersionCompatibilitySurface>,
20}
21
22/// Version compatibility lane for one surface contract.
23#[derive(Debug, Clone, PartialEq, Eq)]
24pub struct VersionCompatibilitySurface {
25    /// Stable surface identifier.
26    pub surface: String,
27    /// Current versions expected for normal production usage.
28    pub current_versions: Vec<String>,
29    /// Explicitly accepted previous versions.
30    pub accepted_previous_versions: Vec<String>,
31    /// Known refused versions to keep failures deterministic.
32    pub refused_versions: Vec<String>,
33}
34
35/// Query contracts/schema inventory without presentation formatting.
36#[must_use]
37pub fn contracts_schema_query() -> ContractsSchemaQuery {
38    ContractsSchemaQuery {
39        schema_ids: vec![
40            "command-envelope-v1".to_string(),
41            "output-envelope-v1".to_string(),
42            "error-envelope-v1".to_string(),
43            "config-schema-registry-v1".to_string(),
44            "plugin-manifest-v2".to_string(),
45            "product-mount-descriptor-v1".to_string(),
46        ],
47        schema_version: "v4".to_string(),
48    }
49}
50
51/// Query version-compatibility lanes without presentation formatting.
52#[must_use]
53pub fn version_compatibility_lanes_query() -> VersionCompatibilityLaneQuery {
54    VersionCompatibilityLaneQuery {
55        schema_version: "v1".to_string(),
56        surfaces: vec![
57            VersionCompatibilitySurface {
58                surface: "cli-command-envelope".to_string(),
59                current_versions: vec!["command-envelope-v1".to_string()],
60                accepted_previous_versions: Vec::new(),
61                refused_versions: vec![
62                    "command-envelope-v0".to_string(),
63                    "command-envelope-v2".to_string(),
64                ],
65            },
66            VersionCompatibilitySurface {
67                surface: "cli-output-envelope".to_string(),
68                current_versions: vec!["output-envelope-v1".to_string()],
69                accepted_previous_versions: Vec::new(),
70                refused_versions: vec![
71                    "output-envelope-v0".to_string(),
72                    "output-envelope-v2".to_string(),
73                ],
74            },
75            VersionCompatibilitySurface {
76                surface: "cli-error-envelope".to_string(),
77                current_versions: vec!["error-envelope-v1".to_string()],
78                accepted_previous_versions: Vec::new(),
79                refused_versions: vec![
80                    "error-envelope-v0".to_string(),
81                    "error-envelope-v2".to_string(),
82                ],
83            },
84            VersionCompatibilitySurface {
85                surface: "config-schema-registry".to_string(),
86                current_versions: vec!["config-schema-registry-v1".to_string()],
87                accepted_previous_versions: Vec::new(),
88                refused_versions: vec![
89                    "config-schema-registry-v0".to_string(),
90                    "config-schema-registry-v2".to_string(),
91                ],
92            },
93            VersionCompatibilitySurface {
94                surface: "mount-descriptor".to_string(),
95                current_versions: vec!["product-mount-descriptor-v1".to_string()],
96                accepted_previous_versions: Vec::new(),
97                refused_versions: vec![
98                    "product-mount-descriptor-v0".to_string(),
99                    "product-mount-descriptor-v2".to_string(),
100                ],
101            },
102            VersionCompatibilitySurface {
103                surface: "graph-spec".to_string(),
104                current_versions: vec!["bijux-dag/v0.1".to_string()],
105                accepted_previous_versions: vec![
106                    "v1".to_string(),
107                    "v0.1".to_string(),
108                    "0.1".to_string(),
109                ],
110                refused_versions: vec!["v9".to_string(), "bijux-dag/v9".to_string()],
111            },
112            VersionCompatibilitySurface {
113                surface: "run-manifest".to_string(),
114                current_versions: vec!["run-manifest/v0.1".to_string()],
115                accepted_previous_versions: Vec::new(),
116                refused_versions: vec![
117                    "run-manifest/v0".to_string(),
118                    "run-manifest/v2".to_string(),
119                ],
120            },
121            VersionCompatibilitySurface {
122                surface: "artifact-index".to_string(),
123                current_versions: vec!["run-dir-schema/v0.1".to_string()],
124                accepted_previous_versions: Vec::new(),
125                refused_versions: vec![
126                    "run-dir-schema/v0".to_string(),
127                    "run-dir-schema/v2".to_string(),
128                ],
129            },
130            VersionCompatibilitySurface {
131                surface: "replay-bundle".to_string(),
132                current_versions: vec![
133                    "export-bundle/v0.1".to_string(),
134                    "proof-bundle/v0.1".to_string(),
135                ],
136                accepted_previous_versions: Vec::new(),
137                refused_versions: vec![
138                    "export-bundle/v0".to_string(),
139                    "proof-bundle/v0".to_string(),
140                    "export-bundle/v2".to_string(),
141                    "proof-bundle/v2".to_string(),
142                ],
143            },
144        ],
145    }
146}