Repository navigation
fix: Name trace nodes of Kotlin companion members after the source class (#591) - #683
Merged
Merged
Conversation
|
imuromtsev
force-pushed
the
imuromtsev/mcp-trace-source-names
branch
from
October 13, 2026 13:05
b611667 to
cef4a25
Compare
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.
Closes #591
What changes
explyt_trace_spring_call_chainnames a traced method's class (classNameof 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 targetVmId.parselinked to a node of classexplyt.trace.VmId.Companion.explyt.trace.VmId, a named companioncompanion object Factory→ its outer class, a companion of a nested class →explyt.trace.Outer.InnerId, and a companion of a class literally namedCompanion→explyt.trace.Companion.containingClass.qualifiedName, as before): Java members, top-level Kotlin functions (FooKt),objectmembers, extension functions, nested and inner classes,internalmembers, and a class nested inside a companion.KtObjectDeclaration.isCompanion()), not by comparing names. The rule lives inSourceNames, next to the one [BUG] Endpoint contract targets retain Companion in route and service-call names #571 uses for contract call names.@JvmStaticcompanion function (VmId.parse(raw), the static copy) and a call throughVmId.Companion.parse(raw)still reach two nodes (distinct ids; the trace identity is the JVM method), but both now carry the source class nameexplyt.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$modulenames 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
SpringBootApplicationMcpToolsetTraceCallChainTest, each committed failing before its fix and failing on theclassNameassertion: companion members of two outer classes, a companion of a nested class, the@JvmStaticpair, and a companion of a class namedCompanion(its precondition checks that the light class name ends with.Companion.Companion). The expected names are computed throughSourceNames, not hard-coded.TraceCallChainTest18/0 andServiceCallsTest25/0 (both readSourceNames) on the head.:spring-ai:test --rerunon the head: 754 tests, 0 failures (fresh XML, 57 suites).Backport
spring-ai (MCP): 252+.
SourceNamescomes from #571; the line needs it first.