Skip to main content
Glama
README.md
<p align="center">
  <img src="assets/brand/logo-horizontal.svg" alt="OpenYantra" width="540"/>
</p>

<h1 align="center">OpenYantra</h1>
<h3 align="center">The Sacred Memory Machine</h3>
<h4 align="center"><em>यन्त्र -- Inspired by Chitragupta, the Hindu God of Data</em></h4>

<p align="center">
  <a href="https://github.com/revanthlevaka/OpenYantra/actions/workflows/ci.yml"><img src="https://github.com/revanthlevaka/OpenYantra/actions/workflows/ci.yml/badge.svg" alt="OpenYantra CI" /></a>
  <img src="https://img.shields.io/badge/Core%20Engine-v7.0.0-saffron?style=flat-square&color=FF9933" />
  <img src="https://img.shields.io/badge/Desktop%20App-v7.0.0-blueviolet?style=flat-square" />
  <img src="https://img.shields.io/badge/MCP-Claude%20%26%20Cursor-success?style=flat-square&color=10b981" />
  <img src="https://img.shields.io/badge/Obsidian-Bi--Directional%20Sync-purple?style=flat-square" />
  <img src="https://img.shields.io/badge/Tests-183%2F183%20Passing-brightgreen?style=flat-square" />
  <img src="https://img.shields.io/badge/License-MIT-blue?style=flat-square" />
</p>

<p align="center">
  <strong>Your personal AI agents remember nothing between sessions. OpenYantra fixes that permanently.</strong><br/>
  One open-standard file. Zero cloud lock-in. Omnipresent Desktop HUD. 1-Click MCP. Local AI sleep consolidation.
</p>

<p align="center">
  <a href="docs/GETTING_STARTED.md"><strong>📖 Complete Getting Started Guide</strong></a> •
  <a href="PROTOCOL.md"><strong>Protocol Spec</strong></a> •
  <a href="docs/TEAM_MESH.md"><strong>Team Mesh</strong></a> •
  <a href="docs/GATEWAY.md"><strong>Memory Gateway</strong></a> •
  <a href="docs/COGNITIVE_DRIFT.md"><strong>Cognitive Drift Engine</strong></a>
</p>

---

<p align="center">
  <img src="assets/brand/banner-github.svg" alt="OpenYantra Banner" width="100%"/>
</p>

<p align="center">
  <img src="assets/demo_cross_app_memory.gif" alt="OpenYantra Cross-App Persistent Memory Demo" width="100%"/>
  <br/>
  <em>Capture decisions in Cursor (<code>Cmd+Shift+Y</code>) & git commits → Instant recall in fresh Claude Desktop sessions with strict workspace isolation.</em>
</p>

---

## The Problem -- Why Your AI Forgets (Session Amnesia)

Every time you open a fresh window in **Claude Desktop**, **Cursor**, **ChatGPT**, or terminal coding agents, they wake up with complete amnesia. They don't know yesterday's architecture decisions, active project milestones, or what you were debugging before you shut your laptop. You waste time re-explaining your stack and re-prompting every single day.

When conversation context windows fill up, the AI quietly compresses older messages -- and your active context vanishes mid-task.

### How OpenYantra Compares

Developers often try two extremes: hand-curating a `NOTES.md` file or piping everything to a hosted vector cloud. Here is why both fall short:

| Capability | Hand-Kept `NOTES.md` | Cloud Vector DB (Pinecone / MemGPT SaaS) | **OpenYantra** |
| :--- | :--- | :--- | :--- |
| **Multi-Tool Sync** | ❌ Manual copy-paste; cannot live-sync across Claude Desktop & Cursor simultaneously | ⚠️ Requires proprietary API keys, network latency, and per-tool plugins | ✅ **Zero-effort live sync**: Desktop HUD (`Cmd+Shift+Y`), CLI, and MCP share the exact same local SQLite WAL |
| **Revert / Undo Awareness** | ❌ Static notes ignore git history; stale decisions linger indefinitely | ❌ High risk of context regression (old vector matches resurrect discarded choices) | ✅ **Git Revert Tracking**: Commit reverts automatically tag decisions `[REVERTED / SUPERSEDED]`; Nidra excludes them from beliefs |
| **Secret & Key Safety** | ❌ High risk of committing API tokens into plaintext notes | ❌ API keys and private code snippets stream to third-party cloud servers | ✅ **Raksha Redactor**: Pattern-matches and sanitizes OpenAI, Anthropic, AWS, GitHub tokens before saving |
| **Storage & Data Ownership**| ✅ Local plain text | ❌ Cloud lock-in, recurring monthly SaaS fees, opaque embeddings | ✅ **100% Open & Local**: Standard `.ods` (LibreOffice ISO/IEC 26300), `.sqlite`, and `.md` |
| **Capture Friction** | ❌ High friction -- requires manually switching tabs and updating files | ⚠️ Agent-dependent; no universal OS hotkey | ✅ **Frictionless**: Global hotkey HUD (`Cmd+Shift+Y`), Git post-commit hooks, and MCP tools |
| **Consolidation & Pruning** | ❌ Notes file grows uncontrollably into unreadable clutter | ⚠️ Blind similarity search returns contradictory chunks | ✅ **Nidra Sleep Engine**: Clusters daily sessions, closes open loops, and promotes recurring preferences |

> **💡 Does the Desktop HUD write to the same store the MCP server reads?**  
> **Yes, 100%.** Both the native Desktop HUD (`Cmd+Shift+Y`), the terminal CLI, and the Cognitive MCP Server (serving Cursor & Claude Desktop) connect directly to the same local SQLite database in WAL (Write-Ahead Logging) mode. When you capture a thought or task in the HUD, your next prompt in Cursor or Claude instantly sees it with sub-millisecond read latency.

---

## 💡 Real-World Developer Use Cases

### 1. 🏢 Multi-Repo Freelancer & Ambient Workspace Auto-Detection
**The Problem:** Juggling multiple client repositories and personal open-source projects leads to dangerous context leaks (e.g. an AI agent attempting to apply Client A's AWS infrastructure rules inside Client B's GCP codebase).  
**The OpenYantra Solution:** The Ambient OS Menu Bar (`yantra menubar`) monitors your frontmost code editor in real-time. As you `Cmd+Tab` between Cursor, VS Code, and terminal windows, OpenYantra automatically detects the active repository and re-binds ground truth to that project's isolated `chitrapat.ods`. Zero cross-repo context leaks.

<p align="center">
  <img src="assets/demo_usecase_multirepo.gif" alt="Multi-Repo Ambient Workspace Auto-Detection Demo" width="100%"/>
</p>

---

### 2. 🛡️ Autonomous Coding Agent Loop Guard (Cursor & Claude Code)
**The Problem:** When running autonomous coding tasks across long sessions (e.g. 1-2 hours of refactoring), conversations hit context window limits. Models compress earlier messages, forgetting foundational architectural constraints (e.g. *"Never use SQLite in multi-process mode without WAL"*) and rewriting forbidden files.  
**The OpenYantra Solution:** Start the Transparent Memory Gateway (`yantra proxy`). Point your editor's OpenAI Base URL to `http://127.0.0.1:7332/v1`. OpenYantra uses VidyaKosha's sub-3ms centroid projection to JIT-inject only the exact architectural beliefs and active open loops pertinent to the prompt. During the session, new decisions made by the agent are passively harvested into your `Session Log` with zero model tool calls.

<p align="center">
  <img src="assets/demo_usecase_loop_guard.gif" alt="Autonomous Coding Agent Loop Guard Demo" width="100%"/>
</p>

---

### 3. 🐙 Git-Native Team Memory Mesh & Rollback Guard
**The Problem:** PR descriptions and commit messages get buried; new teammates repeatedly re-try discarded architectural experiments. Furthermore, when an experiment is rolled back via `git revert`, AI agents with stale embeddings keep suggesting the discarded code.  
**The OpenYantra Solution:** OpenYantra's Git post-commit hook (`yantra hook install`) automatically ingests commits into your `Session Log`. When you run `git revert`, OpenYantra automatically detects the rollback and marks the prior decision `[REVERTED / SUPERSEDED]`. With **Mandala v7.0.0**, run `yantra mesh push` and `yantra mesh pull` to synchronize portable memory records (`.openyantra/mesh/mesh.jsonl`) with deterministic cryptographic reconciliation and conflict quarantine.

<p align="center">
  <img src="assets/demo_usecase_git_revert.gif" alt="Git-Native Team Memory Mesh & Revert Guard Demo" width="100%"/>
</p>

---

