usesuper::*;fn written() -> std::path::PathBuf { std::path::Path::new(&std::env::var("CARGO_MANIFEST_DIR").expect("cargo sets CARGO_MANIFEST_DIR")).join("../../scripts/dev/lane.sb")}/// RULE: The lane launcher's seatbelt profile file is cotton-core's lane_profile, so the folders a lane is denied have one source.#[test]fn the_launchers_profile_is_cores() {if std::env::var_os("COTTON_WRITE_LANE_PROFILE").is_some() { std::fs::write(written(), lane_profile()).unwrap(); }let on_disk = std::fs::read_to_string(written()).unwrap_or_default(); assert!(on_disk == lane_profile(), "scripts/dev/lane.sb is stale: COTTON_WRITE_LANE_PROFILE=1 cargo test -p cotton-core lane_sandbox");}/// RULE: A lane is denied the real app's data folder and every secret in SECRETS_DENIED_IN_HOME; the keychain is denied in the list and opened again by name, read and write, as the ONE opening that is not read-only — a lane runs on the Mac's own Claude login (owner, 21 Oct 2026: Remote Control on lanes; reverses lanekeychain, 15 Oct).#[test]fn a_lane_is_denied_the_data_folder_and_the_secrets() {let denied = lane_denied_in_home(); assert!(real_data_in_home().iter().all(|p| denied.contains(p)));for secret in SECRETS_DENIED_IN_HOME { assert!(denied.iter().any(|p| p == secret), "{secret}"); } assert!(denied.iter().any(|p| p == "Library/Keychains"), "the keychain"); assert!(LANE_OPENED_IN_HOME.iter().all(|(p, _)| denied.iter().any(|d| p.starts_with(&format!("{d}/")))), "an opening sits inside a denied folder");let (keychain, _) = LANE_KEYCHAIN_OPENED; assert!(denied.iter().any(|p| p == keychain), "the opening names a denied folder");let profile = lane_profile();let deny = format!("(deny file-read* file-write* (subpath \"{HOME}/{keychain}\"))");let open = format!("(allow file-read* file-write* (subpath \"{HOME}/{keychain}\"))"); assert!(profile.find(&deny).unwrap() < profile.find(&open).unwrap(), "the keychain's opening follows its denial, so it wins"); assert_eq!(profile.matches("(allow file-read* file-write*").count(), 1, "the keychain is the only read-write opening");}/// RULE: No entry of the lane profile carries `no-sandbox`: a child of a lane inherits the lane's profile or does not run, because an exec opened to run free (it was /usr/bin/sandbox-exec) takes any profile its caller writes, and `(allow default)` then read every folder the lane is denied (architect, 15 Oct 2026).#[test]fn nothing_a_lane_runs_leaves_its_profile() {let profile = lane_profile(); assert!(!profile.contains(NO_SANDBOX), "a lane profile entry runs free:\n{profile}"); assert!(!profile.lines().any(|line| !line.starts_with(";;") && line.contains("process-exec")), "a lane profile opens an exec:\n{profile}");}/// RULE: A lane can neither open nor connect to Codex's shared daemon folder (/private/tmp/codex-daemon-<uid>): the daemon runs outside every profile, so a lane that reached it ran its commands unsandboxed (security note 7948836e, 15 Oct 2026).#[test]fn a_lane_cannot_reach_codexs_shared_daemon() {let profile = lane_profile();let daemon = regex_literal(CODEX_DAEMON_SOCKETS); assert!(profile.contains(&format!("(deny file-read* file-write* (regex #\"^{daemon}\"))")), "{profile}"); assert!(profile.contains(&format!("(deny network-outbound (remote unix-socket (path-regex #\"^{daemon}\")))")), "{profile}");}