Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors
Rust
fix(run): preflight ai-jail availability
AkitaOnRails7f8b95fea545
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 8e0b0aae..6eb549be 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -24,7 +24,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0- Fixed `ai-memory run --jail` leaving the `ssh` toggle unchecked when`git push` goes over SSH but `origin`'s fetch URL does not show it: an HTTPS`origin` with an SSH `pushurl` or `pushInsteadOf`, or a `host:path` remote- using an `~/.ssh/config` alias. (#1024)+ using an `~/.ssh/config` alias. The interactive offer now also uses+ ai-jail's own dry-run preflight, so a backend that exists but fails ai-jail's+ trust checks is treated as unavailable instead of producing a broken offer.+ (#1024)## [2.5.2] - 2026-10-01diff --git a/crates/ai-memory-cli/tests/suite/packaging.rs b/crates/ai-memory-cli/tests/suite/packaging.rsindex 622df167..2101888d 100644--- a/crates/ai-memory-cli/tests/suite/packaging.rs+++ b/crates/ai-memory-cli/tests/suite/packaging.rs@@ -2301,6 +2301,7 @@ mod slow {.arg("upgrade").env("PATH", path).env("HOME", tmp.path())+ .env("XDG_DATA_HOME", tmp.path().join("data")).env("AI_MEMORY_DOCKER", &docker).env("AI_MEMORY_WRAPPER_URL",@@ -2726,6 +2727,7 @@ mod slow {.env("AI_MEMORY_SKIP_SELF_UPGRADE", "1").env("AI_MEMORY_SERVER_URL", "http://192.168.0.90:49374").env("HOME", tmp.path())+ .env("XDG_DATA_HOME", tmp.path().join("data")).output().unwrap();assert!(diff --git a/crates/ai-memory-workstream/src/jail.rs b/crates/ai-memory-workstream/src/jail.rsindex 3a191251..b4b7cb23 100644--- a/crates/ai-memory-workstream/src/jail.rs+++ b/crates/ai-memory-workstream/src/jail.rs@@ -54,11 +54,35 @@ pub fn usable_ai_jail(os: JailOs, lookup: impl Fn(&str) -> Option<PathBuf>) -> O/// install location when that directory is not on `PATH`).#[must_use]pub fn usable_ai_jail_here() -> Option<PathBuf> {- usable_ai_jail(current_jail_os(), |name| match find_on_path(name) {+ let candidate = usable_ai_jail(current_jail_os(), |name| match find_on_path(name) {Some(path) => Some(path),+ None if name == "bwrap" => std::env::var_os("BWRAP_BIN").map(PathBuf::from),None if name == "ai-jail" => home_local_bin_ai_jail(),None => None,- })+ })?;+ preflighted_ai_jail(candidate, ai_jail_preflight)+}++fn preflighted_ai_jail(+ candidate: PathBuf,+ preflight: impl FnOnce(&Path) -> bool,+) -> Option<PathBuf> {+ preflight(&candidate).then_some(candidate)+}++/// Ask the installed ai-jail to validate its complete local launch boundary.+/// `--dry-run` does not execute the child or write configuration, but it does+/// apply ai-jail's own backend trust checks (including root ownership and the+/// protected-Nix-store exception) so our offer cannot lead directly to a+/// refusal that the shallower PATH probe missed.+fn ai_jail_preflight(ai_jail: &Path) -> bool {+ std::process::Command::new(ai_jail)+ .args(["--dry-run", "--", "/bin/true"])+ .stdin(std::process::Stdio::null())+ .stdout(std::process::Stdio::null())+ .stderr(std::process::Stdio::null())+ .status()+ .is_ok_and(|status| status.success())}fn find_on_path(name: &str) -> Option<PathBuf> {@@ -872,6 +896,22 @@ mod tests {assert_eq!(usable_ai_jail(JailOs::MacOs, linux_backend_on_macos), None);}+ #[test]+ fn failed_ai_jail_preflight_suppresses_the_offer() {+ let candidate = PathBuf::from("/opt/bin/ai-jail");+ assert_eq!(+ preflighted_ai_jail(candidate.clone(), |path| {+ assert_eq!(path, candidate);+ false+ }),+ None+ );+ assert_eq!(+ preflighted_ai_jail(candidate.clone(), |_| true),+ Some(candidate)+ );+ }+/// ai-jail is unsupported on Windows: even a file named `ai-jail` on PATH/// (a Git-Bash or WSL shim) must not produce the offer, and the lookup is/// never consulted.diff --git a/docs/design-yolo-safety-ai-jail.md b/docs/design-yolo-safety-ai-jail.mdindex 7a904acd..342075ca 100644--- a/docs/design-yolo-safety-ai-jail.md+++ b/docs/design-yolo-safety-ai-jail.md@@ -58,9 +58,11 @@ scripts, hooks, and CI keep working unchanged.The offer appears only when accepting it can actually work(`usable_ai_jail`): on Linux or macOS, with the ai-jail binary on `PATH`-(fallback `~/.local/bin/ai-jail`) **and** its sandbox backend on `PATH`-(`bwrap` on Linux, `sandbox-exec` on macOS). It never appears on Windows, where-ai-jail is unsupported, even if a file named `ai-jail` happens to be on `PATH`.+(fallback `~/.local/bin/ai-jail`) **and** a sandbox backend candidate available+(`bwrap` on Linux, including `BWRAP_BIN`; `sandbox-exec` on macOS). A no-exec+`ai-jail --dry-run` preflight then applies ai-jail's own backend trust and local+configuration checks before the offer is shown. It never appears on Windows,+where ai-jail is unsupported, even if a file named `ai-jail` happens to be on `PATH`.When ai-jail is not usable there is no question at all — the run proceedsdirectly after the §1 warning. The re-exec runs the exact path this checkresolved, never a bare `ai-jail` re-looked-up through `PATH` (which missed a