### 4. 🔒 Zero-Retention Offline Defense & Confidential IP
**The Problem:** Cloud-hosted memory platforms (e.g. Pinecone, cloud SaaS vectors) expose proprietary algorithms, patient health data (HIPAA), or financial models to third-party data breaches and recurring subscription bills.  
**The OpenYantra Solution:** OpenYantra operates 100% offline. All state lives inside your local `chitrapat.ods` (ISO/IEC 26300 standard) and SQLite cache. Raksha automatically strips API keys and credentials before disk writes. Nightly sleep memory consolidation (`yantra dream`) executes on-device using the Apple Silicon Neural Engine (`apple-fm` via `/usr/bin/fm` on macOS 15.1+) or local Ollama—with zero bytes ever sent over the network.

<p align="center">
  <img src="assets/demo_usecase_offline_defense.gif" alt="Zero-Retention Offline Defense Demo" width="100%"/>
</p>

---

## ⚡ What's New in v7.0 ("Mandala: Git-Native Team Memory Mesh & Swarm Soul Matrix")

### 1. 🌐 Git-Native Team Memory Mesh (`yantra mesh` / `yantra push` / `yantra pull`)
Decentralized, peer-to-peer architectural memory sharing directly through your Git repository with zero cloud SaaS lock-in.
- **Repository Mesh Store:** Portable, line-delimited cryptographic records stored at `.openyantra/mesh/mesh.jsonl` and committed directly to Git.
- **Deterministic Cryptographic Reconciliation:** Monotonically merges new non-conflicting team beliefs, tasks, and projects. When divergence occurs, conflicting records are never overwritten blindly -- they are quarantined and routed to `SHEET_CORRECTIONS` with status `Pending` for human review (`yantra corrections`).
- **Cryptographic Mudra Hashes:** Every record carries an immutable SHA-256 digital signature (`mudra:<hash>`) linking content, topic, and author.

### 2. 🎭 Subagent Soul Matrix & Swarm Partitioning (`yantra soul` / `yantra mesh soul`)
Namespace memory partitioning designed specifically for multi-agent coding swarms.
- **Specialized Personas:** Dedicated operational namespaces (`@architect`, `@coder`, `@tester`, `@security`, `@devops`).
- **Context Hygiene:** Partitions task queues and open loops to prevent cross-agent context contamination, hallucinations, and prompt bloating while sharing foundational repository beliefs.
- **CLI Commands:** List personas (`yantra soul --list`), switch active roles (`yantra soul --switch <role>`), check active persona (`yantra soul --current`), or inspect role-filtered working memory (`yantra soul --context`).
- See full documentation in [docs/TEAM_MESH.md](docs/TEAM_MESH.md).

---

## ⚡ What's New in v6.6 ("Nidra-Vichara: Counterfactual Dreaming & Cognitive Drift Engine")

### 1. 💭 Counterfactual Dreaming & Cognitive Drift Engine (`yantra drift` / `yantra resolve`)
Transforms Nidra from an episodic summarizer into an active cognitive guardian defending architectural consistency.
- **Contradiction Matrix Engine:** Performs pairwise semantic contradiction checks across recent session decisions, active tasks, code anchors, and living beliefs (`always` vs `never`, latency SLA budget violations, and core local-first privacy invariants).
- **Counterfactual Failure Simulation:** Evaluates what breaks at runtime if contradictory beliefs coexist, leveraging local Apple Foundation Models (`/usr/bin/fm respond`), Ollama (`llama3.2`), or deterministic heuristic simulators.
- **Morning Briefing Warnings:** Proactively surfaces high-severity cognitive drift alerts during your daily terminal morning briefing (`yantra morning`).
- **Interactive CLI Resolver:** Reconcile contradictions with `yantra resolve` through four deterministic pathways: supersede belief, revert decision, quarantine for review, or dismiss.
- See full documentation in [docs/COGNITIVE_DRIFT.md](docs/COGNITIVE_DRIFT.md).

---

## ⚡ What's New in v6.5 ("Sutra-Baddha: Code-Level Semantic Anchoring")

### 1. ⚓ Code-Level Semantic Anchoring (`yantra anchor`)
Bi-directionally links abstract `.ods` memory rows to exact code symbols (functions, classes, methods) in repositories.
- **In-Code Directives:** Annotate code using `# @yantra:belief(...)`, `// @yantra:loop(...)`, `# @yantra:decision(...)`, or `// @yantra:task(...)`.
- **AST-Aware Symbol Resolution:** Python scanner uses `ast.NodeVisitor` to associate anchors directly with enclosing function and method symbols (`Class.method`). Polyglot regex heuristic supports TypeScript, JavaScript, Rust, Go, C/C++, Java, and SQL.
- **Architectural Drift Guard:** Automatically detects when code depends on a belief that has been marked `SUPERSEDED`, or carries `@yantra:loop(...)` directives for loops that were already marked `RESOLVED`.
- **CI Quality Gate:** Run `yantra anchor check --strict` in CI/CD to prevent orphaned anchors or broken memory links.
- See full documentation in [docs/SEMANTIC_ANCHORS.md](docs/SEMANTIC_ANCHORS.md).

---

## ⚡ What's New in v6.4 ("Samsthana: Ambient OS Menu Bar & Workspace Detection")

### 1. ☸ Ambient OS Menu Bar & Workspace Detection (`yantra menubar`)
Continuous, non-intrusive workspace and repository sensing across **macOS, Linux, and Windows**.
- **Frontmost Window Sensing:** Senses active code editors (VS Code, Cursor, Windsurf, JetBrains) and terminal paths without manual project switching.
- **Dynamic Ground Truth Binding:** Automatically detects local project `.chitrapat.ods` or scopes the global workbook to the active workspace.
- **Mandala System Tray with Notification Badge:** Dynamic icon renders real-time open loop and active task counts.
- **One-Click Cognitive Control:** Instant quick capture note dialog, Desktop HUD trigger (`Cmd+Shift+Y`), Nidra sleep consolidation trigger, and native file manager reveal.
- **Headless Daemon Graceful Fallback:** Automatically switches to headless background watcher mode on remote servers and CI.
- See full documentation in [docs/AMBIENT_MENUBAR.md](docs/AMBIENT_MENUBAR.md).

---

## ⚡ What's New in v6.3 ("Prana: Transparent Memory Gateway")

### 1. ⚡ Transparent Local Memory Gateway (`yantra proxy`)
Zero-friction persistent memory for **Cursor, Claude Code, Cline, Aider, and Windsurf**.
- **No MCP Configuration Needed:** Run `yantra proxy` and set your editor's custom OpenAI Base URL to `http://127.0.0.1:7332/v1`.
- **Just-In-Time (JIT) Context Injection:** Uses VidyaKosha's sub-millisecond zero-retention routing to project prompt centroids and inject only the pertinent architectural decisions, open loops, and tasks directly into the system prompt (< 3ms routing overhead).
- **Passive Decision Harvesting:** OpenYantra listens to turn exchanges asynchronously in the background, automatically logging new architectural choices and tasks to your `Session Log` without model tool calls.
- See full documentation in [docs/GATEWAY.md](docs/GATEWAY.md).

---

## ⚡ What's New in v6.1 & v6.2 (Desktop & Apple Foundation Model)

### 1. 🖥️ OpenYantra Desktop & Floating HUD (`Cmd+Shift+Y`)
No more opening browser tabs. Run `yantra desktop` (or `yantra hud`) to launch an ultra-lightweight native OS HUD (< 15MB binary, zero Electron bloat). Press `Cmd+Shift+Y` to trigger a Raycast/Spotlight-style floating palette directly over Cursor, VS Code, or your terminal.
- **Instant Capture:** Quick-dump notes with `#project`, `@person`, or `!urgent` tags.
- **Instant Recall:** Live fuzzy & semantic search across your entire knowledge base.
- **1-Click Sleep:** Trigger autonomous memory consolidation right from the HUD.

### 2. ⚡ 1-Click MCP Auto-Setup for Claude & Cursor (`yantra mcp setup`)
Zero manual JSON editing. One command auto-detects Claude Desktop and Cursor configurations across macOS, Windows, and Linux, creates a backup, and installs the OpenYantra MCP server seamlessly.

