Skip to content

refactor(cli): collapse write/query forks onto GraphClient (RFC-009 Phase 3b) - #211

Merged
aaltshuler merged 1 commit into
mainfrom
refactor/graph-client-writes
Jun 13, 2026
Merged

refactor(cli): collapse write/query forks onto GraphClient (RFC-009 Phase 3b)#211
aaltshuler merged 1 commit into
mainfrom
refactor/graph-client-writes

Conversation

@aaltshuler

Copy link
Copy Markdown
Collaborator

Phase 3a put the GraphClient enum in place and collapsed the five uniform read forks. 3b folds the remaining data-plane forks onto the same enum: load, ingest, mutate, query, branch create/delete/merge, and schema apply. The 15 per-command if graph.is_remote {…} else {…} forks are now gone.

Design

  • Embedded grew an optional policy context{ uri, graph: Option<ResolvedCliGraph>, actor }. resolve() (reads + query) leaves it empty → bare Omnigraph::open; resolve_with_policy() (writes) fills it → open_local_db_with_policy + resolved actor. One open_embedded helper picks the path, preserving today's two behaviors exactly.
  • apply_schema takes the catalog validator as impl FnOnce(&Catalog) — embedded runs it inside apply_schema_as_with_catalog_check, remote ignores it (server runs its own check). That non-object-safe closure is why GraphClient is an enum, not a trait. The stored-query registry is still built caller-side, and only for the local path.
  • load and ingest stay separate methods — same operation, different surfaced shape (CLI LoadOutput with two distinct per-arm mappings vs the wire IngestOutput), so no drift risk.
  • The now-fully-dead execute_read/execute_read_remote and execute_change/execute_change_remote pairs are retired (legacy_change_request_body stays — client.rs uses it). The export pair remains for 3c.

Verification

  • parity_matrix.rs textually unchanged (not in the diff) — all 11 rows green.
  • cli_data / cli_schema_config / cli_queries green.
  • Full cargo test --workspace --locked → exit 0, zero failures.

Out of scope (→ 3c): export (streaming), graphs-list, export helper retirement.

🤖 Generated with Claude Code

…hase 3b)

Phase 3a put the GraphClient enum in place and collapsed the five uniform
read forks. 3b folds the remaining data-plane forks onto the same enum:
load, ingest, mutate, query, branch create/delete/merge, and schema apply.

The wrinkle 3a deferred was the local policy attachment. Reads and query
open the local engine without a policy; writes open through
open_local_db_with_policy and attribute a resolved actor. So the Embedded
variant grows an optional policy context (graph/actor) filled by a second
factory, resolve_with_policy; resolve() leaves it empty. open_embedded
picks the open path from whether the context is present, preserving both
of today's behaviors exactly. query still uses resolve() (no policy), as
the read path did.

apply_schema takes the catalog-validator closure as impl FnOnce(&Catalog)
— the embedded arm runs it inside apply_schema_as_with_catalog_check, the
remote arm ignores it (the server runs its own check). That non-object-safe
closure is why GraphClient is an enum, not a trait. The stored-query
registry is still built caller-side and only for the local path.

load and ingest stay separate methods: same operation, but load surfaces
the CLI LoadOutput (two distinct per-arm mappings preserved) while ingest
surfaces the wire IngestOutput. The now-fully-dead execute_read/
execute_read_remote and execute_change/execute_change_remote pairs are
retired (legacy_change_request_body stays — client.rs uses it); the export
pair remains for 3c.

The Phase-1 parity matrix is unchanged and green; full workspace tests pass.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@aaltshuler
aaltshuler requested a review from ragnorc as a code owner June 13, 2026 15:32

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aaltshuler has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@ragnorc

ragnorc commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

@greptile review

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aaltshuler has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@aaltshuler
aaltshuler merged commit d32c1ac into main Jun 13, 2026
8 checks passed
@aaltshuler
aaltshuler deleted the refactor/graph-client-writes branch June 13, 2026 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants