feat(config,cli): global-first layered config load

Add load_layered_config: load the global ~/.omnigraph/config.yaml layer under the
project ./omnigraph.yaml (or --config) layer and merge them, returning the merged
config, its provenance, and per-layer deprecation warnings. The CLI's load_cli_config
now uses it — so a graph/server/defaults defined only in the global config is usable
from any directory with no project file. The server stays single-layer (a deployment
manifest must not pick up ambient $HOME state).

Global and cwd-default files are optional (absent = no layer); an explicit project
--config still errors if missing. base_dir stays the highest loaded layer's config
dir so relative ad-hoc --query paths resolve as before. The CLI test harness pins
OMNIGRAPH_HOME to an empty temp dir so tests never read the developer's real global
config.
This commit is contained in:
Ragnor Comerford 2026-06-05 11:31:10 +02:00
parent d3ebc29c05
commit 059fbe4c4a
No known key found for this signature in database
4 changed files with 212 additions and 9 deletions

View file

@ -27,7 +27,7 @@ use omnigraph_compiler::{
};
use omnigraph_config::{
AliasCommand, GraphLocator, OmnigraphConfig, ReadOutputFormat, graph_resource_id_for_selection,
load_config,
load_layered_config,
};
use omnigraph_policy::{
PolicyAction, PolicyDecision, PolicyEngine, PolicyRequest, PolicyTestConfig,
@ -775,14 +775,16 @@ fn load_env_file_into_process(path: &Path) -> Result<()> {
}
fn load_cli_config(config_path: Option<&PathBuf>) -> Result<OmnigraphConfig> {
let config = load_config(config_path)?;
for warning in config.deprecation_warnings() {
// Global-first layered load (global `~/.omnigraph/config.yaml` under the
// project `./omnigraph.yaml`); RFC-002 §4. Warnings are collected per layer.
let loaded = load_layered_config(config_path)?;
for warning in &loaded.warnings {
eprintln!("warning: {warning}");
}
if let Some(path) = config.resolve_auth_env_file() {
if let Some(path) = loaded.config.resolve_auth_env_file() {
load_env_file_into_process(&path)?;
}
Ok(config)
Ok(loaded.config)
}
#[derive(Debug, Clone)]