Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors
Rust
fix(run): make an explicit ai-jail selection exact with --no-X for unselected rows
AkitaOnRails80a78d025598
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 67512b49..87fc8deb 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -15,10 +15,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0on the host (`~/.config/gh`, `~/.aws`, `~/.kube`, `~/.config/gcloud`,`~/.docker/config.json`), SSH when `origin` is an SSH remote, and worktreemetadata in a linked worktree; host capabilities (`docker`, `gpu`,- `display`, `pictures`, `tailscale`) stay off. `--jail=github,aws,no-mise`- enables exactly the listed toggles (`all` and `none` also work), works- without `--yolo` and in scripts, and fails instead of running unjailed when- ai-jail is not usable. Only toggles the installed ai-jail advertises in its+ `display`, `pictures`, `tailscale`) stay off, and anything else is left to+ the user's own ai-jail config. `--jail=github,aws,no-mise` is exact: it+ passes every checklist row it does not name as `--no-X`, so a global+ `~/.ai-jail` cannot add to it (`all` and `none` also work); the checklist+ likewise passes unchecked rows as `--no-X`. `--jail` works without `--yolo`+ and in scripts, and fails instead of running unjailed when ai-jail is not+ usable. Only toggles the installed ai-jail advertises in its`--help` are offered or passed; the credential mounts need ai-jail 2.5.0.ai-jail's security switches (`seccomp`, `landlock`, `private-home`, …) arenever accepted. `--no-jail` skips the offer while keeping the `--yolo`diff --git a/crates/ai-memory-cli/src/cli.rs b/crates/ai-memory-cli/src/cli.rsindex 2c897037..d2705980 100644--- a/crates/ai-memory-cli/src/cli.rs+++ b/crates/ai-memory-cli/src/cli.rs@@ -302,7 +302,8 @@ pub struct RunArgs {/// the smart defaults (credentials present on this host, SSH for an SSH/// `origin`, worktree metadata in a linked worktree); `--jail=LIST` enables/// exactly the comma-separated ai-jail toggles listed (`github`, `aws`,- /// `ssh`, `gpu`, `docker`, …; `no-X` forces one off; `all`; `none`). A+ /// `ssh`, `gpu`, `docker`, …; `no-X` forces one off; `all`; `none`) and+ /// forces every other checklist row off, so it is exact. A/// project `.ai-jail` in the launch directory replaces the smart defaults/// (a list still applies on top). Fails when ai-jail is not usable here;/// ignored inside ai-jail. Wrapper-owneddiff --git a/crates/ai-memory-cli/src/commands/run.rs b/crates/ai-memory-cli/src/commands/run.rsindex 01a064fe..3594e03e 100644--- a/crates/ai-memory-cli/src/commands/run.rs+++ b/crates/ai-memory-cli/src/commands/run.rs@@ -16,13 +16,14 @@ use ai_memory_workstream::{JailHostFacts, JailSupport, JailToggleChoice, JailToggleKind, LaunchMode, LaunchPlan,LaunchRoots, ManagedHarness, NativeSessionCandidate, ai_jail_support,allows_native_session_adoption, apply_claude_true_yolo, apply_yolo, build_ai_jail_invocation,- build_launch_plan, build_launch_plan_with_env, checked_choices, crush_global_config_path,+ build_launch_plan, build_launch_plan_with_env, crush_global_config_path,discover_native_session, export_transcript, has_native_session_selector, inside_ai_jail_here,inspect_repository, jail_checklist, jail_toggle, kiro_explicit_session_id,kiro_harness_from_source_cursor, kiro_selects_non_default_engine, kiro_selects_v2_engine,kiro_selects_v3_engine, kiro_v3_resume_uses_default_store, list_native_sessions,- native_session_exists, native_session_in_checkout, omp_profile_flag, omp_profile_flag_env,- parse_jail_toggles, store_override_vars, usable_ai_jail_here, wait_for_transcript_flush,+ marked_choices, native_session_exists, native_session_in_checkout, omp_profile_flag,+ omp_profile_flag_env, parse_jail_toggles, store_override_vars, usable_ai_jail_here,+ wait_for_transcript_flush,};use anyhow::{Context as _, Result, anyhow};use tokio::process::Command;@@ -1133,7 +1134,9 @@ fn render_checklist(/// The interactive toggle checklist (docs/design-yolo-safety-ai-jail.md §5),/// line-based with injected `input`/`output` like [`read_yolo_confirmation`].-/// Enter or EOF accepts the marks; the result enables every checked row.+/// Enter or EOF accepts the marks. The result is every row as the user saw+/// it ([`marked_choices`]): checked rows `--X`, unchecked rows `--no-X`, so an+/// unchecked row stays off even if the user's own ai-jail config enables it.fn read_jail_checklist(items: &[JailChecklistItem],input: &mut impl io::BufRead,@@ -1170,12 +1173,14 @@ fn read_jail_checklist(checked,}).collect();- Ok(checked_choices(&marked))+ Ok(marked_choices(&marked))}/// The one-line account of what the jailed re-run enables, grouped the way-/// the risk differs: credentials the agent can use, host capabilities, and-/// toggles forced off — and whether the project `.ai-jail` supplies the rest.+/// the risk differs: credentials the agent can use, host capabilities, the+/// user's own `no-X` entries, and — for an explicit selection — the visible+/// rows it left out (forced off, summarized rather than spelled out) — and+/// whether the project `.ai-jail` supplies the rest.fn jail_summary(toggles: &[JailToggleChoice], project_config: bool) -> String {let labels = |kind: JailToggleKind| -> Vec<&'static str> {toggles@@ -1198,12 +1203,15 @@ fn jail_summary(toggles: &[JailToggleChoice], project_config: bool) -> String {}let off: Vec<String> = toggles.iter()- .filter(|choice| !choice.enable)+ .filter(|choice| !choice.enable && !choice.implied).map(JailToggleChoice::flag).collect();if !off.is_empty() {parts.push(format!("forced off: {}", off.join(" ")));}+ if toggles.iter().any(|choice| choice.implied) {+ parts.push("everything else in the checklist off".to_owned());+ }if project_config {parts.push("plus the project .ai-jail".to_owned());}@@ -2743,7 +2751,11 @@ mod tests {#[test]fn checklist_enter_and_eof_accept_the_smart_defaults() {let (enter, printed) = run_checklist("\n");- assert_eq!(enter.unwrap(), ["--github", "--aws"]);+ assert_eq!(+ enter.unwrap(),+ ["--github", "--aws", "--no-ssh", "--no-docker"],+ "every row as seen: unchecked rows are forced off"+ );assert!(printed.contains("Enable in the jail (Enter = as marked"));assert!(printed.contains("[x] 1) GitHub CLI credentials"));assert!(printed.contains("[x] 2) AWS credentials"));@@ -2751,25 +2763,40 @@ mod tests {assert!(printed.contains("[ ] 4) Docker socket"));assert!(printed.contains("⚠ grants host root"));let (eof, _) = run_checklist("");- assert_eq!(eof.unwrap(), ["--github", "--aws"]);+ assert_eq!(+ eof.unwrap(),+ ["--github", "--aws", "--no-ssh", "--no-docker"]+ );}#[test]fn checklist_numbers_flip_rows_and_all_none_set_every_row() {let (flipped, printed) = run_checklist("2 4\n\n");- assert_eq!(flipped.unwrap(), ["--github", "--docker"]);+ assert_eq!(+ flipped.unwrap(),+ ["--github", "--no-aws", "--no-ssh", "--docker"]+ );assert!(printed.contains("[ ] 2) AWS credentials") && printed.contains("[x] 4) Docker socket"),"the list is shown again after a flip:\n{printed}");let (commas, _) = run_checklist("1,3\n\n");- assert_eq!(commas.unwrap(), ["--aws", "--ssh"]);+ assert_eq!(+ commas.unwrap(),+ ["--no-github", "--aws", "--ssh", "--no-docker"]+ );let (all, _) = run_checklist("all\n\n");assert_eq!(all.unwrap(), ["--github", "--aws", "--ssh", "--docker"]);let (none, _) = run_checklist("NONE\n\n");- assert_eq!(none.unwrap(), Vec::<String>::new());+ assert_eq!(+ none.unwrap(),+ ["--no-github", "--no-aws", "--no-ssh", "--no-docker"]+ );let (none_then_one, _) = run_checklist("none\n3\n");- assert_eq!(none_then_one.unwrap(), ["--ssh"]);+ assert_eq!(+ none_then_one.unwrap(),+ ["--no-github", "--no-aws", "--ssh", "--no-docker"]+ );}#[test]@@ -2777,14 +2804,17 @@ mod tests {let (recovered, printed) = run_checklist("9\nyes\n2\n\n");assert_eq!(recovered.unwrap(),- ["--github"],+ ["--github", "--no-aws", "--no-ssh", "--no-docker"],"invalid lines change nothing; the later valid flip applies");assert!(printed.contains("`9` is not a row number between 1 and 4"));assert!(printed.contains("`yes` is not a row number"));// `2 9` is rejected whole: row 2 must not flip.let (partial, _) = run_checklist("2 9\n\n");- assert_eq!(partial.unwrap(), ["--github", "--aws"]);+ assert_eq!(+ partial.unwrap(),+ ["--github", "--aws", "--no-ssh", "--no-docker"]+ );let (gave_up, _) = run_checklist("x\nx\nx\n\n");assert!(@@ -2795,7 +2825,16 @@ mod tests {#[test]fn jail_summary_groups_credentials_capabilities_and_forced_off() {- let choice = |stem, enable| JailToggleChoice { stem, enable };+ let choice = |stem, enable| JailToggleChoice {+ stem,+ enable,+ implied: false,+ };+ let implied_off = |stem| JailToggleChoice {+ stem,+ enable: false,+ implied: true,+ };assert_eq!(jail_summary(&[@@ -2822,6 +2861,25 @@ mod tests {"ai-memory: re-running inside ai-jail (capabilities: GPU devices; plus the \project .ai-jail)");+ // An explicit selection: the user's own `no-X` is named, the rows it+ // left out are summarized, never claimed as "no extra mounts" only.+ assert_eq!(+ jail_summary(+ &[+ choice("github", true),+ choice("mise", false),+ implied_off("docker"),+ implied_off("gpu"),+ ],+ false+ ),+ "ai-memory: re-running inside ai-jail (credentials: GitHub CLI credentials; \+ forced off: --no-mise; everything else in the checklist off)"+ );+ assert_eq!(+ jail_summary(&[implied_off("docker")], false),+ "ai-memory: re-running inside ai-jail (everything else in the checklist off)"+ );}#[test]diff --git a/crates/ai-memory-cli/tests/suite/jail_toggles_e2e.rs b/crates/ai-memory-cli/tests/suite/jail_toggles_e2e.rsindex d8378546..80240ae6 100644--- a/crates/ai-memory-cli/tests/suite/jail_toggles_e2e.rs+++ b/crates/ai-memory-cli/tests/suite/jail_toggles_e2e.rs@@ -257,6 +257,31 @@ fn toggles(flags: &[String]) -> Vec<String> {rest.to_vec()}+/// The checklist rows an empty fixture `$HOME` shows with the 2.4.1 help:+/// only the opt-in capabilities (GPU and display are Linux-only).+fn visible_capability_rows() -> Vec<&'static str> {+ if cfg!(target_os = "linux") {+ vec!["docker", "gpu", "display", "pictures", "tailscale"]+ } else {+ vec!["docker", "pictures", "tailscale"]+ }+}++/// What an explicit selection emits: the named flags in order, then `--no-X`+/// for every visible checklist row the selection did not mention.+fn exact(named: &[&str]) -> Vec<String> {+ let mut expected: Vec<String> = named.iter().map(|flag| (*flag).to_owned()).collect();+ for row in visible_capability_rows() {+ let mentioned = named+ .iter()+ .any(|flag| *flag == format!("--{row}") || *flag == format!("--no-{row}"));+ if !mentioned {+ expected.push(format!("--no-{row}"));+ }+ }+ expected+}+fn exe() -> String {Path::new(BIN).canonicalize()@@ -299,7 +324,11 @@ async fn jail_list_reexecs_under_ai_jail_with_exactly_the_listed_toggles() {.any(|pair| pair == ["--env", "AI_MEMORY_SERVER_URL"]),"the server URL is forwarded into the jail: {flags:?}");- assert_eq!(toggles(flags), ["--gpu", "--ssh"]);+ assert_eq!(+ toggles(flags),+ exact(&["--gpu", "--ssh"]),+ "exactly the list: every other visible row is forced off"+ );assert_eq!(wrapped,[@@ -421,7 +450,7 @@ async fn jail_list_overrides_a_project_ai_jail() {assert!(output.status.success(), "{}", stderr(&output));let argv = fixture.jail_argv().expect("ai-jail exec'd");let (flags, _) = split_at_separator(&argv);- assert_eq!(toggles(flags), ["--gpu", "--no-docker"]);+ assert_eq!(toggles(flags), exact(&["--gpu", "--no-docker"]));handle.abort();}@@ -590,10 +619,21 @@ async fn yolo_offer_then_checklist_execs_ai_jail_on_a_terminal() {.jail_argv().unwrap_or_else(|| panic!("ai-jail exec'd:\n{output}"));let (flags, _) = split_at_separator(&argv);+ let expected: Vec<String> = visible_capability_rows()+ .iter()+ .enumerate()+ .map(|(index, row)| {+ if index == 1 {+ format!("--{row}")+ } else {+ format!("--no-{row}")+ }+ })+ .collect();assert_eq!(toggles(flags),- ["--gpu"],- "row 2 (GPU) was flipped on; the rest stay as marked"+ expected,+ "row 2 was flipped on; every other row is passed as the user saw it (off)");assert!(!fixture.claude_ran.exists());let requests = requests.lock().unwrap();diff --git a/crates/ai-memory-workstream/src/jail.rs b/crates/ai-memory-workstream/src/jail.rsindex 72e7af44..180d3629 100644--- a/crates/ai-memory-workstream/src/jail.rs+++ b/crates/ai-memory-workstream/src/jail.rs@@ -574,6 +574,11 @@ pub struct JailToggleChoice {pub stem: &'static str,/// `true` emits `--<stem>`, `false` emits `--no-<stem>`.pub enable: bool,+ /// Off only because an explicit selection left this visible row out+ /// (an unchecked checklist row, or a row a `--jail=…` list did not+ /// name), as opposed to a `no-X` the user typed. The flag is the same;+ /// the summary line groups these as "everything else in the checklist".+ pub implied: bool,}impl JailToggleChoice {@@ -588,9 +593,9 @@ impl JailToggleChoice {}}-/// The checked rows as choices: what Enter, or a bare `--jail`, enables.-/// Unchecked rows emit nothing, leaving ai-jail's own default (off for every-/// checklist toggle) and the user's ai-jail config in charge.+/// The checked rows as choices: what a bare `--jail` enables. The user saw no+/// selection there, so unchecked rows emit nothing and their own ai-jail+/// configuration (e.g. a global `~/.ai-jail`) still applies to the rest.#[must_use]pub fn checked_choices(items: &[JailChecklistItem]) -> Vec<JailToggleChoice> {items@@ -599,6 +604,23 @@ pub fn checked_choices(items: &[JailChecklistItem]) -> Vec<JailToggleChoice> {.map(|item| JailToggleChoice {stem: item.toggle.stem,enable: true,+ implied: false,+ })+ .collect()+}++/// Every row's state as the user saw it, for the interactive checklist:+/// checked emits `--X`, unchecked `--no-X`. The checklist is+/// what-you-see-is-what-you-get — an unchecked `[ ] Docker socket` stays off+/// even when the user's global `~/.ai-jail` enables it.+#[must_use]+pub fn marked_choices(items: &[JailChecklistItem]) -> Vec<JailToggleChoice> {+ items+ .iter()+ .map(|item| JailToggleChoice {+ stem: item.toggle.stem,+ enable: item.checked,+ implied: !item.checked,}).collect()}@@ -647,8 +669,16 @@ impl std::error::Error for JailToggleError {}/// Parse a `--jail=…` list: comma-separated stems, each optionally prefixed/// `no-` to force it off, plus `all` (every row of `checklist`) and `none`/// (clear everything listed so far). Later entries win, so `all,no-docker`-/// works. An empty list means the smart defaults; any other list is exactly-/// what it names — nothing else is enabled.+/// works.+///+/// An empty list means a bare `--jail`: the smart defaults only+/// ([`checked_choices`]), deferring to the user's ai-jail config for the+/// rest. Any other list is an explicit selection and exact: after the named+/// entries (in order), every visible `checklist` row the list did not name is+/// forced off with `--no-X`, so nothing else is enabled even when a global+/// `~/.ai-jail` would, and `none` turns every checklist row off. Rows not in+/// `checklist` (absent credentials, CLI-only toggles) are never forced: they+/// stay out of the invocation unless named.pub fn parse_jail_toggles(spec: &str,checklist: &[JailChecklistItem],@@ -677,6 +707,7 @@ pub fn parse_jail_toggles(JailToggleChoice {stem: row.toggle.stem,enable: true,+ implied: false,},);}@@ -709,9 +740,19 @@ pub fn parse_jail_toggles(JailToggleChoice {stem: toggle.stem,enable,+ implied: false,},);}+ for row in checklist {+ if !choices.iter().any(|choice| choice.stem == row.toggle.stem) {+ choices.push(JailToggleChoice {+ stem: row.toggle.stem,+ enable: false,+ implied: true,+ });+ }+ }Ok(choices)}@@ -1256,8 +1297,16 @@ mod tests {Vec::<String>::new(),"bare --jail defers to the file");- assert_eq!(parse("github,gpu"), ["--github", "--gpu"]);- assert_eq!(parse("all").len(), checklist.len());+ let listed = parse("github,gpu");+ assert_eq!(listed[..2], ["--github", "--gpu"]);+ assert!(+ listed[2..].iter().all(|flag| flag.starts_with("--no-")),+ "an explicit list forces the unnamed rows off even with a project file: {listed:?}"+ );+ assert_eq!(listed.len(), checklist.len());+ let all = parse("all");+ assert_eq!(all.len(), checklist.len());+ assert!(all.iter().all(|flag| !flag.starts_with("--no-")));}#[test]@@ -1283,32 +1332,47 @@ mod tests {let checklist = sample_checklist(home.path());let support = support_2_5_0();let parse = |spec: &str| flags(&parse_jail_toggles(spec, &checklist, &support).unwrap());+ // The visible rows of `sample_checklist`, in order.+ let rows = [+ "github",+ "aws",+ "ssh",+ "docker",+ "gpu",+ "display",+ "pictures",+ "tailscale",+ ];+ // The named flags, then `--no-X` for every visible row not named.+ let exact = |named: &[&str]| -> Vec<String> {+ let mut expected: Vec<String> = named.iter().map(|flag| (*flag).to_owned()).collect();+ for row in rows {+ let mentioned = named+ .iter()+ .any(|flag| *flag == format!("--{row}") || *flag == format!("--no-{row}"));+ if !mentioned {+ expected.push(format!("--no-{row}"));+ }+ }+ expected+ };- assert_eq!(parse(""), ["--github", "--aws"], "empty = smart defaults");assert_eq!(- parse("gpu, ssh"),- ["--gpu", "--ssh"],- "exactly what is listed"+ parse(""),+ ["--github", "--aws"],+ "empty = smart defaults only, nothing forced");+ assert_eq!(parse("gpu, ssh"), exact(&["--gpu", "--ssh"]));assert_eq!(parse("github,aws,no-mise"),- ["--github", "--aws", "--no-mise"]+ exact(&["--github", "--aws", "--no-mise"]));- assert_eq!(parse("GPU"), ["--gpu"], "case-insensitive");- assert_eq!(parse("gpu,no-gpu"), ["--no-gpu"], "later wins");+ assert_eq!(parse("GPU"), exact(&["--gpu"]), "case-insensitive");+ assert_eq!(parse("gpu,no-gpu"), exact(&["--no-gpu"]), "later wins");assert_eq!(parse("all"),- [- "--github",- "--aws",- "--ssh",- "--docker",- "--gpu",- "--display",- "--pictures",- "--tailscale"- ],- "all = every visible checklist row"+ rows.map(|row| format!("--{row}")),+ "all = every visible checklist row, nothing left to force");assert_eq!(parse("all,no-docker"),@@ -1323,15 +1387,66 @@ mod tests {"--no-docker"]);- assert_eq!(parse("none"), Vec::<String>::new());- assert_eq!(parse("all,none,toolchains"), ["--toolchains"]);+ assert_eq!(parse("none"), exact(&[]), "none = every visible row off");+ assert_eq!(parse("all,none,toolchains"), exact(&["--toolchains"]));assert_eq!(parse("kube"),- ["--kube"],- "an absent credential may still be named"+ exact(&["--kube"]),+ "an absent credential may still be named; it is never forced"+ );+ assert!(+ !parse("gpu")+ .iter()+ .any(|flag| flag.contains("mise") || flag.contains("kube")),+ "rows outside the checklist are never forced off");}+ /// Adversarial: an explicit selection must be exact even when the user's+ /// global `~/.ai-jail` enables something. An unchecked Docker row and+ /// `--jail=none` must both emit `--no-docker` (and `none`, a `--no-X` for+ /// every visible row) — emitting nothing would let that config mount the+ /// host-root Docker socket behind an unchecked box.+ #[test]+ fn explicit_selections_force_every_unselected_visible_row_off() {+ let home = tempfile::tempdir().unwrap();+ let checklist = sample_checklist(home.path());+ let docker = checklist+ .iter()+ .find(|item| item.toggle.stem == "docker")+ .expect("docker row visible");+ assert!(!docker.checked, "docker is unchecked by default");+ let marked = flags(&marked_choices(&checklist));+ assert_eq!(+ marked,+ [+ "--github",+ "--aws",+ "--no-ssh",+ "--no-docker",+ "--no-gpu",+ "--no-display",+ "--no-pictures",+ "--no-tailscale"+ ],+ "the checklist emits every row as the user saw it"+ );+ assert!(+ !flags(&checked_choices(&checklist)).contains(&"--no-docker".to_owned()),+ "control: bare --jail (no selection shown) defers the rest to ai-jail config"+ );++ let none = flags(&parse_jail_toggles("none", &checklist, &support_2_5_0()).unwrap());+ assert_eq!(none.len(), checklist.len());+ for item in &checklist {+ assert!(+ none.contains(&format!("--no-{}", item.toggle.stem)),+ "--jail=none must force {} off: {none:?}",+ item.toggle.stem+ );+ }+ }+#[test]fn toggle_list_rejects_unknown_and_reserved_names() {let home = tempfile::tempdir().unwrap();@@ -1374,7 +1489,8 @@ mod tests {#[test]fn toggle_list_names_the_ai_jail_release_a_missing_flag_needs() {let home = tempfile::tempdir().unwrap();- let checklist = sample_checklist(home.path());+ let facts = facts_with(home.path(), &[".config/gh", ".ssh"]);+ let checklist = jail_checklist(&facts, &support_2_4_1());let error = parse_jail_toggles("ssh,github", &checklist, &support_2_4_1()).unwrap_err();assert_eq!(error,@@ -1387,7 +1503,15 @@ mod tests {assert!(parse_jail_toggles("no-toolchains", &checklist, &support_2_4_1()).is_err());assert_eq!(flags(&parse_jail_toggles("ssh,gpu", &checklist, &support_2_4_1()).unwrap()),- ["--ssh", "--gpu"]+ [+ "--ssh",+ "--gpu",+ "--no-docker",+ "--no-display",+ "--no-pictures",+ "--no-tailscale"+ ],+ "2.4.1 has no github row to force");}@@ -1398,10 +1522,12 @@ mod tests {JailToggleChoice {stem: "gpu",enable: true,+ implied: false,},JailToggleChoice {stem: "mise",enable: false,+ implied: false,},];let forwarded = ["run", "claude", "--jail=gpu,no-mise"].map(OsString::from);diff --git a/crates/ai-memory-workstream/src/lib.rs b/crates/ai-memory-workstream/src/lib.rsindex b12a4105..32b804ff 100644--- a/crates/ai-memory-workstream/src/lib.rs+++ b/crates/ai-memory-workstream/src/lib.rs@@ -17,8 +17,8 @@ pub use jail::{FORWARDED_ENV_NAMES, JAIL_TOGGLES, JailChecklistItem, JailEnv, JailHostFacts, JailOs,JailSupport, JailToggle, JailToggleChoice, JailToggleError, JailToggleKind, ai_jail_support,build_ai_jail_invocation, checked_choices, current_jail_os, inside_ai_jail,- inside_ai_jail_here, jail_checklist, jail_toggle, parse_jail_toggles, usable_ai_jail,- usable_ai_jail_here,+ inside_ai_jail_here, jail_checklist, jail_toggle, marked_choices, parse_jail_toggles,+ usable_ai_jail, usable_ai_jail_here,};pub use repository::{RepositoryIdentity, inspect_repository};pub use transcript::{diff --git a/docs/cookbook.md b/docs/cookbook.mdindex c29f9b3c..69e3b7cc 100644--- a/docs/cookbook.md+++ b/docs/cookbook.md@@ -187,12 +187,15 @@ ai-memory run --yolo claudeDocker socket (grants host root), GPU, display, Pictures, and Tailscale arelisted unchecked. Type row numbers to flip them (`2 4`), or `all` / `none`.A mounted credential is usable by the unsupervised agent, so uncheck what it- should not touch.+ should not touch. What you see is what you get: unchecked rows are passed+ as `--no-X`, so they stay off even if your global `~/.ai-jail` enables them.- **Skipping the questions.** `ai-memory run --jail claude` re-runs inside- ai-jail straight away with those defaults — with or without `--yolo`, and in- scripts too; it fails rather than running unjailed if ai-jail is not usable.- `--jail=github,ssh,no-mise` enables exactly the listed toggles (`no-X`- forces one off), plus `all` / `none`. `--no-jail` never jails and skips the+ ai-jail straight away, turning on those pre-marked defaults and leaving+ everything else to your own ai-jail config — with or without `--yolo`, and+ in scripts too; it fails rather than running unjailed if ai-jail is not+ usable. `--jail=github,ssh,no-mise` is exact: the listed toggles (`no-X`+ forces one off), with every other checklist row forced off; `all` turns+ every row on and `none` turns every row off. `--no-jail` never jails and skips theoffer (the `--yolo` warning stays). There are no bare `--github`-styleflags on purpose: they would collide with the harness's own flags (ClaudeCode has a `--worktree`). The credential mounts need ai-jail 2.5.0; togglesdiff --git a/docs/design-yolo-safety-ai-jail.md b/docs/design-yolo-safety-ai-jail.mdindex 6d052590..2245d24e 100644--- a/docs/design-yolo-safety-ai-jail.md+++ b/docs/design-yolo-safety-ai-jail.md@@ -193,8 +193,8 @@ arguments too, like `--yolo`; neither ever reaches the harness):| Form | Meaning ||---|---|| `--jail` | Re-run inside ai-jail now, without the "Re-run inside it?" question or the checklist, using the smart defaults below. |-| `--jail=github,aws,no-mise` | Same, enabling exactly the listed toggles; `no-X` forces one off (`--no-X`). Nothing unlisted is enabled. |-| `--jail=all` / `--jail=none` | Every checklist row this host shows / no toggles at all. Lists are applied left to right, so `all,no-docker` works. |+| `--jail=github,aws,no-mise` | Same, with exactly the listed toggles; `no-X` forces one off (`--no-X`), and every checklist row this host shows that the list does not name is forced off too. |+| `--jail=all` / `--jail=none` | Every checklist row this host shows on / every one of them off. Lists are applied left to right, so `all,no-docker` works. || `--no-jail` | Never re-run inside ai-jail; the `--yolo` warning still shows. Conflicts with `--jail`. |`--jail` needs `=` for its list (`require_equals`), so `ai-memory run --jail@@ -239,11 +239,28 @@ where without its metadata mounted writable the agent cannot commit. The hostcapabilities stay off: they widen the sandbox without being needed for theusual task.-**Semantics.** Unchecked rows (and toggles a list does not name) emit-nothing, so ai-jail's own default — off for every checklist toggle — and the-user's own ai-jail configuration stay in charge; `no-X` is the explicit way to-force one off. The chosen toggles are emitted as `--X` / `--no-X` after the-`--network --agent-state --no-save-config --env …` baseline and before the `--` separator.+**Semantics: an explicit selection is exact.** ai-jail's own config can+enable toggles too — the trusted global `~/.ai-jail` may turn on, say,+`docker`. So whenever the user makes a selection, ai-memory states every+visible row explicitly, and ai-jail's CLI flags override its config:++- **Interactive checklist:** every row the user saw is passed as marked —+ checked `--X`, unchecked `--no-X` (`marked_choices`). An unchecked+ `[ ] Docker socket` stays off even when `~/.ai-jail` enables it; the+ checklist is what-you-see-is-what-you-get.+- **`--jail=LIST`, including `none`:** the named entries, in order (later+ entries win), then `--no-X` for every visible checklist row the list did+ not name. "Exactly what it names" holds against any ai-jail config, and+ `none` means none of the checklist rows. Rows that are not visible are never+ forced: an absent credential mounts nothing either way, and CLI-only toggles+ stay out of the invocation unless named.+- **Bare `--jail`:** the user saw no selection, so it only enables the+ smart-default rows (`checked_choices`) and emits nothing for the rest; the+ user's own ai-jail configuration still decides those.++The chosen toggles are emitted after the+`--network --agent-state --no-save-config --env …` baseline and before the `--`+separator.**A project `.ai-jail` replaces the checklist.** ai-jail reads its projectconfig only from the invocation directory, which the re-exec inherits from@@ -251,9 +268,9 @@ ai-memory. When a regular file `.ai-jail` exists there:| | no project `.ai-jail` | project `.ai-jail` present ||---|---|---|-| offer accepted (no flag) | checklist, smart defaults | no checklist, no toggles: the file is loaded as-is |-| bare `--jail` | smart defaults | no toggles: the file is loaded as-is |-| `--jail=LIST` | exactly the list | the list, on top of the file (CLI flags override config in ai-jail) |+| offer accepted (no flag) | checklist; every row passed as marked | no checklist, no toggles: the file is loaded as-is |+| bare `--jail` | smart-default rows on; the rest left to ai-jail config | no toggles: the file is loaded as-is |+| `--jail=LIST` | exactly the list; unnamed visible rows `--no-X` | the same exact list, on top of the file (CLI flags override config in ai-jail) |A project file is untrusted — it lives in the repository the agent works on.ai-jail lets it disable capabilities but never enable credentials, `docker`,@@ -295,7 +312,9 @@ Enter (or EOF) accepts as marked; row numbers (spaces or commas) flip rows andredraw the list; `all` / `none` set every row. An unrecognized answer changesnothing and re-prompts; the third one aborts the launch rather than guessingwhat to mount. One summary line then names what the jail gets, grouped into-credentials, capabilities, and forced-off toggles. With no visible row the+credentials, capabilities, and the user's own `no-X` entries, then "everything+else in the checklist off" for the rows an explicit selection left out (rather+than spelling out each `--no-X`). With no visible row thechecklist is skipped. The reader takes injected `BufRead`/`Write`, like the §1prompt, so its grammar is unit-tested without a TTY.diff --git a/docs/support-matrix.md b/docs/support-matrix.mdindex 3df5c1d2..8c5a42d9 100644--- a/docs/support-matrix.md+++ b/docs/support-matrix.md@@ -22,7 +22,7 @@| Pi | Supported | Generated `~/.pi/agent/extensions/ai-memory-pi.ts` extension provides lifecycle capture and an HTTP MCP bridge; generated extension enforces capture exclusions. || Crush | Managed-only | `ai-memory run crush` resumes its project-local session database and supplies portable context through a temporary supported global-context file; no lifecycle-hook installer is provided. || Managed workstreams | Opt-in | `ai-memory run` provides transparent cross-harness continuity for Claude Code, Codex, OpenCode, OpenCode 2 beta, Pi, Crush, Kimi Code, Command Code, both incompatible Kiro CLI engines, OMP, Grok Build CLI, and Antigravity CLI. Direct launches remain unchanged. See [`docs/managed-workstreams.md`](managed-workstreams.md). |-| `--yolo` safety + ai-jail | Linux/macOS; Windows partial | `ai-memory run --yolo` warns before it disarms an agent's permission prompts and, on Linux/macOS, offers to re-exec the session inside [ai-jail](https://github.com/akitaonrails/ai-jail) when it is usable — installed and with its sandbox backend present (`bwrap` / `sandbox-exec`); otherwise it asks nothing and proceeds (`--network`, forwarding only already-set credential/config env vars). Accepting the offer shows a checklist of ai-jail toggles pre-marked with smart defaults (credentials present on the host, SSH for an SSH `origin`, worktree metadata in a linked worktree; Docker socket, GPU, display, Pictures, Tailscale unchecked). `--jail` re-runs inside ai-jail without asking (also without `--yolo` and non-interactively; it errors when ai-jail is not usable), `--jail=github,aws,no-mise` enables exactly the listed toggles (`all`/`none` too), and `--no-jail` skips the offer. Only toggles the installed ai-jail supports are offered; the credential mounts (`github`, `aws`, `kube`, `gcloud`, `docker-config`) need ai-jail 2.5.0. A project `.ai-jail` in the launch directory replaces the checklist and the bare-`--jail` defaults (ai-jail loads it as-is; `--jail=…` still overrides), and every re-exec passes `--no-save-config` so ai-jail never writes the run's flags into it. Both prompts are skipped on a non-interactive stdin/stderr and when already detected inside ai-jail. Windows gets the warning but never the ai-jail offer (ai-jail is Linux/macOS-only). Opt-in `--true-yolo` implies `--yolo` and, for Claude only, additionally forces `bypassPermissions` over any settings `defaultMode` (interchangeable with `--yolo` for other harnesses); `claude_true_yolo` applies the same Claude extra to `--yolo` launches. Claude's own explicit `ask` rules and command-safety checks still prompt in every mode. See [`docs/design-yolo-safety-ai-jail.md`](design-yolo-safety-ai-jail.md). |+| `--yolo` safety + ai-jail | Linux/macOS; Windows partial | `ai-memory run --yolo` warns before it disarms an agent's permission prompts and, on Linux/macOS, offers to re-exec the session inside [ai-jail](https://github.com/akitaonrails/ai-jail) when it is usable — installed and with its sandbox backend present (`bwrap` / `sandbox-exec`); otherwise it asks nothing and proceeds (`--network`, forwarding only already-set credential/config env vars). Accepting the offer shows a checklist of ai-jail toggles pre-marked with smart defaults (credentials present on the host, SSH for an SSH `origin`, worktree metadata in a linked worktree; Docker socket, GPU, display, Pictures, Tailscale unchecked). `--jail` re-runs inside ai-jail without asking (also without `--yolo` and non-interactively; it errors when ai-jail is not usable), `--jail=github,aws,no-mise` is exact (every unnamed checklist row is forced off with `--no-X`; `all`/`none` too; the checklist likewise passes unchecked rows as `--no-X`, while bare `--jail` leaves unmarked rows to your ai-jail config), and `--no-jail` skips the offer. Only toggles the installed ai-jail supports are offered; the credential mounts (`github`, `aws`, `kube`, `gcloud`, `docker-config`) need ai-jail 2.5.0. A project `.ai-jail` in the launch directory replaces the checklist and the bare-`--jail` defaults (ai-jail loads it as-is; `--jail=…` still overrides), and every re-exec passes `--no-save-config` so ai-jail never writes the run's flags into it. Both prompts are skipped on a non-interactive stdin/stderr and when already detected inside ai-jail. Windows gets the warning but never the ai-jail offer (ai-jail is Linux/macOS-only). Opt-in `--true-yolo` implies `--yolo` and, for Claude only, additionally forces `bypassPermissions` over any settings `defaultMode` (interchangeable with `--yolo` for other harnesses); `claude_true_yolo` applies the same Claude extra to `--yolo` launches. Claude's own explicit `ask` rules and command-safety checks still prompt in every mode. See [`docs/design-yolo-safety-ai-jail.md`](design-yolo-safety-ai-jail.md). || Claude Desktop | MCP-only | Uses `mcp-remote`; no lifecycle hooks. || OpenClaw | Supported | MCP config + native plugin lifecycle hooks; generated plugin enforces capture exclusions. || Antigravity CLI | Supported | MCP config (`serverUrl`) + lifecycle hooks (`agy` alias). Only `PreInvocation` with `invocationNum = 0` maps to SessionStart; later model calls cannot consume a next-session handoff. No automatic true session-end hook, so run `ai-memory finalize-session --agent antigravity-cli` after the final turn when you need a summary, handoff, and opt-in SessionEnd consolidation; an interactive session launched with `ai-memory run antigravity` is finalized automatically when it exits if the run can tie the session to itself (see [`docs/managed-workstreams.md`](managed-workstreams.md)). `ai-memory run antigravity` (aliases `antigravity-cli`, `agy`) adds managed workstream resume via `--conversation`; conversation text is not decoded, so the ledger for this harness comes from hook capture. Tool outputs (`run_command`, `view_file`, `list_dir`, etc.) are resolved directly from `.system_generated/steps/<stepIdx>/output.txt` during `post-tool-use` while mutation tools preserve code from arguments (#966). |