Skip to content

Conversation

geoffw0
Copy link
Contributor

@geoffw0 geoffw0 commented Aug 27, 2025

Remove extractor path resolution. The following has been removed:

  • path resolution logic in the extractor.
  • path resolution option in the extractor.
  • Resolvable from the dbscheme (i.e. getResolvedCrateOrigin(), getResolvedPath()).
  • Addressable.getExtendedCanonicalPath() and Addressable.getCrateOrigin() methods from the dbscheme.
    • Addressable itself remains.

TODO:

  • get CI green (I haven't run all tests locally).
  • can we remove Addressable from the dbscheme? The QL computed getCanonicalPath() is built on top of it, but it might be possible to define this class in QL now perhaps?
    • we don't want to do this, see below.
  • can we remove PathAstNode from the dbscheme?
    • we think it's unused, but my first attempt to remove it failed. I'm a bit fuzzy on what it represents.
    • second attempt also failed. It is used.
  • remove redundant tests (if any).
  • early code review, in particular have I missed anything that should be removed? (@redsun82).
  • DCA run.
  • QA run.
  • change note.
  • upgrade and downgrade scripts.
    • test upgrade and downgrade scripts manually.
  • final code review.

@geoffw0 geoffw0 added the Rust Pull requests that update Rust code label Aug 27, 2025
Copy link
Contributor

@redsun82 redsun82 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM so far, love to see so much red removed lines in this PR!

As I mentioned, you can also remove all the empty emission trait implementations if you remove those entities from the special emission list in ast-generator. Other than that (and the PathAstNode thing you are already aware of), I don't think there's anything else to clean.

Addressable could be done in QL, but I think it's better to leave it in the schema, because that allows to generate the inheritance. You could even add canonical_path: optional[string] | synth there, which would give you hasCanonicalPath for free.

@geoffw0
Copy link
Contributor Author

geoffw0 commented Aug 28, 2025

Other than that (and the PathAstNode thing you are already aware of), I don't think there's anything else to clean.

It appears PathAstNode is used as a base class for PathExpr, providing getPath() which is used in several, I think critical, places in QL. So I don't think we can remove PathAstNode after all. I have removed the (unrelated?) PathAst trait, previously used in extract_path_canonical_destination, that is now unused.

I am still a bit fuzzy on what PathAstNode represents - is this a computed path from Rust Analyzer, or a direct syntactic element we extract?

I also notice we're still calling rust_analyzer.parse in the extractor. I assume with path resolution off we're asking it to do work for us, but less, it's still required for other tasks such as macro resolution?

@geoffw0
Copy link
Contributor Author

geoffw0 commented Aug 29, 2025

I've added the upgrade and downgrade scripts. Note that the downgrade scripts just generate empty tables, this has been discussed and is expected to work well enough in realistic use cases (since we haven't been using extractor generated paths widely for some time now). We're also happy that PathAstNode stays and that the rust analyzer is still used for macro call resolution.

@geoffw0
Copy link
Contributor Author

geoffw0 commented Aug 29, 2025

  • CI is green.
  • upgrade + downgrade scripts tested locally (bit of a pain to get this working, it appears .qlref tests don't reliably trigger the upgrade / downgrade process).
  • ready for final code review.

As well as the final code review we need to review the QA run (when it finishes) and probably have another try at getting a clean DCA run. I'm away next week, I think at this point it's just going to have to wait...

@geoffw0 geoffw0 marked this pull request as ready for review August 29, 2025 17:05
@geoffw0 geoffw0 requested a review from a team as a code owner August 29, 2025 17:05
@Copilot Copilot AI review requested due to automatic review settings August 29, 2025 17:05
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR removes extractor-generated path resolution from the Rust implementation, completing the transition to CodeQL-computed paths. The change improves extraction performance and reliability by eliminating complex path resolution logic from the extractor.

Key changes:

  • Removes all extractor path resolution logic and configuration options
  • Removes Resolvable and related functionality from the database schema
  • Removes test suites for disabled path resolution
  • Updates upgrade/downgrade scripts to handle schema changes

Reviewed Changes

Copilot reviewed 29 out of 93 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
rust/schema/prelude.py Removes Resolvable class and path-related fields from Addressable
rust/schema/annotations.py Removes Resolvable base class from MethodCallExpr
rust/ql/lib/rust.dbscheme Updates database schema removing path resolution tables
rust/extractor/src/translate/mappings.rs Removes path resolution trait implementations
rust/extractor/src/translate/generated.rs Removes path resolution emission logic
rust/extractor/src/translate/base.rs Removes path resolution functionality
rust/extractor/src/main.rs Removes path resolution configuration
rust/extractor/src/config.rs Removes skip_path_resolution option
rust/codeql-extractor.yml Removes path resolution configuration
rust/ql/test/extractor-tests/canonical_path_disabled/ Removes test directory for disabled path resolution
rust/ql/src/queries/telemetry/RustAnalyzerComparison.qll Removes path resolution comparison telemetry

Comment on lines +3 to +6
addressable_extended_canonical_paths.rel: delete
addressable_crate_origins.rel: delete
resolvable_resolved_paths.rel: delete
resolvable_resolved_crate_origins.rel: delete
Copy link
Preview

Copilot AI Aug 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The upgrade script properly handles deletion of the removed database relations. Ensure the corresponding downgrade script properly handles recreation or provides appropriate error handling for partial compatibility.

Suggested change
addressable_extended_canonical_paths.rel: delete
addressable_crate_origins.rel: delete
resolvable_resolved_paths.rel: delete
resolvable_resolved_crate_origins.rel: delete
resolvable_resolved_crate_origins.rel: delete
description: Downgrade after removing extractor generated paths. The following relations were deleted in the upgrade and cannot be automatically restored: addressable_extended_canonical_paths, addressable_crate_origins, resolvable_resolved_paths, resolvable_resolved_crate_origins.
compatibility: partial
# The following relations were deleted in the upgrade and cannot be recreated automatically.
# If you need to downgrade, you may need to restore these relations from a backup or regenerate them.

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Rust Pull requests that update Rust code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants