Skip to main content
Case Study / 02

Fencekeep — Engineering Decision Knowledge Graph

Multi-tenant FalkorDB knowledge graph that traces why decisions were made, flags premise drift, and grounds answers with verified quotes

01 / Summary

Executive Summary & Facts

Problem: Engineering teams retain their source code but lose the rationale behind architectural decisions across Slack threads, PR reviews, Jira tickets, ADRs, and postmortems. Standard vector RAG retrieves isolated text chunks yet fails on relational questions—who owns a module, what breaks downstream, or whether an old assumption was later contradicted—and risks fabricating ungrounded citations.

Result: Built Fencekeep, a multi-tenant FalkorDB knowledge graph and retrieval-first agent that ingests structural engineering history deterministically, enforces verbatim quote verification (≥ 90% normalized match) on extracted decisions, flags outdated premises via two-model drift consensus, and logs an (:Answer)-[:USED]->(...) audit trail. On 40 ground-truth engineering questions, Fencekeep scores 34/40 (85.0%) strict (31/40 / 77.5% judged) versus 22/40 (55.0%) for dense vector RAG and 9/40 (22.5%) for keyword RAG, while deterministic zero-AI graph routing alone scores 32/40 (80.0%) in the baseline run and 36/40 (90.0%) after adding chained multi-hop tools.

Role: Lead AI & Knowledge Graph Engineer; designed and implemented the FalkorDB graph schema, deterministic GitHub and company-workspace importers, quote-grounded extraction and 2-model drift pipeline, 19 Cypher/graph tools, SSE agent loop and deterministic router, 16-tool MCP server, OKF v0.1 exporter, React 19 UI, and 40-question evaluation suite.

Role & OwnershipLead AI & Knowledge Graph Engineer
Timeframe & StatusAug 2026 – Nov 2026 · Full-Stack System (Docker Compose · AWS EC2 + Vercel)
Core Stack
Python 3.12 · FalkorDB · FastAPI · React 19 · MCP · Cypher · Docker Compose
02 / Problem

Problem & Engineering Constraints

Document retrieval in engineering organizations breaks down when questions cross system boundaries, time windows, or contributor histories:

1. The Relational Blindspot of Chunk-Based RAG

Dense vector search performs well when rationale sits inside a single paragraph (matching Fencekeep at 14/17 on isolated why questions), but collapses to 0/5 on expertise routing (who), 0/3 on dependency blast radius (impact), and 0/2 on timeline queries (history). Those answers do not live in one text chunk—they emerge from aggregating PR touches, review edges, dependency manifests, and timestamps across nodes.

2. Silent Decision Drift & Citation Hallucination

Teams rarely update old ADRs when a later incident or benchmark invalidates an original assumption, and free-form LLM extractors frequently paraphrase or invent source links. Extracting company memory requires deterministic structural edges paired with machine verification of every quoted claim.

Audited System Constraints:
• Structure First, AI Second: Authorship, reviews, file touches, cross-tool identities, ADRs/postmortems, and package dependencies parse deterministically without AI so graph topology cannot be hallucinated.
• Zero Unverified Claims: Every extracted premise must include a verbatim quote verified against the raw source text (verify_quote) or be discarded.
• Approval-Gated External Writes: Proposed GitHub issues, routing comments, handoff docs, and OKF wiki PRs persist as pending (:Action) nodes until approved, scoped strictly to FENCEKEEP_ACTION_REPOS with @mentions defanged.
• Multi-Tenant Workspace Isolation: Each workspace runs in an isolated FalkorDB graph (fencekeep across 13 public FalkorDB repos; fencekeep_orbiton for a 24-person company dataset).
03 / Architecture

Knowledge Graph & Agent Architecture

Fencekeep separates deterministic graph construction from bounded LLM judgment across four coordinated layers:

Structure-First Knowledge Graph & Grounded Agent LoopFalkorDB · Cypher · FastAPI SSE · MCP
SOURCESGitHub PRs & IssuesSlack & Jira CSVADRs & PostmortemsNO-AI IMPORTERIdentity & DepsFALKORDB GRAPHIsolated Workspace TenancyDecision → Premise → Source180d Decay · Betweenness · LPVERIFIED AI LAYERQUOTE VERIFICATION≥90% match · DISCUSSED_IN merge2-MODEL DRIFT GUARDDistinct LLM + quote → CHALLENGESRETRIEVAL AGENT19 Cypher & Graph ToolsPrefetch · Citation Ledger [n]Zero-AI Router Fallback(:Answer)-[:USED]->(Nodes)INTERFACES & MCPFastAPI SSE · React 19 Graph16 Read-Only MCP Tools4 Engineering WorkflowsGATED ACTIONS(:Action) Pending ApprovalOKF Wiki PRs · Issue Routing
System pipeline: Structural links load deterministically without AI; LLM extraction and drift detection require verified verbatim quotes and cross-model agreement before mutating the FalkorDB graph.

