Repository navigation
fix(memory): download ONNX Runtime from NuGet when GitHub returns 404 - #38
Open
MasterErik wants to merge 1 commit into
Open
MasterErik wants to merge 1 commit into
MasterErik wants to merge 1 commit into
Conversation
microsoft/onnxruntime was removed from GitHub in November 2026, so the release URL baked into ensure_ort_dll() returns 404 and the ONNX embedding models (bge-small, jina-code-v2, granite-97m) cannot start: VectorEngine initialization fails in MemoryManager::initialize and semantic search silently degrades to name matching while embedding_status still claims the embeddings are "building in the background". Keep the GitHub release zip as the primary source, and retry the same ORT_VERSION from the Microsoft.ML.OnnxRuntime nupkg, extracting runtimes/win-x64/native/onnxruntime.dll into the existing cache path. Extraction is split into extract_member_from_zip() so member lookup and its diagnostic can be tested without network access; two unit tests cover the extraction and the missing-member case. CHANGELOG gets an [Unreleased] entry. Verified on Windows 11 x64 with the cache emptied: the server downloaded the nupkg itself, cached onnxruntime.dll (11,567,648 bytes, sha256 52f8ebe8f08f369a44fed6d1cb680c7c89169795e1c2949ee25b88b538ef0948), then reported "Saved 714 symbol vectors ... model=BGE-Small-EN-v1.5 (384d, 512-tok context)" and symbol_search answered match_reason "Semantic".
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
Windows builds cannot start the ONNX embedding models.
microsoft/onnxruntimewasremoved from GitHub in mid-November 2026, so the release URL baked into
ensure_ort_dll()now returns 404:The vector engine dies in
MemoryManager::initialize, sosymbol_searchsilentlydegrades to name matching while
embedding_statusstill reports "Embeddings arebuilding in the background" — a message that is never true. Structural tools keep
working, which makes the failure easy to miss.
This change adds a NuGet fallback: when the GitHub download fails for any reason,
the same
ORT_VERSIONis fetched fromMicrosoft.ML.OnnxRuntimeandruntimes/win-x64/native/onnxruntime.dllis extracted into the existing cache path.Motivation
Semantic search is the main reason to run the engine, and on Windows it is dead
until someone places
onnxruntime.dllby hand. Every Windows user who enablesbge-small(the default),jina-code-v2orgranite-97mhits this. NuGet stillserves the identical binaries and is the fallback other projects adopted after the
repository was removed.
Changes
ensure_ort_dll()keeps the GitHub release zip as the primary source and retriesfrom
https://api.nuget.org/v3-flatcontainer/microsoft.ml.onnxruntime/{ORT_VERSION}/microsoft.ml.onnxruntime.{ORT_VERSION}.nupkgon failure, logging the GitHub error at
warnlevel instead of aborting.extract_member_from_zip(), so member lookup and theerror text are testable without network access;
extract_zip_member()keeps thedownload and temp-file cleanup.
extracts_the_requested_member_only— builds a small archive, extracts onemember, asserts the bytes and that the other entry is ignored;
missing_member_is_an_error— asserts the diagnostic for a missing member.CHANGELOG.md: entry under[Unreleased].No new dependencies:
ureqandzipare already dependencies of this crate onWindows. Everything is inside
#[cfg(target_os = "windows")], so macOS and Linuxbuilds are unaffected.
Why the same version, and why NuGet
The NuGet package carries the same binaries that used to ship in the GitHub release
archive. Reusing
ORT_VERSIONfor both sources keeps the DLL in lockstep with theortcrate version pinned by fastembed — mixing ONNX Runtime versions is a muchworse failure mode than a 404. A DLL already present next to the executable or in
~/.codegraph/fastembed_cache/ort/is still preferred, so working installs are nottouched.
Testing
Verified on Windows 11, x86_64-pc-windows-msvc, rustc 1.94.1 (the repo toolchain):
rustfmt --checkon the touched file — clean.cargo clippy -p codegraph-memory --all-targets— no warnings from the changedcode (the two reported lints are pre-existing, in
src/docs.rs).cargo build --release -p codegraph-server— succeeds.downloaded the nupkg itself, extracted
onnxruntime.dll(11,567,648 bytes, sha256
52f8ebe8f08f369a44fed6d1cb680c7c89169795e1c2949ee25b88b538ef0948),logged
Saved 714 symbol vectors … model=BGE-Small-EN-v1.5 (384d, 512-tok context),and
symbol_searchansweredmatch_reason: "Semantic"(11 ms).initialize+tools/list0.93 s, 42tools listed.
Caveat, stated openly:
cargo test -p codegraph-memory --libcannot LINK on thismachine —
LNK2005: … already defined in libcpmt.lib(static/dynamic CRT mix inthe memory crate's test binary). The same failure reproduces on the unmodified
tree (
git stash→ same error), so it is a pre-existing MSVC environment issue,not a regression from this change. The new tests are therefore expected to run in
CI rather than locally.
CodeGraph PR review (self-check)
Generated with the repository's own tooling (
--graph-only --run-tool codegraph_pr_context):Reading that honestly: the "0 functions" and "0 tests cover the changes" lines are
limitations of the graph diff — the changed functions are
ensure_ort_dll()and thenew
extract_member_from_zip(), and the change does add tests. Risk is rated lowbecause the edit is confined to one Windows-only code path.
Notes for the maintainer
that is still maintained; GitHub first keeps the upstream archive authoritative if
it ever comes back.
pin it.
ORT_VERSIONis unchanged, so stored vectors stay valid.