Every Claude Code session accumulates decisions, patterns, and context. KFS (Knowledge Fabric Service) is the layer that captures this context, extracts the structure from it, and builds a temporal knowledge graph — so future sessions, Ralph tasks, and the dashboard can query what was decided, what was built, what was blocked, and why.
Without KFS: every session starts cold. With KFS: every session is aware of the full history — every decision made, every pattern confirmed, every connection drawn between Forge components. The graph compounds with time.
KFS is two services operating in layers:
| Service | Port | Responsibility |
|---|---|---|
knowledge | 5012 | Supabase-backed entity/relationship store. Ingests Gmail, Calendar, Drive. Vector search. |
kfs-graphiti | 5022 | Temporal graph via Graphiti + FalkorDB. Stores episodes (sessions, events) → extracts entities → builds relationships with time windows. |
The graphiti layer is what makes KFS different from a plain database: every fact has a valid_at and invalid_at timestamp, so the graph can answer "what was true at this point in time" rather than just "what is true now."
The harvest script reads Claude Code session JSONLs and feeds them into the graph automatically:
~/.claude/projects/-opt-forge/DECISION, PATTERN, BLOCKED, BUILT, RESOLVED, FIXED, DEPLOYEDkfs-graphiti which uses GPT-4o-mini to extract entities + relationships/opt/forge/logs/kfs-harvest.logforge-kfs-harvest.timer systemd unit. Processes the 5 most recent sessions. Dedup ensures no wasted work.
Each session is ingested as an episode in the claudecc vault. Graphiti automatically extracts:
# Semantic search across all sessions
curl -X POST http://localhost:5022/v1/query \
-H "Content-Type: application/json" \
-d '{"query":"cascade routing decisions","group_ids":["claudecc"],"limit":5}'
# Timeline for a specific entity
curl "http://localhost:5022/v1/timeline?entity=ClawdRouter&group_id=claudecc"
# Knowledge service search (Supabase vector)
curl "http://localhost:5012/v1/search?q=who+works+on+GTM"
| group_id | Source | What's in it |
|---|---|---|
claudecc | harvest-session.py | All Claude Code session decisions/patterns |
ralph | ralph.sh (planned) | Ralph task completions, errors, patterns |
jason | knowledge service | Gmail, Calendar, Drive entities |
curated | manual | Hand-crafted canonical facts |
# Harvest the current session manually
python3 /opt/forge/scripts/kfs/harvest-session.py --recent 1
# Backfill historical sessions
python3 /opt/forge/scripts/kfs/harvest-session.py --backfill 50
# Force re-harvest a session
python3 /opt/forge/scripts/kfs/harvest-session.py --recent 1 --force
# Query what the graph knows about a topic
curl -X POST http://localhost:5022/v1/query \
-H "Content-Type: application/json" \
-d '{"query":"YOUR QUESTION","group_ids":["claudecc"],"limit":5}'
ralph vault.
| Path | Purpose |
|---|---|
scripts/kfs/harvest-session.py | Core harvest script |
scripts/kfs/harvest-session.sh | Bash wrapper (uses kfs venv) |
services/forge-kfs-harvest.service | systemd oneshot service |
services/forge-kfs-harvest.timer | systemd timer (every 30min) |
services/kfs-graphiti/main.py | Graphiti FastAPI service (port 5022) |
logs/kfs-harvest.log | Harvest run log |
logs/kfs-harvested.txt | Dedup index (sha256 hashes of processed files) |