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: second review round for the run engine setting
Keep hosted cancellation semantics separate from wrapper stop proof, restore supervised monitoring notices and Windows login attempts, and retain source timestamp bounds without replaying terminal effects.

Assisted-by: gpt-6.1-sol
  • Loading branch information
small-angel committed Nov 5, 2026
commit 827ade89d3382092a42ea7c41cf57bb64dcf4e03
11 changes: 6 additions & 5 deletions arc/agents.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,12 +211,13 @@ chat, or on its own with its own worktree, and the delegator's later
`subscribe` or `wait` does not undo that. A side chat reports only when its
agent `send`s. Agents answer questions through orx; approvals stay with the user.

**Agents write to each other in the open.** Everything orx or another chat's
agent writes into a chat (a task, a message, news) reaches its agent opening
with `[orx]`, so the agent can tell it from the user. The transcript records
it with its kind and sender and keeps what the sender wrote, refs included;
**Agents write to each other in the open.** A task, message or piece of chat
news that orx or another chat's agent writes into a chat reaches its agent
opening with `[orx]`, so the agent can tell it from the user. The transcript
records it with its kind and sender and keeps what the sender wrote, refs included;
only the agent reads the refs expanded and the instructions around them. The
dashboard shows it as the sender's message, and a finished run by its outcome.
dashboard shows it as the sender's message. Run results and monitoring notices
reach agents in hidden turns; the transcript records only the agent's reply.

**Messages travel by reference.** Each user message reaches its agent tagged
with a short ref from its id. A ref in a task or message, the user's included,
Expand Down
15 changes: 7 additions & 8 deletions arc/experiments.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,13 @@ unreconciled until the user abandons it.

### Cancel and Abandon

Cancelling records the intent and its reason on the run. For an active run, a
nonzero exit or signal after an accepted cancel ends Cancelled, preserving the
reported exit code. The engine delivers the stop whenever the run's machine is
reachable, and the run's wrapper performs the stop, so verification never races
its own exit: a container's cancel hook, TERM, a grace period, KILL, then fresh
scans of every process carrying the
run's tag. Completion of a run is its direct child's exit; processes it left
behind are listed, raise one notice, and are stopped only on request.
Cancelling records the intent and its reason on the run. For a run on a hosted
service, a nonzero exit or signal after an accepted cancel ends Cancelled,
preserving the reported exit code. The engine delivers the stop whenever the
run's machine is reachable, and the run's wrapper performs the stop, so
verification never races its own exit: a container's cancel hook, TERM, a
grace period, KILL, then fresh scans of every process carrying the run's tag.
Completion of a run is its direct child's exit; processes it left behind are listed, raise one notice, and are stopped only on request.

