Skip to content

Shared: Add extractor-common crate for shared extractor code - #23262

Merged
paldepind merged 4 commits into
mainfrom
shared-rust-library
Nov 26, 2026
Merged

paldepind merged 4 commits into
mainfrom
shared-rust-library

Conversation

@paldepind

@paldepind paldepind commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

This adds a new extractor-common crate in shared/extractor-common for code that is shared between the Rust-based extractors but isn't related to tree-sitter. The idea is to gradually move such code out of shared/tree-sitter-extractor (codeql-extractor), so that extractors not using tree-sitter, like the Rust extractor, don't have to depend on it.

As a first step, file_paths is moved over unchanged and the shared tree-sitter extractor, Ruby, and Rust now import it from extractor_common directly.

The Rust extractor still depends on codeql-extractor for TRAP, location helpers, and tracing setup. Moving those is left for follow-up work.

paldepind and others added 3 commits November 26, 2026 13:44
Add a crate for parser-independent functionality that is shared across
the Rust-based extractors, so that such functionality does not have to
live in the tree-sitter-specific `codeql-extractor` crate.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 60c30357-9ac7-4fd6-ac9c-f6fc837aa378
Move the `file_paths` module, which does not depend on tree-sitter, from
`codeql-extractor` to the new `extractor-common` crate and update all
extractors that use it.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 60c30357-9ac7-4fd6-ac9c-f6fc837aa378
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 60c30357-9ac7-4fd6-ac9c-f6fc837aa378
@github-actions github-actions Bot added documentation Ruby QL-for-QL Rust Pull requests that update Rust code labels Nov 26, 2026
@paldepind paldepind changed the title Shared: Add extractor-common crate Shared: Add extractor-common crate for shared extractor code Nov 26, 2026
@paldepind
paldepind requested an adaptive review from Copilot November 26, 2026 13:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The change leaves an active moderate issue because the Ruby extractor cache key omits shared extractor-common sources and relevant Cargo manifests, allowing stale binaries to be reused after those files change.

1 open issue
What changed in this PR

Adds a parser-independent extractor-common Rust crate and moves shared file_paths utilities out of codeql-extractor, allowing the tree-sitter, Ruby, and Rust extractors to depend on them directly.

Changes:

  • Creates the new Cargo/Bazel crate with shared path utilities and tests.
  • Updates extractor imports, dependencies, workspace metadata, lockfiles, and Bazel mappings.
  • Updates CI path filters, checks, and extractor build-cache configuration.
File Description
shared/​tree-sitter-extractor/​src/​lib.rs Removes the former local file_paths module export.
shared/​tree-sitter-extractor/​src/​extractor/​mod.rs Imports shared path utilities from extractor-common.
shared/​tree-sitter-extractor/​src/​extractor/​driver.rs Updates path utility calls to use the shared crate.
shared/​tree-sitter-extractor/​Cargo.toml Adds the extractor-common dependency.
shared/​tree-sitter-extractor/​BUILD.bazel Adds the Bazel dependency on extractor-common.
shared/​extractor-common/​src/​lib.rs Defines the new shared utility crate module.
shared/​extractor-common/​src/​file_paths.rs Provides shared path normalization, transformation, and archive utilities with tests.
shared/​extractor-common/​README.md Documents the purpose and usage of the new crate.
shared/​extractor-common/​Cargo.toml Defines the new Cargo package.
shared/​extractor-common/​BUILD.bazel Defines the Bazel Rust library target for the new crate.
rust/​extractor/​src/​trap.rs Switches Rust trap generation to the shared path utilities.
rust/​extractor/​src/​archive.rs Switches Rust source archiving to the shared path utilities.
rust/​extractor/​Cargo.toml Adds the extractor-common dependency.
rust/​extractor/​BUILD.bazel Adds the Bazel dependency on the shared crate.
ruby/​extractor/​src/​extractor.rs Switches Ruby extraction and path transformation to the shared utilities.
ruby/​extractor/​Cargo.toml Adds the extractor-common dependency.
ruby/​extractor/​BUILD.bazel Adds the Bazel dependency on the shared crate.
misc/​bazel/​3rdparty/​rust_workspace_deps/​crates.bzl Registers the new workspace crate with Bazel dependency metadata.
Cargo.toml Adds shared/extractor-common to the Rust workspace.
Cargo.lock Records the new workspace package and dependency relationships.
.github/​workflows/​tree-sitter-extractor-test.yml Includes the new crate in CI path triggers and Rust checks.
.github/​workflows/​ql-for-ql-build.yml Updates the extractor build-cache key to include shared extractor sources.

Review effort: Lite (adaptive)

Comment thread ruby/extractor/Cargo.toml Resolved
@paldepind
paldepind marked this pull request as ready for review November 26, 2026 13:52
@paldepind
paldepind requested review from a team as code owners November 26, 2026 13:52
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 60c30357-9ac7-4fd6-ac9c-f6fc837aa378

@tausbn tausbn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This looks reasonable to me. For the CI integration, I'm wondering if this would need changes to the internal workflows.

@paldepind

Copy link
Copy Markdown
Contributor Author

This looks reasonable to me. For the CI integration, I'm wondering if this would need changes to the internal workflows.

Good point. I'll check and see.

@paldepind
paldepind merged commit 43fb30b into main Nov 26, 2026
102 checks passed
@paldepind
paldepind deleted the shared-rust-library branch November 26, 2026 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation QL-for-QL Ruby Rust Pull requests that update Rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants