From e2924e7f902900e32f529cc1a5371b863b173e01 Mon Sep 17 00:00:00 2001 From: Ragnor Comerford Date: Wed, 3 Jun 2026 17:14:23 +0200 Subject: [PATCH] refactor(cli): dispatch remaining commands on the typed locator MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Convert the 6 commands that still scheme-sniffed a raw URI — commit list, commit show, schema show, snapshot, export, graphs list — from `resolve_uri` + `is_remote_uri(&uri)` to `resolve_cli_graph` + `graph.is_remote()`, matching the pattern the other 8 commands already use (`let uri = graph.uri.clone()`). The scheme sniff is no longer a dispatch decision; `is_remote_uri` now survives only inside `normalize_policy_graph_uri` (Cedar id), and `resolve_uri` only inside `resolve_cli_graph` and the local-only optimize/cleanup paths. Behavior-preserving on the open path: local branches keep plain `Omnigraph::open` (these are reads — unlike writes, they don't attach policy). One intentional consistency delta: routing through `resolve_cli_graph` means these commands now apply the same top-level-block coherence check every other command applies — but only for a named-graph invocation with a populated top-level `policy`/`queries` block; positional invocations are byte-identical. No HTTP/API change. --- crates/omnigraph-cli/src/main.rs | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/crates/omnigraph-cli/src/main.rs b/crates/omnigraph-cli/src/main.rs index 832faa6..f28798d 100644 --- a/crates/omnigraph-cli/src/main.rs +++ b/crates/omnigraph-cli/src/main.rs @@ -2512,8 +2512,9 @@ async fn main() -> Result<()> { let config = load_cli_config(config.as_ref())?; let bearer_token = resolve_remote_bearer_token(&config, uri.as_deref(), target.as_deref())?; - let uri = resolve_uri(&config, uri, target.as_deref())?; - let commits = if is_remote_uri(&uri) { + let graph = resolve_cli_graph(&config, uri, target.as_deref())?; + let uri = graph.uri.clone(); + let commits = if graph.is_remote() { remote_json::( &http_client, Method::GET, @@ -2551,8 +2552,9 @@ async fn main() -> Result<()> { let config = load_cli_config(config.as_ref())?; let bearer_token = resolve_remote_bearer_token(&config, uri.as_deref(), target.as_deref())?; - let uri = resolve_uri(&config, uri, target.as_deref())?; - let commit = if is_remote_uri(&uri) { + let graph = resolve_cli_graph(&config, uri, target.as_deref())?; + let uri = graph.uri.clone(); + let commit = if graph.is_remote() { remote_json::( &http_client, Method::GET, @@ -2670,8 +2672,9 @@ async fn main() -> Result<()> { let config = load_cli_config(config.as_ref())?; let bearer_token = resolve_remote_bearer_token(&config, uri.as_deref(), target.as_deref())?; - let uri = resolve_uri(&config, uri, target.as_deref())?; - let output = if is_remote_uri(&uri) { + let graph = resolve_cli_graph(&config, uri, target.as_deref())?; + let uri = graph.uri.clone(); + let output = if graph.is_remote() { remote_json::( &http_client, Method::GET, @@ -2734,9 +2737,10 @@ async fn main() -> Result<()> { let config = load_cli_config(config.as_ref())?; let bearer_token = resolve_remote_bearer_token(&config, uri.as_deref(), target.as_deref())?; - let uri = resolve_uri(&config, uri, target.as_deref())?; + let graph = resolve_cli_graph(&config, uri, target.as_deref())?; + let uri = graph.uri.clone(); let branch = resolve_branch(&config, branch, None, "main"); - let payload = if is_remote_uri(&uri) { + let payload = if graph.is_remote() { remote_json::( &http_client, Method::GET, @@ -2769,7 +2773,8 @@ async fn main() -> Result<()> { let config = load_cli_config(config.as_ref())?; let bearer_token = resolve_remote_bearer_token(&config, uri.as_deref(), target.as_deref())?; - let uri = resolve_uri(&config, uri, target.as_deref())?; + let graph = resolve_cli_graph(&config, uri, target.as_deref())?; + let uri = graph.uri.clone(); let branch = resolve_branch(&config, branch, None, "main"); if jsonl { eprintln!("warning: --jsonl is deprecated; `omnigraph export` always emits JSONL"); @@ -2777,7 +2782,7 @@ async fn main() -> Result<()> { let stdout = io::stdout(); let mut stdout = stdout.lock(); - if is_remote_uri(&uri) { + if graph.is_remote() { execute_export_remote_to_writer( &http_client, &uri, @@ -3134,8 +3139,9 @@ async fn main() -> Result<()> { let config = load_cli_config(config.as_ref())?; let bearer_token = resolve_remote_bearer_token(&config, uri.as_deref(), target.as_deref())?; - let uri = resolve_uri(&config, uri, target.as_deref())?; - if !is_remote_uri(&uri) { + let graph = resolve_cli_graph(&config, uri, target.as_deref())?; + let uri = graph.uri.clone(); + if !graph.is_remote() { bail!( "`omnigraph graphs list` requires a remote multi-graph server URL \ (http:// or https://). To enumerate local graphs, read `omnigraph.yaml` \