From 193c6cd9eb79d22fa1bd8a4601a2093db2014437 Mon Sep 17 00:00:00 2001 From: hermes Date: Fri, 13 Nov 2026 18:22:33 +0000 Subject: [PATCH] default profile falls back to built-in defaults --- README.md | 3 +++ src/profile.rs | 9 +++++++-- tests/e2e.py | 11 +++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index bb3edbd..b186c30 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,9 @@ done, failed, needs-human (gate still red, or the agent wanted something the all ## Profile (`~/.config/orch/profiles/NAME.toml`) +`--profile` defaults to `default`; if `default.toml` does not exist, built-in defaults apply (`hx` from PATH, your own +`~/.hx` login, 2 retries, no allowlist). Any other missing profile name is an error. + ```toml hx = "hx" # command home = "/work/hxhome" # own HOME => own hx login diff --git a/src/profile.rs b/src/profile.rs index 5a6c8bc..2a2fdad 100644 --- a/src/profile.rs +++ b/src/profile.rs @@ -94,8 +94,13 @@ impl Profile { let path = crate::config_dir() .join("profiles") .join(format!("{name}.toml")); - let s = std::fs::read_to_string(&path) - .with_context(|| format!("profile {}", path.display()))?; + let s = match std::fs::read_to_string(&path) { + // only the implicit profile may be missing; a typo in any other name must still fail + Err(e) if name == "default" && e.kind() == std::io::ErrorKind::NotFound => { + String::new() + } + r => r.with_context(|| format!("profile {}", path.display()))?, + }; Self::parse(&s).with_context(|| path.display().to_string()) } diff --git a/tests/e2e.py b/tests/e2e.py index c59bb79..a6ee040 100644 --- a/tests/e2e.py +++ b/tests/e2e.py @@ -316,6 +316,17 @@ shutil.copytree(ev, broken) bad = subprocess.run([orch, "bench", str(broken), "--check"], env=env, capture_output=True, text=True) assert bad.returncode == 1 and "broken case" in bad.stdout, bad +# --- no profile file: `default` falls back to built-in defaults, other names still fail --- +nocfg = {**env, "ORCH_CONFIG_DIR": str(tmp / "no-cfg"), "FAKE_VERSION": "0"} +(tmp / "bin").mkdir(exist_ok=True) +hxw = tmp / "bin/hx" +hxw.write_text(f"#!/bin/sh\nexec {sys.executable} {fake} \"$@\"\n") +hxw.chmod(0o755) +nb = subprocess.run([orch, "bench", str(ev), "--case", "fix-typo-readme", "--out", str(tmp / "nb.jsonl")], env={**nocfg, "PATH": f"{tmp / 'bin'}:{os.environ['PATH']}", "SOLVE_DIR": str(ev)}, capture_output=True, text=True) +assert nb.returncode == 1 and (tmp / "nb.jsonl").exists() and "default.toml" not in nb.stderr, nb # hx ran (unsolved: SOLVE_DIR is filtered from its env), no missing-profile error +miss = subprocess.run([orch, "bench", str(ev), "--profile", "typo"], env=nocfg, capture_output=True, text=True) +assert miss.returncode != 0 and "typo.toml" in miss.stderr, miss + # kill orch mid-run: status must say interrupted and hx must be dead after the next orch call pidfile = tmp / "hx.pid" p = subprocess.Popen([orch, "run", str(task("killed", "HANG")), "--repo", str(repo), "--profile", "p"],