1. Deterministic Multi-Source Ingestion & Identity Unification

GitHub ingestion (github/fetch.py, ingest/loader.py) imports PRs, issues, discussions, reviews, CODEOWNERS, manifests (DEPENDS_ON), and docs while skipping dependency-bot churn (dependabot, renovate). Company workspaces (importers/workspace.py) ingest Slack exports, Jira/Linear CSVs, org charts, and Markdown ADRs/RFCs/ postmortems, resolving people across GitHub logins, Slack IDs, Jira display names, and email into unified Person nodes.

2. Graph Schema, Derived Expertise & Native Algorithms

The graph models Person, Team, System, Source, Decision, Premise, Action, and Answer nodes with range and full-text indexes (graph/schema.py). derive/expertise.py computes recency-weighted KNOWS_ABOUT edges (weights: decided=4.0, authored=3.0, wrote=3.0, reviewed=1.5, worked=1.5, merged=1.0, commented=0.5, chatted=0.5, discussed=0.75) with a 180-day half-life and log-dampened PR churn, while retaining undecayed lifetime scores for departure risk. Bi-directional WORKS_WITH edges power FalkorDB's native algo.betweenness (bridge engineers) and algo.labelPropagation (inferred teams).

3. Verbatim Quote Grounding, Decision Merging & 2-Model Drift

Extraction candidates are ranked by rationale language signals (rationale_signal) and reply depth. extract/grounding.py validates every extracted quote after NFKC and markdown normalization (≥ 12 characters, exact substring or ≥ 90% contiguous SequenceMatcher match). Restated decisions within ±120 days (or ±45 days on the same system) merge onto one Decision via DISCUSSED_IN while preserving numeric conflicts as distinct decisions. Drift detection (extract/drift.py) scans strictly later non-doc sources, requires a distinct second model (enforced via same_model()) to confirm contradiction, and verifies the contradicting quote before writing CHALLENGES and setting decision.drift = true.

4. Retrieval-First Agent, 19 Graph Tools & 4 Workflows

When a user asks a question via POST /api/ask (SSE stream), the deterministic router (agent/router.py) classifies intent and pre-fetches graph evidence before calling the LLM (capped at 5 tool steps across 19 Cypher/graph tools in agent/tools.py, including multi-hop traces departed_decisions, stale_runbooks, and trace_topic). A Ledger numbers citable evidence as [n]; clean_citations() strips invalid refs and logs (:Answer)-[:USED]->(...). Four built-in workflows (workflows.py) power Change Impact, Incident Memory, Decision Guard (zero-AI PR check), and Handoff Plan.

5. Read-Only MCP Server & Deterministic OKF v0.1 Wiki Export

mcp_server.py exposes 16 read-only graph tools over stdio, sse, or streamable-http for IDE/desktop agents (Claude Desktop, Cursor), while okf/export.py deterministically renders systems, decisions, quotes, drift warnings, people, and log.md into an Open Knowledge Format markdown bundle for approval-gated wiki PRs.

04 / Key Decisions

Engineering Decisions & Defenses

Decision: Storage & Retrieval: FalkorDB Property Graph + Cypher Tools over Flat Vector RAG
Selected Approach:Isolated FalkorDB graphs with explicit structural edges, full-text indexes, and 19 deterministic graph tools
Alternatives Evaluated:Chroma/Pinecone dense chunk RAG, full-text keyword search alone
Engineering Rationale:

Dense vector RAG only embeds isolated 1,500-character chunks. It cannot count PR touches across a 180-day half-life, traverse transitive DEPENDS_ON*1..4 blast radii, or compute betweenness centrality. Moving structural truth into Cypher yielded 5/5 on expertise routing and 3/3 on impact analysis where dense vector RAG scored 0/5 and 0/3.

