Skip to main content

vibe/
degrade.rs

1//! Graceful degradation copy (P16.7). Fail closed; never pretend GPU/LLM ran.
2
3/// GPU missing → stay on bytecode / scalar CPU.
4pub fn gpu_missing(detail: impl AsRef<str>) -> String {
5    format!(
6        "{}; falling back to bytecode / scalar CPU (no GPU this pass)",
7        detail.as_ref()
8    )
9}
10
11/// Local model missing → diagnostic. Consented remote is not implied.
12pub fn llm_missing(detail: impl AsRef<str>) -> String {
13    format!(
14        "{}; local model unavailable; consented remote is the only fallback and is not taken automatically",
15        detail.as_ref()
16    )
17}
18
19#[cfg(test)]
20mod tests {
21    use super::*;
22
23    #[test]
24    fn gpu_message_names_bytecode() {
25        let m = gpu_missing("gpu_init: no adapter");
26        assert!(m.contains("bytecode"));
27        assert!(m.contains("gpu_init"));
28    }
29
30    #[test]
31    fn llm_message_does_not_auto_remote() {
32        let m = llm_missing("Inference.load_model: not found");
33        assert!(m.contains("not taken automatically"));
34        assert!(m.contains("consented remote"));
35    }
36}