mirror of
https://github.com/ModernRelay/omnigraph.git
synced 2026-06-24 02:38:06 +02:00
refactor(cli): collapse export + graphs-list onto GraphClient (RFC-009 Phase 3c) (#213)
The last two embedded-vs-remote forks move onto the enum, so every such `if` in the CLI now lives in client.rs — the point of the refactor. - `export<W: Write>`: the streaming verb 3b deferred (writes to a writer, chunks the HTTP response body, rather than returning a DTO). Embedded calls db.export_jsonl_to_writer; Remote streams the chunked body through. Opens WITHOUT policy (like reads), so it routes via resolve(). - `list_graphs`: remote-only by design (no local enumeration endpoint), so the Embedded arm keeps the loud "requires a remote multi-graph server" bail verbatim. Routing it through the enum still buys the shared resolve() addressing/token preamble the arm hand-rolled. Retire the now-orphaned execute_export_to_writer / execute_export_remote_to_writer pair, and sweep two pre-existing dead fns while in the files: inferred_config_path (helpers.rs) and yaml_string (output.rs, shadowed by test-local copies). parity_matrix gains one row, parity_export — the single intended matrix change in this phase. Export is a JSONL stream, not a single --json doc, so it compares the two arms' output line-wise (sorted; twin graphs are byte-copies so rows need no scrubbing). graphs-list gets no row: its remote-only behavior is a documented exclusion, not an equality case. Full workspace tests pass; all 12 parity rows green. Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
d32c1ac191
commit
45500a690a
5 changed files with 137 additions and 114 deletions
|
|
@ -179,6 +179,35 @@ fn parity_load() {
|
|||
assert_parity("load", &l, &r);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parity_export() {
|
||||
let p = parity();
|
||||
let (l, r) = p.run(&["export"]);
|
||||
// export emits a JSONL STREAM, not a single `--json` document, so the
|
||||
// scrubbed-single-doc `assert_parity` doesn't apply — compare line-wise.
|
||||
// The twin graphs are byte-copies of one loaded fixture, so rows carry
|
||||
// identical ids/versions and need no scrubbing; sort the lines so any
|
||||
// cross-arm row-ordering difference doesn't masquerade as a divergence.
|
||||
assert_eq!(
|
||||
l.status.code(),
|
||||
r.status.code(),
|
||||
"export: exit codes diverge\nlocal {l:?}\nremote {r:?}"
|
||||
);
|
||||
assert!(l.status.success(), "export local arm failed: {l:?}");
|
||||
let mut local_lines: Vec<&str> = std::str::from_utf8(&l.stdout).unwrap().lines().collect();
|
||||
let mut remote_lines: Vec<&str> = std::str::from_utf8(&r.stdout).unwrap().lines().collect();
|
||||
assert!(
|
||||
!local_lines.is_empty(),
|
||||
"export produced no rows — the parity check would be vacuous"
|
||||
);
|
||||
local_lines.sort_unstable();
|
||||
remote_lines.sort_unstable();
|
||||
assert_eq!(
|
||||
local_lines, remote_lines,
|
||||
"export: JSONL streams diverge (left=local, right=remote)"
|
||||
);
|
||||
}
|
||||
|
||||
// ---- error parity: exit codes must match for shared failure cases ----
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue