Skip to content

fix: Name trace nodes of Kotlin companion members after the source class (#591) - #683

Merged
imuromtsev merged 6 commits into
mainfrom
imuromtsev/mcp-trace-source-names
Oct 13, 2026
Merged

imuromtsev merged 6 commits into
mainfrom
imuromtsev/mcp-trace-source-names

Conversation

@imuromtsev

Copy link
Copy Markdown
Collaborator

Closes #591

What changes

explyt_trace_spring_call_chain names a traced method's class (className of a chain node) after the Kotlin source, as the call targets and the endpoint contract's call names (#571) already do. Before, a node reached through a companion member carried the JVM light-class name, so the call target VmId.parse linked to a node of class explyt.trace.VmId.Companion.

  • Companion members take the class that declares the companion: explyt.trace.VmId, a named companion companion object Factory → its outer class, a companion of a nested class → explyt.trace.Outer.InnerId, and a companion of a class literally named Companion → explyt.trace.Companion.
  • Everything else keeps its name (containingClass.qualifiedName, as before): Java members, top-level Kotlin functions (FooKt), object members, extension functions, nested and inner classes, internal members, and a class nested inside a companion.
  • A companion member is recognised by its declaration (KtObjectDeclaration.isCompanion()), not by comparing names. The rule lives in SourceNames, next to the one [BUG] Endpoint contract targets retain Companion in route and service-call names #571 uses for contract call names.
  • A Java call to a @JvmStatic companion function (VmId.parse(raw), the static copy) and a call through VmId.Companion.parse(raw) still reach two nodes (distinct ids; the trace identity is the JVM method), but both now carry the source class name explyt.trace.VmId. The pinned test from fix: Name companion-object calls by their outer class (#504) #568 is updated accordingly.

The external call target (CallChainTracer.kt:185) is unchanged: it is reached only for a library method on an injected dependency, named after the dependency's declared type, where companion and $module names cannot occur.

Not in this PR

Merging the static copy and the companion member into one node would need a trace identity based on the source declaration instead of the JVM method; it is not asked for in #591.

Verification

  • Red tests in SpringBootApplicationMcpToolsetTraceCallChainTest, each committed failing before its fix and failing on the className assertion: companion members of two outer classes, a companion of a nested class, the @JvmStatic pair, and a companion of a class named Companion (its precondition checks that the light class name ends with .Companion.Companion). The expected names are computed through SourceNames, not hard-coded.
  • TraceCallChainTest 18/0 and ServiceCallsTest 25/0 (both read SourceNames) on the head.
  • :spring-ai:test --rerun on the head: 754 tests, 0 failures (fresh XML, 57 suites).

Backport

spring-ai (MCP): 252+. SourceNames comes from #571; the line needs it first.

@imuromtsev imuromtsev added the spring-mcp-tools Explyt MCP tools (explyt_*); need JetBrains MCP Server, IDEA 2025.2+ label Oct 13, 2026
@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
TestsPassed ✅Skipped ⚠️Failed
JUnit Test Report4398 ran4392 passed6 skipped0 failed

@imuromtsev
imuromtsev force-pushed the imuromtsev/mcp-trace-source-names branch from b611667 to cef4a25 Compare October 13, 2026 13:05
@imuromtsev
imuromtsev merged commit 5303a60 into main Oct 13, 2026
1 check passed
@imuromtsev
imuromtsev deleted the imuromtsev/mcp-trace-source-names branch October 13, 2026 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

spring-mcp-tools Explyt MCP tools (explyt_*); need JetBrains MCP Server, IDEA 2025.2+

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MCP trace still uses light-class names for external calls and node className

1 participant