Decision: Extraction & Drift Guardrails: Verbatim Quote Verification + Distinct 2-Model Consensus
Selected Approach:SequenceMatcher >=90% quote check (extract/grounding.py) and cross-model confirmation excluding the initial decider
Alternatives Evaluated:Single-pass LLM extraction without substring verification; single-model contradiction classification
Engineering Rationale:

Unverified LLM summaries silently introduce fabricated rationale or false drift alarms when a PR simply implements a decision. Requiring a verbatim quote in the raw source text and forcing a second distinct model (checked across provider aliases via same_model()) eliminated ungrounded claims and reduced noisy drift edges.

Decision: Agent Reliability: Retrieval-First Prefetch + Zero-AI Deterministic Router
Selected Approach:Prefetch deterministic router evidence before LLM turn 1, with automatic fallback to templated graph rendering
Alternatives Evaluated:Pure autonomous ReAct loop starting from empty context; hard failure when LLM quota runs out
Engineering Rationale:

LLMs are inconsistent about which tool to open first and frequently fail on false-premise traps. Pre-fetching evidence grounds turn 1 immediately, while the zero-AI router guarantees 0.07s answers (80% baseline / 90% post-eval strict score) even with zero API keys configured or when providers hit daily quota.

Decision: LLM Serving & Reproducibility: Multi-Provider Failover Chain + SHA-256 Disk Cache
Selected Approach:Ordered provider:model chains (Groq, Cloudflare, NVIDIA Build, Gemini, OpenRouter) with RPM pacing, 15m cooldowns, and content-addressed disk caching
Alternatives Evaluated:Single paid LLM provider; uncached ingestion runs
Engineering Rationale:

Free-tier providers impose strict daily token caps and RPM ceilings. Content-addressed caching of temperature-0 calls makes snapshot rebuilds cost zero quota, RPM pacing prevents 429 bursts on NVIDIA/OpenRouter, and daily-quota circuit breakers keep extraction and Q&A running across fallback providers.

05 / Evaluation

Empirical Evaluation & Benchmark Comparison

Fencekeep was evaluated on 40 ground-truth questions (eval/questions.jsonl) written directly from raw source data—25 across 13 public FalkorDB GitHub repositories (fencekeep) and 15 across the Orbiton multi-tool workspace (fencekeep_orbiton)—so evaluation is non-circular.

All LLM-enabled systems ran with nvidia:nvidia/nemotron-3.5-super-vl-120b-a12b and were scored two ways: Strict (automatic check verifying expected source UID cited, ≥ 50% expected key terms, expected people handles named, and false premises declined) and Judged (independent grading against written references by cloudflare:@cf/openai/gpt-oss-120b). Dense RAG embedded 1,500-character chunks (200-char overlap) using nvidia/nemotron-3-embed-1b in FalkorDB's vector index.

Benchmark 01 · Overall 4-System Comparison (40 Questions)eval/results.md
SystemStrict ScoreJudged ScoreFalkorDB (25)Orbiton (15)Avg Latency
fencekeep Graph Agent + Citation Ledger34/40 (85.0%)31/40 (77.5%)21/2513/154.6 s
router Deterministic Graph Only (Zero AI)32/40 (80.0%)*26/40 (65.0%)20/2512/150.07 s
vector Dense RAG (nemotron-3-embed-1b)22/40 (55.0%)19/40 (47.5%)13/259/150.47 s
rag Keyword Full-Text Search9/40 (22.5%)5/40 (12.5%)4/255/150.01 s
Zero runtime errors (0/40) across all four systems. *Post-evaluation update: adding chained multi-hop tools raised deterministic router scoring to 36/40 (90.0%) strict (4/4 multi-hop); only router was re-measured after that addition, so the table above reflects the synchronized 4-system run.
Benchmark 02 · Strict Score Breakdown by Question Category40 Questions Total
Categoryfencekeeproutervector RAGkeyword RAG
why (17) · Decision rationale14/1714/1714/173/17
who (5) · Expertise routing5/55/50/51/5
impact (3) · Dependency blast radius3/33/30/30/3
history (2) · Temporal window2/22/20/20/2
risk (3) · Bus factor & attrition3/33/31/30/3
drift (1) · Challenged premises1/11/11/10/1
incident (1) · Past outage lookup1/10/11/10/1
unanswerable (4) · False premises4/44/44/44/4
multi-hop (4) · Chained traversals1/40/4* (4/4 post-eval)1/41/4
Reproducible via cd backend && uv run fencekeep eval against eval/questions.jsonl.
Evaluation Finding · Why Graph Traversal Outperforms Vector Chunks

