fix(aft-bridge): align PATH defaults to plugin#127
Conversation
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
There was a problem hiding this comment.
2 issues found across 3 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="crates/aft/src/cli/warmup.rs">
<violation number="1" location="crates/aft/src/cli/warmup.rs:294">
P1: Hardcoded ONNX Runtime version string can drift from the actual cached ORT version and break semantic warmup.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| } else { | ||
| "libonnxruntime.so" | ||
| }; | ||
| let ort_dir = storage_dir.join("onnxruntime").join("1.24.4"); |
There was a problem hiding this comment.
P1: Hardcoded ONNX Runtime version string can drift from the actual cached ORT version and break semantic warmup.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At crates/aft/src/cli/warmup.rs, line 294:
<comment>Hardcoded ONNX Runtime version string can drift from the actual cached ORT version and break semantic warmup.</comment>
<file context>
@@ -248,11 +254,50 @@ fn warmup_storage_dir() -> PathBuf {
+ } else {
+ "libonnxruntime.so"
+ };
+ let ort_dir = storage_dir.join("onnxruntime").join("1.24.4");
+ for candidate in [ort_dir.join(lib_name), ort_dir.join("lib").join(lib_name)] {
+ if candidate.is_file() {
</file context>
There was a problem hiding this comment.
Pre-existing pattern! The plugin side already pins 1.24.4 in two separate files (onnx-runtime.ts, onnx.ts). The Rust string is a third copy. Cross-language constant sync would require build-time codegen, which is out of scope for this fix.
a3b71fb to
dc0dae5
Compare
| let ort_dir = storage_dir.join("onnxruntime").join("1.24.4"); | ||
| for candidate in [ort_dir.join(lib_name), ort_dir.join("lib").join(lib_name)] { | ||
| if candidate.is_file() { | ||
| std::env::set_var("ORT_DYLIB_PATH", &candidate); | ||
| break; | ||
| } | ||
| } |
There was a problem hiding this comment.
Silent no-op when library not cached
try_set_ort_dylib_path returns without setting ORT_DYLIB_PATH (and without any diagnostic) if neither candidate path exists. The subsequent configure call will then hit the same dlopen failure this fix is meant to prevent, with no indication of why. A user who hasn't yet run the plugin (so the library was never downloaded) will see the exact same opaque error as before. At minimum, an eprintln! warning pointing to the expected path would help with diagnosis.
| } else { | ||
| "libonnxruntime.so" | ||
| }; | ||
| let ort_dir = storage_dir.join("onnxruntime").join("1.24.4"); |
There was a problem hiding this comment.
The version string
"1.24.4" is hardcoded in the library probe path. When the plugin upgrades its ONNX Runtime cache (e.g. onnxruntime/1.25.0/), try_set_ort_dylib_path will silently find nothing and ORT_DYLIB_PATH will remain unset. Given the PR description already acknowledges this, consider at least making it a named constant so there is a single place to update.
| let ort_dir = storage_dir.join("onnxruntime").join("1.24.4"); | |
| const ORT_VERSION: &str = "1.24.4"; | |
| let ort_dir = storage_dir.join("onnxruntime").join(ORT_VERSION); |
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
dc0dae5 to
f984b57
Compare
…_DYLIB_PATH in warmup
Three functions defaulted to ~/.cache/aft instead of the plugin's
~/.local/share/cortexkit/aft, causing standalone `aft warmup` to
write to a different path than the plugin. Fallback now mirrors
resolveCortexKitStorageRoot() from the TS plugin (XDG_DATA_HOME,
Windows LOCALAPPDATA/APPDATA, ~/.local/share/cortexkit/aft).
warmup.rs also never set ORT_DYLIB_PATH, so semantic index warmup
failed with dlopen('libonnxruntime.so'). Now resolves the cached
library from <storage_dir>/onnxruntime/1.24.4/ (and lib/ subdir)
if ORT_DYLIB_PATH is not already set.
f984b57 to
a058506
Compare
Fixes #128
What is this about?
Three functions defaulted to
~/.cache/aftinstead of the plugin's~/.local/share/cortexkit/aft, causing standaloneaft warmupto write to a different path than the plugin. The fallback now mirrorsresolveCortexKitStorageRoot()from the plugin.warmup.rsalso never setORT_DYLIB_PATH, so semantic index warmup failed withdlopen('libonnxruntime.so'). Now resolves the cached library from<storage_dir>/onnxruntime/1.24.4/(andlib/subdir) ifORT_DYLIB_PATHis not already set.Hint
Currently, the version of onnxruntime was hardcoded, so I didn't change this.
Need help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.Summary by cubic
Aligns standalone storage defaults with the plugin so both use the same
cortexkit/aftpath, and fixes semantic warmup by auto-settingORT_DYLIB_PATHfrom the cached ONNX Runtime to avoid dlopen errors.resolveCortexKitStorageRoot(): preferXDG_DATA_HOME; on Windows useLOCALAPPDATA/APPDATA; else~/.local/share/cortexkit/aft(Windows:AppData/Local/cortexkit/aft). Applied inbash_background::storage_dir,warmup_storage_dir, andsearch_index::resolve_cache_dir.aft warmup --semanticnow setsORT_DYLIB_PATHif unset by locating the cached library under<storage_dir>/onnxruntime/1.24.4/(also checkslib/). Preventsdlopen('libonnxruntime.*')/missing DLL errors.Written for commit a058506. Summary will update on new commits.
Greptile Summary
Aligns the storage path fallback in three independent functions (
bash_background::storage_dir,warmup_storage_dir,search_index::resolve_cache_dir) from the old~/.cache/aftto~/.local/share/cortexkit/aft, mirroringresolveCortexKitStorageRoot()from the TS plugin. Additionally addstry_set_ort_dylib_pathto auto-detect the cached ONNX Runtime dylib beforeconfigure()runs, fixing thedlopenfailure for standaloneaft warmup --semantic.try_set_ort_dylib_pathchecks two candidate paths under<storage_dir>/onnxruntime/1.24.4/(root andlib/subdir) and setsORT_DYLIB_PATHwhen found; it silently no-ops if the library is absent or the env var is already set.Confidence Score: 5/5
Safe to merge; the path-alignment changes are mechanical and consistent across all three sites, and the new ONNX probe is additive with a correct early-exit guard.
All three fallback rewrites produce identical path logic and match the TS plugin's documented convention. The
try_set_ort_dylib_pathaddition is additive: it guards onORT_DYLIB_PATHalready being set, only touches the env beforeconfigure()runs, and has a unit test covering the happy path. The remaining concerns (silent no-op on missing library, hardcoded ONNX version, duplicated resolution block) are already tracked in prior review threads or are purely maintenance-oriented.No files require special attention beyond what is already covered in prior review threads on
warmup.rs.Important Files Changed
try_set_ort_dylib_path(probes two candidate paths, setsORT_DYLIB_PATH) and updateswarmup_storage_dirto the new XDG/Windows fallback chain; hardcoded version "1.24.4" and silent no-op when library is absent are previously-flagged concerns.~/.cache/aftto~/.local/share/cortexkit/aft; logic is correct and mirrors the other two functions exactly.resolve_cache_dirupdated to the new storage root; appends/index/<key>consistently with the configured-path branch, no logic regressions.Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A([storage_dir / warmup_storage_dir / resolve_cache_dir]) --> B{configured / AFT_STORAGE_DIR\nAFT_CACHE_DIR set?} B -->|Yes| C[Return override path] B -->|No| D{XDG_DATA_HOME set?\n all platforms} D -->|Yes| E["Return XDG_DATA_HOME/cortexkit/aft"] D -->|No| F{Windows build?} F -->|Yes| G{LOCALAPPDATA or\nAPPDATA set?} G -->|Yes| H["Return dir/cortexkit/aft"] G -->|No| I["Return USERPROFILE or HOME\n/AppData/Local/cortexkit/aft"] F -->|No| J["Return HOME/.local/share/cortexkit/aft"] K([try_set_ort_dylib_path]) --> L{ORT_DYLIB_PATH\nalready set?} L -->|Yes| M[Return early — no-op] L -->|No| N["Probe storage_dir/onnxruntime/1.24.4/lib"] N --> O{Root path\nexists?} O -->|Yes| P[set_var ORT_DYLIB_PATH] O -->|No| Q["Probe .../lib/lib"] Q --> R{lib/ path\nexists?} R -->|Yes| P R -->|No| S["Silent return - ORT_DYLIB_PATH unset"]%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%% flowchart TD A([storage_dir / warmup_storage_dir / resolve_cache_dir]) --> B{configured / AFT_STORAGE_DIR\nAFT_CACHE_DIR set?} B -->|Yes| C[Return override path] B -->|No| D{XDG_DATA_HOME set?\n all platforms} D -->|Yes| E["Return XDG_DATA_HOME/cortexkit/aft"] D -->|No| F{Windows build?} F -->|Yes| G{LOCALAPPDATA or\nAPPDATA set?} G -->|Yes| H["Return dir/cortexkit/aft"] G -->|No| I["Return USERPROFILE or HOME\n/AppData/Local/cortexkit/aft"] F -->|No| J["Return HOME/.local/share/cortexkit/aft"] K([try_set_ort_dylib_path]) --> L{ORT_DYLIB_PATH\nalready set?} L -->|Yes| M[Return early — no-op] L -->|No| N["Probe storage_dir/onnxruntime/1.24.4/lib"] N --> O{Root path\nexists?} O -->|Yes| P[set_var ORT_DYLIB_PATH] O -->|No| Q["Probe .../lib/lib"] Q --> R{lib/ path\nexists?} R -->|Yes| P R -->|No| S["Silent return - ORT_DYLIB_PATH unset"]Reviews (3): Last reviewed commit: "fix: align standalone storage dir fallba..." | Re-trigger Greptile