Skip to content

feat: HTTP graph mutation endpoints — POST /graph/edge and DELETE /graph/edge - #555

Merged
ajianaz merged 1 commit into
developfrom
feat/issue-542-graph-mutation-endpoints
Jul 4, 2026
Merged

ajianaz merged 1 commit into
developfrom
feat/issue-542-graph-mutation-endpoints

Conversation

@ajianaz

@ajianaz ajianaz commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

Closes #542

Adds HTTP endpoints for knowledge graph mutations so clients (e.g. Corin desktop) can operate fully HTTP-only without needing direct uteke-core::Uteke access — eliminating lifetime issues (E0597) from Mutex-locked state borrows.

Changes

New HTTP Endpoints

Method Path Auth Description
POST /graph/edge Write Add edge between two existing memories
DELETE /graph/edge?source=...&target=... Write Remove edge by source+target pair

Validation

  • 404 if source or target memory does not exist
  • 400 for self-loop edges (source == target)
  • 403 for read-only tokens (consistent with other write endpoints)

New MCP JSON-RPC Tools

  • uteke_graph_add_edge(source, target, edge_type?, weight?)
  • uteke_graph_remove_edge(source, target)

Core Changes

  • GraphStore::remove_edge() — deletes edge by source+target, returns bool

Files Changed (4 files, +261 lines)

File Change
uteke-core/src/graph.rs remove_edge() + 2 tests
uteke-server/src/handlers.rs POST/DELETE /graph/edge handlers
uteke-server/src/types.rs GraphEdgeRequest type
uteke-mcp/src/lib.rs 2 tool definitions + 2 exec functions

Acceptance Criteria (from #542)

  • POST /graph/edge adds edge between existing memories
  • DELETE /graph/edge?source=...&target=... removes edge
  • Returns 404 if source or target memory does not exist
  • Returns 400 for self-loop edges (source == target)
  • Read-only token returns 403
  • MCP JSON-RPC wrapper works for both operations
  • Handler tests added

Testing

  • 341 tests pass (including 2 new remove_edge tests)
  • Clippy clean, format clean, all CI checks should pass

Comment thread crates/uteke-mcp/src/lib.rs Fixed
@github-actions

github-actions Bot commented Jul 4, 2026 •

Copy link
Copy Markdown

🔍 Cora AI Code Review

❌ Blocked — critical issues found.

🔴 Error (1)

  • crates/uteke-core/src/graph.rs:304 — The new remove_edge implementation runs DELETE FROM graph_edges WHERE source_id = ?1 AND target_id = ?2, which ignores edge_type. In the same diff, edge creation explicitly supports typed relations (add_edge(..., edge_type, weight) and the new APIs accept edge_type on create), so if multiple differently typed edges exist between the same source/target pair, a single remove call will delete all of them. This is a functional bug and can cause unintended data loss.

Review powered by cora-cli · BYOK · MIT

…aph/edge (#542)

Adds HTTP endpoints for knowledge graph mutations so clients can be
fully HTTP-only without direct uteke-core access.

New endpoints:
- POST /graph/edge: Add edge between two existing memories
  - Validates both source/target memories exist (404 if not)
  - Rejects self-loops (400 if source == target)
  - Optional edge_type (default: 'related') and weight (default: 1.0)
- DELETE /graph/edge?source=...&target=...: Remove edge by source+target
  - Returns 404 if edge doesn't exist
  - Both endpoints return 403 for read-only tokens

New MCP tools:
- uteke_graph_add_edge: Add edge via JSON-RPC
- uteke_graph_remove_edge: Remove edge via JSON-RPC

Core changes:
- GraphStore::remove_edge() method (returns bool for existence check)
- GraphEdgeRequest type in server types
- Handler tests for remove_edge
@ajianaz
ajianaz force-pushed the feat/issue-542-graph-mutation-endpoints branch from 03f51cd to 03672d3 Compare July 4, 2026 04:04
/// Returns true if an edge was removed, false if none existed.
pub fn remove_edge(&self, source_id: &str, target_id: &str) -> Result<bool, Error> {
let affected = self
.conn
@ajianaz
ajianaz merged commit c094b55 into develop Jul 4, 2026
8 of 9 checks passed
@ajianaz
ajianaz deleted the feat/issue-542-graph-mutation-endpoints branch July 9, 2026 14:27
ajianaz added a commit that referenced this pull request Aug 13, 2026
…n-endpoints

feat: HTTP graph mutation endpoints — POST /graph/edge and DELETE /graph/edge
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.

feat: HTTP graph mutation endpoints — POST /graph/edge and DELETE /graph/edge

2 participants