Skip to content

fix(aft-bridge): align PATH defaults to plugin#127

Open
tobwen wants to merge 1 commit into
cortexkit:mainfrom
tobwen:fix/standalone-storage-defaults
Open

fix(aft-bridge): align PATH defaults to plugin#127
tobwen wants to merge 1 commit into
cortexkit:mainfrom
tobwen:fix/standalone-storage-defaults

Conversation

@tobwen

@tobwen tobwen commented Jun 19, 2026

Copy link
Copy Markdown

Fixes #128

What is this about?

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. The fallback now mirrors resolveCortexKitStorageRoot() from the plugin.

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.

Hint

Currently, the version of onnxruntime was hardcoded, so I didn't change this.


View with Codesmith Autofix with Codesmith
Need help on this PR? Tag /codesmith with what you need. Autofix is disabled.


Summary by cubic

Aligns standalone AFT storage defaults with the plugin so both use the same cortexkit/aft path, and fixes aft warmup by auto-setting ORT_DYLIB_PATH from the cached ONNX Runtime to prevent dlopen errors.

  • Bug Fixes
    • Unified storage fallbacks to mirror the plugin’s resolveCortexKitStorageRoot: prefer XDG_DATA_HOME; on Windows use LOCALAPPDATA/APPDATA; otherwise use ~/.local/share/cortexkit/aft (Windows: AppData/Local/cortexkit/aft). Applied in bash_background::storage_dir, warmup_storage_dir, and search_index::resolve_cache_dir.
    • aft warmup --semantic now sets ORT_DYLIB_PATH if unset by locating the cached library under <storage_dir>/onnxruntime/1.24.4/ (also checks lib/). Prevents dlopen('libonnxruntime.*')/missing DLL errors when running standalone.

Written for commit a3b71fb. Summary will update on new commits.

Review in cubic

…_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.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/bash_background/mod.rs">

<violation number="1" location="crates/aft/src/bash_background/mod.rs:178">
P2: Windows no-home fallback produces a synthetic `<temp>/AppData/Local/...` path that diverges from the TS plugin's behavior</violation>
</file>

<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");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

home.join(".cache").join("aft")
// commands like `move /Y .\.cache\aft\... ...` fail with "system cannot
// find the path specified" once the working directory shifts.
let home = if cfg!(target_os = "windows") {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Windows no-home fallback produces a synthetic <temp>/AppData/Local/... path that diverges from the TS plugin's behavior

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At crates/aft/src/bash_background/mod.rs, line 178:

<comment>Windows no-home fallback produces a synthetic `<temp>/AppData/Local/...` path that diverges from the TS plugin's behavior</comment>

<file context>
@@ -156,19 +156,37 @@ pub fn storage_dir(configured: Option<&std::path::Path>) -> PathBuf {
-    home.join(".cache").join("aft")
+    // commands like `move /Y .\.cache\aft\... ...` fail with "system cannot
+    // find the path specified" once the working directory shifts.
+    let home = if cfg!(target_os = "windows") {
+        std::env::var_os("USERPROFILE").or_else(|| std::env::var_os("HOME"))
+    } else {
</file context>

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pre-existing! The original code already used temp_dir() as the ultimate fallback when HOME/USERPROFILE are both unset. The plugin uses os.homedir(). I kept it intentionally: the divergence is documented in the comment, and both env vars being missing is near-zero in practice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Standalone aft warmup uses wrong storage default and fails to load ONNX Runtime

1 participant