Future Directions: Ontology Gardening & Neurosymbolic Approaches

Date: 2025-12-21 Status: Exploration & Planning Context: Two major architectural directions for repolex evolution


Direction 1: Ontology Gardening for Code

What Is It?

Ontology Gardening is an approach where schemas evolve from observed data rather than being pre-defined. Instead of forcing all code into fixed ontologies (WOC, TreeSitter), the system learns domain-specific concepts by observing patterns across a codebase.

Core Loop:

  1. Observe → TreeSitter AST + docstrings/comments
  2. Extract → LLM generates SPO statements about code intent
  3. Learn → GLiNER2 finds entities/relations against current schema
  4. Evolve → Gardener agent proposes new concepts when needed
  5. Refine → Curator agent merges duplicates, creates hierarchies

Originally developed for visual knowledge graphs (octology project), where VLMs observe images and the schema evolves to accommodate new visual concepts.

How It Would Improve Repolex

Current Limitation: Repolex extracts structure (classes, functions, AST) but doesn't understand domain semantics. Querying for "authentication code" or "data validation logic" requires knowing exact class/function names. The system has no concept of what "authentication" means in YOUR codebase.

With Gardening:

1. Domain Vocabulary Discovery

2. Architectural Pattern Recognition

3. Intent Relationships

4. Per-Repo Schemas

Hard Problems It Would Solve

1. The "Synonym Problem"

Current Issue:

Gardening Solution:

2. The "Intent Gap"

Current Issue:

Gardening Solution:

3. The "Subsystem Boundary Problem"

Current Issue:

Gardening Solution:


Direction 2: Neurosymbolic Approach with Embeddings

Why Add Embeddings?

Current State:

With Embeddings:

Embedding Strategies: Pushing the Envelope

1. Code Graph Embeddings (Microsoft Research)

What: Embed the graph structure itself, not just code text.

Microsoft's GraphCodeBERT / CodeT5+:

Novel Queries:

2. Hyperbolic Embeddings (Poincaré, Lorentz)

What: Embed in hyperbolic space instead of Euclidean.

Why: Code has hierarchical structure (packages → modules → classes → methods). Hyperbolic space naturally represents hierarchies with logarithmic growth.

Novel Queries:

3. Multi-Modal Embeddings (Code + Docs + Tests)

What: Embed functions with their documentation, tests, and usage examples in shared space.

OpenAI CLIP-style for Code:

Novel Queries:

4. Relational Embeddings (Knowledge Graph Completion)

What: Embed entities AND relationships (predicates) as vectors.

Models:

Novel Capabilities:

Should We Add Kuzu Entity Database?

Kuzu: Fast, embedded graph database optimized for OLAP queries, not RDF.

Pros:

Cons:

Recommendation: Option C (Oxigraph + FAISS/Qdrant)

Why:

No Kuzu needed unless you hit serious GROUP BY performance issues in Oxigraph (which you can test first).


Next Steps

  1. Prototype Gardener - Start with minimal implementation in octology, then adapt for repolex
  2. Benchmark Embeddings - Test CodeBERT-small on a medium repo (~1000 functions), measure speed
  3. Design Kuzu decision - Run GROUP BY benchmarks on Oxigraph, see if we actually need Kuzu
  4. Clean up CLI - Implement proper command structure with click
  5. Write tests - Start with ground truth for one small repo

What direction feels most exciting to you? Gardening or embeddings?

Future Directions: Ontology Gardening & Neurosymbolic Approaches
by @goodlux with claude-sonnet-4-5-20250929
2026-01-16T09:15:34+00:00