Skip to content

fix(intelligence): Phase 5 extractor bugs — runtime crash, ThreadLocal, Go dedup, interface detection#31

Merged
aksOps merged 10 commits into
mainfrom
fix/major-issues-phase5
Apr 4, 2026
Merged

fix(intelligence): Phase 5 extractor bugs — runtime crash, ThreadLocal, Go dedup, interface detection#31
aksOps merged 10 commits into
mainfrom
fix/major-issues-phase5

Conversation

@aksOps

@aksOps aksOps commented Apr 4, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Critical: Wrap builder.getEdges()/getNodes() in new ArrayList<>() in EnrichCommand — both assignment sites. Was throwing UnsupportedOperationException at runtime when LanguageEnricher.enrich() called addAll() on the immutable List.copyOf() returned by GraphBuilder
  • Critical: Remove ThreadLocal<JavaParser> from JavaLanguageExtractorPARSER.remove() in finally defeated caching, recreating the parser on every call. Replaced with method-local new JavaParser()
  • Important: Add Set<String> seen dedup to GoLanguageExtractor.extractImportEdges + fix lookupUnambiguous to deduplicate by node ID (same node under multiple registry keys was falsely triggering ambiguity guard)
  • Important: Replace fragile String.contains fake-Go-syntax with RECEIVER_METHOD regex in GoLanguageExtractor.extractInterfaceHints. Old pattern never matched real Go source
  • Cleanup: Remove dead sanitizeRelType method from EnrichCommand; fix tautological assertTrue(0||1) test assertion
  • Docs: Update CLAUDE.md — 37 endpoints (was 34), 34 MCP tools (was 31), add intelligence/ package structure, IntelligenceController endpoints, updated pipeline diagram, remove dead INTERFACE_METHOD constant

Test Plan

  • 1680 tests, 0 failures, 0 errors (mvn test)
  • New regression test enrichedEdgesAreMutableForLanguageEnricher covers the immutable list fix
  • New test extract_samePkgMatchedByNameAndPath_noDuplicateEdges covers Go edge dedup
  • New test extract_realGoReceiverSyntax_detectsInterfaceSatisfaction covers Go receiver regex
  • Code review passed (spec compliance + quality)

🤖 Generated with Claude Code

aksOps and others added 10 commits April 4, 2026 05:07
…hCommand

builder.getEdges() returns List.copyOf() (immutable). LanguageEnricher.enrich()
calls edges.addAll() on it, which would throw UnsupportedOperationException at
runtime during language enrichment.
After the ServiceDetector block, enrichedNodes/enrichedEdges were reassigned
directly from builder.getNodes()/getEdges() (immutable). Fix the same latent
UnsupportedOperationException for any downstream mutation.
ThreadLocal.remove() in finally defeated caching — parser was recreated every
call via withInitial anyway. Method-local new JavaParser() is simpler, equally
safe on virtual threads, and avoids ThreadLocal overhead.
…portEdges

Matches the dedup pattern used in Python and TypeScript extractors. Prevents
duplicate IMPORTS edges when a package is matched by both short name and full path.

Also fixes lookupUnambiguous to deduplicate by node ID, so that a node stored
under multiple registry keys (id, label, full path) is not falsely treated as
ambiguous.
…eceiver matching

Old pattern matched fabricated Go syntax. New RECEIVER_METHOD regex extracts
actual receiver methods from Go source and matches interface labels using Go
naming convention (Reader->Read, Closer->Close).
…tion

sanitizeRelType was never called anywhere. EnrichCommandTest assertion accepted
both 0 and 1 exit codes which tested nothing meaningful.
… + intelligence layer

Add intelligence/ package structure, IntelligenceController endpoints,
updated pipeline diagram, and key intelligence files to reference table.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…E_METHOD pattern

Review found: documented endpoint count was 39 but actual bullet count is 37
(21 GraphController + 9 TopologyController + 4 FlowController + 3 IntelligenceController).
Also removed unused INTERFACE_METHOD Pattern constant from GoLanguageExtractor
left over after extractInterfaceHints was rewritten to use RECEIVER_METHOD.
@sonarqubecloud

sonarqubecloud Bot commented Apr 4, 2026

Copy link
Copy Markdown

@aksOps aksOps merged commit 541fc81 into main Apr 4, 2026
10 checks passed
@aksOps aksOps deleted the fix/major-issues-phase5 branch April 26, 2026 05:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant