fix(embed): extract macOS ONNX Runtime tarballs (./ prefix)#24
Conversation
`openmemory model download` shipped in v0.3.2 with bundled ONNX Runtime install. The tar extractor matched entries by string prefix against `<archive_root>/lib/`, but macOS ONNX Runtime tarballs prefix every entry with `./` while Linux ones do not, so on macOS the matcher dropped every entry. The install dir ended up empty, `ensure_dylib_symlink` then wrote a broken `libonnxruntime.dylib` symlink, and the post-check fired with `extraction completed but ...libonnxruntime.1.20.0.dylib is missing`. `extract_lib_subtree` now strips a leading `./` from each entry before comparing the prefix. `ensure_dylib_symlink` switches its "already installed?" check from `Path::exists` (which follows symlinks and reports false for a broken one) to `Path::symlink_metadata`, so a broken symlink left over from a prior failed run no longer poisons retries with EEXIST. Two new tests build synthetic tarballs that mirror the upstream Linux and macOS layouts (real versioned dylib + unversioned symlink in `lib/`, unrelated entry in `include/`) and assert that both extract correctly and the include subtree is skipped. A third test pre-seeds a broken symlink and confirms `ensure_dylib_symlink` is a no-op rather than a hard error. Verified end-to-end on macOS by running `openmemory model download` into a clean home directory: 25 MB versioned dylib, dSYM, and unversioned symlink all land under `<home>/runtime/onnxruntime-osx-arm64-1.20.0/lib/`. Linux remains unaffected because the new matcher is a strict superset of the old (strip `./` if present, otherwise leave the path unchanged); the new Linux-style test guards against regression. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Warning
|
| Layer / File(s) | Summary |
|---|---|
Tar extraction and symlink robustness improvements crates/openmemory-embed/src/runtime.rs |
extract_lib_subtree strips leading ./ from tar entry paths before prefix matching; ensure_dylib_symlink uses symlink_metadata() to detect symlink presence and permit retries with broken symlinks. |
Regression tests and test infrastructure crates/openmemory-embed/src/runtime.rs |
build_fake_tarball helper constructs synthetic ONNX Runtime tarballs with configurable prefixes; new tests cover macOS ./-prefixed extraction, Linux extraction, and symlink recovery from missing targets. |
Changelog documentation CHANGELOG.md |
Fixed section documents the macOS path normalization, symlink robustness change, and synthetic tarball test coverage. |
Possibly Related PRs
- raymondj99/openmemory#20: Introduces the ONNX Runtime extraction and symlink installation logic that this PR refines with macOS
./prefix handling and symlink metadata robustness.
Estimated Code Review Effort
🎯 2 (Simple) | ⏱️ ~12 minutes
Poem
🐰 A tarball comes from macOS bright,
With./prefixes, oh what a sight!
Symlinks once broken now pass the test,
Extract and retry—no more unrest.
The rabbit hops on, fixes complete! ✨
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check | ✅ Passed | The title directly matches the primary fix: enabling extraction of macOS ONNX Runtime tarballs by handling the ./ prefix issue. |
| Docstring Coverage | ✅ Passed | Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. |
| Linked Issues check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ Finishing Touches
📝 Generate docstrings
- Create stacked PR
- Commit on current branch
🧪 Generate unit tests (beta)
- Create PR with unit tests
- Commit unit tests in branch
fix/macos-ort-extraction
Comment @coderabbitai help to get the list of available commands and usage tips.
Summary
extract_lib_subtreenow strips a leading./from each tar entry path before matching the prefix. macOS ONNX Runtime tarballs (onnxruntime-osx-*-1.20.0.tgz) prefix every entry with./, Linux tarballs do not — so the original matcher dropped every macOS entry, left the install dir empty, and failed withextraction completed but ...libonnxruntime.1.20.0.dylib is missing.ensure_dylib_symlinknow usesPath::symlink_metadatainstead ofPath::exists. The old check followed the symlink, so a broken symlink left by a prior failed run looked absent; the retry then crashed withcreating symlink ...: File exists (os error 17).crates/openmemory-embed/src/runtime.rsbuild synthetic tarballs mirroring the upstream Linux and macOS layouts and assert correct extraction. A third test pre-seeds a broken symlink and confirmsensure_dylib_symlinkis a no-op.Repro (before this PR)
After this PR
End-to-end
openmemory_search mode=vectorround-trip works:ortloads the dylib (Loaded ONNX Runtime dylib with version '1.20.0'), embeddings active, semantic recall returns a 0.61-similarity match between"fast canine over slothful canid"and"the quick brown fox jumps over the lazy dog".Test plan
cargo test -p openmemory-embed --lib runtime::— 7/7 pass (including 3 new tests)cargo test --workspace— all suites greencargo clippy --workspace --all-targets -- -D warnings(default +--no-default-features)cargo fmt --all -- --checkcargo doc --workspace --no-deps(default +--all-features)rm -rf /tmp/home && openmemory --home /tmp/home model download→ 25 MB versioned dylib + dSYM + symlink extracted; subsequentopenmemory_search mode=vectorworksstrip_prefix("./").unwrap_or(s)); theextracts_linux_style_tarball_without_dot_slash_prefixtest guards against regression and CI's Ubuntu job exercises the full integration🤖 Generated with Claude Code
Summary by CodeRabbit