How krshirkoohi/tana-context-mask works
Tana Semantic Engine mirrors a Tana workspace and turns natural-language tasks into grounded context packets for AI clients. The main workflow is context acquisition: hybrid semantic/lexical and temporal retrieval finds seed notes, graph expansion adds structural evidence, reranking selects useful nodes, and the system returns formatted context with citations and provenance. Search, node inspection, synchronization, and MCP access are also product capabilities. The repository contains self-hosted Python and Cloudflare Worker implementations; sampled excerpts do not expose all orchestration details, so uncertain internal links are omitted.
Main entry points: index.ts Worker Gateway · context_builder.py Context Builder · semantic_search.py Semantic Search · server.py REST API
Components 24
Client Interfaces
- REST API
tana_context_mask/api/server.py - MCP Server
tana_context_mask/api/mcp_server.py - CLI
tana_context_mask/cli/main.py
Context Acquisition
- Context Builder
tana_context_mask/engine/context_builder.py - Context Packet
tana_context_mask/models/context.py
Retrieval And Graph
- Semantic Search
tana_context_mask/engine/semantic_search.py - Graph Expansion
tana_context_mask/engine/graph_engine.py - Reranker
tana_context_mask/engine/reranker.py - Temporal Routing
tana_context_mask/engine/temporal.py
Workspace Mirror
- SQLite Mirror
tana_context_mask/storage/db.py - Vector Store
tana_context_mask/storage/vector_store.py - Mirror Sync
tana_context_mask/sync/mirror_engine.py - Tana MCP Client
tana_context_mask/client/tana_mcp_client.py
Cloudflare Runtime
- Worker Gateway
worker/src/index.ts - Hybrid Search
worker/src/services/search.ts - D1 Graph Store
worker/src/services/graph.ts - Edge Reranker
worker/src/services/reranker.ts - Edge Sync
worker/src/services/sync.ts - Remote MCP
worker/src/services/mcp.ts
Other components
- AI Client
- Tana Workspace
- Cloudflare D1
- Vectorize
- Workers AI
Connections 36
- AI Client → REST API: requests context
- AI Client → MCP Server: uses MCP
- AI Client → Worker Gateway: calls gateway
- CLI → Context Builder: acquires context
- CLI → Semantic Search: searches
- CLI → Mirror Sync: starts sync
- REST API → Context Builder: acquires context
- REST API → Semantic Search: searches
- REST API → Graph Expansion: inspects nodes
- REST API → Mirror Sync: starts sync
- Context Builder → Semantic Search: retrieves seeds
- Context Builder → Graph Expansion: expands graph
- Context Builder → Reranker: ranks candidates
- Context Builder → Context Packet: formats result
- Semantic Search → SQLite Mirror: reads candidates
- Semantic Search → Vector Store: queries vectors
- Semantic Search → Temporal Routing: scores dates
- Graph Expansion → SQLite Mirror: reads relations
- Mirror Sync → Tana MCP Client: requests workspace data
- Mirror Sync → SQLite Mirror: writes mirror
- Mirror Sync → Vector Store: updates embeddings
- Tana MCP Client → Tana Workspace: calls Remote MCP
- Worker Gateway → Remote MCP: dispatches MCP
- Worker Gateway → Hybrid Search: runs retrieval
- Worker Gateway → D1 Graph Store: expands context
- Worker Gateway → Edge Reranker: reranks candidates
- Worker Gateway → Edge Sync: dispatches sync
- Hybrid Search → D1 Graph Store: loads nodes
- Hybrid Search → Cloudflare D1: queries lexical index
- Hybrid Search → Vectorize: searches vectors
- Hybrid Search → Workers AI: embeds query
- D1 Graph Store → Cloudflare D1: reads graph
- Remote MCP → Tana Workspace: calls Remote MCP
- Edge Sync → Tana Workspace: syncs workspace
- Edge Sync → Cloudflare D1: updates mirror
- Edge Sync → Vectorize: updates vectors