Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
29de444
test: run a real sshd per test behind a fault proxy
small-angel Nov 3, 2026
7963a9a
feat(host): add orx-host, a static per-run supervisor and RPC server
small-angel Nov 3, 2026
fc5c068
feat(engine): run every new run through one engine inside `orx up`
small-angel Nov 3, 2026
227f896
feat(ui): show engine run states, host contact and paged logs
small-angel Nov 3, 2026
cccc644
docs: describe the run engine in the architecture essays
small-angel Nov 3, 2026
18574d3
fix: distinguish pending run cancellation and confirm abandonment
small-angel Nov 3, 2026
c38a192
fix(engine): release rented boxes when cancelling or abandoning
small-angel Nov 3, 2026
e4b0a55
fix(ui): offer "Keep tracking" instead of "Cancel" when abandoning a run
small-angel Nov 3, 2026
bfb3ad2
fix(engine): cancel rentals after persistent SSH key rejection
small-angel Nov 3, 2026
ecb54a8
fix(engine): preserve legacy wakeups and completion log tails
small-angel Nov 3, 2026
1dd9ce5
test(engine): wait for host watchers before removing the rental test …
small-angel Nov 4, 2026
edfefbc
feat: put the run engine behind a setting
small-angel Nov 4, 2026
5bfdac4
fix(engine): API providers keep exit codes and report rejected creden…
small-angel Nov 4, 2026
827ade8
fix: second review round for the run engine setting
small-angel Nov 5, 2026
2c76586
fix(ui): run log and status polish
small-angel Nov 5, 2026
48cfa34
fix: bump the dashboard protocol for the engine's remote API
small-angel Nov 5, 2026
4cfaf9f
fix: embed the macOS orx-host in every release
small-angel Nov 5, 2026
c97876f
fix(engine): spawn engine processes the way a terminal would
small-angel Nov 5, 2026
c7efe51
fix(engine): detach the rental supervisor from the launching shell
small-angel Nov 5, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix(engine): spawn engine processes the way a terminal would
Route laptop-side engine commands through the terminal environment and keep host-side spawning in the host process environment.

Assisted-by: gpt-6.1-sol
  • Loading branch information
small-angel committed Nov 5, 2026
commit c97876f17ac2933afec209bfa87f73a9b6e3c731
2 changes: 2 additions & 0 deletions crates/orx-host/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Host processes inherit the host environment and the recorded run environment.
#![allow(clippy::disallowed_methods)]
#![cfg(unix)]

pub mod exec;
Expand Down
2 changes: 2 additions & 0 deletions crates/orx-host/tests/rpc.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Separate test crate; commands inherit the terminal environment.
#![allow(clippy::disallowed_methods)]
#![cfg(unix)]
mod common;
use common::{until, Directory, Group};
Expand Down
2 changes: 2 additions & 0 deletions crates/orx-host/tests/ssh.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Separate test crate; commands inherit the terminal environment.
#![allow(clippy::disallowed_methods)]
#![cfg(unix)]
mod common;
use common::until;
Expand Down
2 changes: 2 additions & 0 deletions crates/orx-host/tests/wrapper.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Separate test crate; commands inherit the terminal environment.
#![allow(clippy::disallowed_methods)]
#![cfg(unix)]
mod common;
use common::{until, Directory, Run};
Expand Down
13 changes: 2 additions & 11 deletions src/commands/exp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ pub(crate) fn spawn_detached_supervise(run_id: &str) -> Result<()> {
let mut child = match supervise_command(&exe, run_id, &path).spawn() {
// `/proc/self/exe` can name a path this process cannot exec (OR-334); the `orx` on PATH still runs.
Err(error) if error.kind() == std::io::ErrorKind::NotFound => {
match crate::local::shell_env::find_on_path("orx").filter(|orx| *orx != exe) {
match crate::local::shell_env::find("orx").filter(|orx| *orx != exe) {
Some(orx) => {
let tried = format!("`{}`{}: {error}", exe.display(), current_exe_note(&exe));
let child = supervise_command(&orx, run_id, &path)
Expand Down Expand Up @@ -300,21 +300,12 @@ fn supervise_command(
.open(log_path)
.map_or_else(|_| std::process::Stdio::null(), std::process::Stdio::from);
// A long-lived `orx up` may be running a replaced binary; spawn the new file at its path.
let mut cmd = std::process::Command::new(exe);
let mut cmd = crate::process::command(exe);
cmd.arg("supervise")
.arg(run_id)
.stdin(std::process::Stdio::null())
.stdout(std::process::Stdio::null())
.stderr(stderr);
// The supervisor re-resolves its directories from its own environment, so
// without this a run launched from the macOS app is tracked in a different
// store than the app is reading.
if let Some(path) = crate::local::shell_env::search_path() {
cmd.env("PATH", path);
}
crate::local::shell_env::export_to(|key, value| {
cmd.env(key, value);
});
#[cfg(unix)]
{
use std::os::unix::process::CommandExt;
Expand Down
4 changes: 2 additions & 2 deletions src/commands/remote_host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1519,7 +1519,7 @@ mod discovery_tests {
std::env::temp_dir().join(format!("orx-legacy-spawn-{}", uuid::Uuid::new_v4()));
std::fs::create_dir_all(&directory).unwrap();
let output = directory.join("source");
let result = std::process::Command::new(std::env::current_exe().unwrap())
let result = crate::process::command(std::env::current_exe().unwrap())
.args([
"--exact",
"commands::remote_host::discovery_tests::legacy_spawn_parent",
Expand Down Expand Up @@ -1702,7 +1702,7 @@ mod discovery_tests {
fn discovery_uses_agent_environment_without_touching_a_descriptor_or_starting_a_server() {
let path =
std::env::temp_dir().join(format!("orx-agent-discovery-{}", uuid::Uuid::new_v4()));
let output = std::process::Command::new(std::env::current_exe().unwrap())
let output = crate::process::command(std::env::current_exe().unwrap())
.args([
"--exact",
"commands::remote_host::discovery_tests::agent_session_child",
Expand Down
10 changes: 5 additions & 5 deletions src/commands/up/api_v2/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ fn run_with_engine(test: &str) -> bool {
if std::env::var("ORX_RUN_ENGINE").as_deref() == Ok("1") {
return false;
}
let output = std::process::Command::new(std::env::current_exe().unwrap())
let output = crate::process::command(std::env::current_exe().unwrap())
.env("ORX_RUN_ENGINE", "1")
.args(["--exact", test, "--nocapture"])
.output()
Expand Down Expand Up @@ -1215,7 +1215,7 @@ async fn wait_and_follow_rediscover_and_rebuild_snapshots_when_the_sse_connectio
});
let output = tokio::time::timeout(
Duration::from_secs(5),
tokio::process::Command::new(std::env::current_exe().unwrap())
crate::process::tokio_command(std::env::current_exe().unwrap())
.args([
"--exact",
"commands::up::api_v2::tests::reconnect_child",
Expand Down Expand Up @@ -1809,7 +1809,7 @@ fn dashboard_connect_clears_the_engine_breaker_and_resumes_pending_runs() {
let directory =
std::env::temp_dir().join(format!("orx-dashboard-host-{}", uuid::Uuid::new_v4()));
std::fs::create_dir_all(&directory).unwrap();
let mut command = std::process::Command::new(std::env::current_exe().unwrap());
let mut command = crate::process::command(std::env::current_exe().unwrap());
command
.args([
"--exact",
Expand Down Expand Up @@ -2016,7 +2016,7 @@ async fn dashboard_host_lifecycle_child() {
let tested: Value = tested.json().await.unwrap();
assert_eq!(tested["reachable"], true, "{tested}");
assert_eq!(server.auth_attempts().unwrap(), attempts);
let processes = std::process::Command::new("ps")
let processes = crate::process::command("ps")
.args(["-axo", "ppid=,comm=,args="])
.output()
.unwrap();
Expand Down Expand Up @@ -2468,7 +2468,7 @@ async fn initial_connection_failure_and_idle_refusal_rediscover_without_replayin
let exiting = tokio::spawn(async move {
axum::serve(listener, app).await.unwrap();
});
let mut command = tokio::process::Command::new(std::env::current_exe().unwrap());
let mut command = crate::process::tokio_command(std::env::current_exe().unwrap());
command
.args([
"--exact",
Expand Down
4 changes: 2 additions & 2 deletions src/engine/adapters/api_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ async fn isolated(test: &str) -> Option<PathBuf> {
let server = tokio::spawn(async move {
axum::serve(listener, app).await.unwrap();
});
let output = tokio::process::Command::new(std::env::current_exe().unwrap())
let output = crate::process::tokio_command(std::env::current_exe().unwrap())
.args([
"--exact",
&format!("engine::adapters::api_tests::{test}"),
Expand Down Expand Up @@ -1177,7 +1177,7 @@ async fn legacy_rejected_key(root: PathBuf, watching: bool) {
.file_name()
.to_string_lossy()
.starts_with("ssh-service-")));
let processes = std::process::Command::new("ps")
let processes = crate::process::command("ps")
.args(["-axo", "command"])
.output()
.unwrap();
Expand Down
10 changes: 6 additions & 4 deletions src/engine/adapters/local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::fs::{self, OpenOptions};
#[cfg(windows)]
use std::io::Write;
use std::path::{Path, PathBuf};
use std::process::{Command, Stdio};
use std::process::Stdio;
use std::time::Duration;

use async_trait::async_trait;
Expand Down Expand Up @@ -203,7 +203,7 @@ impl Local {
.create(true)
.append(true)
.open(dir.join("wrapper.log"))?;
let status = Command::new(crate::local::bash::program())
let status = crate::process::command(crate::local::bash::program())
.args(["-c", "\"$@\" &", "orx-local"])
.arg(binary)
.arg("wrap")
Expand Down Expand Up @@ -243,7 +243,7 @@ impl Local {
dir.join("pid_script"),
script_path.to_string_lossy().as_bytes(),
)?;
let mut command = Command::new(crate::local::bash::program());
let mut command = crate::process::command(crate::local::bash::program());
command
.arg(crate::local::bash::bash_path(&script_path))
.envs(&env)
Expand Down Expand Up @@ -479,7 +479,9 @@ impl Backend for Local {
}
std::thread::sleep(Duration::from_millis(100));
}
let output = Command::new("ps").args(["-axo", "pgid=,stat="]).output()?;
let output = crate::process::command("ps")
.args(["-axo", "pgid=,stat="])
.output()?;
if !output.status.success() {
bail!("Could not inspect the local process group");
}
Expand Down
18 changes: 9 additions & 9 deletions src/engine/adapters/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ async fn ssh_idempotent_launch_staging_notify_and_cleanup() {
fs::create_dir(&snapshot).unwrap();
fs::write(snapshot.join("value"), "staged").unwrap();
let archive = f.server.directory().join("source.tar");
assert!(std::process::Command::new("tar")
assert!(crate::process::command("tar")
.arg("-cf")
.arg(&archive)
.arg("-C")
Expand Down Expand Up @@ -583,7 +583,7 @@ async fn fifty_runs_share_one_ssh_session() {
})
.await
.unwrap();
let output = std::process::Command::new("ps")
let output = crate::process::command("ps")
.args(["-A", "-ww", "-o", "comm=,args="])
.output()
.unwrap();
Expand Down Expand Up @@ -695,7 +695,7 @@ async fn adopted_legacy_run_uses_read_only_inspection_and_group_cancel() {
fs::create_dir(&dir).unwrap();
let script = "sleep 60";
fs::write(dir.join("run.sh"), script).unwrap();
let mut child = std::process::Command::new("bash")
let mut child = crate::process::command("bash")
.arg(dir.join("run.sh"))
.process_group(0)
.spawn()
Expand Down Expand Up @@ -1127,7 +1127,7 @@ async fn submission_child() {
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn kill_engine_at_each_submission_boundary_then_restart_executes_once() {
if std::env::var_os("ORX_ADAPTER_CRASH_PARENT").is_none() {
let output = tokio::process::Command::new(std::env::current_exe().unwrap())
let output = crate::process::tokio_command(std::env::current_exe().unwrap())
.args(["--exact", "engine::adapters::tests::kill_engine_at_each_submission_boundary_then_restart_executes_once", "--nocapture"])
.env("ORX_ADAPTER_CRASH_PARENT", "1")
.env(crate::jobs::tinker::API_KEY_ENV, "test-only-tinker-key")
Expand All @@ -1152,7 +1152,7 @@ async fn kill_engine_at_each_submission_boundary_then_restart_executes_once() {
json!({"id":id,"script":script,"kind":kind}).to_string(),
)
.unwrap();
let output = tokio::process::Command::new(std::env::current_exe().unwrap())
let output = crate::process::tokio_command(std::env::current_exe().unwrap())
.args([
"--exact",
"engine::adapters::tests::submission_child",
Expand Down Expand Up @@ -1412,7 +1412,7 @@ async fn interrupted_blob_upload_recovers_without_failing_the_run() {
fs::create_dir(&source).unwrap();
fs::write(source.join("large"), vec![b'x'; 8 * 1024 * 1024]).unwrap();
let archive = f.server.directory().join("upload.tar");
assert!(std::process::Command::new("tar")
assert!(crate::process::command("tar")
.arg("-cf")
.arg(&archive)
.arg("-C")
Expand Down Expand Up @@ -1466,7 +1466,7 @@ async fn a_source_swept_before_launch_is_restaged_and_runs() {
fs::create_dir(&source).unwrap();
fs::write(source.join("train"), "x").unwrap();
let archive = f.server.directory().join("swept.tar");
assert!(std::process::Command::new("tar")
assert!(crate::process::command("tar")
.arg("-cf")
.arg(&archive)
.arg("-C")
Expand Down Expand Up @@ -2157,7 +2157,7 @@ async fn ssh_recovery_cancels_a_fully_staged_intent_before_launch_repair() {
let dir = f.dir(&intent.run.id);
fs::create_dir_all(dir.join("repo")).unwrap();
let archive = dir.join("source.tar");
assert!(std::process::Command::new("tar")
assert!(crate::process::command("tar")
.args(["-cf"])
.arg(&archive)
.arg("-C")
Expand Down Expand Up @@ -2997,7 +2997,7 @@ async fn legacy_survivors_settle_on_group_absence_without_reconnect() {
] {
let dir = f.server.home().join(id);
fs::create_dir(&dir).unwrap();
let mut child = std::process::Command::new("sleep")
let mut child = crate::process::command("sleep")
.arg("60")
.process_group(0)
.spawn()
Expand Down
7 changes: 2 additions & 5 deletions src/engine/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,16 +190,13 @@ mod tests {
#[tokio::test]
async fn a_live_submitter_is_killed_and_a_reused_pid_is_not_mistaken_for_it() {
let mut child = if cfg!(windows) {
std::process::Command::new("ping")
crate::process::command("ping")
.args(["-n", "60", "127.0.0.1"])
.stdout(std::process::Stdio::null())
.spawn()
.unwrap()
} else {
std::process::Command::new("sleep")
.arg("60")
.spawn()
.unwrap()
crate::process::command("sleep").arg("60").spawn().unwrap()
};
let recorded = identity(child.id()).unwrap();
let impostor = SubmitterIdentity {
Expand Down
2 changes: 1 addition & 1 deletion src/engine/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1346,7 +1346,7 @@ mod tests {
const CHILD: &str = "ORX_TEST_RETIREMENT_BACKOFF";
if std::env::var_os(CHILD).is_none() {
let server = orx_test_support::Sshd::start().unwrap();
let output = std::process::Command::new(std::env::current_exe().unwrap())
let output = crate::process::command(std::env::current_exe().unwrap())
.args([
"--exact",
"engine::runtime::tests::ssh_retirement_failures_wait_five_minutes_before_retrying",
Expand Down
7 changes: 3 additions & 4 deletions src/engine/runtime/chaos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use std::collections::BTreeMap;
use std::fs;
use std::io::{Read, Seek, SeekFrom};
use std::num::NonZeroU64;
use std::process::Command;
use std::time::Instant;

pub(crate) mod rng;
Expand Down Expand Up @@ -146,7 +145,7 @@ async fn chaos_engine_worker() {
fn worker(server: &Sshd, hook: Option<&str>) -> Process {
let ready = server.directory().join("worker-ready");
let _ = fs::remove_file(&ready);
let mut command = Command::new(std::env::current_exe().unwrap());
let mut command = crate::process::command(std::env::current_exe().unwrap());
command
.args([
"--exact",
Expand Down Expand Up @@ -389,7 +388,7 @@ fn assert_step(
}
terminal += usize::from(phase.is_terminal());
}
let output = Command::new("ps")
let output = crate::process::command("ps")
.args(["-axo", "comm=,args="])
.output()
.unwrap();
Expand Down Expand Up @@ -475,7 +474,7 @@ fn held_outage_does_not_make_an_old_live_marker_prove_receipt_reconciliation() {
.set_times(fs::FileTimes::new().set_modified(old))
.unwrap();
}
let worker = Process::spawn(&mut Command::new("true")).unwrap();
let worker = Process::spawn(&mut crate::process::command("true")).unwrap();
let mut starts = BTreeMap::new();
assert_eq!(assert_step(&server, &worker, &mut starts, None), 0);
let healthy = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
Expand Down
5 changes: 1 addition & 4 deletions src/engine/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -636,10 +636,7 @@ async fn a_relaunch_interrupted_again_waits_out_the_backoff_with_the_launch_erro
#[tokio::test]
async fn recovery_waits_out_a_recorded_submitter_before_asking_the_backend() {
let f = Fixture::new();
let mut child = std::process::Command::new("sleep")
.arg("60")
.spawn()
.unwrap();
let mut child = crate::process::command("sleep").arg("60").spawn().unwrap();
*f.backend.submitter.lock().unwrap() = Some(child.id());
f.backend
.then_launch(Err(LaunchError::Interrupted {
Expand Down
2 changes: 1 addition & 1 deletion src/engine/transport/ssh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl Drop for Session {
}

pub(super) fn command(config: &Config) -> Command {
let mut command = Command::new("ssh");
let mut command = crate::process::tokio_command("ssh");
if let Some(path) = &config.ssh_config {
command.arg("-F").arg(path);
}
Expand Down
2 changes: 1 addition & 1 deletion src/engine/transport/ssh/properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::engine::runtime::chaos::rng::Rng;

fn stub(bytes: &[u8]) -> Session {
let hex: String = bytes.iter().map(|byte| format!("{byte:02x}")).collect();
let mut child = Command::new("python3")
let mut child = crate::process::tokio_command("python3")
.args(["-c", "import os,sys; os.write(1,bytes.fromhex(sys.argv[1])); os.close(1); sys.stdin.buffer.read()", &hex])
.stdin(Stdio::piped()).stdout(Stdio::piped()).stderr(Stdio::null()).kill_on_drop(true).spawn().unwrap();
Session {
Expand Down
8 changes: 4 additions & 4 deletions src/engine/transport/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ async fn logged_attempts(server: &Sshd, count: usize) -> BTreeMap<(String, Strin
}

fn ssh_pids(server: &Sshd) -> Vec<u32> {
let output = std::process::Command::new("ps")
let output = crate::process::command("ps")
.args(["-axo", "pid=,ppid=,comm=,args="])
.output()
.unwrap();
Expand Down Expand Up @@ -309,7 +309,7 @@ async fn interactive_lifecycle(server: Sshd, factors: usize) {
let fixture = fixture.clone();
Box::pin(async move {
prompts.fetch_add(1, Ordering::SeqCst);
let answer = tokio::process::Command::new(fixture)
let answer = crate::process::tokio_command(fixture)
.arg(question)
.output()
.await?;
Expand Down Expand Up @@ -1948,7 +1948,7 @@ else
fi
"#).unwrap();
fs::set_permissions(&shim, fs::Permissions::from_mode(0o700)).unwrap();
let mut command = std::process::Command::new(std::env::current_exe().unwrap());
let mut command = crate::process::command(std::env::current_exe().unwrap());
command
.args([
"--exact",
Expand Down Expand Up @@ -2020,7 +2020,7 @@ fi
);

let plain = |scoped: bool| {
let mut command = tokio::process::Command::new("ssh");
let mut command = crate::process::tokio_command("ssh");
command
.args([
"-oBatchMode=yes",
Expand Down
2 changes: 1 addition & 1 deletion src/jobs/localbox/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ mod tests {
#[test]
fn cancellation_checks_the_job_even_after_the_exit_code() {
let dir = crate::local::git::TemporaryDirectory::new("orx-job-exited").unwrap();
let mut command = Command::new("cmd");
let mut command = crate::process::command("cmd");
command.args(["/C", "ping -n 30 127.0.0.1 >nul"]);
let mut child = spawn(&mut command, dir.path()).unwrap();
std::fs::write(dir.path().join("exit_code"), "0\n").unwrap();
Expand Down
Loading