ruvnet/ruflo/tree/main/plugins/ruflo-knowledge-graph
ruflo-knowledge-graph
지식 그래프 구축—엔터티 추출, 관계 매핑, 경로 탐색 그래프 순회. mod(ADR-445)로서 비밀을 그래프에서 제외하고, 그래프 삭제를 확인하며, /kg-mod와 콘솔에 표시되는 상태 파일을 제공합니다
이 mod 소개
지식 그래프 구축—엔터티 추출, 관계 매핑, 경로 탐색 그래프 순회.
개요
소스 코드와 문서에서 엔터티(클래스, 함수, 모듈, 타입, 개념)와 관계(imports, extends, implements, depends-on, calls)를 추출합니다. 계층형 노드와 인과 엣지를 사용해 AgentDB에 탐색 가능한 지식 그래프를 구축합니다. 경로 탐색 알고리즘으로 그래프를 순회하며, 엣지 가중치와 의미적 유사도로 경로를 평가합니다.
설치
claude --plugin-dir plugins/ruflo-knowledge-graph
Agents
| Agent | 모델 | 역할 |
|-------|------|------|
| graph-navigator | sonnet | 엔터티 추출, 관계 매핑, 지식 그래프 구축, 경로 탐색 |
Skills
| Skill | 사용법 | 설명 |
|-------|--------|------|
| kg-extract | /kg-extract <path> | 소스 파일에서 엔터티와 관계를 추출해 지식 그래프 구축 |
| kg-traverse | /kg-traverse <entity> [--depth N] | 시드 엔터티에서 시작하는 경로 탐색 |
명령(5개 하위 명령)
kg extract <path> # 소스 파일에서 엔터티와 관계 추출
kg traverse <entity> # 시드 엔터티에서 경로 탐색 시작
kg relations <entity> # 엔터티의 모든 직접 관계 나열
kg visualize # 지식 그래프를 ASCII로 시각화
kg search <query> # 그래프 전체에서 의미 검색
엔터티 유형
| 유형 | 예시 |
|------|------|
| class | UserService, AuthController |
| function | calculateDiscount, handleRequest |
| module | auth, payments, api |
| concept | authentication, caching |
| type | User, OrderStatus |
| config | database, redis, jwt |
호환성
- CLI:
@claude-flow/cliv3.6 major+minor에 고정됩니다. - 검증:
bash plugins/ruflo-knowledge-graph/scripts/smoke.sh가 계약입니다.
네임스페이스 조정
이 플러그인은 knowledge-graph AgentDB 네임스페이스를 소유합니다(kebab-case이며 ruflo-agentdb ADR-0001 "Namespace convention"의 규칙을 따릅니다). 예약된 네임스페이스(pattern, claude-memories, default)를 가려서는 안 됩니다.
엔터티 노드는 agentdb_hierarchical-store로 저장하고, 관계 엣지는 agentdb_causal-edge로 저장하며, 의미 인덱싱에는 embeddings_generate를 사용합니다(embeddings_embed가 아님—그런 도구 이름은 존재하지 않으며 ADR-0001에서 이전 참조를 바로잡았습니다).
경로 탐색 알고리즘
- Seed — 대상 엔터티 노드에서 시작
- Expand — 인과 엣지를 바깥쪽으로 따라감(설정 가능한 깊이, 기본값 3)
- Score —
relevance = edge_weight * semantic_similarity(query, node) - Prune — 임계값 미만의 경로 제거(기본값 0.3)
- Rank — 누적 관련성 기준으로 상위 K개 경로 반환
G7 컨트롤러(ruflo 3.6.23+ / 3.6.24에서 활성화)
ADR-095에서 이 플러그인의 그래프 순회가 활용할 수 있는 AgentDB 컨트롤러 5개를 완성했습니다.
gnnService— AgentDB 인과 그래프에서 GNN 임베딩과 관계 점수 계산을 수행합니다. 경로 탐색기의semantic_similarity(query, node)항에 구조를 반영한 점수를 더하고, 관련성이 확인된 노드의 그래프 이웃 노드를 상향합니다.rvfOptimizer— 영속화 전에 벡터 블록을 양자화하고 중복 제거합니다. 지식 그래프 인덱스에는 여러 모듈에서 다시 내보낸 동일 클래스처럼 거의 중복되는 엔터티 벡터가 많은 경우가 흔하며,rvfOptimizer가 이를 투명하게 합칩니다.mutationGuard+attestationLog+GuardedVectorBackend— 하위 벡터 저장소에 대한 쓰기를 증명으로 게이트합니다. 그래프가 신뢰 경계를 넘는 경우(연합 지식 가져오기)에 유용하며,.swarm/attestation.db의 증명 체인이 사후 감사를 위해 모든 변경을 기록합니다.
아직 보류 중인 graphAdapter 컨트롤러는 이 플러그인에 일급 그래프 DB 백엔드를 제공합니다(AgentDB의 평면 causal-edge 테이블 위에 그래프 뷰를 만드는 방식 대신). ADR-095에서 추적 중입니다.
agentdb_controllers 또는 agentdb_health MCP 도구로 런타임 상태를 확인할 수 있습니다.
검증
bash plugins/ruflo-knowledge-graph/scripts/smoke.sh
# 예상: "10 passed, 0 failed"
아키텍처 결정
관련 플러그인
ruflo-agentdb— 위 G7 컨트롤러는 이 플러그인의 런타임을 통해 제공됩니다. 전체 그래프 및 순회 범위를 사용하려면 둘 다 설치하세요. 네임스페이스 규칙 소유자입니다ruflo-ruvector— 그래프 노드의 빠른 의미 검색을 위한 HNSW 인덱싱ruflo-adr— ADR 의존성 그래프가 동일한 인과 엣지 모델을 공유
라이선스
MIT
mod로 사용
이 플러그인은 함수 훅 mod(ADR-445, hooks/register.ts)를 함께 제공합니다. 네트워크 호출, 프로세스 생성, 모델 호출을 하지 않습니다.
- Guard(기본 활성화, 강화만 가능): 키, 토큰 또는 비밀번호가 들어 있는 그래프 쓰기(
agentdb_causal-edge,agentdb_hierarchical-store,agentdb_pattern-store)를 거부하고,confirm: true가 없는agentdb_causal-edge-delete/agentdb_causal-node-delete호출도 거부합니다. 거부할 때 비밀을 다시 표시하지 않습니다. /kg-mod:status,recent,tools(이 플러그인의 어떤 도구가 연결되었는지),scan <text>(Guard가 거부할지)를 제공합니다. 로컬에서 응답합니다.- 상태 파일:
.claude-flow/kg-mod/status.json({version: 1, updatedMs, guard, calls, total, blocked, recent}, 카운터만 포함하며 도구 입력은 저장하지 않음)을 세션 시작 시와 이 플러그인의 도구를 호출한 뒤마다 기록합니다.
옵션(userConfig): guard(켜짐), confirmDeletes(켜짐).
테스트: claude plugin validate plugins/ruflo-knowledge-graph, claude plugin test plugins/ruflo-knowledge-graph, bash plugins/ruflo-knowledge-graph/scripts/smoke.sh.
설치
먼저 작성자의 README에서 marketplace와 플러그인 이름을 확인하세요. 저장소 구조에 따라 명령어가 달라질 수 있습니다.
claude plugin marketplace add ruvnet/ruflo claude plugin install ruflo-knowledge-graph
원문 / README
ruflo-knowledge-graph
Knowledge graph construction -- entity extraction, relation mapping, and pathfinder graph traversal.
Overview
Extracts entities (classes, functions, modules, types, concepts) and relations (imports, extends, implements, depends-on, calls) from source code and documentation. Builds a navigable knowledge graph stored in AgentDB with hierarchical nodes and causal edges. Traverses the graph using a pathfinder algorithm that scores paths by edge weight and semantic similarity.
Installation
claude --plugin-dir plugins/ruflo-knowledge-graph
Agents
| Agent | Model | Role |
|-------|-------|------|
| graph-navigator | sonnet | Entity extraction, relation mapping, knowledge graph construction, pathfinder traversal |
Skills
| Skill | Usage | Description |
|-------|-------|-------------|
| kg-extract | /kg-extract <path> | Extract entities and relations from source files to build a knowledge graph |
| kg-traverse | /kg-traverse <entity> [--depth N] | Pathfinder traversal starting from a seed entity |
Commands (5 subcommands)
kg extract <path> # Extract entities and relations from source files
kg traverse <entity> # Pathfinder traversal from a seed entity
kg relations <entity> # List all direct relations for an entity
kg visualize # ASCII visualization of the knowledge graph
kg search <query> # Semantic search across the graph
Entity Types
| Type | Examples |
|------|----------|
| class | UserService, AuthController |
| function | calculateDiscount, handleRequest |
| module | auth, payments, api |
| concept | authentication, caching |
| type | User, OrderStatus |
| config | database, redis, jwt |
Compatibility
- CLI: pinned to
@claude-flow/cliv3.6 major+minor. - Verification:
bash plugins/ruflo-knowledge-graph/scripts/smoke.shis the contract.
Namespace coordination
This plugin owns the knowledge-graph AgentDB namespace (kebab-case, follows the convention from ruflo-agentdb ADR-0001 §"Namespace convention"). Reserved namespaces (pattern, claude-memories, default) MUST NOT be shadowed.
Entity nodes are stored via agentdb_hierarchical-store; relation edges via agentdb_causal-edge; semantic indexing via embeddings_generate (NOT embeddings_embed — that tool name doesn't exist; ADR-0001 fixes prior references).
Pathfinder Algorithm
- Seed -- start from the target entity node
- Expand -- follow causal edges outward (configurable depth, default 3)
- Score --
relevance = edge_weight * semantic_similarity(query, node) - Prune -- remove paths below threshold (default 0.3)
- Rank -- return top-K paths by cumulative relevance
G7 controllers (activated in ruflo 3.6.23+ / 3.6.24)
ADR-095 closed five AgentDB controllers that this plugin's graph traversal can leverage:
gnnService— GNN embeddings + relational scoring over the AgentDB causal graph. Augments the pathfinder'ssemantic_similarity(query, node)term with structurally-aware scoring; nodes that are graph-neighbors of confirmed-relevant nodes get a boost.rvfOptimizer— Quantizes + dedupes vector blocks before persistence. Knowledge-graph indexes commonly have many near-duplicate entity vectors (same class re-exported from multiple modules); rvfOptimizer collapses them transparently.mutationGuard+attestationLog+GuardedVectorBackend— Proof-gated writes to the underlying vector store. Relevant when the graph spans trust boundaries (federated knowledge import) — the attestation chain at.swarm/attestation.dbrecords every mutation for after-the-fact audit.
The yet-pending graphAdapter controller will give this plugin a first-class graph-DB backend (instead of building the graph view on top of AgentDB's flat causal-edge table). Tracked in ADR-095.
Inspect runtime status via the agentdb_controllers or agentdb_health MCP tools.
Verification
bash plugins/ruflo-knowledge-graph/scripts/smoke.sh
# Expected: "10 passed, 0 failed"
Architecture Decisions
Related Plugins
ruflo-agentdb-- The G7 controllers above ship via this plugin's runtime; install both for full graph + traversal coverage; namespace convention ownerruflo-ruvector-- HNSW indexing for fast semantic search across graph nodesruflo-adr-- ADR dependency graphs share the same causal edge model
License
MIT
As a mod
This plugin ships a function-hook mod (ADR-445, hooks/register.ts). It makes no network call, spawns no process and makes no model call.
- Guard (tighten-only, on by default): Refuses graph writes (
agentdb_causal-edge,agentdb_hierarchical-store,agentdb_pattern-store) that hold a key, token or password, andagentdb_causal-edge-delete/agentdb_causal-node-deleteunless the call carriesconfirm: true. A refusal never echoes the secret. /kg-mod:status,recent,tools(which of this plugin's tools are connected) andscan <text>(would the guard refuse it). Answered locally.- Status file:
.claude-flow/kg-mod/status.json({version: 1, updatedMs, guard, calls, total, blocked, recent}, counters only, never tool input), written at session start and after every call to this plugin's tools.
Options (userConfig): guard (on), confirmDeletes (on).
Test it: claude plugin validate plugins/ruflo-knowledge-graph, claude plugin test plugins/ruflo-knowledge-graph, bash plugins/ruflo-knowledge-graph/scripts/smoke.sh.