From b4af90182c1ef8ff4d7fc30dff2a793c2831fd1e Mon Sep 17 00:00:00 2001 From: Alchimestre <6957532+alchimestre@users.noreply.github.com> Date: Wed, 25 Nov 2026 20:46:15 +0100 Subject: [PATCH 1/2] feat(macos): run review supervisor and full test suite on macOS - supervisor watches the parent by polling getppid instead of PR_SET_PDEATHSIG - non-UTF-8 filename test runs on Linux only (APFS refuses those names) - macOS CI runs the full Rust suite and launcher smoke test - ignore cargo target/ --- .github/workflows/ci.yml | 6 ++++-- .gitignore | 1 + rust/lore-core/src/pending.rs | 2 ++ rust/lore-core/src/supervisor.rs | 30 +++++++++++++++++++++++++----- 4 files changed, 32 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ac1bf7e..aa5dc36 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,13 +20,15 @@ jobs: - uses: Swatinem/rust-cache@v2 - name: Check native macOS carrier run: cargo check --locked --workspace - - name: Test native macOS pending continuations + - name: Test native macOS carrier env: TMPDIR: ${{ runner.temp }}/lore-tests + RUST_TEST_THREADS: 1 run: | mkdir -p "$TMPDIR" chmod 700 "$TMPDIR" - cargo test --locked --test pending_pages + cargo test --locked + LORE_RS="$PWD/target/debug/lore-rs" sh scripts/test-native-launcher.sh test: runs-on: ubuntu-latest # The whole suite runs in about a second; anything approaching this diff --git a/.gitignore b/.gitignore index 36626b5..bd156fb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ __pycache__/ dist/ *.egg-info/ +/target/ diff --git a/rust/lore-core/src/pending.rs b/rust/lore-core/src/pending.rs index 6361b5d..656311a 100644 --- a/rust/lore-core/src/pending.rs +++ b/rust/lore-core/src/pending.rs @@ -1363,6 +1363,8 @@ mod tests { } #[cfg(unix)] #[test] + // APFS refuses non-UTF-8 file names, so this fixture cannot be created on macOS. + #[cfg(target_os = "linux")] fn non_utf8_json_stem_makes_every_session_summary_incomplete() { use std::os::unix::ffi::OsStringExt; let temp = tempfile::tempdir().unwrap(); diff --git a/rust/lore-core/src/supervisor.rs b/rust/lore-core/src/supervisor.rs index e483b29..c727821 100644 --- a/rust/lore-core/src/supervisor.rs +++ b/rust/lore-core/src/supervisor.rs @@ -29,7 +29,7 @@ pub fn required(args: &[String]) -> bool { a[0] == "--event" && matches!(a[1].as_str(), "pre-compact" | "session-end") }) } -#[cfg(target_os = "linux")] +#[cfg(any(target_os = "linux", target_os = "macos"))] pub fn enter_worker() -> Result { let Some(raw) = std::env::var_os("LORE_NATIVE_SUPERVISOR_PID") else { return Ok(false); @@ -56,9 +56,12 @@ pub fn enter_worker() -> Result { worker_parent_lost as *const () as libc::sighandler_t, ); } + #[cfg(target_os = "linux")] if unsafe { libc::prctl(libc::PR_SET_PDEATHSIG, libc::SIGTERM) } != 0 { return Err(Error::Untrusted); } + #[cfg(target_os = "macos")] + watch_parent(pid); if unsafe { libc::getppid() } != pid { unsafe { libc::kill(-libc::getpgrp(), libc::SIGKILL); @@ -67,7 +70,7 @@ pub fn enter_worker() -> Result { std::env::remove_var("LORE_NATIVE_SUPERVISOR_PID"); Ok(true) } -#[cfg(target_os = "linux")] +#[cfg(any(target_os = "linux", target_os = "macos"))] pub fn run(args: &[String]) -> Result { use std::os::unix::process::CommandExt; let background = std::env::var("LORE_NATIVE_BACKGROUND_REVIEW").is_ok_and(|v| v == "1"); @@ -91,6 +94,7 @@ pub fn run(args: &[String]) -> Result { } else { None }; + #[cfg(target_os = "linux")] if unsafe { libc::prctl(libc::PR_SET_CHILD_SUBREAPER, 1) } != 0 { return Err(Error::Untrusted); } @@ -109,7 +113,11 @@ pub fn run(args: &[String]) -> Result { .stderr(Stdio::inherit()); unsafe { command.pre_exec(move || { - if libc::setpgid(0, 0) != 0 || libc::prctl(libc::PR_SET_PDEATHSIG, libc::SIGTERM) != 0 { + if libc::setpgid(0, 0) != 0 { + return Err(std::io::Error::last_os_error()); + } + #[cfg(target_os = "linux")] + if libc::prctl(libc::PR_SET_PDEATHSIG, libc::SIGTERM) != 0 { return Err(std::io::Error::last_os_error()); } if libc::getppid() != parent { @@ -154,6 +162,8 @@ pub fn run(args: &[String]) -> Result { let status = child.wait(); // Subreaper ownership admits escaped provider grandchildren too. Reparented // children are our children, so none can be an unrelated reused PID. + // shortcut: macOS has no subreaper or /proc, so a grandchild that left the + // process group is not reaped; upgrade with kqueue process tracking if needed. let children = std::path::PathBuf::from(format!("/proc/{parent}/task/{parent}/children")); let cleanup_deadline = Instant::now() + Duration::from_secs(3); loop { @@ -186,11 +196,21 @@ pub fn run(args: &[String]) -> Result { } Ok(status?.code().unwrap_or(1)) } -#[cfg(not(target_os = "linux"))] +#[cfg(target_os = "macos")] +fn watch_parent(parent: libc::pid_t) { + const PARENT_POLL: Duration = Duration::from_millis(100); + std::thread::spawn(move || loop { + if unsafe { libc::getppid() } != parent { + worker_parent_lost(libc::SIGTERM); + } + std::thread::sleep(PARENT_POLL); + }); +} +#[cfg(not(any(target_os = "linux", target_os = "macos")))] pub fn enter_worker() -> Result { Ok(false) } -#[cfg(not(target_os = "linux"))] +#[cfg(not(any(target_os = "linux", target_os = "macos")))] pub fn run(_args: &[String]) -> Result { Err(Error::Unsupported) } From c6200b87d8529a2f68d81d0686ee129c94ee159b Mon Sep 17 00:00:00 2001 From: Alchimestre <6957532+alchimestre@users.noreply.github.com> Date: Wed, 25 Nov 2026 22:02:33 +0100 Subject: [PATCH 2/2] test(macos): gate non-UTF-8 stem test on linux only --- rust/lore-core/src/pending.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/rust/lore-core/src/pending.rs b/rust/lore-core/src/pending.rs index 656311a..abbd9f3 100644 --- a/rust/lore-core/src/pending.rs +++ b/rust/lore-core/src/pending.rs @@ -1361,10 +1361,9 @@ mod tests { assert_eq!(for_sessions(&cfg, &request).unwrap()["complete"], true); } } - #[cfg(unix)] - #[test] // APFS refuses non-UTF-8 file names, so this fixture cannot be created on macOS. #[cfg(target_os = "linux")] + #[test] fn non_utf8_json_stem_makes_every_session_summary_incomplete() { use std::os::unix::ffi::OsStringExt; let temp = tempfile::tempdir().unwrap();