fix(crossrepo): treat only "::" as a namespace marker - #82
Merged
Conversation
linkSharedSymbols guards against linking two repos in different languages
that merely share a domain type name. The guard is skipped for identities
it considers namespace-qualified, and isQualifiedIdentity counted any dot
as qualifying.
By the time it runs, typeIdentity has already stripped the module prefix,
so a residual dot means type nesting, not a namespace. Kotlin and Swift
both emit nested declarations as "Outer.Inner". Two apps that model the
same product in different languages therefore cleared minSharedSymbols on
nested names alone, bypassed the guard, and were given a bidirectional
depends_on -- a 2-cycle in the service graph, and an edge no parser
justifies. traverse, find_path and impact_analysis route through it, and
coverage_report overstates each app's outbound edge count.
Replace isQualifiedIdentity with isNamespaceQualified, matching "::" only,
at both call sites: the same-language guard and the isDistinctiveIdentity
short-circuit. Nested identities are now unqualified, so they fall under
the language guard and under the length/generic-name filters.
Coverage:
- TestComputeLinks_SharedSymbolsCrossLanguageNestedTypesSkipped, which
failed before this change with the exact bidirectional pair.
- TestComputeLinks_SharedSymbolsSameLanguageNestedTypesLink, guarding
the over-correction: a nested identity is now unqualified and so newly
depends on the language guard; same-language repos must still link.
- testdata/repos/kotlin_swift_multirepo, the first golden fixture pairing
two different-language repos. The bug lives between what the extractors
name symbols and what the linker assumes a dot means, and every input in
crossrepo_test.go is a hand-built fact, so no synthetic-fact test can
reach it. Verified by reinstating the bug and watching the golden fail.
No cacheVersion bump: linkCrossRepo runs after runExtractors and after the
extractor cache is saved, so no extractor output changes. The linker's
synthetic facts do land in facts.jsonl, so goldens were regenerated; the
pre-existing 16 are byte-identical.
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.
linkSharedSymbols guards against linking two repos in different languages that merely share a domain type name. The guard is skipped for identities it considers namespace-qualified, and isQualifiedIdentity counted any dot as qualifying.
By the time it runs, typeIdentity has already stripped the module prefix, so a residual dot means type nesting, not a namespace. Kotlin and Swift both emit nested declarations as "Outer.Inner". Two apps that model the same product in different languages therefore cleared minSharedSymbols on nested names alone, bypassed the guard, and were given a bidirectional depends_on -- a 2-cycle in the service graph, and an edge no parser justifies. traverse, find_path and impact_analysis route through it, and coverage_report overstates each app's outbound edge count.
Replace isQualifiedIdentity with isNamespaceQualified, matching "::" only, at both call sites: the same-language guard and the isDistinctiveIdentity short-circuit. Nested identities are now unqualified, so they fall under the language guard and under the length/generic-name filters.
Coverage:
No cacheVersion bump: linkCrossRepo runs after runExtractors and after the extractor cache is saved, so no extractor output changes. The linker's synthetic facts do land in facts.jsonl, so goldens were regenerated; the pre-existing 16 are byte-identical.