Repository navigation
Go Port Phase 4: Native tree-sitter AST extraction engine - #8
Merged
Merged
Conversation
Agent-Logs-Url: https://github.com/kristofer/codegraph/sessions/5f8cbd56-5b17-42dc-b1fe-3393751b9eeb Co-authored-by: kristofer <[email protected]>
Add the complete tree-sitter-based AST extraction engine for the Go port of CodeGraph. All 15 tests pass. ## Changes ### New packages **internal/extraction/languages/** (package ): - – struct with node-type lists and callback functions; dispatcher - – TypeScript/JavaScript/JSX/TSX config - – Python config (docstring extraction, visibility heuristic) - – Go config (type_declaration → struct/interface/alias, method_declaration vs function_declaration) - – Rust config (impl_item body for methods, visibility_modifier) - – Java config (modifiers-based visibility and export) - – C#, PHP, Ruby, Swift, Kotlin, C/C++, Svelte configs **internal/extraction/**: - – (lazy per language), , , extension → Language map - – (tree traversal), , helper types - – , , - – (file scanning, parallel indexing, hash-based change detection), , ### Test coverage (extraction_test.go) - TestDetectLanguage / TestDetectLanguageCppHeuristic - TestIsLanguageSupported - TestExtractTypeScript / TestExtractTypeScriptAsync - TestExtractPython / TestExtractGo / TestExtractRust / TestExtractJava - TestExtractEdges - TestHashContent / TestScanFiles - TestParallelIndexing / TestHashChangeDetection - TestUnresolvedRefs Co-authored-by: Copilot <[email protected]> Co-authored-by: kristofer <[email protected]>
- Document 16-char SHA-256 prefix to explain parity with TypeScript impl - Fix channel buffer sizes (no spurious +1) - Propagate DB upsert errors into IndexResult.Errors instead of silently ignoring them Co-authored-by: Copilot <[email protected]> Co-authored-by: kristofer <[email protected]>
- Add parserPoolMaxSize constant (was magic number 32) - Fix redundant []rune double-conversion in isExported check - Add FilesOversized to IndexResult to distinguish size-skipped vs hash-skipped - Use fileOutcome named type instead of anonymous struct in processFile - Handle filepath.Match error explicitly in matchesGlob Co-authored-by: Copilot <[email protected]> Co-authored-by: kristofer <[email protected]>
Agent-Logs-Url: https://github.com/kristofer/codegraph/sessions/5f8cbd56-5b17-42dc-b1fe-3393751b9eeb Co-authored-by: kristofer <[email protected]>
Copilot
AI
changed the title
[WIP] Implement phase 4 of the AST extraction engine
Go Port Phase 4: Native tree-sitter AST extraction engine
Apr 27, 2026
Owner
|
@copilot resolve the merge conflicts in this pull request |
Co-authored-by: kristofer <[email protected]>
Author
Merge conflicts resolved in commit |
kristofer
approved these changes
Apr 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements Phase 4 of the Go port plan: a parallel AST extraction engine using native CGO go-tree-sitter bindings (no WASM). Covers grammar registry, parser pooling, per-language configs, and a parallel orchestrator with hash-based change detection.
Grammar Registry (
grammars.go)sync.Onceinitialization per language viaGrammarRegistryDetectLanguage()with.h→ C/C++ heuristic (keyword scan fornamespace,class,template<,#pragma once,::)IsLanguageSupported()for 16 languages; Dart/Pascal/Liquid return false (no go-tree-sitter grammar available)Parser Wrapper (
tree_sitter.go)parserPool(capped at 32 idle parsers) shared across all goroutinesParseSource(lang, source)→*sitter.Tree;ExtractFromSource(path, source, lang)→*ExtractionResultLanguage Configs (
languages/)Data-driven
LangConfigstructs — node-type lists plus callback hooks — one per language group:typescript.gopython.gogolang.gotype_declaration→ struct/interface/alias)rust.gojava.goother.goCore Walker (
extractor.go)Generic recursive AST visitor driven by
LangConfig. ProducesNode/Edge/UnresolvedReferencewith:Outer::Inner::method)containsedges from every parent to child symbolkind:sha256(path:kind:name:line)[:32](matches TypeScript format)type_declaration, Rustimpl_item, Pythondecorated_definition, TSexport_statementOrchestrator (
orchestrator.go)ScanFiles()with full**glob matching againstinclude/excludepatternsIndexAll(): fan-out toruntime.NumCPU()workers; SHA-256 hash-based skip for unchanged filesSyncFiles(changedFiles): same pipeline restricted to a provided file listDBinterface for storage (matches existingdbpackage method signatures)Tests
16 tests covering language detection, symbol extraction (TypeScript, Python, Go, Rust, Java), edge generation, hash change detection, parallel indexing,
SyncFiles, and unresolved import refs.