diff --git a/Cargo.lock b/Cargo.lock index bb95af9..994bb5e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4561,6 +4561,7 @@ dependencies = [ "color-eyre", "lance", "lance-index", + "omnigraph-api-types", "omnigraph-cluster", "omnigraph-compiler", "omnigraph-engine", diff --git a/crates/omnigraph-cli/Cargo.toml b/crates/omnigraph-cli/Cargo.toml index 1670fb2..e21b21e 100644 --- a/crates/omnigraph-cli/Cargo.toml +++ b/crates/omnigraph-cli/Cargo.toml @@ -15,6 +15,7 @@ path = "src/main.rs" [dependencies] omnigraph = { package = "omnigraph-engine", path = "../omnigraph", version = "0.7.0" } omnigraph-compiler = { path = "../omnigraph-compiler", version = "0.7.0" } +omnigraph-api-types = { path = "../omnigraph-api-types", version = "0.7.0" } omnigraph-cluster = { path = "../omnigraph-cluster", version = "0.7.0" } omnigraph-policy = { path = "../omnigraph-policy", version = "0.7.0" } omnigraph-server = { path = "../omnigraph-server", version = "0.7.0" } diff --git a/crates/omnigraph-cli/src/main.rs b/crates/omnigraph-cli/src/main.rs index 8178e65..0b518eb 100644 --- a/crates/omnigraph-cli/src/main.rs +++ b/crates/omnigraph-cli/src/main.rs @@ -22,7 +22,7 @@ use omnigraph_compiler::{ QueryLintSeverity, QueryLintStatus, SchemaMigrationPlan, SchemaMigrationStep, build_catalog, json_params_to_param_map, lint_query_file, }; -use omnigraph_server::api::{ +use omnigraph_api_types::{ BranchCreateOutput, BranchCreateRequest, BranchDeleteOutput, BranchListOutput, BranchMergeOutput, BranchMergeRequest, ChangeOutput, CommitListOutput, CommitOutput, ErrorOutput, ExportRequest, GraphListResponse, IngestOutput, IngestRequest, ReadOutput, @@ -188,7 +188,7 @@ async fn main() -> Result<()> { bearer_token.as_deref(), ) .await?; - load_output_from_tables(&uri, &branch, mode, &output) + load_output_from_tables(&uri, &branch, mode.as_str(), &output) } else { let db = open_local_db_with_policy(&graph).await?; let actor = resolve_cli_actor(cli.as_actor.as_deref(), &config)?; @@ -202,17 +202,7 @@ async fn main() -> Result<()> { actor, ) .await?; - LoadOutput { - uri: uri.clone(), - branch: branch.clone(), - mode: mode.as_str(), - base_branch: result.base_branch.clone(), - branch_created: result.branch_created, - nodes_loaded: result.nodes_loaded.values().sum(), - edges_loaded: result.edges_loaded.values().sum(), - node_types_loaded: result.nodes_loaded.len(), - edge_types_loaded: result.edges_loaded.len(), - } + load_output_from_result(&uri, &branch, mode.as_str(), &result) }; if json { print_json(&payload)?; diff --git a/crates/omnigraph-cli/src/output.rs b/crates/omnigraph-cli/src/output.rs index 964307b..c6acd32 100644 --- a/crates/omnigraph-cli/src/output.rs +++ b/crates/omnigraph-cli/src/output.rs @@ -21,7 +21,7 @@ pub(crate) struct LoadOutput { pub(crate) fn load_output_from_tables( uri: &str, branch: &str, - mode: CliLoadMode, + mode: &'static str, output: &IngestOutput, ) -> LoadOutput { let mut nodes_loaded = 0; @@ -40,7 +40,7 @@ pub(crate) fn load_output_from_tables( LoadOutput { uri: uri.to_string(), branch: branch.to_string(), - mode: mode.as_str(), + mode, base_branch: output.base_branch.clone(), branch_created: output.branch_created, nodes_loaded, @@ -50,6 +50,31 @@ pub(crate) fn load_output_from_tables( } } +/// The local arm's twin of `load_output_from_tables`: build the same +/// `LoadOutput` from the engine `LoadResult` directly (the remote arm only +/// has the wire `IngestOutput`'s table list; the local arm has the full +/// result). Both load mappings live here, next to the struct — RFC-009 +/// Phase 2's "one place" for the `-> LoadOutput` mapping that used to fork +/// between this file and main.rs's inline construction. +pub(crate) fn load_output_from_result( + uri: &str, + branch: &str, + mode: &'static str, + result: &omnigraph::loader::LoadResult, +) -> LoadOutput { + LoadOutput { + uri: uri.to_string(), + branch: branch.to_string(), + mode, + base_branch: result.base_branch.clone(), + branch_created: result.branch_created, + nodes_loaded: result.nodes_loaded.values().sum(), + edges_loaded: result.edges_loaded.values().sum(), + node_types_loaded: result.nodes_loaded.len(), + edge_types_loaded: result.edges_loaded.len(), + } +} + #[derive(Debug, Serialize)] pub(crate) struct SchemaPlanOutput<'a> { pub(crate) uri: &'a str,