Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion selfhost/versions.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"about": "The dashboard commit each platform release ships: a full 40-character commit SHA of CoderHelm/coderhelm, never a branch or tag (scripts/check-dashboard-ref.mjs fails CI and the release otherwise). The release workflow builds exactly this commit (dashboard/) into dashboard.tar.gz. Move it with scripts/bump-dashboard.sh in a reviewed PR, in the same PR as any API change the dashboard needs.",
"dashboardRef": "dbfbd17a51c80c6feb95be3a5444676ddc51bff0"
"dashboardRef": "7d2e215d04058dd17ec087c3c16ae775abaedc9b"
}
18 changes: 18 additions & 0 deletions services/common/src/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,11 @@ pub struct ReviewMessage {
/// differs and was already reviewed at this commit, it doesn't run.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub description_hash: Option<String>,
/// Review the whole PR even after an earlier review of it: set on the
/// review a hunks-only re-review sends before it would approve, so an
/// approval always rests on a full review.
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
pub full_review: bool,
}

#[derive(Serialize, Deserialize, Debug, Default)]
Expand Down Expand Up @@ -816,6 +821,17 @@ pub struct TicketMessage {
/// Epoch ms of the first attempt — the wall-clock runaway backstop.
#[serde(default)]
pub first_attempt_ms: u64,
/// A person retried this earlier run (`run_status::retry_resumes`): the
/// new run takes up its plan and the commits on its branch instead of
/// planning and implementing from scratch. Absent when the plan was what
/// failed, and on Start over.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub resume_from: Option<String>,
/// Set in-process when the run took up `resume_from`'s plan and branch:
/// the coder is told the branch already holds that run's work and
/// finishes what is left. Never serialized.
#[serde(skip)]
pub retry_of_run: bool,
/// Times this run was sent again after a transient model error (a 5xx,
/// 429, 529 or network failure that outlasted the client's own retries).
/// The run keeps its run_id across these, like a continuation.
Expand Down Expand Up @@ -882,6 +898,8 @@ impl Default for TicketMessage {
continuation: 0,
continuation_run_id: None,
first_attempt_ms: 0,
resume_from: None,
retry_of_run: false,
model_retries: 0,
ticket_update_note: None,
ticket_history_note: None,
Expand Down
52 changes: 52 additions & 0 deletions services/common/src/run_status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,24 @@ pub fn ended_by_person(status: &str) -> bool {
ENDED_BY_PERSON.contains(&status)
}

/// Whether a person's Retry of an ended run takes up its plan and branch
/// instead of starting over. Superseded runs cost $63 in 17 days, most of it
/// planning and implementing again what the earlier run had already
/// written. It starts over when the plan was what failed: the run stopped in
/// triage or planning (`current_pass`), or its error is about the plan.
/// Start over (`reset`) always starts over. A run that kept no plan of its
/// own has nothing to take up: the new run plans as usual.
pub fn retry_resumes(current_pass: &str, error: &str) -> bool {
let pass = current_pass.trim().to_ascii_lowercase();
if pass.starts_with("triage") || pass.starts_with("plan") {
return false;
}
let error = error.to_ascii_lowercase();
!error
.split(|c: char| !c.is_ascii_alphanumeric())
.any(|w| matches!(w, "plan" | "planning" | "planner"))
}

/// The lesson trigger for a person's answer to "why was this closed?" on
/// CoderHelm's PR (the gateway sends it, the worker's lessons read it).
pub const CLOSE_REASON_TRIGGER: &str = "close_reason";
Expand Down Expand Up @@ -390,3 +408,37 @@ mod tests {
);
}
}

#[cfg(test)]
mod retry_resumes_tests {
use super::retry_resumes;

#[test]
fn a_retry_takes_up_the_plan_and_branch_unless_the_plan_failed() {
assert!(retry_resumes(
"implement",
"Reached the maximum number of steps"
));
assert!(retry_resumes(
"review",
"the model call failed: 529 overloaded"
));
assert!(retry_resumes("pr", ""));
// The plan was what failed: plan again.
assert!(!retry_resumes("plan", "out of time"));
assert!(!retry_resumes("plan_review", ""));
assert!(!retry_resumes("triage", ""));
assert!(!retry_resumes(
"implement",
"The plan names a file that doesn't exist"
));
assert!(!retry_resumes(
"implement",
"planning gap: no task for the migration"
));
// A finished pass name says nothing about the plan.
assert!(retry_resumes("done", "Reached the maximum number of steps"));
// A word that only contains "plan" isn't about the plan.
assert!(retry_resumes("implement", "the explanation was cut off"));
}
}
Loading
Loading