Skip to content

Code Intelligence

This is a worked concept for a codebase-aware engineering assistant that reasons about a codebase as a connected software system. It is a design exploration, not a description of a completed or shipped product.

Problem

Many code assistants began by retrieving text that looks relevant to a question. Current coding agents mostly search with grep and read files in a loop, and some add structural tools such as repository maps and language-server queries. Both approaches find text well, and persistent agents find a lot. Neither, by default, shows how a system is put together. A change may depend on a type hierarchy, an interface contract, a service boundary, a runtime dependency, or an architectural convention that is not visible in the nearest text fragments, or on history and configuration that no code search reaches.

The assistant should help an engineer find and understand those relationships before proposing a change.

Positioning

None of the building blocks is new. Code graphs, AST chunking, language-server tools for agents, graph-guided code localization and links between code and its history all exist, and several systems already combine a code graph with an LLM agent (related work § Positioning). A literature search on 2026-04-05 found both parts of the original bet partly covered: commit history, co-change and runtime traces are already used as LLM context, and structural indexes have already been compared with grep agents. What remains is narrower:

  • configuration and infrastructure evidence linked to code, and history, configuration and runtime evidence combined for open developer questions rather than benchmark repair;
  • a cumulative per-level ladder (syntax, symbols, call and data flow, history) against both a tuned lexical baseline and a grep agent, split by evidence spread and by lexical overlap between question and code.

Both are hypotheses with refutation criteria in the thesis and evaluation plan. Where prior work already covers the rest, the project is a replication and a practical build, and should be described that way.

Design goals

  • Preserve meaningful code structures instead of splitting files into arbitrary chunks.
  • Combine textual retrieval with symbols, references, dependencies, and repository structure.
  • Show the evidence used to form an answer and let the engineer correct the search path.
  • Prefer current code and documentation when older material no longer represents the system.
  • Support design and refactoring work without pretending that structural evidence proves runtime behavior.

System outline

Structural index

Language parsers build an index around modules, classes, functions, interfaces, and imports. Abstract syntax trees provide the basic boundaries. Language Server Protocol data adds symbol definitions, references, and type relationships where the language tooling supports them.

This structure gives the assistant better retrieval units and a graph of relationships that can be followed across files and packages.

Hybrid retrieval

A request is resolved through several complementary signals:

  1. Text and semantic search identify likely concepts and documentation.
  2. Symbol search identifies concrete implementation candidates.
  3. Dependency traversal expands from those candidates to callers, implementations, tests, configuration, and related services.
  4. Repository metadata supplies ownership, recency, and change history where available.

No single signal is treated as authoritative. The result is a set of candidate paths with an explanation of why each path may matter.

Temporal relevance

Software knowledge becomes stale. Search ranking should prefer the current implementation and recent documentation, while keeping older decisions available when they explain why the current structure exists. Recency is a ranking signal rather than an automatic reason to discard material.

Human verification

For broad or ambiguous questions, the assistant asks the engineer to confirm the likely subsystem, service, or symbol before it expands the search. This makes uncertainty visible and reduces the chance that a plausible but unrelated code path becomes the basis for a design recommendation.

Evaluation approach

The full plan, with hypotheses, baselines and decision rules, is in the thesis and evaluation plan.

The assistant should be evaluated on engineering tasks with observable evidence, not only on whether an answer sounds useful. Example checks include:

  • whether it identifies the files and symbols required for a change;
  • whether it follows important callers, implementations, and tests;
  • whether its explanation cites evidence that actually supports the conclusion;
  • whether it detects uncertainty or conflicting candidates;
  • whether a proposed change preserves relevant contracts and passes the project checks;
  • whether engineers can correct a mistaken search direction without restarting the task.

The evaluation set should include changes that cross module or service boundaries, because those are where text-only retrieval is most likely to miss important context.

Limitations

Static structure cannot fully describe runtime behavior, generated code, reflection, dynamic configuration, or undocumented operational dependencies. Language tooling also varies in quality across repositories. The assistant therefore needs explicit confidence limits and access to tests, traces, and runtime evidence when the task depends on behavior rather than code structure alone.

Next steps

The smallest useful prototype would support one language and one repository. It would combine AST-aware chunks, language-server references, configuration links, text search, and a review step where an engineer selects the relevant subsystem.

The first evaluation targets what published work leaves open. A pilot of about 60 items tests how much each approach loses when the question shares no words with the code, by rewriting the same issues without identifiers. A small symbol-level arm keeps the results comparable with published numbers. Details are in thesis and evaluation plan § Pilot.