### 3. 🌙 Autonomous Sleep & Memory Consolidation (Nidra)
Mimics biological slow-wave sleep. Run `yantra dream` or `yantra consolidate`:
- **Episodic Clustering:** Clusters recent session logs into macro-milestones and decisions.
- **Open Loop Auto-Resolution:** Automatically identifies and closes loops resolved during work.
- **Preference Promotion:** Promotes recurring user preferences (e.g., *"prefers dark mode"*, *"always use python 3.9"*) into foundational `Beliefs & Principles`.
- **🍎 Native Apple Foundation Model (AFM) on macOS:** On Apple Silicon Macs running macOS Sequoia (15.1+), OpenYantra automatically detects and uses the built-in system Foundation Model (`/usr/bin/fm`) executing on the **Apple Neural Engine (ANE)**. Zero setup, zero downloads (0 MB extra disk), sub-50ms latency, and zero private RAM bloat.
- **🎛️ User-Controlled Inference & Opt-Out:** Switch models or opt out anytime via CLI (`--provider apple-fm|ollama|heuristic`) or environment variable (`export OPENYANTRA_NIDRA_PROVIDER=ollama`).
- **🦙 Ollama & Heuristic Fallbacks:** On Linux/Windows or when AFM is unavailable/unlicensed, seamlessly cascades to local Ollama (`llama3`, `mistral`) or deterministic rule-based heuristics with zero cloud dependency.

### 4. 📓 Bi-Directional Obsidian Vault Sync (`yantra vault sync`)
- **Export:** Translates your Chitrapat into clean Obsidian Markdown notes with YAML frontmatter, wikilinks (`[[Projects/X]]`), and task checklists.
- **Import:** Check off an item (`- [x]`) in Obsidian, and OpenYantra resolves it in the ledger. Add notes in `Inbox.md`, and they are enqueued into your memory bank.

### 5. 🛡️ Raksha Credential & Secret Redactor Guard
Pre-commit interceptor pattern-matches and redacts Anthropic, OpenAI, AWS, GitHub, Google API keys, Slack tokens, and private keys before committing any record to disk.

### 6. 🐙 Git Commit Auto-Ingest & Revert Detection (`yantra hook install`)
Install a git post-commit hook in your repositories. Every time you commit code, OpenYantra automatically extracts the commit hash, branch, message, and modified files into your `Session Log`. If you revert a commit (`git revert`), OpenYantra automatically detects the rollback, tags the prior decision as `[REVERTED / SUPERSEDED]`, and ensures the Nidra sleep engine never promotes undone code experiments into your core architecture beliefs.

### 7. 📟 Cyberpunk Terminal TUI (`yantra tui`)
For command-line purists and SSH workflows. An interactive terminal dashboard displaying live open loops, active projects, recent decisions, and quick-capture hotkeys.

### 8. 🔌 Drop-in Framework Adapters
First-class Python bindings for:
- **LangChain:** `OpenYantraChatMessageHistory`, `OpenYantraRetriever`
- **CrewAI:** `OpenYantraCrewMemory` for multi-agent autonomous teams

### 9. ⚡ Sub-Millisecond Zero-Retention Routing (`yantra route`)
Apical Arbor hierarchical routing layer. Projects single-turn prompt embeddings against precomputed sheet centroids to activate only the minimal memory subspace needed for the turn:
- Cuts prompt token bloat by **-51.9%** in **5.4ms** with **100.0% precision**.
- Retains zero conversational prompt state.
- Exposes pluggable hook (`VidyaKosha.set_external_router()`) for external low-latency routers (such as Plexus / Apical Arbor).

### 10. 👁️ Autonomous Soul-Engine Background Daemon (`yantra dream --daemon`)
A detached background process that monitors the Chitrapat for quiet periods following conversational writes. When inactivity settles (`inactivity >= idle_threshold`), it automatically executes offline sleep consolidation, prunes expired loops (TTL), promotes repeated preferences into foundational beliefs, and reconciles SQLite WAL tables without blocking active conversation interactivity.

---

## ⚡ Routing & Latency Benchmarks

Tested across realistic multi-sheet memory vaults (50+ entries across 8 active sheets):

| Evaluation Metric | Baseline (Full Unpruned) | Zero-Retention Subspace Router | Hybrid FAISS+BM25 |
| :--- | :--- | :--- | :--- |
| **Average Latency** | 477.02 ms | **5.435 ms** | 4.48 ms |
| **Prompt Token Size** | 459 tokens | **221 tokens** | N/A (Row Hits) |
| **Token Reduction** | 0.0% | **-51.9%** | N/A |
| **Target Precision** | N/A | **100.0%** | N/A |

Run the benchmark suite yourself at any time:
```bash
python -m benchmarks.benchmark_routing
```

---

## 🚀 Install in One Command

### macOS / Linux:
```bash
curl -sSL https://raw.githubusercontent.com/revanthlevaka/OpenYantra/main/install.sh | bash
```

### Windows (PowerShell):
```powershell
irm https://raw.githubusercontent.com/revanthlevaka/OpenYantra/main/install.ps1 | iex
```

