From 72125c7b4f86b6f2325b00481453e88650964602 Mon Sep 17 00:00:00 2001 From: Ragnor Comerford Date: Thu, 4 Jun 2026 08:33:37 +0200 Subject: [PATCH] feat(config): deprecation_warnings() for the legacy schema and `uri:` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a pure `OmnigraphConfig::deprecation_warnings() -> Vec` so the CLI and server can surface load-time migration notices while the config crate stays stdio-agnostic. It flags a config with no `version:` (the legacy schema — gated on a new `loaded_from_file` so there's nothing to warn about when no `omnigraph.yaml` exists) and any graph still using the legacy `uri:` key (vs `storage:`/`server:`). Unused until the next commit wires the emit sites. 4 config tests added. --- crates/omnigraph-config/src/lib.rs | 76 ++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/crates/omnigraph-config/src/lib.rs b/crates/omnigraph-config/src/lib.rs index 1ad3b0a..99aae41 100644 --- a/crates/omnigraph-config/src/lib.rs +++ b/crates/omnigraph-config/src/lib.rs @@ -348,6 +348,11 @@ pub struct OmnigraphConfig { pub queries: BTreeMap, #[serde(skip)] base_dir: PathBuf, + /// Whether a config file was actually loaded (vs the built-in default). + /// Gates the no-`version:` deprecation notice — there is nothing to migrate + /// when no `omnigraph.yaml` exists. + #[serde(skip)] + loaded_from_file: bool, } impl Default for OmnigraphConfig { @@ -365,6 +370,7 @@ impl Default for OmnigraphConfig { policy: PolicySettings::default(), queries: BTreeMap::new(), base_dir: PathBuf::new(), + loaded_from_file: false, } } } @@ -599,6 +605,30 @@ impl OmnigraphConfig { .ok_or_else(|| color_eyre::eyre::eyre!("alias '{}' not found", name)) } + /// Load-time deprecation notices (RFC-002 §Migration), computed purely so the + /// CLI/server can print them — the config crate stays stdio-agnostic. The + /// no-`version:` notice is gated on `loaded_from_file` (nothing to migrate when + /// no config file exists); the per-graph notice flags a legacy `uri:` entry. + pub fn deprecation_warnings(&self) -> Vec { + let mut warnings = Vec::new(); + if self.loaded_from_file && self.version.is_none() { + warnings.push( + "omnigraph.yaml has no `version:`; the legacy schema is deprecated — add \ + `version: 1` so unknown keys error instead of being silently ignored." + .to_string(), + ); + } + for (name, entry) in &self.graphs { + if entry.storage.is_none() && entry.server.is_none() && !entry.uri.is_empty() { + warnings.push(format!( + "graph '{name}' uses the legacy `uri:` key; use `storage:` for an embedded \ + graph or `server:` for a remote one." + )); + } + } + warnings + } + /// Resolve a graph selection to a typed [`GraphLocator`] (RFC-002 §1): an /// explicit positional `` (scheme-sniffed), else a local `graphs:` /// alias, else a `server/graph_id` qualified name against `servers:`. A @@ -820,6 +850,7 @@ fn load_config_in(cwd: &Path, config_path: Option<&PathBuf>) -> Result) -> Result super::OmnigraphConfig { let temp = tempdir().unwrap(); fs::write(temp.path().join("omnigraph.yaml"), yaml).unwrap();