refactor(cli): consume omnigraph-api-types directly; unify the load mapping

The CLI's wire-DTO imports repoint from omnigraph_server::api to
omnigraph-api-types (the server's other exports — queries registry,
config types — still come from omnigraph-server). The local Load arm's
inline LoadOutput hand-construction in main.rs is extracted into
load_output_from_result next to load_output_from_tables in output.rs, so
both '-> LoadOutput' mappings (engine LoadResult for local, wire
IngestOutput for remote) live in one place.

Deviation from the plan, with reason: LoadOutput stays CLI-side rather
than moving into the wire-DTO crate — it is a rendered CLI output type,
not an HTTP wire DTO, and its mapping consumes a CLI clap type
(CliLoadMode). The shared crate stays strictly wire DTOs. Shapes
unchanged: the parity matrix passes textually unchanged.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
aaltshuler 2026-06-13 17:05:32 +03:00
parent 4821e7208f
commit adbb2a181c
4 changed files with 32 additions and 15 deletions

1
Cargo.lock generated
View file

@ -4561,6 +4561,7 @@ dependencies = [
"color-eyre",
"lance",
"lance-index",
"omnigraph-api-types",
"omnigraph-cluster",
"omnigraph-compiler",
"omnigraph-engine",

View file

@ -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" }

View file

@ -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)?;

View file

@ -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,