# Codebase Analysis

## Definition

Codebase analysis is a responsibility of the CodeIntelligence Runtime layer: semantic code understanding, repository intelligence, and dependency reasoning, bound to organizational context rather than treated as a standalone search/embeddings feature.

## Key properties

- Layer 1 (CodeIntelligence Runtime) responsibilities: repository intelligence, semantic code understanding, spec grounding, inference-time retrieval, dependency reasoning, architecture understanding, organizational context binding, MCP interaction

## How analysis runs (extraction engine)

- **Ingest** — the cheap, deterministic pass: per-file structure (tree-sitter; code containers, callable units, data structures, data elements), corpus-wide architecture (modules, storage locations, reference resolution), and embeddings. No LLM.

- **Refine** — the LLM pass: parallel extraction lanes (feature-finder, actor-finder, rule-finder, domain-entity-finder) over scoped graph neighborhoods, then module roll-up to business capabilities, then identity resolution to collapse duplicate concepts. Re-runnable and memoised.

- **Output** — a grounded, layered knowledge graph: every derived finding carries an `evidenced_by` / `derived_from` chain down to source code, and an epistemic-order marking (source > human doc > AI summary > synthesis). Full detail:[Methodology](/comparisons/methodology.md).

## Related terms

- [code intelligence](/definitions/code-intelligence.md)

- [intelligence model](/definitions/intelligence-model.md)

- [spec](/definitions/spec.md)
