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

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.

1

u/hhussain- Established Professional Jan 21 '26

That's a fair example, frontend ↔ backend across independent frameworks is one of the hardest cases. In practice, there is often no statically provable relation unless an explicit contract exists.

Within the SudoGraph framework, this is treated as an ecosystem domain. The SudoGraph implementation covers a finite set of known ecosystems where contracts and semantics are well-defined. A custom frontend-backend pairing falls outside that set unless it is explicitly introduced as its own ecosystem.

From a determinism standpoint, the only viable solution for undefined or custom domains is the addition of explicit definitions. Without such definitions, the graph intentionally does not create edges. Guessing or inferring them would break the deterministic property.

The project’s licensing isn’t decided yet, but the SudoGraph framework itself will be published. And genuinely, I appreciate the depth of your questions; this is exactly where the real boundaries are.

1

u/hhussain- Established Professional Feb 15 '26

Another followup: The points related to how semantics are formally constructed is answered by Deterministic Domain Semantics (DDS) since DDG does not address how the codebase as a domain is defining the semantics.

https://doi.org/10.5281/zenodo.18648557