From 9f3dcb176a786d250b9fa592e8dcec4dca17ab8f Mon Sep 17 00:00:00 2001 From: Petya <64523372+peti12352@users.noreply.github.com> Date: Wed, 18 Nov 2026 12:24:28 -0800 Subject: [PATCH 01/12] Fail-closed fit, share, login, and engine key handling. Light engines stop paying SGLang's 1.8 GB overhead; retired pkg host migrates; pack SM unknown, verification origin, public share allowlist, and cmdline secrets are tightened. Share --allow is the client's IP (or goethe api allow); nginx always deny all. --- engine/crates/core/src/calc.rs | 4 - engine/crates/core/src/chooser.rs | 14 +- .../crates/core/src/engines/goethe_engine.rs | 4 +- engine/crates/core/src/engines/llama_cpp.rs | 9 +- engine/crates/core/src/engines/mod.rs | 37 ++++- engine/crates/core/src/engines/ninfer.rs | 4 +- engine/crates/core/src/engines/sglang.rs | 23 ++- engine/crates/core/src/hw.rs | 1 + engine/crates/core/src/install.rs | 2 +- engine/crates/core/src/models.rs | 1 + engine/crates/core/src/packs.rs | 6 +- engine/crates/core/src/platform_api.rs | 41 +++++- engine/crates/core/src/public_share.rs | 137 ++++++++++++------ engine/crates/core/src/recommend.rs | 2 + engine/crates/core/src/setup.rs | 37 ++++- engine/crates/core/src/update.rs | 1 + engine/crates/goethe/src/main.rs | 19 +-- .../e2e/fake/goethe_engine/openai_server.py | 4 +- engine/tests/lib/goethe_test.py | 6 +- engine/tests/lib/stub_engine.py | 3 + 20 files changed, 270 insertions(+), 85 deletions(-) diff --git a/engine/crates/core/src/calc.rs b/engine/crates/core/src/calc.rs index e8b46f17..76f00603 100644 --- a/engine/crates/core/src/calc.rs +++ b/engine/crates/core/src/calc.rs @@ -6,10 +6,6 @@ const CUDA_CONTEXT_GB: f64 = crate::engine_overhead::DEFAULT_CONTEXT_GB; pub const BASE_OVERHEAD_GB: f64 = 1.8; pub const METAL_OVERHEAD_GB: f64 = 0.5; -pub fn base_overhead_gb(cc: &str) -> f64 { - // llama.cpp on Metal has no CUDA context or graph pools, only its compute buffers. - if crate::gpu_arch::is_apple(cc) { METAL_OVERHEAD_GB } else { BASE_OVERHEAD_GB } -} const LEARN_SLACK_GB: f64 = 0.25; #[derive(Debug, Clone, Copy, PartialEq, Default)] diff --git a/engine/crates/core/src/chooser.rs b/engine/crates/core/src/chooser.rs index b512d7a6..6c40e1f7 100644 --- a/engine/crates/core/src/chooser.rs +++ b/engine/crates/core/src/chooser.rs @@ -1,6 +1,6 @@ // Tensor parallel size and GPU set selection for goethe load. -use crate::calc::{base_overhead_gb, missing_gb, shortfall, Need}; +use crate::calc::{missing_gb, shortfall, Need, METAL_OVERHEAD_GB}; use crate::memory_spec::MemorySpec; const GIB: f64 = 1024.0 * 1024.0 * 1024.0; @@ -22,6 +22,7 @@ pub struct ChooserInput { pub marlin_extra_gb: f64, pub supported_sm: Vec, pub memory: Option, + pub overhead_gb: f64, } pub struct CardFacts { @@ -48,6 +49,7 @@ impl ChooserInput { marlin_extra_gb: crate::install::card_marlin_extra_gb(card), supported_sm: crate::install::card_supported_sm(card), memory, + overhead_gb: crate::engines::of_card(card).map_or(crate::calc::BASE_OVERHEAD_GB, |e| e.overhead_gb), } } } @@ -129,12 +131,13 @@ pub fn need(input: &ChooserInput, tp: usize, cc: &str) -> Need { let tokens = kv_tokens(input.ctx, input.max_conc) as f64; let conc = input.max_conc.max(1); let request_table = ((conc + 1) * (input.ctx + 4) * 4) as f64 / GIB; + let oh = if gpu_arch::is_apple(cc) { METAL_OVERHEAD_GB } else { input.overhead_gb } + request_table; let Some(m) = &input.memory else { let shard = kv_shard(tp, input.num_kv_heads, &input.attention); return Need { weights: (input.static_vram_gb + marlin) / tp as f64, kv: tokens * input.kv_bytes_per_token as f64 / GIB / shard, - overhead: base_overhead_gb(cc) + request_table, + overhead: oh, ..Need::default() }; }; @@ -149,7 +152,7 @@ pub fn need(input: &ChooserInput, tp: usize, cc: &str) -> Need { / tp as f64 + ((conc + 1) * m.request_bytes + m.fixed_bytes) as f64) / GIB, - overhead: base_overhead_gb(cc) + request_table, + overhead: oh, load_peak: m.load_peak_bytes as f64 / tp as f64 / GIB, } } @@ -461,13 +464,16 @@ mod tests { marlin_extra_gb: 0.0, supported_sm: Vec::new(), memory: None, + overhead_gb: crate::calc::BASE_OVERHEAD_GB, } } #[test] fn metal_pays_no_cuda_overhead() { let (cuda, metal) = (need(&inp(), 1, "12.0"), need(&inp(), 1, "metal")); - assert!((cuda.overhead - metal.overhead - (crate::calc::BASE_OVERHEAD_GB - crate::calc::METAL_OVERHEAD_GB)).abs() < 1e-9); + assert!((cuda.overhead - metal.overhead - (crate::calc::BASE_OVERHEAD_GB - METAL_OVERHEAD_GB)).abs() < 1e-9); + let llama = need(&ChooserInput { overhead_gb: METAL_OVERHEAD_GB, ..inp() }, 1, "12.0"); + assert!((llama.overhead - metal.overhead).abs() < 1e-9); } fn gpu(idx: u32, free_gb: f64, foreign: bool) -> GpuPlacementInput { diff --git a/engine/crates/core/src/engines/goethe_engine.rs b/engine/crates/core/src/engines/goethe_engine.rs index 86ecd60b..18ba833f 100644 --- a/engine/crates/core/src/engines/goethe_engine.rs +++ b/engine/crates/core/src/engines/goethe_engine.rs @@ -1,11 +1,12 @@ // goethe-engine: a signed kernel pack plus the weights its verification lists, served by python -m goethe_engine. -use super::{card_env, kept_env, placement_env, resolve_python, EngineSpec}; +use super::{card_env, engine_key_env, kept_env, placement_env, resolve_python, EngineSpec}; use std::path::PathBuf; use std::process::Command; pub const ENGINE: super::Engine = super::Engine { id: "goethe-engine", + overhead_gb: crate::calc::METAL_OVERHEAD_GB, layer: Some(crate::pyenv::Layer::Engine), params: None, command: goethe_engine_command, @@ -54,6 +55,7 @@ fn goethe_engine_command(spec: &EngineSpec) -> Result { .envs(card_env(spec)) .envs(placement_env(spec)) .env_remove("GOETHE_ENGINE_ALLOW_UNSIGNED"); + engine_key_env(&mut cmd, spec.engine_key); Ok(cmd) } diff --git a/engine/crates/core/src/engines/llama_cpp.rs b/engine/crates/core/src/engines/llama_cpp.rs index f541bfac..d2701e60 100644 --- a/engine/crates/core/src/engines/llama_cpp.rs +++ b/engine/crates/core/src/engines/llama_cpp.rs @@ -1,6 +1,6 @@ // llama.cpp: llama-server on one GGUF, one GPU, OpenAI-compatible; the universal engine for GGUF models. -use super::{card_env, kept_env, placement_env, EngineSpec}; +use super::{card_env, engine_key_env, kept_env, placement_env, EngineSpec}; use std::collections::HashMap; use std::io::Read; use std::path::{Path, PathBuf}; @@ -18,6 +18,7 @@ type Get<'a> = &'a dyn Fn(&str) -> Result, String>; pub const ENGINE: super::Engine = super::Engine { id: "llama.cpp", + overhead_gb: crate::calc::METAL_OVERHEAD_GB, layer: None, params: Some(&[ "temperature", "top_p", "top_k", "min_p", "max_tokens", "max_completion_tokens", "n", "stop", "seed", @@ -332,8 +333,6 @@ fn llama_command(spec: &EngineSpec) -> Result { .arg(gguf_in(spec.model_path, spec.card, None)?) .args(["--host", "127.0.0.1", "--port"]) .arg(spec.port.to_string()) - .arg("--api-key") - .arg(spec.engine_key) .arg("--alias") .arg(spec.served_name) .arg("-c") @@ -354,6 +353,7 @@ fn llama_command(spec: &EngineSpec) -> Result { .envs(kept_env()) .envs(card_env(spec)) .envs(placement_env(spec)); + engine_key_env(&mut cmd, spec.engine_key); Ok(cmd) } @@ -404,8 +404,11 @@ mod tests { assert_eq!((at("--host").as_str(), at("--alias").as_str(), at("-np").as_str()), ("127.0.0.1", "org/m", "4")); assert_eq!((at("-c"), at("--kv-unified-per-slot")), (crate::chooser::kv_tokens(4096, 4).to_string(), "4096".to_string())); assert!(!a.iter().any(|x| x == "--embeddings")); + assert!(!a.iter().any(|x| x == "--api-key"), "key stays off argv: {a:?}"); let env = |k: &str| c.get_envs().find(|(n, _)| *n == k).and_then(|(_, v)| v).map(|v| v.to_string_lossy().into_owned()); assert_eq!(env("CUDA_VISIBLE_DEVICES").as_deref(), Some("2")); + assert_eq!(env("LLAMA_API_KEY").as_deref().map(|s| s.len()), Some(32)); + assert_eq!(env(super::super::ENGINE_KEY_ENV).as_deref().map(|s| s.len()), Some(32)); let emb: toml::Value = toml::from_str("runtime = \"llama.cpp\"\ntask = \"embed\"").unwrap(); assert!(command(&test_spec(d.path(), &emb, &[2])).unwrap().get_args().any(|x| x == "--embeddings")); assert!(command(&test_spec(d.path(), &card, &[2, 3])).unwrap_err().contains("one GPU")); diff --git a/engine/crates/core/src/engines/mod.rs b/engine/crates/core/src/engines/mod.rs index 591d49cf..173a53bd 100644 --- a/engine/crates/core/src/engines/mod.rs +++ b/engine/crates/core/src/engines/mod.rs @@ -11,6 +11,7 @@ use std::process::Command; pub struct Engine { pub id: &'static str, + pub overhead_gb: f64, pub layer: Option, pub params: Option<&'static [&'static str]>, pub command: fn(&EngineSpec) -> Result, @@ -164,12 +165,22 @@ fn compiler_env() -> Vec<(String, String)> { crate::host_compiler::engine_env(crate::host_compiler::find().as_ref(), inherited.as_deref()) } +pub const ENGINE_KEY_ENV: &str = "GOETHE_ENGINE_API_KEY"; + +fn engine_key_env(cmd: &mut Command, key: &str) { + // Owner-only in /proc//environ; never put the secret on argv (world-readable cmdline). + cmd.env(ENGINE_KEY_ENV, key).env("LLAMA_API_KEY", key); +} + fn card_env(spec: &EngineSpec) -> Vec<(String, String)> { - // Card env table and card pythonpath. + // Card env table and card pythonpath. Loader hooks from a card never enter the process. let home = spec.home; let mut out = Vec::new(); if let Some(table) = spec.card.get("env").and_then(|v| v.as_table()) { for (k, v) in table { + if k.starts_with("LD_") || k.starts_with("DYLD_") { + continue; + } if let Some(s) = v.as_str() { out.push((k.clone(), expand_home(s, home))); } @@ -235,7 +246,6 @@ mod tests { assert_eq!(a[n + 1], "org/m"); let q = a.iter().position(|x| x == "--uvicorn-access-log-exclude-prefixes").unwrap(); assert_eq!(&a[q + 1..q + 4], ["/health", "/v1/models", "/get_model_info"]); - assert!(a[q + 4].starts_with("--")); assert!(!a.iter().any(|x| x == "--disable-radix-cache")); } @@ -262,13 +272,16 @@ mod tests { assert_eq!(e.get("CUDA_VISIBLE_DEVICES"), Some(&Some("3,2".to_string()))); assert_eq!(e.get(INSTANCE_ENV), Some(&Some("inst-x".to_string()))); assert_eq!(e.get("SPT_NOENV"), Some(&Some("1".to_string()))); - assert_eq!(e.get("PYTHONPATH"), Some(&Some("/h/x".to_string()))); + assert_eq!(e.get("PYTHONPATH"), Some(&Some("/h/lib:/h/x".to_string()))); assert_eq!(e.get("A"), Some(&Some("1".to_string()))); assert!(!e.contains_key("TERNARY_PACK_DIR")); assert!(!e.contains_key("CARGO_MANIFEST_DIR")); let a = args(&plain); - let k = a.iter().position(|x| x == "--api-key").unwrap(); - assert_eq!(a[k + 1].len(), 32); + assert!(!a.iter().any(|x| x == "--api-key"), "{a:?}"); + assert_eq!(e.get(ENGINE_KEY_ENV).and_then(|v| v.as_ref().map(|s| s.len())), Some(32)); + let blocked = envs(&spec_cmd("[env]\nLD_PRELOAD = \"/x.so\"\nDYLD_INSERT_LIBRARIES = \"/y.dylib\"\nOK = \"1\"", 1)); + assert!(!blocked.contains_key("LD_PRELOAD") && !blocked.contains_key("DYLD_INSERT_LIBRARIES")); + assert_eq!(blocked.get("OK"), Some(&Some("1".into()))); } #[test] @@ -303,8 +316,9 @@ mod tests { assert!(err.contains("not allowed"), "{err}"); assert!(check_extra_args(&strs(&["--tokenizer-worker-num=2"])).is_err()); let single = args(&spec_cmd("extra_sglang_args = [\"--tokenizer-worker-num\", \"1\"]", 1)); - assert!(single.iter().any(|a| a == "--api-key")); + assert!(!single.iter().any(|a| a == "--api-key")); assert!(single.windows(2).any(|w| w[0] == "--host" && w[1] == "127.0.0.1")); + assert!(single.iter().any(|a| a == "goethe_sglang_boot")); } #[test] @@ -316,6 +330,15 @@ mod tests { assert_ne!(a, b); } + #[test] + fn light_engines_pay_half_a_gig_on_cuda_sglang_pays_base() { + assert!((by_id("llama.cpp").unwrap().overhead_gb - crate::calc::METAL_OVERHEAD_GB).abs() < 1e-9); + assert!((by_id("goethe-engine").unwrap().overhead_gb - crate::calc::METAL_OVERHEAD_GB).abs() < 1e-9); + assert!((by_id("ninfer").unwrap().overhead_gb - crate::calc::METAL_OVERHEAD_GB).abs() < 1e-9); + assert!((by_id("sglang").unwrap().overhead_gb - crate::calc::BASE_OVERHEAD_GB).abs() < 1e-9); + assert!((by_id("ternary").unwrap().overhead_gb - crate::calc::BASE_OVERHEAD_GB).abs() < 1e-9); + } + #[test] fn hybrid_models_get_the_state_slots_goethe_budgeted() { let dir = tempfile::tempdir().unwrap(); @@ -338,7 +361,7 @@ mod tests { for id in ["sglang", "ternary", "ninfer", "goethe-engine", "llama.cpp"] { assert_eq!(of_card(&toml::from_str(&format!("runtime = \"{id}\"")).unwrap()).unwrap().id, id); } - assert!(args(&spec_cmd("", 1)).iter().any(|a| a == "sglang.launch_server")); + assert!(args(&spec_cmd("", 1)).iter().any(|a| a == "goethe_sglang_boot")); assert!(of_card(&toml::from_str("runtime = \"vllm\"").unwrap()).map(|e| e.id).unwrap_err().contains("not one goethe runs")); } diff --git a/engine/crates/core/src/engines/ninfer.rs b/engine/crates/core/src/engines/ninfer.rs index c7bd1f39..cf10a9c9 100644 --- a/engine/crates/core/src/engines/ninfer.rs +++ b/engine/crates/core/src/engines/ninfer.rs @@ -1,11 +1,12 @@ // NInfer: the pinned .ninfer artifact (fetch, verify, head patch) and its ninfer-serve command line. -use super::{kept_env, placement_env, EngineSpec}; +use super::{engine_key_env, kept_env, placement_env, EngineSpec}; use std::path::{Path, PathBuf}; use std::process::Command; pub const ENGINE: super::Engine = super::Engine { id: "ninfer", + overhead_gb: crate::calc::METAL_OVERHEAD_GB, layer: None, params: None, command: ninfer_command, @@ -303,6 +304,7 @@ fn ninfer_command(spec: &EngineSpec) -> Result { cmd.env_clear() .envs(kept_env()) .envs(placement_env(spec)); + engine_key_env(&mut cmd, spec.engine_key); Ok(cmd) } diff --git a/engine/crates/core/src/engines/sglang.rs b/engine/crates/core/src/engines/sglang.rs index 9330f150..00353bbd 100644 --- a/engine/crates/core/src/engines/sglang.rs +++ b/engine/crates/core/src/engines/sglang.rs @@ -1,10 +1,14 @@ // SGLang: python -m sglang.launch_server with Goethe-owned flags, card and load extras; ternary is SGLang plus its kernel env. -use super::{arch_env, card_env, compiler_env, default_cuda_home, engine_path, expand_home, kept_env, placement_env, resolve_python, EngineSpec}; +use super::{ + arch_env, card_env, compiler_env, default_cuda_home, engine_key_env, engine_path, expand_home, kept_env, placement_env, + resolve_python, EngineSpec, +}; use std::process::Command; pub const SGLANG: super::Engine = super::Engine { id: "sglang", + overhead_gb: crate::calc::BASE_OVERHEAD_GB, layer: Some(crate::pyenv::Layer::Sglang), params: None, command: |spec| Ok(sglang_command(spec)), @@ -76,11 +80,19 @@ fn memory_args(spec: &EngineSpec, extras: &[String]) -> Vec { args.chunks(2).filter(|p| !(user_chunk && p[0] == "--chunked-prefill-size")).flatten().cloned().collect() } +const SGLANG_BOOT: &str = "import os,runpy,sys\nsys.argv=['sglang.launch_server',*sys.argv[1:],'--api-key',os.environ['GOETHE_ENGINE_API_KEY']]\nrunpy.run_module('sglang.launch_server',run_name='__main__')\n"; + fn sglang_command(spec: &EngineSpec) -> Command { // Goethe flags, then checked card and load extras, in a cleared env; probe paths stay out of the access log. + let lib = spec.home.join("lib"); + let boot = lib.join("goethe_sglang_boot.py"); + if !boot.is_file() { + let _ = std::fs::create_dir_all(&lib); + let _ = crate::platform::write_private(&boot, SGLANG_BOOT.as_bytes()); + } let mut cmd = Command::new(resolve_python(spec.home)); cmd.arg("-m") - .arg("sglang.launch_server") + .arg("goethe_sglang_boot") .arg("--model-path") .arg(spec.model_path) .arg("--host") @@ -101,7 +113,6 @@ fn sglang_command(spec: &EngineSpec) -> Command { .args(QUIET_PATHS); let extras: Vec = card_extra_args(spec.card).into_iter().chain(spec.load_extra.iter().cloned()).collect(); cmd.args(memory_args(spec, &extras)); - cmd.arg("--api-key").arg(spec.engine_key); if let Some(dtype) = spec .card .get("kv_cache_dtype") @@ -116,6 +127,10 @@ fn sglang_command(spec: &EngineSpec) -> Command { } cmd.args(&extras); let card_vars = card_env(spec); + let mut py_path = lib.display().to_string(); + if let Some((_, v)) = card_vars.iter().find(|(k, _)| k == "PYTHONPATH") { + py_path = format!("{py_path}:{v}"); + } cmd.env_clear() .envs(kept_env()) .env("PATH", engine_path(spec.home)) @@ -125,8 +140,10 @@ fn sglang_command(spec: &EngineSpec) -> Command { .envs(compiler_env()) .envs(card_vars) .envs(placement_env(spec)) + .env("PYTHONPATH", py_path) .env("PYTORCH_CUDA_ALLOC_CONF", "expandable_segments:True") .env("SPT_NOENV", "1"); + engine_key_env(&mut cmd, spec.engine_key); cmd } diff --git a/engine/crates/core/src/hw.rs b/engine/crates/core/src/hw.rs index e9c3b7ae..d681f222 100644 --- a/engine/crates/core/src/hw.rs +++ b/engine/crates/core/src/hw.rs @@ -142,6 +142,7 @@ pub fn run_pick_gpus(tp: Option, model: Option<&str>) -> Result<(), String> marlin_extra_gb: 0.0, supported_sm: Vec::new(), memory: None, + overhead_gb: crate::calc::BASE_OVERHEAD_GB, }; let fit = view.fit("", &empty, Some(t)); (String::new(), fit.map(|f| (format!("tp={} on GPU {}", f.tp, crate::placement::format_gpu_list(&f.gpus)), f.gpus))) diff --git a/engine/crates/core/src/install.rs b/engine/crates/core/src/install.rs index 7733f2da..e546fadd 100644 --- a/engine/crates/core/src/install.rs +++ b/engine/crates/core/src/install.rs @@ -2480,7 +2480,7 @@ mod tests { crate::engine_overhead::store_learned(&con, "nvidia/Big-NVFP4", "NVIDIA GeForce RTX 5090", 1, crate::engine_overhead::Kind::Overhead, 4.8, "llama.cpp").unwrap(); assert!(spare(card(tight)).is_ok(), "a llama.cpp row never reaches the pack budget"); let view = view_of(home.path(), card(tight)); - let input = crate::chooser::ChooserInput { static_vram_gb: 20.0, kv_bytes_per_token: 131072, num_attention_heads: 32, num_kv_heads: 8, attention: "gqa".into(), max_ctx: 8192, ctx: 4096, max_conc: 8, marlin_extra_gb: 0.0, supported_sm: vec!["12.0".into()], memory: None }; + let input = crate::chooser::ChooserInput { static_vram_gb: 20.0, kv_bytes_per_token: 131072, num_attention_heads: 32, num_kv_heads: 8, attention: "gqa".into(), max_ctx: 8192, ctx: 4096, max_conc: 8, marlin_extra_gb: 0.0, supported_sm: vec!["12.0".into()], memory: None, overhead_gb: crate::calc::METAL_OVERHEAD_GB }; assert!(view.fit_as("nvidia/Big-NVFP4", &input, None, "llama.cpp").is_err(), "the same row does bind the llama.cpp runtime"); } diff --git a/engine/crates/core/src/models.rs b/engine/crates/core/src/models.rs index 4576d6ef..648ac94e 100644 --- a/engine/crates/core/src/models.rs +++ b/engine/crates/core/src/models.rs @@ -446,6 +446,7 @@ fn installed_rows(home: &Path, con: &Connection) -> Result, Strin marlin_extra_gb: install::card_marlin_extra_gb(&card), supported_sm: install::card_supported_sm(&card), memory: crate::memory_spec::installed(&home.join(r.get::<_, String>(11)?), &card, &[]), + overhead_gb: crate::engines::of_card(&card).map_or(crate::calc::BASE_OVERHEAD_GB, |e| e.overhead_gb), }, }) }) diff --git a/engine/crates/core/src/packs.rs b/engine/crates/core/src/packs.rs index 954938e1..89bc8e25 100644 --- a/engine/crates/core/src/packs.rs +++ b/engine/crates/core/src/packs.rs @@ -256,12 +256,14 @@ fn arch_runs(arch: &str, cc: &str) -> String { } pub fn sku_why(dev: &Device, req: &SkuReq) -> String { - // Why one GPU cannot run one variant ("" when it can), by goethe-engine's rule: the arch on the compute capability, the grid's SMs co-resident, the shared memory per block; an unknown SM count or shared memory never refuses. + // Why one GPU cannot run one variant ("" when it can): arch, SM count, shared memory. Unknown device limits refuse when the pack asks for any. let why = arch_runs(&req.arch, &dev.cc); if !why.is_empty() { return format!("device cc {}: {why}", dev.cc); } match (dev.sms, dev.smem_block) { + (None, _) if req.sms > 0 => format!("the plan's grid needs {} SMs co-resident; this device's SM count is unknown", req.sms), + (_, None) if req.smem_block > 0 => format!("the plan needs {} B shared memory per block; this device's shared-memory limit is unknown", req.smem_block), (Some(have), _) if req.sms > have => format!("the plan's grid needs {} SMs co-resident, the device has {have}", req.sms), (_, Some(have)) if req.smem_block > have => format!("the plan needs {} B shared memory per block, the device allows {have}", req.smem_block), _ => String::new(), @@ -1074,7 +1076,7 @@ mod tests { let line = sku_refusal(&reqs, &[gpu("NVIDIA GeForce RTX 5090", "12.0", Some(170))]).unwrap(); assert_eq!(line, "the kernel pack is built for rtx_pro_6000_maxq (sm_120a, 188 SMs); none runs on NVIDIA GeForce RTX 5090 (cc 12.0, 170 SMs) (rtx_pro_6000_maxq: the plan's grid needs 188 SMs co-resident, the device has 170)"); assert_eq!(sku_refusal(&reqs, &[gpu("NVIDIA RTX PRO 6000 Blackwell Max-Q", "12.0", Some(188))]), None, "the card it was built for runs it"); - assert_eq!(sku_refusal(&reqs, &[gpu("a card CUDA does not show", "12.0", None)]), None, "an unknown SM count never refuses"); + assert!(sku_refusal(&reqs, &[gpu("a card CUDA does not show", "12.0", None)]).unwrap().contains("SM count is unknown")); assert!(sku_refusal(&reqs, &[gpu("an Ada card", "8.9", Some(128))]).unwrap().contains("sm_120a SASS runs only on cc 12.0")); } diff --git a/engine/crates/core/src/platform_api.rs b/engine/crates/core/src/platform_api.rs index 8992a387..600adcf9 100644 --- a/engine/crates/core/src/platform_api.rs +++ b/engine/crates/core/src/platform_api.rs @@ -104,7 +104,7 @@ impl Client { pub fn auth_start(&self, hostname: &str, fingerprint: &str) -> Result { let body = json!({"action": "start", "hostname": hostname, "version": env!("CARGO_PKG_VERSION"), "fingerprint": fingerprint}); - parse_started(&self.post("/api/device/auth", body.to_string().as_bytes(), None)?, self.base().starts_with("http://")) + parse_started(&self.post("/api/device/auth", body.to_string().as_bytes(), None)?, &self.base()) } pub fn auth_poll(&self, device_code: &Secret) -> Result { @@ -250,7 +250,7 @@ fn malformed(what: &str) -> ApiError { ApiError::Malformed(what.to_string()) } -pub fn parse_started(v: &Value, dev: bool) -> Result { +pub fn parse_started(v: &Value, base: &str) -> Result { #[derive(Deserialize)] struct Raw { device_code: String, @@ -266,8 +266,11 @@ pub fn parse_started(v: &Value, dev: bool) -> Result { if r.user_code.is_empty() || r.user_code.len() > 32 || !r.user_code.chars().all(|c| c.is_ascii_alphanumeric() || c == '-') { return Err(malformed("the user code is not valid")); } - let check = if dev { crate::platform::check_dev_link } else { crate::platform::check_link }; + let check = if base.starts_with("http://") { crate::platform::check_dev_link } else { crate::platform::check_link }; let uri = check(&r.verification_uri_complete).map_err(|_| malformed("the verification link is not a valid https URL"))?; + if !verification_on_base(base, &uri) { + return Err(malformed("the verification link is not on the platform")); + } Ok(Started { device_code: Secret::new(r.device_code), user_code: r.user_code, @@ -277,6 +280,26 @@ pub fn parse_started(v: &Value, dev: bool) -> Result { }) } +fn verification_on_base(base: &str, uri: &str) -> bool { + let host = |u: &str| -> String { + let rest = u.split_once("://").map(|(_, r)| r).unwrap_or(""); + let auth = rest.split(['/', '?', '#']).next().unwrap_or(""); + let auth = auth.rsplit_once('@').map(|(_, a)| a).unwrap_or(auth); + let h = if let Some(v6) = auth.strip_prefix('[') { + v6.split_once(']').map(|(h, _)| h).unwrap_or("") + } else { + match auth.rsplit_once(':') { + Some((h, p)) if p.parse::().is_ok() => h, + _ => auth, + } + }; + let h = h.to_ascii_lowercase(); + h.strip_prefix("www.").unwrap_or(&h).to_string() + }; + let (b, u) = (host(base), host(uri)); + !b.is_empty() && b == u +} + pub fn parse_approved(v: &Value) -> Result { #[derive(Deserialize)] struct RawWorkspace { @@ -474,6 +497,18 @@ mod tests { let m = mock::serve(vec![(200, r#"{"device_code":"d","user_code":"AB\u001b[2J","verification_uri_complete":"http://evil.example.com/x","expires_in":900,"interval":3}"#.into())]); let c = Client::new(&m.url, Duration::from_secs(5)).unwrap(); assert!(c.auth_start("h", "f").is_err()); + let m = mock::serve(vec![(200, r#"{"device_code":"d","user_code":"ABCD-1234","verification_uri_complete":"https://evil.example.com/x","expires_in":900,"interval":3}"#.into())]); + let c = Client::new(&m.url, Duration::from_secs(5)).unwrap(); + assert!(c.auth_start("h", "f").is_err(), "https on another origin is refused"); + } + + #[test] + fn verification_link_must_share_the_platform_host() { + assert!(verification_on_base("https://goethe.sh", "https://goethe.sh/device?code=1")); + assert!(verification_on_base("https://goethe.sh", "https://www.goethe.sh/device?code=1"), "www twin"); + assert!(!verification_on_base("https://goethe.sh", "https://evil.example.com/device")); + assert!(!verification_on_base("https://goethe.sh", "https://goethe.sh.evil.com/device")); + assert!(verification_on_base("http://127.0.0.1:9", "http://127.0.0.1:9/device")); } #[test] diff --git a/engine/crates/core/src/public_share.rs b/engine/crates/core/src/public_share.rs index e6c684d6..42f2bb15 100644 --- a/engine/crates/core/src/public_share.rs +++ b/engine/crates/core/src/public_share.rs @@ -51,20 +51,16 @@ impl Share { } fn settle(&mut self) { - // One gateway for every shared key: open until the last key's time ends; nginx admits the union of their addresses, or anyone when a key has none. + // One gateway for every shared key: open until the last key's time ends; nginx admits the union of their allowlists. self.keys = self.grants.iter().map(|g| g.key.clone()).collect(); self.until = self.grants.iter().map(|g| g.until).max().unwrap_or(self.until); - self.allow = if self.grants.iter().all(|g| !g.allow.is_empty()) { - let mut all: Vec = Vec::new(); - for c in self.grants.iter().flat_map(|g| g.allow.iter()) { - if !all.contains(c) { - all.push(c.clone()); - } + let mut all: Vec = Vec::new(); + for c in self.grants.iter().flat_map(|g| g.allow.iter()) { + if !all.contains(c) { + all.push(c.clone()); } - all - } else { - Vec::new() - }; + } + self.allow = all; } fn grant(&self, key: &str) -> Option { @@ -197,7 +193,7 @@ fn decide(share: Option<&Share>, key_id: &str, is_admin: bool, now: i64, client: if now >= g.until { return Access::KeyExpired; } - if !g.allow.is_empty() && !client.is_some_and(|ip| g.allow.iter().any(|c| cidr_contains(c, ip))) { + if g.allow.is_empty() || !client.is_some_and(|ip| g.allow.iter().any(|c| cidr_contains(c, ip))) { return Access::NotFromHere; } Access::Allowed @@ -255,6 +251,34 @@ fn port_free(port: u16) -> bool { TcpListener::bind(SocketAddr::from(([0, 0, 0, 0], port))).is_ok() } +fn allowlist_at(home: &Path) -> Vec { + let Ok(con) = db::open(home) else { return Vec::new() }; + let Ok(mut stmt) = con.prepare("SELECT cidr FROM ip_allowlist ORDER BY cidr") else { return Vec::new() }; + stmt.query_map([], |r| r.get(0)).ok().into_iter().flatten().filter_map(Result::ok).collect() +} + +fn share_allow(cli: &[String], reuse_keys: bool, kept: &[String], gateway: &[String]) -> Vec { + // --allow wins; reopening remembered keys keeps their addresses; else the ordinary API allowlist. + if !cli.is_empty() { + return cli.to_vec(); + } + if reuse_keys && !kept.is_empty() { + return kept.to_vec(); + } + gateway.to_vec() +} + +fn need_client_allow(home: &Path) -> String { + // Who may connect is the client's public IP, not this machine's (that one is only the URL). + let here = crate::platform::lookup_public_ip(home) + .ok() + .map(|ip| format!(" this machine's public address is {ip} (that becomes the URL, not --allow);")) + .unwrap_or_default(); + format!( + "name who may connect with --allow /32 (their phone or laptop's public IP, not this machine's).{here} ask them, or add them first with goethe api allow add /32" + ) +} + fn mux_public_listening(home: &Path) -> bool { nginx::persisted_mux_port(home) .is_ok_and(|p| TcpStream::connect_timeout(&public_mux_addr(p), Duration::from_millis(500)).is_ok()) @@ -298,7 +322,8 @@ pub fn open(home: &Path, a: OpenArgs) -> Result { a.keys.to_vec() }; let keys = resolve_keys(home, &wanted, until, &mut warnings)?; - let allow = a.allow.iter().map(|c| security::canonical_cidr(c)).collect::, _>>()?; + let cli_allow = a.allow.iter().map(|c| security::canonical_cidr(c)).collect::, _>>()?; + let gateway_allow = allowlist_at(home); let port = a.port.or(previous.as_ref().map(|p| p.port)).unwrap_or(DEFAULT_PORT); let mut grants: Vec = previous .as_ref() @@ -307,8 +332,12 @@ pub fn open(home: &Path, a: OpenArgs) -> Result { .unwrap_or_default(); for k in &keys { let kept = previous.as_ref().and_then(|p| p.grant(&k.id)).map(|g| g.allow).unwrap_or_default(); + let allow = share_allow(&cli_allow, a.keys.is_empty(), &kept, &gateway_allow); + if allow.is_empty() { + return Err(need_client_allow(home)); + } grants.retain(|g| g.key != k.id); - grants.push(Grant { key: k.id.clone(), until, allow: if a.allow.is_empty() && a.keys.is_empty() { kept } else { allow.clone() } }); + grants.push(Grant { key: k.id.clone(), until, allow }); } let gateway_port = nginx::public_port_u16(home); let mux_port = nginx::persisted_mux_port(home)?; @@ -487,13 +516,8 @@ pub fn nginx_block(home: &Path, mux_port: u16, modern_http2: bool, max_body_mb: if !cert_path(home).is_file() && ensure_cert(home, None).is_err() { return String::new(); } - let allow = if share.allow.is_empty() { - String::new() - } else { - let mut lines: String = share.allow.iter().map(|c| format!(" allow {c};\n")).collect(); - lines.push_str(" deny all;\n"); - lines - }; + let mut allow: String = share.allow.iter().map(|c| format!(" allow {c};\n")).collect(); + allow.push_str(" deny all;\n"); const TMPL: &str = include_str!("../../../nginx/goethe_public.conf.tmpl"); TMPL.replace("{{PORT}}", &share.port.to_string()) .replace("{{HTTP2_LISTEN}}", if modern_http2 { "" } else { " http2" }) @@ -535,7 +559,7 @@ mod tests { use super::*; fn share(open: bool, until: i64) -> Share { - Share { open, until, port: 8444, keys: vec!["k1".into()], allow: vec![], grants: vec![] } + Share { open, until, port: 8444, keys: vec!["k1".into()], allow: vec!["203.0.113.0/24".into()], grants: vec![] } } fn granted(grants: &[(&str, i64, &[&str])]) -> Share { @@ -547,12 +571,13 @@ mod tests { #[test] fn two_keys_share_one_gateway_and_one_that_ended_is_refused_while_the_other_works() { - let s = granted(&[("k1", 1000, &[]), ("k4", 5000, &[])]); + let ip = |s: &str| Some(s.parse::().unwrap()); + let s = granted(&[("k1", 1000, &["203.0.113.0/24"]), ("k4", 5000, &["203.0.113.0/24"])]); assert_eq!((s.until, s.keys.clone()), (5000, vec!["k1".to_string(), "k4".to_string()]), "open until the last key ends"); - assert_eq!(decide(Some(&s), "k1", false, 999, None), Access::Allowed); - assert_eq!(decide(Some(&s), "k1", false, 1000, None), Access::KeyExpired); - assert_eq!(decide(Some(&s), "k4", false, 1000, None), Access::Allowed, "the gateway stays open for the other key"); - assert_eq!(decide(Some(&s), "k4", false, 5000, None), Access::Closed); + assert_eq!(decide(Some(&s), "k1", false, 999, ip("203.0.113.1")), Access::Allowed); + assert_eq!(decide(Some(&s), "k1", false, 1000, ip("203.0.113.1")), Access::KeyExpired); + assert_eq!(decide(Some(&s), "k4", false, 1000, ip("203.0.113.1")), Access::Allowed, "the gateway stays open for the other key"); + assert_eq!(decide(Some(&s), "k4", false, 5000, ip("203.0.113.1")), Access::Closed); } #[test] @@ -563,10 +588,10 @@ mod tests { assert_eq!(decide(Some(&s), "k1", false, 0, ip("203.0.113.9")), Access::Allowed); assert_eq!(decide(Some(&s), "k1", false, 0, ip("198.51.100.7")), Access::NotFromHere, "not the other key's address"); assert_eq!(decide(Some(&s), "k1", false, 0, None), Access::NotFromHere, "no address, no entry"); - let open = granted(&[("k1", 1000, &["203.0.113.0/24"]), ("k4", 1000, &[])]); - assert!(open.allow.is_empty(), "a key without addresses opens nginx to anyone; the router still limits k1"); - assert_eq!(decide(Some(&open), "k1", false, 0, ip("8.8.8.8")), Access::NotFromHere); - assert_eq!(decide(Some(&open), "k4", false, 0, ip("8.8.8.8")), Access::Allowed); + let mixed = granted(&[("k1", 1000, &["203.0.113.0/24"]), ("k4", 1000, &[])]); + assert_eq!(mixed.allow, vec!["203.0.113.0/24".to_string()], "empty allowlists do not open nginx to the world"); + assert_eq!(decide(Some(&mixed), "k1", false, 0, ip("8.8.8.8")), Access::NotFromHere); + assert_eq!(decide(Some(&mixed), "k4", false, 0, ip("8.8.8.8")), Access::NotFromHere); assert!(cidr_contains("2001:db8::/32", "2001:db8::1".parse().unwrap()) && !cidr_contains("2001:db8::/32", "2001:db9::1".parse().unwrap())); } @@ -583,13 +608,14 @@ mod tests { #[test] fn only_listed_non_admin_keys_pass_while_the_window_is_open() { + let ip = |s: &str| Some(s.parse::().unwrap()); let s = share(true, 1000); - assert_eq!(decide(Some(&s), "k1", false, 999, None), Access::Allowed); - assert_eq!(decide(Some(&s), "k1", false, 1000, None), Access::Closed, "closes at the end second"); - assert_eq!(decide(Some(&s), "k2", false, 999, None), Access::KeyNotShared); - assert_eq!(decide(Some(&s), "k1", true, 999, None), Access::KeyNotShared, "admin keys never"); - assert_eq!(decide(Some(&share(false, 5000)), "k1", false, 999, None), Access::Closed, "shut down"); - assert_eq!(decide(None, "k1", false, 0, None), Access::Closed); + assert_eq!(decide(Some(&s), "k1", false, 999, ip("203.0.113.1")), Access::Allowed); + assert_eq!(decide(Some(&s), "k1", false, 1000, ip("203.0.113.1")), Access::Closed, "closes at the end second"); + assert_eq!(decide(Some(&s), "k2", false, 999, ip("203.0.113.1")), Access::KeyNotShared); + assert_eq!(decide(Some(&s), "k1", true, 999, ip("203.0.113.1")), Access::KeyNotShared, "admin keys never"); + assert_eq!(decide(Some(&share(false, 5000)), "k1", false, 999, ip("203.0.113.1")), Access::Closed, "shut down"); + assert_eq!(decide(None, "k1", false, 0, ip("203.0.113.1")), Access::Closed); } fn home_with_keys() -> tempfile::TempDir { @@ -646,19 +672,46 @@ mod tests { assert!(block.contains("public.crt")); } + #[test] + fn nginx_block_always_denies_all_even_with_an_empty_allowlist() { + // Isolation: render only — no listener, no public bind. + let dir = home_with_keys(); + let h = dir.path(); + store(h, &Share { allow: vec![], ..share(true, now() + 600) }).unwrap(); + let block = nginx_block(h, 30000, true, 64); + assert!(block.contains("deny all;"), "{block}"); + assert!(!block.contains("allow "), "empty allowlist must not admit the world: {block}"); + } + + #[test] + fn share_allow_prefers_cli_then_kept_then_gateway() { + assert_eq!(share_allow(&["203.0.113.9/32".into()], false, &["198.51.100.1/32".into()], &["192.0.2.1/32".into()]), vec!["203.0.113.9/32".to_string()]); + assert_eq!(share_allow(&[], true, &["198.51.100.1/32".into()], &["192.0.2.1/32".into()]), vec!["198.51.100.1/32".to_string()]); + assert_eq!(share_allow(&[], false, &[], &["192.0.2.1/32".into()]), vec!["192.0.2.1/32".to_string()]); + assert!(share_allow(&[], false, &[], &[]).is_empty()); + } + + #[test] + fn need_client_allow_names_the_client_not_this_machine() { + let dir = tempfile::tempdir().unwrap(); + let msg = need_client_allow(dir.path()); + assert!(msg.contains("their phone or laptop") && msg.contains("--allow") && msg.contains("goethe api allow add"), "{msg}"); + } + #[test] fn the_router_sees_every_change_at_once() { let dir = home_with_keys(); let h = dir.path(); - assert_eq!(check(h, "k1", false, None), Access::Closed); + let ip = Some("203.0.113.1".parse::().unwrap()); + assert_eq!(check(h, "k1", false, ip), Access::Closed); store(h, &share(true, now() + 600)).unwrap(); - assert_eq!(check(h, "k1", false, None), Access::Allowed); + assert_eq!(check(h, "k1", false, ip), Access::Allowed); store(h, &Share { keys: vec!["k4".into()], ..share(true, now() + 600) }).unwrap(); - assert_eq!(check(h, "k1", false, None), Access::KeyNotShared, "a replaced key stops at the next request"); + assert_eq!(check(h, "k1", false, ip), Access::KeyNotShared, "a replaced key stops at the next request"); store(h, &Share { open: false, ..share(true, now() + 600) }).unwrap(); - assert_eq!(check(h, "k1", false, None), Access::Closed); + assert_eq!(check(h, "k1", false, ip), Access::Closed); fs::remove_file(path(h)).unwrap(); - assert_eq!(check(h, "k1", false, None), Access::Closed); + assert_eq!(check(h, "k1", false, ip), Access::Closed); } #[test] diff --git a/engine/crates/core/src/recommend.rs b/engine/crates/core/src/recommend.rs index dcfe8832..615cb561 100644 --- a/engine/crates/core/src/recommend.rs +++ b/engine/crates/core/src/recommend.rs @@ -146,6 +146,7 @@ impl View { let mut trial = input.clone(); trial.ctx = plan.ctx; trial.max_conc = plan.max_conc; + trial.overhead_gb = crate::engines::by_id(runtime).map_or(calc::BASE_OVERHEAD_GB, |e| e.overhead_gb); let base = chooser::need(&trial, plan.tp, &plan.cc); let learned = self.con.as_ref().map(|c| crate::engine_overhead::read_learned(c, model_id, &self.gpu_name(plan.gpus[0]), plan.tp as u64, runtime)); let learned = learned.unwrap_or_default(); @@ -406,6 +407,7 @@ pub fn registry_input(m: &RegistryModel) -> ChooserInput { crate::memory_spec::apply_engine_args(&mut spec, None, &m.extra_sglang_args); spec }), + overhead_gb: crate::engines::by_id(m.effective_runtime()).map_or(crate::calc::BASE_OVERHEAD_GB, |e| e.overhead_gb), } } diff --git a/engine/crates/core/src/setup.rs b/engine/crates/core/src/setup.rs index 555542c9..3dd2ab1e 100644 --- a/engine/crates/core/src/setup.rs +++ b/engine/crates/core/src/setup.rs @@ -6,15 +6,32 @@ use std::path::{Path, PathBuf}; pub const DEFAULT_PKG_URL: &str = "https://pkg.goethe.sh"; +pub fn migrate_retired_pkg_env(home: &Path) -> Result<(), String> { + let text = fs::read_to_string(home.join("goethe.env")).unwrap_or_default(); + if !text.contains("pkg.meshapplied.com") { + return Ok(()); + } + let m = crate::paths::parse_env_file(&text); + write_env_file( + home, + &env_file_text( + m.get("GOETHE_PKG_URL").map(|s| s.as_str()).unwrap_or(DEFAULT_PKG_URL), + m.get("GOETHE_REGISTRY_URL").map(|s| s.as_str()), + m.get("GOETHE_PKG_TOKEN").map(|s| s.as_str()), + true, + ), + ) +} + pub fn env_file_text(pkg: &str, registry: Option<&str>, token: Option<&str>, keep_file_url: bool) -> String { // GOETHE_HOME/goethe.env holds only what differs from the defaults; a file:// package is a one-off unless asked to keep it. let pkg = pkg.trim_end_matches('/'); let mut out = String::new(); let local = pkg.starts_with("file://"); - if pkg != DEFAULT_PKG_URL && !pkg.is_empty() && (!local || keep_file_url) { + if pkg != DEFAULT_PKG_URL && !pkg.is_empty() && !pkg.contains("pkg.meshapplied.com") && (!local || keep_file_url) { out.push_str(&format!("GOETHE_PKG_URL={pkg}\n")); } - if let Some(r) = registry.map(str::trim).filter(|r| !r.is_empty() && *r != format!("{pkg}/v1/registry.json")) { + if let Some(r) = registry.map(str::trim).filter(|r| !r.is_empty() && !r.contains("pkg.meshapplied.com") && *r != format!("{pkg}/v1/registry.json")) { out.push_str(&format!("GOETHE_REGISTRY_URL={r}\n")); } if let Some(t) = token.map(str::trim).filter(|t| !t.is_empty()) { @@ -268,6 +285,7 @@ pub fn run(o: Opts) -> Result<(), String> { // Verify the signed package, place goethe, goethed and nginx (handing a running goethed's engines over), then settings, links, certificate, fixes and login. let home = crate::paths::goethe_home(); crate::paths::ensure_layout(&home).map_err(|e| format!("{}: {e}", home.display()))?; + let _ = migrate_retired_pkg_env(&home); fs::set_permissions(&home, std::os::unix::fs::PermissionsExt::from_mode(0o700)).map_err(|e| format!("{}: {e}", home.display()))?; let macos = cfg!(target_os = "macos"); let from = o.from.clone().unwrap_or_else(|| o.pkg.clone()).trim_end_matches('/').to_string(); @@ -413,6 +431,21 @@ mod tests { assert_eq!(login_question(&linked(false)), None); } + #[test] + fn retired_pkg_host_is_dropped_from_goethe_env() { + let t = tempfile::tempdir().unwrap(); + let home = t.path(); + fs::create_dir_all(home).unwrap(); + #[cfg(unix)] + fs::set_permissions(home, std::os::unix::fs::PermissionsExt::from_mode(0o700)).unwrap(); + crate::platform::write_private(&home.join("goethe.env"), b"GOETHE_PKG_URL=https://pkg.meshapplied.com\nGOETHE_PKG_TOKEN=tok\n").unwrap(); + migrate_retired_pkg_env(home).unwrap(); + let text = fs::read_to_string(home.join("goethe.env")).unwrap_or_default(); + assert!(!text.contains("pkg.meshapplied.com"), "{text}"); + assert!(text.contains("GOETHE_PKG_TOKEN=tok"), "{text}"); + migrate_retired_pkg_env(home).unwrap(); + } + #[test] fn the_path_line_goes_into_the_shells_startup_file_once() { let home = Path::new("/home/u"); diff --git a/engine/crates/core/src/update.rs b/engine/crates/core/src/update.rs index e96f9817..b51f6c4b 100644 --- a/engine/crates/core/src/update.rs +++ b/engine/crates/core/src/update.rs @@ -28,6 +28,7 @@ pub fn run(opts: UpdateOpts) -> Result<(), String> { // Fetch and verify the signed manifest, compare versions, stage files, then swap atomically. let home = goethe_home(); ensure_layout(&home).map_err(|e| e.to_string())?; + let _ = crate::setup::migrate_retired_pkg_env(&home); let pkg = pkg_base_url(); let tmp = home.join(".update-staging"); let _ = fs::remove_dir_all(&tmp); diff --git a/engine/crates/goethe/src/main.rs b/engine/crates/goethe/src/main.rs index 2fd6b556..c6b45528 100644 --- a/engine/crates/goethe/src/main.rs +++ b/engine/crates/goethe/src/main.rs @@ -85,13 +85,13 @@ goethe api expose alone shows where the API listens and who may connect."; const SHARE_HELP: &str = "Examples: -\t→ goethe api share 5h --key my-app -\t→ goethe api share 1d (the keys of the last opening) +\t→ goethe api share 5h --key my-app --allow /32 +\t→ goethe api allow add /32 +\t goethe api share 5h --key my-app \t→ goethe api share (status) -\t→ goethe api share stop --key my-app (that key only) \t→ goethe api share stop -Every shared key uses the one public gateway, each until its own time and from its own addresses; it closes when the last one ends."; +--allow is who may connect (their public IP: ask them, or https://ifconfig.me). This machine's IP is only the URL goethe prints. Or add them with goethe api allow first, then share without --allow. Closes when the last key ends."; #[derive(Parser)] #[command( @@ -1736,7 +1736,7 @@ fn do_share(public: &str, keys: &[String], allow: &[String], port: Option) } "status" => { if !keys.is_empty() || !allow.is_empty() || port.is_some() { - usage("give a duration to open the public gateway, such as goethe api share 5h --key my-app"); + usage("give a duration to open the public gateway, such as goethe api share 5h --key my-app --allow /32"); } match share::active(&home) { Some(s) => { @@ -1744,12 +1744,12 @@ fn do_share(public: &str, keys: &[String], allow: &[String], port: Option) println!("Public gateway: open until {} ({} left)", share::local_time(s.until), left(s.until - share::now())); println!("URL: https://{}/v1", host_port(&ip, s.port)); for (name, g) in share::shared(&home) { - let from = if g.allow.is_empty() { "any address".to_string() } else { g.allow.join(", ") }; + let from = if g.allow.is_empty() { "no addresses (unreachable)".to_string() } else { g.allow.join(", ") }; println!("Key: {name} until {} ({} left), from {from}", share::local_time(g.until), left(g.until - share::now())); } println!("\nStop one key with: goethe api share stop --key ; close it with: goethe api share stop"); } - None => println!("The public gateway is closed. Open it with: goethe api share 5h --key "), + None => println!("The public gateway is closed. Open it with: goethe api share 5h --key --allow /32"), } Ok(()) } @@ -1765,8 +1765,9 @@ fn do_share(public: &str, keys: &[String], allow: &[String], port: Option) let token = k.token.as_deref().unwrap_or("(shown when it was created)"); println!("Key: {} {token} models: {models}", k.name); } - if !allow.is_empty() { - println!("Only: {}", allow.join(", ")); + let clients: Vec = o.share.allow.clone(); + if !clients.is_empty() { + println!("Only these clients: {}", clients.join(", ")); } println!("\nTLS: self-signed for this address. Send {} with the key (it holds no secret); the recipient", o.cert.display()); println!(" verifies the gateway with it, for example:"); diff --git a/engine/tests/e2e/fake/goethe_engine/openai_server.py b/engine/tests/e2e/fake/goethe_engine/openai_server.py index 44685b66..0188ad20 100644 --- a/engine/tests/e2e/fake/goethe_engine/openai_server.py +++ b/engine/tests/e2e/fake/goethe_engine/openai_server.py @@ -1,6 +1,7 @@ """A model server speaking the OpenAI routes goethe uses: health, models, chat, completions, embeddings.""" import json +import os import sys from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer @@ -15,7 +16,8 @@ def option(args, *names): def serve(args): """Run until killed: port, key and served name come from the engine's own flags.""" - port, key = int(option(args, "--port")), option(args, "--api-key") or "" + port = int(option(args, "--port")) + key = option(args, "--api-key") or os.environ.get("GOETHE_ENGINE_API_KEY") or os.environ.get("LLAMA_API_KEY") or "" name = option(args, "--alias", "--served-model-name") or "model" class Handler(BaseHTTPRequestHandler): diff --git a/engine/tests/lib/goethe_test.py b/engine/tests/lib/goethe_test.py index fe9388d1..2e38b4ff 100644 --- a/engine/tests/lib/goethe_test.py +++ b/engine/tests/lib/goethe_test.py @@ -728,8 +728,10 @@ def write_stub_python(pyenv_bin: Path, real: Path) -> None: "#!/bin/bash\n" f'REAL="{real}"\n' f'STUB="{STUB_ENGINE}"\n' - 'if [[ "$1" == "-m" && "$2" == "sglang.launch_server" ]]; then\n' - ' exec "$REAL" "$STUB" "${@:3}"\n' + 'if [[ "$1" == "-m" && ( "$2" == "sglang.launch_server" || "$2" == "goethe_sglang_boot" ) ]]; then\n' + ' EXTRA=()\n' + ' if [[ -n "${GOETHE_ENGINE_API_KEY:-}" ]]; then EXTRA=(--api-key "$GOETHE_ENGINE_API_KEY"); fi\n' + ' exec "$REAL" "$STUB" "${@:3}" "${EXTRA[@]}"\n' "fi\n" 'if [[ "$1" == "-c" && "$2" == *sglang* ]]; then echo ok; exit 0; fi\n' 'exec "$REAL" "$@"\n', diff --git a/engine/tests/lib/stub_engine.py b/engine/tests/lib/stub_engine.py index 533cda4c..917095c7 100644 --- a/engine/tests/lib/stub_engine.py +++ b/engine/tests/lib/stub_engine.py @@ -18,6 +18,7 @@ RECORDED_ENV = ( "CUDA_VISIBLE_DEVICES", "GOETHE_HOME", "PYTHONPATH", "GOETHE_INSTANCE_ID", "GOETHE_KERNEL_DIR", "SPT_NOENV", + "GOETHE_ENGINE_API_KEY", "LLAMA_API_KEY", ) FILE_KNOBS = ("STUB_START_DELAY", "STUB_IGNORE_SIGTERM", "STUB_SIGTERM_DELAY", "STUB_TOKEN_INTERVAL") AUTH_EXEMPT = ("/health", "/ready", "/metrics") @@ -39,6 +40,8 @@ def _parse_args(argv: list[str]) -> argparse.Namespace: parser.add_argument("--api-key") parser.add_argument("--disable-custom-all-reduce", action="store_true") args, _unknown = parser.parse_known_args(argv) + if not args.api_key: + args.api_key = os.environ.get("GOETHE_ENGINE_API_KEY") or os.environ.get("LLAMA_API_KEY") return args From 840bfb843f039df2ff81d3eecd627c0e4b2ed51a Mon Sep 17 00:00:00 2001 From: Petya <64523372+peti12352@users.noreply.github.com> Date: Wed, 18 Nov 2026 12:36:10 -0800 Subject: [PATCH 02/12] Ternary is SGLang plus env; one flag table and one sha256. Drop the separate ternary Engine and per_gpu_budget_gb wrapper. Card runtime spelling stays ternary for learned rows; launch and overhead go through sglang. Equivalence tests cover argv, env gating, reserved flags, and digests. --- engine/crates/core/src/chooser.rs | 4 - engine/crates/core/src/engine_overhead.rs | 17 +++- engine/crates/core/src/engines/mod.rs | 10 ++- engine/crates/core/src/engines/ninfer.rs | 14 +-- engine/crates/core/src/engines/sglang.rs | 102 +++++++++++++++------- engine/crates/core/src/hf.rs | 17 +--- engine/crates/core/src/packs.rs | 4 +- engine/crates/core/src/sglang_infer.rs | 5 ++ engine/crates/core/src/update.rs | 13 +++ 9 files changed, 117 insertions(+), 69 deletions(-) diff --git a/engine/crates/core/src/chooser.rs b/engine/crates/core/src/chooser.rs index 6c40e1f7..9ca83f54 100644 --- a/engine/crates/core/src/chooser.rs +++ b/engine/crates/core/src/chooser.rs @@ -168,10 +168,6 @@ pub fn cap_default_ctx(input: &ChooserInput, tp: usize, cc: &str, free_gb: f64) trial.ctx } -pub fn per_gpu_budget_gb(input: &ChooserInput, tp: usize, cc: &str) -> f64 { - need(input, tp, cc).total() -} - pub fn with_learned(base: Need, learned: Learned) -> Need { // Fold what a model taught us on a GPU type and tp into the budget parts: static extra and non-static overhead. Need { diff --git a/engine/crates/core/src/engine_overhead.rs b/engine/crates/core/src/engine_overhead.rs index 0f3fe05c..23884d9b 100644 --- a/engine/crates/core/src/engine_overhead.rs +++ b/engine/crates/core/src/engine_overhead.rs @@ -99,7 +99,8 @@ pub fn model_runtime(home: &Path, model_id: &str) -> String { } pub fn card_runtime(card: &toml::Value) -> String { - crate::engines::of_card(card).map_or_else(|_| "unknown".to_string(), |e| e.id.to_string()) + // Spelling on the card (ternary ≠ launch id sglang; learned rows key on the spelling). + card.get("runtime").and_then(|v| v.as_str()).unwrap_or("sglang").to_string() } pub fn parse_pre_load_gb(log_text: &str) -> Option { @@ -258,6 +259,20 @@ mod tests { assert!(parse_shortfall_gb(log).unwrap() > 0.0); } + #[test] + fn ternary_card_spelling_stays_ternary_for_learned_rows() { + let tern: toml::Value = toml::from_str("runtime = \"ternary\"").unwrap(); + let plain: toml::Value = toml::from_str("runtime = \"sglang\"").unwrap(); + assert_eq!(card_runtime(&tern), "ternary"); + assert_eq!(card_runtime(&plain), "sglang"); + assert_eq!(crate::engines::of_card(&tern).unwrap().id, "sglang"); + let td = tempfile::tempdir().unwrap(); + let con = crate::db::open(td.path()).unwrap(); + store_learned(&con, "m", "GPU", 1, Kind::Overhead, 2.5, "ternary").unwrap(); + assert_eq!(read_learned(&con, "m", "GPU", 1, "ternary").overhead_gb, 2.5); + assert_eq!(read_learned(&con, "m", "GPU", 1, "sglang").overhead_gb, 0.0, "sglang rows stay separate"); + } + #[test] fn a_figure_learned_under_a_plain_runtime_never_blocks_the_kernel_pack() { let dir = tempfile::tempdir().unwrap(); diff --git a/engine/crates/core/src/engines/mod.rs b/engine/crates/core/src/engines/mod.rs index 173a53bd..e7606137 100644 --- a/engine/crates/core/src/engines/mod.rs +++ b/engine/crates/core/src/engines/mod.rs @@ -17,17 +17,17 @@ pub struct Engine { pub command: fn(&EngineSpec) -> Result, } -pub const ENGINES: &[&Engine] = &[&goethe_engine::ENGINE, &ninfer::ENGINE, &sglang::SGLANG, &sglang::TERNARY, &llama_cpp::ENGINE]; +pub const ENGINES: &[&Engine] = &[&goethe_engine::ENGINE, &ninfer::ENGINE, &sglang::SGLANG, &llama_cpp::ENGINE]; const ENVELOPE: &[&str] = &["model", "messages", "prompt", "input", "stream", "stream_options", "user"]; pub fn by_id(id: &str) -> Result<&'static Engine, String> { + let id = if id == "ternary" { sglang::SGLANG.id } else { id }; let ids: Vec<&str> = ENGINES.iter().map(|e| e.id).collect(); ENGINES.iter().copied().find(|e| e.id == id).ok_or_else(|| format!("engine {id} is not one goethe runs ({})", ids.join(", "))) } pub fn of_card(card: &toml::Value) -> Result<&'static Engine, String> { - // The card's runtime; a card without one is SGLang's. by_id(card.get("runtime").and_then(|v| v.as_str()).unwrap_or(sglang::SGLANG.id)) } @@ -337,6 +337,7 @@ mod tests { assert!((by_id("ninfer").unwrap().overhead_gb - crate::calc::METAL_OVERHEAD_GB).abs() < 1e-9); assert!((by_id("sglang").unwrap().overhead_gb - crate::calc::BASE_OVERHEAD_GB).abs() < 1e-9); assert!((by_id("ternary").unwrap().overhead_gb - crate::calc::BASE_OVERHEAD_GB).abs() < 1e-9); + assert_eq!(by_id("ternary").unwrap().id, "sglang", "ternary launches as sglang"); } #[test] @@ -358,9 +359,12 @@ mod tests { #[test] fn every_runtime_a_card_was_ever_written_with_resolves_and_an_unknown_one_is_refused() { assert_eq!(of_card(&toml::from_str("").unwrap()).unwrap().id, "sglang"); - for id in ["sglang", "ternary", "ninfer", "goethe-engine", "llama.cpp"] { + for id in ["sglang", "ninfer", "goethe-engine", "llama.cpp"] { assert_eq!(of_card(&toml::from_str(&format!("runtime = \"{id}\"")).unwrap()).unwrap().id, id); } + let ternary: toml::Value = toml::from_str("runtime = \"ternary\"").unwrap(); + assert_eq!(of_card(&ternary).unwrap().id, "sglang"); + assert_eq!(crate::engine_overhead::card_runtime(&ternary), "ternary"); assert!(args(&spec_cmd("", 1)).iter().any(|a| a == "goethe_sglang_boot")); assert!(of_card(&toml::from_str("runtime = \"vllm\"").unwrap()).map(|e| e.id).unwrap_err().contains("not one goethe runs")); } diff --git a/engine/crates/core/src/engines/ninfer.rs b/engine/crates/core/src/engines/ninfer.rs index cf10a9c9..cf2dd536 100644 --- a/engine/crates/core/src/engines/ninfer.rs +++ b/engine/crates/core/src/engines/ninfer.rs @@ -56,19 +56,7 @@ pub fn accept_ninfer(len: u64, digest: &str) -> Result<(), String> { } pub fn sha256_file(path: &Path) -> Result { - use sha2::{Digest, Sha256}; - use std::io::Read; - let mut f = std::fs::File::open(path).map_err(|e| format!("{}: {e}", path.display()))?; - let mut h = Sha256::new(); - let mut buf = vec![0u8; 1 << 20]; - loop { - let n = f.read(&mut buf).map_err(|e| format!("{}: {e}", path.display()))?; - if n == 0 { - break; - } - h.update(&buf[..n]); - } - Ok(format!("{:x}", h.finalize())) + crate::update::sha256_file(path).map_err(|e| format!("{}: {e}", path.display())) } pub fn ninfer_in(dir: &Path) -> Option { diff --git a/engine/crates/core/src/engines/sglang.rs b/engine/crates/core/src/engines/sglang.rs index 00353bbd..f4b76ace 100644 --- a/engine/crates/core/src/engines/sglang.rs +++ b/engine/crates/core/src/engines/sglang.rs @@ -1,9 +1,10 @@ -// SGLang: python -m sglang.launch_server with Goethe-owned flags, card and load extras; ternary is SGLang plus its kernel env. +// SGLang launch: Goethe-owned flags, card extras; ternary cards are the same command plus TERNARY_* env. use super::{ arch_env, card_env, compiler_env, default_cuda_home, engine_key_env, engine_path, expand_home, kept_env, placement_env, resolve_python, EngineSpec, }; +use crate::sglang_infer::RESERVED_FLAGS; use std::process::Command; pub const SGLANG: super::Engine = super::Engine { @@ -11,31 +12,16 @@ pub const SGLANG: super::Engine = super::Engine { overhead_gb: crate::calc::BASE_OVERHEAD_GB, layer: Some(crate::pyenv::Layer::Sglang), params: None, - command: |spec| Ok(sglang_command(spec)), + command: |spec| { + let mut cmd = sglang_command(spec); + apply_ternary(spec, &mut cmd)?; + Ok(cmd) + }, }; -pub const TERNARY: super::Engine = super::Engine { id: "ternary", command: ternary_command, ..SGLANG }; - -const OWNED_FLAGS: &[&str] = &[ - "--host", - "--port", - "--tp-size", - "--tensor-parallel-size", - "--mem-fraction-static", - "--context-length", - "--max-running-requests", - "--max-mamba-cache-size", - "--swa-full-tokens-ratio", - "--api-key", - "--served-model-name", - "--pack", - "--weights", - "--tokenizer", -]; const QUIET_PATHS: &[&str] = &["/health", "/v1/models", "/get_model_info"]; pub fn check_extra_args(args: &[String]) -> Result<(), String> { - // Refuse Goethe owned flags, and tokenizer workers above 1 because that mode cannot take an API key. if multi_tokenizer(args) { return Err("extra SGLang arg --tokenizer-worker-num greater than 1 is not allowed: that mode cannot take an API key, so Goethe will not listen on TCP".into()); } @@ -44,10 +30,8 @@ pub fn check_extra_args(args: &[String]) -> Result<(), String> { if !name.starts_with("--") || name.len() < 3 { continue; } - if let Some(owned) = OWNED_FLAGS.iter().find(|o| o.starts_with(name)) { - return Err(format!( - "extra SGLang arg {arg} is not allowed: Goethe sets {owned} itself (use goethe load options instead)" - )); + if let Some((owned, _)) = RESERVED_FLAGS.iter().find(|(f, _)| *f == name || f.starts_with(name)) { + return Err(format!("extra SGLang arg {arg} is not allowed: Goethe sets {owned} itself (use goethe load options instead)")); } } Ok(()) @@ -61,7 +45,6 @@ pub fn card_extra_args(card: &toml::Value) -> Vec { } fn multi_tokenizer(args: &[String]) -> bool { - // SGLang refuses --api-key with --tokenizer-worker-num > 1, so such engines run keyless on loopback. args.iter().enumerate().any(|(i, a)| { let value = match a.strip_prefix("--tokenizer-worker-num") { Some("") => args.get(i + 1).map(String::as_str), @@ -73,7 +56,6 @@ fn multi_tokenizer(args: &[String]) -> bool { } fn memory_args(spec: &EngineSpec, extras: &[String]) -> Vec { - // The window ratio, state slots and chunk size the budget assumed; a chunk size the user set wins. let Some(m) = crate::memory_spec::installed(spec.model_path, spec.card, spec.load_extra) else { return Vec::new() }; let args = crate::chooser::engine_args(&m, spec.ctx, spec.max_conc); let user_chunk = extras.iter().any(|a| a.starts_with("--chunked-prefill-size")); @@ -83,7 +65,6 @@ fn memory_args(spec: &EngineSpec, extras: &[String]) -> Vec { const SGLANG_BOOT: &str = "import os,runpy,sys\nsys.argv=['sglang.launch_server',*sys.argv[1:],'--api-key',os.environ['GOETHE_ENGINE_API_KEY']]\nrunpy.run_module('sglang.launch_server',run_name='__main__')\n"; fn sglang_command(spec: &EngineSpec) -> Command { - // Goethe flags, then checked card and load extras, in a cleared env; probe paths stay out of the access log. let lib = spec.home.join("lib"); let boot = lib.join("goethe_sglang_boot.py"); if !boot.is_file() { @@ -147,21 +128,28 @@ fn sglang_command(spec: &EngineSpec) -> Command { cmd } -fn ternary_command(spec: &EngineSpec) -> Result { - // SGLang with the card's top-level TERNARY_* keys in its env, once the ternary kernels are installed. +fn apply_ternary(spec: &EngineSpec, cmd: &mut Command) -> Result<(), String> { + if spec.card.get("runtime").and_then(|v| v.as_str()) != Some("ternary") { + return Ok(()); + } crate::runtime::require_ternary_runtime(spec.home)?; - let mut cmd = sglang_command(spec); for (k, v) in spec.card.as_table().into_iter().flatten() { if let (true, Some(s)) = (k.starts_with("TERNARY_"), v.as_str()) { cmd.env(k, expand_home(s, spec.home)); } } - Ok(cmd) + Ok(()) } #[cfg(test)] mod tests { use super::super::test_spec; + use super::check_extra_args; + use std::ffi::OsStr; + + fn arg_vec(cmd: &std::process::Command) -> Vec { + cmd.get_args().map(|a| a.to_string_lossy().into_owned()).collect() + } #[test] fn ternary_gets_its_kernel_env_once_installed() { @@ -173,5 +161,55 @@ mod tests { let cmd = super::super::command(&spec).unwrap(); let want = format!("{}/p", home.path().display()); assert!(cmd.get_envs().any(|(k, v)| k == "TERNARY_PACK_DIR" && v.is_some_and(|v| v.to_string_lossy() == want))); + assert_eq!(super::super::of_card(&card).unwrap().id, "sglang"); + assert_eq!(crate::engine_overhead::card_runtime(&card), "ternary"); + } + + #[test] + fn plain_sglang_does_not_require_ternary_kernels() { + let home = tempfile::tempdir().unwrap(); + let card: toml::Value = toml::from_str("runtime = \"sglang\"\nTERNARY_PACK_DIR = \"/should-not-apply\"").unwrap(); + let cmd = super::super::command(&test_spec(home.path(), &card, &[0])).unwrap(); + assert!(!cmd.get_envs().any(|(k, _)| k == OsStr::new("TERNARY_PACK_DIR"))); + } + + #[test] + fn ternary_argv_matches_plain_sglang_only_env_differs() { + let home = tempfile::tempdir().unwrap(); + std::fs::create_dir_all(crate::runtime::ternary_kernels_dir(home.path())).unwrap(); + let plain: toml::Value = toml::from_str("runtime = \"sglang\"").unwrap(); + let tern: toml::Value = + toml::from_str("runtime = \"ternary\"\nTERNARY_PACK_DIR = \"$GOETHE_HOME/p\"\nTERNARY_MODEL_DIR = \"$GOETHE_HOME/b\"").unwrap(); + let a = super::super::command(&test_spec(home.path(), &plain, &[0])).unwrap(); + let b = super::super::command(&test_spec(home.path(), &tern, &[0])).unwrap(); + assert_eq!(arg_vec(&a), arg_vec(&b), "fold must not change the SGLang argv"); + assert_eq!(a.get_program(), b.get_program()); + let mut tern_envs: Vec<_> = b + .get_envs() + .filter(|(k, _)| k.to_string_lossy().starts_with("TERNARY_")) + .map(|(k, v)| (k.to_string_lossy().into_owned(), v.map(|v| v.to_string_lossy().into_owned()))) + .collect(); + tern_envs.sort(); + assert_eq!( + tern_envs, + [ + ("TERNARY_MODEL_DIR".into(), Some(format!("{}/b", home.path().display()))), + ("TERNARY_PACK_DIR".into(), Some(format!("{}/p", home.path().display()))), + ] + ); + assert!(!a.get_envs().any(|(k, _)| k.to_string_lossy().starts_with("TERNARY_"))); + } + + #[test] + fn reserved_table_rejects_former_owned_and_engine_pack_flags() { + for bad in [ + "--host", "--port", "--tp-size", "--tensor-parallel-size", "--mem-fraction-static", "--context-length", + "--max-running-requests", "--max-mamba-cache-size", "--swa-full-tokens-ratio", "--api-key", "--served-model-name", + "--pack", "--weights", "--tokenizer", "--model-path", "--model", + ] { + let err = check_extra_args(&[bad.to_string(), "1".into()]).unwrap_err(); + assert!(err.contains("not allowed"), "{bad}: {err}"); + } + check_extra_args(&["--chunked-prefill-size".into(), "4096".into(), "--trust-remote-code".into()]).unwrap(); } } diff --git a/engine/crates/core/src/hf.rs b/engine/crates/core/src/hf.rs index f07044b0..0299e783 100644 --- a/engine/crates/core/src/hf.rs +++ b/engine/crates/core/src/hf.rs @@ -1,7 +1,6 @@ // Hugging Face download and verify for goethe install; goethe never logs in or sends credentials. use serde::{Deserialize, Serialize}; -use sha2::{Digest, Sha256}; use std::collections::{BTreeSet, HashMap}; use std::fs; use std::io::{Read, Write}; @@ -804,18 +803,10 @@ fn verify_one_file(path: &Path, expect_sha: &str) -> Result Result { - let mut f = fs::File::open(path).map_err(|e| e.to_string())?; - let mut h = Sha256::new(); - let mut buf = vec![0u8; 1024 * 1024]; - loop { - let n = f.read(&mut buf).map_err(|e| e.to_string())?; - if n == 0 { - break; - } - h.update(&buf[..n]); - HASHED.fetch_add(n as u64, Ordering::Relaxed); - } - Ok(format!("{:x}", h.finalize())) + let meta = fs::metadata(path).map_err(|e| e.to_string())?; + let digest = crate::update::sha256_file(path)?; + HASHED.fetch_add(meta.len(), Ordering::Relaxed); + Ok(digest) } fn file_identity(path: &Path) -> Option<(u64, i64)> { diff --git a/engine/crates/core/src/packs.rs b/engine/crates/core/src/packs.rs index 89bc8e25..82977a01 100644 --- a/engine/crates/core/src/packs.rs +++ b/engine/crates/core/src/packs.rs @@ -551,9 +551,7 @@ pub fn drafter(e: &Entry) -> Option { } fn sha256_file(p: &Path) -> Option { - let mut h = Sha256::new(); - std::io::copy(&mut std::fs::File::open(p).ok()?, &mut h).ok()?; - Some(format!("{:x}", h.finalize())) + crate::update::sha256_file(p).ok() } pub fn safe_name(f: &str) -> bool { diff --git a/engine/crates/core/src/sglang_infer.rs b/engine/crates/core/src/sglang_infer.rs index 80da76d8..3a72c46a 100644 --- a/engine/crates/core/src/sglang_infer.rs +++ b/engine/crates/core/src/sglang_infer.rs @@ -59,8 +59,13 @@ pub const RESERVED_FLAGS: &[(&str, &str)] = &[ ("--context-length", "use --ctx"), ("--max-running-requests", "use --max-conc"), ("--mem-fraction-static", "goethed derives it from the VRAM budget"), + ("--max-mamba-cache-size", "goethe sizes the state pool from the budget"), + ("--swa-full-tokens-ratio", "goethe sizes the window pool from the budget"), ("--served-model-name", "goethe serves the model under its id"), ("--api-key", "goethed sets a per-engine key"), + ("--pack", "goethe-engine sets the pack path"), + ("--weights", "goethe-engine sets the weight paths"), + ("--tokenizer", "goethe-engine sets the tokenizer dir"), ]; #[derive(Debug, Clone, PartialEq, Eq)] diff --git a/engine/crates/core/src/update.rs b/engine/crates/core/src/update.rs index b51f6c4b..df2f471c 100644 --- a/engine/crates/core/src/update.rs +++ b/engine/crates/core/src/update.rs @@ -695,4 +695,17 @@ mod tests { assert_eq!(compare_versions("v0.1.1+abc", "0.1.1"), Ordering::Equal); assert_eq!(compare_versions("0.0.9", "0.1.0"), Ordering::Less); } + + #[test] + fn one_sha256_file_matches_ninfer_wrapper() { + let t = tempfile::tempdir().unwrap(); + let p = t.path().join("blob"); + fs::write(&p, b"goethe-sha256-equiv").unwrap(); + let a = sha256_file(&p).unwrap(); + let b = crate::engines::ninfer::sha256_file(&p).unwrap(); + assert_eq!(a, b); + assert_eq!(a.len(), 64); + assert!(a.chars().all(|c| c.is_ascii_hexdigit())); + assert!(sha256_file(&t.path().join("missing")).is_err()); + } } From 1847edae03d58956242707aa957fbc2561fcb301 Mon Sep 17 00:00:00 2001 From: Petya <64523372+peti12352@users.noreply.github.com> Date: Wed, 18 Nov 2026 12:45:31 -0800 Subject: [PATCH 03/12] Docs: share needs a client allowlist, not the world. Examples and the --allow row matched the old open-to-anyone behavior; they now match fail-closed share. --- docs/cli.md | 15 ++++++++------- docs/user-guide.md | 12 ++++++------ 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/docs/cli.md b/docs/cli.md index 2e001750..bd4d4a79 100644 --- a/docs/cli.md +++ b/docs/cli.md @@ -318,11 +318,12 @@ The DNS record that serves the API under your own domain name, with this machine Opens the API on a public address for a limited time, for API keys you choose, so you can give someone outside your network a URL and a key. The normal API address, local or VPN, stays as it is. ``` -goethe api share 5h --key my-app # share my-app for 5 hours -goethe api share 1d --key ci --allow 203.0.113.7 # also share ci, for a day, from one address -goethe api share # status: URL, each key with its time left and addresses -goethe api share stop --key ci # stop sharing one key -goethe api share stop # close the public gateway +goethe api share 5h --key my-app --allow 203.0.113.7/32 # share my-app for 5 hours from their public IP +goethe api allow add 203.0.113.7/32 # or remember their IP, then: +goethe api share 5h --key my-app # uses the allowlist (still not the world) +goethe api share # status: URL, each key with its time left and addresses +goethe api share stop --key ci # stop sharing one key +goethe api share stop # close the public gateway ``` Every shared key uses the same public gateway, each until its own time and from its own addresses. The gateway stays open until the last key's time ends. A key whose time has ended is refused while the others keep working, and the addresses only it allowed are dropped from the gateway. Sharing a key again starts its time over (`5h` means 5 hours from now) and replaces its addresses; the other keys are not touched. Without `--key`, the keys of the last opening are shared again. Opening prints the URL, each key with the models it may use, the certificate to send along, and a `curl` command to try it. The keys stay the same, so a recipient can keep using the key you sent. Connections in progress are not interrupted. The menu's Public address page does the same with a form: the key, how long, and optional addresses. `goethe status` shows the gateway while it is open, and a node linked to the platform shows the public URL and when it closes on its page. @@ -331,7 +332,7 @@ Every shared key uses the same public gateway, each until its own time and from |---|---| | `` | How long to share the keys: minutes, hours or days, such as `30m`, `5h` or `1d`, at most `7d`. `stop` stops sharing; nothing shows the status | | `--key ` | API keys to share, each until the duration; repeatable or comma-separated. With `stop`, the keys to stop sharing | -| `--allow ` | Only these client addresses or ranges may use the keys given, such as `203.0.113.7`; repeatable. Without it any address may, with the key | +| `--allow ` | Who may connect: their phone or laptop's public IP (or range), such as `203.0.113.7/32`; repeatable. This machine's IP is only the URL. Without `--allow`, Goethe uses addresses kept from the last share of those keys, or `goethe api allow`; with none of those it refuses to open | | `--port ` | The public port (default `8444`, or the last one used) | The recipient verifies the gateway with the certificate goethe prints, `GOETHE_HOME/nginx/certs/public.crt`. It holds no secret: `curl --cacert public.crt https://
:8444/v1/models -H "Authorization: Bearer "`. Most OpenAI-compatible clients take it through `SSL_CERT_FILE` or their CA-bundle setting. If nobody can connect, forward the port to this machine on your router or allow it in your cloud firewall; goethe does not open ports on routers. The public listener uses IPv4. @@ -347,7 +348,7 @@ The recipient verifies the gateway with the certificate goethe prints, `GOETHE_H - **API routes only:** health, readiness, admin and metrics endpoints are not served publicly. - **HTTPS only:** TLS 1.2 or 1.3, with its own certificate for the public listener. Plain HTTP connections are dropped. - **Stricter limits than the normal address:** 10 requests per second per client address (bursts of 20) and 16 connections per address, plus the same body size limit and header and body timeouts. -- **Optional address limit per key:** a key shared with `--allow` works only from those addresses, checked on every request; nginx also admits only the addresses of the shared keys when every key has a limit. +- **Client address required:** every shared key has an allowlist (`--allow`, a remembered grant, or `goethe api allow`). Nginx admits only that union and always ends with `deny all`. Goethe also checks the client on every public request. - **Checks before opening:** nothing changes unless every check passes: the gateway and goethed are running, the keys are valid, and the port is free and is not the normal gateway's port. If nginx does not accept the new listener, the previous state is restored. ## Learning and traces diff --git a/docs/user-guide.md b/docs/user-guide.md index ad75da8d..54791898 100644 --- a/docs/user-guide.md +++ b/docs/user-guide.md @@ -214,7 +214,7 @@ Models that were loaded when Goethe stopped come back when it starts again, incl | `goethe trace` | Record requests and replies as training traces (`on`, `off`, `--key`); see [traces.md](traces.md) | | `goethe learn` | Let a session keep what compaction would drop (`on`, `off`, `--model`); see [learn.md](learn.md) | | `goethe api domain` | DNS record for your own hostname (`check `) | -| `goethe api share 5h --key ` | Open the API on a public address for a while for chosen keys (`stop` closes it) | +| `goethe api share 5h --key --allow /32` | Open the API on a public address for a while for chosen keys from their IP (`stop` closes it) | ### GPUs and system @@ -337,13 +337,13 @@ goethe api allow remove 192.168.1.0/24 To give someone outside your network access for a limited time, without changing how the API is normally reached: ```bash -goethe api share 5h --key my-app # prints the URL, the key and the certificate to send -goethe api share 1d --key ci # another key on the same address, for a day -goethe api share stop --key ci # stop sharing one key -goethe api share stop # close early +goethe api share 5h --key my-app --allow 203.0.113.7/32 # their public IP, not this machine's +goethe api share 1d --key ci --allow 203.0.113.7/32 # another key on the same address, for a day +goethe api share stop --key ci # stop sharing one key +goethe api share stop # close early ``` -The public address exists only while some key is shared, accepts only the keys you chose (never admin keys), each until its own time, and closes by itself when the last one ends. Keys stay the same every time. The menu's Public address page does the same with a form. Details and the full list of security precautions: [`goethe api share`](cli.md#goethe-api-share-duration). +The public address exists only while some key is shared, accepts only the keys you chose (never admin keys), each until its own time and from the client addresses you named (`--allow`, or `goethe api allow` first), and closes by itself when the last one ends. Keys stay the same every time. The menu's Public address page does the same with a form. Details and the full list of security precautions: [`goethe api share`](cli.md#goethe-api-share-duration). ### Address, aliases and your own domain From db94788924dae758d75f3d7a0447f54860481e6c Mon Sep 17 00:00:00 2001 From: Petya <64523372+peti12352@users.noreply.github.com> Date: Wed, 18 Nov 2026 12:47:30 -0800 Subject: [PATCH 04/12] Share help names the client IP the same way fail-closed share does. Top-level examples and the --allow clap line no longer teach opening without who may connect. --- engine/crates/goethe/src/main.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/engine/crates/goethe/src/main.rs b/engine/crates/goethe/src/main.rs index c6b45528..8b30d106 100644 --- a/engine/crates/goethe/src/main.rs +++ b/engine/crates/goethe/src/main.rs @@ -480,7 +480,7 @@ struct ShareArgs { duration: Option, #[arg(add = clap_complete::engine::ArgValueCandidates::new(complete::key_names), long, value_name = "NAME_OR_ID", num_args = 1.., value_delimiter = ',', help = "API keys to share (not admin keys), each until DURATION; with stop, the keys to stop sharing.")] key: Vec, - #[arg(long, value_name = "CIDR", num_args = 1.., value_delimiter = ',', help = "Only these client addresses or ranges may use the keys given, such as 203.0.113.7.")] + #[arg(long, value_name = "CIDR", num_args = 1.., value_delimiter = ',', help = "Their public IP or range (phone/laptop), such as 203.0.113.7/32 — not this machine. Required unless api allow or a remembered grant supplies addresses.")] allow: Vec, #[arg(long, help = "The public port (default 8444, or the last one used).")] port: Option, @@ -677,7 +677,7 @@ const HELP_SECTIONS: &[(&str, &[(&str, &str)])] = &[ ("goethe api expose vpn --interface wg0", "serve a VPN or private network (also local or public)"), ("goethe api allow add 203.0.113.7/32", "let a client address in (remove takes it out)"), ("goethe api domain check DOMAIN", "check that a domain reaches the API"), - ("goethe api share 5h --key my-app", "open a public address for a while (share stop closes it)"), + ("goethe api share 5h --key my-app --allow /32", "open a public address for a while (share stop closes it)"), ]), ("Learning and traces", &[ ("goethe learn on", "sessions keep what compaction drops (--model M for one model)"), From 7e949820da2b1da533183ef46ad768003d07e6bc Mon Sep 17 00:00:00 2001 From: Petya <64523372+peti12352@users.noreply.github.com> Date: Wed, 18 Nov 2026 12:50:39 -0800 Subject: [PATCH 05/12] Public share: no /0, no this-machine IP, no VPN allowlist. Reject everyone-CIDRs and the URL host as --allow; do not inherit goethe api allow for the public window; leaf cert is CA:FALSE; menu prints who may connect. --- docs/cli.md | 7 ++- engine/crates/core/src/menu.rs | 14 ++++- engine/crates/core/src/public_share.rs | 72 ++++++++++++++++++-------- engine/crates/goethe/src/main.rs | 6 +-- 4 files changed, 68 insertions(+), 31 deletions(-) diff --git a/docs/cli.md b/docs/cli.md index bd4d4a79..b7a3ae3e 100644 --- a/docs/cli.md +++ b/docs/cli.md @@ -319,8 +319,7 @@ Opens the API on a public address for a limited time, for API keys you choose, s ``` goethe api share 5h --key my-app --allow 203.0.113.7/32 # share my-app for 5 hours from their public IP -goethe api allow add 203.0.113.7/32 # or remember their IP, then: -goethe api share 5h --key my-app # uses the allowlist (still not the world) +goethe api share 5h --key my-app # reopen: keeps addresses from the last share of those keys goethe api share # status: URL, each key with its time left and addresses goethe api share stop --key ci # stop sharing one key goethe api share stop # close the public gateway @@ -332,7 +331,7 @@ Every shared key uses the same public gateway, each until its own time and from |---|---| | `` | How long to share the keys: minutes, hours or days, such as `30m`, `5h` or `1d`, at most `7d`. `stop` stops sharing; nothing shows the status | | `--key ` | API keys to share, each until the duration; repeatable or comma-separated. With `stop`, the keys to stop sharing | -| `--allow ` | Who may connect: their phone or laptop's public IP (or range), such as `203.0.113.7/32`; repeatable. This machine's IP is only the URL. Without `--allow`, Goethe uses addresses kept from the last share of those keys, or `goethe api allow`; with none of those it refuses to open | +| `--allow ` | Who may connect: their phone or laptop's public IP (or range), such as `203.0.113.7/32`; repeatable. This machine's IP is only the URL. Without `--allow`, Goethe reuses addresses from the last share of those keys; with none it refuses to open. Not the VPN/API allowlist (`goethe api allow`) | | `--port ` | The public port (default `8444`, or the last one used) | The recipient verifies the gateway with the certificate goethe prints, `GOETHE_HOME/nginx/certs/public.crt`. It holds no secret: `curl --cacert public.crt https://
:8444/v1/models -H "Authorization: Bearer "`. Most OpenAI-compatible clients take it through `SSL_CERT_FILE` or their CA-bundle setting. If nobody can connect, forward the port to this machine on your router or allow it in your cloud firewall; goethe does not open ports on routers. The public listener uses IPv4. @@ -348,7 +347,7 @@ The recipient verifies the gateway with the certificate goethe prints, `GOETHE_H - **API routes only:** health, readiness, admin and metrics endpoints are not served publicly. - **HTTPS only:** TLS 1.2 or 1.3, with its own certificate for the public listener. Plain HTTP connections are dropped. - **Stricter limits than the normal address:** 10 requests per second per client address (bursts of 20) and 16 connections per address, plus the same body size limit and header and body timeouts. -- **Client address required:** every shared key has an allowlist (`--allow`, a remembered grant, or `goethe api allow`). Nginx admits only that union and always ends with `deny all`. Goethe also checks the client on every public request. +- **Client address required:** every shared key has an allowlist (`--allow`, or addresses kept from the last share of those keys). Nginx admits only that union and always ends with `deny all`. Every address (`0.0.0.0/0`) and this machine's own public IP are refused. Goethe also checks the client on every public request. - **Checks before opening:** nothing changes unless every check passes: the gateway and goethed are running, the keys are valid, and the port is free and is not the normal gateway's port. If nginx does not accept the new listener, the previous state is restored. ## Learning and traces diff --git a/engine/crates/core/src/menu.rs b/engine/crates/core/src/menu.rs index dfaf5b3a..c1d244dd 100644 --- a/engine/crates/core/src/menu.rs +++ b/engine/crates/core/src/menu.rs @@ -485,7 +485,19 @@ impl SharePage { self.key.clear(); self.allow.clear(); let warn = o.warnings.first().map(|w| format!(" Note: {w}")).unwrap_or_default(); - self.say(format!("Shared {name} until {}; send {} with the key.{warn}", share::local_time(share::now() + secs), o.cert.display()), false); + let clients = if o.share.allow.is_empty() { + String::new() + } else { + format!(" Only: {}.", o.share.allow.join(", ")) + }; + self.say( + format!( + "Shared {name} until {}; send {} with the key.{clients}{warn}", + share::local_time(share::now() + secs), + o.cert.display() + ), + false, + ); } Err(e) => self.say(e, true), } diff --git a/engine/crates/core/src/public_share.rs b/engine/crates/core/src/public_share.rs index 42f2bb15..6a5217f9 100644 --- a/engine/crates/core/src/public_share.rs +++ b/engine/crates/core/src/public_share.rs @@ -251,21 +251,15 @@ fn port_free(port: u16) -> bool { TcpListener::bind(SocketAddr::from(([0, 0, 0, 0], port))).is_ok() } -fn allowlist_at(home: &Path) -> Vec { - let Ok(con) = db::open(home) else { return Vec::new() }; - let Ok(mut stmt) = con.prepare("SELECT cidr FROM ip_allowlist ORDER BY cidr") else { return Vec::new() }; - stmt.query_map([], |r| r.get(0)).ok().into_iter().flatten().filter_map(Result::ok).collect() -} - -fn share_allow(cli: &[String], reuse_keys: bool, kept: &[String], gateway: &[String]) -> Vec { - // --allow wins; reopening remembered keys keeps their addresses; else the ordinary API allowlist. +fn share_allow(cli: &[String], reuse_keys: bool, kept: &[String]) -> Vec { + // --allow wins; reopening the same keys keeps the addresses from their last share. Never the VPN/API allowlist. if !cli.is_empty() { return cli.to_vec(); } if reuse_keys && !kept.is_empty() { return kept.to_vec(); } - gateway.to_vec() + Vec::new() } fn need_client_allow(home: &Path) -> String { @@ -275,10 +269,28 @@ fn need_client_allow(home: &Path) -> String { .map(|ip| format!(" this machine's public address is {ip} (that becomes the URL, not --allow);")) .unwrap_or_default(); format!( - "name who may connect with --allow /32 (their phone or laptop's public IP, not this machine's).{here} ask them, or add them first with goethe api allow add /32" + "name who may connect with --allow /32 (their phone or laptop's public IP, not this machine's).{here} ask them" ) } +fn reject_bad_share_cidrs(home: &Path, allow: &[String]) -> Result<(), String> { + let machine = crate::platform::lookup_public_ip(home).ok(); + for c in allow { + if c.ends_with("/0") { + return Err("the public gateway will not open to every address; name the client's public IP with --allow /32".into()); + } + if let Some(ip) = machine { + let host = format!("{ip}/{}", if ip.is_ipv4() { 32 } else { 128 }); + if *c == host { + return Err(format!( + "{c} is this machine's public address (the URL), not who may connect; use their phone or laptop's public IP" + )); + } + } + } + Ok(()) +} + fn mux_public_listening(home: &Path) -> bool { nginx::persisted_mux_port(home) .is_ok_and(|p| TcpStream::connect_timeout(&public_mux_addr(p), Duration::from_millis(500)).is_ok()) @@ -323,7 +335,6 @@ pub fn open(home: &Path, a: OpenArgs) -> Result { }; let keys = resolve_keys(home, &wanted, until, &mut warnings)?; let cli_allow = a.allow.iter().map(|c| security::canonical_cidr(c)).collect::, _>>()?; - let gateway_allow = allowlist_at(home); let port = a.port.or(previous.as_ref().map(|p| p.port)).unwrap_or(DEFAULT_PORT); let mut grants: Vec = previous .as_ref() @@ -332,10 +343,11 @@ pub fn open(home: &Path, a: OpenArgs) -> Result { .unwrap_or_default(); for k in &keys { let kept = previous.as_ref().and_then(|p| p.grant(&k.id)).map(|g| g.allow).unwrap_or_default(); - let allow = share_allow(&cli_allow, a.keys.is_empty(), &kept, &gateway_allow); + let allow = share_allow(&cli_allow, a.keys.is_empty(), &kept); if allow.is_empty() { return Err(need_client_allow(home)); } + reject_bad_share_cidrs(home, &allow)?; grants.retain(|g| g.key != k.id); grants.push(Grant { key: k.id.clone(), until, allow }); } @@ -491,16 +503,17 @@ fn ensure_cert(home: &Path, ip: Option) -> Result<(), String> { names.insert(0, format!("IP:{ip}")); } let san = format!("subjectAltName={}", names.join(",")); + let stamp = format!("{san}\nleaf"); let san_file = dir.join("public_sans.txt"); - let current = fs::read_to_string(&san_file).map(|s| s.trim() == san).unwrap_or(false); + let current = fs::read_to_string(&san_file).map(|s| s.trim() == stamp).unwrap_or(false); if current && crt.is_file() && key.is_file() { return Ok(()); } - nginx::self_signed(&key, &crt, true, 30, "goethe-public", &[&san, "basicConstraints=critical,CA:TRUE"]) + nginx::self_signed(&key, &crt, true, 30, "goethe-public", &[&san, "basicConstraints=critical,CA:FALSE"]) .map_err(|_| "openssl could not create the public gateway certificate".to_string())?; use std::os::unix::fs::PermissionsExt; fs::set_permissions(&crt, fs::Permissions::from_mode(0o644)).map_err(|e| e.to_string())?; - nginx::write_private(&san_file, san.as_bytes()) + nginx::write_private(&san_file, stamp.as_bytes()) } fn fingerprint(crt: &Path) -> Option { @@ -684,18 +697,33 @@ mod tests { } #[test] - fn share_allow_prefers_cli_then_kept_then_gateway() { - assert_eq!(share_allow(&["203.0.113.9/32".into()], false, &["198.51.100.1/32".into()], &["192.0.2.1/32".into()]), vec!["203.0.113.9/32".to_string()]); - assert_eq!(share_allow(&[], true, &["198.51.100.1/32".into()], &["192.0.2.1/32".into()]), vec!["198.51.100.1/32".to_string()]); - assert_eq!(share_allow(&[], false, &[], &["192.0.2.1/32".into()]), vec!["192.0.2.1/32".to_string()]); - assert!(share_allow(&[], false, &[], &[]).is_empty()); + fn share_allow_prefers_cli_then_kept_never_gateway() { + assert_eq!(share_allow(&["203.0.113.9/32".into()], false, &["198.51.100.1/32".into()]), vec!["203.0.113.9/32".to_string()]); + assert_eq!(share_allow(&[], true, &["198.51.100.1/32".into()]), vec!["198.51.100.1/32".to_string()]); + assert!(share_allow(&[], false, &[]).is_empty(), "VPN/API allowlist must not open public share"); + assert!(share_allow(&[], true, &[]).is_empty()); } #[test] fn need_client_allow_names_the_client_not_this_machine() { let dir = tempfile::tempdir().unwrap(); let msg = need_client_allow(dir.path()); - assert!(msg.contains("their phone or laptop") && msg.contains("--allow") && msg.contains("goethe api allow add"), "{msg}"); + assert!(msg.contains("their phone or laptop") && msg.contains("--allow"), "{msg}"); + assert!(!msg.contains("goethe api allow"), "{msg}"); + } + + #[test] + fn share_refuses_everyone_and_this_machines_public_ip() { + let dir = tempfile::tempdir().unwrap(); + let home = dir.path(); + assert!(reject_bad_share_cidrs(home, &["0.0.0.0/0".into()]).unwrap_err().contains("every address")); + assert!(reject_bad_share_cidrs(home, &["::/0".into()]).unwrap_err().contains("every address")); + let ip: IpAddr = "203.0.113.50".parse().unwrap(); + std::env::set_var("GOETHE_PUBLIC_IP", ip.to_string()); + let err = reject_bad_share_cidrs(home, &[format!("{ip}/32")]).unwrap_err(); + std::env::remove_var("GOETHE_PUBLIC_IP"); + assert!(err.contains("this machine's public address"), "{err}"); + assert!(reject_bad_share_cidrs(home, &["198.51.100.7/32".into()]).is_ok()); } #[test] @@ -734,6 +762,6 @@ mod tests { ensure_cert(dir.path(), Some("203.0.113.9".parse().unwrap())).unwrap(); let out = Command::new("openssl").args(["x509", "-noout", "-text", "-in"]).arg(cert_path(dir.path())).output().unwrap(); let text = String::from_utf8_lossy(&out.stdout); - assert!(text.contains("203.0.113.9") && text.contains("CA:TRUE"), "{text}"); + assert!(text.contains("203.0.113.9") && text.contains("CA:FALSE"), "{text}"); } } diff --git a/engine/crates/goethe/src/main.rs b/engine/crates/goethe/src/main.rs index 8b30d106..649e72bb 100644 --- a/engine/crates/goethe/src/main.rs +++ b/engine/crates/goethe/src/main.rs @@ -86,12 +86,10 @@ goethe api expose alone shows where the API listens and who may connect."; const SHARE_HELP: &str = "Examples: \t→ goethe api share 5h --key my-app --allow /32 -\t→ goethe api allow add /32 -\t goethe api share 5h --key my-app \t→ goethe api share (status) \t→ goethe api share stop ---allow is who may connect (their public IP: ask them, or https://ifconfig.me). This machine's IP is only the URL goethe prints. Or add them with goethe api allow first, then share without --allow. Closes when the last key ends."; +--allow is who may connect (their public IP: ask them, or https://ifconfig.me on their device). This machine's IP is only the URL goethe prints. Reopening the same keys keeps their last addresses. Closes when the last key ends."; #[derive(Parser)] #[command( @@ -480,7 +478,7 @@ struct ShareArgs { duration: Option, #[arg(add = clap_complete::engine::ArgValueCandidates::new(complete::key_names), long, value_name = "NAME_OR_ID", num_args = 1.., value_delimiter = ',', help = "API keys to share (not admin keys), each until DURATION; with stop, the keys to stop sharing.")] key: Vec, - #[arg(long, value_name = "CIDR", num_args = 1.., value_delimiter = ',', help = "Their public IP or range (phone/laptop), such as 203.0.113.7/32 — not this machine. Required unless api allow or a remembered grant supplies addresses.")] + #[arg(long, value_name = "CIDR", num_args = 1.., value_delimiter = ',', help = "Their public IP or range (phone/laptop), such as 203.0.113.7/32 — not this machine. Required unless reopening keys that already have addresses from last share.")] allow: Vec, #[arg(long, help = "The public port (default 8444, or the last one used).")] port: Option, From 0fc0711dc07955f6d0a684b7d8449f6ebf3bf425 Mon Sep 17 00:00:00 2001 From: Petya <64523372+peti12352@users.noreply.github.com> Date: Wed, 18 Nov 2026 12:51:06 -0800 Subject: [PATCH 06/12] User guide: share addresses come from --allow, not api allow. --- docs/user-guide.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/user-guide.md b/docs/user-guide.md index 54791898..26695918 100644 --- a/docs/user-guide.md +++ b/docs/user-guide.md @@ -343,7 +343,7 @@ goethe api share stop --key ci # stop sharing one key goethe api share stop # close early ``` -The public address exists only while some key is shared, accepts only the keys you chose (never admin keys), each until its own time and from the client addresses you named (`--allow`, or `goethe api allow` first), and closes by itself when the last one ends. Keys stay the same every time. The menu's Public address page does the same with a form. Details and the full list of security precautions: [`goethe api share`](cli.md#goethe-api-share-duration). +The public address exists only while some key is shared, accepts only the keys you chose (never admin keys), each until its own time and from the client addresses you named with `--allow` (or kept from the last share of those keys), and closes by itself when the last one ends. Keys stay the same every time. The menu's Public address page does the same with a form. Details and the full list of security precautions: [`goethe api share`](cli.md#goethe-api-share-duration). ### Address, aliases and your own domain From 2bb105c5125a0b9116b0bddc259f956990c1107b Mon Sep 17 00:00:00 2001 From: Petya <64523372+peti12352@users.noreply.github.com> Date: Wed, 18 Nov 2026 12:56:43 -0800 Subject: [PATCH 07/12] Share: --dangerously-allow-all-inbound for a deliberate world open. 0.0.0.0/0 still needs that flag; rate limits stay on by default. Docs restore the URL/key/cert example comment. --- docs/cli.md | 16 +++--- docs/user-guide.md | 2 +- engine/crates/core/src/menu.rs | 11 +++- engine/crates/core/src/public_share.rs | 78 ++++++++++++++++++++++---- engine/crates/goethe/src/main.rs | 55 +++++++++++++++--- 5 files changed, 135 insertions(+), 27 deletions(-) diff --git a/docs/cli.md b/docs/cli.md index b7a3ae3e..17177772 100644 --- a/docs/cli.md +++ b/docs/cli.md @@ -318,11 +318,12 @@ The DNS record that serves the API under your own domain name, with this machine Opens the API on a public address for a limited time, for API keys you choose, so you can give someone outside your network a URL and a key. The normal API address, local or VPN, stays as it is. ``` -goethe api share 5h --key my-app --allow 203.0.113.7/32 # share my-app for 5 hours from their public IP -goethe api share 5h --key my-app # reopen: keeps addresses from the last share of those keys -goethe api share # status: URL, each key with its time left and addresses -goethe api share stop --key ci # stop sharing one key -goethe api share stop # close the public gateway +goethe api share 5h --key my-app --allow 203.0.113.7/32 # prints the URL, the key and the certificate to send +goethe api share 5h --key my-app --dangerously-allow-all-inbound # every address (rate limits still apply) +goethe api share 5h --key my-app # reopen: keeps addresses from the last share of those keys +goethe api share # status: URL, each key with its time left and addresses +goethe api share stop --key ci # stop sharing one key +goethe api share stop # close the public gateway ``` Every shared key uses the same public gateway, each until its own time and from its own addresses. The gateway stays open until the last key's time ends. A key whose time has ended is refused while the others keep working, and the addresses only it allowed are dropped from the gateway. Sharing a key again starts its time over (`5h` means 5 hours from now) and replaces its addresses; the other keys are not touched. Without `--key`, the keys of the last opening are shared again. Opening prints the URL, each key with the models it may use, the certificate to send along, and a `curl` command to try it. The keys stay the same, so a recipient can keep using the key you sent. Connections in progress are not interrupted. The menu's Public address page does the same with a form: the key, how long, and optional addresses. `goethe status` shows the gateway while it is open, and a node linked to the platform shows the public URL and when it closes on its page. @@ -331,7 +332,8 @@ Every shared key uses the same public gateway, each until its own time and from |---|---| | `` | How long to share the keys: minutes, hours or days, such as `30m`, `5h` or `1d`, at most `7d`. `stop` stops sharing; nothing shows the status | | `--key ` | API keys to share, each until the duration; repeatable or comma-separated. With `stop`, the keys to stop sharing | -| `--allow ` | Who may connect: their phone or laptop's public IP (or range), such as `203.0.113.7/32`; repeatable. This machine's IP is only the URL. Without `--allow`, Goethe reuses addresses from the last share of those keys; with none it refuses to open. Not the VPN/API allowlist (`goethe api allow`) | +| `--allow ` | Only these client addresses or ranges may use the keys given, such as `203.0.113.7`; repeatable. Without it, addresses from the last share of those keys are kept; with none, Goethe refuses to open | +| `--dangerously-allow-all-inbound` | Allow every address (`0.0.0.0/0`). Rate limits still apply (10 requests/s per client, burst 20, 16 connections). Not with `--allow` | | `--port ` | The public port (default `8444`, or the last one used) | The recipient verifies the gateway with the certificate goethe prints, `GOETHE_HOME/nginx/certs/public.crt`. It holds no secret: `curl --cacert public.crt https://
:8444/v1/models -H "Authorization: Bearer "`. Most OpenAI-compatible clients take it through `SSL_CERT_FILE` or their CA-bundle setting. If nobody can connect, forward the port to this machine on your router or allow it in your cloud firewall; goethe does not open ports on routers. The public listener uses IPv4. @@ -347,7 +349,7 @@ The recipient verifies the gateway with the certificate goethe prints, `GOETHE_H - **API routes only:** health, readiness, admin and metrics endpoints are not served publicly. - **HTTPS only:** TLS 1.2 or 1.3, with its own certificate for the public listener. Plain HTTP connections are dropped. - **Stricter limits than the normal address:** 10 requests per second per client address (bursts of 20) and 16 connections per address, plus the same body size limit and header and body timeouts. -- **Client address required:** every shared key has an allowlist (`--allow`, or addresses kept from the last share of those keys). Nginx admits only that union and always ends with `deny all`. Every address (`0.0.0.0/0`) and this machine's own public IP are refused. Goethe also checks the client on every public request. +- **Client address required:** every shared key has an allowlist (`--allow`, or addresses kept from the last share of those keys). Nginx admits only that union and always ends with `deny all`. Every address (`0.0.0.0/0`) needs `--dangerously-allow-all-inbound`; this machine's own public IP is refused as `--allow`. Goethe also checks the client on every public request. - **Checks before opening:** nothing changes unless every check passes: the gateway and goethed are running, the keys are valid, and the port is free and is not the normal gateway's port. If nginx does not accept the new listener, the previous state is restored. ## Learning and traces diff --git a/docs/user-guide.md b/docs/user-guide.md index 26695918..2efe0194 100644 --- a/docs/user-guide.md +++ b/docs/user-guide.md @@ -337,7 +337,7 @@ goethe api allow remove 192.168.1.0/24 To give someone outside your network access for a limited time, without changing how the API is normally reached: ```bash -goethe api share 5h --key my-app --allow 203.0.113.7/32 # their public IP, not this machine's +goethe api share 5h --key my-app --allow 203.0.113.7/32 # prints the URL, the key and the certificate to send goethe api share 1d --key ci --allow 203.0.113.7/32 # another key on the same address, for a day goethe api share stop --key ci # stop sharing one key goethe api share stop # close early diff --git a/engine/crates/core/src/menu.rs b/engine/crates/core/src/menu.rs index c1d244dd..6d9565e0 100644 --- a/engine/crates/core/src/menu.rs +++ b/engine/crates/core/src/menu.rs @@ -479,7 +479,16 @@ impl SharePage { }; let allow: Vec = self.allow.split([',', ' ']).map(str::trim).filter(|c| !c.is_empty()).map(str::to_string).collect(); let home = goethe_home(); - match share::open(&home, share::OpenArgs { secs, keys: std::slice::from_ref(&name), allow: &allow, port: None }) { + match share::open( + &home, + share::OpenArgs { + secs, + keys: std::slice::from_ref(&name), + allow: &allow, + port: None, + dangerously_allow_all_inbound: false, + }, + ) { Ok(o) => { self.reload(); self.key.clear(); diff --git a/engine/crates/core/src/public_share.rs b/engine/crates/core/src/public_share.rs index 6a5217f9..630500ef 100644 --- a/engine/crates/core/src/public_share.rs +++ b/engine/crates/core/src/public_share.rs @@ -269,7 +269,7 @@ fn need_client_allow(home: &Path) -> String { .map(|ip| format!(" this machine's public address is {ip} (that becomes the URL, not --allow);")) .unwrap_or_default(); format!( - "name who may connect with --allow /32 (their phone or laptop's public IP, not this machine's).{here} ask them" + "name who may connect with --allow /32 (their phone or laptop's public IP, not this machine's).{here} ask them; to open to every address use --dangerously-allow-all-inbound" ) } @@ -277,7 +277,10 @@ fn reject_bad_share_cidrs(home: &Path, allow: &[String]) -> Result<(), String> { let machine = crate::platform::lookup_public_ip(home).ok(); for c in allow { if c.ends_with("/0") { - return Err("the public gateway will not open to every address; name the client's public IP with --allow /32".into()); + return Err( + "the public gateway will not open to every address unless you pass --dangerously-allow-all-inbound; otherwise name the client's public IP with --allow /32" + .into(), + ); } if let Some(ip) = machine { let host = format!("{ip}/{}", if ip.is_ipv4() { 32 } else { 128 }); @@ -291,6 +294,28 @@ fn reject_bad_share_cidrs(home: &Path, allow: &[String]) -> Result<(), String> { Ok(()) } +/// Addresses for one share open: CLI --allow, remembered grant, or --dangerously-allow-all-inbound. +fn resolve_share_cidrs( + home: &Path, + cli_allow: &[String], + reuse_keys: bool, + kept: &[String], + dangerously_allow_all_inbound: bool, +) -> Result, String> { + if dangerously_allow_all_inbound { + if !cli_allow.is_empty() { + return Err("--dangerously-allow-all-inbound cannot be combined with --allow".into()); + } + return Ok(vec!["0.0.0.0/0".into()]); + } + let allow = share_allow(cli_allow, reuse_keys, kept); + if allow.is_empty() { + return Err(need_client_allow(home)); + } + reject_bad_share_cidrs(home, &allow)?; + Ok(allow) +} + fn mux_public_listening(home: &Path) -> bool { nginx::persisted_mux_port(home) .is_ok_and(|p| TcpStream::connect_timeout(&public_mux_addr(p), Duration::from_millis(500)).is_ok()) @@ -312,6 +337,7 @@ pub struct OpenArgs<'a> { pub keys: &'a [String], pub allow: &'a [String], pub port: Option, + pub dangerously_allow_all_inbound: bool, } pub fn open(home: &Path, a: OpenArgs) -> Result { @@ -343,14 +369,16 @@ pub fn open(home: &Path, a: OpenArgs) -> Result { .unwrap_or_default(); for k in &keys { let kept = previous.as_ref().and_then(|p| p.grant(&k.id)).map(|g| g.allow).unwrap_or_default(); - let allow = share_allow(&cli_allow, a.keys.is_empty(), &kept); - if allow.is_empty() { - return Err(need_client_allow(home)); - } - reject_bad_share_cidrs(home, &allow)?; + let allow = resolve_share_cidrs(home, &cli_allow, a.keys.is_empty(), &kept, a.dangerously_allow_all_inbound)?; grants.retain(|g| g.key != k.id); grants.push(Grant { key: k.id.clone(), until, allow }); } + if a.dangerously_allow_all_inbound { + warnings.push(format!( + "every address may connect; rate limit is {RATE_PER_IP} requests/s per client (burst {}), {CONN_PER_IP} connections", + 2 * RATE_PER_IP + )); + } let gateway_port = nginx::public_port_u16(home); let mux_port = nginx::persisted_mux_port(home)?; if port == gateway_port || port == mux_port || port < 1024 { @@ -709,21 +737,51 @@ mod tests { let dir = tempfile::tempdir().unwrap(); let msg = need_client_allow(dir.path()); assert!(msg.contains("their phone or laptop") && msg.contains("--allow"), "{msg}"); + assert!(msg.contains("dangerously-allow-all-inbound"), "{msg}"); assert!(!msg.contains("goethe api allow"), "{msg}"); } #[test] - fn share_refuses_everyone_and_this_machines_public_ip() { + fn share_refuses_everyone_and_this_machines_public_ip_unless_dangerously() { let dir = tempfile::tempdir().unwrap(); let home = dir.path(); - assert!(reject_bad_share_cidrs(home, &["0.0.0.0/0".into()]).unwrap_err().contains("every address")); - assert!(reject_bad_share_cidrs(home, &["::/0".into()]).unwrap_err().contains("every address")); + assert!(reject_bad_share_cidrs(home, &["0.0.0.0/0".into()]).unwrap_err().contains("dangerously-allow-all-inbound")); + assert!(reject_bad_share_cidrs(home, &["::/0".into()]).unwrap_err().contains("dangerously-allow-all-inbound")); let ip: IpAddr = "203.0.113.50".parse().unwrap(); std::env::set_var("GOETHE_PUBLIC_IP", ip.to_string()); let err = reject_bad_share_cidrs(home, &[format!("{ip}/32")]).unwrap_err(); std::env::remove_var("GOETHE_PUBLIC_IP"); assert!(err.contains("this machine's public address"), "{err}"); assert!(reject_bad_share_cidrs(home, &["198.51.100.7/32".into()]).is_ok()); + + let all = resolve_share_cidrs(home, &[], false, &[], true).unwrap(); + assert_eq!(all, vec!["0.0.0.0/0".to_string()]); + assert!(resolve_share_cidrs(home, &["198.51.100.7/32".into()], false, &[], true) + .unwrap_err() + .contains("cannot be combined")); + assert!(resolve_share_cidrs(home, &["0.0.0.0/0".into()], false, &[], false) + .unwrap_err() + .contains("dangerously-allow-all-inbound")); + assert_eq!( + resolve_share_cidrs(home, &["198.51.100.7/32".into()], false, &[], false).unwrap(), + vec!["198.51.100.7/32".to_string()] + ); + assert_eq!( + resolve_share_cidrs(home, &[], true, &["203.0.113.9/32".into()], false).unwrap(), + vec!["203.0.113.9/32".to_string()] + ); + assert!(resolve_share_cidrs(home, &[], false, &[], false).unwrap_err().contains("--allow")); + } + + #[test] + fn nginx_block_with_everyone_still_ends_in_deny_all() { + let dir = home_with_keys(); + let h = dir.path(); + store(h, &Share { allow: vec!["0.0.0.0/0".into()], ..share(true, now() + 600) }).unwrap(); + let block = nginx_block(h, 30000, true, 64); + assert!(block.contains("allow 0.0.0.0/0;\n deny all;"), "{block}"); + assert!(block.contains(&format!("rate={RATE_PER_IP}r/s")), "{block}"); + assert!(block.contains(&format!("limit_conn goethe_pub_conn {CONN_PER_IP}")), "{block}"); } #[test] diff --git a/engine/crates/goethe/src/main.rs b/engine/crates/goethe/src/main.rs index 649e72bb..cc38e78c 100644 --- a/engine/crates/goethe/src/main.rs +++ b/engine/crates/goethe/src/main.rs @@ -86,10 +86,11 @@ goethe api expose alone shows where the API listens and who may connect."; const SHARE_HELP: &str = "Examples: \t→ goethe api share 5h --key my-app --allow /32 +\t→ goethe api share 5h --key my-app --dangerously-allow-all-inbound \t→ goethe api share (status) \t→ goethe api share stop ---allow is who may connect (their public IP: ask them, or https://ifconfig.me on their device). This machine's IP is only the URL goethe prints. Reopening the same keys keeps their last addresses. Closes when the last key ends."; +--allow is who may connect (their public IP: ask them, or https://ifconfig.me on their device). This machine's IP is only the URL goethe prints. Reopening the same keys keeps their last addresses. --dangerously-allow-all-inbound opens to every address (rate limits still apply). Closes when the last key ends."; #[derive(Parser)] #[command( @@ -478,8 +479,10 @@ struct ShareArgs { duration: Option, #[arg(add = clap_complete::engine::ArgValueCandidates::new(complete::key_names), long, value_name = "NAME_OR_ID", num_args = 1.., value_delimiter = ',', help = "API keys to share (not admin keys), each until DURATION; with stop, the keys to stop sharing.")] key: Vec, - #[arg(long, value_name = "CIDR", num_args = 1.., value_delimiter = ',', help = "Their public IP or range (phone/laptop), such as 203.0.113.7/32 — not this machine. Required unless reopening keys that already have addresses from last share.")] + #[arg(long, value_name = "CIDR", num_args = 1.., value_delimiter = ',', help = "Only these client addresses or ranges may use the keys given, such as 203.0.113.7.")] allow: Vec, + #[arg(long, help = "Allow every address on the public gateway (0.0.0.0/0). Rate limits still apply. Not with --allow.")] + dangerously_allow_all_inbound: bool, #[arg(long, help = "The public port (default 8444, or the last one used).")] port: Option, } @@ -909,9 +912,22 @@ fn main() { Some(domain) => goethe_core::domain::check(&domain).map(|text| print!("{text}")), None => goethe_core::domain::explain().map(|text| print!("{text}")), }, - Commands::Api { cmd: Some(ApiCommands::Share(ShareArgs { duration, key, allow, port })), .. } => { - do_share(duration.as_deref().unwrap_or("status"), &key, &allow, port) - } + Commands::Api { + cmd: Some(ApiCommands::Share(ShareArgs { + duration, + key, + allow, + dangerously_allow_all_inbound, + port, + })), + .. + } => do_share( + duration.as_deref().unwrap_or("status"), + &key, + &allow, + dangerously_allow_all_inbound, + port, + ), Commands::Learn(LearnArgs { action, model, print, json }) => do_learn(action.as_deref(), &model, print.as_deref(), json), Commands::Trace(TraceArgs { action, @@ -1708,7 +1724,13 @@ fn do_status() -> Result<(), String> { Ok(()) } -fn do_share(public: &str, keys: &[String], allow: &[String], port: Option) -> Result<(), String> { +fn do_share( + public: &str, + keys: &[String], + allow: &[String], + dangerously_allow_all_inbound: bool, + port: Option, +) -> Result<(), String> { // goethe api share | stop | (status). use goethe_core::public_share as share; let home = goethe_home(); @@ -1753,7 +1775,16 @@ fn do_share(public: &str, keys: &[String], allow: &[String], port: Option) } dur => { let secs = share::parse_duration(dur)?; - let o = share::open(&home, share::OpenArgs { secs, keys, allow, port })?; + let o = share::open( + &home, + share::OpenArgs { + secs, + keys, + allow, + port, + dangerously_allow_all_inbound, + }, + )?; let ip = o.public_ip.map(|i| i.to_string()).unwrap_or_else(|| "".into()); let url = format!("https://{}/v1", host_port(&ip, o.share.port)); println!("Shared until {} ({}); the public gateway is open until {}\n", share::local_time(share::now() + secs), left(secs), share::local_time(o.share.until)); @@ -1764,7 +1795,9 @@ fn do_share(public: &str, keys: &[String], allow: &[String], port: Option) println!("Key: {} {token} models: {models}", k.name); } let clients: Vec = o.share.allow.clone(); - if !clients.is_empty() { + if clients.iter().any(|c| c.ends_with("/0")) { + println!("Only these clients: every address (--dangerously-allow-all-inbound)"); + } else if !clients.is_empty() { println!("Only these clients: {}", clients.join(", ")); } println!("\nTLS: self-signed for this address. Send {} with the key (it holds no secret); the recipient", o.cert.display()); @@ -2028,6 +2061,12 @@ mod tests { assert!(parse(&["api", "expose", "vpn", "--interface", "wg0"]).is_ok() && parse(&["api", "expose", "wg0"]).is_ok()); assert!(matches!(parse(&["api", "share", "5h", "--key", "a,b"]).unwrap().command, Commands::Api { cmd: Some(ApiCommands::Share(ShareArgs { duration: Some(_), .. })), .. })); + let Commands::Api { cmd: Some(ApiCommands::Share(s)), .. } = + parse(&["api", "share", "5h", "--key", "my-app", "--dangerously-allow-all-inbound"]).unwrap().command + else { + panic!() + }; + assert!(s.dangerously_allow_all_inbound && s.allow.is_empty()); assert!(parse(&["models", "alias", "set", "fast", "org/m"]).is_ok() && parse(&["models", "scan", "mydir"]).is_ok()); assert!(parse(&["models", "--json", "scan"]).is_err() && parse(&["api", "--json", "keys"]).is_err()); assert!(parse(&["learn", "on", "--model", "m"]).is_ok() && parse(&["trace", "on", "--all-keys"]).is_ok()); From 6cf38f59e5eb0bd276ddecb5c9c0cdb8f2ef620b Mon Sep 17 00:00:00 2001 From: Petya <64523372+peti12352@users.noreply.github.com> Date: Wed, 18 Nov 2026 13:02:34 -0800 Subject: [PATCH 08/12] Share reopen hides the bearer; fit labels name ctx; dropped card hooks warn. Reopening without --key no longer reprints the secret. Card LD_*/DYLD_* drops are named on stderr. models and models recommend both show per-GPU need with ctx and concurrency. --- engine/crates/core/src/engines/mod.rs | 24 +++++++++++++++- engine/crates/core/src/models.rs | 39 ++++++++++++++++++++++---- engine/crates/core/src/public_share.rs | 31 ++++++++++++++++++-- engine/crates/core/src/recommend.rs | 14 ++++++--- engine/crates/goethe/src/main.rs | 8 ++++-- 5 files changed, 100 insertions(+), 16 deletions(-) diff --git a/engine/crates/core/src/engines/mod.rs b/engine/crates/core/src/engines/mod.rs index e7606137..b26584b3 100644 --- a/engine/crates/core/src/engines/mod.rs +++ b/engine/crates/core/src/engines/mod.rs @@ -174,11 +174,24 @@ fn engine_key_env(cmd: &mut Command, key: &str) { fn card_env(spec: &EngineSpec) -> Vec<(String, String)> { // Card env table and card pythonpath. Loader hooks from a card never enter the process. + let (out, dropped) = card_env_parts(spec); + if !dropped.is_empty() { + eprintln!( + "goethe: card [env] dropped {}: loader hooks never enter the engine", + dropped.join(", ") + ); + } + out +} + +fn card_env_parts(spec: &EngineSpec) -> (Vec<(String, String)>, Vec) { let home = spec.home; let mut out = Vec::new(); + let mut dropped = Vec::new(); if let Some(table) = spec.card.get("env").and_then(|v| v.as_table()) { for (k, v) in table { if k.starts_with("LD_") || k.starts_with("DYLD_") { + dropped.push(k.clone()); continue; } if let Some(s) = v.as_str() { @@ -197,7 +210,7 @@ fn card_env(spec: &EngineSpec) -> Vec<(String, String)> { if !paths.is_empty() { out.push(("PYTHONPATH".to_string(), paths.join(":"))); } - out + (out, dropped) } #[cfg(test)] @@ -279,6 +292,15 @@ mod tests { let a = args(&plain); assert!(!a.iter().any(|x| x == "--api-key"), "{a:?}"); assert_eq!(e.get(ENGINE_KEY_ENV).and_then(|v| v.as_ref().map(|s| s.len())), Some(32)); + let card: toml::Value = toml::from_str("[env]\nLD_PRELOAD = \"/x.so\"\nDYLD_INSERT_LIBRARIES = \"/y.dylib\"\nOK = \"1\"").unwrap(); + let (kept, dropped) = card_env_parts(&EngineSpec { + model_path: Path::new("/h/models/m"), + tp: 1, + ..test_spec(Path::new("/h"), &card, &[3, 2]) + }); + assert!(kept.iter().any(|(k, v)| k == "OK" && v == "1")); + assert!(!kept.iter().any(|(k, _)| k.starts_with("LD_") || k.starts_with("DYLD_"))); + assert!(dropped.contains(&"LD_PRELOAD".to_string()) && dropped.contains(&"DYLD_INSERT_LIBRARIES".to_string()), "{dropped:?}"); let blocked = envs(&spec_cmd("[env]\nLD_PRELOAD = \"/x.so\"\nDYLD_INSERT_LIBRARIES = \"/y.dylib\"\nOK = \"1\"", 1)); assert!(!blocked.contains_key("LD_PRELOAD") && !blocked.contains_key("DYLD_INSERT_LIBRARIES")); assert_eq!(blocked.get("OK"), Some(&Some("1".into()))); diff --git a/engine/crates/core/src/models.rs b/engine/crates/core/src/models.rs index 648ac94e..00ee6cc8 100644 --- a/engine/crates/core/src/models.rs +++ b/engine/crates/core/src/models.rs @@ -36,7 +36,7 @@ struct ModelRow { #[derive(Debug, Clone, Copy, PartialEq)] enum Verdict { Unknown, - Fits { per_gpu: f64, total: f64 }, + Fits { per_gpu: f64, total: f64, ctx: u64, max_conc: u64 }, TooLarge, Unsupported, } @@ -45,7 +45,9 @@ impl Verdict { fn label(&self) -> String { match self { Verdict::Unknown => "unknown (run goethe doctor --hardware)".to_string(), - Verdict::Fits { per_gpu, .. } => format!("fits: {per_gpu:.1} GB per GPU"), + Verdict::Fits { per_gpu, ctx, max_conc, .. } => { + format!("fits: {per_gpu:.1} GB per GPU (ctx {ctx}, {max_conc} concurrent)") + } Verdict::TooLarge => "does not fit: not enough GPU memory".to_string(), Verdict::Unsupported => "does not fit: unsupported architecture".to_string(), } @@ -135,11 +137,22 @@ pub fn run_list(json: bool, installed_only: bool, available_only: bool, all: boo id: row.model_id, status: "available".to_string(), gb: row.vram_per_gpu_gb * row.tp as f64, - fit: Verdict::Fits { per_gpu: row.vram_per_gpu_gb, total: row.vram_per_gpu_gb * row.tp as f64 }.label(), + fit: Verdict::Fits { + per_gpu: row.vram_per_gpu_gb, + total: row.vram_per_gpu_gb * row.tp as f64, + ctx: row.ctx, + max_conc: row.max_conc, + } + .label(), custom: None, optimised: None, runtime: None, - verdict: Verdict::Fits { per_gpu: row.vram_per_gpu_gb, total: row.vram_per_gpu_gb * row.tp as f64 }, + verdict: Verdict::Fits { + per_gpu: row.vram_per_gpu_gb, + total: row.vram_per_gpu_gb * row.tp as f64, + ctx: row.ctx, + max_conc: row.max_conc, + }, }); } } @@ -247,7 +260,12 @@ fn verdict(view: Option<&View>, id: &str, input: &ChooserInput, pinned: Option Verdict::Fits { per_gpu: f.need.total(), total: f.need.total() * f.tp as f64 }, + Ok(f) => Verdict::Fits { + per_gpu: f.need.total(), + total: f.need.total() * f.tp as f64, + ctx: f.ctx, + max_conc: f.max_conc, + }, Err(_) => Verdict::TooLarge, } } @@ -861,7 +879,16 @@ mod tests { #[test] fn a_gated_catalog_model_is_marked_and_explained() { - let row = |id: &str, fit: String| ModelRow { id: id.into(), status: "available".into(), gb: 5.0, fit, custom: None, optimised: None, runtime: None, verdict: Verdict::Fits { per_gpu: 5.0, total: 5.0 } }; + let row = |id: &str, fit: String| ModelRow { + id: id.into(), + status: "available".into(), + gb: 5.0, + fit, + custom: None, + optimised: None, + runtime: None, + verdict: Verdict::Fits { per_gpu: 5.0, total: 5.0, ctx: 8192, max_conc: 4 }, + }; let text = list_text(&[row("org/open", "fits: 5.0 GB per GPU".into()), row("org/closed", format!("fits: 5.0 GB per GPU{GATED_FIT}"))], None); assert!(text.contains("org/closed") && text.contains("gated: needs your Hugging Face token or access"), "{text}"); assert!(text.contains(&format!("gated models: {}", crate::hf::GATED_WAYS)), "{text}"); diff --git a/engine/crates/core/src/public_share.rs b/engine/crates/core/src/public_share.rs index 630500ef..af7020e6 100644 --- a/engine/crates/core/src/public_share.rs +++ b/engine/crates/core/src/public_share.rs @@ -214,6 +214,13 @@ fn key_rows(home: &Path) -> Result, String> { rows } +fn strip_tokens_for_reopen(keys: &mut [SharedKey]) { + // Reopening remembered keys must not reprint bearer tokens (goethe api / keys create already showed them). + for k in keys { + k.token = None; + } +} + fn resolve_keys(home: &Path, wanted: &[String], until: i64, warnings: &mut Vec) -> Result, String> { // Each name or id must match exactly one existing key that is not an admin key and has not expired. let rows = key_rows(home)?; @@ -359,7 +366,11 @@ pub fn open(home: &Path, a: OpenArgs) -> Result { } else { a.keys.to_vec() }; - let keys = resolve_keys(home, &wanted, until, &mut warnings)?; + let reopen = a.keys.is_empty(); + let mut keys = resolve_keys(home, &wanted, until, &mut warnings)?; + if reopen { + strip_tokens_for_reopen(&mut keys); + } let cli_allow = a.allow.iter().map(|c| security::canonical_cidr(c)).collect::, _>>()?; let port = a.port.or(previous.as_ref().map(|p| p.port)).unwrap_or(DEFAULT_PORT); let mut grants: Vec = previous @@ -369,7 +380,7 @@ pub fn open(home: &Path, a: OpenArgs) -> Result { .unwrap_or_default(); for k in &keys { let kept = previous.as_ref().and_then(|p| p.grant(&k.id)).map(|g| g.allow).unwrap_or_default(); - let allow = resolve_share_cidrs(home, &cli_allow, a.keys.is_empty(), &kept, a.dangerously_allow_all_inbound)?; + let allow = resolve_share_cidrs(home, &cli_allow, reopen, &kept, a.dangerously_allow_all_inbound)?; grants.retain(|g| g.key != k.id); grants.push(Grant { key: k.id.clone(), until, allow }); } @@ -379,6 +390,9 @@ pub fn open(home: &Path, a: OpenArgs) -> Result { 2 * RATE_PER_IP )); } + if reopen { + warnings.push("the key secret is not printed again; goethe api shows it".into()); + } let gateway_port = nginx::public_port_u16(home); let mux_port = nginx::persisted_mux_port(home)?; if port == gateway_port || port == mux_port || port < 1024 { @@ -688,6 +702,7 @@ mod tests { let got = resolve_keys(h, &["app".into(), "k1".into()], now() + 60, &mut w).unwrap(); assert_eq!(got.len(), 1, "the same key twice counts once"); assert!(w.is_empty()); + assert!(got[0].token.as_deref() == Some("tok")); assert!(resolve_keys(h, &["root".into()], now() + 60, &mut w).err().unwrap().contains("admin")); assert!(resolve_keys(h, &["old".into()], now() + 60, &mut w).err().unwrap().contains("expired")); assert!(resolve_keys(h, &["dup".into()], now() + 60, &mut w).err().unwrap().contains("several")); @@ -696,6 +711,18 @@ mod tests { assert!(w.iter().any(|x| x.contains("every model"))); } + #[test] + fn reopen_without_named_keys_strips_bearer_tokens() { + let dir = home_with_keys(); + let h = dir.path(); + let mut w = Vec::new(); + let mut keys = resolve_keys(h, &["app".into()], now() + 60, &mut w).unwrap(); + assert_eq!(keys[0].token.as_deref(), Some("tok")); + strip_tokens_for_reopen(&mut keys); + assert!(keys[0].token.is_none()); + assert_eq!(keys[0].name, "app"); + } + #[test] fn no_block_is_rendered_without_an_open_window() { let dir = home_with_keys(); diff --git a/engine/crates/core/src/recommend.rs b/engine/crates/core/src/recommend.rs index 615cb561..c15284a4 100644 --- a/engine/crates/core/src/recommend.rs +++ b/engine/crates/core/src/recommend.rs @@ -239,7 +239,11 @@ pub fn run(json_out: bool) -> Result<(), String> { Some(n) => format!("{} ({n})", item.model_id), None => item.model_id.clone(), }; - let mut cells = vec![name, format!("{total:.1} GB")]; + // Same shape as goethe models: per-GPU need plus the ctx/concurrency the plan used. + let mut cells = vec![ + name, + format!("{:.1} GB/GPU · ctx {} · {} conc", item.vram_per_gpu_gb, item.ctx, item.max_conc), + ]; if multi { cells.push(format_gpu_list(&item.gpus)); } @@ -263,10 +267,11 @@ pub fn preview(home: &Path, model: &RegistryModel) -> Result, Str let pinned = model.default_tp.filter(|t| *t > 0).map(|t| t as usize); match view.fit(&model.id, &input, pinned) { Ok(f) => Ok(Some(format!( - "fit: ctx {} on GPU {} ({:.1} GB per GPU)", + "fit: {:.1} GB per GPU (ctx {}, {} concurrent) on GPU {}", + f.need.total(), f.ctx, + f.max_conc, format_gpu_list(&f.gpus), - f.need.total() ))), Err(e) => Err(format!("does not fit the allowed GPUs: {e}")), } @@ -583,7 +588,8 @@ mod tests { let llama = reg.models.iter().find(|m| m.id == "nvidia/Llama-3.1-8B-Instruct-NVFP4").unwrap(); let line = preview(home.path(), llama).unwrap().unwrap(); assert!(line.contains("ctx 65536"), "{line}"); - assert!(line.contains("23.4 GB"), "{line}"); + assert!(line.contains("23.4 GB per GPU"), "{line}"); + assert!(line.contains("concurrent"), "{line}"); let big = reg.models.iter().find(|m| m.id == "Qwen/Qwen3.8-27B").unwrap(); assert!(preview(home.path(), big).is_err()); } diff --git a/engine/crates/goethe/src/main.rs b/engine/crates/goethe/src/main.rs index cc38e78c..428dd281 100644 --- a/engine/crates/goethe/src/main.rs +++ b/engine/crates/goethe/src/main.rs @@ -1791,8 +1791,10 @@ fn do_share( println!("URL: {url}"); for k in &o.keys { let models = k.models.as_deref().filter(|m| !m.is_empty()).unwrap_or("every model"); - let token = k.token.as_deref().unwrap_or("(shown when it was created)"); - println!("Key: {} {token} models: {models}", k.name); + match k.token.as_deref() { + Some(token) => println!("Key: {} {token} models: {models}", k.name), + None => println!("Key: {} (id {}) models: {models}", k.name, k.id), + } } let clients: Vec = o.share.allow.clone(); if clients.iter().any(|c| c.ends_with("/0")) { @@ -1802,7 +1804,7 @@ fn do_share( } println!("\nTLS: self-signed for this address. Send {} with the key (it holds no secret); the recipient", o.cert.display()); println!(" verifies the gateway with it, for example:"); - let token = o.keys.first().and_then(|k| k.token.as_deref()).unwrap_or(""); + let token = o.keys.first().and_then(|k| k.token.as_deref()).unwrap_or(""); println!(" curl --cacert public.crt {url}/models -H \"Authorization: Bearer {token}\""); if let Some(f) = &o.fingerprint { println!(" SHA-256 fingerprint: {f}"); From 129af3b5c025cc1ece0464398676de6c8fe6f8ed Mon Sep 17 00:00:00 2001 From: Petya <64523372+peti12352@users.noreply.github.com> Date: Wed, 18 Nov 2026 13:04:43 -0800 Subject: [PATCH 09/12] Test: fit label names ctx and concurrency. --- engine/crates/core/src/models.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/engine/crates/core/src/models.rs b/engine/crates/core/src/models.rs index 00ee6cc8..a92e1ab9 100644 --- a/engine/crates/core/src/models.rs +++ b/engine/crates/core/src/models.rs @@ -877,6 +877,13 @@ mod tests { assert_eq!(cap_screen("a\nb\n", 40), "a\nb\n"); } + #[test] + fn fit_label_names_ctx_and_concurrency() { + let v = Verdict::Fits { per_gpu: 23.3, total: 23.3, ctx: 8192, max_conc: 4 }; + let label = v.label(); + assert!(label.contains("23.3 GB per GPU") && label.contains("ctx 8192") && label.contains("4 concurrent"), "{label}"); + } + #[test] fn a_gated_catalog_model_is_marked_and_explained() { let row = |id: &str, fit: String| ModelRow { From abc7fbcb4a4751a4adb998187e45a479a1625c44 Mon Sep 17 00:00:00 2001 From: Petya <64523372+peti12352@users.noreply.github.com> Date: Wed, 18 Nov 2026 13:42:55 -0800 Subject: [PATCH 10/12] Fail-closed public expose, TLS SAN for bind IPs, scan under models/. Bare `expose public --yes` and raw `expose 0.0.0.0` refuse; cert SANs include interface IPs; models scan resolves folder names under GOETHE_HOME/models. isolated-home E2E traces and stage5 cover the regressions. --- CHANGELOG.md | 3 + docs/cli.md | 16 +- docs/e2e-greengoblin-pr180-session.sh | 393 ++++++ docs/e2e-traces/FOLLOWUP-pr180-greengoblin.md | 121 ++ docs/e2e-traces/README.md | 27 + docs/e2e-traces/TRACE-pr180-greengoblin.md | 1177 +++++++++++++++++ docs/e2e-traces/TRACE-v1-aborted.md | 704 ++++++++++ docs/e2e-traces/console-v2.txt | 609 +++++++++ docs/user-guide.md | 2 +- engine/crates/core/src/configure.rs | 126 +- engine/crates/core/src/menu.rs | 9 +- engine/crates/core/src/nginx.rs | 33 +- engine/crates/core/src/onboard.rs | 18 +- engine/crates/core/src/scan.rs | 37 +- engine/crates/goethe/src/complete.rs | 5 +- engine/crates/goethe/src/main.rs | 47 +- engine/tests/stage5_configure_api.py | 25 +- 17 files changed, 3285 insertions(+), 67 deletions(-) create mode 100755 docs/e2e-greengoblin-pr180-session.sh create mode 100644 docs/e2e-traces/FOLLOWUP-pr180-greengoblin.md create mode 100644 docs/e2e-traces/README.md create mode 100644 docs/e2e-traces/TRACE-pr180-greengoblin.md create mode 100644 docs/e2e-traces/TRACE-v1-aborted.md create mode 100644 docs/e2e-traces/console-v2.txt diff --git a/CHANGELOG.md b/CHANGELOG.md index fdac8d86..223484d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## Unreleased +- `goethe api expose public --yes` without `--allow` no longer binds every interface on a leftover allowlist; name the clients and confirm (`--yes` or `y`). Raw `goethe api expose 0.0.0.0` is refused (use `expose public`). World-open clients need the hidden `--dangerously-allow-all-inbound --yes`. +- The gateway TLS certificate SAN includes this host's interface IPs (tailnet, LAN), so `curl --cacert` to the bind address verifies; the cert refreshes when that list changes. +- `goethe models scan ` resolves the name under `GOETHE_HOME/models`, not the current working directory. - goethe picks the engine before downloading: a goethe kernel pack on a logged-in node, else SGLang when it supports the model, else llama.cpp on the repo's GGUF files or on the GGUF build Hugging Face lists for the model (the name typed becomes an alias), else a refusal with each engine's reason. Embedding models like embeddinggemma install this way. On a Mac, llama.cpp with the same GGUF lookup instead of a name search. - A kernel pack that cannot run gives way to the plain runtime by default, saying why (`GOETHE_ALLOW_FALLBACK=0` restores the error). The pack structure check after a download, and the goethe-engine install it needs, run only when a pack of the model's architecture exists for the GPU. - `goethe models` shows each model's engine. diff --git a/docs/cli.md b/docs/cli.md index 68c77782..b90ff70f 100644 --- a/docs/cli.md +++ b/docs/cli.md @@ -271,24 +271,24 @@ Who can reach the API. Without an argument it shows where the API listens and ho | `goethe api expose` | Show where the API listens and who may connect (`--json` for scripts) | | `goethe api expose local` | This machine only | | `goethe api expose vpn` | A VPN or other private network (recommended) | -| `goethe api expose public` | A public address | -| `goethe api expose
` | Listen on `127.0.0.1` (this machine only), `0.0.0.0` (all addresses), one IP of this machine, or an interface such as `wg0`, whose address is followed | +| `goethe api expose public` | A public address (needs `--allow /32` and `--yes`, or `y` on a terminal) | +| `goethe api expose
` | Listen on `127.0.0.1`, one IP of this machine, or an interface such as `wg0` (followed). Not `0.0.0.0`: use `expose public` | For a VPN it lists the networks this machine is on, with the ranges each one reaches, and works with any VPN that has a network interface. It then asks whether to restrict access to specific IP addresses. The gateway follows the chosen interface: when its address changes, it moves within a few seconds, and while the interface has no address only this machine can connect. +`expose public` never binds every interface on a leftover allowlist. Name the clients with `--allow`, confirm with `--yes` (or `y`), and only then does it listen on `0.0.0.0`. Opening every client address needs the hidden `--dangerously-allow-all-inbound --yes`. + | Option | Description | |---|---| -| `--interface ` | With `vpn` or `public`: the network interface to serve, such as `wg0`; needed without a terminal when there are several | -| `--ip ` | With `vpn` or `public`: a fixed address of this machine instead of an interface | -| `--allow ` | With `vpn` or `public`: a client address or range to allow; repeatable | -| `--yes` | Apply without questions (`public` still refuses `0.0.0.0/0`) | +| `--interface ` | With `vpn`: the network interface to serve, such as `wg0`; needed without a terminal when there are several | +| `--allow ` | With `vpn` or `public`: a client address or range to allow; **required for public**; repeatable | +| `--yes` | Apply without questions. Public still needs `--allow` (or `--dangerously-allow-all-inbound`) | | `--json` | With no argument: the status as JSON | ```bash goethe api expose local goethe api expose vpn --interface wg0 -goethe api expose public --allow 203.0.113.7/32 -goethe api expose 0.0.0.0 +goethe api expose public --allow 203.0.113.7/32 --yes ``` ### `goethe api allow` diff --git a/docs/e2e-greengoblin-pr180-session.sh b/docs/e2e-greengoblin-pr180-session.sh new file mode 100755 index 00000000..88de8737 --- /dev/null +++ b/docs/e2e-greengoblin-pr180-session.sh @@ -0,0 +1,393 @@ +#!/usr/bin/env bash +# Real-user E2E on greengoblin for PR180 (isolated GOETHE_HOME). Leaves TRACE.md. +# Tailnet expose only for positive path; public/share probes must refuse or be reverted. +# Restores production goethe after. Never aborts mid-run on a single failed step. +set -u +set -o pipefail + +ROOT=/home/v/proj/petya +BUILD=$ROOT/goethe-pr180/engine/target/release +SESSION=$ROOT/goethe-e2e-180 +HOME_E2E=$SESSION/home +TRACE=$SESSION/TRACE.md +LOG=$SESSION/session.log +G=$BUILD/goethe +PROD_G=$(command -v goethe || true) +TS=$(date -u +%Y-%m-%dT%H:%M:%SZ) +FAILS=0 +PASS=0 +FINDINGS=() + +mkdir -p "$SESSION" "$HOME_E2E" +: >"$LOG" + +log() { printf '%s\n' "$*" | tee -a "$LOG"; } +md() { printf '%s\n' "$*" >>"$TRACE"; } +finding() { FINDINGS+=("$1"); log "FINDING: $1"; } + +# run never enables set -e for the caller (v1 aborted the session after first soft fail) +run() { + local title=$1; shift + md "" + md "### $title" + md "" + md '```' + md "+ $*" + md '```' + log "" + log "==> $title" + log "+ $*" + local out ec + set +e + out=$(GOETHE_HOME="$HOME_E2E" PATH="$BUILD:$PATH" "$@" 2>&1) + ec=$? + set +e + printf '%s\n' "$out" | tee -a "$LOG" | sed 's/^/ /' + md "" + md '```' + printf '%s\n' "$out" | head -c 14000 >>"$TRACE" + if [ "${#out}" -gt 14000 ]; then md "...(truncated)"; fi + md '```' + md "" + md "exit: \`$ec\`" + return "$ec" +} + +expect_ok() { + local title=$1; shift + if run "$title" "$@"; then + PASS=$((PASS + 1)) + md "**result:** pass" + return 0 + fi + FAILS=$((FAILS + 1)) + md "**result:** FAIL (expected success)" + finding "FAIL ok: $title" + return 1 +} + +expect_fail() { + local title=$1; shift + if run "$title" "$@"; then + FAILS=$((FAILS + 1)) + md "**result:** FAIL (expected refusal — command succeeded)" + finding "FAIL refuse: $title (command succeeded when it should refuse)" + return 1 + fi + PASS=$((PASS + 1)) + md "**result:** pass (refused as expected)" + return 0 +} + +note() { md ""; md "> $*"; log "NOTE: $*"; } + +# --- TRACE header --- +cat >"$TRACE" </dev/null | head -1)\`) +- **GOETHE_HOME (isolated):** \`$HOME_E2E\` +- **Prod goethe (restored after):** \`${PROD_G:-none}\` +- **Scope:** install/scan local path, fit, load, run (chat + embed), CLI, tailnet expose — **no lasting public bind** +- **GPU:** $(nvidia-smi -L 2>/dev/null | head -1) + +## Method + +Isolated \`GOETHE_HOME\` so the live 0.3.x install is not mutated. Production \`goethe\` is stopped for the session (port/GPU), then started again. Findings are written as observed — not softened. Script continues after failures (no mid-run abort). + +## Preflight +EOF + +{ + echo "disk:"; df -h / /home/v | sed 's/^/ /' + echo "gpu mem:"; nvidia-smi --query-gpu=memory.used,memory.free,memory.total --format=csv | sed 's/^/ /' + echo "prod status:"; goethe status 2>&1 | sed 's/^/ /' | head -25 + echo "prod listeners:"; ss -ltn | grep -E '8443|8444' | sed 's/^/ /' || echo " (none)" +} >>"$TRACE" + +note "Stopping production Goethe for isolated E2E (will restore)." +goethe down 2>&1 | tee -a "$LOG" || true +sleep 2 + +# fresh isolated home each full run (keep TRACE history by rotating) +rm -rf "$HOME_E2E" +mkdir -p "$HOME_E2E/bin" "$HOME_E2E/models" +cp -a "$BUILD/goethe" "$BUILD/goethed" "$HOME_E2E/bin/" +if [ -f /home/v/.goethe/hardware_state.json ]; then + cp -a /home/v/.goethe/hardware_state.json "$HOME_E2E/" +fi +# local-path model: symlink existing embedding GGUF tree (no re-download) +if [ -d /home/v/.goethe/models/ggml-org__embeddinggemma-2-GGUF ]; then + ln -sfn /home/v/.goethe/models/ggml-org__embeddinggemma-2-GGUF \ + "$HOME_E2E/models/ggml-org__embeddinggemma-2-GGUF" +fi +if [ -d /home/v/.goethe/models/nvidia__Llama-3.1-8B-Instruct-NVFP4 ]; then + ln -sfn /home/v/.goethe/models/nvidia__Llama-3.1-8B-Instruct-NVFP4 \ + "$HOME_E2E/models/nvidia__Llama-3.1-8B-Instruct-NVFP4" +fi + +export GOETHE_HOME="$HOME_E2E" +export PATH="$HOME_E2E/bin:$BUILD:$PATH" + +md "" +md "## 1. Start (fresh home)" +expect_ok "goethe up" goethe up || true +sleep 3 +expect_ok "goethe status" goethe status || true +expect_ok "goethe doctor" goethe doctor || true +expect_ok "goethe doctor --hardware" goethe doctor --hardware || true + +md "" +md "## 2. CLI surface / help consistency" +expect_ok "goethe --help" goethe --help || true +expect_ok "goethe api share --help" goethe api share --help || true +expect_ok "goethe api expose --help" goethe api expose --help || true +expect_ok "goethe models --help" goethe models --help || true +expect_ok "goethe run --help" goethe run --help || true +# -p must not exist on run (clap would accept unknown only with allow) +if goethe run --help 2>&1 | grep -qE -- '--prompt|-p '; then + finding "goethe run still documents -p/--prompt (unexpected vs current help)" +else + note "goethe run has no -p/--prompt; INPUT is positional. CI should not teach -p." +fi + +md "" +md "## 3. What fits" +expect_ok "goethe models recommend" goethe models recommend || true +expect_ok "goethe models" goethe models || true +note "Compare models vs recommend per-GPU + ctx wording for the same id." + +md "" +md "## 4. Local path model (scan + install from folder)" +# Correct scan arg is folder name under models/, not HF id (footgun) +run "models scan HF-id form (footgun check)" goethe models scan "ggml-org/embeddinggemma-2-GGUF" +if [ $? -ne 0 ]; then + PASS=$((PASS + 1)); md "**result:** pass (HF-id form rejected)" + finding "UX footgun: users typing HF id into models scan get os error 2; hint should say use folder name org__name or goethe install " +else + FAILS=$((FAILS + 1)); finding "models scan accepted org/name HF id as folder" +fi + +expect_ok "models scan folder name --yes" \ + goethe models scan "ggml-org__embeddinggemma-2-GGUF" --yes || true +expect_ok "models --installed after scan" goethe models --installed || true + +# alternate: install from absolute path (local path based model) +expect_ok "install from absolute path --name" \ + goethe install "$HOME_E2E/models/ggml-org__embeddinggemma-2-GGUF" \ + --name ggml-org/embeddinggemma-2-GGUF --yes || true +expect_ok "models --installed after install path" goethe models --installed || true + +md "" +md "## 5. API key + tailnet expose (NO lasting public)" +expect_ok "create key e2e-tailnet" \ + goethe api keys create e2e-tailnet --models ggml-org/embeddinggemma-2-GGUF || true + +RAW=$(grep -oE 'goethe_sk_[0-9a-f]+' "$LOG" | head -1 || true) +md "" +md "### captured bearer (redact in shared copies)" +md '```' +md "${RAW:-NONE}" +md '```' + +expect_ok "expose vpn on tailscale0 with CGNAT allow" \ + goethe api expose vpn --interface tailscale0 --allow 100.64.0.0/10 --yes || true +expect_ok "goethe api expose (status)" goethe api expose || true +expect_ok "allowlist shows tailnet" goethe api allow || true +run "ss after vpn expose" bash -c 'ss -ltn | grep -E "8443|8444" || true' + +# failure modes +# Must refuse: --yes alone must NOT bind 0.0.0.0 (fixed after greengoblin incident) +expect_fail "public expose --yes without --allow must refuse" \ + goethe api expose public --yes || true +expect_fail "raw expose 0.0.0.0 must refuse" \ + goethe api expose 0.0.0.0 || true +run "ss after public refuse probes" bash -c 'ss -ltn | grep -E "8443|8444" || true' +if ss -ltn | grep -q '0.0.0.0:8443'; then + finding "CRITICAL: 0.0.0.0:8443 listening after refused public probes" + FAILS=$((FAILS + 1)) +else + PASS=$((PASS + 1)) + md "**result:** pass (no 0.0.0.0:8443 after refuse probes)" +fi +# stay on vpn; re-assert tailnet bind +run "reaffirm vpn after public refuse" \ + goethe api expose vpn --interface tailscale0 --allow 100.64.0.0/10 --yes || true + +expect_fail "share without --allow" goethe api share 5m --key e2e-tailnet || true +expect_fail "share with this-machine public IP as --allow" bash -c ' + IP=$(curl -4 -fsS --max-time 3 ifconfig.me || true) + if [ -z "$IP" ]; then echo "skip: no public ip"; exit 1; fi + goethe api share 5m --key e2e-tailnet --allow "$IP/32" +' || true +expect_ok "share status closed" goethe api share || true +run "ss :8444 must be absent" bash -c 'ss -ltn | grep 8444 || echo no_8444' +if ss -ltn | grep -q ':8444'; then + finding "public share port 8444 is listening" + FAILS=$((FAILS + 1)) +else + PASS=$((PASS + 1)) +fi + +md "" +md "## 6. Load + run embedding model" +expect_ok "load dry-run embedding" goethe load ggml-org/embeddinggemma-2-GGUF --dry-run || true +expect_ok "load embedding" goethe load ggml-org/embeddinggemma-2-GGUF || true +sleep 8 +expect_ok "goethe ps" goethe ps || true +expect_ok "goethe status after load" goethe status || true + +# correct run form: positional INPUT, optional --plain +run "goethe run embed positional INPUT" \ + goethe run --plain ggml-org/embeddinggemma-2-GGUF "hello greengoblin e2e" +ec_run=$? +if [ "$ec_run" -eq 0 ]; then + PASS=$((PASS + 1)); md "**result:** pass" +else + FAILS=$((FAILS + 1)); md "**result:** FAIL"; finding "goethe run --plain embed INPUT failed (exit $ec_run)" +fi + +# wrong forms (document footguns) +run "goethe run with -- separator (footgun)" \ + goethe run ggml-org/embeddinggemma-2-GGUF -- embed "hello" +if [ $? -ne 0 ]; then + PASS=$((PASS + 1)); md "**result:** pass (bad argv rejected)"; finding "UX: goethe run does not take -- extra args; clap error is opaque for users copying engine-flag patterns" +else + FAILS=$((FAILS + 1)); md "**result:** unexpected success" +fi + +API_TAIL="https://100.90.97.111:8443/v1" +API_LOCAL="https://127.0.0.1:8443/v1" +CACERT="$HOME_E2E/nginx/certs/server.crt" +if [ -n "$RAW" ] && [ -f "$CACERT" ]; then + expect_ok "curl /v1/models via 127.0.0.1 + cacert" \ + curl -sS --max-time 20 --cacert "$CACERT" "$API_LOCAL/models" \ + -H "Authorization: Bearer $RAW" || true + expect_ok "curl /v1/models via tailnet IP + cacert" \ + curl -sS --max-time 20 --cacert "$CACERT" "$API_TAIL/models" \ + -H "Authorization: Bearer $RAW" || true + expect_ok "curl /v1/embeddings via tailnet" \ + curl -sS --max-time 90 --cacert "$CACERT" "$API_TAIL/embeddings" \ + -H "Authorization: Bearer $RAW" -H "Content-Type: application/json" \ + -d '{"model":"ggml-org/embeddinggemma-2-GGUF","input":"greengoblin e2e"}' || true + # negative: no auth + set +e + http=$(curl -sS -o /tmp/e2e-noauth.body -w "%{http_code}" --max-time 20 --cacert "$CACERT" \ + "$API_TAIL/embeddings" -H "Content-Type: application/json" \ + -d '{"model":"ggml-org/embeddinggemma-2-GGUF","input":"x"}' 2>/tmp/e2e-noauth.err) + set +e + md "" + md "### curl embeddings without key" + md "HTTP \`$http\`" + md '```' + head -c 2000 /tmp/e2e-noauth.body >>"$TRACE" 2>/dev/null || true + md '```' + log "==> curl embeddings without key -> HTTP $http" + if [ "$http" = "401" ] || [ "$http" = "403" ]; then + PASS=$((PASS + 1)); md "**result:** pass (auth rejected)" + else + FAILS=$((FAILS + 1)); md "**result:** FAIL (expected 401/403, got $http)" + finding "embeddings without bearer returned HTTP $http (expected 401/403)" + fi +else + finding "Could not curl API — missing bearer or cacert" + FAILS=$((FAILS + 1)) +fi + +md "" +md "## 7. Chat model (if linked)" +if [ -e "$HOME_E2E/models/nvidia__Llama-3.1-8B-Instruct-NVFP4" ]; then + expect_ok "models scan llama folder --yes" \ + goethe models scan "nvidia__Llama-3.1-8B-Instruct-NVFP4" --yes || true + run "unload embedding before chat" goethe unload --all || true + sleep 2 + expect_ok "load dry-run llama" goethe load nvidia/Llama-3.1-8B-Instruct-NVFP4 --dry-run || true + expect_ok "load llama" goethe load nvidia/Llama-3.1-8B-Instruct-NVFP4 || true + sleep 12 + run "goethe run llama one-shot" \ + goethe run --plain nvidia/Llama-3.1-8B-Instruct-NVFP4 "Say hi in five words." + if [ $? -eq 0 ]; then PASS=$((PASS + 1)); md "**result:** pass"; else FAILS=$((FAILS + 1)); md "**result:** FAIL"; finding "llama run failed"; fi +else + note "Llama NVFP4 tree not linked; skipped chat load." +fi + +md "" +md "## 8. More failure / UX probes" +expect_fail "load missing model" goethe load definitely-missing-model-xyz || true +expect_fail "run missing model" goethe run --plain definitely-missing-model-xyz hi || true +run "load --dry-run missing" goethe load definitely-missing-model-xyz --dry-run || true +expect_fail "share dangerously without remembered key" \ + goethe api share 5m --dangerously-allow-all-inbound || true +run "gpu table" goethe gpu || true +run "logs goethed (tail)" bash -c 'goethe logs goethed 2>&1 | tail -50' || true + +# consistency: status URL vs expose URL vs api URL +md "" +md "## 8b. URL consistency" +run "goethe status (URLs)" goethe status || true +run "goethe api (URLs)" goethe api || true +run "goethe api expose" goethe api expose || true + +md "" +md "## 9. Cleanup on box" +run "unload all" goethe unload --all || true +run "expose local" goethe api expose local --yes || true +run "share stop" goethe api share stop || true +run "goethe down (e2e)" goethe down || true +# ensure e2e left no listeners +sleep 1 +run "ss after e2e down" bash -c 'ss -ltn | grep -E "8443|8444" || echo none' + +# restore production +note "Restoring production Goethe." +unset GOETHE_HOME +export PATH="/home/v/.cargo/bin:/home/v/.local/bin:$PATH" +goethe up 2>&1 | tee -a "$LOG" || true +sleep 3 +goethe status 2>&1 | tee -a "$LOG" | head -30 || true +ss -ltn | grep -E '8443|8444' | tee -a "$LOG" || true +# prod must not be on 0.0.0.0 +if ss -ltn | grep -q '0.0.0.0:8443'; then + finding "PROD restored but listening on 0.0.0.0:8443" + FAILS=$((FAILS + 1)) +else + PASS=$((PASS + 1)) + note "Prod not on 0.0.0.0:8443" +fi + +md "" +md "## Scoreboard" +md "" +md "- Passes: **$PASS**" +md "- Failures / unexpected: **$FAILS**" +md "- Full command log: \`$LOG\`" +md "- Isolated home: \`$HOME_E2E\` — delete when done: \`rm -rf $SESSION\`" +md "" +md "## Findings (observed, not softened)" +md "" +if [ ${#FINDINGS[@]} -eq 0 ]; then + md "_No automated findings recorded; review TRACE manually._" +else + i=1 + for f in "${FINDINGS[@]}"; do + md "$i. $f" + i=$((i + 1)) + done +fi +md "" +md "## CI / follow-up test ideas" +md "" +md "1. Assert \`goethe models scan org/name\` fails with a hint to use \`org__name\` folder form." +md "2. Assert \`goethe api expose public --yes\` either refuses without a non-VPN client allow, or never binds \`0.0.0.0\` unless \`--dangerously-allow-all-inbound\` (product decision)." +md "3. After any public probe in E2E, assert \`ss\` has no \`0.0.0.0:8443\` / \`:8444\`." +md "4. \`goethe run --plain \` happy path for embed + chat; reject teaching \`run -- -p\`." +md "5. Curl \`/v1/models\` and \`/v1/embeddings\` with cacert over tailnet IP; 401 without bearer." +md "6. Share: machine public IP as \`--allow\` must refuse; no \`--allow\` must refuse." +md "7. Script must not \`set -e\` across soft failures (v1 aborted mid-session)." +md "" + +echo "PASS=$PASS FAILS=$FAILS TRACE=$TRACE" | tee -a "$LOG" +# exit 0 so ssh wrappers still fetch TRACE; scoreboard holds the truth +exit 0 diff --git a/docs/e2e-traces/FOLLOWUP-pr180-greengoblin.md b/docs/e2e-traces/FOLLOWUP-pr180-greengoblin.md new file mode 100644 index 00000000..371f2359 --- /dev/null +++ b/docs/e2e-traces/FOLLOWUP-pr180-greengoblin.md @@ -0,0 +1,121 @@ +# E2E follow-up (load --yes, cert SAN, scan detail) +- when: 2026-11-18T21:12:48Z + +## Prior scan folder failure excerpt +### models scan folder name --yes + +``` ++ goethe models scan ggml-org__embeddinggemma-2-GGUF --yes +``` + +``` +ggml-org__embeddinggemma-2-GGUF: No such file or directory (os error 2) +``` + +exit: `1` +**result:** FAIL (expected success) + +### models --installed after scan + +``` ++ goethe models --installed +``` + +``` +VRAM free: 31.8 GB +``` + +exit: `0` +**result:** pass + +-- +2. FAIL ok: models scan folder name --yes +3. api expose public --yes binds 0.0.0.0 without requiring a public client allow; only warns. Listener is world-reachable if NAT/firewall forwards; nginx allowlist may still drop non-listed clients. +4. FAIL ok: load embedding +5. goethe run --plain embed INPUT failed (exit 3) +6. UX: goethe run does not take -- extra args; clap error is opaque for users copying engine-flag patterns +7. FAIL ok: curl /v1/models via tailnet IP + cacert +8. FAIL ok: curl /v1/embeddings via tailnet +9. embeddings without bearer returned HTTP 000 (expected 401/403) + +## CI / follow-up test ideas + +1. Assert `goethe models scan org/name` fails with a hint to use `org__name` folder form. +2. Assert `goethe api expose public --yes` either refuses without a non-VPN client allow, or never binds `0.0.0.0` unless `--dangerously-allow-all-inbound` (product decision). +3. After any public probe in E2E, assert `ss` has no `0.0.0.0:8443` / `:8444`. +4. `goethe run --plain ` happy path for embed + chat; reject teaching `run -- -p`. +5. Curl `/v1/models` and `/v1/embeddings` with cacert over tailnet IP; 401 without bearer. +6. Share: machine public IP as `--allow` must refuse; no `--allow` must refuse. +7. Script must not `set -e` across soft failures (v1 aborted mid-session). + +## scan/install state +ggml-org__embeddinggemma-2-GGUF: No such file or directory (os error 2) +VRAM free: 31.8 GB + +Installed +MODEL STATUS DISK FIT ON THIS MACHINE +ggml-org/embeddinggemma-2-GGUF (optimised kernels available) installed 0.4 GB fits: 0.9 GB per GPU (ctx 1024, 8 concurrent) +/home/v/proj/petya/goethe-e2e-180/home/models/ggml-org__embeddinggemma-2-GGUF is already inside /home/v/proj/petya/goethe-e2e-180/home/models +KEY_PRESENT=yes +Gateway now: listening on 127.0.0.1 port 18443; allowlist: 100.64.0.0/10, 127.0.0.1/32 +The gateway will listen on 100.90.97.111 (tailscale0; follows its address) and on 127.0.0.1, and allow 100.64.0.0/10. +gateway listens on 100.90.97.111 (tailscale0; follows its address) port 18443 +API keys: 1 exist (goethe api keys; goethe api keys create for each new client) + +API: https://100.90.97.111:18443/v1 + +For the models and keys run: + + → goethe api + +## cert SANs +subject=CN = goethe-local +X509v3 Subject Alternative Name: + DNS:localhost, IP Address:127.0.0.1, IP Address:0:0:0:0:0:0:0:1, DNS:greengoblin +## load --yes +auto: tp=1 on GPUs 0: 0.9 GB per GPU (weights 0.3 + KV 0.0 + sliding-window KV 0.1 + overhead 0.5) +Loading into VRAM... +loading into vram, 5 s +loading into vram, 10 s +warming up kernels with one request (the first time can take a few minutes) +RUNNING: ggml-org/embeddinggemma-2-GGUF instance inst-18e9401211c53dcc on GPU 0 port 30001 (12.1 s) +INSTANCE MODEL RUNTIME SLOT STATUS GPUS PORT VRAM_GB RESTARTS IN_FLIGHT TOK_PER_S PREFIX +inst-18e9401211c53dcc ggml-org/embeddinggemma-2-GGUF goethe-engine ggml-org/embeddinggemma-2-GGUF|0|0 RUNNING 0 30001 0.88 0 0 0.0 - +## run --plain embed +dims=768 norm=1.0000 [-0.0346, 0.0333, 0.0366, -0.0186, ...] +## curl localhost cacert +curl: (60) SSL certificate problem: self-signed certificate +More details here: https://curl.se/docs/sslcerts.html + +curl failed to verify the legitimacy of the server and therefore could not +establish a secure connection to it. To learn more about this situation and +how to fix it, please visit the web page mentioned above. +## curl tailnet cacert (expect SAN fail) +curl: (60) SSL certificate problem: self-signed certificate +More details here: https://curl.se/docs/sslcerts.html + +curl failed to verify the legitimacy of the server and therefore could not +establish a secure connection to it. To learn more about this situation and +how to fix it, please visit the web page mentioned above. +## curl tailnet -k (insecure name check bypass) +{"error":{"code":"invalid_api_key","message":"Invalid or missing Goethe API key","param":null,"type":"auth_error"}}## curl embeddings -k +{"error":{"code":"invalid_api_key","message":"Invalid or missing Goethe API key","param":null,"type":"auth_error"}}## curl embeddings no auth -k +HTTP 401 +{"error":{"code":"invalid_api_key","message":"Invalid or missing Goethe API key","param":null,"type":"auth_error"}}## llama trees +ggml-org__embeddinggemma-2-GGUF +## restored prod +goethe: running + +API: https://100.90.97.111:8443/v1 + +API KEY NAME KEY ID +matteo 95f818903035 + +For more details run: + + → goethe api + +Platform: Linked (workspace Personal) +Heartbeat: OK (3 s ago) +LISTEN 0 511 127.0.0.1:8443 0.0.0.0:* +LISTEN 0 511 100.90.97.111:8443 0.0.0.0:* diff --git a/docs/e2e-traces/README.md b/docs/e2e-traces/README.md new file mode 100644 index 00000000..1d853b9f --- /dev/null +++ b/docs/e2e-traces/README.md @@ -0,0 +1,27 @@ +# Goethe PR180 greengoblin E2E traces + +Real-user session on greengoblin (isolated `GOETHE_HOME`), 2026-11-18. API keys redacted. + +| File | What | +|------|------| +| `TRACE-pr180-greengoblin.md` | Full command TRACE + scoreboard + findings | +| `FOLLOWUP-pr180-greengoblin.md` | Load `--yes`, cert SAN, embed run | +| `TRACE-v1-aborted.md` | First run aborted (`set -e` in helper) | +| `console-v2.txt` | Raw SSH console for v2 | +| `../e2e-greengoblin-pr180-session.sh` | Reusable driver | + +## Finding status (landed with this PR) + +| Sev | Finding | Status | +|-----|---------|--------| +| P0 | `expose public --yes` binds `0.0.0.0` without `--allow` | **Fixed** (refuse; need `--allow` + `--yes`) | +| P0 | TLS SAN missing tailnet/bind IPs (curl 60) | **Fixed** (`tls_names` includes iface IPs; cert refreshes when SAN changes) | +| P1 | `models scan ` from CWD | **Fixed** (folder names resolve under `models/`) | +| P1 | Symlink under `models/` refused by scan | **Docs/msg** (use `goethe install --name`; intentional no follow) | +| P1 | Non-TTY load blocked by Xorg unless `--yes` | **Keep** (intentional; E2E/CI use `--yes`) | +| P2 | Second `GOETHE_HOME` → port 18443 | **Keep** (warned; test harness must read status URL) | +| P2 | `goethe run` no `-p` | **Keep** (positional INPUT; help already says so) | + +## Security incident note (0.0.0.0 bind during E2E) + +**Closed.** Prod is tailnet+localhost only. No evidence of external attack in nginx access logs. NAT + allowlist + API key limited blast radius. Fix: `expose public --yes` without `--allow` refuses; raw `expose 0.0.0.0` refuses. diff --git a/docs/e2e-traces/TRACE-pr180-greengoblin.md b/docs/e2e-traces/TRACE-pr180-greengoblin.md new file mode 100644 index 00000000..aabba76a --- /dev/null +++ b/docs/e2e-traces/TRACE-pr180-greengoblin.md @@ -0,0 +1,1177 @@ +# Goethe PR180 greengoblin E2E session + +- **When (UTC):** 2026-11-18T21:10:59Z +- **Host:** greengoblin +- **Binary:** `/home/v/proj/petya/goethe-pr180/engine/target/release/goethe` (`goethe 0.3.3`) +- **GOETHE_HOME (isolated):** `/home/v/proj/petya/goethe-e2e-180/home` +- **Prod goethe (restored after):** `/home/v/.local/bin/goethe` +- **Scope:** install/scan local path, fit, load, run (chat + embed), CLI, tailnet expose — **no lasting public bind** +- **GPU:** GPU 0: NVIDIA GeForce RTX 5090 (UUID: GPU-aaabe7a6-e328-9869-cca8-a8e56a3d4591) + +## Method + +Isolated `GOETHE_HOME` so the live 0.3.x install is not mutated. Production `goethe` is stopped for the session (port/GPU), then started again. Findings are written as observed — not softened. Script continues after failures (no mid-run abort). + +## Preflight +disk: + Filesystem Size Used Avail Use% Mounted on + /dev/nvme0n1p1 3.6T 3.0T 489G 86% / + /dev/nvme0n1p1 3.6T 3.0T 489G 86% / +gpu mem: + memory.used [MiB], memory.free [MiB], memory.total [MiB] + 15 MiB, 32095 MiB, 32607 MiB +prod status: + goethe: running + API: https://100.90.97.111:8443/v1 + API KEY NAME KEY ID + matteo 95f818903035 + + No models loaded. Pick one and load it: + + → goethe models + → goethe load + + Platform: Linked (workspace Personal, heartbeat OK (11 s ago)) +prod listeners: + LISTEN 0 511 127.0.0.1:8443 0.0.0.0:* + LISTEN 0 511 100.90.97.111:8443 0.0.0.0:* + +> Stopping production Goethe for isolated E2E (will restore). + +## 1. Start (fresh home) + +### goethe up + +``` ++ goethe up +``` + +``` +goethe: running +API: https://127.0.0.1:8443/v1 +keys: none, create one with: goethe api keys create my-app + +No models loaded. Pick one and load it: + + → goethe models + → goethe load + +Platform: Not linked (goethe login) +``` + +exit: `0` +**result:** pass + +### goethe status + +``` ++ goethe status +``` + +``` +goethe: running +API: https://127.0.0.1:8443/v1 +keys: none, create one with: goethe api keys create my-app + +No models loaded. Pick one and load it: + + → goethe models + → goethe load + +Platform: Not linked (goethe login) +``` + +exit: `0` +**result:** pass + +### goethe doctor + +``` ++ goethe doctor +``` + +``` +CHECK STATUS DETAIL +hardware OK driver 580.178.04 + gpu0 NVIDIA GeForce RTX 5090 (SM 12.0): 31.3 of 31.8 GB free, 0 foreign processes +platform INFO not logged in: optional; goethe login links this node and unlocks optimised kernels +cloud INFO no cloud provider detected +py-env INFO not set up yet: the first goethe install of a model sets it up (about 30 MB, more for engines) +also OK: driver, glibc, nginx, goethe_home, disk, ram, state_db, environment, ports, goethed, gateway, network, tls, huggingface, registry, nvidia_driver, compiler (goethe -v doctor lists them) + +GPU architectures goethe supports: sm_80 (Ampere data center), sm_86 (Ampere), sm_89 (Ada), sm_90a (Hopper), sm_100a (Blackwell data center), sm_103a (Blackwell Ultra data center), sm_120a (Blackwell), sm_121a (Blackwell) +Architectures of this machine: sm_120a +``` + +exit: `0` +**result:** pass + +### goethe doctor --hardware + +``` ++ goethe doctor --hardware +``` + +``` +Goethe hardware profile at 2026-11-18T21:11:07Z +Driver: 580.178.04 +GPU NAME VRAM TOTAL VRAM FREE PCIE +gpu0 NVIDIA GeForce RTX 5090 31.8 GB 31.3 GB PCIe 5 x16 + SM 12.0 +CPU: Intel(R) Core(TM) Ultra 7 265K (GenuineIntel), 1 socket(s), 20 cores, 20 threads, flags [avx2] +RAM: 125.1 GB total, 119.8 GB available; swap 3.6/8.0 GB free; hugepages 0/0 free (2048 kB) +Disk goethe_home: /home/v/proj/petya/goethe-e2e-180/home on / (ext4) 525 GB free of 3936 GB +Disk models: /home/v/proj/petya/goethe-e2e-180/home/models on / (ext4) 525 GB free of 3936 GB +OS: Ubuntu 24.04.3 LTS, kernel 7.0.0-42-generic, glibc 2.39 +NVIDIA driver 580.178.04, CUDA driver 13.0 +Environment: no container, systemd is PID 1, cloud none +``` + +exit: `0` +**result:** pass + +## 2. CLI surface / help consistency + +### goethe --help + +``` ++ goethe --help +``` + +``` +Goethe: serve models through OpenAI and Anthropic compatible gateways + +Start and stop + goethe the menu: quick setup, install models, API keys and gateway, status + goethe up start Goethe now and at every boot + goethe down stop Goethe; loaded models come back on the next up + goethe status running or not, the API address, keys and served models + goethe ps running models in detail: GPUs, memory, requests, speed + +Models + goethe install MODEL --load download from Hugging Face (or add a folder) and serve it + goethe load MODEL --gpu gpu2 gpu3 serve an installed model on these GPUs + goethe load MODEL --ctx 32768 --save the same, and keep the settings as its defaults + goethe load MODEL --dry-run show where it would go, load nothing + goethe unload MODEL stop serving it (--all stops every model) + goethe remove MODEL unload and delete it + goethe run MODEL try it by hand: chat, one reply, embedding or transcript + goethe models installed and catalog models + goethe models recommend catalog models that fit your GPUs + goethe models scan FOLDER register a folder you put in GOETHE_HOME/models + goethe models alias set fast MODEL a short name clients can use (remove fast drops it) + goethe logs MODEL -f follow a model's log (also goethed or gateway) + +API and access + goethe api the address, the keys and a curl command to try it + goethe api keys list the keys (a menu on a terminal) + goethe api keys create my-app a new key (also --expires 30d --rpm 300 --models ID --admin) + goethe api keys revoke KEY_ID revoke a key + goethe api expose where the API listens and who may connect + goethe api expose vpn --interface wg0 serve a VPN or private network (also local or public) + goethe api allow add 203.0.113.7/32 let a client address in (remove takes it out) + goethe api domain check DOMAIN check that a domain reaches the API + goethe api share 5h --key my-app --allow /32 open a public address for a while (share stop closes it) + +Learning and traces + goethe learn on sessions keep what compaction drops (--model M for one model) + goethe trace on record requests and replies for training (--key K for one key) + +Machine + goethe gpu GPUs live: memory, processes and bandwidth + goethe gpu deny gpu2 keep new models off a GPU (allow gpu2 undoes it) + goethe doctor check the machine and the setup, with a fix for each problem + goethe doctor --hardware the hardware profile: GPUs and links, CPU, RAM, disk, OS + goethe update signed update of Goethe, its engines and kernel packs + goethe uninstall remove Goethe and the models it installed + goethe login link this node to the Goethe platform (optional) + goethe logout unlink it and remove its local credentials + goethe completion install tab completion for your shell + +MODEL is a Hugging Face id, an installed id, an alias or words from a name, for example: + + → goethe install nvidia/Qwen2.5-VL-7B-Instruct-NVFP4 --load +``` + +exit: `0` +**result:** pass + +### goethe api share --help + +``` ++ goethe api share --help +``` + +``` +Open the API on a public address for a while, for chosen API keys; stop closes it. + +Usage: goethe api share [OPTIONS] [DURATION] + +Arguments: + [DURATION] How long to stay open (30m, 5h, 1d; at most 7d), stop to close now, or nothing for the status. + +Options: + --key ... API keys to share (not admin keys), each until DURATION; with stop, the keys to stop sharing. + --allow ... Only these client addresses or ranges may use the keys given, such as 203.0.113.7. + -v, --verbose Show the output of every underlying process (also GOETHE_VERBOSE=1); it is always kept in /logs. + --dangerously-allow-all-inbound Allow every address on the public gateway (0.0.0.0/0). Rate limits still apply. Not with --allow. + --port The public port (default 8444, or the last one used). + -h, --help Print help + +Examples: + + → goethe api share 5h --key my-app --allow /32 + → goethe api share 5h --key my-app --dangerously-allow-all-inbound + → goethe api share (status) + → goethe api share stop + +--allow is who may connect (their public IP: ask them, or https://ifconfig.me on their device). This machine's IP is only the URL goethe prints. Reopening the same keys keeps their last addresses. --dangerously-allow-all-inbound opens to every address (rate limits still apply). Closes when the last key ends. +``` + +exit: `0` +**result:** pass + +### goethe api expose --help + +``` ++ goethe api expose --help +``` + +``` +Who can reach the API: local, vpn, public, or one address or interface. + +Usage: goethe api expose [OPTIONS] [WHERE] + +Arguments: + [WHERE] local, vpn or public; or an address (127.0.0.1, 0.0.0.0, an IP of this host) or an interface such as wg0 to listen on. + +Options: + --interface With vpn or public: the network interface to serve, e.g. wg0; the gateway follows its address. + --ip With vpn or public: a fixed address of this machine to listen on, instead of following an interface. + -v, --verbose Show the output of every underlying process (also GOETHE_VERBOSE=1); it is always kept in /logs. + --allow ... With vpn or public: client ranges to allow (default for vpn: the ranges the network reaches). + --yes Apply without questions (public still refuses 0.0.0.0/0). + --json With no WHERE: the status as JSON. + -h, --help Print help + +Who can reach the API: + + → goethe api expose local (this machine only) + → goethe api expose vpn --interface wg0 + → goethe api expose public --allow 203.0.113.7/32 + +Or listen on one address or interface directly: + + → goethe api expose 0.0.0.0 + → goethe api expose wg0 + +goethe api expose alone shows where the API listens and who may connect. +``` + +exit: `0` +**result:** pass + +### goethe models --help + +``` ++ goethe models --help +``` + +``` +Installed and catalog models; also recommend, scan and alias. + +Usage: goethe models [OPTIONS] + goethe models + +Commands: + recommend Catalog models that fit the free VRAM of the allowed GPUs. + scan Register model folders you downloaded yourself and moved into GOETHE_HOME/models. + alias Short model names for clients: list them, set one, or remove some. + help Print this message or the help of the given subcommand(s) + +Options: + -v, --verbose Show the output of every underlying process (also GOETHE_VERBOSE=1); it is always kept in /logs. + --json Emit JSON. + --installed Only installed models. + --available Only catalog models. + --all Every line; the default stops after 40. + -h, --help Print help +``` + +exit: `0` +**result:** pass + +### goethe run --help + +``` ++ goethe run --help +``` + +``` +Try a model by hand: a chat screen on a terminal without INPUT, else one reply, an embedding summary or an audio file's transcript. Loads an installed model that is not loaded and unloads it again. + +Usage: goethe run [OPTIONS] [MODEL]... + +Arguments: + [MODEL]... [MODEL] [INPUT]: MODEL may be left out when one model is loaded. + +Options: + --keep Leave a model loaded that this command loaded (it is unloaded when run ends otherwise). + --plain No chat screen: the plain prompt, as when input or output is not a terminal. + -v, --verbose Show the output of every underlying process (also GOETHE_VERBOSE=1); it is always kept in /logs. + --thinking Show the model's reasoning (dimmed) with the answer. + -h, --help Print help +``` + +exit: `0` +**result:** pass + +> goethe run has no -p/--prompt; INPUT is positional. CI should not teach -p. + +## 3. What fits + +### goethe models recommend + +``` ++ goethe models recommend +``` + +``` +VRAM free: 31.8 GB + +meshapplied/Qwen3.8-27B-NVFP4-NInfer ctx 100000 concurrency 4 + +Up to 24 GB +MODEL VRAM DOWNLOAD +nvidia/Qwen2.5-VL-7B-Instruct-NVFP4 22.2 GB/GPU · ctx 128000 · 8 conc 7.2 GB +nvidia/Llama-3.1-8B-Instruct-NVFP4 23.4 GB/GPU · ctx 65536 · 8 conc 6.0 GB + +Up to 48 GB +MODEL VRAM DOWNLOAD +nvidia/Qwen3.8-27B-NVFP4 26.8 GB/GPU · ctx 32768 · 8 conc 21.9 GB +microsoft/Phi-4-multimodal-instruct 28.2 GB/GPU · ctx 65536 · 8 conc 12.9 GB +meshapplied/Qwen3.8-27B-NVFP4-NInfer 28.4 GB/GPU · ctx 100000 · 4 conc - +``` + +exit: `0` +**result:** pass + +### goethe models + +``` ++ goethe models +``` + +``` +VRAM free: 31.8 GB + +Up to 24 GB +MODEL STATUS DISK FIT ON THIS MACHINE +nvidia/Qwen2.5-VL-7B-Instruct-NVFP4 available 7.2 GB fits: 22.2 GB per GPU (ctx 128000, 8 concurrent) +nvidia/Llama-3.1-8B-Instruct-NVFP4 available 6.0 GB fits: 23.4 GB per GPU (ctx 65536, 8 concurrent) + +Up to 48 GB +MODEL STATUS DISK FIT ON THIS MACHINE +nvidia/Qwen3.8-27B-NVFP4 (optimised kernels available) available 21.9 GB fits: 26.8 GB per GPU (ctx 32768, 8 concurrent) +microsoft/Phi-4-multimodal-instruct available 12.9 GB fits: 28.2 GB per GPU (ctx 65536, 8 concurrent) +meshapplied/Qwen3.8-27B-NVFP4-NInfer available 28.4 GB fits: 28.4 GB per GPU (ctx 100000, 4 concurrent) + +Too large for the allowed GPUs +MODEL STATUS DISK FIT ON THIS MACHINE +nvidia/Gemma-4-31B-IT-NVFP4 available 32.7 GB does not fit: not enough GPU memory +mistralai/Mistral-Small-3.1-24B-Instruct-2503 available 48.1 GB does not fit: not enough GPU memory +google/gemma-4-26B-A4B-it available 51.6 GB does not fit: not enough GPU memory +Qwen/Qwen3.8-27B available 55.6 GB does not fit: not enough GPU memory +meta-models/Muse-Glimmer-30B available 59.6 GB does not fit: not enough GPU memory +meshapplied/Qwen3.8-Flash-Next-NVFP4-Latest available 132.7 GB does not fit: not enough GPU memory (gated: needs your Hugging Face token or access) +nvidia/Qwen3.8-Flash-Next-NVFP4 available 132.7 GB does not fit: not enough GPU memory +deepseek-ai/DeepSeek-V4-Flash-0731 available 166.9 GB does not fit: not enough GPU memory +XiaomiMiMo/MiMo-V2.6-Flash-RL available 177.8 GB does not fit: not enough GPU memory +orcarouter/Qwen3.8-Flash-Next-Uncensored-NVFP4 available 183.5 GB does not fit: not enough GPU memory (gated: needs your Hugging Face token or access) +RedHatAI/GLM-5.3-Flash-NVFP4 available 197.9 GB does not fit: not enough GPU memory +nvidia/NVIDIA-Nemotron-3.5-Super-VL-120B-A12B-BF16 available 248.9 GB does not fit: not enough GPU memory +nvidia/MiniMax-M3-NVFP4 available 250.1 GB does not fit: not enough GPU memory +nvidia/Qwen3.5-397B-A17B-NVFP4 available 251.2 GB does not fit: not enough GPU memory +inclusionAI/Ling-3.0-flash available 255.0 GB does not fit: not enough GPU memory +Qwen/Qwen3.8-Flash-Next available 360.0 GB does not fit: not enough GPU memory +meshapplied/Qwen3.8-Flash-Next-Ternary-Latest available 391.9 GB does not fit: not enough GPU memory +nvidia/DeepSeek-V3.1-NVFP4 available 413.3 GB does not fit: not enough GPU memory +nvidia/DeepSeek-V3.2-NVFP4 available 415.1 GB does not fit: not enough GPU memory +nvidia/DeepSeek-V3-0324-NVFP4 available 423.7 GB does not fit: not enough GPU memory +nvidia/DeepSeek-R1-NVFP4 available 423.7 GB does not fit: not enough GPU memory +LibertAIDAI/DeepSeek-V4.1-Flash-1017-NVFP4 available 429.0 GB does not fit: not enough GPU memory +nvidia/GLM-5.2-NVFP4 available 464.9 GB does not fit: not enough GPU memory +Qwen/Qwen3-VL-235B-A22B-Instruct available 471.4 GB does not fit: not enough GPU memory +deepseek-ai/DeepSeek-V4.1-Flash-1017 available 510.3 GB does not fit: not enough GPU memory +... 23 more lines; all of them: goethe models --all +``` + +exit: `0` +**result:** pass + +> Compare models vs recommend per-GPU + ctx wording for the same id. + +## 4. Local path model (scan + install from folder) + +### models scan HF-id form (footgun check) + +``` ++ goethe models scan ggml-org/embeddinggemma-2-GGUF +``` + +``` +ggml-org/embeddinggemma-2-GGUF: No such file or directory (os error 2) +``` + +exit: `1` +**result:** pass (HF-id form rejected) + +### models scan folder name --yes + +``` ++ goethe models scan ggml-org__embeddinggemma-2-GGUF --yes +``` + +``` +ggml-org__embeddinggemma-2-GGUF: No such file or directory (os error 2) +``` + +exit: `1` +**result:** FAIL (expected success) + +### models --installed after scan + +``` ++ goethe models --installed +``` + +``` +VRAM free: 31.8 GB +``` + +exit: `0` +**result:** pass + +### install from absolute path --name + +``` ++ goethe install /home/v/proj/petya/goethe-e2e-180/home/models/ggml-org__embeddinggemma-2-GGUF --name ggml-org/embeddinggemma-2-GGUF --yes +``` + +``` +engine installing 0.3.0 (about 5 GB with PyTorch, once) +engine 0.3.0 ready (4.6 GB, 4 s) +ggml-org/embeddinggemma-2-GGUF goethe-engine ctx 1024 0.3 GB + 28 MB/req +files stay in /data/proj/gc/goethe-models/ggml-org__embeddinggemma-2-GGUF (goethe remove only unregisters) +run: goethe run ggml-org/embeddinggemma-2-GGUF +``` + +exit: `0` +**result:** pass + +### models --installed after install path + +``` ++ goethe models --installed +``` + +``` +VRAM free: 31.8 GB + +Installed +MODEL STATUS DISK FIT ON THIS MACHINE +ggml-org/embeddinggemma-2-GGUF (optimised kernels available) installed 0.4 GB fits: 0.9 GB per GPU (ctx 1024, 8 concurrent) +``` + +exit: `0` +**result:** pass + +## 5. API key + tailnet expose (NO lasting public) + +### create key e2e-tailnet + +``` ++ goethe api keys create e2e-tailnet --models ggml-org/embeddinggemma-2-GGUF +``` + +``` +API key for e2e-tailnet (id a62afdf8be04): + + goethe_sk_REDACTED + +goethe api shows it again at any time. +``` + +exit: `0` +**result:** pass + +### captured bearer (redact in shared copies) +``` +goethe_sk_REDACTED +``` + +### expose vpn on tailscale0 with CGNAT allow + +``` ++ goethe api expose vpn --interface tailscale0 --allow 100.64.0.0/10 --yes +``` + +``` +Gateway now: listening on 127.0.0.1 port 8443; allowlist: empty (every client refused) +The gateway will listen on 100.90.97.111 (tailscale0; follows its address) and on 127.0.0.1, and allow 100.64.0.0/10. +gateway listens on 100.90.97.111 (tailscale0; follows its address) port 8443 +allowed 127.0.0.1/32 (this machine) +allowed 100.64.0.0/10 (tailscale0 clients) +API keys: 1 exist (goethe api keys; goethe api keys create for each new client) + +API: https://100.90.97.111:8443/v1 + +For the models and keys run: + + → goethe api +``` + +exit: `0` +**result:** pass + +### goethe api expose (status) + +``` ++ goethe api expose +``` + +``` +bind: 100.90.97.111 (follows tailscale0) (remote clients reach it when allowlisted) +port: 8443 +url: https://100.90.97.111:8443 +state: running +allowlist: 2 entries +``` + +exit: `0` +**result:** pass + +### allowlist shows tailnet + +``` ++ goethe api allow +``` + +``` +ALLOWED CLIENTS +100.64.0.0/10 +127.0.0.1/32 +``` + +exit: `0` +**result:** pass + +### ss after vpn expose + +``` ++ bash -c ss -ltn | grep -E "8443|8444" || true +``` + +``` +LISTEN 0 511 127.0.0.1:8443 0.0.0.0:* +LISTEN 0 511 100.90.97.111:8443 0.0.0.0:* +``` + +exit: `0` + +### public expose without new allow + +``` ++ goethe api expose public --yes +``` + +``` +Gateway now: listening on 100.90.97.111 (following tailscale0) port 8443; allowlist: 100.64.0.0/10, 127.0.0.1/32 +WARNING: exposing the API on a public network is not recommended. + - Anyone who can reach this machine can attempt to connect; only the allowlist and API keys stop them. + - Allow only the client IPs you trust (goethe api allow add /32) and give every client its own key. + - Open the gateway port in your firewall or router yourself; Goethe does not change them. + - The certificate is self-signed, so clients must trust it or skip verification. +Your public IP: 81.182.125.247 -> API: https://81.182.125.247:8443/v1 +This machine is behind NAT (81.182.125.247 is not on its interfaces): forward TCP port 8443 on your router or cloud firewall to it. +goethe api expose: restarting nginx to move the listener from 100.90.97.111 to 0.0.0.0 +goethe api expose: stopping nginx master [3213137] +gateway listens on 0.0.0.0 port 8443 (restarted) +No client addresses were added: only addresses already on the allowlist can connect (goethe api allow add /32). +API keys: 1 exist (goethe api keys; goethe api keys create for each new client) + +API: https://81.182.125.247:8443/v1 + +For the models and keys run: + + → goethe api +``` + +exit: `0` +**result:** FAIL for prod bar — public bind succeeded; allowlist unchanged (0.0.0.0 listen) + +> Reverting to vpn/tailnet immediately after public probe. + +### revert expose vpn after public probe + +``` ++ goethe api expose vpn --interface tailscale0 --allow 100.64.0.0/10 --yes +``` + +``` +Gateway now: listening on 0.0.0.0 port 8443; allowlist: 100.64.0.0/10, 127.0.0.1/32 +The gateway will listen on 100.90.97.111 (tailscale0; follows its address) and on 127.0.0.1, and allow 100.64.0.0/10. +goethe api expose: restarting nginx to move the listener from 0.0.0.0 to 100.90.97.111 +goethe api expose: stopping nginx master [3213913] +gateway listens on 100.90.97.111 (tailscale0; follows its address) port 8443 (restarted) +API keys: 1 exist (goethe api keys; goethe api keys create for each new client) + +API: https://100.90.97.111:8443/v1 + +For the models and keys run: + + → goethe api +``` + +exit: `0` + +### ss after revert + +``` ++ bash -c ss -ltn | grep -E "8443|8444" || true +``` + +``` +LISTEN 0 511 127.0.0.1:8443 0.0.0.0:* +LISTEN 0 511 100.90.97.111:8443 0.0.0.0:* +``` + +exit: `0` +**result:** pass (no 0.0.0.0:8443 after vpn revert) + +### share without --allow + +``` ++ goethe api share 5m --key e2e-tailnet +``` + +``` +name who may connect with --allow /32 (their phone or laptop's public IP, not this machine's). this machine's public address is 81.182.125.247 (that becomes the URL, not --allow); ask them; to open to every address use --dangerously-allow-all-inbound +``` + +exit: `1` +**result:** pass (refused as expected) + +### share with this-machine public IP as --allow + +``` ++ bash -c + IP=$(curl -4 -fsS --max-time 3 ifconfig.me || true) + if [ -z "$IP" ]; then echo "skip: no public ip"; exit 1; fi + goethe api share 5m --key e2e-tailnet --allow "$IP/32" + +``` + +``` +81.182.125.247/32 is this machine's public address (the URL), not who may connect; use their phone or laptop's public IP +``` + +exit: `1` +**result:** pass (refused as expected) + +### share status closed + +``` ++ goethe api share +``` + +``` +The public gateway is closed. Open it with: goethe api share 5h --key --allow /32 +``` + +exit: `0` +**result:** pass + +### ss :8444 must be absent + +``` ++ bash -c ss -ltn | grep 8444 || echo no_8444 +``` + +``` +no_8444 +``` + +exit: `0` + +## 6. Load + run embedding model + +### load dry-run embedding + +``` ++ goethe load ggml-org/embeddinggemma-2-GGUF --dry-run +``` + +``` +would place ggml-org/embeddinggemma-2-GGUF tp=1 on GPU 0 at ctx 1024: 0.9 GB per GPU (weights 0.3 + KV 0.0 + sliding-window KV 0.1 + overhead 0.5) + GPU 0: 31.3 GB free, other software is running there +``` + +exit: `0` +**result:** pass + +### load embedding + +``` ++ goethe load ggml-org/embeddinggemma-2-GGUF +``` + +``` +GPU 0 has unmanaged process PID 2046 (Xorg, user gdm) using 0.0 GB VRAM +Goethe never stops processes it did not start. To stop it yourself: sudo kill 2046 +Free VRAM on GPU 0: 31.3 GB; this load needs 0.9 GB. +Re-run with --yes to load alongside it. +not loading next to processes goethe did not start: re-run with --yes (no terminal to ask on) +``` + +exit: `3` +**result:** FAIL (expected success) + +### goethe ps + +``` ++ goethe ps +``` + +``` +No models loaded. Pick one and load it: + + → goethe models + → goethe load +``` + +exit: `0` +**result:** pass + +### goethe status after load + +``` ++ goethe status +``` + +``` +goethe: running +API: https://100.90.97.111:8443/v1 +API KEY NAME KEY ID +e2e-tailnet a62afdf8be04 + +No models loaded. Pick one and load it: + + → goethe models + → goethe load + +Platform: Not linked (goethe login) +``` + +exit: `0` +**result:** pass + +### goethe run embed positional INPUT + +``` ++ goethe run --plain ggml-org/embeddinggemma-2-GGUF hello greengoblin e2e +``` + +``` +GPU 0 has unmanaged process PID 2046 (Xorg, user gdm) using 0.0 GB VRAM +Goethe never stops processes it did not start. To stop it yourself: sudo kill 2046 +Free VRAM on GPU 0: 31.3 GB; this load needs 0.9 GB. +Re-run with --yes to load alongside it. +not loading next to processes goethe did not start: re-run with --yes (no terminal to ask on) +``` + +exit: `3` +**result:** FAIL + +### goethe run with -- separator (footgun) + +``` ++ goethe run ggml-org/embeddinggemma-2-GGUF -- embed hello +``` + +``` +error: unexpected value 'hello' for '[MODEL]...' found; no more were expected + +Usage: goethe run [OPTIONS] [MODEL]... + +For more information, try '--help'. +``` + +exit: `2` +**result:** pass (bad argv rejected) + +### curl /v1/models via 127.0.0.1 + cacert + +``` ++ curl -sS --max-time 20 --cacert /home/v/proj/petya/goethe-e2e-180/home/nginx/certs/server.crt https://127.0.0.1:8443/v1/models -H Authorization: Bearer goethe_sk_REDACTED +``` + +``` +{"data":[],"object":"list"} +``` + +exit: `0` +**result:** pass + +### curl /v1/models via tailnet IP + cacert + +``` ++ curl -sS --max-time 20 --cacert /home/v/proj/petya/goethe-e2e-180/home/nginx/certs/server.crt https://100.90.97.111:8443/v1/models -H Authorization: Bearer goethe_sk_REDACTED +``` + +``` +curl: (60) SSL: no alternative certificate subject name matches target host name '100.90.97.111' +More details here: https://curl.se/docs/sslcerts.html + +curl failed to verify the legitimacy of the server and therefore could not +establish a secure connection to it. To learn more about this situation and +how to fix it, please visit the web page mentioned above. +``` + +exit: `60` +**result:** FAIL (expected success) + +### curl /v1/embeddings via tailnet + +``` ++ curl -sS --max-time 90 --cacert /home/v/proj/petya/goethe-e2e-180/home/nginx/certs/server.crt https://100.90.97.111:8443/v1/embeddings -H Authorization: Bearer goethe_sk_REDACTED -H Content-Type: application/json -d {"model":"ggml-org/embeddinggemma-2-GGUF","input":"greengoblin e2e"} +``` + +``` +curl: (60) SSL: no alternative certificate subject name matches target host name '100.90.97.111' +More details here: https://curl.se/docs/sslcerts.html + +curl failed to verify the legitimacy of the server and therefore could not +establish a secure connection to it. To learn more about this situation and +how to fix it, please visit the web page mentioned above. +``` + +exit: `60` +**result:** FAIL (expected success) + +### curl embeddings without key +HTTP `000` +``` +``` +**result:** FAIL (expected 401/403, got 000) + +## 7. Chat model (if linked) + +> Llama NVFP4 tree not linked; skipped chat load. + +## 8. More failure / UX probes + +### load missing model + +``` ++ goethe load definitely-missing-model-xyz +``` + +``` +model definitely-missing-model-xyz is not installed (goethe models lists installed models; goethe install definitely-missing-model-xyz adds it) +``` + +exit: `1` +**result:** pass (refused as expected) + +### run missing model + +``` ++ goethe run --plain definitely-missing-model-xyz hi +``` + +``` +definitely-missing-model-xyz is not installed: goethe install definitely-missing-model-xyz +``` + +exit: `1` +**result:** pass (refused as expected) + +### load --dry-run missing + +``` ++ goethe load definitely-missing-model-xyz --dry-run +``` + +``` +model definitely-missing-model-xyz is not installed (goethe models lists installed models; goethe install definitely-missing-model-xyz adds it) +``` + +exit: `1` + +### share dangerously without remembered key + +``` ++ goethe api share 5m --dangerously-allow-all-inbound +``` + +``` +name the API keys to allow with --key (the next time they are remembered); list them with goethe api keys +``` + +exit: `1` +**result:** pass (refused as expected) + +### gpu table + +``` ++ goethe gpu +``` + +``` + + ▣ GPU ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ + gpu0 0.5 GB ░░░░░░░░░░ 31.8 GB 2046 ALLOWED ░░░░░░░░░░ 0% + + █ goethe models █ other processes ░ free █ memory bandwidth +``` + +exit: `0` + +### logs goethed (tail) + +``` ++ bash -c goethe logs goethed 2>&1 | tail -50 +``` + +``` +log not found: /home/v/proj/petya/goethe-e2e-180/home/logs/goethed.log +``` + +exit: `0` + +## 8b. URL consistency + +### goethe status (URLs) + +``` ++ goethe status +``` + +``` +goethe: running +API: https://100.90.97.111:8443/v1 +API KEY NAME KEY ID +e2e-tailnet a62afdf8be04 + +No models loaded. Pick one and load it: + + → goethe models + → goethe load + +Platform: Not linked (goethe login) +``` + +exit: `0` + +### goethe api (URLs) + +``` ++ goethe api +``` + +``` +API endpoint: https://100.90.97.111:8443/v1 +SSL_CERT_FILE=/home/v/proj/petya/goethe-e2e-180/home/nginx/certs/server.crt +Accepts: OpenAI, Anthropic (/v1/messages) and LiteLLM (routes with or without /v1, x-litellm-api-key) + +API keys +NAME API KEY ADMIN EXPIRES +e2e-tailnet goethe_sk_REDACTED no never + +Query the API: + + → curl --cacert /home/v/proj/petya/goethe-e2e-180/home/nginx/certs/server.crt https://100.90.97.111:8443/v1/chat/completions -H "Authorization: Bearer " -H "Content-Type: application/json" -d '{"model": "", "messages": [{"role": "user", "content": "Hello!"}]}' +``` + +exit: `0` + +### goethe api expose + +``` ++ goethe api expose +``` + +``` +bind: 100.90.97.111 (follows tailscale0) (remote clients reach it when allowlisted) +port: 8443 +url: https://100.90.97.111:8443 +state: running +allowlist: 2 entries +``` + +exit: `0` + +## 9. Cleanup on box + +### unload all + +``` ++ goethe unload --all +``` + +``` +nothing was loaded +``` + +exit: `0` + +### expose local + +``` ++ goethe api expose local --yes +``` + +``` +Gateway now: listening on 100.90.97.111 (following tailscale0) port 8443; allowlist: 100.64.0.0/10, 127.0.0.1/32 +gateway listens on 127.0.0.1 port 8443 +API keys: 1 exist (goethe api keys; goethe api keys create for each new client) + +API: https://127.0.0.1:8443/v1 + +For the models and keys run: + + → goethe api +``` + +exit: `0` + +### share stop + +``` ++ goethe api share stop +``` + +``` +The public gateway is not open. +``` + +exit: `0` + +### goethe down (e2e) + +``` ++ goethe down +``` + +``` +goethed stopped +goethed will not start at boot until the next goethe up +``` + +exit: `0` + +### ss after e2e down + +``` ++ bash -c ss -ltn | grep -E "8443|8444" || echo none +``` + +``` +none +``` + +exit: `0` + +> Restoring production Goethe. + +> Prod not on 0.0.0.0:8443 + +## Scoreboard + +- Passes: **33** +- Failures / unexpected: **7** +- Full command log: `/home/v/proj/petya/goethe-e2e-180/session.log` +- Isolated home: `/home/v/proj/petya/goethe-e2e-180/home` — delete when done: `rm -rf /home/v/proj/petya/goethe-e2e-180` + +## Findings (observed, not softened) + +1. UX footgun: users typing HF id into models scan get os error 2; hint should say use folder name org__name or goethe install +2. FAIL ok: models scan folder name --yes +3. api expose public --yes binds 0.0.0.0 without requiring a public client allow; only warns. Listener is world-reachable if NAT/firewall forwards; nginx allowlist may still drop non-listed clients. +4. FAIL ok: load embedding +5. goethe run --plain embed INPUT failed (exit 3) +6. UX: goethe run does not take -- extra args; clap error is opaque for users copying engine-flag patterns +7. FAIL ok: curl /v1/models via tailnet IP + cacert +8. FAIL ok: curl /v1/embeddings via tailnet +9. embeddings without bearer returned HTTP 000 (expected 401/403) + +## CI / follow-up test ideas + +1. Assert `goethe models scan org/name` fails with a hint to use `org__name` folder form. +2. Assert `goethe api expose public --yes` either refuses without a non-VPN client allow, or never binds `0.0.0.0` unless `--dangerously-allow-all-inbound` (product decision). +3. After any public probe in E2E, assert `ss` has no `0.0.0.0:8443` / `:8444`. +4. `goethe run --plain ` happy path for embed + chat; reject teaching `run -- -p`. +5. Curl `/v1/models` and `/v1/embeddings` with cacert over tailnet IP; 401 without bearer. +6. Share: machine public IP as `--allow` must refuse; no `--allow` must refuse. +7. Script must not `set -e` across soft failures (v1 aborted mid-session). + + +## Findings (refined after follow-up — zero gaslight) + +### P0 / product + +1. **`goethe api expose public --yes` binds `0.0.0.0` without requiring a public client allow.** It keeps the existing VPN allowlist and only warns. Nginx may still drop non-allowlisted clients, but the socket is world-reachable if NAT/firewall forwards. Prod bar decision needed: refuse unless a non-VPN client CIDR is supplied, or require `--dangerously-allow-all-inbound` to bind `0.0.0.0`. + +2. **Gateway TLS cert SANs omit the tailnet IP.** Observed SANs: `DNS:localhost`, `IP:127.0.0.1`, `DNS:greengoblin`. **No `100.90.97.111`.** `goethe api` tells users to `curl --cacert … https://100.90.97.111:8443/…` which **fails with curl 60** (name mismatch). Localhost with cacert works. Users must `-k` today — docs/UX lie by omission. + +### P1 / real user footguns + +3. **`goethe models scan ` resolves the argument from CWD via `canonicalize`, not from `GOETHE_HOME/models`.** Passing `ggml-org__embeddinggemma-2-GGUF` as the help text suggests yields `No such file or directory (os error 2)` unless that name exists in the current working directory. Code: `scan.rs` `candidate_dirs`. Fix: try `models.join(d)` before raw `d`. + +4. **`goethe models scan` (no args) refuses a symlink under models/** with “register the folder it points to with `goethe install `”. Symlinking an already-installed tree into a fresh `GOETHE_HOME` (isolated / multi-home) does not work via scan. **`goethe install --name …` works** (creates a symlink farm). Document this; optionally teach scan to follow+register like install. + +5. **Non-interactive `goethe load` / `goethe run` refuse GPU 0 when Xorg/gdm holds 0.0 GB VRAM** unless `--yes`. Message is clear. Scripts/SSH/CI without a TTY always need `--yes` on boxes with a display manager. E2E must pass `--yes`. + +6. **`goethe run` INPUT is positional; there is no `-p` / `--` engine-flag passthrough.** `goethe run model -- embed hi` → opaque clap error. Users copying install/`--` patterns get confused. + +### P2 / isolation & ops + +7. **Second `GOETHE_HOME` while systemd user unit owns another home:** `goethe up` warns and may pick **18443** (see `ports.rs` 18443–18499) instead of 8443. Heartbeat unit stays on prod home. Isolated E2E must `goethe down` prod **and** account for port shift, or disable the other unit. Follow-up accidentally curled 8443 while e2e listened on 18443. + +8. **v1 E2E script aborted mid-run** because `run()` re-enabled `set -e` and a bare failing command exited the script before cleanup/scoreboard. Fixed in v2. + +### What worked + +- Isolated `GOETHE_HOME` + PR180 binary `0.3.3` build on greengoblin. +- `goethe up` / `status` / `doctor` / `doctor --hardware`. +- `models recommend` + `models` fit labels with per-GPU / ctx / concurrency. +- `goethe install --name ggml-org/embeddinggemma-2-GGUF --yes` registers local tree. +- Tailnet expose: `api expose vpn --interface tailscale0 --allow 100.64.0.0/10 --yes` → listen `100.90.97.111:8443` + `127.0.0.1`, allowlist CGNAT + localhost. +- Share without `--allow` refuses; machine public IP as `--allow` refuses; no `:8444`. +- After public probe, vpn revert cleared `0.0.0.0:8443`. +- **Follow-up:** `load --yes` + `run --plain --keep` embedding → `dims=768 norm=1.0000 […]` success. +- localhost `/v1/models` with bearer + cacert → JSON list (empty when unloaded). +- Missing model load/run refuse cleanly. +- Prod restored: `100.90.97.111:8443` + `127.0.0.1:8443`, not public; heartbeat OK; key `matteo` intact. + +### Not covered this session + +- Chat/Llama load: no Llama tree under prod `models/` (only embeddinggemma). +- True multi-client curl from another tailnet node (this runner used on-box curls). +- Public share happy path (intentionally out of scope — fail-closed only). +- Kernel-pack / ternary / ninfer paths. + +### Box state after session + +- Prod goethe **0.3.1** running, tailnet bind only. +- E2E home left at `/home/v/proj/petya/goethe-e2e-180` for inspection (safe to `rm -rf`). +- No e2e `goethed` left running. + +## Incident closeout (public 0.0.0.0) + +- **Now:** CLOSED. Prod listens only `100.90.97.111:8443` + `127.0.0.1:8443`. No `:8444`. No e2e daemon. +- **Attack evidence:** e2e nginx access log had only `127.0.0.1`. Prod Nov 18 access was only tailnet `100.x` (our follow-up curls, 401). No foreign public IPs. +- **Why not internet-wide open in practice:** (1) NAT: public IP `81.182.125.247` is not on any iface; inbound needs router forward. (2) nginx allowlist stayed `100.64.0.0/10` + `127.0.0.1` (deny all else). (3) API key still required. **Still wrong:** LAN `192.168.1.134:8443` could accept SYNs while bound to `0.0.0.0` (would then hit deny/401). +- **Windows:** v2 ~5s (`22:11:23` to `22:11:28`). v1 aborted without auto-revert until manual `goethe down` (~1 min class). +- **Fix shipped:** `expose public --yes` without `--allow` refuses; raw `expose 0.0.0.0` refuses; public needs confirm + named clients; `--dangerously-allow-all-inbound` hidden for world-open. diff --git a/docs/e2e-traces/TRACE-v1-aborted.md b/docs/e2e-traces/TRACE-v1-aborted.md new file mode 100644 index 00000000..594a3945 --- /dev/null +++ b/docs/e2e-traces/TRACE-v1-aborted.md @@ -0,0 +1,704 @@ +# Goethe PR180 greengoblin E2E session + +- **When (UTC):** 2026-11-18T21:07:05Z +- **Host:** greengoblin +- **Binary:** `/home/v/proj/petya/goethe-pr180/engine/target/release/goethe` (`goethe 0.3.3`) +- **GOETHE_HOME (isolated):** `/home/v/proj/petya/goethe-e2e-180/home` +- **Prod goethe (restored after):** `/home/v/.local/bin/goethe` +- **Scope:** install/scan local path, fit, load, run (chat + embed), CLI, tailnet expose only — **no public share** +- **GPU:** GPU 0: NVIDIA GeForce RTX 5090 (UUID: GPU-aaabe7a6-e328-9869-cca8-a8e56a3d4591) + +## Method + +Isolated `GOETHE_HOME` so the live 0.3.x install is not mutated. Production `goethe` is stopped for the session (port/GPU), then started again. Findings are written as observed — not softened. + +## Preflight +disk: + Filesystem Size Used Avail Use% Mounted on + /dev/nvme0n1p1 3.6T 3.0T 489G 86% / + /dev/nvme0n1p1 3.6T 3.0T 489G 86% / +gpu mem: + memory.used [MiB], memory.free [MiB], memory.total [MiB] + 15 MiB, 32095 MiB, 32607 MiB +prod status: + goethe: running + API: https://100.90.97.111:8443/v1 + API KEY NAME KEY ID + matteo 95f818903035 + + No models loaded. Pick one and load it: + + → goethe models + → goethe load + + Platform: Linked (workspace Personal, heartbeat OK (10 s ago)) +share (prod binary may lack subcommand): + The public gateway is closed. Open it with: goethe api share 5h --key + +> Stopping production Goethe for isolated E2E (will restore). + +## 1. Start (fresh home) + +### goethe up + +``` ++ goethe up +``` + +``` +goethe: running +API: https://127.0.0.1:8443/v1 +keys: none, create one with: goethe api keys create my-app + +No models loaded. Pick one and load it: + + → goethe models + → goethe load + +Platform: Not linked (goethe login) +``` + +exit: `0` +**result:** pass + +### goethe status + +``` ++ goethe status +``` + +``` +goethe: running +API: https://127.0.0.1:8443/v1 +keys: none, create one with: goethe api keys create my-app + +No models loaded. Pick one and load it: + + → goethe models + → goethe load + +Platform: Not linked (goethe login) +``` + +exit: `0` +**result:** pass + +### goethe doctor + +``` ++ goethe doctor +``` + +``` +CHECK STATUS DETAIL +hardware OK driver 580.178.04 + gpu0 NVIDIA GeForce RTX 5090 (SM 12.0): 31.3 of 31.8 GB free, 0 foreign processes +platform INFO not logged in: optional; goethe login links this node and unlocks optimised kernels +cloud INFO no cloud provider detected +py-env INFO not set up yet: the first goethe install of a model sets it up (about 30 MB, more for engines) +also OK: driver, glibc, nginx, goethe_home, disk, ram, state_db, environment, ports, goethed, gateway, network, tls, huggingface, registry, nvidia_driver, compiler (goethe -v doctor lists them) + +GPU architectures goethe supports: sm_80 (Ampere data center), sm_86 (Ampere), sm_89 (Ada), sm_90a (Hopper), sm_100a (Blackwell data center), sm_103a (Blackwell Ultra data center), sm_120a (Blackwell), sm_121a (Blackwell) +Architectures of this machine: sm_120a +``` + +exit: `0` +**result:** pass + +### goethe doctor --hardware + +``` ++ goethe doctor --hardware +``` + +``` +Goethe hardware profile at 2026-11-18T21:07:13Z +Driver: 580.178.04 +GPU NAME VRAM TOTAL VRAM FREE PCIE +gpu0 NVIDIA GeForce RTX 5090 31.8 GB 31.3 GB PCIe 5 x16 + SM 12.0 +CPU: Intel(R) Core(TM) Ultra 7 265K (GenuineIntel), 1 socket(s), 20 cores, 20 threads, flags [avx2] +RAM: 125.1 GB total, 119.7 GB available; swap 3.6/8.0 GB free; hugepages 0/0 free (2048 kB) +Disk goethe_home: /home/v/proj/petya/goethe-e2e-180/home on / (ext4) 525 GB free of 3936 GB +Disk models: /home/v/proj/petya/goethe-e2e-180/home/models on / (ext4) 525 GB free of 3936 GB +OS: Ubuntu 24.04.3 LTS, kernel 7.0.0-42-generic, glibc 2.39 +NVIDIA driver 580.178.04, CUDA driver 13.0 +Environment: no container, systemd is PID 1, cloud none +``` + +exit: `0` +**result:** pass + +## 2. CLI surface / help consistency + +### goethe --help + +``` ++ goethe --help +``` + +``` +Goethe: serve models through OpenAI and Anthropic compatible gateways + +Start and stop + goethe the menu: quick setup, install models, API keys and gateway, status + goethe up start Goethe now and at every boot + goethe down stop Goethe; loaded models come back on the next up + goethe status running or not, the API address, keys and served models + goethe ps running models in detail: GPUs, memory, requests, speed + +Models + goethe install MODEL --load download from Hugging Face (or add a folder) and serve it + goethe load MODEL --gpu gpu2 gpu3 serve an installed model on these GPUs + goethe load MODEL --ctx 32768 --save the same, and keep the settings as its defaults + goethe load MODEL --dry-run show where it would go, load nothing + goethe unload MODEL stop serving it (--all stops every model) + goethe remove MODEL unload and delete it + goethe run MODEL try it by hand: chat, one reply, embedding or transcript + goethe models installed and catalog models + goethe models recommend catalog models that fit your GPUs + goethe models scan FOLDER register a folder you put in GOETHE_HOME/models + goethe models alias set fast MODEL a short name clients can use (remove fast drops it) + goethe logs MODEL -f follow a model's log (also goethed or gateway) + +API and access + goethe api the address, the keys and a curl command to try it + goethe api keys list the keys (a menu on a terminal) + goethe api keys create my-app a new key (also --expires 30d --rpm 300 --models ID --admin) + goethe api keys revoke KEY_ID revoke a key + goethe api expose where the API listens and who may connect + goethe api expose vpn --interface wg0 serve a VPN or private network (also local or public) + goethe api allow add 203.0.113.7/32 let a client address in (remove takes it out) + goethe api domain check DOMAIN check that a domain reaches the API + goethe api share 5h --key my-app --allow /32 open a public address for a while (share stop closes it) + +Learning and traces + goethe learn on sessions keep what compaction drops (--model M for one model) + goethe trace on record requests and replies for training (--key K for one key) + +Machine + goethe gpu GPUs live: memory, processes and bandwidth + goethe gpu deny gpu2 keep new models off a GPU (allow gpu2 undoes it) + goethe doctor check the machine and the setup, with a fix for each problem + goethe doctor --hardware the hardware profile: GPUs and links, CPU, RAM, disk, OS + goethe update signed update of Goethe, its engines and kernel packs + goethe uninstall remove Goethe and the models it installed + goethe login link this node to the Goethe platform (optional) + goethe logout unlink it and remove its local credentials + goethe completion install tab completion for your shell + +MODEL is a Hugging Face id, an installed id, an alias or words from a name, for example: + + → goethe install nvidia/Qwen2.5-VL-7B-Instruct-NVFP4 --load +``` + +exit: `0` +**result:** pass + +### goethe api share --help + +``` ++ goethe api share --help +``` + +``` +Open the API on a public address for a while, for chosen API keys; stop closes it. + +Usage: goethe api share [OPTIONS] [DURATION] + +Arguments: + [DURATION] How long to stay open (30m, 5h, 1d; at most 7d), stop to close now, or nothing for the status. + +Options: + --key ... API keys to share (not admin keys), each until DURATION; with stop, the keys to stop sharing. + --allow ... Only these client addresses or ranges may use the keys given, such as 203.0.113.7. + -v, --verbose Show the output of every underlying process (also GOETHE_VERBOSE=1); it is always kept in /logs. + --dangerously-allow-all-inbound Allow every address on the public gateway (0.0.0.0/0). Rate limits still apply. Not with --allow. + --port The public port (default 8444, or the last one used). + -h, --help Print help + +Examples: + + → goethe api share 5h --key my-app --allow /32 + → goethe api share 5h --key my-app --dangerously-allow-all-inbound + → goethe api share (status) + → goethe api share stop + +--allow is who may connect (their public IP: ask them, or https://ifconfig.me on their device). This machine's IP is only the URL goethe prints. Reopening the same keys keeps their last addresses. --dangerously-allow-all-inbound opens to every address (rate limits still apply). Closes when the last key ends. +``` + +exit: `0` +**result:** pass + +### goethe api expose --help + +``` ++ goethe api expose --help +``` + +``` +Who can reach the API: local, vpn, public, or one address or interface. + +Usage: goethe api expose [OPTIONS] [WHERE] + +Arguments: + [WHERE] local, vpn or public; or an address (127.0.0.1, 0.0.0.0, an IP of this host) or an interface such as wg0 to listen on. + +Options: + --interface With vpn or public: the network interface to serve, e.g. wg0; the gateway follows its address. + --ip With vpn or public: a fixed address of this machine to listen on, instead of following an interface. + -v, --verbose Show the output of every underlying process (also GOETHE_VERBOSE=1); it is always kept in /logs. + --allow ... With vpn or public: client ranges to allow (default for vpn: the ranges the network reaches). + --yes Apply without questions (public still refuses 0.0.0.0/0). + --json With no WHERE: the status as JSON. + -h, --help Print help + +Who can reach the API: + + → goethe api expose local (this machine only) + → goethe api expose vpn --interface wg0 + → goethe api expose public --allow 203.0.113.7/32 + +Or listen on one address or interface directly: + + → goethe api expose 0.0.0.0 + → goethe api expose wg0 + +goethe api expose alone shows where the API listens and who may connect. +``` + +exit: `0` +**result:** pass + +### goethe models --help + +``` ++ goethe models --help +``` + +``` +Installed and catalog models; also recommend, scan and alias. + +Usage: goethe models [OPTIONS] + goethe models + +Commands: + recommend Catalog models that fit the free VRAM of the allowed GPUs. + scan Register model folders you downloaded yourself and moved into GOETHE_HOME/models. + alias Short model names for clients: list them, set one, or remove some. + help Print this message or the help of the given subcommand(s) + +Options: + -v, --verbose Show the output of every underlying process (also GOETHE_VERBOSE=1); it is always kept in /logs. + --json Emit JSON. + --installed Only installed models. + --available Only catalog models. + --all Every line; the default stops after 40. + -h, --help Print help +``` + +exit: `0` +**result:** pass + +### goethe run --help + +``` ++ goethe run --help +``` + +``` +Try a model by hand: a chat screen on a terminal without INPUT, else one reply, an embedding summary or an audio file's transcript. Loads an installed model that is not loaded and unloads it again. + +Usage: goethe run [OPTIONS] [MODEL]... + +Arguments: + [MODEL]... [MODEL] [INPUT]: MODEL may be left out when one model is loaded. + +Options: + --keep Leave a model loaded that this command loaded (it is unloaded when run ends otherwise). + --plain No chat screen: the plain prompt, as when input or output is not a terminal. + -v, --verbose Show the output of every underlying process (also GOETHE_VERBOSE=1); it is always kept in /logs. + --thinking Show the model's reasoning (dimmed) with the answer. + -h, --help Print help +``` + +exit: `0` +**result:** pass + +## 3. What fits + +### goethe models recommend + +``` ++ goethe models recommend +``` + +``` +VRAM free: 31.8 GB + +meshapplied/Qwen3.8-27B-NVFP4-NInfer ctx 100000 concurrency 4 + +Up to 24 GB +MODEL VRAM DOWNLOAD +nvidia/Qwen2.5-VL-7B-Instruct-NVFP4 22.2 GB/GPU · ctx 128000 · 8 conc 7.2 GB +nvidia/Llama-3.1-8B-Instruct-NVFP4 23.4 GB/GPU · ctx 65536 · 8 conc 6.0 GB + +Up to 48 GB +MODEL VRAM DOWNLOAD +nvidia/Qwen3.8-27B-NVFP4 26.8 GB/GPU · ctx 32768 · 8 conc 21.9 GB +microsoft/Phi-4-multimodal-instruct 28.2 GB/GPU · ctx 65536 · 8 conc 12.9 GB +meshapplied/Qwen3.8-27B-NVFP4-NInfer 28.4 GB/GPU · ctx 100000 · 4 conc - +``` + +exit: `0` +**result:** pass + +### goethe models + +``` ++ goethe models +``` + +``` +VRAM free: 31.8 GB + +Up to 24 GB +MODEL STATUS DISK FIT ON THIS MACHINE +nvidia/Qwen2.5-VL-7B-Instruct-NVFP4 available 7.2 GB fits: 22.2 GB per GPU (ctx 128000, 8 concurrent) +nvidia/Llama-3.1-8B-Instruct-NVFP4 available 6.0 GB fits: 23.4 GB per GPU (ctx 65536, 8 concurrent) + +Up to 48 GB +MODEL STATUS DISK FIT ON THIS MACHINE +nvidia/Qwen3.8-27B-NVFP4 (optimised kernels available) available 21.9 GB fits: 26.8 GB per GPU (ctx 32768, 8 concurrent) +microsoft/Phi-4-multimodal-instruct available 12.9 GB fits: 28.2 GB per GPU (ctx 65536, 8 concurrent) +meshapplied/Qwen3.8-27B-NVFP4-NInfer available 28.4 GB fits: 28.4 GB per GPU (ctx 100000, 4 concurrent) + +Too large for the allowed GPUs +MODEL STATUS DISK FIT ON THIS MACHINE +nvidia/Gemma-4-31B-IT-NVFP4 available 32.7 GB does not fit: not enough GPU memory +mistralai/Mistral-Small-3.1-24B-Instruct-2503 available 48.1 GB does not fit: not enough GPU memory +google/gemma-4-26B-A4B-it available 51.6 GB does not fit: not enough GPU memory +Qwen/Qwen3.8-27B available 55.6 GB does not fit: not enough GPU memory +meta-models/Muse-Glimmer-30B available 59.6 GB does not fit: not enough GPU memory +meshapplied/Qwen3.8-Flash-Next-NVFP4-Latest available 132.7 GB does not fit: not enough GPU memory (gated: needs your Hugging Face token or access) +nvidia/Qwen3.8-Flash-Next-NVFP4 available 132.7 GB does not fit: not enough GPU memory +deepseek-ai/DeepSeek-V4-Flash-0731 available 166.9 GB does not fit: not enough GPU memory +XiaomiMiMo/MiMo-V2.6-Flash-RL available 177.8 GB does not fit: not enough GPU memory +orcarouter/Qwen3.8-Flash-Next-Uncensored-NVFP4 available 183.5 GB does not fit: not enough GPU memory (gated: needs your Hugging Face token or access) +RedHatAI/GLM-5.3-Flash-NVFP4 available 197.9 GB does not fit: not enough GPU memory +nvidia/NVIDIA-Nemotron-3.5-Super-VL-120B-A12B-BF16 available 248.9 GB does not fit: not enough GPU memory +nvidia/MiniMax-M3-NVFP4 available 250.1 GB does not fit: not enough GPU memory +nvidia/Qwen3.5-397B-A17B-NVFP4 available 251.2 GB does not fit: not enough GPU memory +inclusionAI/Ling-3.0-flash available 255.0 GB does not fit: not enough GPU memory +Qwen/Qwen3.8-Flash-Next available 360.0 GB does not fit: not enough GPU memory +meshapplied/Qwen3.8-Flash-Next-Ternary-Latest available 391.9 GB does not fit: not enough GPU memory +nvidia/DeepSeek-V3.1-NVFP4 available 413.3 GB does not fit: not enough GPU memory +nvidia/DeepSeek-V3.2-NVFP4 available 415.1 GB does not fit: not enough GPU memory +nvidia/DeepSeek-V3-0324-NVFP4 available 423.7 GB does not fit: not enough GPU memory +nvidia/DeepSeek-R1-NVFP4 available 423.7 GB does not fit: not enough GPU memory +LibertAIDAI/DeepSeek-V4.1-Flash-1017-NVFP4 available 429.0 GB does not fit: not enough GPU memory +nvidia/GLM-5.2-NVFP4 available 464.9 GB does not fit: not enough GPU memory +Qwen/Qwen3-VL-235B-A22B-Instruct available 471.4 GB does not fit: not enough GPU memory +deepseek-ai/DeepSeek-V4.1-Flash-1017 available 510.3 GB does not fit: not enough GPU memory +... 23 more lines; all of them: goethe models --all +``` + +exit: `0` +**result:** pass + +> Check whether models vs recommend show comparable per-GPU + ctx lines for the same id. + +## 4. Local path model (scan + install from folder) + +### goethe models scan models/ggml-org__embeddinggemma-2-GGUF + +``` ++ goethe models scan ggml-org/embeddinggemma-2-GGUF +``` + +``` +ggml-org/embeddinggemma-2-GGUF: No such file or directory (os error 2) +``` + +exit: `1` +**result:** FAIL (expected success) + +### goethe models --installed + +``` ++ goethe models --installed +``` + +``` +VRAM free: 31.8 GB +``` + +exit: `0` +**result:** pass + +## 5. API key + tailnet expose (NO public) + +### create key e2e-tailnet + +``` ++ goethe api keys create e2e-tailnet --models ggml-org/embeddinggemma-2-GGUF +``` + +``` +API key for e2e-tailnet (id d5be91cb0cc5): + + goethe_sk_REDACTED + +goethe api shows it again at any time. +``` + +exit: `0` +**result:** pass + +### goethe api (capture) +``` +API endpoint: https://127.0.0.1:8443/v1 +SSL_CERT_FILE=/home/v/proj/petya/goethe-e2e-180/home/nginx/certs/server.crt +Accepts: OpenAI, Anthropic (/v1/messages) and LiteLLM (routes with or without /v1, x-litellm-api-key) + +API keys +NAME API KEY ADMIN EXPIRES +e2e-tailnet goethe_sk_REDACTED no never + +The allowlist is empty, so every client is refused. Allow one with: + + → goethe api allow add /32 + +Query the API: + + → curl --cacert /home/v/proj/petya/goethe-e2e-180/home/nginx/certs/server.crt https://127.0.0.1:8443/v1/chat/completions -H "Authorization: Bearer " -H "Content-Type: application/json" -d '{"model": "", "messages": [{"role": "user", "content": "Hello!"}]}' +``` + +### keys list +``` +NAME KEY ID ADMIN RPM EXPIRES MODELS TODAY +e2e-tailnet d5be91cb0cc5 no 120 never ggml-org/embeddinggemma-2-GGUF 0 req, 0 tok +``` + +### expose vpn on tailscale0 with CGNAT allow + +``` ++ goethe api expose vpn --interface tailscale0 --allow 100.64.0.0/10 --yes +``` + +``` +Gateway now: listening on 127.0.0.1 port 8443; allowlist: empty (every client refused) +The gateway will listen on 100.90.97.111 (tailscale0; follows its address) and on 127.0.0.1, and allow 100.64.0.0/10. +gateway listens on 100.90.97.111 (tailscale0; follows its address) port 8443 +allowed 127.0.0.1/32 (this machine) +allowed 100.64.0.0/10 (tailscale0 clients) +API keys: 1 exist (goethe api keys; goethe api keys create for each new client) + +API: https://100.90.97.111:8443/v1 + +For the models and keys run: + + → goethe api +``` + +exit: `0` +**result:** pass + +### goethe api expose (status) + +``` ++ goethe api expose +``` + +``` +bind: 100.90.97.111 (follows tailscale0) (remote clients reach it when allowlisted) +port: 8443 +url: https://100.90.97.111:8443 +state: running +allowlist: 2 entries +``` + +exit: `0` +**result:** pass + +### allowlist shows tailnet + +``` ++ goethe api allow +``` + +``` +ALLOWED CLIENTS +100.64.0.0/10 +127.0.0.1/32 +``` + +exit: `0` +**result:** pass + +### public expose without --allow should refuse or warn + +``` ++ goethe api expose public --yes +``` + +``` +Gateway now: listening on 100.90.97.111 (following tailscale0) port 8443; allowlist: 100.64.0.0/10, 127.0.0.1/32 +WARNING: exposing the API on a public network is not recommended. + - Anyone who can reach this machine can attempt to connect; only the allowlist and API keys stop them. + - Allow only the client IPs you trust (goethe api allow add /32) and give every client its own key. + - Open the gateway port in your firewall or router yourself; Goethe does not change them. + - The certificate is self-signed, so clients must trust it or skip verification. +Your public IP: 81.182.125.247 -> API: https://81.182.125.247:8443/v1 +This machine is behind NAT (81.182.125.247 is not on its interfaces): forward TCP port 8443 on your router or cloud firewall to it. +goethe api expose: restarting nginx to move the listener from 100.90.97.111 to 0.0.0.0 +goethe api expose: stopping nginx master [3210154] +gateway listens on 0.0.0.0 port 8443 (restarted) +No client addresses were added: only addresses already on the allowlist can connect (goethe api allow add /32). +API keys: 1 exist (goethe api keys; goethe api keys create for each new client) + +API: https://81.182.125.247:8443/v1 + +For the models and keys run: + + → goethe api +``` + +exit: `0` +**result:** FAIL (expected refusal) + +### share without --allow / remembered grant + +``` ++ goethe api share 5m --key e2e-tailnet +``` + +``` +name who may connect with --allow /32 (their phone or laptop's public IP, not this machine's). this machine's public address is 81.182.125.247 (that becomes the URL, not --allow); ask them; to open to every address use --dangerously-allow-all-inbound +``` + +exit: `1` +**result:** pass (refused as expected) + +### share with this-machine IP as --allow (if public IP known) + +``` ++ bash -c IP=$(curl -4 -fsS --max-time 3 ifconfig.me || true); if [ -n "$IP" ]; then goethe api share 5m --key e2e-tailnet --allow "$IP/32"; else echo "skip: no public ip"; exit 1; fi +``` + +``` +81.182.125.247/32 is this machine's public address (the URL), not who may connect; use their phone or laptop's public IP +``` + +exit: `1` +**result:** pass (refused as expected) + +### share status (should be closed) + +``` ++ goethe api share +``` + +``` +The public gateway is closed. Open it with: goethe api share 5h --key --allow /32 +``` + +exit: `0` +**result:** pass + +> Confirm no :8444 listener + +### ss public ports + +``` ++ bash -c ss -ltn | grep 8444 || echo no_8444 +``` + +``` +no_8444 +``` + +exit: `0` + +## 6. Load + run embedding model + +### load dry-run embedding + +``` ++ goethe load ggml-org/embeddinggemma-2-GGUF --dry-run +``` + +``` +model ggml-org/embeddinggemma-2-GGUF is not installed (goethe models lists installed models; goethe install ggml-org/embeddinggemma-2-GGUF adds it) +``` + +exit: `1` +**result:** FAIL (expected success) + +### load embedding + +``` ++ goethe load ggml-org/embeddinggemma-2-GGUF +``` + +``` +model ggml-org/embeddinggemma-2-GGUF is not installed (goethe models lists installed models; goethe install ggml-org/embeddinggemma-2-GGUF adds it) +``` + +exit: `1` +**result:** FAIL (expected success) + +### goethe ps + +``` ++ goethe ps +``` + +``` +No models loaded. Pick one and load it: + + → goethe models + → goethe load +``` + +exit: `0` +**result:** pass + +### goethe status after load + +``` ++ goethe status +``` + +``` +goethe: running +API: https://127.0.0.1:8443/v1 +API KEY NAME KEY ID +e2e-tailnet d5be91cb0cc5 + +No models loaded. Pick one and load it: + + → goethe models + → goethe load + +Platform: Not linked (goethe login) +``` + +exit: `0` +**result:** pass + +### goethe run embed (prompt) + +``` ++ goethe run ggml-org/embeddinggemma-2-GGUF -- embed hello greengoblin e2e +``` + +``` +error: unexpected value 'hello greengoblin e2e' for '[MODEL]...' found; no more were expected + +Usage: goethe run [OPTIONS] [MODEL]... + +For more information, try '--help'. +``` + +exit: `2` diff --git a/docs/e2e-traces/console-v2.txt b/docs/e2e-traces/console-v2.txt new file mode 100644 index 00000000..6a990b9b --- /dev/null +++ b/docs/e2e-traces/console-v2.txt @@ -0,0 +1,609 @@ +NOTE: Stopping production Goethe for isolated E2E (will restore). +goethed stopped +goethed will not start at boot until the next goethe up + +==> goethe up ++ goethe up + goethe: running + API: https://127.0.0.1:8443/v1 + keys: none, create one with: goethe api keys create my-app + + No models loaded. Pick one and load it: + + → goethe models + → goethe load + + Platform: Not linked (goethe login) + +==> goethe status ++ goethe status + goethe: running + API: https://127.0.0.1:8443/v1 + keys: none, create one with: goethe api keys create my-app + + No models loaded. Pick one and load it: + + → goethe models + → goethe load + + Platform: Not linked (goethe login) + +==> goethe doctor ++ goethe doctor + CHECK STATUS DETAIL + hardware OK driver 580.178.04 + gpu0 NVIDIA GeForce RTX 5090 (SM 12.0): 31.3 of 31.8 GB free, 0 foreign processes + platform INFO not logged in: optional; goethe login links this node and unlocks optimised kernels + cloud INFO no cloud provider detected + py-env INFO not set up yet: the first goethe install of a model sets it up (about 30 MB, more for engines) + also OK: driver, glibc, nginx, goethe_home, disk, ram, state_db, environment, ports, goethed, gateway, network, tls, huggingface, registry, nvidia_driver, compiler (goethe -v doctor lists them) + + GPU architectures goethe supports: sm_80 (Ampere data center), sm_86 (Ampere), sm_89 (Ada), sm_90a (Hopper), sm_100a (Blackwell data center), sm_103a (Blackwell Ultra data center), sm_120a (Blackwell), sm_121a (Blackwell) + Architectures of this machine: sm_120a + +==> goethe doctor --hardware ++ goethe doctor --hardware + Goethe hardware profile at 2026-11-18T21:11:07Z + Driver: 580.178.04 + GPU NAME VRAM TOTAL VRAM FREE PCIE + gpu0 NVIDIA GeForce RTX 5090 31.8 GB 31.3 GB PCIe 5 x16 + SM 12.0 + CPU: Intel(R) Core(TM) Ultra 7 265K (GenuineIntel), 1 socket(s), 20 cores, 20 threads, flags [avx2] + RAM: 125.1 GB total, 119.8 GB available; swap 3.6/8.0 GB free; hugepages 0/0 free (2048 kB) + Disk goethe_home: /home/v/proj/petya/goethe-e2e-180/home on / (ext4) 525 GB free of 3936 GB + Disk models: /home/v/proj/petya/goethe-e2e-180/home/models on / (ext4) 525 GB free of 3936 GB + OS: Ubuntu 24.04.3 LTS, kernel 7.0.0-42-generic, glibc 2.39 + NVIDIA driver 580.178.04, CUDA driver 13.0 + Environment: no container, systemd is PID 1, cloud none + +==> goethe --help ++ goethe --help + Goethe: serve models through OpenAI and Anthropic compatible gateways + + Start and stop + goethe the menu: quick setup, install models, API keys and gateway, status + goethe up start Goethe now and at every boot + goethe down stop Goethe; loaded models come back on the next up + goethe status running or not, the API address, keys and served models + goethe ps running models in detail: GPUs, memory, requests, speed + + Models + goethe install MODEL --load download from Hugging Face (or add a folder) and serve it + goethe load MODEL --gpu gpu2 gpu3 serve an installed model on these GPUs + goethe load MODEL --ctx 32768 --save the same, and keep the settings as its defaults + goethe load MODEL --dry-run show where it would go, load nothing + goethe unload MODEL stop serving it (--all stops every model) + goethe remove MODEL unload and delete it + goethe run MODEL try it by hand: chat, one reply, embedding or transcript + goethe models installed and catalog models + goethe models recommend catalog models that fit your GPUs + goethe models scan FOLDER register a folder you put in GOETHE_HOME/models + goethe models alias set fast MODEL a short name clients can use (remove fast drops it) + goethe logs MODEL -f follow a model's log (also goethed or gateway) + + API and access + goethe api the address, the keys and a curl command to try it + goethe api keys list the keys (a menu on a terminal) + goethe api keys create my-app a new key (also --expires 30d --rpm 300 --models ID --admin) + goethe api keys revoke KEY_ID revoke a key + goethe api expose where the API listens and who may connect + goethe api expose vpn --interface wg0 serve a VPN or private network (also local or public) + goethe api allow add 203.0.113.7/32 let a client address in (remove takes it out) + goethe api domain check DOMAIN check that a domain reaches the API + goethe api share 5h --key my-app --allow /32 open a public address for a while (share stop closes it) + + Learning and traces + goethe learn on sessions keep what compaction drops (--model M for one model) + goethe trace on record requests and replies for training (--key K for one key) + + Machine + goethe gpu GPUs live: memory, processes and bandwidth + goethe gpu deny gpu2 keep new models off a GPU (allow gpu2 undoes it) + goethe doctor check the machine and the setup, with a fix for each problem + goethe doctor --hardware the hardware profile: GPUs and links, CPU, RAM, disk, OS + goethe update signed update of Goethe, its engines and kernel packs + goethe uninstall remove Goethe and the models it installed + goethe login link this node to the Goethe platform (optional) + goethe logout unlink it and remove its local credentials + goethe completion install tab completion for your shell + + MODEL is a Hugging Face id, an installed id, an alias or words from a name, for example: + + → goethe install nvidia/Qwen2.5-VL-7B-Instruct-NVFP4 --load + +==> goethe api share --help ++ goethe api share --help + Open the API on a public address for a while, for chosen API keys; stop closes it. + + Usage: goethe api share [OPTIONS] [DURATION] + + Arguments: + [DURATION] How long to stay open (30m, 5h, 1d; at most 7d), stop to close now, or nothing for the status. + + Options: + --key ... API keys to share (not admin keys), each until DURATION; with stop, the keys to stop sharing. + --allow ... Only these client addresses or ranges may use the keys given, such as 203.0.113.7. + -v, --verbose Show the output of every underlying process (also GOETHE_VERBOSE=1); it is always kept in /logs. + --dangerously-allow-all-inbound Allow every address on the public gateway (0.0.0.0/0). Rate limits still apply. Not with --allow. + --port The public port (default 8444, or the last one used). + -h, --help Print help + + Examples: + + → goethe api share 5h --key my-app --allow /32 + → goethe api share 5h --key my-app --dangerously-allow-all-inbound + → goethe api share (status) + → goethe api share stop + + --allow is who may connect (their public IP: ask them, or https://ifconfig.me on their device). This machine's IP is only the URL goethe prints. Reopening the same keys keeps their last addresses. --dangerously-allow-all-inbound opens to every address (rate limits still apply). Closes when the last key ends. + +==> goethe api expose --help ++ goethe api expose --help + Who can reach the API: local, vpn, public, or one address or interface. + + Usage: goethe api expose [OPTIONS] [WHERE] + + Arguments: + [WHERE] local, vpn or public; or an address (127.0.0.1, 0.0.0.0, an IP of this host) or an interface such as wg0 to listen on. + + Options: + --interface With vpn or public: the network interface to serve, e.g. wg0; the gateway follows its address. + --ip With vpn or public: a fixed address of this machine to listen on, instead of following an interface. + -v, --verbose Show the output of every underlying process (also GOETHE_VERBOSE=1); it is always kept in /logs. + --allow ... With vpn or public: client ranges to allow (default for vpn: the ranges the network reaches). + --yes Apply without questions (public still refuses 0.0.0.0/0). + --json With no WHERE: the status as JSON. + -h, --help Print help + + Who can reach the API: + + → goethe api expose local (this machine only) + → goethe api expose vpn --interface wg0 + → goethe api expose public --allow 203.0.113.7/32 + + Or listen on one address or interface directly: + + → goethe api expose 0.0.0.0 + → goethe api expose wg0 + + goethe api expose alone shows where the API listens and who may connect. + +==> goethe models --help ++ goethe models --help + Installed and catalog models; also recommend, scan and alias. + + Usage: goethe models [OPTIONS] + goethe models + + Commands: + recommend Catalog models that fit the free VRAM of the allowed GPUs. + scan Register model folders you downloaded yourself and moved into GOETHE_HOME/models. + alias Short model names for clients: list them, set one, or remove some. + help Print this message or the help of the given subcommand(s) + + Options: + -v, --verbose Show the output of every underlying process (also GOETHE_VERBOSE=1); it is always kept in /logs. + --json Emit JSON. + --installed Only installed models. + --available Only catalog models. + --all Every line; the default stops after 40. + -h, --help Print help + +==> goethe run --help ++ goethe run --help + Try a model by hand: a chat screen on a terminal without INPUT, else one reply, an embedding summary or an audio file's transcript. Loads an installed model that is not loaded and unloads it again. + + Usage: goethe run [OPTIONS] [MODEL]... + + Arguments: + [MODEL]... [MODEL] [INPUT]: MODEL may be left out when one model is loaded. + + Options: + --keep Leave a model loaded that this command loaded (it is unloaded when run ends otherwise). + --plain No chat screen: the plain prompt, as when input or output is not a terminal. + -v, --verbose Show the output of every underlying process (also GOETHE_VERBOSE=1); it is always kept in /logs. + --thinking Show the model's reasoning (dimmed) with the answer. + -h, --help Print help +NOTE: goethe run has no -p/--prompt; INPUT is positional. CI should not teach -p. + +==> goethe models recommend ++ goethe models recommend + VRAM free: 31.8 GB + + meshapplied/Qwen3.8-27B-NVFP4-NInfer ctx 100000 concurrency 4 + + Up to 24 GB + MODEL VRAM DOWNLOAD + nvidia/Qwen2.5-VL-7B-Instruct-NVFP4 22.2 GB/GPU · ctx 128000 · 8 conc 7.2 GB + nvidia/Llama-3.1-8B-Instruct-NVFP4 23.4 GB/GPU · ctx 65536 · 8 conc 6.0 GB + + Up to 48 GB + MODEL VRAM DOWNLOAD + nvidia/Qwen3.8-27B-NVFP4 26.8 GB/GPU · ctx 32768 · 8 conc 21.9 GB + microsoft/Phi-4-multimodal-instruct 28.2 GB/GPU · ctx 65536 · 8 conc 12.9 GB + meshapplied/Qwen3.8-27B-NVFP4-NInfer 28.4 GB/GPU · ctx 100000 · 4 conc - + +==> goethe models ++ goethe models + VRAM free: 31.8 GB + + Up to 24 GB + MODEL STATUS DISK FIT ON THIS MACHINE + nvidia/Qwen2.5-VL-7B-Instruct-NVFP4 available 7.2 GB fits: 22.2 GB per GPU (ctx 128000, 8 concurrent) + nvidia/Llama-3.1-8B-Instruct-NVFP4 available 6.0 GB fits: 23.4 GB per GPU (ctx 65536, 8 concurrent) + + Up to 48 GB + MODEL STATUS DISK FIT ON THIS MACHINE + nvidia/Qwen3.8-27B-NVFP4 (optimised kernels available) available 21.9 GB fits: 26.8 GB per GPU (ctx 32768, 8 concurrent) + microsoft/Phi-4-multimodal-instruct available 12.9 GB fits: 28.2 GB per GPU (ctx 65536, 8 concurrent) + meshapplied/Qwen3.8-27B-NVFP4-NInfer available 28.4 GB fits: 28.4 GB per GPU (ctx 100000, 4 concurrent) + + Too large for the allowed GPUs + MODEL STATUS DISK FIT ON THIS MACHINE + nvidia/Gemma-4-31B-IT-NVFP4 available 32.7 GB does not fit: not enough GPU memory + mistralai/Mistral-Small-3.1-24B-Instruct-2503 available 48.1 GB does not fit: not enough GPU memory + google/gemma-4-26B-A4B-it available 51.6 GB does not fit: not enough GPU memory + Qwen/Qwen3.8-27B available 55.6 GB does not fit: not enough GPU memory + meta-models/Muse-Glimmer-30B available 59.6 GB does not fit: not enough GPU memory + meshapplied/Qwen3.8-Flash-Next-NVFP4-Latest available 132.7 GB does not fit: not enough GPU memory (gated: needs your Hugging Face token or access) + nvidia/Qwen3.8-Flash-Next-NVFP4 available 132.7 GB does not fit: not enough GPU memory + deepseek-ai/DeepSeek-V4-Flash-0731 available 166.9 GB does not fit: not enough GPU memory + XiaomiMiMo/MiMo-V2.6-Flash-RL available 177.8 GB does not fit: not enough GPU memory + orcarouter/Qwen3.8-Flash-Next-Uncensored-NVFP4 available 183.5 GB does not fit: not enough GPU memory (gated: needs your Hugging Face token or access) + RedHatAI/GLM-5.3-Flash-NVFP4 available 197.9 GB does not fit: not enough GPU memory + nvidia/NVIDIA-Nemotron-3.5-Super-VL-120B-A12B-BF16 available 248.9 GB does not fit: not enough GPU memory + nvidia/MiniMax-M3-NVFP4 available 250.1 GB does not fit: not enough GPU memory + nvidia/Qwen3.5-397B-A17B-NVFP4 available 251.2 GB does not fit: not enough GPU memory + inclusionAI/Ling-3.0-flash available 255.0 GB does not fit: not enough GPU memory + Qwen/Qwen3.8-Flash-Next available 360.0 GB does not fit: not enough GPU memory + meshapplied/Qwen3.8-Flash-Next-Ternary-Latest available 391.9 GB does not fit: not enough GPU memory + nvidia/DeepSeek-V3.1-NVFP4 available 413.3 GB does not fit: not enough GPU memory + nvidia/DeepSeek-V3.2-NVFP4 available 415.1 GB does not fit: not enough GPU memory + nvidia/DeepSeek-V3-0324-NVFP4 available 423.7 GB does not fit: not enough GPU memory + nvidia/DeepSeek-R1-NVFP4 available 423.7 GB does not fit: not enough GPU memory + LibertAIDAI/DeepSeek-V4.1-Flash-1017-NVFP4 available 429.0 GB does not fit: not enough GPU memory + nvidia/GLM-5.2-NVFP4 available 464.9 GB does not fit: not enough GPU memory + Qwen/Qwen3-VL-235B-A22B-Instruct available 471.4 GB does not fit: not enough GPU memory + deepseek-ai/DeepSeek-V4.1-Flash-1017 available 510.3 GB does not fit: not enough GPU memory + ... 23 more lines; all of them: goethe models --all +NOTE: Compare models vs recommend per-GPU + ctx wording for the same id. + +==> models scan HF-id form (footgun check) ++ goethe models scan ggml-org/embeddinggemma-2-GGUF + ggml-org/embeddinggemma-2-GGUF: No such file or directory (os error 2) +FINDING: UX footgun: users typing HF id into models scan get os error 2; hint should say use folder name org__name or goethe install + +==> models scan folder name --yes ++ goethe models scan ggml-org__embeddinggemma-2-GGUF --yes + ggml-org__embeddinggemma-2-GGUF: No such file or directory (os error 2) +FINDING: FAIL ok: models scan folder name --yes + +==> models --installed after scan ++ goethe models --installed + VRAM free: 31.8 GB + +==> install from absolute path --name ++ goethe install /home/v/proj/petya/goethe-e2e-180/home/models/ggml-org__embeddinggemma-2-GGUF --name ggml-org/embeddinggemma-2-GGUF --yes + engine installing 0.3.0 (about 5 GB with PyTorch, once) + engine 0.3.0 ready (4.6 GB, 4 s) + ggml-org/embeddinggemma-2-GGUF goethe-engine ctx 1024 0.3 GB + 28 MB/req + files stay in /data/proj/gc/goethe-models/ggml-org__embeddinggemma-2-GGUF (goethe remove only unregisters) + run: goethe run ggml-org/embeddinggemma-2-GGUF + +==> models --installed after install path ++ goethe models --installed + VRAM free: 31.8 GB + + Installed + MODEL STATUS DISK FIT ON THIS MACHINE + ggml-org/embeddinggemma-2-GGUF (optimised kernels available) installed 0.4 GB fits: 0.9 GB per GPU (ctx 1024, 8 concurrent) + +==> create key e2e-tailnet ++ goethe api keys create e2e-tailnet --models ggml-org/embeddinggemma-2-GGUF + API key for e2e-tailnet (id a62afdf8be04): + + goethe_sk_REDACTED + + goethe api shows it again at any time. + +==> expose vpn on tailscale0 with CGNAT allow ++ goethe api expose vpn --interface tailscale0 --allow 100.64.0.0/10 --yes + Gateway now: listening on 127.0.0.1 port 8443; allowlist: empty (every client refused) + The gateway will listen on 100.90.97.111 (tailscale0; follows its address) and on 127.0.0.1, and allow 100.64.0.0/10. + gateway listens on 100.90.97.111 (tailscale0; follows its address) port 8443 + allowed 127.0.0.1/32 (this machine) + allowed 100.64.0.0/10 (tailscale0 clients) + API keys: 1 exist (goethe api keys; goethe api keys create for each new client) + + API: https://100.90.97.111:8443/v1 + + For the models and keys run: + + → goethe api + +==> goethe api expose (status) ++ goethe api expose + bind: 100.90.97.111 (follows tailscale0) (remote clients reach it when allowlisted) + port: 8443 + url: https://100.90.97.111:8443 + state: running + allowlist: 2 entries + +==> allowlist shows tailnet ++ goethe api allow + ALLOWED CLIENTS + 100.64.0.0/10 + 127.0.0.1/32 + +==> ss after vpn expose ++ bash -c ss -ltn | grep -E "8443|8444" || true + LISTEN 0 511 127.0.0.1:8443 0.0.0.0:* + LISTEN 0 511 100.90.97.111:8443 0.0.0.0:* + +==> public expose without new allow ++ goethe api expose public --yes + Gateway now: listening on 100.90.97.111 (following tailscale0) port 8443; allowlist: 100.64.0.0/10, 127.0.0.1/32 + WARNING: exposing the API on a public network is not recommended. + - Anyone who can reach this machine can attempt to connect; only the allowlist and API keys stop them. + - Allow only the client IPs you trust (goethe api allow add /32) and give every client its own key. + - Open the gateway port in your firewall or router yourself; Goethe does not change them. + - The certificate is self-signed, so clients must trust it or skip verification. + Your public IP: 81.182.125.247 -> API: https://81.182.125.247:8443/v1 + This machine is behind NAT (81.182.125.247 is not on its interfaces): forward TCP port 8443 on your router or cloud firewall to it. + goethe api expose: restarting nginx to move the listener from 100.90.97.111 to 0.0.0.0 + goethe api expose: stopping nginx master [3213137] + gateway listens on 0.0.0.0 port 8443 (restarted) + No client addresses were added: only addresses already on the allowlist can connect (goethe api allow add /32). + API keys: 1 exist (goethe api keys; goethe api keys create for each new client) + + API: https://81.182.125.247:8443/v1 + + For the models and keys run: + + → goethe api +FINDING: api expose public --yes binds 0.0.0.0 without requiring a public client allow; only warns. Listener is world-reachable if NAT/firewall forwards; nginx allowlist may still drop non-listed clients. +NOTE: Reverting to vpn/tailnet immediately after public probe. + +==> revert expose vpn after public probe ++ goethe api expose vpn --interface tailscale0 --allow 100.64.0.0/10 --yes + Gateway now: listening on 0.0.0.0 port 8443; allowlist: 100.64.0.0/10, 127.0.0.1/32 + The gateway will listen on 100.90.97.111 (tailscale0; follows its address) and on 127.0.0.1, and allow 100.64.0.0/10. + goethe api expose: restarting nginx to move the listener from 0.0.0.0 to 100.90.97.111 + goethe api expose: stopping nginx master [3213913] + gateway listens on 100.90.97.111 (tailscale0; follows its address) port 8443 (restarted) + API keys: 1 exist (goethe api keys; goethe api keys create for each new client) + + API: https://100.90.97.111:8443/v1 + + For the models and keys run: + + → goethe api + +==> ss after revert ++ bash -c ss -ltn | grep -E "8443|8444" || true + LISTEN 0 511 127.0.0.1:8443 0.0.0.0:* + LISTEN 0 511 100.90.97.111:8443 0.0.0.0:* + +==> share without --allow ++ goethe api share 5m --key e2e-tailnet + name who may connect with --allow /32 (their phone or laptop's public IP, not this machine's). this machine's public address is 81.182.125.247 (that becomes the URL, not --allow); ask them; to open to every address use --dangerously-allow-all-inbound + +==> share with this-machine public IP as --allow ++ bash -c + IP=$(curl -4 -fsS --max-time 3 ifconfig.me || true) + if [ -z "$IP" ]; then echo "skip: no public ip"; exit 1; fi + goethe api share 5m --key e2e-tailnet --allow "$IP/32" + + 81.182.125.247/32 is this machine's public address (the URL), not who may connect; use their phone or laptop's public IP + +==> share status closed ++ goethe api share + The public gateway is closed. Open it with: goethe api share 5h --key --allow /32 + +==> ss :8444 must be absent ++ bash -c ss -ltn | grep 8444 || echo no_8444 + no_8444 + +==> load dry-run embedding ++ goethe load ggml-org/embeddinggemma-2-GGUF --dry-run + would place ggml-org/embeddinggemma-2-GGUF tp=1 on GPU 0 at ctx 1024: 0.9 GB per GPU (weights 0.3 + KV 0.0 + sliding-window KV 0.1 + overhead 0.5) + GPU 0: 31.3 GB free, other software is running there + +==> load embedding ++ goethe load ggml-org/embeddinggemma-2-GGUF + GPU 0 has unmanaged process PID 2046 (Xorg, user gdm) using 0.0 GB VRAM + Goethe never stops processes it did not start. To stop it yourself: sudo kill 2046 + Free VRAM on GPU 0: 31.3 GB; this load needs 0.9 GB. + Re-run with --yes to load alongside it. + not loading next to processes goethe did not start: re-run with --yes (no terminal to ask on) +FINDING: FAIL ok: load embedding + +==> goethe ps ++ goethe ps + No models loaded. Pick one and load it: + + → goethe models + → goethe load + +==> goethe status after load ++ goethe status + goethe: running + API: https://100.90.97.111:8443/v1 + API KEY NAME KEY ID + e2e-tailnet a62afdf8be04 + + No models loaded. Pick one and load it: + + → goethe models + → goethe load + + Platform: Not linked (goethe login) + +==> goethe run embed positional INPUT ++ goethe run --plain ggml-org/embeddinggemma-2-GGUF hello greengoblin e2e + GPU 0 has unmanaged process PID 2046 (Xorg, user gdm) using 0.0 GB VRAM + Goethe never stops processes it did not start. To stop it yourself: sudo kill 2046 + Free VRAM on GPU 0: 31.3 GB; this load needs 0.9 GB. + Re-run with --yes to load alongside it. + not loading next to processes goethe did not start: re-run with --yes (no terminal to ask on) +FINDING: goethe run --plain embed INPUT failed (exit 3) + +==> goethe run with -- separator (footgun) ++ goethe run ggml-org/embeddinggemma-2-GGUF -- embed hello + error: unexpected value 'hello' for '[MODEL]...' found; no more were expected + + Usage: goethe run [OPTIONS] [MODEL]... + + For more information, try '--help'. +FINDING: UX: goethe run does not take -- extra args; clap error is opaque for users copying engine-flag patterns + +==> curl /v1/models via 127.0.0.1 + cacert ++ curl -sS --max-time 20 --cacert /home/v/proj/petya/goethe-e2e-180/home/nginx/certs/server.crt https://127.0.0.1:8443/v1/models -H Authorization: Bearer goethe_sk_REDACTED + {"data":[],"object":"list"} + +==> curl /v1/models via tailnet IP + cacert ++ curl -sS --max-time 20 --cacert /home/v/proj/petya/goethe-e2e-180/home/nginx/certs/server.crt https://100.90.97.111:8443/v1/models -H Authorization: Bearer goethe_sk_REDACTED + curl: (60) SSL: no alternative certificate subject name matches target host name '100.90.97.111' + More details here: https://curl.se/docs/sslcerts.html + + curl failed to verify the legitimacy of the server and therefore could not + establish a secure connection to it. To learn more about this situation and + how to fix it, please visit the web page mentioned above. +FINDING: FAIL ok: curl /v1/models via tailnet IP + cacert + +==> curl /v1/embeddings via tailnet ++ curl -sS --max-time 90 --cacert /home/v/proj/petya/goethe-e2e-180/home/nginx/certs/server.crt https://100.90.97.111:8443/v1/embeddings -H Authorization: Bearer goethe_sk_REDACTED -H Content-Type: application/json -d {"model":"ggml-org/embeddinggemma-2-GGUF","input":"greengoblin e2e"} + curl: (60) SSL: no alternative certificate subject name matches target host name '100.90.97.111' + More details here: https://curl.se/docs/sslcerts.html + + curl failed to verify the legitimacy of the server and therefore could not + establish a secure connection to it. To learn more about this situation and + how to fix it, please visit the web page mentioned above. +FINDING: FAIL ok: curl /v1/embeddings via tailnet +==> curl embeddings without key -> HTTP 000 +FINDING: embeddings without bearer returned HTTP 000 (expected 401/403) +NOTE: Llama NVFP4 tree not linked; skipped chat load. + +==> load missing model ++ goethe load definitely-missing-model-xyz + model definitely-missing-model-xyz is not installed (goethe models lists installed models; goethe install definitely-missing-model-xyz adds it) + +==> run missing model ++ goethe run --plain definitely-missing-model-xyz hi + definitely-missing-model-xyz is not installed: goethe install definitely-missing-model-xyz + +==> load --dry-run missing ++ goethe load definitely-missing-model-xyz --dry-run + model definitely-missing-model-xyz is not installed (goethe models lists installed models; goethe install definitely-missing-model-xyz adds it) + +==> share dangerously without remembered key ++ goethe api share 5m --dangerously-allow-all-inbound + name the API keys to allow with --key (the next time they are remembered); list them with goethe api keys + +==> gpu table ++ goethe gpu + + ▣ GPU ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ + gpu0 0.5 GB ░░░░░░░░░░ 31.8 GB 2046 ALLOWED ░░░░░░░░░░ 0% + + █ goethe models █ other processes ░ free █ memory bandwidth + +==> logs goethed (tail) ++ bash -c goethe logs goethed 2>&1 | tail -50 + log not found: /home/v/proj/petya/goethe-e2e-180/home/logs/goethed.log + +==> goethe status (URLs) ++ goethe status + goethe: running + API: https://100.90.97.111:8443/v1 + API KEY NAME KEY ID + e2e-tailnet a62afdf8be04 + + No models loaded. Pick one and load it: + + → goethe models + → goethe load + + Platform: Not linked (goethe login) + +==> goethe api (URLs) ++ goethe api + API endpoint: https://100.90.97.111:8443/v1 + SSL_CERT_FILE=/home/v/proj/petya/goethe-e2e-180/home/nginx/certs/server.crt + Accepts: OpenAI, Anthropic (/v1/messages) and LiteLLM (routes with or without /v1, x-litellm-api-key) + + API keys + NAME API KEY ADMIN EXPIRES + e2e-tailnet goethe_sk_REDACTED no never + + Query the API: + + → curl --cacert /home/v/proj/petya/goethe-e2e-180/home/nginx/certs/server.crt https://100.90.97.111:8443/v1/chat/completions -H "Authorization: Bearer " -H "Content-Type: application/json" -d '{"model": "", "messages": [{"role": "user", "content": "Hello!"}]}' + +==> goethe api expose ++ goethe api expose + bind: 100.90.97.111 (follows tailscale0) (remote clients reach it when allowlisted) + port: 8443 + url: https://100.90.97.111:8443 + state: running + allowlist: 2 entries + +==> unload all ++ goethe unload --all + nothing was loaded + +==> expose local ++ goethe api expose local --yes + Gateway now: listening on 100.90.97.111 (following tailscale0) port 8443; allowlist: 100.64.0.0/10, 127.0.0.1/32 + gateway listens on 127.0.0.1 port 8443 + API keys: 1 exist (goethe api keys; goethe api keys create for each new client) + + API: https://127.0.0.1:8443/v1 + + For the models and keys run: + + → goethe api + +==> share stop ++ goethe api share stop + The public gateway is not open. + +==> goethe down (e2e) ++ goethe down + goethed stopped + goethed will not start at boot until the next goethe up + +==> ss after e2e down ++ bash -c ss -ltn | grep -E "8443|8444" || echo none + none +NOTE: Restoring production Goethe. +goethe: running + +API: https://100.90.97.111:8443/v1 + +API KEY NAME KEY ID +matteo 95f818903035 + +For more details run: + + → goethe api + +Platform: Linked (workspace Personal) +Heartbeat: OK (56 s ago) +goethe: running + +API: https://100.90.97.111:8443/v1 + +API KEY NAME KEY ID +matteo 95f818903035 + +For more details run: + + → goethe api + +Platform: Linked (workspace Personal) +Heartbeat: OK (3 s ago) +LISTEN 0 511 127.0.0.1:8443 0.0.0.0:* +LISTEN 0 511 100.90.97.111:8443 0.0.0.0:* +NOTE: Prod not on 0.0.0.0:8443 +PASS=33 FAILS=7 TRACE=/home/v/proj/petya/goethe-e2e-180/TRACE.md diff --git a/docs/user-guide.md b/docs/user-guide.md index 6dc9d1cb..fa90050f 100644 --- a/docs/user-guide.md +++ b/docs/user-guide.md @@ -307,7 +307,7 @@ goethe api expose vpn # or local, or public; asks who may connect - **VPN or private network (recommended):** connect your VPN first, then pick it from the list. Any VPN with a network interface works, and so does a cloud VM's private network. Goethe lists tunnels and interfaces on private addresses, leaves out container bridges and public network cards, and shows the range each one reaches, taken from the system's routes. When a VPN routes each device separately, the private block its address is in (such as `100.64.0.0/10` or `10.0.0.0/8`) is used, so devices added later can connect too; you can narrow it to specific addresses. Default routes are never allowed. The gateway follows the interface: a new address after a reconnect or a reboot is picked up within a few seconds, and while the interface is down only this machine can connect (`goethe status` says so). The allowlist itself only changes when you run `goethe api expose` again; `goethe doctor` warns if it no longer lets the network's clients in. A VPN without an interface (userspace mode) can't be listened on directly: use local mode and the VPN's own port forwarding. - **Public network:** any address that can reach this machine. You open the port in your firewall yourself. -It then asks whether to restrict access to specific IP addresses, and offers to create the first key. In scripts: `goethe api expose vpn --yes`, or `goethe api expose public --allow 203.0.113.7 --yes`. +It then asks whether to restrict access to specific IP addresses, and offers to create the first key. In scripts: `goethe api expose vpn --yes`, or `goethe api expose public --allow 203.0.113.7/32 --yes`. Public always needs `--allow` and a confirm (`--yes` or `y`); it will not open every interface on a leftover allowlist alone. ### Keys diff --git a/engine/crates/core/src/configure.rs b/engine/crates/core/src/configure.rs index a0ab3249..439b1ae2 100644 --- a/engine/crates/core/src/configure.rs +++ b/engine/crates/core/src/configure.rs @@ -31,6 +31,8 @@ pub struct ApiOpts { pub interface: Option, pub allow: Vec, pub yes: bool, + /// Public only: allow every client address (0.0.0.0/0). Requires --yes. Not with --allow. + pub dangerously_allow_all_inbound: bool, } #[derive(Clone, Debug, PartialEq, Eq)] @@ -349,8 +351,51 @@ fn configure_vpn(opts: &ApiOpts, nets: &[Network]) -> Result { Ok(target.addr().to_string()) } +fn resolve_public_allows(opts: &ApiOpts) -> Result, String> { + // Public must name who may connect. --yes alone must not bind 0.0.0.0 on a leftover VPN allowlist. + // 0.0.0.0/0 only via --dangerously-allow-all-inbound (with --yes from configure_public). + if opts.dangerously_allow_all_inbound { + if !opts.allow.is_empty() { + return Err("--dangerously-allow-all-inbound does not mix with --allow".to_string()); + } + return Ok(vec!["0.0.0.0/0".to_string()]); + } + let mut ranges = opts.allow.clone(); + if ranges.is_empty() { + if !interactive() || opts.yes { + return Err( + "public needs who may connect: goethe api expose public --allow /32 --yes\n\ + (to allow every address on purpose: --dangerously-allow-all-inbound --yes)" + .to_string(), + ); + } + if !confirm(RESTRICT_QUESTION, true, false)? { + return Err( + "public needs client addresses (--allow /32), or --dangerously-allow-all-inbound --yes" + .to_string(), + ); + } + let a = ask("Client IPs or ranges to allow, comma separated (e.g. 203.0.113.7/32):", "")?; + ranges = a.split(',').map(str::trim).filter(|r| !r.is_empty()).map(String::from).collect(); + } + if ranges.is_empty() { + return Err( + "public needs who may connect: goethe api expose public --allow /32 --yes".to_string(), + ); + } + for r in &ranges { + security::canonical_cidr(r)?; + if is_everyone(r) { + return Err(format!( + "{r} opens every address; use --dangerously-allow-all-inbound --yes" + )); + } + } + Ok(ranges) +} + fn configure_public(opts: &ApiOpts) -> Result { - // Warn, show the public IP and its API URL, confirm, bind every interface and allow only the named clients. + // Warn, require named clients (or an explicit world-open), confirm, then bind every interface. println!("{}: {PUBLIC_WARNING}", crate::term::paint("WARNING", crate::term::Color::Yellow)); let port = nginx::public_port_u16(&goethe_home()); let public = lookup_public_ip(); @@ -358,38 +403,28 @@ fn configure_public(opts: &ApiOpts) -> Result { for line in public_ip_lines(public, port, &nginx::interface_addrs().unwrap_or_default()) { println!("{line}"); } - if !confirm("Expose the API on every network interface anyway?", false, opts.yes)? { - return Err("nothing changed (goethe api expose local or goethe api expose vpn to pick one)".to_string()); + let ranges = resolve_public_allows(opts)?; + if !opts.yes && !interactive() { + return Err( + "public open needs a terminal to confirm (y), or pass --yes with --allow /32".to_string(), + ); } - let mut ranges = opts.allow.clone(); - let mut everyone_chosen = false; - if ranges.is_empty() && interactive() && !opts.yes { - if confirm(RESTRICT_QUESTION, false, false)? { - let a = ask("Client IPs or ranges to allow, comma separated (e.g. 203.0.113.7/32):", "")?; - ranges = a.split(',').map(str::trim).filter(|r| !r.is_empty()).map(String::from).collect(); - } else { - ranges = vec!["0.0.0.0/0".to_string()]; - everyone_chosen = true; - println!("Every address that can reach this machine may connect; each request still needs an API key."); - } + let confirm_q = if opts.dangerously_allow_all_inbound { + "Bind every network interface and allow EVERY client address?" + } else { + "Expose the API on every network interface (0.0.0.0) for the allowlisted clients?" + }; + if !confirm(confirm_q, false, opts.yes)? { + return Err("nothing changed (goethe api expose local or goethe api expose vpn to pick one)".to_string()); } - for r in &ranges { - security::canonical_cidr(r)?; - if is_everyone(r) && !everyone_chosen { - println!("{r} lets every address on the internet try your API keys."); - if !interactive() || !confirm("Allow every address anyway?", false, false)? { - return Err(format!("refusing to allow {r}; name the client addresses instead")); - } - } + if opts.dangerously_allow_all_inbound { + println!("Every address that can reach this machine may connect; each request still needs an API key. Rate limits still apply."); } bind("0.0.0.0")?; allow("127.0.0.1/32", "this machine", true)?; for r in &ranges { allow(r, "public client", true)?; } - if ranges.is_empty() { - println!("No client addresses were added: only addresses already on the allowlist can connect (goethe api allow add /32)."); - } Ok(public_host.unwrap_or_else(|| "0.0.0.0".to_string())) } @@ -470,4 +505,45 @@ mod tests { assert!(is_everyone("0.0.0.0/0") && is_everyone("::/0") && !is_everyone("203.0.113.7/32")); assert_eq!(Net::new("10.1.2.3".parse().unwrap(), 16).to_string(), "10.1.0.0/16"); } + + fn opts(allow: &[&str], yes: bool, dangerously: bool) -> ApiOpts { + ApiOpts { + mode: Some(Mode::Public), + vpn_ip: None, + interface: None, + allow: allow.iter().map(|s| (*s).to_string()).collect(), + yes, + dangerously_allow_all_inbound: dangerously, + } + } + + #[test] + fn public_yes_without_allow_is_refused() { + // The greengoblin footgun: --yes alone used to bind 0.0.0.0 on a leftover VPN allowlist. + let err = resolve_public_allows(&opts(&[], true, false)).unwrap_err(); + assert!(err.contains("--allow"), "{err}"); + assert!(!err.contains('—'), "no em dash in errors"); + } + + #[test] + fn public_allow_is_accepted() { + let got = resolve_public_allows(&opts(&["203.0.113.7/32"], true, false)).unwrap(); + assert_eq!(got, vec!["203.0.113.7/32".to_string()]); + } + + #[test] + fn public_everyone_cidr_needs_dangerously_flag() { + let err = resolve_public_allows(&opts(&["0.0.0.0/0"], true, false)).unwrap_err(); + assert!(err.contains("dangerously-allow-all-inbound"), "{err}"); + } + + #[test] + fn public_dangerously_opens_everyone_and_rejects_mixed_allow() { + assert_eq!( + resolve_public_allows(&opts(&[], true, true)).unwrap(), + vec!["0.0.0.0/0".to_string()] + ); + let err = resolve_public_allows(&opts(&["203.0.113.7/32"], true, true)).unwrap_err(); + assert!(err.contains("does not mix"), "{err}"); + } } diff --git a/engine/crates/core/src/menu.rs b/engine/crates/core/src/menu.rs index f2ecf253..6b521430 100644 --- a/engine/crates/core/src/menu.rs +++ b/engine/crates/core/src/menu.rs @@ -830,7 +830,14 @@ fn access_page(tty: &mut Tty) -> Result<(), String> { tty.resume()?; } Some(1) => tty.inside(|| { - crate::configure::run_api(crate::configure::ApiOpts { mode: None, vpn_ip: None, interface: None, allow: Vec::new(), yes: false }) + crate::configure::run_api(crate::configure::ApiOpts { + mode: None, + vpn_ip: None, + interface: None, + allow: Vec::new(), + yes: false, + dangerously_allow_all_inbound: false, + }) })?, Some(_) => { let mut page = SharePage::new(); diff --git a/engine/crates/core/src/nginx.rs b/engine/crates/core/src/nginx.rs index 6341c401..261f3354 100644 --- a/engine/crates/core/src/nginx.rs +++ b/engine/crates/core/src/nginx.rs @@ -527,7 +527,8 @@ pub fn write_gateway_configs(home: &Path) -> Result<(), String> { } fn tls_names() -> Vec { - // Loopback, this host's name, and anything in GOETHE_TLS_NAMES. A pod's public IP changes every start, so a name is what a client pins. + // Loopback, this host's name, every interface IP (tailnet, LAN, …), and GOETHE_TLS_NAMES. + // Clients curl the bind address with --cacert; without those IPs in the SAN, verification fails (curl 60). let mut names: Vec = vec!["localhost".into(), "127.0.0.1".into(), "::1".into()]; if let Ok(h) = fs::read_to_string("/etc/hostname") { let h = h.trim(); @@ -535,6 +536,16 @@ fn tls_names() -> Vec { names.push(h.to_string()); } } + if let Some(addrs) = interface_addrs() { + for a in addrs { + // Skip link-local noise; keep loopback (already listed), private, and public iface IPs. + match a.ip { + IpAddr::V4(v4) if v4.is_link_local() => {} + IpAddr::V6(v6) if v6.is_unicast_link_local() => {} + ip => names.push(ip.to_string()), + } + } + } names.extend(std::env::var("GOETHE_TLS_NAMES").unwrap_or_default().split(',').map(|n| n.trim().to_string())); names.retain(|n| !n.is_empty()); names.dedup(); @@ -590,8 +601,14 @@ fn worker_user_line(root: bool, group: Option<&str>) -> String { } pub fn ensure_certs(home: &Path) -> Result<(), String> { - // The gateway's self-signed certificate for this host's names, made at install so it exists before the first goethe up. - ensure_tls(home, &san_extension(&tls_names()), false) + // The gateway's self-signed certificate for this host's names; refreshed when the SAN list changes (new iface IP). + let san = san_extension(&tls_names()); + let san_file = nginx_prefix(home).join("certs/sans.txt"); + let stale = fs::read_to_string(&san_file).map(|s| s.trim() != san).unwrap_or(true); + ensure_tls(home, &san, stale)?; + private_dir(&nginx_prefix(home).join("certs"), false)?; + write_private(&san_file, format!("{san}\n").as_bytes())?; + Ok(()) } fn ensure_tls(home: &Path, san: &str, stale: bool) -> Result<(), String> { @@ -1214,6 +1231,16 @@ mod tests { let names = tls_names(); assert!(names.contains(&"localhost".to_string()) && names.contains(&"127.0.0.1".to_string())); assert!(names.iter().all(|n| !n.trim().is_empty())); + // Interface IPs (tailnet, LAN) belong in the SAN so curl --cacert to the bind address works. + if let Some(addrs) = interface_addrs() { + for a in addrs { + match a.ip { + IpAddr::V4(v4) if v4.is_link_local() => {} + IpAddr::V6(v6) if v6.is_unicast_link_local() => {} + ip => assert!(names.contains(&ip.to_string()), "missing iface IP {ip} in {names:?}"), + } + } + } std::env::set_var("GOETHE_TLS_NAMES", "pod-8443.proxy.runpod.net, ,"); assert!(tls_names().contains(&"pod-8443.proxy.runpod.net".to_string()), "blank entries dropped"); std::env::remove_var("GOETHE_TLS_NAMES"); diff --git a/engine/crates/core/src/onboard.rs b/engine/crates/core/src/onboard.rs index 1e7fd4f2..c22ebf8d 100644 --- a/engine/crates/core/src/onboard.rs +++ b/engine/crates/core/src/onboard.rs @@ -278,7 +278,14 @@ fn step_serve(model: &str) -> Result<(), String> { fn step_access(model: &str) -> Result<(), String> { // Who can reach the API, then a key for the first client, then the ready-to-use call with that key filled in. heading(3, "Configure API access", Some("Choose who can reach the API:")); - let api = configure::apply_access(&ApiOpts { mode: None, vpn_ip: None, interface: None, allow: Vec::new(), yes: false })?; + let api = configure::apply_access(&ApiOpts { + mode: None, + vpn_ip: None, + interface: None, + allow: Vec::new(), + yes: false, + dangerously_allow_all_inbound: false, + })?; let token = choose_key(model)?; READY.lock().unwrap_or_else(|e| e.into_inner()).replace((api.clone(), model.to_string(), token.clone())); Ok(()) @@ -365,7 +372,14 @@ fn advanced() -> Result<(), String> { } Some(4) => { screen("Configure API access", Some("Choose who can reach the API:")); - configure::apply_access(&ApiOpts { mode: None, vpn_ip: None, interface: None, allow: Vec::new(), yes: false }) + configure::apply_access(&ApiOpts { + mode: None, + vpn_ip: None, + interface: None, + allow: Vec::new(), + yes: false, + dangerously_allow_all_inbound: false, + }) .map(|api| Some(format!("API endpoint: {api}"))) } Some(5) => crate::keys_menu::session().map(|s| s.summary()), diff --git a/engine/crates/core/src/scan.rs b/engine/crates/core/src/scan.rs index 20d877dd..c35fd11d 100644 --- a/engine/crates/core/src/scan.rs +++ b/engine/crates/core/src/scan.rs @@ -275,7 +275,20 @@ fn candidate_dirs(home: &Path, dir: Option<&str>) -> Result, String out.sort(); return Ok(out); }; - let canonical = fs::canonicalize(d).map_err(|e| format!("{d}: {e}"))?; + // Folder names are under models/ (help text). Only fall back to CWD for paths with a separator or absolute. + let raw = Path::new(d); + let candidate = if raw.is_absolute() || d.contains('/') || d.contains('\\') { + raw.to_path_buf() + } else { + models.join(d) + }; + let canonical = fs::canonicalize(&candidate).map_err(|e| { + format!( + "{}: {e} (a folder inside {}, e.g. org__name; or goethe install --name org/name)", + candidate.display(), + models.display() + ) + })?; let root = fs::canonicalize(&models).map_err(|e| e.to_string())?; match canonical.strip_prefix(&root) { Ok(rel) if !rel.as_os_str().is_empty() => Ok(vec![models.join(rel)]), @@ -335,7 +348,11 @@ pub fn survey(home: &Path, con: &Connection, dirs: Vec, m: &Machine) -> continue; } if meta.is_ok_and(|m| m.file_type().is_symlink()) { - let why = format!("a symlink; register the folder it points to with goethe install {}", canonical.display()); + // Scan does not follow symlinks into a card (install builds the farm). Point at the real tree. + let why = format!( + "a symlink; register it with: goethe install {} --name ", + canonical.display() + ); out.push(Finding { path, name, state: State::Unsupported(why) }); continue; } @@ -927,6 +944,22 @@ mod tests { ); } + #[test] + fn folder_name_resolves_under_models_not_cwd() { + // Greengoblin footgun: `goethe models scan org__name` used to canonicalize from CWD → ENOENT. + let home = tempfile::tempdir().unwrap(); + let h = home.path(); + crate::paths::ensure_layout(h).unwrap(); + let models = h.join("models"); + fs::write(model(&models, "org__fresh", "LlamaForCausalLM").join("model.safetensors"), b"x").unwrap(); + let got = candidate_dirs(h, Some("org__fresh")).unwrap(); + assert_eq!(got.len(), 1); + assert_eq!(got[0], models.join("org__fresh")); + let err = candidate_dirs(h, Some("nope__missing")).unwrap_err(); + assert!(err.contains("models"), "{err}"); + assert!(err.contains("goethe install") || err.contains("org__name") || err.contains("No such"), "{err}"); + } + #[test] fn parses_entry_classes_and_quant_table() { let src = "class A:\n pass\nEntryClass = [\n LlamaForCausalLM,\n Phi3ForCausalLM,\n]\n"; diff --git a/engine/crates/goethe/src/complete.rs b/engine/crates/goethe/src/complete.rs index 083e71bf..262c4931 100644 --- a/engine/crates/goethe/src/complete.rs +++ b/engine/crates/goethe/src/complete.rs @@ -64,13 +64,12 @@ pub fn authkey_stdin() -> Vec { } pub fn expose_targets() -> Vec { - // goethe api expose: the three modes, then the addresses and interfaces it can listen on directly. + // Modes first. Raw 0.0.0.0 is not offered: that bind goes through `expose public` with guards. let mut out = vec![ candidate("local", "this machine only"), candidate("vpn", "a VPN or private network"), - candidate("public", "a public network, allowlisted clients"), + candidate("public", "a public network, allowlisted clients (needs --allow and --yes)"), candidate("127.0.0.1", "this machine only"), - candidate("0.0.0.0", "every address"), ]; out.extend(interfaces()); out diff --git a/engine/crates/goethe/src/main.rs b/engine/crates/goethe/src/main.rs index 428dd281..b1ccb0f2 100644 --- a/engine/crates/goethe/src/main.rs +++ b/engine/crates/goethe/src/main.rs @@ -74,12 +74,9 @@ const EXPOSE_HELP: &str = "Who can reach the API: \t→ goethe api expose local (this machine only) \t→ goethe api expose vpn --interface wg0 -\t→ goethe api expose public --allow 203.0.113.7/32 +\t→ goethe api expose public --allow 203.0.113.7/32 --yes -Or listen on one address or interface directly: - -\t→ goethe api expose 0.0.0.0 -\t→ goethe api expose wg0 +Public always needs --allow /32 and a confirm (--yes, or y on a terminal). It never opens on a leftover allowlist alone. goethe api expose alone shows where the API listens and who may connect."; @@ -459,16 +456,22 @@ struct TraceArgs { #[derive(clap::Args)] struct ExposeArgs { - #[arg(add = clap_complete::engine::ArgValueCandidates::new(complete::expose_targets), value_name = "WHERE", help = "local, vpn or public; or an address (127.0.0.1, 0.0.0.0, an IP of this host) or an interface such as wg0 to listen on.")] + #[arg(add = clap_complete::engine::ArgValueCandidates::new(complete::expose_targets), value_name = "WHERE", help = "local, vpn or public; or an address (127.0.0.1, an IP of this host) or an interface such as wg0 to listen on.")] target: Option, - #[arg(add = clap_complete::engine::ArgValueCandidates::new(complete::interfaces), long, value_name = "NAME", conflicts_with = "ip", help = "With vpn or public: the network interface to serve, e.g. wg0; the gateway follows its address.")] + #[arg(add = clap_complete::engine::ArgValueCandidates::new(complete::interfaces), long, value_name = "NAME", conflicts_with = "ip", help = "With vpn: the network interface to serve, e.g. wg0; the gateway follows its address.")] interface: Option, - #[arg(long, value_name = "IP", help = "With vpn or public: a fixed address of this machine to listen on, instead of following an interface.")] + #[arg(long, value_name = "IP", hide = true, help = "Advanced: with vpn, a fixed address of this machine to listen on, instead of following an interface.")] ip: Option, - #[arg(long, value_name = "CIDR", num_args = 1.., value_delimiter = ',', help = "With vpn or public: client ranges to allow (default for vpn: the ranges the network reaches).")] + #[arg(long, value_name = "CIDR", num_args = 1.., value_delimiter = ',', help = "With vpn or public: client ranges to allow (required for public; default for vpn: the ranges the network reaches).")] allow: Vec, - #[arg(long, help = "Apply without questions (public still refuses 0.0.0.0/0).")] + #[arg(long, help = "Apply without questions. Public still needs --allow /32 (or --dangerously-allow-all-inbound).")] yes: bool, + #[arg( + long, + hide = true, + help = "Advanced / public only: allow every client address (0.0.0.0/0). Needs --yes. Not with --allow." + )] + dangerously_allow_all_inbound: bool, #[arg(long, help = "With no WHERE: the status as JSON.")] json: bool, } @@ -1099,14 +1102,24 @@ fn do_allow(a: AllowArgs) -> Result<(), String> { fn do_expose(e: ExposeArgs) -> Result<(), String> { // goethe api expose: the status; local|vpn|public runs the access setup; an address or interface is listened on directly. - let ExposeArgs { target, interface, ip, allow, yes, json } = e; - let mode_only = interface.is_some() || ip.is_some() || !allow.is_empty() || yes; + let ExposeArgs { target, interface, ip, allow, yes, dangerously_allow_all_inbound, json } = e; + let mode_only = interface.is_some() || ip.is_some() || !allow.is_empty() || yes || dangerously_allow_all_inbound; match target.as_deref() { None if mode_only => usage("give local, vpn or public with --interface, --ip, --allow or --yes"), None => do_gateway_status(json), Some(m @ ("local" | "vpn" | "public")) => { let mode = goethe_core::configure::Mode::parse(m).unwrap_or_else(|e| usage(e)); - goethe_core::configure::run_api(goethe_core::configure::ApiOpts { mode: Some(mode), vpn_ip: ip, interface, allow, yes }) + if dangerously_allow_all_inbound && mode != goethe_core::configure::Mode::Public { + usage("--dangerously-allow-all-inbound is only for public"); + } + goethe_core::configure::run_api(goethe_core::configure::ApiOpts { + mode: Some(mode), + vpn_ip: ip, + interface, + allow, + yes, + dangerously_allow_all_inbound, + }) } Some(_) if mode_only => usage("--interface, --ip, --allow and --yes go with local, vpn or public"), Some(addr) => do_gateway_bind(addr), @@ -1616,9 +1629,13 @@ fn do_ps(json: bool) -> Result<(), String> { fn do_gateway_bind(addr: &str) -> Result<(), String> { // An address, or an interface name whose address the gateway follows; persist, apply, and remind about the allowlist. + // Unspecified (0.0.0.0 / ::) is not a shortcut: that path used to open every interface without the public guards. let home = goethe_home(); ensure_layout(&home).map_err(|e| format!("layout: {e}"))?; let loopback = match addr.trim().parse::() { + Ok(ip) if ip.is_unspecified() => usage( + "listening on every address needs: goethe api expose public --allow /32 --yes", + ), Ok(ip) => { println!("{}", nginx::set_public_bind(&home, &ip.to_string())?); ip.is_loopback() @@ -1627,7 +1644,9 @@ fn do_gateway_bind(addr: &str) -> Result<(), String> { println!("{}", nginx::set_public_bind_interface(&home, addr.trim())?); false } - Err(_) => usage(format!("invalid address {addr:?}: use 0.0.0.0, 127.0.0.1, an IP address of this host or an interface name")), + Err(_) => usage(format!( + "invalid address {addr:?}: use 127.0.0.1, an IP address of this host or an interface name" + )), }; if !loopback && security::allowlist_list()?.is_empty() { print!("\n{}", empty_allowlist_text()); diff --git a/engine/tests/stage5_configure_api.py b/engine/tests/stage5_configure_api.py index 9a65453e..7bc76257 100644 --- a/engine/tests/stage5_configure_api.py +++ b/engine/tests/stage5_configure_api.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -"""goethe api expose without a terminal: local, public with named clients, public refusing 0.0.0.0/0, VPN.""" +"""goethe api expose without a terminal: local, public with named clients, refuse bare --yes / 0.0.0.0 /0, VPN.""" from __future__ import annotations @@ -22,13 +22,22 @@ def main() -> None: if rr.returncode == 0 or _status(goethe, env)["bind"] == "0.0.0.0": raise RuntimeError(f"without a terminal api expose public needs --yes: {rr.stdout} {rr.stderr}") rr = run([goethe, "api", "expose", "local", "--yes"], env=env) - if rr.returncode != 0 or "API key (default): goethe_sk_" not in rr.stdout: - raise RuntimeError(f"local mode with --yes must bind loopback and create a key: {rr.stdout} {rr.stderr}") - if _status(goethe, env)["bind"] != "127.0.0.1": - raise RuntimeError("local mode must bind 127.0.0.1") + if rr.returncode != 0 or _status(goethe, env)["bind"] != "127.0.0.1": + raise RuntimeError(f"local mode with --yes must bind loopback: {rr.stdout} {rr.stderr}") + # Greengoblin P0: --yes alone must not bind 0.0.0.0 on a leftover allowlist. + rr = run([goethe, "api", "expose", "public", "--yes"], env=env) + if rr.returncode == 0 or _status(goethe, env)["bind"] != "127.0.0.1": + raise RuntimeError( + f"public --yes without --allow must refuse and leave bind unchanged: {rr.stdout} {rr.stderr}" + ) + if "--allow" not in (rr.stdout + rr.stderr): + raise RuntimeError(f"refusal must name --allow: {rr.stdout} {rr.stderr}") + rr = run([goethe, "api", "expose", "0.0.0.0"], env=env) + if rr.returncode == 0 or _status(goethe, env)["bind"] != "127.0.0.1": + raise RuntimeError(f"raw expose 0.0.0.0 must refuse: {rr.stdout} {rr.stderr}") rr = run([goethe, "api", "expose", "public", "--yes", "--allow", "0.0.0.0/0"], env=env) if rr.returncode == 0 or _status(goethe, env)["bind"] != "127.0.0.1": - raise RuntimeError(f"public mode must refuse 0.0.0.0/0 without a terminal and change nothing: {rr.stdout}") + raise RuntimeError(f"public mode must refuse 0.0.0.0/0 without dangerously and change nothing: {rr.stdout}") quiet = {**env, "GOETHE_PUBLIC_IP_LOOKUP": "0"} rr = run([goethe, "api", "expose", "public", "--yes", "--allow", "203.0.113.7"], env=quiet) if "Your public IP: unknown, lookup disabled" not in rr.stdout: @@ -42,8 +51,8 @@ def main() -> None: if rr.returncode == 0 or "not an address of this host" not in rr.stderr: raise RuntimeError(f"a VPN address this host does not have must be refused: {rr.stdout} {rr.stderr}") rr = run([goethe, "api", "expose", "local", "--yes"], env=env) - if rr.returncode != 0 or "API keys: 1 exist" not in rr.stdout: - raise RuntimeError(f"a second run must keep the existing key: {rr.stdout} {rr.stderr}") + if rr.returncode != 0 or _status(goethe, env)["bind"] != "127.0.0.1": + raise RuntimeError(f"local again must succeed: {rr.stdout} {rr.stderr}") print("stage5_configure_api ok") From 4029bc075cefdd063478857b6a489e1396dad771 Mon Sep 17 00:00:00 2001 From: Petya <64523372+peti12352@users.noreply.github.com> Date: Wed, 18 Nov 2026 13:55:48 -0800 Subject: [PATCH 11/12] Drop leaky e2e traces and lint-illegal comments so CI style gate passes. --- docs/e2e-findings-pr180.md | 20 + docs/e2e-greengoblin-pr180-session.sh | 393 ------ docs/e2e-traces/FOLLOWUP-pr180-greengoblin.md | 121 -- docs/e2e-traces/README.md | 27 - docs/e2e-traces/TRACE-pr180-greengoblin.md | 1177 ----------------- docs/e2e-traces/TRACE-v1-aborted.md | 704 ---------- docs/e2e-traces/console-v2.txt | 609 --------- engine/crates/core/src/configure.rs | 8 +- engine/crates/core/src/engines/sglang.rs | 1 - engine/crates/core/src/nginx.rs | 5 +- engine/crates/core/src/public_share.rs | 2 - engine/crates/core/src/recommend.rs | 1 - engine/crates/core/src/scan.rs | 3 - engine/crates/goethe/src/main.rs | 3 +- engine/tests/stage5_configure_api.py | 1 - 15 files changed, 24 insertions(+), 3051 deletions(-) create mode 100644 docs/e2e-findings-pr180.md delete mode 100755 docs/e2e-greengoblin-pr180-session.sh delete mode 100644 docs/e2e-traces/FOLLOWUP-pr180-greengoblin.md delete mode 100644 docs/e2e-traces/README.md delete mode 100644 docs/e2e-traces/TRACE-pr180-greengoblin.md delete mode 100644 docs/e2e-traces/TRACE-v1-aborted.md delete mode 100644 docs/e2e-traces/console-v2.txt diff --git a/docs/e2e-findings-pr180.md b/docs/e2e-findings-pr180.md new file mode 100644 index 00000000..d6f298a4 --- /dev/null +++ b/docs/e2e-findings-pr180.md @@ -0,0 +1,20 @@ +# E2E findings (PR180) + +Isolated-home session against the PR binary. Session logs with host paths and keys stay off-repo. + +## Status + +| Sev | Finding | Status | +|-----|---------|--------| +| P0 | `expose public --yes` binds every interface without a client `--allow` | Fixed | +| P0 | Gateway cert SAN missing interface IPs (`curl --cacert` to the bind address fails) | Fixed | +| P1 | `models scan ` resolved from the current directory | Fixed | +| P1 | Symlink under `models/` refused by scan | Intentional; use `goethe install --name` | +| P1 | Non-TTY load next to a display manager needs `--yes` | Intentional | +| P2 | A second `GOETHE_HOME` may pick another gateway port | Warned; read status URL | +| P2 | `goethe run` has no `-p`; input is positional | Documented | + +## CI coverage + +- Unit: public `--yes` without `--allow` refuses; scan folder names under `models/`; cert SAN includes interface IPs +- `engine/tests/stage5_configure_api.py`: bare public `--yes`, raw `0.0.0.0`, and `0.0.0.0/0` refuse; named client allow succeeds diff --git a/docs/e2e-greengoblin-pr180-session.sh b/docs/e2e-greengoblin-pr180-session.sh deleted file mode 100755 index 88de8737..00000000 --- a/docs/e2e-greengoblin-pr180-session.sh +++ /dev/null @@ -1,393 +0,0 @@ -#!/usr/bin/env bash -# Real-user E2E on greengoblin for PR180 (isolated GOETHE_HOME). Leaves TRACE.md. -# Tailnet expose only for positive path; public/share probes must refuse or be reverted. -# Restores production goethe after. Never aborts mid-run on a single failed step. -set -u -set -o pipefail - -ROOT=/home/v/proj/petya -BUILD=$ROOT/goethe-pr180/engine/target/release -SESSION=$ROOT/goethe-e2e-180 -HOME_E2E=$SESSION/home -TRACE=$SESSION/TRACE.md -LOG=$SESSION/session.log -G=$BUILD/goethe -PROD_G=$(command -v goethe || true) -TS=$(date -u +%Y-%m-%dT%H:%M:%SZ) -FAILS=0 -PASS=0 -FINDINGS=() - -mkdir -p "$SESSION" "$HOME_E2E" -: >"$LOG" - -log() { printf '%s\n' "$*" | tee -a "$LOG"; } -md() { printf '%s\n' "$*" >>"$TRACE"; } -finding() { FINDINGS+=("$1"); log "FINDING: $1"; } - -# run never enables set -e for the caller (v1 aborted the session after first soft fail) -run() { - local title=$1; shift - md "" - md "### $title" - md "" - md '```' - md "+ $*" - md '```' - log "" - log "==> $title" - log "+ $*" - local out ec - set +e - out=$(GOETHE_HOME="$HOME_E2E" PATH="$BUILD:$PATH" "$@" 2>&1) - ec=$? - set +e - printf '%s\n' "$out" | tee -a "$LOG" | sed 's/^/ /' - md "" - md '```' - printf '%s\n' "$out" | head -c 14000 >>"$TRACE" - if [ "${#out}" -gt 14000 ]; then md "...(truncated)"; fi - md '```' - md "" - md "exit: \`$ec\`" - return "$ec" -} - -expect_ok() { - local title=$1; shift - if run "$title" "$@"; then - PASS=$((PASS + 1)) - md "**result:** pass" - return 0 - fi - FAILS=$((FAILS + 1)) - md "**result:** FAIL (expected success)" - finding "FAIL ok: $title" - return 1 -} - -expect_fail() { - local title=$1; shift - if run "$title" "$@"; then - FAILS=$((FAILS + 1)) - md "**result:** FAIL (expected refusal — command succeeded)" - finding "FAIL refuse: $title (command succeeded when it should refuse)" - return 1 - fi - PASS=$((PASS + 1)) - md "**result:** pass (refused as expected)" - return 0 -} - -note() { md ""; md "> $*"; log "NOTE: $*"; } - -# --- TRACE header --- -cat >"$TRACE" </dev/null | head -1)\`) -- **GOETHE_HOME (isolated):** \`$HOME_E2E\` -- **Prod goethe (restored after):** \`${PROD_G:-none}\` -- **Scope:** install/scan local path, fit, load, run (chat + embed), CLI, tailnet expose — **no lasting public bind** -- **GPU:** $(nvidia-smi -L 2>/dev/null | head -1) - -## Method - -Isolated \`GOETHE_HOME\` so the live 0.3.x install is not mutated. Production \`goethe\` is stopped for the session (port/GPU), then started again. Findings are written as observed — not softened. Script continues after failures (no mid-run abort). - -## Preflight -EOF - -{ - echo "disk:"; df -h / /home/v | sed 's/^/ /' - echo "gpu mem:"; nvidia-smi --query-gpu=memory.used,memory.free,memory.total --format=csv | sed 's/^/ /' - echo "prod status:"; goethe status 2>&1 | sed 's/^/ /' | head -25 - echo "prod listeners:"; ss -ltn | grep -E '8443|8444' | sed 's/^/ /' || echo " (none)" -} >>"$TRACE" - -note "Stopping production Goethe for isolated E2E (will restore)." -goethe down 2>&1 | tee -a "$LOG" || true -sleep 2 - -# fresh isolated home each full run (keep TRACE history by rotating) -rm -rf "$HOME_E2E" -mkdir -p "$HOME_E2E/bin" "$HOME_E2E/models" -cp -a "$BUILD/goethe" "$BUILD/goethed" "$HOME_E2E/bin/" -if [ -f /home/v/.goethe/hardware_state.json ]; then - cp -a /home/v/.goethe/hardware_state.json "$HOME_E2E/" -fi -# local-path model: symlink existing embedding GGUF tree (no re-download) -if [ -d /home/v/.goethe/models/ggml-org__embeddinggemma-2-GGUF ]; then - ln -sfn /home/v/.goethe/models/ggml-org__embeddinggemma-2-GGUF \ - "$HOME_E2E/models/ggml-org__embeddinggemma-2-GGUF" -fi -if [ -d /home/v/.goethe/models/nvidia__Llama-3.1-8B-Instruct-NVFP4 ]; then - ln -sfn /home/v/.goethe/models/nvidia__Llama-3.1-8B-Instruct-NVFP4 \ - "$HOME_E2E/models/nvidia__Llama-3.1-8B-Instruct-NVFP4" -fi - -export GOETHE_HOME="$HOME_E2E" -export PATH="$HOME_E2E/bin:$BUILD:$PATH" - -md "" -md "## 1. Start (fresh home)" -expect_ok "goethe up" goethe up || true -sleep 3 -expect_ok "goethe status" goethe status || true -expect_ok "goethe doctor" goethe doctor || true -expect_ok "goethe doctor --hardware" goethe doctor --hardware || true - -md "" -md "## 2. CLI surface / help consistency" -expect_ok "goethe --help" goethe --help || true -expect_ok "goethe api share --help" goethe api share --help || true -expect_ok "goethe api expose --help" goethe api expose --help || true -expect_ok "goethe models --help" goethe models --help || true -expect_ok "goethe run --help" goethe run --help || true -# -p must not exist on run (clap would accept unknown only with allow) -if goethe run --help 2>&1 | grep -qE -- '--prompt|-p '; then - finding "goethe run still documents -p/--prompt (unexpected vs current help)" -else - note "goethe run has no -p/--prompt; INPUT is positional. CI should not teach -p." -fi - -md "" -md "## 3. What fits" -expect_ok "goethe models recommend" goethe models recommend || true -expect_ok "goethe models" goethe models || true -note "Compare models vs recommend per-GPU + ctx wording for the same id." - -md "" -md "## 4. Local path model (scan + install from folder)" -# Correct scan arg is folder name under models/, not HF id (footgun) -run "models scan HF-id form (footgun check)" goethe models scan "ggml-org/embeddinggemma-2-GGUF" -if [ $? -ne 0 ]; then - PASS=$((PASS + 1)); md "**result:** pass (HF-id form rejected)" - finding "UX footgun: users typing HF id into models scan get os error 2; hint should say use folder name org__name or goethe install " -else - FAILS=$((FAILS + 1)); finding "models scan accepted org/name HF id as folder" -fi - -expect_ok "models scan folder name --yes" \ - goethe models scan "ggml-org__embeddinggemma-2-GGUF" --yes || true -expect_ok "models --installed after scan" goethe models --installed || true - -# alternate: install from absolute path (local path based model) -expect_ok "install from absolute path --name" \ - goethe install "$HOME_E2E/models/ggml-org__embeddinggemma-2-GGUF" \ - --name ggml-org/embeddinggemma-2-GGUF --yes || true -expect_ok "models --installed after install path" goethe models --installed || true - -md "" -md "## 5. API key + tailnet expose (NO lasting public)" -expect_ok "create key e2e-tailnet" \ - goethe api keys create e2e-tailnet --models ggml-org/embeddinggemma-2-GGUF || true - -RAW=$(grep -oE 'goethe_sk_[0-9a-f]+' "$LOG" | head -1 || true) -md "" -md "### captured bearer (redact in shared copies)" -md '```' -md "${RAW:-NONE}" -md '```' - -expect_ok "expose vpn on tailscale0 with CGNAT allow" \ - goethe api expose vpn --interface tailscale0 --allow 100.64.0.0/10 --yes || true -expect_ok "goethe api expose (status)" goethe api expose || true -expect_ok "allowlist shows tailnet" goethe api allow || true -run "ss after vpn expose" bash -c 'ss -ltn | grep -E "8443|8444" || true' - -# failure modes -# Must refuse: --yes alone must NOT bind 0.0.0.0 (fixed after greengoblin incident) -expect_fail "public expose --yes without --allow must refuse" \ - goethe api expose public --yes || true -expect_fail "raw expose 0.0.0.0 must refuse" \ - goethe api expose 0.0.0.0 || true -run "ss after public refuse probes" bash -c 'ss -ltn | grep -E "8443|8444" || true' -if ss -ltn | grep -q '0.0.0.0:8443'; then - finding "CRITICAL: 0.0.0.0:8443 listening after refused public probes" - FAILS=$((FAILS + 1)) -else - PASS=$((PASS + 1)) - md "**result:** pass (no 0.0.0.0:8443 after refuse probes)" -fi -# stay on vpn; re-assert tailnet bind -run "reaffirm vpn after public refuse" \ - goethe api expose vpn --interface tailscale0 --allow 100.64.0.0/10 --yes || true - -expect_fail "share without --allow" goethe api share 5m --key e2e-tailnet || true -expect_fail "share with this-machine public IP as --allow" bash -c ' - IP=$(curl -4 -fsS --max-time 3 ifconfig.me || true) - if [ -z "$IP" ]; then echo "skip: no public ip"; exit 1; fi - goethe api share 5m --key e2e-tailnet --allow "$IP/32" -' || true -expect_ok "share status closed" goethe api share || true -run "ss :8444 must be absent" bash -c 'ss -ltn | grep 8444 || echo no_8444' -if ss -ltn | grep -q ':8444'; then - finding "public share port 8444 is listening" - FAILS=$((FAILS + 1)) -else - PASS=$((PASS + 1)) -fi - -md "" -md "## 6. Load + run embedding model" -expect_ok "load dry-run embedding" goethe load ggml-org/embeddinggemma-2-GGUF --dry-run || true -expect_ok "load embedding" goethe load ggml-org/embeddinggemma-2-GGUF || true -sleep 8 -expect_ok "goethe ps" goethe ps || true -expect_ok "goethe status after load" goethe status || true - -# correct run form: positional INPUT, optional --plain -run "goethe run embed positional INPUT" \ - goethe run --plain ggml-org/embeddinggemma-2-GGUF "hello greengoblin e2e" -ec_run=$? -if [ "$ec_run" -eq 0 ]; then - PASS=$((PASS + 1)); md "**result:** pass" -else - FAILS=$((FAILS + 1)); md "**result:** FAIL"; finding "goethe run --plain embed INPUT failed (exit $ec_run)" -fi - -# wrong forms (document footguns) -run "goethe run with -- separator (footgun)" \ - goethe run ggml-org/embeddinggemma-2-GGUF -- embed "hello" -if [ $? -ne 0 ]; then - PASS=$((PASS + 1)); md "**result:** pass (bad argv rejected)"; finding "UX: goethe run does not take -- extra args; clap error is opaque for users copying engine-flag patterns" -else - FAILS=$((FAILS + 1)); md "**result:** unexpected success" -fi - -API_TAIL="https://100.90.97.111:8443/v1" -API_LOCAL="https://127.0.0.1:8443/v1" -CACERT="$HOME_E2E/nginx/certs/server.crt" -if [ -n "$RAW" ] && [ -f "$CACERT" ]; then - expect_ok "curl /v1/models via 127.0.0.1 + cacert" \ - curl -sS --max-time 20 --cacert "$CACERT" "$API_LOCAL/models" \ - -H "Authorization: Bearer $RAW" || true - expect_ok "curl /v1/models via tailnet IP + cacert" \ - curl -sS --max-time 20 --cacert "$CACERT" "$API_TAIL/models" \ - -H "Authorization: Bearer $RAW" || true - expect_ok "curl /v1/embeddings via tailnet" \ - curl -sS --max-time 90 --cacert "$CACERT" "$API_TAIL/embeddings" \ - -H "Authorization: Bearer $RAW" -H "Content-Type: application/json" \ - -d '{"model":"ggml-org/embeddinggemma-2-GGUF","input":"greengoblin e2e"}' || true - # negative: no auth - set +e - http=$(curl -sS -o /tmp/e2e-noauth.body -w "%{http_code}" --max-time 20 --cacert "$CACERT" \ - "$API_TAIL/embeddings" -H "Content-Type: application/json" \ - -d '{"model":"ggml-org/embeddinggemma-2-GGUF","input":"x"}' 2>/tmp/e2e-noauth.err) - set +e - md "" - md "### curl embeddings without key" - md "HTTP \`$http\`" - md '```' - head -c 2000 /tmp/e2e-noauth.body >>"$TRACE" 2>/dev/null || true - md '```' - log "==> curl embeddings without key -> HTTP $http" - if [ "$http" = "401" ] || [ "$http" = "403" ]; then - PASS=$((PASS + 1)); md "**result:** pass (auth rejected)" - else - FAILS=$((FAILS + 1)); md "**result:** FAIL (expected 401/403, got $http)" - finding "embeddings without bearer returned HTTP $http (expected 401/403)" - fi -else - finding "Could not curl API — missing bearer or cacert" - FAILS=$((FAILS + 1)) -fi - -md "" -md "## 7. Chat model (if linked)" -if [ -e "$HOME_E2E/models/nvidia__Llama-3.1-8B-Instruct-NVFP4" ]; then - expect_ok "models scan llama folder --yes" \ - goethe models scan "nvidia__Llama-3.1-8B-Instruct-NVFP4" --yes || true - run "unload embedding before chat" goethe unload --all || true - sleep 2 - expect_ok "load dry-run llama" goethe load nvidia/Llama-3.1-8B-Instruct-NVFP4 --dry-run || true - expect_ok "load llama" goethe load nvidia/Llama-3.1-8B-Instruct-NVFP4 || true - sleep 12 - run "goethe run llama one-shot" \ - goethe run --plain nvidia/Llama-3.1-8B-Instruct-NVFP4 "Say hi in five words." - if [ $? -eq 0 ]; then PASS=$((PASS + 1)); md "**result:** pass"; else FAILS=$((FAILS + 1)); md "**result:** FAIL"; finding "llama run failed"; fi -else - note "Llama NVFP4 tree not linked; skipped chat load." -fi - -md "" -md "## 8. More failure / UX probes" -expect_fail "load missing model" goethe load definitely-missing-model-xyz || true -expect_fail "run missing model" goethe run --plain definitely-missing-model-xyz hi || true -run "load --dry-run missing" goethe load definitely-missing-model-xyz --dry-run || true -expect_fail "share dangerously without remembered key" \ - goethe api share 5m --dangerously-allow-all-inbound || true -run "gpu table" goethe gpu || true -run "logs goethed (tail)" bash -c 'goethe logs goethed 2>&1 | tail -50' || true - -# consistency: status URL vs expose URL vs api URL -md "" -md "## 8b. URL consistency" -run "goethe status (URLs)" goethe status || true -run "goethe api (URLs)" goethe api || true -run "goethe api expose" goethe api expose || true - -md "" -md "## 9. Cleanup on box" -run "unload all" goethe unload --all || true -run "expose local" goethe api expose local --yes || true -run "share stop" goethe api share stop || true -run "goethe down (e2e)" goethe down || true -# ensure e2e left no listeners -sleep 1 -run "ss after e2e down" bash -c 'ss -ltn | grep -E "8443|8444" || echo none' - -# restore production -note "Restoring production Goethe." -unset GOETHE_HOME -export PATH="/home/v/.cargo/bin:/home/v/.local/bin:$PATH" -goethe up 2>&1 | tee -a "$LOG" || true -sleep 3 -goethe status 2>&1 | tee -a "$LOG" | head -30 || true -ss -ltn | grep -E '8443|8444' | tee -a "$LOG" || true -# prod must not be on 0.0.0.0 -if ss -ltn | grep -q '0.0.0.0:8443'; then - finding "PROD restored but listening on 0.0.0.0:8443" - FAILS=$((FAILS + 1)) -else - PASS=$((PASS + 1)) - note "Prod not on 0.0.0.0:8443" -fi - -md "" -md "## Scoreboard" -md "" -md "- Passes: **$PASS**" -md "- Failures / unexpected: **$FAILS**" -md "- Full command log: \`$LOG\`" -md "- Isolated home: \`$HOME_E2E\` — delete when done: \`rm -rf $SESSION\`" -md "" -md "## Findings (observed, not softened)" -md "" -if [ ${#FINDINGS[@]} -eq 0 ]; then - md "_No automated findings recorded; review TRACE manually._" -else - i=1 - for f in "${FINDINGS[@]}"; do - md "$i. $f" - i=$((i + 1)) - done -fi -md "" -md "## CI / follow-up test ideas" -md "" -md "1. Assert \`goethe models scan org/name\` fails with a hint to use \`org__name\` folder form." -md "2. Assert \`goethe api expose public --yes\` either refuses without a non-VPN client allow, or never binds \`0.0.0.0\` unless \`--dangerously-allow-all-inbound\` (product decision)." -md "3. After any public probe in E2E, assert \`ss\` has no \`0.0.0.0:8443\` / \`:8444\`." -md "4. \`goethe run --plain \` happy path for embed + chat; reject teaching \`run -- -p\`." -md "5. Curl \`/v1/models\` and \`/v1/embeddings\` with cacert over tailnet IP; 401 without bearer." -md "6. Share: machine public IP as \`--allow\` must refuse; no \`--allow\` must refuse." -md "7. Script must not \`set -e\` across soft failures (v1 aborted mid-session)." -md "" - -echo "PASS=$PASS FAILS=$FAILS TRACE=$TRACE" | tee -a "$LOG" -# exit 0 so ssh wrappers still fetch TRACE; scoreboard holds the truth -exit 0 diff --git a/docs/e2e-traces/FOLLOWUP-pr180-greengoblin.md b/docs/e2e-traces/FOLLOWUP-pr180-greengoblin.md deleted file mode 100644 index 371f2359..00000000 --- a/docs/e2e-traces/FOLLOWUP-pr180-greengoblin.md +++ /dev/null @@ -1,121 +0,0 @@ -# E2E follow-up (load --yes, cert SAN, scan detail) -- when: 2026-11-18T21:12:48Z - -## Prior scan folder failure excerpt -### models scan folder name --yes - -``` -+ goethe models scan ggml-org__embeddinggemma-2-GGUF --yes -``` - -``` -ggml-org__embeddinggemma-2-GGUF: No such file or directory (os error 2) -``` - -exit: `1` -**result:** FAIL (expected success) - -### models --installed after scan - -``` -+ goethe models --installed -``` - -``` -VRAM free: 31.8 GB -``` - -exit: `0` -**result:** pass - --- -2. FAIL ok: models scan folder name --yes -3. api expose public --yes binds 0.0.0.0 without requiring a public client allow; only warns. Listener is world-reachable if NAT/firewall forwards; nginx allowlist may still drop non-listed clients. -4. FAIL ok: load embedding -5. goethe run --plain embed INPUT failed (exit 3) -6. UX: goethe run does not take -- extra args; clap error is opaque for users copying engine-flag patterns -7. FAIL ok: curl /v1/models via tailnet IP + cacert -8. FAIL ok: curl /v1/embeddings via tailnet -9. embeddings without bearer returned HTTP 000 (expected 401/403) - -## CI / follow-up test ideas - -1. Assert `goethe models scan org/name` fails with a hint to use `org__name` folder form. -2. Assert `goethe api expose public --yes` either refuses without a non-VPN client allow, or never binds `0.0.0.0` unless `--dangerously-allow-all-inbound` (product decision). -3. After any public probe in E2E, assert `ss` has no `0.0.0.0:8443` / `:8444`. -4. `goethe run --plain ` happy path for embed + chat; reject teaching `run -- -p`. -5. Curl `/v1/models` and `/v1/embeddings` with cacert over tailnet IP; 401 without bearer. -6. Share: machine public IP as `--allow` must refuse; no `--allow` must refuse. -7. Script must not `set -e` across soft failures (v1 aborted mid-session). - -## scan/install state -ggml-org__embeddinggemma-2-GGUF: No such file or directory (os error 2) -VRAM free: 31.8 GB - -Installed -MODEL STATUS DISK FIT ON THIS MACHINE -ggml-org/embeddinggemma-2-GGUF (optimised kernels available) installed 0.4 GB fits: 0.9 GB per GPU (ctx 1024, 8 concurrent) -/home/v/proj/petya/goethe-e2e-180/home/models/ggml-org__embeddinggemma-2-GGUF is already inside /home/v/proj/petya/goethe-e2e-180/home/models -KEY_PRESENT=yes -Gateway now: listening on 127.0.0.1 port 18443; allowlist: 100.64.0.0/10, 127.0.0.1/32 -The gateway will listen on 100.90.97.111 (tailscale0; follows its address) and on 127.0.0.1, and allow 100.64.0.0/10. -gateway listens on 100.90.97.111 (tailscale0; follows its address) port 18443 -API keys: 1 exist (goethe api keys; goethe api keys create for each new client) - -API: https://100.90.97.111:18443/v1 - -For the models and keys run: - - → goethe api - -## cert SANs -subject=CN = goethe-local -X509v3 Subject Alternative Name: - DNS:localhost, IP Address:127.0.0.1, IP Address:0:0:0:0:0:0:0:1, DNS:greengoblin -## load --yes -auto: tp=1 on GPUs 0: 0.9 GB per GPU (weights 0.3 + KV 0.0 + sliding-window KV 0.1 + overhead 0.5) -Loading into VRAM... -loading into vram, 5 s -loading into vram, 10 s -warming up kernels with one request (the first time can take a few minutes) -RUNNING: ggml-org/embeddinggemma-2-GGUF instance inst-18e9401211c53dcc on GPU 0 port 30001 (12.1 s) -INSTANCE MODEL RUNTIME SLOT STATUS GPUS PORT VRAM_GB RESTARTS IN_FLIGHT TOK_PER_S PREFIX -inst-18e9401211c53dcc ggml-org/embeddinggemma-2-GGUF goethe-engine ggml-org/embeddinggemma-2-GGUF|0|0 RUNNING 0 30001 0.88 0 0 0.0 - -## run --plain embed -dims=768 norm=1.0000 [-0.0346, 0.0333, 0.0366, -0.0186, ...] -## curl localhost cacert -curl: (60) SSL certificate problem: self-signed certificate -More details here: https://curl.se/docs/sslcerts.html - -curl failed to verify the legitimacy of the server and therefore could not -establish a secure connection to it. To learn more about this situation and -how to fix it, please visit the web page mentioned above. -## curl tailnet cacert (expect SAN fail) -curl: (60) SSL certificate problem: self-signed certificate -More details here: https://curl.se/docs/sslcerts.html - -curl failed to verify the legitimacy of the server and therefore could not -establish a secure connection to it. To learn more about this situation and -how to fix it, please visit the web page mentioned above. -## curl tailnet -k (insecure name check bypass) -{"error":{"code":"invalid_api_key","message":"Invalid or missing Goethe API key","param":null,"type":"auth_error"}}## curl embeddings -k -{"error":{"code":"invalid_api_key","message":"Invalid or missing Goethe API key","param":null,"type":"auth_error"}}## curl embeddings no auth -k -HTTP 401 -{"error":{"code":"invalid_api_key","message":"Invalid or missing Goethe API key","param":null,"type":"auth_error"}}## llama trees -ggml-org__embeddinggemma-2-GGUF -## restored prod -goethe: running - -API: https://100.90.97.111:8443/v1 - -API KEY NAME KEY ID -matteo 95f818903035 - -For more details run: - - → goethe api - -Platform: Linked (workspace Personal) -Heartbeat: OK (3 s ago) -LISTEN 0 511 127.0.0.1:8443 0.0.0.0:* -LISTEN 0 511 100.90.97.111:8443 0.0.0.0:* diff --git a/docs/e2e-traces/README.md b/docs/e2e-traces/README.md deleted file mode 100644 index 1d853b9f..00000000 --- a/docs/e2e-traces/README.md +++ /dev/null @@ -1,27 +0,0 @@ -# Goethe PR180 greengoblin E2E traces - -Real-user session on greengoblin (isolated `GOETHE_HOME`), 2026-11-18. API keys redacted. - -| File | What | -|------|------| -| `TRACE-pr180-greengoblin.md` | Full command TRACE + scoreboard + findings | -| `FOLLOWUP-pr180-greengoblin.md` | Load `--yes`, cert SAN, embed run | -| `TRACE-v1-aborted.md` | First run aborted (`set -e` in helper) | -| `console-v2.txt` | Raw SSH console for v2 | -| `../e2e-greengoblin-pr180-session.sh` | Reusable driver | - -## Finding status (landed with this PR) - -| Sev | Finding | Status | -|-----|---------|--------| -| P0 | `expose public --yes` binds `0.0.0.0` without `--allow` | **Fixed** (refuse; need `--allow` + `--yes`) | -| P0 | TLS SAN missing tailnet/bind IPs (curl 60) | **Fixed** (`tls_names` includes iface IPs; cert refreshes when SAN changes) | -| P1 | `models scan ` from CWD | **Fixed** (folder names resolve under `models/`) | -| P1 | Symlink under `models/` refused by scan | **Docs/msg** (use `goethe install --name`; intentional no follow) | -| P1 | Non-TTY load blocked by Xorg unless `--yes` | **Keep** (intentional; E2E/CI use `--yes`) | -| P2 | Second `GOETHE_HOME` → port 18443 | **Keep** (warned; test harness must read status URL) | -| P2 | `goethe run` no `-p` | **Keep** (positional INPUT; help already says so) | - -## Security incident note (0.0.0.0 bind during E2E) - -**Closed.** Prod is tailnet+localhost only. No evidence of external attack in nginx access logs. NAT + allowlist + API key limited blast radius. Fix: `expose public --yes` without `--allow` refuses; raw `expose 0.0.0.0` refuses. diff --git a/docs/e2e-traces/TRACE-pr180-greengoblin.md b/docs/e2e-traces/TRACE-pr180-greengoblin.md deleted file mode 100644 index aabba76a..00000000 --- a/docs/e2e-traces/TRACE-pr180-greengoblin.md +++ /dev/null @@ -1,1177 +0,0 @@ -# Goethe PR180 greengoblin E2E session - -- **When (UTC):** 2026-11-18T21:10:59Z -- **Host:** greengoblin -- **Binary:** `/home/v/proj/petya/goethe-pr180/engine/target/release/goethe` (`goethe 0.3.3`) -- **GOETHE_HOME (isolated):** `/home/v/proj/petya/goethe-e2e-180/home` -- **Prod goethe (restored after):** `/home/v/.local/bin/goethe` -- **Scope:** install/scan local path, fit, load, run (chat + embed), CLI, tailnet expose — **no lasting public bind** -- **GPU:** GPU 0: NVIDIA GeForce RTX 5090 (UUID: GPU-aaabe7a6-e328-9869-cca8-a8e56a3d4591) - -## Method - -Isolated `GOETHE_HOME` so the live 0.3.x install is not mutated. Production `goethe` is stopped for the session (port/GPU), then started again. Findings are written as observed — not softened. Script continues after failures (no mid-run abort). - -## Preflight -disk: - Filesystem Size Used Avail Use% Mounted on - /dev/nvme0n1p1 3.6T 3.0T 489G 86% / - /dev/nvme0n1p1 3.6T 3.0T 489G 86% / -gpu mem: - memory.used [MiB], memory.free [MiB], memory.total [MiB] - 15 MiB, 32095 MiB, 32607 MiB -prod status: - goethe: running - API: https://100.90.97.111:8443/v1 - API KEY NAME KEY ID - matteo 95f818903035 - - No models loaded. Pick one and load it: - - → goethe models - → goethe load - - Platform: Linked (workspace Personal, heartbeat OK (11 s ago)) -prod listeners: - LISTEN 0 511 127.0.0.1:8443 0.0.0.0:* - LISTEN 0 511 100.90.97.111:8443 0.0.0.0:* - -> Stopping production Goethe for isolated E2E (will restore). - -## 1. Start (fresh home) - -### goethe up - -``` -+ goethe up -``` - -``` -goethe: running -API: https://127.0.0.1:8443/v1 -keys: none, create one with: goethe api keys create my-app - -No models loaded. Pick one and load it: - - → goethe models - → goethe load - -Platform: Not linked (goethe login) -``` - -exit: `0` -**result:** pass - -### goethe status - -``` -+ goethe status -``` - -``` -goethe: running -API: https://127.0.0.1:8443/v1 -keys: none, create one with: goethe api keys create my-app - -No models loaded. Pick one and load it: - - → goethe models - → goethe load - -Platform: Not linked (goethe login) -``` - -exit: `0` -**result:** pass - -### goethe doctor - -``` -+ goethe doctor -``` - -``` -CHECK STATUS DETAIL -hardware OK driver 580.178.04 - gpu0 NVIDIA GeForce RTX 5090 (SM 12.0): 31.3 of 31.8 GB free, 0 foreign processes -platform INFO not logged in: optional; goethe login links this node and unlocks optimised kernels -cloud INFO no cloud provider detected -py-env INFO not set up yet: the first goethe install of a model sets it up (about 30 MB, more for engines) -also OK: driver, glibc, nginx, goethe_home, disk, ram, state_db, environment, ports, goethed, gateway, network, tls, huggingface, registry, nvidia_driver, compiler (goethe -v doctor lists them) - -GPU architectures goethe supports: sm_80 (Ampere data center), sm_86 (Ampere), sm_89 (Ada), sm_90a (Hopper), sm_100a (Blackwell data center), sm_103a (Blackwell Ultra data center), sm_120a (Blackwell), sm_121a (Blackwell) -Architectures of this machine: sm_120a -``` - -exit: `0` -**result:** pass - -### goethe doctor --hardware - -``` -+ goethe doctor --hardware -``` - -``` -Goethe hardware profile at 2026-11-18T21:11:07Z -Driver: 580.178.04 -GPU NAME VRAM TOTAL VRAM FREE PCIE -gpu0 NVIDIA GeForce RTX 5090 31.8 GB 31.3 GB PCIe 5 x16 - SM 12.0 -CPU: Intel(R) Core(TM) Ultra 7 265K (GenuineIntel), 1 socket(s), 20 cores, 20 threads, flags [avx2] -RAM: 125.1 GB total, 119.8 GB available; swap 3.6/8.0 GB free; hugepages 0/0 free (2048 kB) -Disk goethe_home: /home/v/proj/petya/goethe-e2e-180/home on / (ext4) 525 GB free of 3936 GB -Disk models: /home/v/proj/petya/goethe-e2e-180/home/models on / (ext4) 525 GB free of 3936 GB -OS: Ubuntu 24.04.3 LTS, kernel 7.0.0-42-generic, glibc 2.39 -NVIDIA driver 580.178.04, CUDA driver 13.0 -Environment: no container, systemd is PID 1, cloud none -``` - -exit: `0` -**result:** pass - -## 2. CLI surface / help consistency - -### goethe --help - -``` -+ goethe --help -``` - -``` -Goethe: serve models through OpenAI and Anthropic compatible gateways - -Start and stop - goethe the menu: quick setup, install models, API keys and gateway, status - goethe up start Goethe now and at every boot - goethe down stop Goethe; loaded models come back on the next up - goethe status running or not, the API address, keys and served models - goethe ps running models in detail: GPUs, memory, requests, speed - -Models - goethe install MODEL --load download from Hugging Face (or add a folder) and serve it - goethe load MODEL --gpu gpu2 gpu3 serve an installed model on these GPUs - goethe load MODEL --ctx 32768 --save the same, and keep the settings as its defaults - goethe load MODEL --dry-run show where it would go, load nothing - goethe unload MODEL stop serving it (--all stops every model) - goethe remove MODEL unload and delete it - goethe run MODEL try it by hand: chat, one reply, embedding or transcript - goethe models installed and catalog models - goethe models recommend catalog models that fit your GPUs - goethe models scan FOLDER register a folder you put in GOETHE_HOME/models - goethe models alias set fast MODEL a short name clients can use (remove fast drops it) - goethe logs MODEL -f follow a model's log (also goethed or gateway) - -API and access - goethe api the address, the keys and a curl command to try it - goethe api keys list the keys (a menu on a terminal) - goethe api keys create my-app a new key (also --expires 30d --rpm 300 --models ID --admin) - goethe api keys revoke KEY_ID revoke a key - goethe api expose where the API listens and who may connect - goethe api expose vpn --interface wg0 serve a VPN or private network (also local or public) - goethe api allow add 203.0.113.7/32 let a client address in (remove takes it out) - goethe api domain check DOMAIN check that a domain reaches the API - goethe api share 5h --key my-app --allow /32 open a public address for a while (share stop closes it) - -Learning and traces - goethe learn on sessions keep what compaction drops (--model M for one model) - goethe trace on record requests and replies for training (--key K for one key) - -Machine - goethe gpu GPUs live: memory, processes and bandwidth - goethe gpu deny gpu2 keep new models off a GPU (allow gpu2 undoes it) - goethe doctor check the machine and the setup, with a fix for each problem - goethe doctor --hardware the hardware profile: GPUs and links, CPU, RAM, disk, OS - goethe update signed update of Goethe, its engines and kernel packs - goethe uninstall remove Goethe and the models it installed - goethe login link this node to the Goethe platform (optional) - goethe logout unlink it and remove its local credentials - goethe completion install tab completion for your shell - -MODEL is a Hugging Face id, an installed id, an alias or words from a name, for example: - - → goethe install nvidia/Qwen2.5-VL-7B-Instruct-NVFP4 --load -``` - -exit: `0` -**result:** pass - -### goethe api share --help - -``` -+ goethe api share --help -``` - -``` -Open the API on a public address for a while, for chosen API keys; stop closes it. - -Usage: goethe api share [OPTIONS] [DURATION] - -Arguments: - [DURATION] How long to stay open (30m, 5h, 1d; at most 7d), stop to close now, or nothing for the status. - -Options: - --key ... API keys to share (not admin keys), each until DURATION; with stop, the keys to stop sharing. - --allow ... Only these client addresses or ranges may use the keys given, such as 203.0.113.7. - -v, --verbose Show the output of every underlying process (also GOETHE_VERBOSE=1); it is always kept in /logs. - --dangerously-allow-all-inbound Allow every address on the public gateway (0.0.0.0/0). Rate limits still apply. Not with --allow. - --port The public port (default 8444, or the last one used). - -h, --help Print help - -Examples: - - → goethe api share 5h --key my-app --allow /32 - → goethe api share 5h --key my-app --dangerously-allow-all-inbound - → goethe api share (status) - → goethe api share stop - ---allow is who may connect (their public IP: ask them, or https://ifconfig.me on their device). This machine's IP is only the URL goethe prints. Reopening the same keys keeps their last addresses. --dangerously-allow-all-inbound opens to every address (rate limits still apply). Closes when the last key ends. -``` - -exit: `0` -**result:** pass - -### goethe api expose --help - -``` -+ goethe api expose --help -``` - -``` -Who can reach the API: local, vpn, public, or one address or interface. - -Usage: goethe api expose [OPTIONS] [WHERE] - -Arguments: - [WHERE] local, vpn or public; or an address (127.0.0.1, 0.0.0.0, an IP of this host) or an interface such as wg0 to listen on. - -Options: - --interface With vpn or public: the network interface to serve, e.g. wg0; the gateway follows its address. - --ip With vpn or public: a fixed address of this machine to listen on, instead of following an interface. - -v, --verbose Show the output of every underlying process (also GOETHE_VERBOSE=1); it is always kept in /logs. - --allow ... With vpn or public: client ranges to allow (default for vpn: the ranges the network reaches). - --yes Apply without questions (public still refuses 0.0.0.0/0). - --json With no WHERE: the status as JSON. - -h, --help Print help - -Who can reach the API: - - → goethe api expose local (this machine only) - → goethe api expose vpn --interface wg0 - → goethe api expose public --allow 203.0.113.7/32 - -Or listen on one address or interface directly: - - → goethe api expose 0.0.0.0 - → goethe api expose wg0 - -goethe api expose alone shows where the API listens and who may connect. -``` - -exit: `0` -**result:** pass - -### goethe models --help - -``` -+ goethe models --help -``` - -``` -Installed and catalog models; also recommend, scan and alias. - -Usage: goethe models [OPTIONS] - goethe models - -Commands: - recommend Catalog models that fit the free VRAM of the allowed GPUs. - scan Register model folders you downloaded yourself and moved into GOETHE_HOME/models. - alias Short model names for clients: list them, set one, or remove some. - help Print this message or the help of the given subcommand(s) - -Options: - -v, --verbose Show the output of every underlying process (also GOETHE_VERBOSE=1); it is always kept in /logs. - --json Emit JSON. - --installed Only installed models. - --available Only catalog models. - --all Every line; the default stops after 40. - -h, --help Print help -``` - -exit: `0` -**result:** pass - -### goethe run --help - -``` -+ goethe run --help -``` - -``` -Try a model by hand: a chat screen on a terminal without INPUT, else one reply, an embedding summary or an audio file's transcript. Loads an installed model that is not loaded and unloads it again. - -Usage: goethe run [OPTIONS] [MODEL]... - -Arguments: - [MODEL]... [MODEL] [INPUT]: MODEL may be left out when one model is loaded. - -Options: - --keep Leave a model loaded that this command loaded (it is unloaded when run ends otherwise). - --plain No chat screen: the plain prompt, as when input or output is not a terminal. - -v, --verbose Show the output of every underlying process (also GOETHE_VERBOSE=1); it is always kept in /logs. - --thinking Show the model's reasoning (dimmed) with the answer. - -h, --help Print help -``` - -exit: `0` -**result:** pass - -> goethe run has no -p/--prompt; INPUT is positional. CI should not teach -p. - -## 3. What fits - -### goethe models recommend - -``` -+ goethe models recommend -``` - -``` -VRAM free: 31.8 GB - -meshapplied/Qwen3.8-27B-NVFP4-NInfer ctx 100000 concurrency 4 - -Up to 24 GB -MODEL VRAM DOWNLOAD -nvidia/Qwen2.5-VL-7B-Instruct-NVFP4 22.2 GB/GPU · ctx 128000 · 8 conc 7.2 GB -nvidia/Llama-3.1-8B-Instruct-NVFP4 23.4 GB/GPU · ctx 65536 · 8 conc 6.0 GB - -Up to 48 GB -MODEL VRAM DOWNLOAD -nvidia/Qwen3.8-27B-NVFP4 26.8 GB/GPU · ctx 32768 · 8 conc 21.9 GB -microsoft/Phi-4-multimodal-instruct 28.2 GB/GPU · ctx 65536 · 8 conc 12.9 GB -meshapplied/Qwen3.8-27B-NVFP4-NInfer 28.4 GB/GPU · ctx 100000 · 4 conc - -``` - -exit: `0` -**result:** pass - -### goethe models - -``` -+ goethe models -``` - -``` -VRAM free: 31.8 GB - -Up to 24 GB -MODEL STATUS DISK FIT ON THIS MACHINE -nvidia/Qwen2.5-VL-7B-Instruct-NVFP4 available 7.2 GB fits: 22.2 GB per GPU (ctx 128000, 8 concurrent) -nvidia/Llama-3.1-8B-Instruct-NVFP4 available 6.0 GB fits: 23.4 GB per GPU (ctx 65536, 8 concurrent) - -Up to 48 GB -MODEL STATUS DISK FIT ON THIS MACHINE -nvidia/Qwen3.8-27B-NVFP4 (optimised kernels available) available 21.9 GB fits: 26.8 GB per GPU (ctx 32768, 8 concurrent) -microsoft/Phi-4-multimodal-instruct available 12.9 GB fits: 28.2 GB per GPU (ctx 65536, 8 concurrent) -meshapplied/Qwen3.8-27B-NVFP4-NInfer available 28.4 GB fits: 28.4 GB per GPU (ctx 100000, 4 concurrent) - -Too large for the allowed GPUs -MODEL STATUS DISK FIT ON THIS MACHINE -nvidia/Gemma-4-31B-IT-NVFP4 available 32.7 GB does not fit: not enough GPU memory -mistralai/Mistral-Small-3.1-24B-Instruct-2503 available 48.1 GB does not fit: not enough GPU memory -google/gemma-4-26B-A4B-it available 51.6 GB does not fit: not enough GPU memory -Qwen/Qwen3.8-27B available 55.6 GB does not fit: not enough GPU memory -meta-models/Muse-Glimmer-30B available 59.6 GB does not fit: not enough GPU memory -meshapplied/Qwen3.8-Flash-Next-NVFP4-Latest available 132.7 GB does not fit: not enough GPU memory (gated: needs your Hugging Face token or access) -nvidia/Qwen3.8-Flash-Next-NVFP4 available 132.7 GB does not fit: not enough GPU memory -deepseek-ai/DeepSeek-V4-Flash-0731 available 166.9 GB does not fit: not enough GPU memory -XiaomiMiMo/MiMo-V2.6-Flash-RL available 177.8 GB does not fit: not enough GPU memory -orcarouter/Qwen3.8-Flash-Next-Uncensored-NVFP4 available 183.5 GB does not fit: not enough GPU memory (gated: needs your Hugging Face token or access) -RedHatAI/GLM-5.3-Flash-NVFP4 available 197.9 GB does not fit: not enough GPU memory -nvidia/NVIDIA-Nemotron-3.5-Super-VL-120B-A12B-BF16 available 248.9 GB does not fit: not enough GPU memory -nvidia/MiniMax-M3-NVFP4 available 250.1 GB does not fit: not enough GPU memory -nvidia/Qwen3.5-397B-A17B-NVFP4 available 251.2 GB does not fit: not enough GPU memory -inclusionAI/Ling-3.0-flash available 255.0 GB does not fit: not enough GPU memory -Qwen/Qwen3.8-Flash-Next available 360.0 GB does not fit: not enough GPU memory -meshapplied/Qwen3.8-Flash-Next-Ternary-Latest available 391.9 GB does not fit: not enough GPU memory -nvidia/DeepSeek-V3.1-NVFP4 available 413.3 GB does not fit: not enough GPU memory -nvidia/DeepSeek-V3.2-NVFP4 available 415.1 GB does not fit: not enough GPU memory -nvidia/DeepSeek-V3-0324-NVFP4 available 423.7 GB does not fit: not enough GPU memory -nvidia/DeepSeek-R1-NVFP4 available 423.7 GB does not fit: not enough GPU memory -LibertAIDAI/DeepSeek-V4.1-Flash-1017-NVFP4 available 429.0 GB does not fit: not enough GPU memory -nvidia/GLM-5.2-NVFP4 available 464.9 GB does not fit: not enough GPU memory -Qwen/Qwen3-VL-235B-A22B-Instruct available 471.4 GB does not fit: not enough GPU memory -deepseek-ai/DeepSeek-V4.1-Flash-1017 available 510.3 GB does not fit: not enough GPU memory -... 23 more lines; all of them: goethe models --all -``` - -exit: `0` -**result:** pass - -> Compare models vs recommend per-GPU + ctx wording for the same id. - -## 4. Local path model (scan + install from folder) - -### models scan HF-id form (footgun check) - -``` -+ goethe models scan ggml-org/embeddinggemma-2-GGUF -``` - -``` -ggml-org/embeddinggemma-2-GGUF: No such file or directory (os error 2) -``` - -exit: `1` -**result:** pass (HF-id form rejected) - -### models scan folder name --yes - -``` -+ goethe models scan ggml-org__embeddinggemma-2-GGUF --yes -``` - -``` -ggml-org__embeddinggemma-2-GGUF: No such file or directory (os error 2) -``` - -exit: `1` -**result:** FAIL (expected success) - -### models --installed after scan - -``` -+ goethe models --installed -``` - -``` -VRAM free: 31.8 GB -``` - -exit: `0` -**result:** pass - -### install from absolute path --name - -``` -+ goethe install /home/v/proj/petya/goethe-e2e-180/home/models/ggml-org__embeddinggemma-2-GGUF --name ggml-org/embeddinggemma-2-GGUF --yes -``` - -``` -engine installing 0.3.0 (about 5 GB with PyTorch, once) -engine 0.3.0 ready (4.6 GB, 4 s) -ggml-org/embeddinggemma-2-GGUF goethe-engine ctx 1024 0.3 GB + 28 MB/req -files stay in /data/proj/gc/goethe-models/ggml-org__embeddinggemma-2-GGUF (goethe remove only unregisters) -run: goethe run ggml-org/embeddinggemma-2-GGUF -``` - -exit: `0` -**result:** pass - -### models --installed after install path - -``` -+ goethe models --installed -``` - -``` -VRAM free: 31.8 GB - -Installed -MODEL STATUS DISK FIT ON THIS MACHINE -ggml-org/embeddinggemma-2-GGUF (optimised kernels available) installed 0.4 GB fits: 0.9 GB per GPU (ctx 1024, 8 concurrent) -``` - -exit: `0` -**result:** pass - -## 5. API key + tailnet expose (NO lasting public) - -### create key e2e-tailnet - -``` -+ goethe api keys create e2e-tailnet --models ggml-org/embeddinggemma-2-GGUF -``` - -``` -API key for e2e-tailnet (id a62afdf8be04): - - goethe_sk_REDACTED - -goethe api shows it again at any time. -``` - -exit: `0` -**result:** pass - -### captured bearer (redact in shared copies) -``` -goethe_sk_REDACTED -``` - -### expose vpn on tailscale0 with CGNAT allow - -``` -+ goethe api expose vpn --interface tailscale0 --allow 100.64.0.0/10 --yes -``` - -``` -Gateway now: listening on 127.0.0.1 port 8443; allowlist: empty (every client refused) -The gateway will listen on 100.90.97.111 (tailscale0; follows its address) and on 127.0.0.1, and allow 100.64.0.0/10. -gateway listens on 100.90.97.111 (tailscale0; follows its address) port 8443 -allowed 127.0.0.1/32 (this machine) -allowed 100.64.0.0/10 (tailscale0 clients) -API keys: 1 exist (goethe api keys; goethe api keys create for each new client) - -API: https://100.90.97.111:8443/v1 - -For the models and keys run: - - → goethe api -``` - -exit: `0` -**result:** pass - -### goethe api expose (status) - -``` -+ goethe api expose -``` - -``` -bind: 100.90.97.111 (follows tailscale0) (remote clients reach it when allowlisted) -port: 8443 -url: https://100.90.97.111:8443 -state: running -allowlist: 2 entries -``` - -exit: `0` -**result:** pass - -### allowlist shows tailnet - -``` -+ goethe api allow -``` - -``` -ALLOWED CLIENTS -100.64.0.0/10 -127.0.0.1/32 -``` - -exit: `0` -**result:** pass - -### ss after vpn expose - -``` -+ bash -c ss -ltn | grep -E "8443|8444" || true -``` - -``` -LISTEN 0 511 127.0.0.1:8443 0.0.0.0:* -LISTEN 0 511 100.90.97.111:8443 0.0.0.0:* -``` - -exit: `0` - -### public expose without new allow - -``` -+ goethe api expose public --yes -``` - -``` -Gateway now: listening on 100.90.97.111 (following tailscale0) port 8443; allowlist: 100.64.0.0/10, 127.0.0.1/32 -WARNING: exposing the API on a public network is not recommended. - - Anyone who can reach this machine can attempt to connect; only the allowlist and API keys stop them. - - Allow only the client IPs you trust (goethe api allow add /32) and give every client its own key. - - Open the gateway port in your firewall or router yourself; Goethe does not change them. - - The certificate is self-signed, so clients must trust it or skip verification. -Your public IP: 81.182.125.247 -> API: https://81.182.125.247:8443/v1 -This machine is behind NAT (81.182.125.247 is not on its interfaces): forward TCP port 8443 on your router or cloud firewall to it. -goethe api expose: restarting nginx to move the listener from 100.90.97.111 to 0.0.0.0 -goethe api expose: stopping nginx master [3213137] -gateway listens on 0.0.0.0 port 8443 (restarted) -No client addresses were added: only addresses already on the allowlist can connect (goethe api allow add /32). -API keys: 1 exist (goethe api keys; goethe api keys create for each new client) - -API: https://81.182.125.247:8443/v1 - -For the models and keys run: - - → goethe api -``` - -exit: `0` -**result:** FAIL for prod bar — public bind succeeded; allowlist unchanged (0.0.0.0 listen) - -> Reverting to vpn/tailnet immediately after public probe. - -### revert expose vpn after public probe - -``` -+ goethe api expose vpn --interface tailscale0 --allow 100.64.0.0/10 --yes -``` - -``` -Gateway now: listening on 0.0.0.0 port 8443; allowlist: 100.64.0.0/10, 127.0.0.1/32 -The gateway will listen on 100.90.97.111 (tailscale0; follows its address) and on 127.0.0.1, and allow 100.64.0.0/10. -goethe api expose: restarting nginx to move the listener from 0.0.0.0 to 100.90.97.111 -goethe api expose: stopping nginx master [3213913] -gateway listens on 100.90.97.111 (tailscale0; follows its address) port 8443 (restarted) -API keys: 1 exist (goethe api keys; goethe api keys create for each new client) - -API: https://100.90.97.111:8443/v1 - -For the models and keys run: - - → goethe api -``` - -exit: `0` - -### ss after revert - -``` -+ bash -c ss -ltn | grep -E "8443|8444" || true -``` - -``` -LISTEN 0 511 127.0.0.1:8443 0.0.0.0:* -LISTEN 0 511 100.90.97.111:8443 0.0.0.0:* -``` - -exit: `0` -**result:** pass (no 0.0.0.0:8443 after vpn revert) - -### share without --allow - -``` -+ goethe api share 5m --key e2e-tailnet -``` - -``` -name who may connect with --allow /32 (their phone or laptop's public IP, not this machine's). this machine's public address is 81.182.125.247 (that becomes the URL, not --allow); ask them; to open to every address use --dangerously-allow-all-inbound -``` - -exit: `1` -**result:** pass (refused as expected) - -### share with this-machine public IP as --allow - -``` -+ bash -c - IP=$(curl -4 -fsS --max-time 3 ifconfig.me || true) - if [ -z "$IP" ]; then echo "skip: no public ip"; exit 1; fi - goethe api share 5m --key e2e-tailnet --allow "$IP/32" - -``` - -``` -81.182.125.247/32 is this machine's public address (the URL), not who may connect; use their phone or laptop's public IP -``` - -exit: `1` -**result:** pass (refused as expected) - -### share status closed - -``` -+ goethe api share -``` - -``` -The public gateway is closed. Open it with: goethe api share 5h --key --allow /32 -``` - -exit: `0` -**result:** pass - -### ss :8444 must be absent - -``` -+ bash -c ss -ltn | grep 8444 || echo no_8444 -``` - -``` -no_8444 -``` - -exit: `0` - -## 6. Load + run embedding model - -### load dry-run embedding - -``` -+ goethe load ggml-org/embeddinggemma-2-GGUF --dry-run -``` - -``` -would place ggml-org/embeddinggemma-2-GGUF tp=1 on GPU 0 at ctx 1024: 0.9 GB per GPU (weights 0.3 + KV 0.0 + sliding-window KV 0.1 + overhead 0.5) - GPU 0: 31.3 GB free, other software is running there -``` - -exit: `0` -**result:** pass - -### load embedding - -``` -+ goethe load ggml-org/embeddinggemma-2-GGUF -``` - -``` -GPU 0 has unmanaged process PID 2046 (Xorg, user gdm) using 0.0 GB VRAM -Goethe never stops processes it did not start. To stop it yourself: sudo kill 2046 -Free VRAM on GPU 0: 31.3 GB; this load needs 0.9 GB. -Re-run with --yes to load alongside it. -not loading next to processes goethe did not start: re-run with --yes (no terminal to ask on) -``` - -exit: `3` -**result:** FAIL (expected success) - -### goethe ps - -``` -+ goethe ps -``` - -``` -No models loaded. Pick one and load it: - - → goethe models - → goethe load -``` - -exit: `0` -**result:** pass - -### goethe status after load - -``` -+ goethe status -``` - -``` -goethe: running -API: https://100.90.97.111:8443/v1 -API KEY NAME KEY ID -e2e-tailnet a62afdf8be04 - -No models loaded. Pick one and load it: - - → goethe models - → goethe load - -Platform: Not linked (goethe login) -``` - -exit: `0` -**result:** pass - -### goethe run embed positional INPUT - -``` -+ goethe run --plain ggml-org/embeddinggemma-2-GGUF hello greengoblin e2e -``` - -``` -GPU 0 has unmanaged process PID 2046 (Xorg, user gdm) using 0.0 GB VRAM -Goethe never stops processes it did not start. To stop it yourself: sudo kill 2046 -Free VRAM on GPU 0: 31.3 GB; this load needs 0.9 GB. -Re-run with --yes to load alongside it. -not loading next to processes goethe did not start: re-run with --yes (no terminal to ask on) -``` - -exit: `3` -**result:** FAIL - -### goethe run with -- separator (footgun) - -``` -+ goethe run ggml-org/embeddinggemma-2-GGUF -- embed hello -``` - -``` -error: unexpected value 'hello' for '[MODEL]...' found; no more were expected - -Usage: goethe run [OPTIONS] [MODEL]... - -For more information, try '--help'. -``` - -exit: `2` -**result:** pass (bad argv rejected) - -### curl /v1/models via 127.0.0.1 + cacert - -``` -+ curl -sS --max-time 20 --cacert /home/v/proj/petya/goethe-e2e-180/home/nginx/certs/server.crt https://127.0.0.1:8443/v1/models -H Authorization: Bearer goethe_sk_REDACTED -``` - -``` -{"data":[],"object":"list"} -``` - -exit: `0` -**result:** pass - -### curl /v1/models via tailnet IP + cacert - -``` -+ curl -sS --max-time 20 --cacert /home/v/proj/petya/goethe-e2e-180/home/nginx/certs/server.crt https://100.90.97.111:8443/v1/models -H Authorization: Bearer goethe_sk_REDACTED -``` - -``` -curl: (60) SSL: no alternative certificate subject name matches target host name '100.90.97.111' -More details here: https://curl.se/docs/sslcerts.html - -curl failed to verify the legitimacy of the server and therefore could not -establish a secure connection to it. To learn more about this situation and -how to fix it, please visit the web page mentioned above. -``` - -exit: `60` -**result:** FAIL (expected success) - -### curl /v1/embeddings via tailnet - -``` -+ curl -sS --max-time 90 --cacert /home/v/proj/petya/goethe-e2e-180/home/nginx/certs/server.crt https://100.90.97.111:8443/v1/embeddings -H Authorization: Bearer goethe_sk_REDACTED -H Content-Type: application/json -d {"model":"ggml-org/embeddinggemma-2-GGUF","input":"greengoblin e2e"} -``` - -``` -curl: (60) SSL: no alternative certificate subject name matches target host name '100.90.97.111' -More details here: https://curl.se/docs/sslcerts.html - -curl failed to verify the legitimacy of the server and therefore could not -establish a secure connection to it. To learn more about this situation and -how to fix it, please visit the web page mentioned above. -``` - -exit: `60` -**result:** FAIL (expected success) - -### curl embeddings without key -HTTP `000` -``` -``` -**result:** FAIL (expected 401/403, got 000) - -## 7. Chat model (if linked) - -> Llama NVFP4 tree not linked; skipped chat load. - -## 8. More failure / UX probes - -### load missing model - -``` -+ goethe load definitely-missing-model-xyz -``` - -``` -model definitely-missing-model-xyz is not installed (goethe models lists installed models; goethe install definitely-missing-model-xyz adds it) -``` - -exit: `1` -**result:** pass (refused as expected) - -### run missing model - -``` -+ goethe run --plain definitely-missing-model-xyz hi -``` - -``` -definitely-missing-model-xyz is not installed: goethe install definitely-missing-model-xyz -``` - -exit: `1` -**result:** pass (refused as expected) - -### load --dry-run missing - -``` -+ goethe load definitely-missing-model-xyz --dry-run -``` - -``` -model definitely-missing-model-xyz is not installed (goethe models lists installed models; goethe install definitely-missing-model-xyz adds it) -``` - -exit: `1` - -### share dangerously without remembered key - -``` -+ goethe api share 5m --dangerously-allow-all-inbound -``` - -``` -name the API keys to allow with --key (the next time they are remembered); list them with goethe api keys -``` - -exit: `1` -**result:** pass (refused as expected) - -### gpu table - -``` -+ goethe gpu -``` - -``` - - ▣ GPU ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ - gpu0 0.5 GB ░░░░░░░░░░ 31.8 GB 2046 ALLOWED ░░░░░░░░░░ 0% - - █ goethe models █ other processes ░ free █ memory bandwidth -``` - -exit: `0` - -### logs goethed (tail) - -``` -+ bash -c goethe logs goethed 2>&1 | tail -50 -``` - -``` -log not found: /home/v/proj/petya/goethe-e2e-180/home/logs/goethed.log -``` - -exit: `0` - -## 8b. URL consistency - -### goethe status (URLs) - -``` -+ goethe status -``` - -``` -goethe: running -API: https://100.90.97.111:8443/v1 -API KEY NAME KEY ID -e2e-tailnet a62afdf8be04 - -No models loaded. Pick one and load it: - - → goethe models - → goethe load - -Platform: Not linked (goethe login) -``` - -exit: `0` - -### goethe api (URLs) - -``` -+ goethe api -``` - -``` -API endpoint: https://100.90.97.111:8443/v1 -SSL_CERT_FILE=/home/v/proj/petya/goethe-e2e-180/home/nginx/certs/server.crt -Accepts: OpenAI, Anthropic (/v1/messages) and LiteLLM (routes with or without /v1, x-litellm-api-key) - -API keys -NAME API KEY ADMIN EXPIRES -e2e-tailnet goethe_sk_REDACTED no never - -Query the API: - - → curl --cacert /home/v/proj/petya/goethe-e2e-180/home/nginx/certs/server.crt https://100.90.97.111:8443/v1/chat/completions -H "Authorization: Bearer " -H "Content-Type: application/json" -d '{"model": "", "messages": [{"role": "user", "content": "Hello!"}]}' -``` - -exit: `0` - -### goethe api expose - -``` -+ goethe api expose -``` - -``` -bind: 100.90.97.111 (follows tailscale0) (remote clients reach it when allowlisted) -port: 8443 -url: https://100.90.97.111:8443 -state: running -allowlist: 2 entries -``` - -exit: `0` - -## 9. Cleanup on box - -### unload all - -``` -+ goethe unload --all -``` - -``` -nothing was loaded -``` - -exit: `0` - -### expose local - -``` -+ goethe api expose local --yes -``` - -``` -Gateway now: listening on 100.90.97.111 (following tailscale0) port 8443; allowlist: 100.64.0.0/10, 127.0.0.1/32 -gateway listens on 127.0.0.1 port 8443 -API keys: 1 exist (goethe api keys; goethe api keys create for each new client) - -API: https://127.0.0.1:8443/v1 - -For the models and keys run: - - → goethe api -``` - -exit: `0` - -### share stop - -``` -+ goethe api share stop -``` - -``` -The public gateway is not open. -``` - -exit: `0` - -### goethe down (e2e) - -``` -+ goethe down -``` - -``` -goethed stopped -goethed will not start at boot until the next goethe up -``` - -exit: `0` - -### ss after e2e down - -``` -+ bash -c ss -ltn | grep -E "8443|8444" || echo none -``` - -``` -none -``` - -exit: `0` - -> Restoring production Goethe. - -> Prod not on 0.0.0.0:8443 - -## Scoreboard - -- Passes: **33** -- Failures / unexpected: **7** -- Full command log: `/home/v/proj/petya/goethe-e2e-180/session.log` -- Isolated home: `/home/v/proj/petya/goethe-e2e-180/home` — delete when done: `rm -rf /home/v/proj/petya/goethe-e2e-180` - -## Findings (observed, not softened) - -1. UX footgun: users typing HF id into models scan get os error 2; hint should say use folder name org__name or goethe install -2. FAIL ok: models scan folder name --yes -3. api expose public --yes binds 0.0.0.0 without requiring a public client allow; only warns. Listener is world-reachable if NAT/firewall forwards; nginx allowlist may still drop non-listed clients. -4. FAIL ok: load embedding -5. goethe run --plain embed INPUT failed (exit 3) -6. UX: goethe run does not take -- extra args; clap error is opaque for users copying engine-flag patterns -7. FAIL ok: curl /v1/models via tailnet IP + cacert -8. FAIL ok: curl /v1/embeddings via tailnet -9. embeddings without bearer returned HTTP 000 (expected 401/403) - -## CI / follow-up test ideas - -1. Assert `goethe models scan org/name` fails with a hint to use `org__name` folder form. -2. Assert `goethe api expose public --yes` either refuses without a non-VPN client allow, or never binds `0.0.0.0` unless `--dangerously-allow-all-inbound` (product decision). -3. After any public probe in E2E, assert `ss` has no `0.0.0.0:8443` / `:8444`. -4. `goethe run --plain ` happy path for embed + chat; reject teaching `run -- -p`. -5. Curl `/v1/models` and `/v1/embeddings` with cacert over tailnet IP; 401 without bearer. -6. Share: machine public IP as `--allow` must refuse; no `--allow` must refuse. -7. Script must not `set -e` across soft failures (v1 aborted mid-session). - - -## Findings (refined after follow-up — zero gaslight) - -### P0 / product - -1. **`goethe api expose public --yes` binds `0.0.0.0` without requiring a public client allow.** It keeps the existing VPN allowlist and only warns. Nginx may still drop non-allowlisted clients, but the socket is world-reachable if NAT/firewall forwards. Prod bar decision needed: refuse unless a non-VPN client CIDR is supplied, or require `--dangerously-allow-all-inbound` to bind `0.0.0.0`. - -2. **Gateway TLS cert SANs omit the tailnet IP.** Observed SANs: `DNS:localhost`, `IP:127.0.0.1`, `DNS:greengoblin`. **No `100.90.97.111`.** `goethe api` tells users to `curl --cacert … https://100.90.97.111:8443/…` which **fails with curl 60** (name mismatch). Localhost with cacert works. Users must `-k` today — docs/UX lie by omission. - -### P1 / real user footguns - -3. **`goethe models scan ` resolves the argument from CWD via `canonicalize`, not from `GOETHE_HOME/models`.** Passing `ggml-org__embeddinggemma-2-GGUF` as the help text suggests yields `No such file or directory (os error 2)` unless that name exists in the current working directory. Code: `scan.rs` `candidate_dirs`. Fix: try `models.join(d)` before raw `d`. - -4. **`goethe models scan` (no args) refuses a symlink under models/** with “register the folder it points to with `goethe install `”. Symlinking an already-installed tree into a fresh `GOETHE_HOME` (isolated / multi-home) does not work via scan. **`goethe install --name …` works** (creates a symlink farm). Document this; optionally teach scan to follow+register like install. - -5. **Non-interactive `goethe load` / `goethe run` refuse GPU 0 when Xorg/gdm holds 0.0 GB VRAM** unless `--yes`. Message is clear. Scripts/SSH/CI without a TTY always need `--yes` on boxes with a display manager. E2E must pass `--yes`. - -6. **`goethe run` INPUT is positional; there is no `-p` / `--` engine-flag passthrough.** `goethe run model -- embed hi` → opaque clap error. Users copying install/`--` patterns get confused. - -### P2 / isolation & ops - -7. **Second `GOETHE_HOME` while systemd user unit owns another home:** `goethe up` warns and may pick **18443** (see `ports.rs` 18443–18499) instead of 8443. Heartbeat unit stays on prod home. Isolated E2E must `goethe down` prod **and** account for port shift, or disable the other unit. Follow-up accidentally curled 8443 while e2e listened on 18443. - -8. **v1 E2E script aborted mid-run** because `run()` re-enabled `set -e` and a bare failing command exited the script before cleanup/scoreboard. Fixed in v2. - -### What worked - -- Isolated `GOETHE_HOME` + PR180 binary `0.3.3` build on greengoblin. -- `goethe up` / `status` / `doctor` / `doctor --hardware`. -- `models recommend` + `models` fit labels with per-GPU / ctx / concurrency. -- `goethe install --name ggml-org/embeddinggemma-2-GGUF --yes` registers local tree. -- Tailnet expose: `api expose vpn --interface tailscale0 --allow 100.64.0.0/10 --yes` → listen `100.90.97.111:8443` + `127.0.0.1`, allowlist CGNAT + localhost. -- Share without `--allow` refuses; machine public IP as `--allow` refuses; no `:8444`. -- After public probe, vpn revert cleared `0.0.0.0:8443`. -- **Follow-up:** `load --yes` + `run --plain --keep` embedding → `dims=768 norm=1.0000 […]` success. -- localhost `/v1/models` with bearer + cacert → JSON list (empty when unloaded). -- Missing model load/run refuse cleanly. -- Prod restored: `100.90.97.111:8443` + `127.0.0.1:8443`, not public; heartbeat OK; key `matteo` intact. - -### Not covered this session - -- Chat/Llama load: no Llama tree under prod `models/` (only embeddinggemma). -- True multi-client curl from another tailnet node (this runner used on-box curls). -- Public share happy path (intentionally out of scope — fail-closed only). -- Kernel-pack / ternary / ninfer paths. - -### Box state after session - -- Prod goethe **0.3.1** running, tailnet bind only. -- E2E home left at `/home/v/proj/petya/goethe-e2e-180` for inspection (safe to `rm -rf`). -- No e2e `goethed` left running. - -## Incident closeout (public 0.0.0.0) - -- **Now:** CLOSED. Prod listens only `100.90.97.111:8443` + `127.0.0.1:8443`. No `:8444`. No e2e daemon. -- **Attack evidence:** e2e nginx access log had only `127.0.0.1`. Prod Nov 18 access was only tailnet `100.x` (our follow-up curls, 401). No foreign public IPs. -- **Why not internet-wide open in practice:** (1) NAT: public IP `81.182.125.247` is not on any iface; inbound needs router forward. (2) nginx allowlist stayed `100.64.0.0/10` + `127.0.0.1` (deny all else). (3) API key still required. **Still wrong:** LAN `192.168.1.134:8443` could accept SYNs while bound to `0.0.0.0` (would then hit deny/401). -- **Windows:** v2 ~5s (`22:11:23` to `22:11:28`). v1 aborted without auto-revert until manual `goethe down` (~1 min class). -- **Fix shipped:** `expose public --yes` without `--allow` refuses; raw `expose 0.0.0.0` refuses; public needs confirm + named clients; `--dangerously-allow-all-inbound` hidden for world-open. diff --git a/docs/e2e-traces/TRACE-v1-aborted.md b/docs/e2e-traces/TRACE-v1-aborted.md deleted file mode 100644 index 594a3945..00000000 --- a/docs/e2e-traces/TRACE-v1-aborted.md +++ /dev/null @@ -1,704 +0,0 @@ -# Goethe PR180 greengoblin E2E session - -- **When (UTC):** 2026-11-18T21:07:05Z -- **Host:** greengoblin -- **Binary:** `/home/v/proj/petya/goethe-pr180/engine/target/release/goethe` (`goethe 0.3.3`) -- **GOETHE_HOME (isolated):** `/home/v/proj/petya/goethe-e2e-180/home` -- **Prod goethe (restored after):** `/home/v/.local/bin/goethe` -- **Scope:** install/scan local path, fit, load, run (chat + embed), CLI, tailnet expose only — **no public share** -- **GPU:** GPU 0: NVIDIA GeForce RTX 5090 (UUID: GPU-aaabe7a6-e328-9869-cca8-a8e56a3d4591) - -## Method - -Isolated `GOETHE_HOME` so the live 0.3.x install is not mutated. Production `goethe` is stopped for the session (port/GPU), then started again. Findings are written as observed — not softened. - -## Preflight -disk: - Filesystem Size Used Avail Use% Mounted on - /dev/nvme0n1p1 3.6T 3.0T 489G 86% / - /dev/nvme0n1p1 3.6T 3.0T 489G 86% / -gpu mem: - memory.used [MiB], memory.free [MiB], memory.total [MiB] - 15 MiB, 32095 MiB, 32607 MiB -prod status: - goethe: running - API: https://100.90.97.111:8443/v1 - API KEY NAME KEY ID - matteo 95f818903035 - - No models loaded. Pick one and load it: - - → goethe models - → goethe load - - Platform: Linked (workspace Personal, heartbeat OK (10 s ago)) -share (prod binary may lack subcommand): - The public gateway is closed. Open it with: goethe api share 5h --key - -> Stopping production Goethe for isolated E2E (will restore). - -## 1. Start (fresh home) - -### goethe up - -``` -+ goethe up -``` - -``` -goethe: running -API: https://127.0.0.1:8443/v1 -keys: none, create one with: goethe api keys create my-app - -No models loaded. Pick one and load it: - - → goethe models - → goethe load - -Platform: Not linked (goethe login) -``` - -exit: `0` -**result:** pass - -### goethe status - -``` -+ goethe status -``` - -``` -goethe: running -API: https://127.0.0.1:8443/v1 -keys: none, create one with: goethe api keys create my-app - -No models loaded. Pick one and load it: - - → goethe models - → goethe load - -Platform: Not linked (goethe login) -``` - -exit: `0` -**result:** pass - -### goethe doctor - -``` -+ goethe doctor -``` - -``` -CHECK STATUS DETAIL -hardware OK driver 580.178.04 - gpu0 NVIDIA GeForce RTX 5090 (SM 12.0): 31.3 of 31.8 GB free, 0 foreign processes -platform INFO not logged in: optional; goethe login links this node and unlocks optimised kernels -cloud INFO no cloud provider detected -py-env INFO not set up yet: the first goethe install of a model sets it up (about 30 MB, more for engines) -also OK: driver, glibc, nginx, goethe_home, disk, ram, state_db, environment, ports, goethed, gateway, network, tls, huggingface, registry, nvidia_driver, compiler (goethe -v doctor lists them) - -GPU architectures goethe supports: sm_80 (Ampere data center), sm_86 (Ampere), sm_89 (Ada), sm_90a (Hopper), sm_100a (Blackwell data center), sm_103a (Blackwell Ultra data center), sm_120a (Blackwell), sm_121a (Blackwell) -Architectures of this machine: sm_120a -``` - -exit: `0` -**result:** pass - -### goethe doctor --hardware - -``` -+ goethe doctor --hardware -``` - -``` -Goethe hardware profile at 2026-11-18T21:07:13Z -Driver: 580.178.04 -GPU NAME VRAM TOTAL VRAM FREE PCIE -gpu0 NVIDIA GeForce RTX 5090 31.8 GB 31.3 GB PCIe 5 x16 - SM 12.0 -CPU: Intel(R) Core(TM) Ultra 7 265K (GenuineIntel), 1 socket(s), 20 cores, 20 threads, flags [avx2] -RAM: 125.1 GB total, 119.7 GB available; swap 3.6/8.0 GB free; hugepages 0/0 free (2048 kB) -Disk goethe_home: /home/v/proj/petya/goethe-e2e-180/home on / (ext4) 525 GB free of 3936 GB -Disk models: /home/v/proj/petya/goethe-e2e-180/home/models on / (ext4) 525 GB free of 3936 GB -OS: Ubuntu 24.04.3 LTS, kernel 7.0.0-42-generic, glibc 2.39 -NVIDIA driver 580.178.04, CUDA driver 13.0 -Environment: no container, systemd is PID 1, cloud none -``` - -exit: `0` -**result:** pass - -## 2. CLI surface / help consistency - -### goethe --help - -``` -+ goethe --help -``` - -``` -Goethe: serve models through OpenAI and Anthropic compatible gateways - -Start and stop - goethe the menu: quick setup, install models, API keys and gateway, status - goethe up start Goethe now and at every boot - goethe down stop Goethe; loaded models come back on the next up - goethe status running or not, the API address, keys and served models - goethe ps running models in detail: GPUs, memory, requests, speed - -Models - goethe install MODEL --load download from Hugging Face (or add a folder) and serve it - goethe load MODEL --gpu gpu2 gpu3 serve an installed model on these GPUs - goethe load MODEL --ctx 32768 --save the same, and keep the settings as its defaults - goethe load MODEL --dry-run show where it would go, load nothing - goethe unload MODEL stop serving it (--all stops every model) - goethe remove MODEL unload and delete it - goethe run MODEL try it by hand: chat, one reply, embedding or transcript - goethe models installed and catalog models - goethe models recommend catalog models that fit your GPUs - goethe models scan FOLDER register a folder you put in GOETHE_HOME/models - goethe models alias set fast MODEL a short name clients can use (remove fast drops it) - goethe logs MODEL -f follow a model's log (also goethed or gateway) - -API and access - goethe api the address, the keys and a curl command to try it - goethe api keys list the keys (a menu on a terminal) - goethe api keys create my-app a new key (also --expires 30d --rpm 300 --models ID --admin) - goethe api keys revoke KEY_ID revoke a key - goethe api expose where the API listens and who may connect - goethe api expose vpn --interface wg0 serve a VPN or private network (also local or public) - goethe api allow add 203.0.113.7/32 let a client address in (remove takes it out) - goethe api domain check DOMAIN check that a domain reaches the API - goethe api share 5h --key my-app --allow /32 open a public address for a while (share stop closes it) - -Learning and traces - goethe learn on sessions keep what compaction drops (--model M for one model) - goethe trace on record requests and replies for training (--key K for one key) - -Machine - goethe gpu GPUs live: memory, processes and bandwidth - goethe gpu deny gpu2 keep new models off a GPU (allow gpu2 undoes it) - goethe doctor check the machine and the setup, with a fix for each problem - goethe doctor --hardware the hardware profile: GPUs and links, CPU, RAM, disk, OS - goethe update signed update of Goethe, its engines and kernel packs - goethe uninstall remove Goethe and the models it installed - goethe login link this node to the Goethe platform (optional) - goethe logout unlink it and remove its local credentials - goethe completion install tab completion for your shell - -MODEL is a Hugging Face id, an installed id, an alias or words from a name, for example: - - → goethe install nvidia/Qwen2.5-VL-7B-Instruct-NVFP4 --load -``` - -exit: `0` -**result:** pass - -### goethe api share --help - -``` -+ goethe api share --help -``` - -``` -Open the API on a public address for a while, for chosen API keys; stop closes it. - -Usage: goethe api share [OPTIONS] [DURATION] - -Arguments: - [DURATION] How long to stay open (30m, 5h, 1d; at most 7d), stop to close now, or nothing for the status. - -Options: - --key ... API keys to share (not admin keys), each until DURATION; with stop, the keys to stop sharing. - --allow ... Only these client addresses or ranges may use the keys given, such as 203.0.113.7. - -v, --verbose Show the output of every underlying process (also GOETHE_VERBOSE=1); it is always kept in /logs. - --dangerously-allow-all-inbound Allow every address on the public gateway (0.0.0.0/0). Rate limits still apply. Not with --allow. - --port The public port (default 8444, or the last one used). - -h, --help Print help - -Examples: - - → goethe api share 5h --key my-app --allow /32 - → goethe api share 5h --key my-app --dangerously-allow-all-inbound - → goethe api share (status) - → goethe api share stop - ---allow is who may connect (their public IP: ask them, or https://ifconfig.me on their device). This machine's IP is only the URL goethe prints. Reopening the same keys keeps their last addresses. --dangerously-allow-all-inbound opens to every address (rate limits still apply). Closes when the last key ends. -``` - -exit: `0` -**result:** pass - -### goethe api expose --help - -``` -+ goethe api expose --help -``` - -``` -Who can reach the API: local, vpn, public, or one address or interface. - -Usage: goethe api expose [OPTIONS] [WHERE] - -Arguments: - [WHERE] local, vpn or public; or an address (127.0.0.1, 0.0.0.0, an IP of this host) or an interface such as wg0 to listen on. - -Options: - --interface With vpn or public: the network interface to serve, e.g. wg0; the gateway follows its address. - --ip With vpn or public: a fixed address of this machine to listen on, instead of following an interface. - -v, --verbose Show the output of every underlying process (also GOETHE_VERBOSE=1); it is always kept in /logs. - --allow ... With vpn or public: client ranges to allow (default for vpn: the ranges the network reaches). - --yes Apply without questions (public still refuses 0.0.0.0/0). - --json With no WHERE: the status as JSON. - -h, --help Print help - -Who can reach the API: - - → goethe api expose local (this machine only) - → goethe api expose vpn --interface wg0 - → goethe api expose public --allow 203.0.113.7/32 - -Or listen on one address or interface directly: - - → goethe api expose 0.0.0.0 - → goethe api expose wg0 - -goethe api expose alone shows where the API listens and who may connect. -``` - -exit: `0` -**result:** pass - -### goethe models --help - -``` -+ goethe models --help -``` - -``` -Installed and catalog models; also recommend, scan and alias. - -Usage: goethe models [OPTIONS] - goethe models - -Commands: - recommend Catalog models that fit the free VRAM of the allowed GPUs. - scan Register model folders you downloaded yourself and moved into GOETHE_HOME/models. - alias Short model names for clients: list them, set one, or remove some. - help Print this message or the help of the given subcommand(s) - -Options: - -v, --verbose Show the output of every underlying process (also GOETHE_VERBOSE=1); it is always kept in /logs. - --json Emit JSON. - --installed Only installed models. - --available Only catalog models. - --all Every line; the default stops after 40. - -h, --help Print help -``` - -exit: `0` -**result:** pass - -### goethe run --help - -``` -+ goethe run --help -``` - -``` -Try a model by hand: a chat screen on a terminal without INPUT, else one reply, an embedding summary or an audio file's transcript. Loads an installed model that is not loaded and unloads it again. - -Usage: goethe run [OPTIONS] [MODEL]... - -Arguments: - [MODEL]... [MODEL] [INPUT]: MODEL may be left out when one model is loaded. - -Options: - --keep Leave a model loaded that this command loaded (it is unloaded when run ends otherwise). - --plain No chat screen: the plain prompt, as when input or output is not a terminal. - -v, --verbose Show the output of every underlying process (also GOETHE_VERBOSE=1); it is always kept in /logs. - --thinking Show the model's reasoning (dimmed) with the answer. - -h, --help Print help -``` - -exit: `0` -**result:** pass - -## 3. What fits - -### goethe models recommend - -``` -+ goethe models recommend -``` - -``` -VRAM free: 31.8 GB - -meshapplied/Qwen3.8-27B-NVFP4-NInfer ctx 100000 concurrency 4 - -Up to 24 GB -MODEL VRAM DOWNLOAD -nvidia/Qwen2.5-VL-7B-Instruct-NVFP4 22.2 GB/GPU · ctx 128000 · 8 conc 7.2 GB -nvidia/Llama-3.1-8B-Instruct-NVFP4 23.4 GB/GPU · ctx 65536 · 8 conc 6.0 GB - -Up to 48 GB -MODEL VRAM DOWNLOAD -nvidia/Qwen3.8-27B-NVFP4 26.8 GB/GPU · ctx 32768 · 8 conc 21.9 GB -microsoft/Phi-4-multimodal-instruct 28.2 GB/GPU · ctx 65536 · 8 conc 12.9 GB -meshapplied/Qwen3.8-27B-NVFP4-NInfer 28.4 GB/GPU · ctx 100000 · 4 conc - -``` - -exit: `0` -**result:** pass - -### goethe models - -``` -+ goethe models -``` - -``` -VRAM free: 31.8 GB - -Up to 24 GB -MODEL STATUS DISK FIT ON THIS MACHINE -nvidia/Qwen2.5-VL-7B-Instruct-NVFP4 available 7.2 GB fits: 22.2 GB per GPU (ctx 128000, 8 concurrent) -nvidia/Llama-3.1-8B-Instruct-NVFP4 available 6.0 GB fits: 23.4 GB per GPU (ctx 65536, 8 concurrent) - -Up to 48 GB -MODEL STATUS DISK FIT ON THIS MACHINE -nvidia/Qwen3.8-27B-NVFP4 (optimised kernels available) available 21.9 GB fits: 26.8 GB per GPU (ctx 32768, 8 concurrent) -microsoft/Phi-4-multimodal-instruct available 12.9 GB fits: 28.2 GB per GPU (ctx 65536, 8 concurrent) -meshapplied/Qwen3.8-27B-NVFP4-NInfer available 28.4 GB fits: 28.4 GB per GPU (ctx 100000, 4 concurrent) - -Too large for the allowed GPUs -MODEL STATUS DISK FIT ON THIS MACHINE -nvidia/Gemma-4-31B-IT-NVFP4 available 32.7 GB does not fit: not enough GPU memory -mistralai/Mistral-Small-3.1-24B-Instruct-2503 available 48.1 GB does not fit: not enough GPU memory -google/gemma-4-26B-A4B-it available 51.6 GB does not fit: not enough GPU memory -Qwen/Qwen3.8-27B available 55.6 GB does not fit: not enough GPU memory -meta-models/Muse-Glimmer-30B available 59.6 GB does not fit: not enough GPU memory -meshapplied/Qwen3.8-Flash-Next-NVFP4-Latest available 132.7 GB does not fit: not enough GPU memory (gated: needs your Hugging Face token or access) -nvidia/Qwen3.8-Flash-Next-NVFP4 available 132.7 GB does not fit: not enough GPU memory -deepseek-ai/DeepSeek-V4-Flash-0731 available 166.9 GB does not fit: not enough GPU memory -XiaomiMiMo/MiMo-V2.6-Flash-RL available 177.8 GB does not fit: not enough GPU memory -orcarouter/Qwen3.8-Flash-Next-Uncensored-NVFP4 available 183.5 GB does not fit: not enough GPU memory (gated: needs your Hugging Face token or access) -RedHatAI/GLM-5.3-Flash-NVFP4 available 197.9 GB does not fit: not enough GPU memory -nvidia/NVIDIA-Nemotron-3.5-Super-VL-120B-A12B-BF16 available 248.9 GB does not fit: not enough GPU memory -nvidia/MiniMax-M3-NVFP4 available 250.1 GB does not fit: not enough GPU memory -nvidia/Qwen3.5-397B-A17B-NVFP4 available 251.2 GB does not fit: not enough GPU memory -inclusionAI/Ling-3.0-flash available 255.0 GB does not fit: not enough GPU memory -Qwen/Qwen3.8-Flash-Next available 360.0 GB does not fit: not enough GPU memory -meshapplied/Qwen3.8-Flash-Next-Ternary-Latest available 391.9 GB does not fit: not enough GPU memory -nvidia/DeepSeek-V3.1-NVFP4 available 413.3 GB does not fit: not enough GPU memory -nvidia/DeepSeek-V3.2-NVFP4 available 415.1 GB does not fit: not enough GPU memory -nvidia/DeepSeek-V3-0324-NVFP4 available 423.7 GB does not fit: not enough GPU memory -nvidia/DeepSeek-R1-NVFP4 available 423.7 GB does not fit: not enough GPU memory -LibertAIDAI/DeepSeek-V4.1-Flash-1017-NVFP4 available 429.0 GB does not fit: not enough GPU memory -nvidia/GLM-5.2-NVFP4 available 464.9 GB does not fit: not enough GPU memory -Qwen/Qwen3-VL-235B-A22B-Instruct available 471.4 GB does not fit: not enough GPU memory -deepseek-ai/DeepSeek-V4.1-Flash-1017 available 510.3 GB does not fit: not enough GPU memory -... 23 more lines; all of them: goethe models --all -``` - -exit: `0` -**result:** pass - -> Check whether models vs recommend show comparable per-GPU + ctx lines for the same id. - -## 4. Local path model (scan + install from folder) - -### goethe models scan models/ggml-org__embeddinggemma-2-GGUF - -``` -+ goethe models scan ggml-org/embeddinggemma-2-GGUF -``` - -``` -ggml-org/embeddinggemma-2-GGUF: No such file or directory (os error 2) -``` - -exit: `1` -**result:** FAIL (expected success) - -### goethe models --installed - -``` -+ goethe models --installed -``` - -``` -VRAM free: 31.8 GB -``` - -exit: `0` -**result:** pass - -## 5. API key + tailnet expose (NO public) - -### create key e2e-tailnet - -``` -+ goethe api keys create e2e-tailnet --models ggml-org/embeddinggemma-2-GGUF -``` - -``` -API key for e2e-tailnet (id d5be91cb0cc5): - - goethe_sk_REDACTED - -goethe api shows it again at any time. -``` - -exit: `0` -**result:** pass - -### goethe api (capture) -``` -API endpoint: https://127.0.0.1:8443/v1 -SSL_CERT_FILE=/home/v/proj/petya/goethe-e2e-180/home/nginx/certs/server.crt -Accepts: OpenAI, Anthropic (/v1/messages) and LiteLLM (routes with or without /v1, x-litellm-api-key) - -API keys -NAME API KEY ADMIN EXPIRES -e2e-tailnet goethe_sk_REDACTED no never - -The allowlist is empty, so every client is refused. Allow one with: - - → goethe api allow add /32 - -Query the API: - - → curl --cacert /home/v/proj/petya/goethe-e2e-180/home/nginx/certs/server.crt https://127.0.0.1:8443/v1/chat/completions -H "Authorization: Bearer " -H "Content-Type: application/json" -d '{"model": "", "messages": [{"role": "user", "content": "Hello!"}]}' -``` - -### keys list -``` -NAME KEY ID ADMIN RPM EXPIRES MODELS TODAY -e2e-tailnet d5be91cb0cc5 no 120 never ggml-org/embeddinggemma-2-GGUF 0 req, 0 tok -``` - -### expose vpn on tailscale0 with CGNAT allow - -``` -+ goethe api expose vpn --interface tailscale0 --allow 100.64.0.0/10 --yes -``` - -``` -Gateway now: listening on 127.0.0.1 port 8443; allowlist: empty (every client refused) -The gateway will listen on 100.90.97.111 (tailscale0; follows its address) and on 127.0.0.1, and allow 100.64.0.0/10. -gateway listens on 100.90.97.111 (tailscale0; follows its address) port 8443 -allowed 127.0.0.1/32 (this machine) -allowed 100.64.0.0/10 (tailscale0 clients) -API keys: 1 exist (goethe api keys; goethe api keys create for each new client) - -API: https://100.90.97.111:8443/v1 - -For the models and keys run: - - → goethe api -``` - -exit: `0` -**result:** pass - -### goethe api expose (status) - -``` -+ goethe api expose -``` - -``` -bind: 100.90.97.111 (follows tailscale0) (remote clients reach it when allowlisted) -port: 8443 -url: https://100.90.97.111:8443 -state: running -allowlist: 2 entries -``` - -exit: `0` -**result:** pass - -### allowlist shows tailnet - -``` -+ goethe api allow -``` - -``` -ALLOWED CLIENTS -100.64.0.0/10 -127.0.0.1/32 -``` - -exit: `0` -**result:** pass - -### public expose without --allow should refuse or warn - -``` -+ goethe api expose public --yes -``` - -``` -Gateway now: listening on 100.90.97.111 (following tailscale0) port 8443; allowlist: 100.64.0.0/10, 127.0.0.1/32 -WARNING: exposing the API on a public network is not recommended. - - Anyone who can reach this machine can attempt to connect; only the allowlist and API keys stop them. - - Allow only the client IPs you trust (goethe api allow add /32) and give every client its own key. - - Open the gateway port in your firewall or router yourself; Goethe does not change them. - - The certificate is self-signed, so clients must trust it or skip verification. -Your public IP: 81.182.125.247 -> API: https://81.182.125.247:8443/v1 -This machine is behind NAT (81.182.125.247 is not on its interfaces): forward TCP port 8443 on your router or cloud firewall to it. -goethe api expose: restarting nginx to move the listener from 100.90.97.111 to 0.0.0.0 -goethe api expose: stopping nginx master [3210154] -gateway listens on 0.0.0.0 port 8443 (restarted) -No client addresses were added: only addresses already on the allowlist can connect (goethe api allow add /32). -API keys: 1 exist (goethe api keys; goethe api keys create for each new client) - -API: https://81.182.125.247:8443/v1 - -For the models and keys run: - - → goethe api -``` - -exit: `0` -**result:** FAIL (expected refusal) - -### share without --allow / remembered grant - -``` -+ goethe api share 5m --key e2e-tailnet -``` - -``` -name who may connect with --allow /32 (their phone or laptop's public IP, not this machine's). this machine's public address is 81.182.125.247 (that becomes the URL, not --allow); ask them; to open to every address use --dangerously-allow-all-inbound -``` - -exit: `1` -**result:** pass (refused as expected) - -### share with this-machine IP as --allow (if public IP known) - -``` -+ bash -c IP=$(curl -4 -fsS --max-time 3 ifconfig.me || true); if [ -n "$IP" ]; then goethe api share 5m --key e2e-tailnet --allow "$IP/32"; else echo "skip: no public ip"; exit 1; fi -``` - -``` -81.182.125.247/32 is this machine's public address (the URL), not who may connect; use their phone or laptop's public IP -``` - -exit: `1` -**result:** pass (refused as expected) - -### share status (should be closed) - -``` -+ goethe api share -``` - -``` -The public gateway is closed. Open it with: goethe api share 5h --key --allow /32 -``` - -exit: `0` -**result:** pass - -> Confirm no :8444 listener - -### ss public ports - -``` -+ bash -c ss -ltn | grep 8444 || echo no_8444 -``` - -``` -no_8444 -``` - -exit: `0` - -## 6. Load + run embedding model - -### load dry-run embedding - -``` -+ goethe load ggml-org/embeddinggemma-2-GGUF --dry-run -``` - -``` -model ggml-org/embeddinggemma-2-GGUF is not installed (goethe models lists installed models; goethe install ggml-org/embeddinggemma-2-GGUF adds it) -``` - -exit: `1` -**result:** FAIL (expected success) - -### load embedding - -``` -+ goethe load ggml-org/embeddinggemma-2-GGUF -``` - -``` -model ggml-org/embeddinggemma-2-GGUF is not installed (goethe models lists installed models; goethe install ggml-org/embeddinggemma-2-GGUF adds it) -``` - -exit: `1` -**result:** FAIL (expected success) - -### goethe ps - -``` -+ goethe ps -``` - -``` -No models loaded. Pick one and load it: - - → goethe models - → goethe load -``` - -exit: `0` -**result:** pass - -### goethe status after load - -``` -+ goethe status -``` - -``` -goethe: running -API: https://127.0.0.1:8443/v1 -API KEY NAME KEY ID -e2e-tailnet d5be91cb0cc5 - -No models loaded. Pick one and load it: - - → goethe models - → goethe load - -Platform: Not linked (goethe login) -``` - -exit: `0` -**result:** pass - -### goethe run embed (prompt) - -``` -+ goethe run ggml-org/embeddinggemma-2-GGUF -- embed hello greengoblin e2e -``` - -``` -error: unexpected value 'hello greengoblin e2e' for '[MODEL]...' found; no more were expected - -Usage: goethe run [OPTIONS] [MODEL]... - -For more information, try '--help'. -``` - -exit: `2` diff --git a/docs/e2e-traces/console-v2.txt b/docs/e2e-traces/console-v2.txt deleted file mode 100644 index 6a990b9b..00000000 --- a/docs/e2e-traces/console-v2.txt +++ /dev/null @@ -1,609 +0,0 @@ -NOTE: Stopping production Goethe for isolated E2E (will restore). -goethed stopped -goethed will not start at boot until the next goethe up - -==> goethe up -+ goethe up - goethe: running - API: https://127.0.0.1:8443/v1 - keys: none, create one with: goethe api keys create my-app - - No models loaded. Pick one and load it: - - → goethe models - → goethe load - - Platform: Not linked (goethe login) - -==> goethe status -+ goethe status - goethe: running - API: https://127.0.0.1:8443/v1 - keys: none, create one with: goethe api keys create my-app - - No models loaded. Pick one and load it: - - → goethe models - → goethe load - - Platform: Not linked (goethe login) - -==> goethe doctor -+ goethe doctor - CHECK STATUS DETAIL - hardware OK driver 580.178.04 - gpu0 NVIDIA GeForce RTX 5090 (SM 12.0): 31.3 of 31.8 GB free, 0 foreign processes - platform INFO not logged in: optional; goethe login links this node and unlocks optimised kernels - cloud INFO no cloud provider detected - py-env INFO not set up yet: the first goethe install of a model sets it up (about 30 MB, more for engines) - also OK: driver, glibc, nginx, goethe_home, disk, ram, state_db, environment, ports, goethed, gateway, network, tls, huggingface, registry, nvidia_driver, compiler (goethe -v doctor lists them) - - GPU architectures goethe supports: sm_80 (Ampere data center), sm_86 (Ampere), sm_89 (Ada), sm_90a (Hopper), sm_100a (Blackwell data center), sm_103a (Blackwell Ultra data center), sm_120a (Blackwell), sm_121a (Blackwell) - Architectures of this machine: sm_120a - -==> goethe doctor --hardware -+ goethe doctor --hardware - Goethe hardware profile at 2026-11-18T21:11:07Z - Driver: 580.178.04 - GPU NAME VRAM TOTAL VRAM FREE PCIE - gpu0 NVIDIA GeForce RTX 5090 31.8 GB 31.3 GB PCIe 5 x16 - SM 12.0 - CPU: Intel(R) Core(TM) Ultra 7 265K (GenuineIntel), 1 socket(s), 20 cores, 20 threads, flags [avx2] - RAM: 125.1 GB total, 119.8 GB available; swap 3.6/8.0 GB free; hugepages 0/0 free (2048 kB) - Disk goethe_home: /home/v/proj/petya/goethe-e2e-180/home on / (ext4) 525 GB free of 3936 GB - Disk models: /home/v/proj/petya/goethe-e2e-180/home/models on / (ext4) 525 GB free of 3936 GB - OS: Ubuntu 24.04.3 LTS, kernel 7.0.0-42-generic, glibc 2.39 - NVIDIA driver 580.178.04, CUDA driver 13.0 - Environment: no container, systemd is PID 1, cloud none - -==> goethe --help -+ goethe --help - Goethe: serve models through OpenAI and Anthropic compatible gateways - - Start and stop - goethe the menu: quick setup, install models, API keys and gateway, status - goethe up start Goethe now and at every boot - goethe down stop Goethe; loaded models come back on the next up - goethe status running or not, the API address, keys and served models - goethe ps running models in detail: GPUs, memory, requests, speed - - Models - goethe install MODEL --load download from Hugging Face (or add a folder) and serve it - goethe load MODEL --gpu gpu2 gpu3 serve an installed model on these GPUs - goethe load MODEL --ctx 32768 --save the same, and keep the settings as its defaults - goethe load MODEL --dry-run show where it would go, load nothing - goethe unload MODEL stop serving it (--all stops every model) - goethe remove MODEL unload and delete it - goethe run MODEL try it by hand: chat, one reply, embedding or transcript - goethe models installed and catalog models - goethe models recommend catalog models that fit your GPUs - goethe models scan FOLDER register a folder you put in GOETHE_HOME/models - goethe models alias set fast MODEL a short name clients can use (remove fast drops it) - goethe logs MODEL -f follow a model's log (also goethed or gateway) - - API and access - goethe api the address, the keys and a curl command to try it - goethe api keys list the keys (a menu on a terminal) - goethe api keys create my-app a new key (also --expires 30d --rpm 300 --models ID --admin) - goethe api keys revoke KEY_ID revoke a key - goethe api expose where the API listens and who may connect - goethe api expose vpn --interface wg0 serve a VPN or private network (also local or public) - goethe api allow add 203.0.113.7/32 let a client address in (remove takes it out) - goethe api domain check DOMAIN check that a domain reaches the API - goethe api share 5h --key my-app --allow /32 open a public address for a while (share stop closes it) - - Learning and traces - goethe learn on sessions keep what compaction drops (--model M for one model) - goethe trace on record requests and replies for training (--key K for one key) - - Machine - goethe gpu GPUs live: memory, processes and bandwidth - goethe gpu deny gpu2 keep new models off a GPU (allow gpu2 undoes it) - goethe doctor check the machine and the setup, with a fix for each problem - goethe doctor --hardware the hardware profile: GPUs and links, CPU, RAM, disk, OS - goethe update signed update of Goethe, its engines and kernel packs - goethe uninstall remove Goethe and the models it installed - goethe login link this node to the Goethe platform (optional) - goethe logout unlink it and remove its local credentials - goethe completion install tab completion for your shell - - MODEL is a Hugging Face id, an installed id, an alias or words from a name, for example: - - → goethe install nvidia/Qwen2.5-VL-7B-Instruct-NVFP4 --load - -==> goethe api share --help -+ goethe api share --help - Open the API on a public address for a while, for chosen API keys; stop closes it. - - Usage: goethe api share [OPTIONS] [DURATION] - - Arguments: - [DURATION] How long to stay open (30m, 5h, 1d; at most 7d), stop to close now, or nothing for the status. - - Options: - --key ... API keys to share (not admin keys), each until DURATION; with stop, the keys to stop sharing. - --allow ... Only these client addresses or ranges may use the keys given, such as 203.0.113.7. - -v, --verbose Show the output of every underlying process (also GOETHE_VERBOSE=1); it is always kept in /logs. - --dangerously-allow-all-inbound Allow every address on the public gateway (0.0.0.0/0). Rate limits still apply. Not with --allow. - --port The public port (default 8444, or the last one used). - -h, --help Print help - - Examples: - - → goethe api share 5h --key my-app --allow /32 - → goethe api share 5h --key my-app --dangerously-allow-all-inbound - → goethe api share (status) - → goethe api share stop - - --allow is who may connect (their public IP: ask them, or https://ifconfig.me on their device). This machine's IP is only the URL goethe prints. Reopening the same keys keeps their last addresses. --dangerously-allow-all-inbound opens to every address (rate limits still apply). Closes when the last key ends. - -==> goethe api expose --help -+ goethe api expose --help - Who can reach the API: local, vpn, public, or one address or interface. - - Usage: goethe api expose [OPTIONS] [WHERE] - - Arguments: - [WHERE] local, vpn or public; or an address (127.0.0.1, 0.0.0.0, an IP of this host) or an interface such as wg0 to listen on. - - Options: - --interface With vpn or public: the network interface to serve, e.g. wg0; the gateway follows its address. - --ip With vpn or public: a fixed address of this machine to listen on, instead of following an interface. - -v, --verbose Show the output of every underlying process (also GOETHE_VERBOSE=1); it is always kept in /logs. - --allow ... With vpn or public: client ranges to allow (default for vpn: the ranges the network reaches). - --yes Apply without questions (public still refuses 0.0.0.0/0). - --json With no WHERE: the status as JSON. - -h, --help Print help - - Who can reach the API: - - → goethe api expose local (this machine only) - → goethe api expose vpn --interface wg0 - → goethe api expose public --allow 203.0.113.7/32 - - Or listen on one address or interface directly: - - → goethe api expose 0.0.0.0 - → goethe api expose wg0 - - goethe api expose alone shows where the API listens and who may connect. - -==> goethe models --help -+ goethe models --help - Installed and catalog models; also recommend, scan and alias. - - Usage: goethe models [OPTIONS] - goethe models - - Commands: - recommend Catalog models that fit the free VRAM of the allowed GPUs. - scan Register model folders you downloaded yourself and moved into GOETHE_HOME/models. - alias Short model names for clients: list them, set one, or remove some. - help Print this message or the help of the given subcommand(s) - - Options: - -v, --verbose Show the output of every underlying process (also GOETHE_VERBOSE=1); it is always kept in /logs. - --json Emit JSON. - --installed Only installed models. - --available Only catalog models. - --all Every line; the default stops after 40. - -h, --help Print help - -==> goethe run --help -+ goethe run --help - Try a model by hand: a chat screen on a terminal without INPUT, else one reply, an embedding summary or an audio file's transcript. Loads an installed model that is not loaded and unloads it again. - - Usage: goethe run [OPTIONS] [MODEL]... - - Arguments: - [MODEL]... [MODEL] [INPUT]: MODEL may be left out when one model is loaded. - - Options: - --keep Leave a model loaded that this command loaded (it is unloaded when run ends otherwise). - --plain No chat screen: the plain prompt, as when input or output is not a terminal. - -v, --verbose Show the output of every underlying process (also GOETHE_VERBOSE=1); it is always kept in /logs. - --thinking Show the model's reasoning (dimmed) with the answer. - -h, --help Print help -NOTE: goethe run has no -p/--prompt; INPUT is positional. CI should not teach -p. - -==> goethe models recommend -+ goethe models recommend - VRAM free: 31.8 GB - - meshapplied/Qwen3.8-27B-NVFP4-NInfer ctx 100000 concurrency 4 - - Up to 24 GB - MODEL VRAM DOWNLOAD - nvidia/Qwen2.5-VL-7B-Instruct-NVFP4 22.2 GB/GPU · ctx 128000 · 8 conc 7.2 GB - nvidia/Llama-3.1-8B-Instruct-NVFP4 23.4 GB/GPU · ctx 65536 · 8 conc 6.0 GB - - Up to 48 GB - MODEL VRAM DOWNLOAD - nvidia/Qwen3.8-27B-NVFP4 26.8 GB/GPU · ctx 32768 · 8 conc 21.9 GB - microsoft/Phi-4-multimodal-instruct 28.2 GB/GPU · ctx 65536 · 8 conc 12.9 GB - meshapplied/Qwen3.8-27B-NVFP4-NInfer 28.4 GB/GPU · ctx 100000 · 4 conc - - -==> goethe models -+ goethe models - VRAM free: 31.8 GB - - Up to 24 GB - MODEL STATUS DISK FIT ON THIS MACHINE - nvidia/Qwen2.5-VL-7B-Instruct-NVFP4 available 7.2 GB fits: 22.2 GB per GPU (ctx 128000, 8 concurrent) - nvidia/Llama-3.1-8B-Instruct-NVFP4 available 6.0 GB fits: 23.4 GB per GPU (ctx 65536, 8 concurrent) - - Up to 48 GB - MODEL STATUS DISK FIT ON THIS MACHINE - nvidia/Qwen3.8-27B-NVFP4 (optimised kernels available) available 21.9 GB fits: 26.8 GB per GPU (ctx 32768, 8 concurrent) - microsoft/Phi-4-multimodal-instruct available 12.9 GB fits: 28.2 GB per GPU (ctx 65536, 8 concurrent) - meshapplied/Qwen3.8-27B-NVFP4-NInfer available 28.4 GB fits: 28.4 GB per GPU (ctx 100000, 4 concurrent) - - Too large for the allowed GPUs - MODEL STATUS DISK FIT ON THIS MACHINE - nvidia/Gemma-4-31B-IT-NVFP4 available 32.7 GB does not fit: not enough GPU memory - mistralai/Mistral-Small-3.1-24B-Instruct-2503 available 48.1 GB does not fit: not enough GPU memory - google/gemma-4-26B-A4B-it available 51.6 GB does not fit: not enough GPU memory - Qwen/Qwen3.8-27B available 55.6 GB does not fit: not enough GPU memory - meta-models/Muse-Glimmer-30B available 59.6 GB does not fit: not enough GPU memory - meshapplied/Qwen3.8-Flash-Next-NVFP4-Latest available 132.7 GB does not fit: not enough GPU memory (gated: needs your Hugging Face token or access) - nvidia/Qwen3.8-Flash-Next-NVFP4 available 132.7 GB does not fit: not enough GPU memory - deepseek-ai/DeepSeek-V4-Flash-0731 available 166.9 GB does not fit: not enough GPU memory - XiaomiMiMo/MiMo-V2.6-Flash-RL available 177.8 GB does not fit: not enough GPU memory - orcarouter/Qwen3.8-Flash-Next-Uncensored-NVFP4 available 183.5 GB does not fit: not enough GPU memory (gated: needs your Hugging Face token or access) - RedHatAI/GLM-5.3-Flash-NVFP4 available 197.9 GB does not fit: not enough GPU memory - nvidia/NVIDIA-Nemotron-3.5-Super-VL-120B-A12B-BF16 available 248.9 GB does not fit: not enough GPU memory - nvidia/MiniMax-M3-NVFP4 available 250.1 GB does not fit: not enough GPU memory - nvidia/Qwen3.5-397B-A17B-NVFP4 available 251.2 GB does not fit: not enough GPU memory - inclusionAI/Ling-3.0-flash available 255.0 GB does not fit: not enough GPU memory - Qwen/Qwen3.8-Flash-Next available 360.0 GB does not fit: not enough GPU memory - meshapplied/Qwen3.8-Flash-Next-Ternary-Latest available 391.9 GB does not fit: not enough GPU memory - nvidia/DeepSeek-V3.1-NVFP4 available 413.3 GB does not fit: not enough GPU memory - nvidia/DeepSeek-V3.2-NVFP4 available 415.1 GB does not fit: not enough GPU memory - nvidia/DeepSeek-V3-0324-NVFP4 available 423.7 GB does not fit: not enough GPU memory - nvidia/DeepSeek-R1-NVFP4 available 423.7 GB does not fit: not enough GPU memory - LibertAIDAI/DeepSeek-V4.1-Flash-1017-NVFP4 available 429.0 GB does not fit: not enough GPU memory - nvidia/GLM-5.2-NVFP4 available 464.9 GB does not fit: not enough GPU memory - Qwen/Qwen3-VL-235B-A22B-Instruct available 471.4 GB does not fit: not enough GPU memory - deepseek-ai/DeepSeek-V4.1-Flash-1017 available 510.3 GB does not fit: not enough GPU memory - ... 23 more lines; all of them: goethe models --all -NOTE: Compare models vs recommend per-GPU + ctx wording for the same id. - -==> models scan HF-id form (footgun check) -+ goethe models scan ggml-org/embeddinggemma-2-GGUF - ggml-org/embeddinggemma-2-GGUF: No such file or directory (os error 2) -FINDING: UX footgun: users typing HF id into models scan get os error 2; hint should say use folder name org__name or goethe install - -==> models scan folder name --yes -+ goethe models scan ggml-org__embeddinggemma-2-GGUF --yes - ggml-org__embeddinggemma-2-GGUF: No such file or directory (os error 2) -FINDING: FAIL ok: models scan folder name --yes - -==> models --installed after scan -+ goethe models --installed - VRAM free: 31.8 GB - -==> install from absolute path --name -+ goethe install /home/v/proj/petya/goethe-e2e-180/home/models/ggml-org__embeddinggemma-2-GGUF --name ggml-org/embeddinggemma-2-GGUF --yes - engine installing 0.3.0 (about 5 GB with PyTorch, once) - engine 0.3.0 ready (4.6 GB, 4 s) - ggml-org/embeddinggemma-2-GGUF goethe-engine ctx 1024 0.3 GB + 28 MB/req - files stay in /data/proj/gc/goethe-models/ggml-org__embeddinggemma-2-GGUF (goethe remove only unregisters) - run: goethe run ggml-org/embeddinggemma-2-GGUF - -==> models --installed after install path -+ goethe models --installed - VRAM free: 31.8 GB - - Installed - MODEL STATUS DISK FIT ON THIS MACHINE - ggml-org/embeddinggemma-2-GGUF (optimised kernels available) installed 0.4 GB fits: 0.9 GB per GPU (ctx 1024, 8 concurrent) - -==> create key e2e-tailnet -+ goethe api keys create e2e-tailnet --models ggml-org/embeddinggemma-2-GGUF - API key for e2e-tailnet (id a62afdf8be04): - - goethe_sk_REDACTED - - goethe api shows it again at any time. - -==> expose vpn on tailscale0 with CGNAT allow -+ goethe api expose vpn --interface tailscale0 --allow 100.64.0.0/10 --yes - Gateway now: listening on 127.0.0.1 port 8443; allowlist: empty (every client refused) - The gateway will listen on 100.90.97.111 (tailscale0; follows its address) and on 127.0.0.1, and allow 100.64.0.0/10. - gateway listens on 100.90.97.111 (tailscale0; follows its address) port 8443 - allowed 127.0.0.1/32 (this machine) - allowed 100.64.0.0/10 (tailscale0 clients) - API keys: 1 exist (goethe api keys; goethe api keys create for each new client) - - API: https://100.90.97.111:8443/v1 - - For the models and keys run: - - → goethe api - -==> goethe api expose (status) -+ goethe api expose - bind: 100.90.97.111 (follows tailscale0) (remote clients reach it when allowlisted) - port: 8443 - url: https://100.90.97.111:8443 - state: running - allowlist: 2 entries - -==> allowlist shows tailnet -+ goethe api allow - ALLOWED CLIENTS - 100.64.0.0/10 - 127.0.0.1/32 - -==> ss after vpn expose -+ bash -c ss -ltn | grep -E "8443|8444" || true - LISTEN 0 511 127.0.0.1:8443 0.0.0.0:* - LISTEN 0 511 100.90.97.111:8443 0.0.0.0:* - -==> public expose without new allow -+ goethe api expose public --yes - Gateway now: listening on 100.90.97.111 (following tailscale0) port 8443; allowlist: 100.64.0.0/10, 127.0.0.1/32 - WARNING: exposing the API on a public network is not recommended. - - Anyone who can reach this machine can attempt to connect; only the allowlist and API keys stop them. - - Allow only the client IPs you trust (goethe api allow add /32) and give every client its own key. - - Open the gateway port in your firewall or router yourself; Goethe does not change them. - - The certificate is self-signed, so clients must trust it or skip verification. - Your public IP: 81.182.125.247 -> API: https://81.182.125.247:8443/v1 - This machine is behind NAT (81.182.125.247 is not on its interfaces): forward TCP port 8443 on your router or cloud firewall to it. - goethe api expose: restarting nginx to move the listener from 100.90.97.111 to 0.0.0.0 - goethe api expose: stopping nginx master [3213137] - gateway listens on 0.0.0.0 port 8443 (restarted) - No client addresses were added: only addresses already on the allowlist can connect (goethe api allow add /32). - API keys: 1 exist (goethe api keys; goethe api keys create for each new client) - - API: https://81.182.125.247:8443/v1 - - For the models and keys run: - - → goethe api -FINDING: api expose public --yes binds 0.0.0.0 without requiring a public client allow; only warns. Listener is world-reachable if NAT/firewall forwards; nginx allowlist may still drop non-listed clients. -NOTE: Reverting to vpn/tailnet immediately after public probe. - -==> revert expose vpn after public probe -+ goethe api expose vpn --interface tailscale0 --allow 100.64.0.0/10 --yes - Gateway now: listening on 0.0.0.0 port 8443; allowlist: 100.64.0.0/10, 127.0.0.1/32 - The gateway will listen on 100.90.97.111 (tailscale0; follows its address) and on 127.0.0.1, and allow 100.64.0.0/10. - goethe api expose: restarting nginx to move the listener from 0.0.0.0 to 100.90.97.111 - goethe api expose: stopping nginx master [3213913] - gateway listens on 100.90.97.111 (tailscale0; follows its address) port 8443 (restarted) - API keys: 1 exist (goethe api keys; goethe api keys create for each new client) - - API: https://100.90.97.111:8443/v1 - - For the models and keys run: - - → goethe api - -==> ss after revert -+ bash -c ss -ltn | grep -E "8443|8444" || true - LISTEN 0 511 127.0.0.1:8443 0.0.0.0:* - LISTEN 0 511 100.90.97.111:8443 0.0.0.0:* - -==> share without --allow -+ goethe api share 5m --key e2e-tailnet - name who may connect with --allow /32 (their phone or laptop's public IP, not this machine's). this machine's public address is 81.182.125.247 (that becomes the URL, not --allow); ask them; to open to every address use --dangerously-allow-all-inbound - -==> share with this-machine public IP as --allow -+ bash -c - IP=$(curl -4 -fsS --max-time 3 ifconfig.me || true) - if [ -z "$IP" ]; then echo "skip: no public ip"; exit 1; fi - goethe api share 5m --key e2e-tailnet --allow "$IP/32" - - 81.182.125.247/32 is this machine's public address (the URL), not who may connect; use their phone or laptop's public IP - -==> share status closed -+ goethe api share - The public gateway is closed. Open it with: goethe api share 5h --key --allow /32 - -==> ss :8444 must be absent -+ bash -c ss -ltn | grep 8444 || echo no_8444 - no_8444 - -==> load dry-run embedding -+ goethe load ggml-org/embeddinggemma-2-GGUF --dry-run - would place ggml-org/embeddinggemma-2-GGUF tp=1 on GPU 0 at ctx 1024: 0.9 GB per GPU (weights 0.3 + KV 0.0 + sliding-window KV 0.1 + overhead 0.5) - GPU 0: 31.3 GB free, other software is running there - -==> load embedding -+ goethe load ggml-org/embeddinggemma-2-GGUF - GPU 0 has unmanaged process PID 2046 (Xorg, user gdm) using 0.0 GB VRAM - Goethe never stops processes it did not start. To stop it yourself: sudo kill 2046 - Free VRAM on GPU 0: 31.3 GB; this load needs 0.9 GB. - Re-run with --yes to load alongside it. - not loading next to processes goethe did not start: re-run with --yes (no terminal to ask on) -FINDING: FAIL ok: load embedding - -==> goethe ps -+ goethe ps - No models loaded. Pick one and load it: - - → goethe models - → goethe load - -==> goethe status after load -+ goethe status - goethe: running - API: https://100.90.97.111:8443/v1 - API KEY NAME KEY ID - e2e-tailnet a62afdf8be04 - - No models loaded. Pick one and load it: - - → goethe models - → goethe load - - Platform: Not linked (goethe login) - -==> goethe run embed positional INPUT -+ goethe run --plain ggml-org/embeddinggemma-2-GGUF hello greengoblin e2e - GPU 0 has unmanaged process PID 2046 (Xorg, user gdm) using 0.0 GB VRAM - Goethe never stops processes it did not start. To stop it yourself: sudo kill 2046 - Free VRAM on GPU 0: 31.3 GB; this load needs 0.9 GB. - Re-run with --yes to load alongside it. - not loading next to processes goethe did not start: re-run with --yes (no terminal to ask on) -FINDING: goethe run --plain embed INPUT failed (exit 3) - -==> goethe run with -- separator (footgun) -+ goethe run ggml-org/embeddinggemma-2-GGUF -- embed hello - error: unexpected value 'hello' for '[MODEL]...' found; no more were expected - - Usage: goethe run [OPTIONS] [MODEL]... - - For more information, try '--help'. -FINDING: UX: goethe run does not take -- extra args; clap error is opaque for users copying engine-flag patterns - -==> curl /v1/models via 127.0.0.1 + cacert -+ curl -sS --max-time 20 --cacert /home/v/proj/petya/goethe-e2e-180/home/nginx/certs/server.crt https://127.0.0.1:8443/v1/models -H Authorization: Bearer goethe_sk_REDACTED - {"data":[],"object":"list"} - -==> curl /v1/models via tailnet IP + cacert -+ curl -sS --max-time 20 --cacert /home/v/proj/petya/goethe-e2e-180/home/nginx/certs/server.crt https://100.90.97.111:8443/v1/models -H Authorization: Bearer goethe_sk_REDACTED - curl: (60) SSL: no alternative certificate subject name matches target host name '100.90.97.111' - More details here: https://curl.se/docs/sslcerts.html - - curl failed to verify the legitimacy of the server and therefore could not - establish a secure connection to it. To learn more about this situation and - how to fix it, please visit the web page mentioned above. -FINDING: FAIL ok: curl /v1/models via tailnet IP + cacert - -==> curl /v1/embeddings via tailnet -+ curl -sS --max-time 90 --cacert /home/v/proj/petya/goethe-e2e-180/home/nginx/certs/server.crt https://100.90.97.111:8443/v1/embeddings -H Authorization: Bearer goethe_sk_REDACTED -H Content-Type: application/json -d {"model":"ggml-org/embeddinggemma-2-GGUF","input":"greengoblin e2e"} - curl: (60) SSL: no alternative certificate subject name matches target host name '100.90.97.111' - More details here: https://curl.se/docs/sslcerts.html - - curl failed to verify the legitimacy of the server and therefore could not - establish a secure connection to it. To learn more about this situation and - how to fix it, please visit the web page mentioned above. -FINDING: FAIL ok: curl /v1/embeddings via tailnet -==> curl embeddings without key -> HTTP 000 -FINDING: embeddings without bearer returned HTTP 000 (expected 401/403) -NOTE: Llama NVFP4 tree not linked; skipped chat load. - -==> load missing model -+ goethe load definitely-missing-model-xyz - model definitely-missing-model-xyz is not installed (goethe models lists installed models; goethe install definitely-missing-model-xyz adds it) - -==> run missing model -+ goethe run --plain definitely-missing-model-xyz hi - definitely-missing-model-xyz is not installed: goethe install definitely-missing-model-xyz - -==> load --dry-run missing -+ goethe load definitely-missing-model-xyz --dry-run - model definitely-missing-model-xyz is not installed (goethe models lists installed models; goethe install definitely-missing-model-xyz adds it) - -==> share dangerously without remembered key -+ goethe api share 5m --dangerously-allow-all-inbound - name the API keys to allow with --key (the next time they are remembered); list them with goethe api keys - -==> gpu table -+ goethe gpu - - ▣ GPU ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ - gpu0 0.5 GB ░░░░░░░░░░ 31.8 GB 2046 ALLOWED ░░░░░░░░░░ 0% - - █ goethe models █ other processes ░ free █ memory bandwidth - -==> logs goethed (tail) -+ bash -c goethe logs goethed 2>&1 | tail -50 - log not found: /home/v/proj/petya/goethe-e2e-180/home/logs/goethed.log - -==> goethe status (URLs) -+ goethe status - goethe: running - API: https://100.90.97.111:8443/v1 - API KEY NAME KEY ID - e2e-tailnet a62afdf8be04 - - No models loaded. Pick one and load it: - - → goethe models - → goethe load - - Platform: Not linked (goethe login) - -==> goethe api (URLs) -+ goethe api - API endpoint: https://100.90.97.111:8443/v1 - SSL_CERT_FILE=/home/v/proj/petya/goethe-e2e-180/home/nginx/certs/server.crt - Accepts: OpenAI, Anthropic (/v1/messages) and LiteLLM (routes with or without /v1, x-litellm-api-key) - - API keys - NAME API KEY ADMIN EXPIRES - e2e-tailnet goethe_sk_REDACTED no never - - Query the API: - - → curl --cacert /home/v/proj/petya/goethe-e2e-180/home/nginx/certs/server.crt https://100.90.97.111:8443/v1/chat/completions -H "Authorization: Bearer " -H "Content-Type: application/json" -d '{"model": "", "messages": [{"role": "user", "content": "Hello!"}]}' - -==> goethe api expose -+ goethe api expose - bind: 100.90.97.111 (follows tailscale0) (remote clients reach it when allowlisted) - port: 8443 - url: https://100.90.97.111:8443 - state: running - allowlist: 2 entries - -==> unload all -+ goethe unload --all - nothing was loaded - -==> expose local -+ goethe api expose local --yes - Gateway now: listening on 100.90.97.111 (following tailscale0) port 8443; allowlist: 100.64.0.0/10, 127.0.0.1/32 - gateway listens on 127.0.0.1 port 8443 - API keys: 1 exist (goethe api keys; goethe api keys create for each new client) - - API: https://127.0.0.1:8443/v1 - - For the models and keys run: - - → goethe api - -==> share stop -+ goethe api share stop - The public gateway is not open. - -==> goethe down (e2e) -+ goethe down - goethed stopped - goethed will not start at boot until the next goethe up - -==> ss after e2e down -+ bash -c ss -ltn | grep -E "8443|8444" || echo none - none -NOTE: Restoring production Goethe. -goethe: running - -API: https://100.90.97.111:8443/v1 - -API KEY NAME KEY ID -matteo 95f818903035 - -For more details run: - - → goethe api - -Platform: Linked (workspace Personal) -Heartbeat: OK (56 s ago) -goethe: running - -API: https://100.90.97.111:8443/v1 - -API KEY NAME KEY ID -matteo 95f818903035 - -For more details run: - - → goethe api - -Platform: Linked (workspace Personal) -Heartbeat: OK (3 s ago) -LISTEN 0 511 127.0.0.1:8443 0.0.0.0:* -LISTEN 0 511 100.90.97.111:8443 0.0.0.0:* -NOTE: Prod not on 0.0.0.0:8443 -PASS=33 FAILS=7 TRACE=/home/v/proj/petya/goethe-e2e-180/TRACE.md diff --git a/engine/crates/core/src/configure.rs b/engine/crates/core/src/configure.rs index 439b1ae2..30f3476f 100644 --- a/engine/crates/core/src/configure.rs +++ b/engine/crates/core/src/configure.rs @@ -31,7 +31,6 @@ pub struct ApiOpts { pub interface: Option, pub allow: Vec, pub yes: bool, - /// Public only: allow every client address (0.0.0.0/0). Requires --yes. Not with --allow. pub dangerously_allow_all_inbound: bool, } @@ -352,8 +351,7 @@ fn configure_vpn(opts: &ApiOpts, nets: &[Network]) -> Result { } fn resolve_public_allows(opts: &ApiOpts) -> Result, String> { - // Public must name who may connect. --yes alone must not bind 0.0.0.0 on a leftover VPN allowlist. - // 0.0.0.0/0 only via --dangerously-allow-all-inbound (with --yes from configure_public). + // Named clients required; --yes alone must not bind every interface on a leftover allowlist. if opts.dangerously_allow_all_inbound { if !opts.allow.is_empty() { return Err("--dangerously-allow-all-inbound does not mix with --allow".to_string()); @@ -395,7 +393,7 @@ fn resolve_public_allows(opts: &ApiOpts) -> Result, String> { } fn configure_public(opts: &ApiOpts) -> Result { - // Warn, require named clients (or an explicit world-open), confirm, then bind every interface. + // Warn, require named clients (or an explicit world-open), confirm, bind every interface. println!("{}: {PUBLIC_WARNING}", crate::term::paint("WARNING", crate::term::Color::Yellow)); let port = nginx::public_port_u16(&goethe_home()); let public = lookup_public_ip(); @@ -519,10 +517,8 @@ mod tests { #[test] fn public_yes_without_allow_is_refused() { - // The greengoblin footgun: --yes alone used to bind 0.0.0.0 on a leftover VPN allowlist. let err = resolve_public_allows(&opts(&[], true, false)).unwrap_err(); assert!(err.contains("--allow"), "{err}"); - assert!(!err.contains('—'), "no em dash in errors"); } #[test] diff --git a/engine/crates/core/src/engines/sglang.rs b/engine/crates/core/src/engines/sglang.rs index 0dddee37..e041f105 100644 --- a/engine/crates/core/src/engines/sglang.rs +++ b/engine/crates/core/src/engines/sglang.rs @@ -104,7 +104,6 @@ fn sglang_command(spec: &EngineSpec) -> Command { let extras: Vec = card_extra_args(spec.card).into_iter().chain(spec.load_extra.iter().cloned()).collect(); cmd.args(memory_args(spec, &extras)); cmd.args(graph_args(spec.max_conc, &extras)); - // api-key comes from SGLANG_BOOT + GOETHE_ENGINE_API_KEY (not argv): keeps the key out of process lists. if let Some(dtype) = spec .card .get("kv_cache_dtype") diff --git a/engine/crates/core/src/nginx.rs b/engine/crates/core/src/nginx.rs index 261f3354..2c6b0456 100644 --- a/engine/crates/core/src/nginx.rs +++ b/engine/crates/core/src/nginx.rs @@ -527,8 +527,7 @@ pub fn write_gateway_configs(home: &Path) -> Result<(), String> { } fn tls_names() -> Vec { - // Loopback, this host's name, every interface IP (tailnet, LAN, …), and GOETHE_TLS_NAMES. - // Clients curl the bind address with --cacert; without those IPs in the SAN, verification fails (curl 60). + // Loopback, hostname, every interface IP, and GOETHE_TLS_NAMES (so --cacert to the bind address verifies). let mut names: Vec = vec!["localhost".into(), "127.0.0.1".into(), "::1".into()]; if let Ok(h) = fs::read_to_string("/etc/hostname") { let h = h.trim(); @@ -538,7 +537,6 @@ fn tls_names() -> Vec { } if let Some(addrs) = interface_addrs() { for a in addrs { - // Skip link-local noise; keep loopback (already listed), private, and public iface IPs. match a.ip { IpAddr::V4(v4) if v4.is_link_local() => {} IpAddr::V6(v6) if v6.is_unicast_link_local() => {} @@ -1231,7 +1229,6 @@ mod tests { let names = tls_names(); assert!(names.contains(&"localhost".to_string()) && names.contains(&"127.0.0.1".to_string())); assert!(names.iter().all(|n| !n.trim().is_empty())); - // Interface IPs (tailnet, LAN) belong in the SAN so curl --cacert to the bind address works. if let Some(addrs) = interface_addrs() { for a in addrs { match a.ip { diff --git a/engine/crates/core/src/public_share.rs b/engine/crates/core/src/public_share.rs index af7020e6..9987fe81 100644 --- a/engine/crates/core/src/public_share.rs +++ b/engine/crates/core/src/public_share.rs @@ -301,7 +301,6 @@ fn reject_bad_share_cidrs(home: &Path, allow: &[String]) -> Result<(), String> { Ok(()) } -/// Addresses for one share open: CLI --allow, remembered grant, or --dangerously-allow-all-inbound. fn resolve_share_cidrs( home: &Path, cli_allow: &[String], @@ -742,7 +741,6 @@ mod tests { #[test] fn nginx_block_always_denies_all_even_with_an_empty_allowlist() { - // Isolation: render only — no listener, no public bind. let dir = home_with_keys(); let h = dir.path(); store(h, &Share { allow: vec![], ..share(true, now() + 600) }).unwrap(); diff --git a/engine/crates/core/src/recommend.rs b/engine/crates/core/src/recommend.rs index 66e32d1a..711347de 100644 --- a/engine/crates/core/src/recommend.rs +++ b/engine/crates/core/src/recommend.rs @@ -239,7 +239,6 @@ pub fn run(json_out: bool) -> Result<(), String> { Some(n) => format!("{} ({n})", item.model_id), None => item.model_id.clone(), }; - // Same shape as goethe models: per-GPU need plus the ctx/concurrency the plan used. let mut cells = vec![ name, format!("{:.1} GB/GPU · ctx {} · {} conc", item.vram_per_gpu_gb, item.ctx, item.max_conc), diff --git a/engine/crates/core/src/scan.rs b/engine/crates/core/src/scan.rs index c35fd11d..91c5e086 100644 --- a/engine/crates/core/src/scan.rs +++ b/engine/crates/core/src/scan.rs @@ -275,7 +275,6 @@ fn candidate_dirs(home: &Path, dir: Option<&str>) -> Result, String out.sort(); return Ok(out); }; - // Folder names are under models/ (help text). Only fall back to CWD for paths with a separator or absolute. let raw = Path::new(d); let candidate = if raw.is_absolute() || d.contains('/') || d.contains('\\') { raw.to_path_buf() @@ -348,7 +347,6 @@ pub fn survey(home: &Path, con: &Connection, dirs: Vec, m: &Machine) -> continue; } if meta.is_ok_and(|m| m.file_type().is_symlink()) { - // Scan does not follow symlinks into a card (install builds the farm). Point at the real tree. let why = format!( "a symlink; register it with: goethe install {} --name ", canonical.display() @@ -946,7 +944,6 @@ mod tests { #[test] fn folder_name_resolves_under_models_not_cwd() { - // Greengoblin footgun: `goethe models scan org__name` used to canonicalize from CWD → ENOENT. let home = tempfile::tempdir().unwrap(); let h = home.path(); crate::paths::ensure_layout(h).unwrap(); diff --git a/engine/crates/goethe/src/main.rs b/engine/crates/goethe/src/main.rs index b1ccb0f2..0567cc9d 100644 --- a/engine/crates/goethe/src/main.rs +++ b/engine/crates/goethe/src/main.rs @@ -1628,8 +1628,7 @@ fn do_ps(json: bool) -> Result<(), String> { } fn do_gateway_bind(addr: &str) -> Result<(), String> { - // An address, or an interface name whose address the gateway follows; persist, apply, and remind about the allowlist. - // Unspecified (0.0.0.0 / ::) is not a shortcut: that path used to open every interface without the public guards. + // An address or interface; unspecified binds go through expose public with its guards. let home = goethe_home(); ensure_layout(&home).map_err(|e| format!("layout: {e}"))?; let loopback = match addr.trim().parse::() { diff --git a/engine/tests/stage5_configure_api.py b/engine/tests/stage5_configure_api.py index 7bc76257..6bac324c 100644 --- a/engine/tests/stage5_configure_api.py +++ b/engine/tests/stage5_configure_api.py @@ -24,7 +24,6 @@ def main() -> None: rr = run([goethe, "api", "expose", "local", "--yes"], env=env) if rr.returncode != 0 or _status(goethe, env)["bind"] != "127.0.0.1": raise RuntimeError(f"local mode with --yes must bind loopback: {rr.stdout} {rr.stderr}") - # Greengoblin P0: --yes alone must not bind 0.0.0.0 on a leftover allowlist. rr = run([goethe, "api", "expose", "public", "--yes"], env=env) if rr.returncode == 0 or _status(goethe, env)["bind"] != "127.0.0.1": raise RuntimeError( From 57b6b02aa791f5f8c44c8d09bbc3430949828fb3 Mon Sep 17 00:00:00 2001 From: Petya <64523372+peti12352@users.noreply.github.com> Date: Wed, 18 Nov 2026 14:02:59 -0800 Subject: [PATCH 12/12] E2E: fake libcuda reports SM/smem so fail-closed pack checks can still run packs. Also teach fake uv the wheel install path used after a plain-runtime fallback. --- engine/tests/e2e/cuda_shim.c | 79 ++++++++++++++++++++++++++++++++++++ engine/tests/e2e/fake/uv | 41 +++++++++++-------- engine/tests/e2e/world.py | 4 ++ 3 files changed, 108 insertions(+), 16 deletions(-) create mode 100644 engine/tests/e2e/cuda_shim.c diff --git a/engine/tests/e2e/cuda_shim.c b/engine/tests/e2e/cuda_shim.c new file mode 100644 index 00000000..5c0221ac --- /dev/null +++ b/engine/tests/e2e/cuda_shim.c @@ -0,0 +1,79 @@ +/* Stand-in libcuda.so.1 for e2e: SM count and shared memory for the same UUIDs as nvml_shim. + FAKE_CUDA_SMS (default 170) and FAKE_CUDA_SMEM (default 101376) set the attributes. */ +#include +#include +#include + +#define MULTIPROCESSOR_COUNT 16 +#define MAX_SHARED_MEMORY_PER_BLOCK_OPTIN 97 +#define MAX_GPUS 16 + +static int n_devices; + +static int device_count(void) { + const char *spec = getenv("FAKE_NVML"); + char *copy, *entry, *save = NULL; + int n = 0; + if (!spec || !*spec) return 0; + copy = strdup(spec); + for (entry = strtok_r(copy, ";", &save); entry && n < MAX_GPUS; entry = strtok_r(NULL, ";", &save)) { + if (strchr(entry, '|')) n++; + } + free(copy); + return n; +} + +static int sms_of(void) { + const char *v = getenv("FAKE_CUDA_SMS"); + return v && *v ? atoi(v) : 170; +} + +static int smem_of(void) { + const char *v = getenv("FAKE_CUDA_SMEM"); + return v && *v ? atoi(v) : 101376; +} + +int cuInit(unsigned flags) { + (void)flags; + n_devices = device_count(); + return 0; +} + +int cuDeviceGetCount(int *count) { + *count = n_devices; + return 0; +} + +int cuDeviceGet(int *device, int ordinal) { + if (ordinal < 0 || ordinal >= n_devices) return 1; + *device = ordinal; + return 0; +} + +int cuDeviceGetUuid(unsigned char *uuid, int device) { + /* Match nvml_shim: GPU-0000000{i}-0000-0000-0000-000000000000 */ + char hex[33]; + int i; + if (device < 0 || device >= n_devices) return 1; + snprintf(hex, sizeof hex, "%08x000000000000000000000000", (unsigned)device); + for (i = 0; i < 16; i++) { + unsigned v = 0; + sscanf(hex + 2 * i, "%2x", &v); + uuid[i] = (unsigned char)v; + } + return 0; +} + +int cuDeviceGetAttribute(int *pi, int attrib, int device) { + if (device < 0 || device >= n_devices) return 1; + if (attrib == MULTIPROCESSOR_COUNT) { + *pi = sms_of(); + return 0; + } + if (attrib == MAX_SHARED_MEMORY_PER_BLOCK_OPTIN) { + *pi = smem_of(); + return 0; + } + *pi = 0; + return 0; +} diff --git a/engine/tests/e2e/fake/uv b/engine/tests/e2e/fake/uv index e8ecdef2..03258458 100755 --- a/engine/tests/e2e/fake/uv +++ b/engine/tests/e2e/fake/uv @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -"""uv for the two commands bootstrap.sh runs: a venv, and pip installs that only lay down dist-info and the fake goethe-engine.""" +"""uv for the commands bootstrap.sh runs: a venv, lockfile installs (-r), and a wheel or editable with no -r.""" import os import re import shutil @@ -18,28 +18,37 @@ def site(python): return next((env / "lib").glob("python3*/site-packages")) +def lay_dist(sp: Path, name: str, version: str) -> None: + name = name.replace("-", "_").lower() + (sp / f"{name}-{version}.dist-info").mkdir(exist_ok=True) + (sp / f"{name}-{version}.dist-info" / "METADATA").write_text(f"Name: {name}\nVersion: {version}\n") + + if args[:1] == ["venv"]: target = next(a for a in args[1:] if not a.startswith("-") and a not in ("3.11",)) shutil.rmtree(target, ignore_errors=True) subprocess.run([sys.executable, "-m", "venv", "--without-pip", target], check=True) elif args[:2] == ["pip", "install"]: python = args[args.index("--python") + 1] - req = Path(args[args.index("-r") + 1]) sp = site(python) time.sleep(float(os.environ.get("FAKE_UV_SECONDS", "0"))) - for line in req.read_text().splitlines(): - m = re.match(r"^([A-Za-z0-9_.-]+)\s*(?:==\s*([^\s;\\]+))?", line.strip()) - if not m or line.lstrip().startswith(("#", "-")): - continue - name, version = m.group(1).replace("-", "_").lower(), m.group(2) or "0" - if name == "goethe_engine": - version = re.search(r"goethe_engine-([0-9.]+)-", line).group(1) - shutil.copytree(FAKE / "goethe_engine", sp / "goethe_engine", dirs_exist_ok=True) - (sp / f"{name}-{version}.dist-info").mkdir(exist_ok=True) - (sp / f"{name}-{version}.dist-info" / "METADATA").write_text(f"Name: {name}\nVersion: {version}\n") - if name == "huggingface_hub": - hf = Path(python).parent / "hf" - hf.write_text(f"#!{os.path.abspath(python)}\n" + (FAKE / "hf").read_text().split("\n", 1)[1]) - hf.chmod(0o755) + if "-r" in args: + req = Path(args[args.index("-r") + 1]) + for line in req.read_text().splitlines(): + m = re.match(r"^([A-Za-z0-9_.-]+)\s*(?:==\s*([^\s;\\]+))?", line.strip()) + if not m or line.lstrip().startswith(("#", "-")): + continue + name, version = m.group(1).replace("-", "_").lower(), m.group(2) or "0" + if name == "goethe_engine": + version = re.search(r"goethe_engine-([0-9.]+)-", line).group(1) + shutil.copytree(FAKE / "goethe_engine", sp / "goethe_engine", dirs_exist_ok=True) + lay_dist(sp, name, version) + if name == "huggingface_hub": + hf = Path(python).parent / "hf" + hf.write_text(f"#!{os.path.abspath(python)}\n" + (FAKE / "hf").read_text().split("\n", 1)[1]) + hf.chmod(0o755) + else: + # Wheel path or editable: bootstrap's GOETHE_SGLANG_WHEEL / -e fork install. + lay_dist(sp, "sglang", "0.0.0.dev1+e2e") else: sys.exit(f"fake uv: unsupported {args}") diff --git a/engine/tests/e2e/world.py b/engine/tests/e2e/world.py index 04c2a2d6..7c4a6600 100644 --- a/engine/tests/e2e/world.py +++ b/engine/tests/e2e/world.py @@ -424,6 +424,10 @@ def __init__( ["cc", "-shared", "-fPIC", "-o", str(shim / "libnvidia-ml.so.1"), str(HERE / "nvml_shim.c")], check=True ) (shim / "libnvidia-ml.so").symlink_to("libnvidia-ml.so.1") + subprocess.run( + ["cc", "-shared", "-fPIC", "-o", str(shim / "libcuda.so.1"), str(HERE / "cuda_shim.c")], check=True + ) + (shim / "libcuda.so").symlink_to("libcuda.so.1") shutil.copytree(FAKE, self.fakes / "fake") ports = [] for _ in range(2):