mirror of
https://github.com/ModernRelay/omnigraph.git
synced 2026-06-21 02:28:07 +02:00
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:
parent
d3ebc29c05
commit
059fbe4c4a
4 changed files with 212 additions and 9 deletions
|
|
@ -239,6 +239,41 @@ fn init_creates_graph_successfully_on_missing_local_directory() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cli_resolves_graph_from_global_config_with_no_project_file() {
|
||||
// Global-first (RFC-002 §4): a graph defined only in the global config is
|
||||
// usable from a working directory that has no `omnigraph.yaml`.
|
||||
let graph_dir = tempdir().unwrap();
|
||||
let graph = graph_path(graph_dir.path());
|
||||
init_graph(&graph);
|
||||
|
||||
let global_dir = tempdir().unwrap();
|
||||
let global_file = global_dir.path().join("config.yaml");
|
||||
write_config(
|
||||
&global_file,
|
||||
&format!(
|
||||
"version: 1\ngraphs:\n g:\n storage: {}\ndefaults:\n graph: g\n",
|
||||
yaml_string(&graph.to_string_lossy())
|
||||
),
|
||||
);
|
||||
|
||||
let empty_cwd = tempdir().unwrap();
|
||||
let output = output_success(
|
||||
cli()
|
||||
.current_dir(empty_cwd.path())
|
||||
.env("OMNIGRAPH_CONFIG", &global_file)
|
||||
.arg("snapshot")
|
||||
.arg("--graph")
|
||||
.arg("g")
|
||||
.arg("--json"),
|
||||
);
|
||||
let json = parse_stdout_json(&output);
|
||||
assert!(
|
||||
json.is_object(),
|
||||
"snapshot --json should print an object resolved from the global config: {json}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn schema_plan_json_reports_supported_additive_change() {
|
||||
let temp = tempdir().unwrap();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue