Eklavya — Runtime Architecture

Eklavya — Runtime Architecture An architecture diagram generated by Archify. Developer · terminal · editor · Architecture component Developer terminal · editor Commit Gate · git pre-commit · Architecture component · fails open Commit Gate git pre-commit fails open Skills & Tutor Agent · 8 slash commands + tutor · Local process space · Claude Code + MCP server Skills & Tutor Agent 8 slash commands + tutor Config files · .eklavya.json → config.json · Local process space · Claude Code + MCP server · server + hooks Config files .eklavya.json → config.json server + hooks SRS Engine · SM-2 · decay · level bands · Local process space · Claude Code + MCP server · pure SRS Engine SM-2 · decay · level bands pure Claude Code Session · agent host process · Local process space · Claude Code + MCP server Claude Code Session agent host process Eklavya MCP Server · stdio · 9 tools · Local process space · Claude Code + MCP server · local dist, else npx Eklavya MCP Server stdio · 9 tools local dist, else npx Store & Gate Ledger · mastery · attempts · gates · Local process space · Claude Code + MCP server Store & Gate Ledger mastery · attempts · gates Hook Scripts · 6 lifecycle events · Node · Architecture component · exit 0 on failure Hook Scripts 6 lifecycle events · Node exit 0 on failure knowledge.db · SQLite WAL · migrated on open · ~/.eklavya/ · private learner state knowledge.db SQLite WAL · migrated on open CLI & Dashboard · eklavya dashboard · loopback only · 127.0.0.1:41729 · read-only CLI & Dashboard eklavya dashboard read-only one MCQ log · plan · grade resolve · schedule WAL write, retry on BUSY PostToolUse reads the row additionalContext: ask ONE tutor pedagogy mode · focus · cadence · difficulty SM-2 grade → next review git commit reads gates.repo · fails open Local process space · Claude Code + MCP server ~/.eklavya/ · private learner state loopback only · 127.0.0.1:41729 Legend Frontend Backend Database Security External

One turn of the loop

  • • 1 · the agent calls log_session_concepts while it works
  • • 2 · PostToolUse reads it and returns additionalContext
  • • 3 · an instruction to ask — never the question itself
  • • 4 · the model plans, asks, grades with record_attempt
  • • Budget is per session: mid-task answers Stop then skips

Six hooks, six mechanisms

  • • SessionStart — stdout; SubagentStart — the JSON form only
  • • UserPromptSubmit — one line, only when a session logged nothing
  • • PostToolUse — exit 0 + JSON; skipped inside subagents
  • • Stop — exit 2 + stderr is what actually blocks the turn
  • • PreToolUse(Bash) — permissionDecision "deny" on git commit

Server, state and boundaries

  • • stdout is the protocol; diagnostics are forced to stderr
  • • retryOnBusy wraps handlers; openDb seeds, then packs
  • • Repo gate reads .eklavya.json only, never global config
  • • Two commit gates, session and repo; both fail open
  • • run.mjs prefers mcp/dist; npx at the pinned version