Repository navigation
Import graph: build variants, symlinked headers, Dart conditional imports, exact Solidity relative paths - #3743
Merged
Conversation
…rts, solidity exact relatives (#3665, #3660) - Stage 2b of the name search, once the token's own path context has failed: - two paths that are one file on disk (SDWebImage's include/X.h -> Core/X.h) collapse to the real file. Needs the scan root, which galaxyscope now gives the sensor; a token that spells a directory no candidate has stays unmatched. - parallel trees that differ in one directory whose names are all build variants (`scala-2`/`scala-3`, `jvm`/`js`, `scala-2.13+`) take the importer's variant (import contract C8). Sibling modules are not variants and stay ambiguous (#261). `_resolve_path_tail` narrows the same way. - solidity `relative_imports_are_exact`: a `../x.sol` naming no scanned file (a build-generated patched/ tree) draws no edge instead of a basename match. - dart: a conditional import's `if (dart.library.x) 'uri'` alternatives are imports. import_graph_accuracy: objective-c recall 97.3 -> 100.0, dart 95.3 -> 100.0, scala 93.5 -> 94.8, solidity precision 97.1 -> 100.0; no other language moved. Kotlin extension-property imports (#3660) need a declared-property channel and are not in this change. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01GCpfMCUMpco98QGbsuv2sr
…-Ray entropy) The single toolchain alternation literal scored 4.81 Shannon entropy, over the binary anomaly detector's 4.8 threshold for a 64+ char string. Same compiled pattern, assembled from two tuples. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01GCpfMCUMpco98QGbsuv2sr
Contributor
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.
Summary
Fixes #3665. Part of #3660: this covers its Dart, Objective-C and Solidity shapes, but not Kotlin (see below). Part of #3641.
Four import shapes where the resolver drew no edge, or the wrong one.
1. One file behind two paths, a symlink (#3665, #3660 objective-c). In SDWebImage,
include/SDWebImage/X.his a symlink toCore/X.h, so the scan sees both paths.#import "SDWebImageCompat.h"looked ambiguous and drew no edge.realpath) collapse to the real file, not the link.galaxyscopenow gives the sensor (network_sensor.root). Without a root nothing collapses.<SDWebImage/X.h>still names theinclude/path it spells: the collapse only runs after that path matching has failed.<SDWebImage/MKAnnotationView+WebCache.h>names a file that only exists underSDWebImageMapKit/.2. Build variants (#3665, import contract C8). circe has
semiauto.scalaunder bothscala-2/andscala-3/. An importer in ascala-2tree means thescala-2copy._BUILD_VARIANT_DIR):scala-2,scala-2.13+,java11,py3;jvm,js,native,android,ios, …_resolve_path_tail(the Scala package-object path, and Dart'spackage:) narrows the same way.service_a/utils.pyfor an importer inservice_a/, andcobol_src/overcobol_copy/. That's "nearest same-named file", which Dependency Attribution Error duplicate filenames #261 rejected. Sibling modules stay ambiguous, and those cases are now pinned as tests.src/test/scala/) compiles against every variant and still draws no edge.3. Solidity relative paths are exact (#3660).
fv/harnesses/*.solimport../patched/access/AccessControl.sol, which is generated at build time. The name search linked those imports tocontracts/access/AccessControl.sol, a file the import doesn't name. Under the new top-level flagrelative_imports_are_exact(solc's own rule), a relative import naming no scanned file draws no edge.4. Dart conditional imports (#3660). In
import 'stub.dart' if (dart.library.io) 'io_client.dart';the alternatives are real, platform-selected imports._dependency_capturegained a branch for eachif (...) 'uri'that directly follows a closing quote. A collection-ifin code (['a', if (c) 'b']) always has a comma there, so it never matches. The branch is bounded and uses one condition.Not in this PR: Kotlin extension properties (#3660, 17 misses).
import com.squareup.kotlinpoet.metadata.isPrimarynamesinternal val KmConstructor.isPrimary. Declared-name resolution indexes functions and classes, but not properties, because nothing records a file's property names. That needs a new per-file declarations channel, persisted so incremental scans keep it, which is a separate change. #3660 stays open for it.docs/import_rule_contract.mdC8 records how it's implemented.Type of change
gitgalaxy/core/detector.py,language_standards.py,prism.py, or a per-language rule)CI checklist
python tests/tools/audit_check.pypasses (bundles the ruff/mypy/dead-key baseline-gated audits +ruff format --check)python -m pytest tests/passespython tests/tools/crucible_check.pypasses: both fixtures re-blessed, 3 differences (below)python tests/tools/tree_sitter_accuracy_audit.py --all --cipassesMeasurements
import_graph_accuracy.py, all 20 measured languages on the pinned corpus:The other 15 languages are unchanged. The baseline is regenerated.
Nine Scala imports stay ambiguous, correctly: their importers sit in shared
scala/orscala-0/trees that compile against both variants.Golden masters: 3 differences, identical in both modes, all from
dart/flutter/editable_text.dart. Its conditional import's web alternative is now an import. That file isn't in the crucible, so it adds one entry to "Extracted Dependencies" and one to "Direct Upstream", and raises the global firewallimports_unknownby one (10290 → 10291). No mass changes, so there are no layout coordinate changes.keyword-rosetta: 51 languages, 0 regressions.
Differential Scan target
The import-graph corpus repos: circe/circe, SDWebImage/SDWebImage, dart-lang/http, OpenZeppelin/openzeppelin-contracts.
Verification
New test file:
tests/security_auditing/test_import_resolution_3665_3660.py. It covers:_build_variantshape rules, including the sibling-module and COBOL cases that must stay ambiguous;rules(orphaned_logic reports 100% dead code for five languages whose invocation model never names the callee — the family #2727 closed without covering #2806);ifdecoy;🤖 Generated with Claude Code
https://claude.ai/code/session_01GCpfMCUMpco98QGbsuv2sr
Generated by Claude Code