| State | Meaning |
| --- | --- |
Expand Down
8 changes: 7 additions & 1 deletion src/commands/up.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6538,7 +6538,13 @@ async fn ssh_run_socket(
target: crate::jobs::ssh::SshTarget,
command: String,
) {
let connection = match crate::jobs::ssh::interactive_args(&target, None, Some(command)).await {
let connection = match crate::jobs::ssh::prepare_interactive_connection(
&target,
None,
Some(command),
)
.await
{
Ok(connection) => connection,
Err(error) => {
send_ws_error(&mut socket, error.to_string()).await;
Expand Down
1 change: 1 addition & 0 deletions src/engine/adapters/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -967,6 +967,7 @@ async fn local_direct_child_completion_recovery_and_pages() {
.unwrap()
.unwrap()
.finished_at
.map(|finished_at| finished_at.min(f.clock.wall_ms()))
);
assert!(started.elapsed() < Duration::from_secs(2));

Expand Down
31 changes: 30 additions & 1 deletion src/engine/legacy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use super::{handle_of, phase_of, Engine};
use crate::error::Result;
use crate::jobs::ssh::ContainerRun;
use crate::jobs::BackendDescriptor;
use crate::store::{Contact, SeenRow, StoredRun, TERMINAL};
use crate::store::{Contact, SeenRow, StoredRun, ATTENTION, RECOVERED, TERMINAL};

/// 0.2.x launched without wrapper or tags, so `CancelLegacy` only reaches the recorded group.
const LEGACY_CANCEL_NOTE: &str = "Cancelled. This run was launched by orx 0.2.x, so only its \
Expand Down Expand Up @@ -136,6 +136,35 @@ impl Engine {
chats.push(chat);
}
}
} else if !adopting {
let descriptor = BackendDescriptor::parse(&run.backend_json)?;
for chat in store.run_subscribers(id)? {
let (kind, body) = if descriptor.monitoring_error.is_some() {
let body = format!(
"[orx] orx can no longer monitor these live runs:\n\
- run `{id}` of experiment `{}` (still **{}**)\n\
Run `orx exp status <expId>` for the reason and tell the user so they \
can fix it. orx wakes you once it can see a run finish; until then \
each run keeps its current status.",
run.experiment_id, run.status
);
(ATTENTION, body)
} else if store.settle_outage_notice(id, &chat)? {
(
RECOVERED,
format!(
"[orx] Run `{id}` is reachable again; status {}.",
run.status
),
)
} else {
continue;
};
let dedupe = store.outage_dedupe(id, &chat, kind)?;
if store.insert_run_notice(id, &chat, kind, &dedupe, &body, now)? {
chats.push(chat);
}
}
}
let changed = seen != Some(&(run.status.clone(), run.updated_at));
if terminal || adopting {
Expand Down
29 changes: 22 additions & 7 deletions src/engine/reconcile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,13 @@ impl Engine {
hook();
}
}
let hosted = match super::handle_of(&load(&self.store(), run_id)?.0) {
Some(Handle::Api { .. }) => true,
Some(Handle::Legacy { descriptor }) => {
super::adapters::api::provider(&descriptor.kind).is_ok()
}
_ => false,
};
let now = self.clock.wall_ms();
// Decided under the store lock that cancel registration also takes.
self.commit(run_id, |phase, state| {
Expand All @@ -289,7 +296,8 @@ impl Engine {
finished_at,
code,
signal,
} if matches!(phase, Phase::Starting | Phase::Running)
} if hosted
&& matches!(phase, Phase::Starting | Phase::Running)
&& state.cancel_accepted_at.is_some()
&& (code.is_some_and(|code| code != 0) || signal.is_some()) =>
{
Expand Down Expand Up @@ -446,12 +454,14 @@ impl Engine {
store.set_result_markdown(run_id, reason)?;
}
}
if moved && !recorded
|| is_tombstone(old_phase, &state.contact) && change.finished_at.is_some()
{
let ended_at = phase
.is_terminal()
.then_some(change.finished_at.unwrap_or(now));
let ended_at = phase.is_terminal().then(|| {
change
.finished_at
.unwrap_or(now)
.min(now)
.max(run.created_at)
});
if moved && !recorded {
let started_at = change
.started_at
.filter(|_| phase == Phase::Running && super::is_engine_row(&run));
Expand All @@ -466,6 +476,11 @@ impl Engine {
change.exit_code,
started_at,
)?;
} else if is_tombstone(old_phase, &state.contact) && change.finished_at.is_some() {
tx.execute(
"UPDATE runs SET ended_at = ?2, exit_code = COALESCE(?3, exit_code) WHERE id = ?1",
rusqlite::params![run_id, ended_at, change.exit_code],
)?;
}

let settled = phase.is_terminal() && !moved && state.contact == Contact::Live;
Expand Down
109 changes: 70 additions & 39 deletions src/engine/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -975,7 +975,7 @@ impl Commands for Runtime {
let target = SshTarget::alias(&host);
#[cfg(unix)]
if supervised && prompt.is_some() {
crate::jobs::ssh::interactive_args(&target, None, None).await?;
drop(crate::jobs::ssh::prepare_interactive_connection(&target, None, None).await?);
}
self.ssh(&Self::host_key(&host, slurm)?)?;
let connections: Vec<_> = lock(&self.conns)
Expand All @@ -996,19 +996,20 @@ impl Commands for Runtime {
}
}
}
if let Some((_, error)) = worst {
return Err(error);
}
if let Err(error) = crate::jobs::ssh::service::reset_existing_backoff(&target).await {
eprintln!("Host {host}: could not reset supervisor SSH backoff: {error:#}");
}
let connected = worst.map_or(Ok(()), |(_, error)| Err(error));
#[cfg(windows)]
if supervised {
connect_supervised(prompt.as_ref(), |operation| {
let connected = if supervised {
connect_supervised(connected, prompt.as_ref(), |operation| {
crate::jobs::ssh::service::request(&target, operation)
})
.await?;
}
.await
} else {
connected
};
connected?;
}
crate::commands::up::compute_settings::check(
backend,
Expand Down Expand Up @@ -1060,43 +1061,51 @@ impl Commands for Runtime {
}

#[cfg(any(windows, test))]
async fn connect_supervised<F, Fut>(prompt: Option<&Prompt>, mut request: F) -> Result<()>
async fn connect_supervised<F, Fut>(
connected: Result<()>,
prompt: Option<&Prompt>,
mut request: F,
) -> Result<()>
where
F: FnMut(Value) -> Fut,
Fut: std::future::Future<Output = Result<Value>>,
{
if request(json!({"op": "status"})).await?["connected"] == true {
return Ok(());
}
let prompt = prompt.ok_or_else(|| {
anyhow!("SSH disconnected. Use Connect to authenticate; background login is disabled.")
})?;
let start = request(json!({"op": "connect_start"})).await?;
let attempt = start["attempt"]
.as_str()
.ok_or_else(|| anyhow!("SSH Connect returned no authentication attempt. Retry Connect."))?;
let result = async {
loop {
let status = request(json!({"op": "connect_status", "attempt": attempt})).await?;
if status["done"] == true {
if let Some(error) = status["error"].as_str() {
bail!("{error}");
let login = async {
if request(json!({"op": "status"})).await?["connected"] == true {
return Ok(());
}
let prompt = prompt.ok_or_else(|| {
anyhow!("SSH disconnected. Use Connect to authenticate; background login is disabled.")
})?;
let start = request(json!({"op": "connect_start"})).await?;
let attempt = start["attempt"].as_str().ok_or_else(|| {
anyhow!("SSH Connect returned no authentication attempt. Retry Connect.")
})?;
let result = async {
loop {
let status = request(json!({"op": "connect_status", "attempt": attempt})).await?;
if status["done"] == true {
if let Some(error) = status["error"].as_str() {
bail!("{error}");
}
return Ok(());
}
return Ok(());
}
if let Some(question) = status["prompt"].as_str() {
let answer = prompt(question.to_owned())
.await?
.ok_or_else(|| anyhow!("SSH authentication cancelled."))?;
request(json!({"op": "connect_answer", "attempt": attempt, "answer": answer}))
.await?;
if let Some(question) = status["prompt"].as_str() {
let answer = prompt(question.to_owned())
.await?
.ok_or_else(|| anyhow!("SSH authentication cancelled."))?;
request(json!({"op": "connect_answer", "attempt": attempt, "answer": answer}))
.await?;
}
tokio::time::sleep(Duration::from_millis(150)).await;
}
tokio::time::sleep(Duration::from_millis(150)).await;
}
.await;
let _ = request(json!({"op": "connect_cancel", "attempt": attempt})).await;
result
}
.await;
let _ = request(json!({"op": "connect_cancel", "attempt": attempt})).await;
result
connected.and(login)
}

pub(crate) fn hex(bytes: &[u8]) -> String {
Expand All @@ -1123,7 +1132,7 @@ mod tests {
async fn supervisor_connect_skips_a_live_service_and_relays_each_authentication_prompt() {
use std::collections::VecDeque;
let mut calls = Vec::new();
connect_supervised(None, |request| {
connect_supervised(Ok(()), None, |request| {
calls.push(request);
std::future::ready(Ok(json!({"connected": true})))
})
Expand All @@ -1144,7 +1153,7 @@ mod tests {
json!({}),
]);
calls.clear();
connect_supervised(Some(&prompt), |request| {
connect_supervised(Ok(()), Some(&prompt), |request| {
calls.push(request);
std::future::ready(Ok(replies.pop_front().unwrap()))
})
Expand Down Expand Up @@ -1172,6 +1181,28 @@ mod tests {
assert!(calls[2..].iter().all(|call| call["attempt"] == "login"));
}

#[tokio::test]
async fn supervisor_connect_attempts_login_after_the_engine_fails() {
let prompt: Prompt = Arc::new(|_| Box::pin(async { Ok(Some("answer".into())) }));
let mut replies = std::collections::VecDeque::from([
json!({"connected": false}),
json!({"attempt": "login"}),
json!({"done": true}),
json!({}),
]);
let mut calls = Vec::new();
let error =
connect_supervised(Err(anyhow!("Unsupported host")), Some(&prompt), |request| {
calls.push(request);
std::future::ready(Ok(replies.pop_front().unwrap()))
})
.await
.unwrap_err();
assert_eq!(error.to_string(), "Unsupported host");
assert!(calls.iter().any(|call| call["op"] == "connect_start"));
assert!(replies.is_empty());
}

#[tokio::test]
async fn supervisor_connect_cancels_the_attempt_after_errors_or_cancelled_prompts() {
let prompt: Prompt = Arc::new(|_| Box::pin(async { Ok(None) }));
Expand All @@ -1187,7 +1218,7 @@ mod tests {
Ok(json!({})),
]);
let mut calls = Vec::new();
assert!(connect_supervised(Some(&prompt), |request| {
assert!(connect_supervised(Ok(()), Some(&prompt), |request| {
calls.push(request);
std::future::ready(replies.pop_front().unwrap())
})
Expand Down
Loading