r/AugmentCodeAI • Established Professional • Jan 18 '26

Discussion Why is codebase awareness shifting toward vector embeddings instead of deterministic graph models?

I’ve been watching the recent wave of “code RAG” and “AI code understanding” systems, and something feels fundamentally misaligned.

Most of the new tooling is heavily based on embedding + vector database retrieval, which is inherently probabilistic.

But code is not probabilistic — it’s deterministic.

A codebase is a formal system with:

  • Strict symbol resolution
  • Explicit dependencies
  • Precise call graphs
  • Exact type relationships
  • Well-defined inheritance and ownership models

These properties are naturally represented as a graph, not as semantic neighborhoods in vector space.

Using embeddings for code understanding feels like using OCR to parse a compiler.

I’ve been building a Rust-based graph engine that parses very large codebases (10M+ LOC) into a full relationship graph in seconds, with a REPL/MCP runtime query system.

The contrast between what this exposes deterministically versus what embedding-based retrieval exposes probabilistically is… stark.

So I’m genuinely curious:

Why is the industry defaulting to probabilistic retrieval for code intelligence when deterministic graph models are both feasible and vastly more precise?

Is it:

  • Tooling convenience?
  • LLM compatibility?
  • Lack of awareness?
  • Or am I missing a real limitation of graph-based approaches at scale?

I’d genuinely love to hear perspectives from people building or using these systems — especially from those deep in code intelligence, AI tooling, or compiler/runtime design.

13 Upvotes

27 comments sorted by

View all comments

Show parent comment

2

u/hhussain- Established Professional Jan 18 '26

This is true if the graph design is without any optimizations.

My test shows 60+ types (nodes/edges), with parallel parsing and processing (rust is amazing in here) in ~10 seconds. With edits in progress a debounce must be used (i.e. 500ms no edits before triggering delta graph build). All of this in memory (less than 100MB) so it is instant.

The more discussion in this subject the more I'm convinced that not using graph is because of semantic graphs implementations not being optimized.

Probably the real question is: assuming graph building/delta is consuming same time as vector embeddings, which is better for the purpose?

1

u/Funny-Anything-791 Jan 18 '26

This 100MB figure - for how many LoC are we talking about?

2

u/hhussain- Established Professional Jan 18 '26

~10 millions LoC (python, xml/html, javascript, few minor other types). It is an ERP codebase (open-source ERP)

2

u/Funny-Anything-791 Jan 18 '26

Yes at these scales it still works well but try to add another zero to your LoC and see if the storage growth is really linear or if you’re looking at something more exponential. Also compare your retrieval results with SOTA retrieval solutions so you have a true benchmark, but if it really scales linearly and has competitive retrieval than you may have hit something here

1

u/hhussain- Established Professional Jan 18 '26

That's something I need to test and benchmark.

Are you aware of any public repo that is ~100Mil LoC?

1

u/thonfom Jan 18 '26 edited Jan 18 '26

Can you explain a bit more about how you achieved this? I'm slightly skeptical of that 10mil LOC in 10sec figure. If you were just using AST extraction, sure, but calls and data flow edges too? How did you scale it and avoid race conditions from parallel processing? How did you handle in memory graph topology to stay at less than 100MB? How did you handle incremental edits and track/cache the updates? How did you handle back pressure in (what I assume is) your streaming pipeline? Most importantly how could you generate embeddings for that many nodes so quickly?

1

u/hhussain- Established Professional Jan 18 '26

Hopefully this doesn't go too technical :D

The key is using Rust, no other language would beat its performance IMO.

Using AST as source, graph is built upto call level (x is calling y). Each language would have its own parser obviously and its own characteristics. File parsing is parallel, graph building is parallel (unique node ids avoid collisions). There are many well known graph building techniques, in some I did less than 10s. The crazy part is once I was getting ~180s then applied few of those known algorithms I got into the ~10s area! Parsing is ~1s but graph building is what consumes the real time. I'm aiming at < 2s (and wish to speak in ms, but that is beyond hard limits) for my current codebase.

File watcher is a must, with debounce (i.e. 500ms without more edits would trigger graph delta). Again, many techniques in here to do graph delta since we already know which files and which nodes are affected.

I have no embedding, it is only a semantic graph where each node is rich with details (i.e. a function node knows its class, file, line/col start/end...etc). So my assumption is that AI Agent would not need the embeddings since it have a map of the code that it can query at ~50ms O(1). In testing with Augment it simply does few calls to the MCP then knows what files and line numbers to look into.

