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
1 change: 1 addition & 0 deletions docs/incidents.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ pipeline still calls it there.
| br. `br_description_writer_upgrade` | After the description writer was upgraded (a final review in the one save, the repository's template as the structure), a pull request opened the day before kept its old text: six checks "Not run: still running when this was written", the file to read first and the way back said twice, filler and a raw page id. Its head had not moved and its checked text was unchanged, so its stamp said current and nothing rebuilt it. | The stamp names the writer version (`description::WRITER`, raised with every change to what a description says or how it is laid out); a description built by another writer, or before the version, is not current. The pull request watch's sweep catches up open pull requests CoderHelm opened, whatever the age of their run: a few per team each sweep (`pr_watch::CATCH_UP_PER_TEAM`), inside its GitHub budget, each rebuilt once and marked on its run. A description still wholly CoderHelm's is built again from the facts of the head alone: nothing of the old text is kept, not even in a fold, except a line that closes an issue. A security fix's pull request gets the same: its sections are computed from the lockfile on the head and nothing else of its old body is kept (`security_fixes::fresh_body`). A description with no CoderHelm stamp, or whose checked text a person changed, is left as it is. |
| br. `br_description_writer_upgrade` | After the description writer was upgraded (a final review in the one save, the repository's template as the structure), a pull request opened the day before kept its old text: six checks "Not run: still running when this was written", the file to read first and the way back said twice, filler and a raw page id. Its head had not moved and its checked text was unchanged, so its stamp said current and nothing rebuilt it. | The stamp names the writer version (`description::WRITER`, raised with every change to what a description says or how it is laid out); a description built by another writer, or before the version, is not current. The pull request watch's sweep catches up open pull requests CoderHelm opened, whatever the age of their run: a few per team each sweep (`pr_watch::CATCH_UP_PER_TEAM`), inside its GitHub budget, each rebuilt once and marked on its run. A description still wholly CoderHelm's is built again from the facts of the head alone: nothing of the old text is kept, not even in a fold, except a line that closes an issue. A description with no CoderHelm stamp, or whose checked text a person changed, is left as it is. |
| bs. `bs_cut_plan_revision` | A ticket with a long history was planned, and the plan check sent the plan back with two open items. The revision reached the output limit partway through its last block. The planner was told the coder's note ("make a change in small edit_file calls"), wrote only its decision block again, and the worker read only that last turn: no tasks, no design. The run failed with "empty or malformed plan ... retry the run" and the first plan was thrown away. | A planner's cut answer is continued where it stopped and read together with what came before the cut, file by file (`plan_sections`). A cut turn's note fits its loop: the coder's edit note only where there are edit tools, the planner's "continue the document" note, a shorter answer for everyone else. A revision that comes back empty, cut off or malformed never replaces a valid file, and a send-back asks for only the files that change. Files still missing are asked for alone, twice at most, the second with a larger output budget. A plan still not usable is planned again in a fresh step, then reported as CoderHelm's own failure, saying what it lacked. No run tells a person to retry it. |
| bt. `bt_proof_answer_closes` | A security update's own review asked for proof of the build and unit tests on the head. The fix rounds changed no code: the second ran every check on the head, all passing, and one runtime check it started was cut short by the step's time. The ledger counted that as a block, the round pushed nothing so no review read the head again, and the draft was held for a person ("Fix them on the branch, or remove a finding") while the merge standing said no person was needed. | A round that pushed nothing is read by a review of the same head, with the round's account in the reviewer's context, and a finding answered with proof closes there. A command, check or codegen a step is too short to start is owed: the pass continues in a fresh step that runs it first, and a round cut short by time is never a block. Nothing on CoderHelm's side holds a draft for a person: what is left after every approach is listed as CoderHelm's note and the pull request goes ready, with CoderHelm's verdict kept so nothing merges over it. A stuck run is sent back to its review on the next look of the ready sweep or the pull request's watch. |

## Adding a case

Expand Down
1 change: 1 addition & 0 deletions services/worker/src/passes/dep_fix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1661,6 +1661,7 @@ pub async fn implement_result(
writes: Default::default(),
outside_plan: Vec::new(),
refused: Vec::new(),
owed: Vec::new(),
evidence: super::proof::RunEvidence {
notes: run.report_md(),
checks: run
Expand Down
72 changes: 64 additions & 8 deletions services/worker/src/passes/implement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,34 @@ pub struct ImplementResult {
pub outside_plan: Vec<(String, String)>,
/// Edits the round was refused and never made.
pub refused: Vec<super::write_guard::Refusal>,
/// Commands (and `run_checks`) the coder asked for that this step had
/// too little time left to start: owed, never dropped. The pass then
/// counts as cut short, and the round continues in a fresh step that
/// runs them first ([`owed_first`]).
pub owed: Vec<String>,
}

/// The name an owed `run_checks` call carries in [`ImplementResult::owed`].
pub const OWED_CHECKS: &str = "run_checks (the repository's checks)";
const OWED_START: &str = "\n\n## Owed from the step before\n";

/// A continuing round's instructions with the checks its last step was too
/// short to start, to run first. Replaces an earlier such section, so a
/// round continued twice carries the newest list once.
pub fn owed_first(feedback: &str, owed: &[String]) -> String {
let base = feedback
.find(OWED_START)
.map_or(feedback, |i| &feedback[..i]);
if owed.is_empty() {
return base.to_string();
}
let list: Vec<String> = owed.iter().map(|c| format!("- `{c}`")).collect();
format!(
"{base}{OWED_START}The step before this one was too short to start these. Run each \
first, as its own call, with this step's full time, then go on. Write a result only \
from output you have here:\n{}",
list.join("\n")
)
}

#[allow(clippy::too_many_arguments)]
Expand Down Expand Up @@ -800,6 +828,7 @@ pub async fn run(
ci_steps,
check_results: std::sync::Mutex::new(Vec::new()),
sandbox_record: std::sync::Mutex::new(Default::default()),
owed: std::sync::Mutex::new(Vec::new()),
last_checks_passed: std::sync::atomic::AtomicBool::new(true),
codegen_cmd,
codegen_env,
Expand Down Expand Up @@ -1192,7 +1221,12 @@ pub async fn run(

// Cut short by the deadline: the loop's own marker, or the pass ended
// inside the wrap-up window (the agent summarized what was left).
let timed_out = reached_deadline(&closing, deadline, std::time::Instant::now());
// A command or check this step was too short to start is owed: the pass
// is cut short and continues in a fresh step that runs it first, never
// a round that ends with the check unrun.
let owed = std::mem::take(&mut *executor.write_executor.owed.lock().unwrap());
let timed_out =
reached_deadline(&closing, deadline, std::time::Instant::now()) || !owed.is_empty();
if closing == crate::agent::anthropic::TIMED_OUT_REPLY {
closing.clear();
}
Expand Down Expand Up @@ -1255,6 +1289,7 @@ pub async fn run(
writes,
outside_plan,
refused,
owed,
evidence: super::proof::RunEvidence {
sources,
lookups,
Expand Down Expand Up @@ -1917,6 +1952,8 @@ struct WriteToolExecutor<'a> {
/// or why it gave no result: the proof check names the real reason a
/// check didn't run.
sandbox_record: std::sync::Mutex<super::proof::SandboxRecord>,
/// Commands the step had too little time to start ([`ImplementResult::owed`]).
owed: std::sync::Mutex<Vec<String>>,
/// Verdict of the most recent run_checks (incl. tests). Starts true (nothing
/// run yet ⇒ no red seen); set on every run_checks so the finish path can
/// warn when the agent stops on a red result.
Expand Down Expand Up @@ -2774,6 +2811,14 @@ impl<'a> WriteToolExecutor<'a> {
Some(check_now_text(left, build))
}

/// A command this step was too short to start: owed to the next one.
fn owe(&self, command: &str) {
let mut owed = self.owed.lock().unwrap();
if !owed.iter().any(|c| c == command) {
owed.push(command.to_string());
}
}

/// Should a hand-edit to `path` (whose current content is `existing`) be
/// rejected and steered to run_codegen? True only when the repo HAS a codegen
/// command, the file looks generated, AND this path hasn't already been
Expand Down Expand Up @@ -2984,10 +3029,14 @@ impl<'a> WriteToolExecutor<'a> {
)));
}
if !sandbox.has_time(self.deadline) {
note(LogOutcome::soft_fail("not run: not enough time left"));
note(LogOutcome::soft_fail(
"not run yet: owed to the next step, which has its full time",
));
self.owe(command);
return Ok(json!(
"This step has too little time left for a sandbox build. Finish your changes; \
CoderHelm runs the repository's checks before the run finishes."
"This step has too little time left to start that command. It is owed, not \
dropped: this round continues in a fresh step with its full time and runs it \
first. Save what you changed and stop now; don't write a result for it."
));
}
if let Some(gate) = &self.policy {
Expand Down Expand Up @@ -3097,11 +3146,13 @@ impl<'a> WriteToolExecutor<'a> {
}
if !sandbox.has_time(self.deadline) {
note(LogOutcome::soft_fail(
"not run: not enough time left in this step; the checks run in the next step",
"not run yet: owed to the next step, which has its full time",
));
// The check is owed, not dropped: the settle stage runs it in a
// step with a full window before the run finishes (`settle`).
// step with a full window before the run finishes (`settle`),
// and a fix round continues in a fresh step that runs it first.
self.sandbox_record.lock().unwrap().refused_for_time = true;
self.owe(OWED_CHECKS);
return Ok(json!(
"This step has too little time left for a sandbox build. Finish your changes \
now; CoderHelm runs the repository's checks on the branch in a fresh step \
Expand Down Expand Up @@ -3440,9 +3491,14 @@ impl<'a> WriteToolExecutor<'a> {
)));
}
if !sandbox.has_time(self.deadline) {
note(LogOutcome::soft_fail("not run: not enough time left"));
note(LogOutcome::soft_fail(
"not run yet: owed to the next step, which has its full time",
));
self.owe("run_codegen");
return Ok(json!(
"Not enough time remains to run codegen; finalize your changes now."
"This step has too little time left to run codegen. It is owed, not dropped: \
this round continues in a fresh step with its full time and runs it first. Save \
what you changed and stop now."
));
}
let source = match self.sandbox_source(sandbox, run_id).await {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,13 @@ fn a_finding_the_ticket_comment_rules_out_is_dropped_by_the_ticket_not_deferred(
let Plan::Settle {
deferred,
by_ticket,
noted,
} = l.decide(&[NAV_AGAIN.to_string()], 0.0, 200.0)
else {
panic!("settled by the ticket");
};
assert!(deferred.is_empty());
let lines = ledger::settled_lines(&deferred, &by_ticket);
assert!(deferred.is_empty() && noted.is_empty());
let lines = ledger::settled_lines(&deferred, &by_ticket, &noted);
assert!(lines[0].contains("the ticket rules it out"), "{lines:?}");
// The review of the head then names it as a note, never a hold.
let mut findings: Vec<crate::passes::review_agent::Finding> = serde_json::from_value(serde_json::json!([
Expand Down
Loading
Loading