### Python Package (Pip):
```bash
git clone https://github.com/revanthlevaka/OpenYantra.git
cd OpenYantra
pip install -e ".[full]"
```

---

## 🛠️ Quickstart Workflow

```bash
# 1. Initialize your personal memory vault (12-question bootstrap interview)
yantra bootstrap

# 2. Configure Claude Desktop & Cursor with 1 click
yantra mcp setup

# 3. Launch the native Desktop HUD (or press Cmd+Shift+Y)
yantra desktop

# 4. View your Morning Brief in the terminal
yantra morning

# 5. Quick capture thoughts, tasks, or loops
yantra inbox "Follow up with Priya regarding the distributed consensus paper"

# 6. Run autonomous sleep consolidation at the end of the day
yantra dream

# 7. Sync with your Obsidian Vault
yantra vault sync ~/my_vault

# 8. Launch the Cyberpunk Terminal TUI
yantra tui
```

---

## 🧭 CLI Command Cheatsheet

| Command | Action |
| :--- | :--- |
| `yantra anchor [scan\|trace\|check]` | Code-level semantic anchoring and AST memory linking (`@yantra`) |
| `yantra drift [scan]` | Scan codebase and recent sessions for cognitive contradictions and drift |
| `yantra resolve` | Interactive contradiction and cognitive drift reconciliation wizard |
| `yantra bootstrap` | Interactive 12-question interview to build your Chitrapat vault |
| `yantra menubar` | Start Ambient OS Menu Bar & Workspace Tracker (`yantra ambient` / `yantra tray`) |
| `yantra proxy` | Start Transparent Local Memory Gateway (`:7332`) for Cursor / Claude Code / Cline |
| `yantra desktop` | Launch native Desktop App & floating HUD palette (`yantra app` / `yantra hud`) |
| `yantra tui` | Open interactive Cyberpunk Terminal TUI |
| `yantra mcp setup` | Auto-configure Claude Desktop and Cursor MCP settings |
| `yantra mcp serve` | Run the standard MCP JSON-RPC server on stdin/stdout |
| `yantra dream` | Run autonomous Nidra memory consolidation (`yantra consolidate`) |
| `yantra dream --daemon` | Run autonomous background soul-engine daemon (`yantra nidra -d`) |
| `yantra route "<prompt>"` | Test sub-millisecond zero-retention memory subspace routing |
| `yantra vault sync [dir]`| Bi-directional sync with Obsidian Markdown vault (`export` / `import`) |
| `yantra hook install` | Install Git post-commit auto-ingest hook in current repo |
| `yantra morning` | Display your daily briefing, streak, and active open loops |
| `yantra context [--project P]` | Compile dynamic context (optionally workspace-scoped) to clipboard |
| `yantra loops` | List and filter unresolved open loops |
| `yantra health` | Run complete database integrity and health diagnostics |
| `yantra doctor` | Verify system environment, SQLite WAL, and vector embedders |
| `yantra ui [--port 7331]` | Launch the browser-based executive memory dashboard |

---

## 🏛️ System Architecture

```
┌────────────────────────────────────────────────────────────────────────┐
│                        OPENYANTRA UNIFIED ARCHITECTURE                 │
└────────────────────────────────────────────────────────────────────────┘

  [Omnipresent Inputs]
    ├── Desktop HUD (Cmd+Shift+Y)  ────► [FastAPI Local REST Engine]
    ├── System Tray Daemon         ────► [Port 7331 / Unix Socket]
    ├── Git Post-Commit Hook       ────►          │
    ├── CLI & Cyberpunk TUI        ────►          │
    └── IDE / Cursor MCP Client    ────► [Cognitive MCP JSON-RPC]
                                                  │
                                                  ▼
                                     ┌─────────────────────────┐
                                     │  Raksha Redactor Guard  │ (Sanitizes keys & secrets)
                                     └────────────┬────────────┘
                                                  │
                                                  ▼
                                     ┌─────────────────────────┐
                                     │ Chitragupta SyncEngine  │ (Single-writer coordinator)
                                     └────────────┬────────────┘
                                                  │
                  ┌───────────────────────────────┴──────────────────────────────┐
                  ▼                                                              ▼
        [SQLite WAL Engine]                                            [Canonical Life Scroll]
       • < 2ms write latency                                          • `chitrapat.ods`
       • Sutradhar Graph Edges                                        • ISO/IEC 26300 Open Document
       • VidyaKosha Vector Index                                      • LibreOffice Human-Readable
                  │                                                              │
                  ▼                                                              ▼
       [Nidra Sleep Engine]                                           [Obsidian Vault Sync]
       • Episodic log clustering                                      • Markdown with YAML frontmatter
       • Open Loop auto-pruning                                       • Checkbox bidirectional resolution
       • Preference to belief promotion                               • Wikilinks [[Projects/X]]
```

