Repository navigation
Shared: Add extractor-common crate for shared extractor code - #23262
Conversation
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
extractor-common crate for shared extractor code
There was a problem hiding this comment.
🟡 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)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 60c30357-9ac7-4fd6-ac9c-f6fc837aa378
tausbn
left a comment
There was a problem hiding this comment.
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. |

This adds a new
extractor-commoncrate inshared/extractor-commonfor 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 ofshared/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_pathsis moved over unchanged and the shared tree-sitter extractor, Ruby, and Rust now import it fromextractor_commondirectly.The Rust extractor still depends on
codeql-extractorfor TRAP, location helpers, and tracing setup. Moving those is left for follow-up work.