Release builds prefer sidecars from the build workspace and the current directory over their bundled ones
Describe the bug
managed_agents/discovery.rs builds the sidecar search path in command_search_dirs() from, in this order: workspace_root_dir() (env!("CARGO_MANIFEST_DIR")/../.., the checkout the app was compiled in), target/{debug,release} under the current directory, and only then the directory of the running executable, where the bundled sidecars are. This applies in every build profile, so a release binary embeds its build path and searches it first.
For an installed app that means:
- if the build checkout still exists on the machine (local release builds), its
target/binaries are used instead of the bundled ones, even when they are older; - starting Buzz from a directory that contains a
target/release/buzz-acp(any Buzz checkout) silently swaps in those sidecars.
Steps to reproduce
- Build and install a release app (
just desktop-release-build), keep the checkout. - Rebuild one sidecar in the checkout, e.g.
cargo build --release -p buzz-acpafter a change. - Start the installed app and run an agent.
resolve_command→resolve_workspace_commandwalkscommand_search_dirs()in the order above, so it picks the checkout'sbuzz-acp, not the bundled one. (I traced this in the code; the nixpkgs build patches it out, so I haven't watched it happen in a running app.)
Expected behavior
Release builds use the bundled sidecars next to the executable. Searching the workspace and the current directory is useful for just dev, so it could stay behind cfg(debug_assertions).
Version and platform
- Buzz version: 0.5.28 (code as of
main347ce88d5) - OS: NixOS (x86_64-linux); the code path is platform-independent
Logs / additional context
#3069 (by @fitz2882) and #2655 both put the bundled sidecars first in release builds, which fixes the main symptom; I missed #3069 when searching before filing this. Both keep the build-checkout and current-directory entries as fallbacks. nixpkgs carries a small patch by @sebfried that gates workspace_root_dir() behind debug_assertions; I'd be glad to open it as a PR if that's the preferred fix.
Closing: I'm focusing on Buzz 1.0 (block/buzz-app), which doesn't use this code.