Whether linking code to configuration values helps, especially where names change between layers, is planned as a separate study in the backlog. It starts once repositories are chosen.

Notes

Thesis:

  • Thesis and evaluation plan: the claim to prove, hypotheses that would refute it, baselines (including an agent with grep), ground truth from Git history, decision rules.
  • Backlog: planned work not yet scheduled, written as plans; first item: the configuration-links study.

Design:

  • Code representation: AST units, repository graphs, compiler-grade analysis (symbol tables, slicing, def-use, types), static vs. dynamic languages, the code property graph.
  • Language servers and code indexes: where structure comes from in practice: tree-sitter, LSP requests and running servers headless, SCIP and stack graphs, CodeQL and Joern; costs, limits, agent tools.
  • Retrieval and context assembly: query understanding, task-aware retrieval findings, the graph-vector-lexical triad, context expansion, packing, index freshness.
  • Software knowledge graph: history, intent, runtime and ecosystem layers on top of the code graph; schema, traversals, trace-augmented retrieval.
  • Implicit knowledge: operational, environmental, evolutionary and social context; repository-mining signals; cheap association indices.
  • Hybrid architecture: deterministic core with LLM orchestration, primitive operations, workflow composition, target scenarios, method.

Research:

  • Related work: code property graphs, LLM-assisted slicing, property-graph RAG, and what this design adds.
  • Graph learning and world model: graph embeddings, link prediction, root-cause scoring; a simulatable world model for what-if questions.

Repository expert (the read-only first product):

  • Roadmap: staged build from a manual-context CLI to a continuously indexed, code-aware system; workstreams and first artifacts.
  • Requirements: users, functional and non-functional requirements, guardrails, failure modes.
  • Evaluation: stratified golden dataset, retrieval and generation metrics, release gates, pipeline.
  • Deployment: distribution patterns, service topology, scaling stages, interfaces to fix early.

Open questions

  • How should the different kinds of information (code slices, history, intent, runtime evidence) be represented in the context window: as text, or as another graph?
  • Which use case comes first: code review, incident resolution, or change-impact analysis?
  • Should the analysis components be exposed to the model as tools?
  • Could a causal inference engine and a library of typical incident evolution schemes support root-cause analysis (see graph learning and world model)?

Explore this section

  • Planned work for the code-intelligence project that is not scheduled yet, each item written as a plan with its question, prerequisites, steps and a done condition.

  • The claim this project has to prove, the hypotheses that would confirm or refute it, and an experiment plan with baselines, ground truth, metrics and decision rules.

  • How to model code for retrieval and reasoning, from AST units and repository graphs to compiler-grade analysis and the code property graph.

  • Research directions beyond deterministic retrieval, with graph machine learning as a probabilistic overlay and a world model that simulates what-if scenarios.

  • A deterministic analysis core wrapped by LLM orchestration, built from primitive operations that compose into debugging, refactoring and impact-analysis workflows.

  • The four kinds of context that static analysis misses, repository-mining signals, and cheap precomputed indices that bring them into retrieval.

  • Where code structure comes from in practice, from tree-sitter and live language servers to precomputed indexes (LSIF, SCIP, stack graphs, Kythe, Glean) and analysis databases (CodeQL, Joern), with costs, limits and use as agent tools.

  • Research and systems close to the code intelligence design, from code property graphs and graph-guided coding agents to studies of history, runtime evidence and structural tools as LLM context, and the narrower claims that remain after …

  • Query understanding, task-aware retrieval for code, the hybrid graph-vector-lexical triad, context expansion, packing and index freshness.

  • Extending the code property graph with history, intent, runtime and ecosystem layers into one queryable graph of the software lifecycle.

Repository Expert: A Read-Only Code Assistant

The read-only, citation-first first product of the code-intelligence project, from roadmap and requirements to evaluation and deployment.

Browse 4 notes
  • Distribution patterns for the repository expert, from a stateless local CLI to a shared retrieval service, with the scaling stages and the interfaces to fix early.

  • How to test the repository expert, with a stratified golden dataset, retrieval and generation metrics, code-specific checks, release gates and a tiered pipeline.

  • Product definition, users, functional and non-functional requirements, guardrails and failure modes for a read-only, citation-first repository expert.

  • The read-only repository expert as a staged build, from a manual-context CLI to an indexed, code-aware and continuously updated system, with the artifacts each stage produces.