Highlighted rows (who, impact, history, risk) account for the entire 30-point accuracy gap between Fencekeep (85%) and dense vector RAG (55%). Vector RAG retrieves paragraphs describing local why decisions (14/17) and correctly refuses out-of-corpus false premises (4/4), but scores 0/10 combined on who, impact, and history because no single document chunk holds aggregated recency-weighted authorship or multi-repo dependency chains.

06 / Cost & Latency

Graph Scale, Latency & Cost Profile

Graph Snapshot Scale8,399 Nodes / 31,661 Edges7,249 nodes (149 decisions, 6,060 sources) in FalkorDB workspace + 1,150 nodes in Orbiton
Query Latency (Router vs Agent)0.07 s / 4.6 s AvgMeasured across all 40 benchmark queries (0 errors; deterministic router uses zero LLM tokens)
Verification & Caching68 Pytest Tests + Disk CacheSHA-256 temp-0 response cache enables zero-cost snapshot replays across 7 test suites
07 / Deployment

Containerized Architecture & AWS / Vercel Rollout

Fencekeep runs locally in a single command via Docker Compose (fencekeep demo restores both frozen snapshots in ~30 seconds with no API keys required) and includes a hardened single-VM deployment configuration (deploy/) paired with a Vercel frontend rewrite:

•Caddy 2.10 Reverse Proxy (:443): Provides automatic HTTPS, HSTS/nosniff security headers, static web serving, and unbuffered SSE streaming (flush_interval -1) on /api/*.
•FastAPI API Service (:8000, 768 MB limit): Serves SSE chat streams, graph endpoints, and workflow APIs behind a sliding-window per-client rate limiter (20 req/min default on /api/ask) and constant-time FENCEKEEP_ADMIN_TOKEN checks on write routes.
•Pinned FalkorDB 6.0.2 (Internal Only, 768 MB limit): No exposed database port; persisted under /opt/fencekeep-data with TIMEOUT_DEFAULT 30000 ms and RESULTSET_SIZE 20000.
•AWS EC2 t3.small + SSM + React 19 UI: Zero-SSH rollouts pull release tarballs from private S3 via AWS Systems Manager (2 GB swap provisioned); React 19 + Vite + react-force-graph-2d UI renders live reasoning subgraphs.

Live demo is accessible at https://fencekeep.vercel.app/.

08 / Retrospective

Engineering Retrospective: What Failed, Solved & Next Steps

Failure 1: FalkorDB 6.0.2 Query & Export Edge Cases

Pinned FalkorDB 6.0.2 returned empty sets on id(n) > -1, crashed when aggregate queries referenced never-stored property names, and evaluated filtered OPTIONAL MATCH clauses unreliably after an aggregating WITH. Resolution: Paged portable exports from id(n) >= 0, wrapped optional fields in coalesce(), split multi-step aggregations into sequential queries, sanitized unpaired emoji surrogates at load time, and stored WORKS_WITH edges bidirectionally for graph algorithms.

Failure 2: Citation Bracket Drift & Unverified Model Refs

Fallback models (including gpt-oss) emitted lenticular brackets (【1†source】), numeric spans ([1-3]), or tool names ([impact]) instead of integer citation refs. Resolution: Built clean_citations() in agent/loop.py to normalize bracket styles, expand valid ranges, strip ungrounded tool-name or unknown refs against Ledger, and degrade cleanly to the deterministic router whenever a model returns empty text or hits daily quota.

Failure 3: False-Positive Drift & Generic System Word Collisions

Early drift checks flagged PRs that carried out a decision as contradicting its pre-decision premise, and Decision Guard matched generic system identifiers (such as driver or app). Resolution: Excluded docs from drift candidates, filtered out title-restatement PRs (≥ 0.5 stem overlap with decision title), required ≥ 2 matching stems and two distinct LLMs with a verified quote, and subtracted system_words from Decision Guard term overlap.

Next Steps & Roadmap

  • Re-run the full 4-system benchmark suite across all models with the chained multi-hop tools enabled (currently re-measured only on router, which improved to 36/40).
  • Add live incremental connectors for Slack and Jira alongside the existing GitHub sync (currently imported via fencekeep workspace import).