---

## 📜 The 14 Sacred Memory Sheets

OpenYantra stores your life context across 14 dedicated sheets in `chitrapat.ods`:

| Sheet | Sanskrit | What it Stores |
|---|---|---|
| 👤 Identity | Svarupa | Persona, occupation, communication style, location |
| 🎯 Goals | Sankalpa | Long and short-term aims with success metrics |
| 🚀 Projects | Karma | Active work -- domain, status, next concrete step |
| 👥 People | Sambandha | Collaborators, relationship context, open threads |
| 💡 Preferences | Ruchi | Tools, habits, rules, anti-goals |
| 🧠 Beliefs | Vishwas | Values, worldview, epistemic evolution history |
| ✅ Tasks | Kartavya | Action items linked to projects with priorities |
| 🔓 Open Loops ★ | Anishtha | Unresolved threads (Zeigarnik Effect safety net) |
| 📅 Session Log | Dinacharya | Chronological episodic summaries & git commits |
| ⚙️ Agent Config | Niyama | Per-agent behavioral guidelines and trust tiers |
| 📒 Agrasandhanī | -- | Immutable ledger -- every write SHA-256 signed |
| 📥 Inbox | Avagraha | Quick capture dumping ground -- routed later |
| ✏️ Corrections | Sanshodhan | Agent-proposed edits pending human approval |
| 🔒 Quarantine | Nirodh | Blocked prompt injections and quarantined inputs |

---

## 🧪 Verification & Test Suite

OpenYantra maintains a rigorous test suite covering security, vector search, passkey authentication, MCP configuration, Nidra consolidation, and desktop HUD endpoints:

```bash
pytest tests/
```
```
============================= test session starts ==============================
platform darwin -- Python 3.9.6, pytest-8.4.2, pluggy-1.6.0
rootdir: /Users/revanthlevaka/openyantra
configfile: pyproject.toml

tests/test_adapters.py ...                                               [  4%]
tests/test_bootstrap.py ...                                              [  8%]
tests/test_cognitive.py .......                                          [ 19%]
tests/test_desktop.py ..                                                 [ 22%]
tests/test_git_hook.py ...                                               [ 26%]
tests/test_mcp_setup.py ...                                              [ 30%]
tests/test_nidra.py ....                                                 [ 36%]
tests/test_passkey.py .....                                              [ 44%]
tests/test_security_sanitizer.py ......                                  [ 52%]
tests/test_setu.py ....                                                  [ 58%]
tests/test_sutra.py ....                                                 [ 64%]
tests/test_sutradhar.py ...............                                  [ 86%]
tests/test_tui.py .                                                      [ 88%]
tests/test_ui_api.py .....                                               [ 95%]
tests/test_vault.py ...                                                  [100%]

================== 68 passed, 4 warnings in 96.69s (0:01:36) ===================
```

---

## 📸 Screenshots & Visual Experience

### ⚡ Core Ingestion & Transparent Memory Gateway (v7.0.0)
| Memory Gateway Proxy (:7332/v1) & JIT Routing | Ambient OS Menubar & Workspace Sensor |
|:---:|:---:|
| <img src="assets/screenshots/screenshot_gateway.svg" alt="Memory Gateway Proxy" width="100%"/> | <img src="assets/screenshots/screenshot_menubar.svg" alt="Ambient OS Menubar" width="100%"/> |

### 🧬 Code Anchoring & Cognitive Drift Engine (v7.0.0)
| Code-Level Semantic Anchors (`@yantra`) | Cognitive Drift & Counterfactual Dreaming |
|:---:|:---:|
| <img src="assets/screenshots/screenshot_anchors.svg" alt="Code Anchors Inspector" width="100%"/> | <img src="assets/screenshots/screenshot_drift.svg" alt="Cognitive Drift Engine" width="100%"/> |

