R353 · Knowledge for agents › Code knowledge graphs for agents

CodeKB: a model writes what each function does, including through its callees

Read the original

code-knowledge-graphretrievalmcpcoding-agentsawsvendor

Filed 27 Nov 2026. Source: the awslabs/codekb repository (Apache-2.0) — the README plus its MCP, configuration, FAQ, local and deployment docs. Surfaced by a practitioner post that carried no link.

The idea

The problem it targets is not "find me this symbol". It is the question a reviewer asks before touching a shared service: which repositories does this change actually reach? Today that is answered from memory, and the failure is silent — you miss one and find out in production.

CodeKB's answer is to make the index semantic rather than syntactic. Tree-sitter parses symbols and rebuilds the call graph, and then a model writes a business-language description of each function together with the code it calls — so the description says what the function accomplishes through its callees, not just what its own body does. Those descriptions are embedded, and the resulting store is what an agent searches. Ask "where are payments authorized" and you get functions, across every analysed repository, whose described purpose matches — including ones whose names and local bodies contain no word resembling the query.

That is the whole bet: a call graph tells you what calls what, and a description written with the callees in view tells you what the chain is for. The second is the thing a reviewer actually needs and the thing grep cannot produce.

Architecture, in order

  1. Ingest a "space" from a Git URL (shallow clone, one branch or tag, one commit) or a zip upload. Source is archived in S3; saved Git tokens are encrypted with KMS.

  2. Parse with tree-sitter: functions, methods, classes, modules, variables. Rebuild the call graph.

  3. Mask, then describe. A Bedrock Guardrail masks secrets and PII first — mandatory, the app will not start without a guardrail ID while the guardrail is enabled — then a Claude model on Bedrock writes each description. One vocabulary pass per analysis establishes the project's business terms.

  4. Embed descriptions with Titan Text Embeddings V2 into S3 Vectors.

  5. Group related repositories into a "hyperspace" so search, chat and overviews span them. Overviews are generated on demand as Markdown.

Search is three mechanisms, not one, and the distinction matters when you reason about failure: semantic search over description embeddings (the recommended entry point), exact and wildcard name lookup, and explicit graph traversal for dependencies and call flows. The semantic layer finds candidates; the graph layer is what you use to establish impact.

Incremental refresh (Git spaces only) is the part worth studying. Changed files are re-parsed, and then the system walks the call graph in reverse to find callers whose descriptions included the changed code, and re-summarises those along with the changed functions. Everything else is reused. A failed refresh leaves the previous indexed version searchable. This is the right shape: a description that incorporates callee behaviour is invalidated by changes below it, so the invalidation has to propagate upward.

The MCP server exposes 14 tools over streamable HTTP. The documented flow is: list spaces, then plain-language search, then fetch the component by its space-qualified ID, then dependencies with dependents included for impact analysis.

Tradeoffs and what the docs don't say

The description-generation mechanics are undocumented. Whether the model receives the callee's description or the callee's source, what order functions are processed in (bottom-up? topological?), and how cycles and recursion are handled — none of it is stated. This is not a detail. Description quality depends entirely on it, and so does the cost: propagating descriptions bottom-up over a topological order is one pass, while feeding callee source at every node multiplies tokens. A reader cannot tell which they are buying. Nor is the reverse-walk's transitivity stated, so you cannot tell whether a leaf change invalidates one hop of callers or the whole chain above it.

The cross-repository claim is the weakest link. The pitch is that the system "automatically and reliably selects the relevant repositories", which is precisely the hard part, and no mechanism is given. How hyperspace membership is established is also unstated. Treat repository selection as unproven and verify it against a change whose blast radius you already know.

No evaluation exists. Not a benchmark, not a recall figure, not an accuracy number, anywhere in the documentation. For a semantic search system whose value proposition is "you won't miss a repository", the absence of a recall measurement is the gap that matters most — a miss is invisible by construction.

No cost figure either. The FAQ's answer is to measure a representative repository in your own account. Bedrock dominates per-analysis cost and each space reports token usage per operation, so the measurement is at least available after the fact. Default model is Claude Opus 4.6, configurable; the embedding model is not.

Bedrock is a hard dependency, including locally. There is no self-hosted path. A local run still needs a supported Claude model and Titan embeddings on Bedrock, plus AWS CLI v2 with S3 Vectors support, Docker and Git. That makes the "run it locally" option a developer convenience rather than an isolation guarantee.

Stated limits worth knowing before you plan an indexing run: 10,000 eligible source files per analysis (extras skipped), files over 10 MB skipped, Git clone must complete within 5 minutes, zip up to 500 MB or 5 GB extracted. 32 background jobs per process; summarisation concurrency defaults to 1 if unset but 40 in the example env, which is a large difference to leave to a default. The CDK's non-dev default is 10 Fargate tasks at 4 vCPU and 16 GB each, flagged as important in the deployment doc.

A space is one commit. No history is indexed, so "when did this behaviour change" is out of scope. Exclusion patterns are fixed at creation — changing them means deleting and re-creating the space. Operations on the same space are "not fully serialized".

Failure modes

Review checklist

  1. Measure recall on a change you already understand. Pick a past change whose true blast radius you know, query for it, and count what the system missed. That number is the product.

  2. Measure the indexing bill on one representative repository before indexing an organisation, and record tokens per thousand functions so you can project it.

  3. Determine the refresh semantics empirically. Change a leaf function, then check whether descriptions two and three levels up were re-summarised. If not, plan periodic full re-indexing.

  4. Decide whether descriptions are an audit artifact or a search index. With no provenance to specific lines, treat them as retrieval aids and require reading the code before acting — and write that rule down, because a fluent business description invites the opposite.

  5. Check the file ceiling against your largest repository and look at what got skipped, not just whether the run succeeded.

  6. Never run with authentication disabled off a developer machine, and set summarisation concurrency explicitly rather than inheriting whichever default applies.

  7. Confirm the guardrail is active and tested against your own secret formats before pointing it at a repository with real credentials in history.

The natural comparison is a purely structural code graph that agents query instead of grepping — same retrieval goal, no model in the indexing path, so no description cost, no description errors and no semantic reach. The other neighbour is the pattern of serving a curated layer to agents over MCP rather than giving them raw access to the underlying store, where the interesting question is always what the curation adds and what it hides.

Part of the Research notes on nowucca.com. Figures and claims are the source's own unless the summary says otherwise.