Alibi LogoALIBI/Architecture & Hackathon Docs
Graph Hacks Track 01 · System Specification

Agents That Act on Connected Data

Alibi is a deductive reasoning detective game powered by FalkorDB. Suspect statements, physical room topology, and forensic items form an isolated graph partition. Graph algorithms expose lies through shortest paths, cycle detection, and alibi-support chains.

Engine: FalkorDB v6.8AI SDK: Vercel AI SDK + Gemini FlashMCP: @modelcontextprotocol/sdkTests: 75 / 75 Passing (Real DB)
Hackathon Requirements

Track 01 Alignment Matrix

Organizers of Track 01 require that graph databases do genuine computational work rather than serving as passive text stores. Here is how Alibi delivers on every single focus point:

Multi-Hop Reasoning

Topological & Motive Traversal

Motive paths traverse up to 3 hops across KNOWN_REL edges. Physical movement feasibility runs variable-length shortest paths over connected estate rooms.

Queries as Agent Tools

10 Formalized Tools

8 read tools and 2 board writes in TOOLS. The AI agent never writes ad-hoc Cypher; it dispatches parameterized, audited queries through typed Zod contracts.

Tool Selection via MCP

Standard Stdio MCP Server

pnpm mcp starts an MCP server over the standard reasoning tool registry, allowing external agent systems (Claude, Cursor, custom agents) to solve murder cases.

Graph-Driven Actions

Board Mutations & Elimination

When graph queries detect a lie, the Inspector writes :Flag and :Hypothesis nodes directly to the board with justification references.

Explainable Results

Concrete Paths, Not Guesses

Every deductive assertion includes the exact room path, contradiction pair, or alibi-support chain that produced it. The verdict screen diffs what the player solved against ground truth.

Honest Abstention

"No Path" vs "Nothing"

Empty query results are semantically differentiated. "No path known" is a valid graph traversal state, preserving full mathematical precision without hallucinating false connections.

Architectural Core

The Information Barrier (Graph Partitions)

In AI reasoning systems, "cheating" occurs when the model or copilot has access to ground truth. Alibi enforces a cryptographic-level information barrier using dedicated FalkorDB database partitions:

truth:{caseId}RESTRICTED

Ground Truth Partition

Contains hidden reality: actual perpetrators, true locations at each minute, hidden secret passages, knowledge facts (knownBy), and authored claims with truth flags.

Accessible ONLY by: ask, search, bait, verdict. Never sent to client or Inspector.
public:{caseId}TEMPLATE

Public Map & Cast

The blueprint copied at the start of an investigation. Contains known rooms, open doors, public suspect personas, and time slots. Hidden doors and true alibis are scrubbed.

Copied via: GRAPH.COPY public:{c} play:{p}:{c}.
play:{pid}:{caseId}PLAY GRAPH

Isolated Tenant Graph

The player's working graph. Grows in real-time as statements are extracted and rooms are searched. Contains :Statement, :Assertion, :Flag, and :Hypothesis nodes.

AI Inspector & MCP read ONLY this partition. Zero truth leakage possible.
FalkorDB Engine Contract

The 10 Formal Reasoning Tools

Every tool conforms to a strict Zod contract returning the standard envelope: { ok, data, trace }. Below are the 10 tools implemented in src/engine/tools/:

Tool NameTypeUnderlying Cypher QueryPurpose & Graph Logic
getBoardReadMulti-MATCHFull snapshot of active statements, evidence, flags, hypotheses, and tick count.
findContradictionsReadQ60_contradictionsFinds assertions placing the same subject in two distinct rooms at the same time slot.
findRehearsedAlibisReadQ61_rehearsedIdentifies pairs/triplets of suspects giving identical specific location details.
findImpossibleMovesReadQ62 & Q63_distanceFlags sequential room claims where required room transitions exceed available time slots.
checkFeasibilityReadQ66_hard_anchorsChecks if a person could have reached a target room given their fixed physical anchors.
whoCouldHaveReadQ68_evidence_actElimination algorithm: tests candidate feasibility for a scene act; returns survivors.
motivePathsReadQ70_motive_pathsTraverses up to 3 hops of known social/business relationships between suspect and victim.
alibiSupportReadGraph Alibi ChainsEvaluates whether a corroborating witness has a reliable alibi or is compromised.
flagWriteCREATE (:Flag)Pins an inconsistency card (contradiction, impossible move, rehearsed) to the board.
hypothesizeWriteCREATE (:Hypothesis)Writes a formal suspect accusation hypothesis with confidence percentage to the board.
OpenCypher Showcase

Key FalkorDB Graph Queries

All Cypher in Alibi is strictly parameterized, pre-audited, and executed via roQuery for sub-10ms performance:

Q60_contradictions·Direct Space-Time Collisions
~3.2ms
MATCH (a:Assertion), (b:Assertion)
WHERE a.subject = b.subject 
  AND a.slot = b.slot 
  AND a.room <> b.room 
  AND a.src < b.src
RETURN a.src AS srcA, a.hard AS hardA, 
       b.src AS srcB, b.hard AS hardB, 
       a.subject AS subject, a.slot AS slot, 
       a.room AS roomA, b.room AS roomB
Q63_distance·Spatial Traversal over Estate Graph
~4.1ms
MATCH (a:Room {id: $from}), (b:Room {id: $to})
MATCH p = shortestPath((a)-[:CONNECTS|HIDDEN_KNOWN*..8]-(b))
WHERE ALL(r IN relationships(p) WHERE 
  (type(r) = 'CONNECTS' AND r.state = 'open') OR 
  (type(r) = 'HIDDEN_KNOWN' AND $useHidden))
RETURN length(p) AS d, [n IN nodes(p) | n.id] AS path
Q70_motive_paths·Social & Business Relationship Chains
~5.4ms
MATCH p = (a:Party {id: $person})-[:KNOWN_REL*1..3]-(v:Person {victim: true})
RETURN [r IN relationships(p) | r.id] AS relationIds, length(p) AS len
ORDER BY len LIMIT 3
Fair Play & Anti-Hallucination

The Author Claim Firewall

LLMs in games frequently hallucinate false clues or reveal the killer prematurely. Alibi solves this with a strict four-stage interrogation pipeline:

1. Claim Selection

Q40_select_claims queries the truth graph for authorized claims matching the topic and time slot that haven't already been revealed.

2. Verbalization

The LLM verbalizes the claim text in character with a structured JSON schema returning { reply, claimIds }.

3. Firewall Check

firewall.ts strictly verifies returned claim IDs and scans for forbidden keyword leaks against truth facts.

4. Template Fallback

If the LLM fails validation or the network is offline (ALIBI_LLM=off), the game falls back directly to the authored claim text.

Verification & Reproducibility

Oracle Parity & Zero Mocking

Every reasoning tool in Alibi has an oracle implementation in pure JavaScript (scripts/reference-engine.mjs). Automated test suites verify 100% parity against live FalkorDB:

Real FalkorDB Tests

Tests hit a real FalkorDB container on localhost:6379. Zero mocked database queries.

Information Barrier Test

Automated leak tests verify that no ground-truth fields (culprits, knownBy) ever appear in player responses or Inspector contexts.

Deterministic Fallback

If an AI provider encounters rate limits or API outages, a deterministic plan executes the exact same FalkorDB tool pipeline with zero disruption.

Explore the Live Implementation

Experience the graph reasoning engine live in the browser, review the developer field manual, or inspect the styleguide component library.