### 🌐 Team Memory Mesh & Desktop HUD (v7.0.0)
| Team Memory Mesh & Soul Matrix Swarm | Floating HUD Palette (`Cmd+Shift+Y`) |
|:---:|:---:|
| <img src="assets/screenshots/screenshot_mesh.svg" alt="Team Memory Mesh & Soul Matrix" width="100%"/> | <img src="assets/screenshots/screenshot_desktop_hud.svg" alt="Desktop HUD Palette" width="100%"/> |

### 🖥️ Briefing Room Dashboard & Terminal TUI
| Today Command Centre | Live Web Dashboard (`:7331`) |
|:---:|:---:|
| <img src="assets/screenshots/screenshot_today.svg" alt="Today Tab" width="100%"/> | <img src="assets/screenshots/screenshot_webui.svg" alt="Web UI" width="100%"/> |

| Terminal Cyberpunk TUI | Open Loops (Anishtha Engine) |
|:---:|:---:|
| <img src="assets/screenshots/screenshot_cli.svg" alt="CLI TUI" width="100%"/> | <img src="assets/screenshots/screenshot_loops.svg" alt="Loops" width="100%"/> |

| System Architecture (Invariants) | Security Engine (Raksha Threat Redactor) |
|:---:|:---:|
| <img src="assets/screenshots/screenshot_architecture.svg" alt="System Architecture" width="100%"/> | <img src="assets/screenshots/screenshot_security.svg" alt="Security Engine" width="100%"/> |

---

## ⚖️ How OpenYantra Compares

| Dimension / Capability | Living Brain (`livingbrain.com`) | Mem0 / Zep | **OpenYantra (v7.0)** |
| :--- | :---: | :---: | :---: |
| **Hosting Model** | Proprietary Cloud SaaS | Cloud SaaS / Complex Self-Host | **100% Local-First / Zero Cloud** |
| **Data Sovereignty & Privacy** | Third-party cloud servers | Third-party cloud servers | **Your device only (Offline SQLite & ODS)** |
| **Human Editability & Transparency**| API / Closed web dashboard | Closed JSON / Vector embeddings | **Open spreadsheet (`.ods`), Obsidian Markdown** |
| **Desktop Ergonomics** | Browser dashboard | Browser dashboard | **Floating HUD (`Cmd+Shift+Y`), Cyberpunk TUI** |
| **Secret & Credential Redactor** | ❌ (Raw context sent over wire) | ❌ (Requires manual masking) | **✅ Raksha automatic regex sanitizer** |
| **Sleep & Memory Consolidation** | Cloud background job | ⚠️ Basic clustering | **✅ Native Apple Foundation Model (ANE) / Local Ollama / Heuristics** |
| **Obsidian Vault Sync** | ❌ None | ❌ None | **✅ Bi-directional Markdown & `- [x]` sync** |
| **1-Click MCP Setup** | ⚠️ Manual config | ⚠️ Manual config | **✅ Auto-injects Claude & Cursor JSON** |
| **Vendor Lock-in & Pricing** | Monthly SaaS Subscription | Metered API Pricing | **100% Free & Open Source (MIT / CC0)** |

---

## 🕉️ Mythology & Philosophy

Named in honour of **Chitragupta** (चित्रगुप्त) -- the Hindu God of Data and divine scribe who maintains the complete ledger of every deed without prejudice or omission.

The architecture mirrors this philosophy precisely:
- **Single Trusted Recorder:** Only Chitragupta may commit records to the ledger.
- **Dharma-Adesh:** The user's righteous command always wins over agent assumptions.
- **Anishtha:** Unfinished intent is preserved across context boundaries.
- **Mudra:** Every write is permanently sealed with a SHA-256 digital signature.

*The record exists to serve the remembered, not the recorder.*

---

## 💛 Support OpenYantra

OpenYantra is free, local-first and open source. If it saves you time, you can support its development through [GitHub Sponsors](https://github.com/sponsors/revanthlevaka) with monthly or one-time tiers. Sponsors are listed in [SPONSORS.md](SPONSORS.md).

Prefer to support with compute credits (for example Claude or Cursor credits)? Reach out through the contact details on my [GitHub profile](https://github.com/revanthlevaka).

## 📄 License & Community

- **Protocol Specification:** [CC0 1.0 Universal](PROTOCOL.md) (Public Domain)
- **Software Library:** [MIT License](LICENSE)
- **Author:** [Revanth Levaka](https://github.com/revanthlevaka)

---
<p align="center">
  <em>OpenYantra -- Open formats only. Zero lock-in. Sovereign AI memory for everyone.</em>
</p>