Repolex Parser Query Testing Review

Date: January 3, 2026 Tester: spacegoatai (Claude Sonnet 4.5) Test Repository: Flask (pallets/flask) Parser Version: repolex-ts (Python implementation) Goal: Critical evaluation of RDF output quality, queryability, and completeness


Executive Summary

Overall Assessment: ✅ Parser works but needs semantic layer

The Repolex parser successfully converts code to RDF with complete AST preservation. All syntactic information is captured (classes, functions, imports, decorators, type annotations, docstrings, line numbers). However, the output is too low-level for intuitive querying.

Key Findings

✅ Strengths:

❌ Critical Issues:

  1. Commits graph fails - Invalid IRI characters (brackets, emoji)
  2. No semantic relationships - Must traverse AST structure to answer basic questions
  3. Methods indistinguishable from functions - All are function_definition
  4. No test/production separation - Test code pollutes queries

⚠️ Counter-Intuitive:

Recommendation

Add semantic layer on top of AST structure. Keep full TreeSitter AST for completeness, but add high-level predicates like:

This hybrid approach enables both intuitive queries (for most users) and deep AST analysis (for experts).

Verdict: Parser is production-ready for AST extraction. Needs semantic enrichment for LLM consumption and human querying.


Test Dataset: Flask


Query Test 3: Class Methods

Objective: Find all methods of a specific class (e.g., Flask)

Actual working query (requires 2-hop traversal through block nodes):

PREFIX woc: <http://w3id.org/woc#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT ?className ?methodName WHERE {
  GRAPH <https://repolex.ai/data/pallets/flask/main/code> {
    ?class a <.../class_definition> .
    ?class rdfs:label ?className .
    ?block woc:childOf ?class .
    ?block a <.../block> .
    ?method woc:childOf ?block .
    ?method a <.../function_definition> .
    ?method rdfs:label ?methodName .
    FILTER(?className = "Flask")
  }
}

Result: ✅ WORKS - but counter-intuitive!

Sample output for Flask class:

Issues:

Recommendation:


Query Test 4: Inheritance Relationships

Objective: Find all classes that inherit from a base class

Result: ⚠️ PARTIAL - data exists but no semantic relationships

What works: Base class names are captured in sourceText of argument_list children

Output: Response inherits from ResponseBase (found in sourceText)

Issues:

Recommendation:


Query Test 5: Import/Dependency Tracking

Objective: Find all files that import a specific module

Result: ✅ WORKS GREAT!

Sample output:

What works well:

Issues:

Recommendation:


Known Issues (From Initial Testing)

1. ❌ CRITICAL: Commits Graph Fails on Invalid IRI Characters

Error: ValueError: Invalid IRI code point '['

Cause: Git commit messages or author names contain characters not valid in IRIs (brackets, emoji, etc.)

Impact: Cannot query git history, authorship, or temporal data

Recommendation:

2. ⚠️ Methods Not Distinguished from Functions

Observation: Parser reports "Methods: 0" but Flask definitely has methods

Impact: Cannot query class methods specifically

Recommendation:

3. ⚠️ No Test vs Production Code Distinction

Impact: Test classes pollute production code queries

Recommendation:


Results Summary

✅ What Works Well

  1. AST Completeness: Full TreeSitter AST preserved in RDF - all node types, source text, line numbers
  2. Import Tracking: Can query which files import which modules
  3. Source Code Location: Line numbers, columns, file URIs all present
  4. Type Annotations: Captured for typed parameters, return types, generics
  5. Decorators: Preserved with full source text in decorated_definition wrappers
  6. Docstrings: String literals traceable back to functions (with traversal)
  7. Multi-language Support: 13 languages in Flask parse, clean type URIs per language

⚠️ What Works But Is Counter-Intuitive

  1. Class Methods Require 2-Hop Traversal: class → block → method

    • Works but requires knowing AST structure
    • Should have direct woc:hasMethod shortcut
  2. Inheritance is String-Only: Base class names in sourceText, not semantic relationships

    • Can extract base class name but can't traverse hierarchy
    • Need woc:inheritsFrom with URI references
  3. Imports Not Structured: Full import statement as text, no parsed symbols

    • Can search by module name but not query "what symbols from X?"
    • Need woc:importsModule, woc:importsSymbol properties

❌ What's Missing or Broken

  1. CRITICAL: Commits Graph Fails - Invalid IRI characters in commit messages
  2. CRITICAL: No Semantic Relationships - AST structure only, no high-level connections
  3. No Test vs Production Distinction - Test code pollutes production queries
  4. Methods Not Distinguished - All stored as function_definition
  5. No Complexity Metrics - Cyclomatic complexity, LOC, etc. not computed
  6. Call Graph Not Semantic - Function calls captured as AST nodes with sourceText

Recommendations

Priority 1: Fix Commits Graph (BLOCKER)

Problem: Invalid IRI characters [, ], emoji, etc. in commit messages/authors

Solutions:

# Option 1: URL-encode special characters
from urllib.parse import quote
commit_uri = f".../{quote(commit_hash)}"
commit_msg_literal = Literal(raw_message)  # Store as literal, not in URI

# Option 2: Hash-based URIs
import hashlib
msg_hash = hashlib.sha256(message.encode()).hexdigest()[:12]
commit_uri = f".../commits/{commit_hash}"
# Store message as literal property, not in URI path

Priority 2: Add Semantic Shortcuts

Problem: Queries require deep AST knowledge (2-3 hop traversals)

Solution: Add high-level relationship triples alongside AST structure

# Keep AST structure:
(class, woc:childOf, module)
(block, woc:childOf, class)
(method, woc:childOf, block)

# ADD semantic shortcuts:
(class, woc:hasMethod, method)  # Direct link
(method, woc:methodOf, class)    # Reverse

# Same for inheritance:
(Response, woc:inheritsFrom, ResponseBase)  # URI reference when available
(Response, woc:baseClassName, "ResponseBase")  # String fallback for external

# Same for imports:
(import_stmt, woc:importsModule, "werkzeug.routing")
(import_stmt, woc:importsSymbol, "MapAdapter")

Schema Design Philosophy

Current approach: Pure AST preservation

Recommended: Hybrid approach

Benefits:

Repolex Parser Query Testing Review - Flask
by @goodlux with claude-sonnet-4-5-20250929
2026-01-16T09:15:55+00:00