Factory: exact parallel limit, remove issues from the board

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Richard ZinkandClaude Sonnet 5.5 committed 2026-11-18 19:48:27 +01:00
1 parent aa6ee7fd31
commit 486c49d50b
8 files changed
+76 -1

No files matched your search

+9 -1
View File
@@ -1497,6 +1497,12 @@ impl Store {
Ok(())
}
/// Remove an issue from the factory board (runs and cost statistics stay).
pub fn factory_issue_delete(&self, repo: &str, number: i64) -> Result<()> {
self.conn.lock().unwrap().execute("DELETE FROM factory_issues WHERE repo_url = ?1 AND number = ?2", params![repo, number])?;
Ok(())
}
/// Update the given columns (whitelisted) of an issue.
pub fn factory_issue_set(&self, repo: &str, number: i64, fields: &[(&str, Value)]) -> Result<()> {
const COLS: [&str; 11] = ["title", "state", "attempts", "rounds", "last_comment", "scenarios", "branch", "pr_url", "note", "author", "version"];
@@ -1586,7 +1592,9 @@ impl Store {
}
pub fn factory_running(&self, repo: &str) -> Result<i64> {
Ok(self.conn.lock().unwrap().query_row("SELECT COUNT(*) FROM factory_runs WHERE repo_url = ?1 AND status = 'running'", [repo], |r| r.get(0))?)
// Counted by issue state, not by run rows: the state is set before the phase is spawned, the run row
// only once its checkout is done – counting runs let a single poll start more phases than allowed.
Ok(self.conn.lock().unwrap().query_row("SELECT COUNT(*) FROM factory_issues WHERE repo_url = ?1 AND state IN ('review', 'building', 'testing')", [repo], |r| r.get(0))?)
}
/// Runs with token and cost totals (joined from the usage table).