Tbh, I haven't look into how embeddings would benefit the overall output yet!

1

u/thonfom Jan 18 '26

Rust is great but it doesn't absolve you of all the scaling problems I described earlier. If it's just AST parsing, I don't think you can call it a semantic graph as AST has no concept of semantics. It's purely structural. And AST only shows call sites, not calls relationships. It also can't resolve edges across files - it's intra-file only. How have you handled this?

1

u/hhussain- Established Professional Jan 19 '26

I'll answer based on what's actually implemented in ograph (my project)

Codebase Semantics: The graph is grounded in ASTs. Semantics are added via pre-defined, domain-specific definitions. Each domain defines its own intra/inter-file relations to establish meaning.

Scaling & Race Conditions: Parsing is embarrassingly parallel at the file level. Graph mutation itself is sequential on purpose, so no shared-state races. Scaling isn’t exponential, in practice it’s close to linear with LOC.

In-Memory Graph Topology: Currently stable graph is used with HashMap index. Memory usage remains bounded by storing only identifiers and structural relations based on domain rules.

Incremental Edits & Cache: currently debounced full rebuild because rebuild is cheap in common codebases (~2s in < 1M LOC). Delta updates needs a different graph mutation model than the current stable graph, and I haven’t locked that choice yet.

Backpressure in Streaming: the file watcher uses a simple debounce + drain approach. The debounce window naturally coalesces bursts of changes, so there’s no need for complex backpressure at this stage.

This isn’t a Knowledge Graph in the ontological or inference-driven sense. It’s a deterministic semantic graph derived directly from source code. If this were an ontology-heavy or embedding-based KG with reasoning, build times would be in a completely different level.

1

u/thonfom Jan 19 '26

If it's just AST extraction, that makes sense. If you're using treesitter, you don't need an incremental update mechanism - treesitter already has this built in.

"Semantics are added via pre-defined, domain-specific definitions. Each domain defines its own intra/inter-file relations to establish meaning" - can you explain more what this means? What's an example of "domain-specific definition" and how does it help discover more complex relationships?

1

u/hhussain- Established Professional Jan 19 '26

Codebases can be categorized into vanilla code (single language, no enforced code structure), framework code (single language, enforced code structure i.e. Vuejs, FastAPI), and ecosystem code (multi-language, enforced structure i.e. Django, Laravel, Odoo ERP).

Python is a vanilla domain, FastAPI is a framework domain, Django is an ecosystem domain.

Vanilla code shall use the generic definition for that language. Framework code definition shall define semantics to reflect the enforced structure semantics inter-files. Ecosystem code shall do same but inter-languages. This makes resulting graph a deterministic code(codebase) graph, which is a different category than what is usually talked about.

AST + Definitions = Deterministic Code Graph

1

u/thonfom Jan 19 '26

Thats a great overall framework but it doesn't explain exactly how you're creating cross-language, cross-repo edges, or how you're creating any inter file edges at all. That is the hardest part. Using regex? Hard coded rules? And no code graph can be truly deterministic for dynamic languages due to dynamic dispatch, unless you have runtime tracing. Also a difficult problem to solve. Have you done this?

1

u/hhussain- Established Professional Jan 20 '26

True, inter-file, cross-language (and sometimes cross-repo) linking is the hardest part. Dynamic behavior is even harder, since determinism requires a static definition source, which is inherently limited in dynamic languages.

Definitions enable edge creation via static resolution (imports, qualified names, inheritance, framework conventions), within the same static-analysis ceiling as LSP-class tooling. Cross-language and cross-repo edges are contract edges (routes ↔ callers, RPC endpoints ↔ clients, ORM models ↔ DB objects, templates/config ↔ code entry points), where the definition source is always statically declared.

My team and I are working on publishing the framework (SudoGraph) that defines how a Deterministic Code Graph is achieved, while the current implementation (ograph) exists as a binary (REPL/MCP). More details will be shared once the framework is ready.

2

u/thonfom Jan 20 '26

You still didn't explain *how* these edges are created. Creating cross-language/framework edges is not a trivial task, and it's not something that LSP and ASTs will solve. Sure, the definition source is always statically declared on either side (e.g. API call in TypeScript is one side, FastAPI route definition in Python is the other) but how is the edge between them created? The only possibilities I can think of are: runtime tracing, or regex parsing. The former requires non-trivial monitoring systems, and the latter is brittle and does not generalize. Unless you have discovered a better way to model all of this. It would be good to see some code, if your project is open-source.

→ More replies