---
title: "ruflo-knowledge-graph"
url: "https://claudemods.dev/ko/builds/ruflo-knowledge-graph-3b4256"
source: "https://github.com/ruvnet/ruflo/tree/main/plugins/ruflo-knowledge-graph"
source_type: "github"
repo: "https://github.com/ruvnet/ruflo/tree/main/plugins/ruflo-knowledge-graph"
author: "ruvnet"
author_handle: "ruvnet"
stars: 82516
category: "멀티 에이전트 및 오케스트레이션"
categories: ["agents"]
tags: ["agentdb", "guard", "hooks", "knowledge-graph", "pathfinder", "plugin"]
permission_level: 2
scan_complete: true
install: "claude plugin marketplace add ruvnet/ruflo\nclaude plugin install ruflo-knowledge-graph"
added: "2026-10-05T08:13:34.132Z"
updated: "2026-11-26T14:25:45Z"
locale: "ko"
content_locale: "ko"
---

# ruflo-knowledge-graph

지식 그래프 구축—엔터티 추출, 관계 매핑, 경로 탐색 그래프 순회. mod(ADR-445)로서 비밀을 그래프에서 제외하고, 그래프 삭제를 확인하며, /kg-mod와 콘솔에 표시되는 상태 파일을 제공합니다

## Description

지식 그래프 구축—엔터티 추출, 관계 매핑, 경로 탐색 그래프 순회.

## 개요

소스 코드와 문서에서 엔터티(클래스, 함수, 모듈, 타입, 개념)와 관계(imports, extends, implements, depends-on, calls)를 추출합니다. 계층형 노드와 인과 엣지를 사용해 AgentDB에 탐색 가능한 지식 그래프를 구축합니다. 경로 탐색 알고리즘으로 그래프를 순회하며, 엣지 가중치와 의미적 유사도로 경로를 평가합니다.

## 설치

```bash
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개 하위 명령)

```bash
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/cli` v3.6 major+minor에 고정됩니다.
- **검증:** `bash plugins/ruflo-knowledge-graph/scripts/smoke.sh`가 계약입니다.

## 네임스페이스 조정

이 플러그인은 `knowledge-graph` AgentDB 네임스페이스를 소유합니다(kebab-case이며 [ruflo-agentdb ADR-0001 `"Namespace convention"`](../ruflo-agentdb/docs/adrs/0001-agentdb-optimization.md)의 규칙을 따릅니다). 예약된 네임스페이스(`pattern`, `claude-memories`, `default`)를 가려서는 안 됩니다.

엔터티 노드는 `agentdb_hierarchical-store`로 저장하고, 관계 엣지는 `agentdb_causal-edge`로 저장하며, 의미 인덱싱에는 `embeddings_generate`를 사용합니다(`embeddings_embed`가 아님—그런 도구 이름은 존재하지 않으며 ADR-0001에서 이전 참조를 바로잡았습니다).

## 경로 탐색 알고리즘

1. **Seed** — 대상 엔터티 노드에서 시작
2. **Expand** — 인과 엣지를 바깥쪽으로 따라감(설정 가능한 깊이, 기본값 3)
3. **Score** — `relevance = edge_weight * semantic_similarity(query, node)`
4. **Prune** — 임계값 미만의 경로 제거(기본값 0.3)
5. **Rank** — 누적 관련성 기준으로 상위 K개 경로 반환

## G7 컨트롤러(ruflo 3.6.23+ / 3.6.24에서 활성화)

[ADR-095](../../v3/docs/adr/ADR-095-architectural-gaps-from-april-audit.md)에서 이 플러그인의 그래프 순회가 활용할 수 있는 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
bash plugins/ruflo-knowledge-graph/scripts/smoke.sh
# 예상: "10 passed, 0 failed"
```

## 아키텍처 결정

- [`ADR-0001` — ruflo-knowledge-graph 플러그인 계약(embeddings_generate 수정, 네임스페이스 조정, smoke를 계약으로 사용)](./docs/adrs/0001-knowledge-graph-contract.md)

## 관련 플러그인

- `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`.

## Install

```
claude plugin marketplace add ruvnet/ruflo
claude plugin install ruflo-knowledge-graph
```

## Original 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

```bash
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)

```bash
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/cli` v3.6 major+minor.
- **Verification:** `bash plugins/ruflo-knowledge-graph/scripts/smoke.sh` is the contract.

## Namespace coordination

This plugin owns the `knowledge-graph` AgentDB namespace (kebab-case, follows the convention from [ruflo-agentdb ADR-0001 §"Namespace convention"](../ruflo-agentdb/docs/adrs/0001-agentdb-optimization.md)). 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

1. **Seed** -- start from the target entity node
2. **Expand** -- follow causal edges outward (configurable depth, default 3)
3. **Score** -- `relevance = edge_weight * semantic_similarity(query, node)`
4. **Prune** -- remove paths below threshold (default 0.3)
5. **Rank** -- return top-K paths by cumulative relevance

## G7 controllers (activated in ruflo 3.6.23+ / 3.6.24)

[ADR-095](../../v3/docs/adr/ADR-095-architectural-gaps-from-april-audit.md) 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's `semantic_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.db` records 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
bash plugins/ruflo-knowledge-graph/scripts/smoke.sh
# Expected: "10 passed, 0 failed"
```

## Architecture Decisions

- [`ADR-0001` — ruflo-knowledge-graph plugin contract (embeddings_generate fix, namespace coordination, smoke as contract)](./docs/adrs/0001-knowledge-graph-contract.md)

## Related Plugins

- `ruflo-agentdb` -- The G7 controllers above ship via this plugin's runtime; install both for full graph + traversal coverage; namespace convention owner
- `ruflo-ruvector` -- HNSW indexing for fast semantic search across graph nodes
- `ruflo-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, and `agentdb_causal-edge-delete` / `agentdb_causal-node-delete` unless the call carries `confirm: true`. A refusal never echoes the secret.
- **`/kg-mod`**: `status`, `recent`, `tools` (which of this plugin's tools are connected) and `scan <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`.
