Repository navigation
Single edge crate - #8173
Single edge crate#8173
Conversation
a0dd0e5 to
6b1e6d2
Compare
0d5a2c9 to
f411be3
Compare
ae1b74c to
78a7ce3
Compare
78a7ce3 to
3acad40
Compare
Fix issues that break `qdrant-edge` build process:
- `use … as segment;` - this causes `ast-grep` rules to replace wrong
paths. So, rename to avoid collisions.
- `#[macro_use]` and `extern crate` required be in the top-level
`lib.rs`.
- `format!("…", crate::something::…)` - `ast-grep` can't fix paths
inside macros. Fixed by moving `crate::something::…` out of the macro.
And fix them to use the generated `qdrant-edge` crate.
Removes empty modules. Checked by `cargo doc`.
3acad40 to
e1fb582
Compare
📝 WalkthroughWalkthroughThis PR introduces an automated amalgamation pipeline for the Qdrant Edge library. It adds a GitHub Actions workflow that executes a Python script ( Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (8)
lib/edge/publish/cargo (1)
21-21:os.execvpeis POSIX-only — acceptable for CI but worth documenting.
os.execvpesemantics on Windows differ (does not replace the current process). Since this is a CI/developer utility targeting Linux/macOS, it is fine in practice. Consider adding a brief comment if Windows support is ever anticipated.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@lib/edge/publish/cargo` at line 21, The call to os.execvpe in the cargo script is POSIX-only and behaves differently on Windows (it doesn't replace the current process), so add a brief comment immediately above the os.execvpe("cargo", ["cargo"] + sys.argv[1:], env) call explaining that this utility targets Linux/macOS and that execvpe semantics differ on Windows; mention that if Windows support is needed in future we should either implement a Windows-specific fallback (e.g., using subprocess) or guard the call behind an OS check..github/workflows/edge-rust-package.yml (2)
42-44: Onlycargo checkis run — no tests orcargo build.This validates type-checking but won't catch linker errors (e.g., missing C dependencies, duplicate symbols). If the intent is a build verification, consider upgrading to
cargo build -p examplesfor stronger validation. Fine as-is if this is intentional to keep CI fast.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/edge-rust-package.yml around lines 42 - 44, The workflow step named "Cargo check" only runs type-checking and won't catch build/linker issues; update the step (the "Cargo check" step in the workflow for working-directory lib/edge/publish) to run a full build instead—replace the run command with "cargo build -p examples" (or "cargo build --all" if broader coverage is desired) so CI verifies actual compilation and linking rather than just type checking.
30-31: Consider pinningast-grepversion for reproducible CI.
npm install --global@ast-grep/cli`` installs the latest version, which could introduce breaking changes and non-reproducible builds. Consider pinning:npm install --global@ast-grep/cli`@`.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/edge-rust-package.yml around lines 30 - 31, The CI step named "Install ast-grep" currently runs `npm install --global `@ast-grep/cli`` which installs the latest package; change this to a pinned version by updating that command to `npm install --global `@ast-grep/cli`@<version>` (or reference a workflow variable like AST_GREP_VERSION) so builds are reproducible and immune to upstream breaking changes—update the step that contains the `npm install --global `@ast-grep/cli`` invocation accordingly.lib/edge/publish/amalgamate.py (4)
59-64: Unusedmanifestin loop.The destructured
manifestvariable isn't used in this loop body. Use_to signal intent.Proposed fix
- for pkg, (path, manifest) in packages.items(): + for pkg, (path, _) in packages.items():🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@lib/edge/publish/amalgamate.py` around lines 59 - 64, The loop over packages destructures a second element named manifest that is never used; update the for loop header to ignore it (e.g., change "for pkg, (path, manifest) in packages.items():" to use an underscore like "for pkg, (path, _) in packages.items():") so intent is clear and linter warnings are avoided; keep the loop body using shutil.copytree and os.rename with pkg and path unchanged.
52-56:shutil.rmtreewithignore_errors=Truesilently swallows permission errors.If the amalgamation directory can't be deleted due to permission issues (e.g., files locked by another process), the subsequent
shutil.copytreecalls will fail with a confusing error instead of surfacing the root cause. Consider removingignore_errors=Trueand handlingFileNotFoundErrorexplicitly.Proposed fix
- shutil.rmtree(AMALGAMATION, ignore_errors=True) + if AMALGAMATION.exists(): + shutil.rmtree(AMALGAMATION)🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@lib/edge/publish/amalgamate.py` around lines 52 - 56, The call shutil.rmtree(AMALGAMATION, ignore_errors=True) is hiding permission/other errors and leading to confusing failures later when copy operations run; update main to remove ignore_errors=True, catch FileNotFoundError to treat missing directory as fine, and otherwise let or re-raise permission/OS errors (or log/raise a clear exception) so failures deleting AMALGAMATION are surfaced before subsequent shutil.copytree calls; modify the code paths around shutil.rmtree, AMALGAMATION, and any following shutil.copytree usage accordingly.
239-260:all_file_dependenciesonly traversesdependencies, notbuild-dependenciesordev-dependenciesfor path-based transitive deps.Line 253 only iterates
manifest["dependencies"]. If any included crate has a path-based build- or dev-dependency that is also inPACKAGES_TO_INCLUDE, it won't be discovered here. This may be fine given the current crate graph, but could silently miss crates if the dependency structure changes.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@lib/edge/publish/amalgamate.py` around lines 239 - 260, all_file_dependencies currently only inspects manifest["dependencies"], missing path-based transitive deps declared under "build-dependencies" or "dev-dependencies"; update all_file_dependencies to iterate the three dependency tables ("dependencies", "build-dependencies", "dev-dependencies") (safely handling missing keys or non-dict sections) and apply the same path-based resolution/seen/stack logic used for manifest["dependencies"] so path deps from build or dev sections are discovered and pushed onto the stack just like regular dependencies.
190-198:gather_dependenciesskips optional deps and doesn't merge features — may cause build issues.Line 191 silently skips optional dependencies. If any optional dep is actually needed at runtime (gated behind a default feature), it won't be included in the generated
Cargo.toml. The comment on line 194 acknowledges the feature-merging gap. Both are acceptable for an initial version but could cause subtle build or runtime issues if the dependency graph evolves.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@lib/edge/publish/amalgamate.py` around lines 190 - 198, The gather_dependencies logic currently skips optional deps and overwrites workspace entries without merging features; update gather_dependencies so it does NOT bail out on spec.get("optional") — instead preserve the dependency entry (keeping optional true) and include any feature requirements so optional-but-needed deps get written to Cargo.toml; and when combining a workspace entry with workspace_deps[name], merge feature-related fields rather than simple dict overwrite: for the merge of workspace_deps[name] and spec (the block that sets spec = { **workspace_deps[name], **... }), compute the union of "features" lists (dedupe), reconcile "default-features" (prefer explicit spec value if present), and copy other keys with spec taking precedence—this ensures features from both sides are preserved when building the final spec.lib/edge/publish/ast-grep-rules.yaml (1)
47-57: Minor:drop-anonymize-derivemay leave empty#[derive()]whenAnonymizeis the sole derive.If a struct has
#[derive(Anonymize)]with no other derives, this rule removesAnonymizebut leaves an empty#[derive()]. This compiles but is dead weight. Since the generated crate is gitignored and this is a build artifact, this is acceptable — just flagging for awareness.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@lib/edge/publish/ast-grep-rules.yaml` around lines 47 - 57, The rule drop-anonymize-derive currently removes the Anonymize token inside the #[derive($$$)] but can leave an empty #[derive()]; update the rule (id: drop-anonymize-derive, pattern: "Anonymize", inside: pattern: "#[derive($$$)]") so that when the derive list becomes empty the whole attribute is removed: change the fix to expand the removal to the attribute end (e.g., set expandEnd to ')' or a regex matching the closing paren and optional surrounding whitespace/commas) and keep template: "" so the entire #[derive(...)] (including any leftover empty parens and dangling commas) is deleted instead of leaving #[derive()].
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@lib/edge/publish/amalgamate.py`:
- Around line 235-236: The loop in function/method that iterates "for seen,
(pattern, _) in zip(seen, replacements):" shadows the outer "seen" list and
should be fixed by renaming the loop variable (e.g., to "seen_flag" or "found")
so it doesn't collide with the outer name, updating the assert to reference the
new name (assert seen_flag, f"Pattern {pattern!r} not found"), and make the zip
call use strict=True (zip(seen, replacements, strict=True)) so mismatched
lengths raise immediately.
---
Nitpick comments:
In @.github/workflows/edge-rust-package.yml:
- Around line 42-44: The workflow step named "Cargo check" only runs
type-checking and won't catch build/linker issues; update the step (the "Cargo
check" step in the workflow for working-directory lib/edge/publish) to run a
full build instead—replace the run command with "cargo build -p examples" (or
"cargo build --all" if broader coverage is desired) so CI verifies actual
compilation and linking rather than just type checking.
- Around line 30-31: The CI step named "Install ast-grep" currently runs `npm
install --global `@ast-grep/cli`` which installs the latest package; change this
to a pinned version by updating that command to `npm install --global
`@ast-grep/cli`@<version>` (or reference a workflow variable like
AST_GREP_VERSION) so builds are reproducible and immune to upstream breaking
changes—update the step that contains the `npm install --global `@ast-grep/cli``
invocation accordingly.
In `@lib/edge/publish/amalgamate.py`:
- Around line 59-64: The loop over packages destructures a second element named
manifest that is never used; update the for loop header to ignore it (e.g.,
change "for pkg, (path, manifest) in packages.items():" to use an underscore
like "for pkg, (path, _) in packages.items():") so intent is clear and linter
warnings are avoided; keep the loop body using shutil.copytree and os.rename
with pkg and path unchanged.
- Around line 52-56: The call shutil.rmtree(AMALGAMATION, ignore_errors=True) is
hiding permission/other errors and leading to confusing failures later when copy
operations run; update main to remove ignore_errors=True, catch
FileNotFoundError to treat missing directory as fine, and otherwise let or
re-raise permission/OS errors (or log/raise a clear exception) so failures
deleting AMALGAMATION are surfaced before subsequent shutil.copytree calls;
modify the code paths around shutil.rmtree, AMALGAMATION, and any following
shutil.copytree usage accordingly.
- Around line 239-260: all_file_dependencies currently only inspects
manifest["dependencies"], missing path-based transitive deps declared under
"build-dependencies" or "dev-dependencies"; update all_file_dependencies to
iterate the three dependency tables ("dependencies", "build-dependencies",
"dev-dependencies") (safely handling missing keys or non-dict sections) and
apply the same path-based resolution/seen/stack logic used for
manifest["dependencies"] so path deps from build or dev sections are discovered
and pushed onto the stack just like regular dependencies.
- Around line 190-198: The gather_dependencies logic currently skips optional
deps and overwrites workspace entries without merging features; update
gather_dependencies so it does NOT bail out on spec.get("optional") — instead
preserve the dependency entry (keeping optional true) and include any feature
requirements so optional-but-needed deps get written to Cargo.toml; and when
combining a workspace entry with workspace_deps[name], merge feature-related
fields rather than simple dict overwrite: for the merge of workspace_deps[name]
and spec (the block that sets spec = { **workspace_deps[name], **... }), compute
the union of "features" lists (dedupe), reconcile "default-features" (prefer
explicit spec value if present), and copy other keys with spec taking
precedence—this ensures features from both sides are preserved when building the
final spec.
In `@lib/edge/publish/ast-grep-rules.yaml`:
- Around line 47-57: The rule drop-anonymize-derive currently removes the
Anonymize token inside the #[derive($$$)] but can leave an empty #[derive()];
update the rule (id: drop-anonymize-derive, pattern: "Anonymize", inside:
pattern: "#[derive($$$)]") so that when the derive list becomes empty the whole
attribute is removed: change the fix to expand the removal to the attribute end
(e.g., set expandEnd to ')' or a regex matching the closing paren and optional
surrounding whitespace/commas) and keep template: "" so the entire
#[derive(...)] (including any leftover empty parens and dangling commas) is
deleted instead of leaving #[derive()].
In `@lib/edge/publish/cargo`:
- Line 21: The call to os.execvpe in the cargo script is POSIX-only and behaves
differently on Windows (it doesn't replace the current process), so add a brief
comment immediately above the os.execvpe("cargo", ["cargo"] + sys.argv[1:], env)
call explaining that this utility targets Linux/macOS and that execvpe semantics
differ on Windows; mention that if Windows support is needed in future we should
either implement a Windows-specific fallback (e.g., using subprocess) or guard
the call behind an OS check.
* Fixups of amalgamator
Fix issues that break `qdrant-edge` build process:
- `use … as segment;` - this causes `ast-grep` rules to replace wrong
paths. So, rename to avoid collisions.
- `#[macro_use]` and `extern crate` required be in the top-level
`lib.rs`.
- `format!("…", crate::something::…)` - `ast-grep` can't fix paths
inside macros. Fixed by moving `crate::something::…` out of the macro.
* Add lib/edge/publish workspace and amalgamation script
* Move `lib/edge/examples` into `lib/edge/publish/` workspace
And fix them to use the generated `qdrant-edge` crate.
* Add github workflow
* Cleanup `qdrant-edge` public API
Removes empty modules. Checked by `cargo doc`.
* Fixups of amalgamator
Fix issues that break `qdrant-edge` build process:
- `use … as segment;` - this causes `ast-grep` rules to replace wrong
paths. So, rename to avoid collisions.
- `#[macro_use]` and `extern crate` required be in the top-level
`lib.rs`.
- `format!("…", crate::something::…)` - `ast-grep` can't fix paths
inside macros. Fixed by moving `crate::something::…` out of the macro.
* Add lib/edge/publish workspace and amalgamation script
* Move `lib/edge/examples` into `lib/edge/publish/` workspace
And fix them to use the generated `qdrant-edge` crate.
* Add github workflow
* Cleanup `qdrant-edge` public API
Removes empty modules. Checked by `cargo doc`.
Depends on #8185.
This PR is a step towards publishing
qdrant-edgeatcrates.io.It adds script
amalgamate.py(name coined by the SQLite Amalgamation) that combines 10 crates into a singleqdrant-edgecrate. This script fixes module paths usingast-grepand regexes. Also, it removes#[derive(Anonymize)]so we do not need to publish a separate proc-macro crate. Now, the only remaining non-crates.iodependency is https://github.com/qdrant/rust-stemmers.Also, a GitHub workflow is added to check whether the generated crate is buildable.
Structure
Everything significant is placed in a new directory
lib/edge/publishthat contains:examplesRust package (was inlib/edge/examples)qdrant-edgeRust package (autogenerated, gitignored)Cargo.lock(gitignored))amalgamate.py- script to generateqdrant-edge.