Skip to content

Semantic layer is mostly disconnected from the AST graph #198

Description

@cs-anonymous

I think there is a structural issue in how graphify merges AST extraction and semantic extraction.

In practice, the semantic layer behaves more like a heuristic exploratory subgraph than a true semantic enrichment layer for the code graph. The two layers are often largely independent, and meaningful fusion seems to rely mostly on exact node-id collisions.

That is a very brittle condition.

Why this happens

AST and semantic extraction run in parallel, so the semantic pass does not know which AST nodes were produced in the current run.

Because of that, the semantic layer cannot intentionally attach edges to AST-only nodes. It can only emit its own nodes and edges, and later merge if some node ids happen to match exactly.

But exact id matching is hard in real cases:

  • AST: SentenceTransformer, get_embedding()
  • semantic: "sentence transformer", "get embedding"

These may describe the same thing, but they are unlikely to end up with the same id.

What I observed

I checked a generated graph locally:

OpenHarness: https://github.com/HKUDS/OpenHarness

  • Node types include code, rationale, document, and concept
  • I found effectively no code <-> document or code <-> concept bridges
  • The code graph forms one large connected component
  • The semantic layer forms a separate subgraph

The similar situation happens in many other cases, the final graph looks more like:

  • one AST/code graph
  • one semantic/document graph
  • very limited real integration between them

Suggestion

It may need a stronger alignment step, such as:

  • canonical labels / normalized concept ids
  • post-merge entity resolution between AST nodes and semantic nodes
  • explicit code-to-concept linking after both passes complete

At the moment, the semantic layer is useful as a heuristic exploration layer, but it does not seem to reliably enrich the AST graph itself.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions