xonecas.io
8447
Co

conveyor / commit 1e898fa

A build that conflicts with one kept meanwhile merges it before done

With two slots, a build can finish after another one was kept over the
same file (#12 vs #13). It failed with "keep or discard those first",
which was wrong (nothing was on trial), and its work was lost: the
follow-up's VM never saw the branch.

`conveyor done` now checks the branch still merges onto the trial
(git merge-tree, no worktree). If not, the trial goes into the guest and
done answers "Not done yet: git merge trial ..."; the agent resolves it
with its context and calls done again. A conflict that still gets
through names the kept builds and their files.

The bake also installs JetBrains Mono, so agents check the editor in its
real font.

Co-Authored-By: Claude Opus 5.5

sacenox2026-11-09 1e898fa0f4ad734b066129cbdf7ac358bc40b88b parent a08bae5

6 files changed

crates/conveyor/src/agent.rs+17−1
@@ -42,7 +42,8 @@ fn run(p: &Project, id: u32) -> Result<String, String> {
4242
4343 let local = crate::paths::vm_sock(&name, "verbs");
4444 let remote = format!("/home/{}/.conveyor/{name}-{}.sock", vm::USER, std::process::id());
45- let verbs = Listener::start(&p.slug, id, local.clone()).map_err(|e| e.to_string())?;
45+ let check = merges_onto(p, &url, &git_ssh, &branch);
46+ let verbs = Listener::start(&p.slug, id, local.clone(), check).map_err(|e| e.to_string())?;
4647 note("agent working");
4748 let stream = File::create(store::dir(&p.slug, id).join("stream.jsonl")).map_err(|e| e.to_string())?;
4849 let mut agent = vm.ssh()
@@ -73,6 +74,21 @@ fn run(p: &Project, id: u32) -> Result<String, String> {
7374 })
7475 }
7576
77+/// What `done` checks: the branch still merges onto what it goes on (the trial, or main), which
78+/// may have moved while the agent worked. If not, that goes into the guest as a branch of the
79+/// same name, for the agent to merge.
80+pub(crate) fn merges_onto(p: &Project, url: &str, git_ssh: &str, branch: &str) -> impl Fn() -> Result<(), String> + Send + 'static {
81+ let (repo, url, git_ssh, branch) = (p.path.clone(), url.to_owned(), git_ssh.to_owned(), branch.to_owned());
82+ let onto = if p.library { "trial" } else { "main" };
83+ move || {
84+ git(&repo, &git_ssh, &["fetch", "-q", &url, &format!("+{branch}:{branch}")])?;
85+ let Err(files) = library::merges(&repo, onto, &branch) else { return Ok(()) };
86+ git(&repo, &git_ssh, &["push", "-q", "-f", &url, &format!("{onto}:{onto}")])?;
87+ Err(format!("Not done yet: while you worked, the user kept or tried other builds, and your branch conflicts with them in {files}. \
88+ Run `git merge {onto}`, resolve it so both changes survive, check it again, commit, then `conveyor done` again."))
89+ }
90+}
91+
7692 /// Copies the ticket's attached files to ~/ticket/files in the guest. What the prompt says of them.
7793 fn give_files(vm: &Vm, p: &Project, id: u32) -> Result<String, String> {
7894 let names: Vec<String> = store::files(&p.slug, id).iter().filter_map(|f| Some(f.file_name()?.to_str()?.to_owned())).collect();
crates/conveyor/src/library.rs+15−1
@@ -129,6 +129,17 @@ pub fn try_out(p: &Project, id: u32, branch: &str) -> Result<(), String> {
129129 trial(Some(id)).inspect_err(|_| { let _ = trial(None); })
130130 }
131131
132+/// Whether `branch` merges onto `onto` without conflicts, worktree untouched. If not, the
133+/// files that conflict.
134+pub fn merges(repo: &Path, onto: &str, branch: &str) -> Result<(), String> {
135+ let out = Command::new("git").arg("-C").arg(repo).args(["merge-tree", "--write-tree", "--name-only", "--no-messages", onto, branch])
136+ .output().map_err(|e| e.to_string())?;
137+ if out.status.success() { return Ok(()); }
138+ let text = String::from_utf8_lossy(&out.stdout);
139+ let files: Vec<&str> = text.lines().skip(1).filter(|l| !l.is_empty()).collect();
140+ Err(if files.is_empty() { String::from_utf8_lossy(&out.stderr).trim().into() } else { files.join(", ") })
141+}
142+
132143 /// Keeps a build on trial: merges it into main. What it was built on comes with it.
133144 pub fn keep(id: u32) -> Result<(), String> {
134145 store::ticket(SLUG, id).filter(|t| t.state == "review").ok_or("that build isn't on trial")?;
@@ -164,7 +175,10 @@ fn trial(fresh: Option<u32>) -> Result<(), String> {
164175 for id in ids {
165176 if let Err(e) = git(&dir, "", &[&COMMIT[..], &["merge", "-q", "--no-edit", &format!("t-{id}")]].concat()) {
166177 let _ = git(&dir, "", &["merge", "--abort"]);
167- let why = format!("it conflicts with the builds on trial before it; keep or discard those first\n{e}");
178+ let why = match merges(&lib, "main", &format!("t-{id}")) {
179+ Err(files) => format!("it conflicts with builds you kept since it started, in {files}; Ctrl+click to have it merged"),
180+ Ok(()) => format!("it conflicts with the builds on trial before it; keep or discard those first\n{e}"),
181+ };
168182 if Some(id) == fresh { return Err(why); }
169183 store::event(SLUG, id, json!({"kind": "error", "msg": format!("left off the trial: {why}")}));
170184 }
crates/conveyor/src/library_tests.rs+14−0
@@ -74,6 +74,20 @@ fn trial_edges() {
7474 keep(b).unwrap();
7575 assert_eq!(state(b), "done");
7676
77+ // c ran while b was kept (#12). Its `done` pushes the trial into the guest for the agent to
78+ // merge, and passes once it has.
79+ assert!(try_out(&p, c, &branch_c).unwrap_err().contains("kept since it started"));
80+ let guest = paths::data().join("guest");
81+ run(&paths::library(), &["clone", "-q", "-b", &branch_c, &paths::library().to_string_lossy(), &guest.to_string_lossy()]);
82+ let check = crate::agent::merges_onto(&p, &guest.to_string_lossy(), "", &branch_c);
83+ assert!(check().unwrap_err().contains("widgets/root.rs"));
84+ assert!(git(&guest, "", &[&COMMIT[..], &["merge", "-q", "trial"]].concat()).is_err());
85+ fs::write(guest.join("widgets/root.rs"), format!("{main_root}// b\n// c\n")).unwrap();
86+ run(&guest, &["commit", "-qam", "merge the trial"]);
87+ check().unwrap();
88+ try_out(&p, c, &branch_c).unwrap();
89+ assert_eq!(state(c), "review");
90+
7791 // Discard: back to draft, out of the trial.
7892 let (e, branch_e) = build("main", "e.rs", WIDGET);
7993 try_out(&p, e, &branch_e).unwrap();
crates/conveyor/src/rules.md+1−1
@@ -8,7 +8,7 @@ You talk to conveyor only through the `conveyor` command:
88 - `conveyor deviate "<change>" --recommend "<path>"`: when doing the ticket well needs something outside its stated scope. Record it, then continue on your recommended path.
99 - `conveyor block --reason "<reason>" --recommend "<path>"`: only for things nobody inside this VM can resolve, such as a missing secret, an account, a payment, access, or a legal question. Finish everything that does not depend on the blocker, then stop. Never build a workaround for a blocker.
1010 - `conveyor note "<text>"`: progress worth showing on the timeline.
11-- `conveyor done "<summary>"`: when the acceptance criteria are met and committed.
11+- `conveyor done "<summary>"`: when the acceptance criteria are met and committed. If it answers "Not done yet", do what it says, then call it again.
1212
1313 Never ask the user a question. Every question becomes a `decide`, a `deviate` or a `block`.
1414
crates/conveyor/src/verbs.rs+14−6
@@ -60,7 +60,7 @@ pub fn client(verb: &str, rest: &[String]) -> i32 {
6060 Ok(serde_json::from_str(&line).unwrap_or(Value::Null))
6161 })();
6262 match res {
63- Ok(r) => { println!("{}", r["msg"].as_str().unwrap_or("?")); 0 }
63+ Ok(r) => { println!("{}", r["msg"].as_str().unwrap_or("?")); if r["ok"] == false { 1 } else { 0 } }
6464 Err(e) => { eprintln!("conveyor {verb}: can't reach conveyor at {}: {e}", path.display()); 1 }
6565 }
6666 }
@@ -81,8 +81,9 @@ pub struct Listener {
8181 }
8282
8383 impl Listener {
84- /// Listens on `path` for one ticket; every verb goes to the ticket's timeline.
85- pub fn start(project: &str, id: u32, path: PathBuf) -> std::io::Result<Listener> {
84+ /// Listens on `path` for one ticket; every verb goes to the ticket's timeline. `done` counts
85+ /// only once `check` passes; otherwise the agent gets its message and keeps working.
86+ pub fn start(project: &str, id: u32, path: PathBuf, check: impl Fn() -> Result<(), String> + Send + 'static) -> std::io::Result<Listener> {
8687 let _ = std::fs::remove_file(&path);
8788 let srv = UnixListener::bind(&path)?;
8889 srv.set_nonblocking(true)?;
@@ -91,7 +92,7 @@ impl Listener {
9192 let thread = std::thread::spawn(move || {
9293 while !st.load(Ordering::Relaxed) {
9394 match srv.accept() {
94- Ok((c, _)) => { let _ = handle(&project, id, c, &out); }
95+ Ok((c, _)) => { let _ = handle(&project, id, c, &out, &check); }
9596 Err(_) => std::thread::sleep(Duration::from_millis(100)),
9697 }
9798 }
@@ -107,7 +108,7 @@ impl Listener {
107108 }
108109 }
109110
110-fn handle(project: &str, id: u32, c: UnixStream, outcome: &Mutex<Outcome>) -> std::io::Result<()> {
111+fn handle(project: &str, id: u32, c: UnixStream, outcome: &Mutex<Outcome>, check: &dyn Fn() -> Result<(), String>) -> std::io::Result<()> {
111112 c.set_nonblocking(false)?;
112113 let mut line = String::new();
113114 BufReader::new(&c).read_line(&mut line)?;
@@ -116,7 +117,14 @@ fn handle(project: &str, id: u32, c: UnixStream, outcome: &Mutex<Outcome>) -> st
116117 store::event(project, id, json!({"kind": "verb", "verb": verb, "args": msg["args"]}));
117118 match verb {
118119 "block" => { *outcome.lock().unwrap() = Outcome::Blocked; store::set_state(project, id, "parked"); }
119- "done" => { let mut o = outcome.lock().unwrap(); if *o != Outcome::Blocked { *o = Outcome::Done(msg["args"]["text"].as_str().unwrap_or("").into()); } }
120+ "done" => {
121+ if let Err(e) = check() {
122+ store::event(project, id, json!({"kind": "conveyor", "msg": e}));
123+ return writeln!(&c, "{}", json!({"ok": false, "msg": e}));
124+ }
125+ let mut o = outcome.lock().unwrap();
126+ if *o != Outcome::Blocked { *o = Outcome::Done(msg["args"]["text"].as_str().unwrap_or("").into()); }
127+ }
120128 _ => {}
121129 }
122130 writeln!(&c, "{}", json!({"ok": true, "msg": reply(verb)}))
tools/bake.py+1−1
@@ -19,7 +19,7 @@ VMS = DATA / "vms"
1919 KEY = DATA / "id_ed25519"
2020 ISO = max(Path.home().glob("s/cachyos-desktop-linux*.iso"), default=None)
2121 USER, PASS = "sacenox", "zzzz"
22-DEV_PKGS = "starship fzf tree-sitter-cli zig rustup nodejs npm kitty nvim git openssh claude-code qemu-guest-agent vulkan-swrast".split()
22+DEV_PKGS = "starship fzf tree-sitter-cli zig rustup nodejs npm kitty nvim git openssh claude-code qemu-guest-agent vulkan-swrast ttf-jetbrains-mono ttf-jetbrains-mono-nerd".split()
2323 XORG_PKGS = "libwnck3 mesa-utils xorg-xdpyinfo xorg-server xorg-xinit xorg-xinput xorg-xkill xorg-xrandr".split()
2424 DE_PKGS = """blueman file-roller galculator gvfs lightdm lightdm-gtk-greeter network-manager-applet ristretto
2525 thunar-archive-plugin xdg-user-dirs-gtk xed xfce4 xfce4-notifyd xfce4-pulseaudio-plugin xfce4-screenshooter