xonecas.io
8447
Co

conveyor / commit fdcfa91

Done merges a code ticket's branch into main, as Keep does for widgets

Moving a code ticket from review to done merges t-<id> into main and deletes it.
A conflict with main, or a checkout git won't overwrite, keeps it in review with
the reason in its conversation; ready then has the agent merge main. With main not
checked out, only a fast-forward lands. A widget build moved to done is kept.

Co-Authored-By: Claude Opus 5.5

sacenox2026-11-10 fdcfa913f91d34a68cf82008ec087ceea3f45e56 parent 9f8c1e2

5 files changed

DESIGN.md+1−1
@@ -93,7 +93,7 @@ Measured from the rats store in the VM: 2 projects, 314 tickets, 5 MB in total.
9393 | `parked` | VM kept, suspended | you answer; the agent resumes |
9494 | `verify` | ticket VM | conveyor runs the acceptance checks, not the agent |
9595 | `review` | host | you |
96-| `done` | store | VM and overlay deleted, branch kept |
96+| `done` | store | the branch merged into main and deleted (Keep, for a widget build). A conflict, or a checkout git won't touch, keeps it in review and says why |
9797
9898 Only `needs-scope`, `parked`, `deviate` and `review` reach you. Each is a call to action with one line, the agent's recommendation and its attachments.
9999
HANDOFF.md+4−1
@@ -1,6 +1,6 @@
11 # Handoff
22
3-State as of 2026-11-09, after v1 and five commits on top of it. The app is stable and in daily
3+State as of 2026-11-10, after v1 and the commits below. The app is stable and in daily
44 use. Read DESIGN.md for how conveyor works; this file covers where things stand and what's next.
55
66 ## The loop
@@ -66,3 +66,6 @@ rune (38 s, against 12 s).
6666 | `1e898fa` | A build that conflicts with one kept meanwhile merges it before `done` |
6767 | `3c10db6` | Tickets wait as ready while the base image is missing or baking |
6868 | `10cc698` | Ponytail pass: serde over hand-rolled formats, dead code removed |
69+| `a1a5277` | Widgets get serde in the app, a secrets store, and failed builds resume their branch |
70+| `9f8c1e2` | The keychain reaches agents as env vars; `cx.secrets()` lists it |
71+| `land.rs` | Done from review merges a code ticket's branch into main, as Keep does for widgets |
crates/conveyor/src/land.rs+98−0
@@ -0,0 +1,98 @@
1+//! Lands a code project's finished ticket: its branch merges into main, as Keep does for widgets.
2+use crate::{agent::git, library::merges};
3+use std::path::Path;
4+
5+/// Merges `branch` into `repo`'s main and deletes it. Leaves everything as it was, and says
6+/// why, when it conflicts with main or git won't touch the user's checkout.
7+pub fn land(repo: &Path, branch: &str) -> Result<(), String> {
8+ merges(repo, "main", branch).map_err(|files| format!(
9+ "{branch} conflicts with main in {files}. Move it to ready to have the agent merge main, or merge it yourself."))?;
10+ let head = git(repo, "", &["symbolic-ref", "-q", "--short", "HEAD"]).unwrap_or_default();
11+ if head.trim() == "main" {
12+ // The user's checkout: git refuses to overwrite their uncommitted changes, and says so.
13+ // It can't conflict (checked above), so there's never a merge of ours to abort.
14+ git(repo, "", &["merge", "-q", "--no-edit", branch])
15+ } else {
16+ // main isn't checked out, so there's no worktree to merge in: fast-forward only.
17+ git(repo, "", &["fetch", "-q", ".", &format!("{branch}:main")])
18+ .map_err(|_| format!("{branch} doesn't fast-forward main, and main isn't checked out. Check out main, then move it to done again."))
19+ }?;
20+ // In main now, which may not be HEAD, so -d would refuse.
21+ git(repo, "", &["branch", "-D", branch]).map(|_| ())
22+}
23+
24+#[cfg(test)]
25+mod tests {
26+ use super::*;
27+
28+ fn run(repo: &Path, args: &[&str]) -> String {
29+ git(repo, "", &[&["-c", "user.name=t", "-c", "user.email=t@t"][..], args].concat()).unwrap()
30+ }
31+
32+ fn commit(repo: &Path, file: &str, text: &str) {
33+ std::fs::write(repo.join(file), text).unwrap();
34+ run(repo, &["add", "-A"]);
35+ run(repo, &["commit", "-qm", file]);
36+ }
37+
38+ #[test]
39+ fn land_edges() {
40+ let repo = std::env::temp_dir().join(format!("conveyor-land-{}", std::process::id()));
41+ let _ = std::fs::remove_dir_all(&repo);
42+ std::fs::create_dir_all(&repo).unwrap();
43+ run(&repo, &["init", "-q", "-b", "main"]);
44+ run(&repo, &["config", "user.name", "t"]);
45+ run(&repo, &["config", "user.email", "t@t"]);
46+ commit(&repo, "a", "1\n");
47+
48+ // A fast-forward lands in the checkout and drops the branch; untracked files stay.
49+ run(&repo, &["switch", "-qc", "t-1"]);
50+ commit(&repo, "b", "b\n");
51+ run(&repo, &["switch", "-q", "main"]);
52+ std::fs::write(repo.join("idea.md"), "mine").unwrap();
53+ land(&repo, "t-1").unwrap();
54+ assert!(repo.join("b").exists() && repo.join("idea.md").exists());
55+ assert!(git(&repo, "", &["rev-parse", "-q", "--verify", "t-1"]).is_err());
56+
57+ // main moved meanwhile: a real merge.
58+ run(&repo, &["switch", "-qc", "t-2"]);
59+ commit(&repo, "c", "c\n");
60+ run(&repo, &["switch", "-q", "main"]);
61+ commit(&repo, "d", "d\n");
62+ land(&repo, "t-2").unwrap();
63+ assert!(repo.join("c").exists() && repo.join("d").exists());
64+
65+ // A conflict leaves main, the checkout and the branch alone.
66+ run(&repo, &["switch", "-qc", "t-3"]);
67+ commit(&repo, "a", "3\n");
68+ run(&repo, &["switch", "-q", "main"]);
69+ commit(&repo, "a", "main\n");
70+ let before = run(&repo, &["rev-parse", "main"]);
71+ assert!(land(&repo, "t-3").unwrap_err().contains("conflicts with main in a"));
72+ assert_eq!(run(&repo, &["rev-parse", "main"]), before);
73+ assert!(run(&repo, &["status", "--porcelain"]).lines().all(|l| l.starts_with("??")));
74+
75+ // A file in the checkout the branch would overwrite: git refuses, nothing moves.
76+ run(&repo, &["switch", "-qc", "t-4"]);
77+ commit(&repo, "e", "e\n");
78+ run(&repo, &["switch", "-q", "main"]);
79+ std::fs::write(repo.join("e"), "dirty").unwrap();
80+ let before = run(&repo, &["rev-parse", "main"]);
81+ assert!(land(&repo, "t-4").is_err());
82+ assert_eq!(run(&repo, &["rev-parse", "main"]), before);
83+ assert_eq!(std::fs::read_to_string(repo.join("e")).unwrap(), "dirty");
84+ std::fs::remove_file(repo.join("e")).unwrap();
85+
86+ // main not checked out: a fast-forward lands, a real merge is refused.
87+ run(&repo, &["switch", "-qc", "other"]);
88+ land(&repo, "t-4").unwrap();
89+ assert!(run(&repo, &["ls-tree", "--name-only", "main"]).contains('e'));
90+ run(&repo, &["switch", "-qc", "t-5", "main"]);
91+ commit(&repo, "f", "f\n");
92+ run(&repo, &["switch", "-q", "main"]);
93+ commit(&repo, "g", "g\n");
94+ run(&repo, &["switch", "-q", "other"]);
95+ assert!(land(&repo, "t-5").unwrap_err().contains("isn't checked out"));
96+ let _ = std::fs::remove_dir_all(&repo);
97+ }
98+}
crates/conveyor/src/main.rs+1−0
@@ -1,6 +1,7 @@
11 //! conveyor: the daemon, its CLI, and (inside a ticket's VM) the agent's verbs. One binary.
22 mod agent;
33 mod dispatch;
4+mod land;
45 mod library;
56 mod paths;
67 mod server;
crates/conveyor/src/server.rs+10−0
@@ -61,6 +61,16 @@ fn set(project: &str, id: u32, state: &str) -> Result<Value, String> {
6161 return Err("running belongs to conveyor: move a ticket to ready to start it".into());
6262 }
6363 if !["draft", "ready", "review", "parked", "failed", "done"].contains(&state) { return Err(format!("no state {state}")); }
64+ // Done from review lands the work: Keep for a widget build, a merge into main for code.
65+ if t.state == "review" && state == "done" {
66+ let p = store::project(project).ok_or("no such project")?;
67+ if p.library { return library::keep(id).map(|_| json!({"ok": true})); }
68+ let branch = format!("t-{id}");
69+ if crate::agent::git(&p.path, "", &["rev-parse", "-q", "--verify", &branch]).is_ok() {
70+ crate::land::land(&p.path, &branch).inspect_err(|e| store::event(project, id, json!({"kind": "error", "msg": e})))?;
71+ store::event(project, id, json!({"kind": "conveyor", "msg": format!("merged into main: {branch} is gone")}));
72+ }
73+ }
6474 store::set_state(project, id, state);
6575 Ok(json!({"ok": true}))
6676 }