Architectural Knowledge Graph & Index¶
Eidos features a built-in, zero-dependency Architectural Knowledge Graph Index powered by an embedded SQLite database (eidos/.cache/index.db) with full-text search (FTS5) and recursive graph traversals (Common Table Expressions).
The index enables sub-3ms architectural queries, intelligent full-text specification discovery, transitive blast-radius analysis, and token-budgeted 3-tier context slicing for AI coding agents.
┌────────────────────────────────────────────────────────┐
│ Living Specs (eidos/) + Polyglot Code & Tests │
└───────────────────────────┬────────────────────────────┘
│ Incremental Dirty Check (mtime_ns + SHA-256, <5ms)
▼
┌────────────────────────────────────────────────────────┐
│ Embedded SQLite Knowledge Graph (eidos/.cache) │
│ ├── entities (CNT, CMP, CTR, CAP, DOM, POL, INV, …) │
│ ├── edges (realizes, provides, consumes_api, …) │
│ ├── indexed_files (mtime, sha256, doc_id tracking) │
│ ├── symbol_mappings & code_symbols (AST coordinates) │
│ ├── spec_validation_cache, test_binding_cache, │
│ │ file_tokens_fts & metadata │
│ └── specs_fts (SQLite FTS5 virtual table with BM25) │
└───────────────┬────────────────────────┬───────────────┘
│ │
CLI Commands Agent Skill (eidos/)
eidos index repo-map SKILL.md
eidos index find-symbol references/setup.md
eidos context --tier anchor references/spec.md
eidos index status references/plan.md
eidos index search references/ops.md
eidos index blast-radius references/memory.md
Zero External Database Dependencies¶
The architectural index requires zero external database daemons and zero third-party vector stores:
- Built on Python's standard library
sqlite3in WAL (Write-Ahead Logging) mode, utilizing native SQLite 3.x FTS5 and recursive Common Table Expressions (CTEs). - Decomposed across 9 disjoint C4 Level 3 components in
src/eidos/core/index/:CMP-GRAPH-STORAGE(storage.py,graph_index.py),CMP-INCREMENTAL-SYNC-ENGINE(sync.py,code_graph.py,spec_edges.py),CMP-FTS-QUERY-ENGINE(fts_query.py),CMP-GRAPH-TRAVERSAL-ENGINE(traversal.py),CMP-TIERED-CONTEXT-COMPRESSOR(context.py,context_globs.py,context_models.py,context_memories.py),CMP-SEMANTIC-EMBEDDING-ENGINE(semantic.py),CMP-AST-SYMBOL-INDEXER(ast_indexer.py,ast_preprocess.py,ast_imports.py,ast_php.py),CMP-HTTP-TOPOLOGY-LINKER(ast_http.py,http_linker.py), andCMP-AST-DIFF-CLASSIFIER(ast_diff.py). - Stores all relational graph data, epistemic
edges.provenance+file:lineevidence, per-call-sitecode_couplings, AST symbol coordinates, inverted file token FTS tables, optional ONNX semantic embeddings, and validation/test/public-surface/Mermaid/memory-freshness caches inside a single self-contained, 100% stateless derived file:eidos/.cache/index.db(canonicalSCHEMA_VERSION = "2.24.0"). - Automatically performs atomic
BEGIN IMMEDIATEdrop-and-rebuild migration onSCHEMA_VERSIONupgrades—preserving content-addressedspec_embeddings(andsemantic_sync_complete) across botheidos index sync --forceand unrelatedSCHEMA_VERSIONupgrades wheneverEMBEDDING_SCHEMA_VERSIONand column schema match, while rebuilding cleanly onEMBEDDING_SCHEMA_VERSIONbumps or database corruption. - The
eidos/.cache/directory is isolated viaeidos/.gitignore, keeping Git repositories pristine.
Automatic Initialization & Lazy Synchronization¶
You never need to remember to run a manual build command before querying.
1. Automatic On-Demand Bootstrapping¶
The first time any command requiring architectural context is invoked (eidos context, eidos index, eidos spec list, or agent skills), Eidos automatically:
1. Creates eidos/.cache/ if it does not exist.
2. Initializes the 15 SQLite tables (entities, edges, code_couplings, indexed_files, symbol_mappings, code_symbols, spec_validation_cache, test_binding_cache, public_surface_cache, mermaid_validation_cache, memory_freshness_cache, spec_embeddings, specs_fts, file_tokens_fts, and metadata).
3. Indexes all living specifications, AST code symbols (including http_endpoint and http_request symbols), governed file tokens, and test bindings in ~100ms.
2. Zero-Drift Freshness (_ensure_synced)¶
Before answering any query, search, or context extraction request, the index runs a lazy two-tier freshness check (check_index_dirty()):
* Compares nanosecond file modification timestamps (mtime_ns) against indexed_files across eidos/, tests/, and every container/component's declared source_path.
* If mtime_ns changed, computes the file's SHA-256 digest; if the content hash is unchanged, refreshes mtime_ns in-place without re-parsing.
* Executes in <5ms on clean working trees.
* If any .adoc spec, source file, or test file was edited, added, or deleted (or if a specification ID was renamed in-place), Eidos evicts stale entities by the previous doc_id stored in indexed_files and incrementally re-indexes only the modified files.
Manual Index Management¶
While synchronization is completely automatic, developers and CI/CD pipelines can inspect or manage the index directly via the CLI:
Inspect Index Status & AST Telemetry¶
View database size, schema version, health, total entities, edges, indexed files, AST parser engine telemetry, symbol breakdown by syntax kind, and test invariant assertions:
# Rich visual panel and tables:
eidos index status
# Machine-readable JSON output for AI agent tool calling:
eidos index status --json
Output:
╭───────────────── Eidos Architectural Knowledge Graph Index ──────────────────╮
│ Database Path: /path/to/project/eidos/.cache/index.db │
│ Schema Version: 2.19.0 │
│ Cache Size: 5308.0 KB │
│ Status: SYNCED (Clean) (1.76ms check) │
│ Total Entities: 208 │
│ Total Edges: 811 │
│ Indexed Files: 312 │
│ AST Engine: ast-grep (Native AST) │
│ AST Symbols: 1227 (49 classes, 374 funcs, 361 methods, 59 test │
│ bindings) │
│ Invariant Assertions: 113 assertions across 45 invariants │
╰──────────────────────────────────────────────────────────────────────────────╯
Entities by Type
┏━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━┓
┃ Type ┃ Count ┃
┡━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━┩
│ delta/mutation │ 108 │
│ invariant │ 45 │
│ product/capability │ 8 │
│ tech/container │ 7 │
│ ... │ ... │
└─────────────────────┴───────┘
AST Code Symbols &
Traceability
┏━━━━━━━━━━━━━━━━━━━━┳━━━━━━━┓
┃ Syntax Kind ┃ Count ┃
┡━━━━━━━━━━━━━━━━━━━━╇━━━━━━━┩
│ class │ 49 │
│ function │ 374 │
│ method │ 361 │
│ test_binding │ 59 │
│ ... │ ... │
└────────────────────┴───────┘
Force Index Rebuild¶
To force a clean rebuild of the SQLite database and FTS5 search index:
The 3-Tier Architectural Context Model¶
When AI agents work on software engineering tasks, providing entire specification files consumes excessive context window tokens and dilutes model attention. Eidos introduces a rank-ordered, token-budgeted 3-tier compression model enforced across both Markdown and JSON outputs:
| Tier | Flag / Param | Token Budget Ceiling | Typical Size | Content Included | Recommended Use Case |
|---|---|---|---|---|---|
| Tier 1: Anchor | --tier anchor |
<= 300 tokens |
~140 tokens | Owning CNT-* / CMP-*, container type, runtime, source_path, bound domain, direct CTR-* signatures, compact 1-line DEC-* decision summaries. |
Fast, single-file edits, routine bug fixes, syntax changes. |
| Tier 2: Guardrails (Default) | --tier guardrails |
<= 1,000 tokens |
~300–900 tokens | Anchor content + domain capabilities (CAP-*), active invariants (INV-*) with test_binding, governing policies (POL-*), and full DEC-* rationale + rejected alternatives. |
Standard feature development, refactorings, policy verification. |
| Tier 3: Deep | --tier deep |
<= 2,500 tokens |
~500–1,500 tokens | Guardrails content + C4 Level 3 standalone component details, contract schemas, and downstream dependents. | Complex multi-module features, architecture reviews, SpecDeltas. |
CLI Usage:¶
# Lightweight anchor context
eidos context -c CNT-EIDOS-CORE --tier anchor
# Default guardrails with invariants, policies, and decisions
eidos context -f src/eidos/cli/main.py --tier guardrails
# Deep architectural context including C4 internal building blocks
eidos context -c CNT-EIDOS-CORE --tier deep
# Slice context from a natural-language task prompt
eidos context -t "rate limiting and token expiration" --tier guardrails --json
Architectural Search & Blast-Radius Analysis¶
Full-Text Architectural Search (BM25)¶
Quickly discover containers, components, contracts, capabilities, and invariants matching concepts, requirements, or keywords:
Output:
Architectural Search Results for 'FTS5' (4 matches)
┏━━━━━━━┳━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┓
┃ Rank ┃ Entity ID ┃ Type ┃ Title ┃ Domain ┃
┡━━━━━━━╇━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━┩
│ -2.79 │ EXP-2026-002 │ product/explor… │ Embedded Graph │ — │
│ -2.78 │ DLT-2026-011 │ delta/mutation │ Integrate Graph │ — │
│ -2.21 │ CNT-EIDOS-CORE │ tech/container │ Core Engine │ DOM-SPEC-ENGINE │
│ -0.83 │ CTR-EIDOS-CLI │ tech/contract │ CLI Contract │ — │
└───────┴────────────────┴─────────────────┴─────────────────┴─────────────────┘
How lexical retrieval works (INV-AGENT-TASK-RETRIEVAL-COVERAGE):
- Every entity & code symbol is searchable (
DLT-2026-078,DLT-2026-106): child invariants (INV-*) across capabilities (CAP-*), policies (POL-*), containers (CNT-*), and standalone components (CMP-*) get their ownspecs_ftsrow (rule text, parent title, test binding), embeddedDEC-*decisions are indexed alongside their owning container or component, and primary ASTcode_symbols(class,function,interface,struct,enum) are projected directly intospecs_fts.symbols(while archived SpecDeltas undereidos/deltas/archive/are excluded fromspecs_ftsto keep search results focused on active architecture and recent changes). - Identifier de-compounding & Two-Tier FTS Precision (
DLT-2026-083):camelCase/snake_caseidentifiers are split on both index and query sides —ArchitecturalIndexis indexed asarchitectural indextoo, and multi-word queries prioritize high-precision multi-termANDconjunction matches before falling back toORexpansion. - Column-weighted BM25: Positional weights
(0, 4, 2, 1, 2, 2)ranktitle(4) >jtbd_or_rule/keywords/symbols(2) >body_text(1), with0assigned to theUNINDEXEDentity_idplaceholder column. - Deterministic Architectural Synonym Expansion & Opt-In Hybrid RRF (
DLT-2026-115): Zero-keyword-overlap conceptual queries expand through deterministic architectural synonyms (expand_architectural_synonyms) and, when the optional local Harrier-OSS-v1-0.6B ONNX semantic index (eidos-ai[semantic], provisioned viaeidos index semantic setupandeidos index semantic sync) is present, fuse FTS5 BM25 with cosine-gated (tau_min = 0.35) semantic similarity via Weighted Reciprocal Rank Fusion (w_lex = 1.0,w_sem = 0.85,k_0 = 60) using thests_queryprompt prefix ("Instruct: Retrieve semantically similar text\nQuery: "). Exact entity ID pinning and 100% deterministic fallback to FTS5 BM25 (--no-semanticor whenspec_embeddingsis empty) are preserved (INV-AGENT-HYBRID-SEMANTIC-FALLBACK). - Slice-scoped candidates, Calibrated Token Budgets & Honest Empty Slices:
eidos context --taskfilters sliceable types (containers, components, contracts, capabilities, policies, invariants, domains, design systems) inside SQL beforeLIMIT, so historical SpecDeltas and explorations never consume top-k slots. Direct container hits are prioritized ahead of 1-hop domain/design-system container expansions (INV-AGENT-TASK-RETRIEVAL-COVERAGE). Token budgets are enforced using structure-calibrated token estimation (~3chars/token for YAML/JSON/code/paths vs~4chars/token for prose). If an explicit query matches zero entities, Eidos returns an honest empty slice rather than injecting unrelated alphabetical fallbacks.
Blast-Radius Impact Analysis & Epistemic Provenance Filtering¶
Before modifying an interface, container, component, symbol, or file, compute the transitive blast radius using delimiter-anchored, hub-scoped recursive CTE graph traversals (DLT-2026-114, DLT-2026-137):
eidos index blast-radius CNT-EIDOS-CORE --depth 2
# Filter edges to observed specs + derived AST/HTTP couplings (excluding inferred ownership):
eidos index blast-radius CNT-EIDOS-CORE --depth 2 --min-confidence derived
# Or pass an AST code symbol, specification path, or source file path directly:
eidos index blast-radius detect_drift --depth 2
eidos index blast-radius src/eidos/vcs/drift.py --depth 2
Every edge in edges carries an explicit epistemic provenance tag governed by precedence upserts (declared_spec > ast_import > ast_http > ast_symbol > inferred_ownership) and mapped to 3-tier confidence (observed, derived, inferred), alongside a code_couplings table preserving every individual ast_import and ast_http call site. resolve_blast_radius_targets resolves canonical entity IDs, .adoc specification paths, source file paths, and AST code symbols (class, function, method, interface, struct, enum, http_endpoint, http_request), filtering multi-match symbol/path resolutions to tech/component (CMP-*) seeds at depth = 0 so ancestor CNT-* containers and shared CTR-* contracts appear at their true 1-hop distance.
Polyglot AST Code Indexing, Static HTTP Auto-Linking & Code Graph¶
In addition to living specifications (eidos/*.adoc), Eidos indexes source code and test suites across polyglot projects using structural Abstract Syntax Trees (AST):
- Unified 17-Language
AstGrepIndexer(DLT-2026-096): Powered by core dependencyast-grep-py(SgRoot), providing unified Tree-sitter AST symbol, import (extract_imports), HTTP endpoint/request (extract_http_endpoints,extract_http_requests), and signature extraction across 17 languages: Python (.py), TypeScript (.ts), TSX (.tsx), JavaScript (.js), JSX (.jsx), Go (.go, includingtype_specand receiver methods), Rust (.rs), Java (.java), Kotlin (.kt,.kts), C (.c), C++ (.cpp,.h,.hpp), C# (.cs), Ruby (.rb), PHP (.php), Swift (.swift), Vue (.vue), and Svelte (.svelte). - Static Frontend-to-Backend HTTP Auto-Linking (
ast_http,POL-ZERO-AI-CALL-DEPENDENCY): Extracts serverhttp_endpointroutes across FastAPI/Flask/Starlette, Express/Fastify/Hono/Koa/NestJS/Next.js App Router, Go, Rust (axum,actix-web), Spring, and ASP.NET Core, and links non-test (is_test = 0) clienthttp_requestcalls (fetch,EventSource,axios,ky, Angularthis.http, Pythonrequests/httpx) to backend endpoints andopenapi/rest_httpCTR-*contracts (complementing Eidos's 17-value canonicaltech/contractparity acrosscode_interface,wsdl,avro,sql_ddl,trpc,websocket,mcp, polyglotcli_args, OpenAPI 3.1webhooks, and bidirectionaljson_schema$defsparity) by normalizing dynamic parameters (:id,{id},<int:id>,[id],${expr}) to{*}. - Persisted Symbol Coordinates (
code_symbols) & AST-Derived Dependencies: Extracts classes, structs, enums, interfaces, functions, and methods with exactline_start,line_end, decorator-prefixed signatures, and primary owner flags, mapping them directly to C4 Level 2 containers (CNT-*) and C4 Level 3 components (CMP-*) ineidos/.cache/index.dband automatically deriving intra-containerconsumes_apiand inter-containerdepends_onedges from source imports. - Syntax-Aware Invariant Test Traceability (
POL-INVARIANT-TEST-ENFORCEMENT): Binds capability, policy, container, and component invariants (INV-*) to both bare test functions (tests/test_file.py::test_func) and class-qualified test methods (tests/test_file.py::TestClass::test_method) viatest_binding_cache.
Token-Budgeted AI Repo Map (eidos index repo-map)¶
AI coding agents struggle with whole-codebase awareness: sending thousands of raw code files exceeds LLM context windows, dilutes attention, and explodes cost.
Eidos provides the Repo Map Engine (eidos index repo-map), which compiles a high-signal, token-budgeted structural outline of the entire codebase directly from persisted code_symbols:
# Generate structural repo map with default budget (1500 tokens)
eidos index repo-map
# Or customize token budget:
eidos index repo-map --max-tokens 800
# Output as structured JSON:
eidos index repo-map --json
High-Density Compression (~98% Token Reduction)¶
The repo map summarizes files by their declared classes, methods, and functions without internal implementation boilerplate:
# 🗺️ Structural Code Graph (Repo Map)
`src/eidos/core/index/ast_indexer.py`:
├── class CodeSymbol (L122-L148)
│ ├── def to_dict (L137)
├── class BaseAstIndexer (L178-L453)
│ ├── def extract_symbols (L181)
│ ├── def extract_test_bindings (L186)
│ ├── def generate_repo_map (L414)
├── class AstGrepIndexer (L479-L1307)
│ ├── def extract_symbols (L1151)
│ ├── def extract_test_bindings (L1285)
├── def get_ast_indexer (L2003)
`src/eidos/core/index/graph_index.py`:
├── class ArchitecturalIndex (L109-L403)
│ ├── def sync (L171)
│ ├── def find_symbol (L213)
│ ├── def get_repo_map (L218)
In benchmarks, 50,000+ tokens of raw source code compress into under 1,000 tokens (98.18% compression ratio) while retaining full structural navigability for LLM planning.
Fast Symbol Discovery (eidos index find-symbol)¶
Developers and AI agents can query any symbol (class name, function name, API route) to find its exact source location and governing living specification:
Output:
Symbol Search Results for 'ArchitecturalIndex' (2 matches)
┏━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┓
┃ Symbol ┃ Kind ┃ File ┃ Spec Entity ┃
┡━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━┩
│ ArchitecturalIndex │ class │ src/eidos/core/graph_inde… │ CNT-EIDOS-INDEX │
│ get_architectural… │ function │ src/eidos/core/graph_inde… │ CNT-EIDOS-INDEX │
└────────────────────┴──────────┴────────────────────────────┴─────────────────┘
Python API Usage¶
The knowledge graph index can also be integrated directly into custom Python tools or automation scripts:
from eidos.core.index.graph_index import get_architectural_index
# Lazily initializes or loads cached index
index = get_architectural_index()
# 1. Tiered context slice (~2ms)
context = index.get_tiered_context_slice(
component="CNT-EIDOS-CORE",
tier="guardrails",
)
print(f"Tokens: ~{context.token_estimate}")
print(context.to_markdown())
# 2. BM25 hybrid full-text search
results = index.query_fts("SQLite knowledge graph", limit=5)
for r in results:
print(f"[{r['type']}] {r['id']}: {r['title']} (Rank: {r['rank']:.2f})")
# 3. Transitive blast-radius analysis
neighbors = index.get_k_hop_neighborhood("CNT-EIDOS-CORE", max_depth=2)
for n in neighbors:
print(f"Hop {n['hop_distance']}: {n['id']} ({n['type']})")
# 4. AI Repo Map generation
repo_map = index.get_repo_map(max_tokens=1500)
print(repo_map)
# 5. Reverse symbol resolution
symbols = index.find_symbol("AstGrepIndexer", limit=5)
for sym in symbols:
print(f"{sym['symbol_name']} ({sym['symbol_kind']}) -> {sym['entity_id']} in {sym['file_path']}")