Add Phase 4 knowledge graph: nodes, cells, facts, edges, gRPC service

Build the knowledge graph pillar with the kg package:
- Node: hierarchical notes with parent/children, C2 wiki-style naming,
  shared tag/category pool with artifacts
- Cell: content units (markdown, code, plain) with ordinal ordering
- Fact: EAV tuples with transaction timestamps and retraction support
- Edge: directed graph links (child, parent, related, artifact_link)

Includes schema migration (002_knowledge_graph.sql), protobuf definitions
(kg.proto), full gRPC KnowledgeGraphService implementation, CLI commands
(node create/get), and comprehensive test coverage.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-21 10:05:43 -07:00
parent a336dc1ebb
commit 051a85d846
14 changed files with 3283 additions and 6 deletions

View File

@@ -60,7 +60,28 @@ Tracks implementation progress against the phases in `PROJECT_PLAN.md`.
- `cmd/exod/main.go`
- `cmd/exo/main.go`, `cmd/exo/yaml.go`
## Phase 4: Knowledge Graph — NOT STARTED
## Phase 4: Knowledge Graph — COMPLETE
**Deliverables:**
- [x] `kg` package: `Node`, `Cell`, `Fact`, `Edge` types with `Store`/`Get` methods
- [x] Database schema migration (`002_knowledge_graph.sql`): nodes, cells, facts, edges, node_tags, node_categories tables
- [x] Node hierarchy (parent/children), C2 wiki-style naming, lookup by name
- [x] Cell content types (markdown, code, plain) with ordinal ordering
- [x] EAV fact storage with transaction timestamps and retraction support
- [x] `GetCurrentFactsForEntity` applies retraction logic to return only active facts
- [x] Edge types: child, parent, related, artifact_link (cross-pillar references)
- [x] Protobuf definitions (`proto/exo/v1/kg.proto`): Node, Cell, Fact, Edge messages and KnowledgeGraphService
- [x] gRPC service: CreateNode, GetNode, AddCell, RecordFact, GetFacts, AddEdge, GetEdges
- [x] CLI commands: `exo node create <name>`, `exo node get <id>`
- [x] KG service registered in exod
- [x] Shared tag/category pool: nodes use the same tags/categories tables as artifacts
- [x] Full test coverage (kg package: 10 tests covering nodes, cells, facts, edges, hierarchy, retractions)
**Files created:**
- `kg/node.go`, `kg/cell.go`, `kg/fact.go`, `kg/edge.go`, `kg/kg_test.go`
- `db/migrations/002_knowledge_graph.sql`
- `proto/exo/v1/kg.proto`, `proto/exo/v1/kg.pb.go`, `proto/exo/v1/kg_grpc.pb.go`
- `server/kg_server.go`
## Phase 5: Desktop Application — NOT STARTED (Kotlin, out of scope for Go backend)