Skip to main content

bucketwarden_server/
storage_backend_support.rs

1use super::*;
2
3pub const STORAGE_BACKEND_NATIVE_OBJECT_ENGINE: &str = "native-object-engine";
4pub const STORAGE_BACKEND_S3_GATEWAY: &str = "s3-gateway";
5pub const STORAGE_BACKEND_FILESYSTEM: &str = "filesystem-backed";
6pub const STORAGE_BACKEND_RADOS: &str = "rados";
7pub const STORAGE_BACKEND_VOLUME_FILER: &str = "volume-filer";
8pub const STORAGE_BACKEND_HADOOP_OBJECT_STORE: &str = "hadoop-object-store";
9
10const STORAGE_BACKEND_CAPABILITIES: &[&str] = &[
11    "native-support-state",
12    "semantic-parity",
13    "configuration-admin-surface",
14    "security-governance-impact",
15    "observability-evidence",
16    "failure-mode-behavior",
17    "validation-test-coverage",
18    "product-specific-caveats",
19];
20
21const STORAGE_BACKEND_CAVEATS: &[&str] = &[
22    "BucketWarden is an S3-compatible object runtime, not a POSIX filesystem.",
23    "Filesystem persistence stores encrypted object bytes plus canonical metadata manifests.",
24    "RADOS, volume/filer, and Hadoop backends are tracked but fail closed outside the current product boundary.",
25];
26
27const STORAGE_BACKEND_FAILURE_MODES: &[&str] = &[
28    "unsupported-backend-rejected",
29    "metadata-manifest-validation",
30    "object-byte-checksum-mismatch",
31    "operator-audit-event-required",
32];
33
34#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
35pub struct StorageBackendSupportEntry {
36    pub backend: &'static str,
37    pub native_support: bool,
38    pub semantic_parity: &'static str,
39    pub failure_mode: &'static str,
40    pub caveat: &'static str,
41}
42
43#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
44pub struct StorageBackendSupportReport {
45    pub active_backend: &'static str,
46    pub supported_backends: Vec<&'static str>,
47    pub unsupported_backends: Vec<&'static str>,
48    pub capabilities: Vec<&'static str>,
49    pub failure_modes: Vec<&'static str>,
50    pub caveats: Vec<&'static str>,
51    pub entries: Vec<StorageBackendSupportEntry>,
52}
53
54impl BucketWarden {
55    pub fn storage_backend_support_report(&self) -> StorageBackendSupportReport {
56        StorageBackendSupportReport {
57            active_backend: STORAGE_BACKEND_FILESYSTEM,
58            supported_backends: vec![
59                STORAGE_BACKEND_NATIVE_OBJECT_ENGINE,
60                STORAGE_BACKEND_S3_GATEWAY,
61                STORAGE_BACKEND_FILESYSTEM,
62            ],
63            unsupported_backends: vec![
64                STORAGE_BACKEND_RADOS,
65                STORAGE_BACKEND_VOLUME_FILER,
66                STORAGE_BACKEND_HADOOP_OBJECT_STORE,
67            ],
68            capabilities: STORAGE_BACKEND_CAPABILITIES.to_vec(),
69            failure_modes: STORAGE_BACKEND_FAILURE_MODES.to_vec(),
70            caveats: STORAGE_BACKEND_CAVEATS.to_vec(),
71            entries: vec![
72                StorageBackendSupportEntry {
73                    backend: STORAGE_BACKEND_NATIVE_OBJECT_ENGINE,
74                    native_support: true,
75                    semantic_parity: "BucketWarden native object-version semantics.",
76                    failure_mode: "runtime object mutations return typed errors and do not silently switch engines.",
77                    caveat: "Native object engine semantics are scoped to BucketWarden, not AWS internal storage.",
78                },
79                StorageBackendSupportEntry {
80                    backend: STORAGE_BACKEND_S3_GATEWAY,
81                    native_support: true,
82                    semantic_parity: "S3-compatible HTTP gateway over the same object engine.",
83                    failure_mode: "unsupported or malformed S3 requests return explicit S3-compatible errors.",
84                    caveat: "Gateway support is endpoint-compatible and excludes AWS account control-plane behavior.",
85                },
86                StorageBackendSupportEntry {
87                    backend: STORAGE_BACKEND_FILESYSTEM,
88                    native_support: true,
89                    semantic_parity: "Encrypted object bytes on local filesystem with manifest metadata restore.",
90                    failure_mode: "manifest schema, path, length, and checksum validation fail closed.",
91                    caveat: "Filesystem backend is an object persistence engine, not a general file-sharing protocol.",
92                },
93                StorageBackendSupportEntry {
94                    backend: STORAGE_BACKEND_RADOS,
95                    native_support: false,
96                    semantic_parity: "No RADOS cluster, pool, placement group, or Ceph semantics are claimed.",
97                    failure_mode: "RADOS backend selection is rejected as unsupported.",
98                    caveat: "RADOS remains tracked out of bounds until a dedicated backend is implemented.",
99                },
100                StorageBackendSupportEntry {
101                    backend: STORAGE_BACKEND_VOLUME_FILER,
102                    native_support: false,
103                    semantic_parity: "No filer volume, inode, lock, or share semantics are claimed.",
104                    failure_mode: "Volume/filer backend selection is rejected as unsupported.",
105                    caveat: "Volume/filer integration requires an external adapter or future backend.",
106                },
107                StorageBackendSupportEntry {
108                    backend: STORAGE_BACKEND_HADOOP_OBJECT_STORE,
109                    native_support: false,
110                    semantic_parity: "No Hadoop filesystem, NameNode, block placement, or HDFS semantics are claimed.",
111                    failure_mode: "Hadoop backend selection is rejected as unsupported.",
112                    caveat: "Hadoop object-store compatibility is outside the current runtime boundary.",
113                },
114            ],
115        }
116    }
117
118    pub fn ensure_storage_backend_supported(&self, backend: &str) -> Result<(), RuntimeError> {
119        let report = self.storage_backend_support_report();
120        if report.supported_backends.contains(&backend) {
121            Ok(())
122        } else {
123            Err(RuntimeError::UnsupportedStorageBackend(backend.to_string()))
124        }
125    }
126}