Conversation
There was a problem hiding this comment.
Pull request overview
Adds developer-facing graph inspection capabilities (single-object lookup and bounded traversal) to the knowledge-graph stack, exposing them through the CLI for debugging/exploration of the stored SQLite graph.
Changes:
- Added
SqliteRepository.getObjectById()andSqliteRepository.getRelatedObjects()to fetch a single graph object and a neighborhood subgraph. - Added
KnowledgeGraphService.lookupObject()andKnowledgeGraphService.traverseGraph()wrappers over the repository. - Added CLI commands
graph getandgraph traverse(with--depth) to print JSON/object summaries and traversal results.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| libs/storage/sqlite/repository.ts | Adds object lookup and BFS traversal helpers over the SQLite graph tables/scopes. |
| libs/knowledge-graph/service.ts | Exposes repository lookup/traversal via service methods. |
| apps/cli/main.ts | Adds graph get / graph traverse CLI commands and argument parsing. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const current = queue.shift()!; | ||
| if (current.depth >= maxDepth) continue; | ||
|
|
||
| const edges = this.getEdgesForObject(current.type, current.id); |
| for (const edge of allEdges) { | ||
| if (!active.has(subjectKey("edge", edge.id))) continue; | ||
| const fromKey = subjectKey(edge.from_type, edge.from_id); | ||
| const toKey = subjectKey(edge.to_type, edge.to_id); | ||
| if (!edgesByObject.has(fromKey)) edgesByObject.set(fromKey, []); | ||
| if (!edgesByObject.has(toKey)) edgesByObject.set(toKey, []); | ||
| edgesByObject.get(fromKey)!.push(edge); | ||
| edgesByObject.get(toKey)!.push(edge); | ||
| } |
|
More thought needs to be put into this. |
…memory-cli-commands
|
@kushalpatil07 You're right to question what we're exposing. Let me break down the current design vs. what could be improved: What we're currently exposing:
The issue: We're exposing graph internals (component/flow/claim/edge/source types, BFS depth, edge relationships) directly to the CLI. The user/agent has to understand the graph model to use these. Suggested improvements with rationale:
What are your thoughts on this ? Happy to iterate on the design. |
…memory-cli-commands
Summary
Implemented graph object lookup and bounded related-memory traversal across the Greplica repository, service, and CLI layers. This adds the ability to retrieve individual graph objects by ID and traverse related graph entities using a configurable breadth-first search (BFS).
Resolve #36
What Changed
Repository Layer (
libs/storage/sqlite/repository.ts)Added repository APIs to support graph lookups and traversal:
getObjectById(type, id)component,flow,claim,edge, orsource).getEdgesForObject(type, id)getRelatedObjects(repoId, seedType, seedId, maxDepth)Service Layer (
libs/knowledge-graph/service.ts)Added service APIs that validate repository state before delegating to the repository layer:
lookupObject(input, type, id)traverseGraph(input, type, id, maxDepth)Validates the repository.
Executes bounded BFS traversal.
Returns a
GraphReadResultcontaining categorized graph entities:CLI (
apps/cli/main.ts)Added new graph commands:
greplica graph get <type> <id>greplica graph traverse <type> <id> [--depth <n>]1).Also added validation for:
Usage
greplica graph get claim cm_abc123 greplica graph traverse component comp_a1b2c3 --depth 2 greplica graph get source src_xyz