diff --git a/docs/incidents.md b/docs/incidents.md index 8a10e9b22..a4c715fb5 100644 --- a/docs/incidents.md +++ b/docs/incidents.md @@ -49,7 +49,7 @@ pipeline still calls it there. | q. `q_run_ceiling` | The same bug had been fixed in one loop at a time. | A run has an absolute ceiling on passes, continuations, worked time and spend that only a person's Retry renews, held at the worker's one entry point, at every model call, and by the stuck-run sweep, each without the others. | | r. `r_github_limit` | A fix round hit GitHub's hourly limit. 29 writes and the diff came back "403 rate limit exceeded", and the run ended "the coder wrote no file ... That is CoderHelm's miss". | GitHub refusing for a while (its rate limit, a 5xx, no answer) never ends a run and is never blamed on the coder. The model is told the run pauses, the pass ends, and the run goes on as itself at GitHub's reset, with its page saying when. The wait adds no step and no pass. Writes GitHub rejected for a real reason are reported with that reason. A review waits for the reset without spending its retries. | | s. `s_silent_draft` | A new-feature run finished with CI green and CoderHelm's review approving, and its pull request stayed a draft. Four of CoderHelm's own sandbox checks had failed on the head, the mark-ready step returned without a word, and the run page said completed. The same day, mark-ready messages that hit GitHub's rate limit were dropped and five more pull requests stayed drafts. | One decision settles every pull request a finished run leaves, on every path. With CI green and the review approving, CoderHelm's own sandbox failures and checklist items never hold the draft: the pull request is marked ready with them under Open items. A hold that remains names each reason and what to do at the top of the description, at warn in the log, and on the run, which is `needs_input` while a person must act. A mark-ready GitHub refuses is tried again after its reset, a bounded number of times, and the last refusal is recorded on the run. A sweep decides again for finished runs left a draft with no recorded reason, respecting a person's draft and a closed pull request. | -| t. `t_unrun_check_hold` | A check's gate couldn't install its package's dependencies (`pnpm: command not found` in CoderHelm's sandbox). The tooling failure went under Open items as a check the change didn't pass, and the pull request stayed a draft after CI passed. | A check CoderHelm's own tools couldn't run becomes an Open item CI settles, never a hold. A line written the old way stops holding once CI is green on the head and leaves the description when the pull request is marked ready. A check the change really failed still holds. | +| t. `t_unrun_check_hold` | A check's gate couldn't install its package's dependencies (`pnpm: command not found` in CoderHelm's sandbox). The tooling failure went under Open items as a check the change didn't pass, and the pull request stayed a draft after CI passed. | A check CoderHelm's own tools couldn't run becomes an Open item CI settles, never a hold. A line written the old way stops holding once CI is green on the head and leaves the description when the pull request is marked ready. A check the change really failed still holds. The decision reads the repository's CI whenever such a line is in the description, not only when CoderHelm's own feature checks have findings: without that read, CI counted as not green and the line kept holding on every sweep. | | u. `u_stacked_plan_check` | A run stacked on an earlier part's open pull request reset to the default branch in every step, rebuilt and force-pushed its branch each time, and measured its plan against the other branch: 13 files that branch already changed read as not done, the coder found nothing to write, and the guard stopped the run after seven continuations. | A later step keeps the base an earlier step stacked it on; a planned file the stacked-on branch already changes is done there, and the plan check's note says so; a fall in the done count is reported on the run page, and its recovery counts as progress a bounded number of times. | ## Adding a case diff --git a/services/worker/src/passes/fix_location.rs b/services/worker/src/passes/fix_location.rs index 7ed3bff87..41e806c97 100644 --- a/services/worker/src/passes/fix_location.rs +++ b/services/worker/src/passes/fix_location.rs @@ -757,7 +757,24 @@ pub fn reask_prompt( proposal: &str, design: &str, tasks: &str, + also: &[String], ) -> String { + // What the plan's checks asked the block to carry (a data migration's + // `release`): a re-ask that left it out lost it, and the check then + // found it missing with no turn left to write it. + let also = if also.is_empty() { + String::new() + } else { + let lines: Vec = also + .iter() + .map(|g| format!("- {}", common::truncate_str(g.trim(), 1500))) + .collect(); + format!( + "\n\n## The plan's checks also need in the block\nWrite these fields in the same block, \ + from the plan:\n{}", + lines.join("\n") + ) + }; format!( "You planned this ticket, but {problem}. Write that block now, from the plan below, and \ nothing else: no other text, no other files.\n\n\ @@ -772,7 +789,7 @@ pub fn reask_prompt( - `evidence.basis`: `feature` for new work, `code` or `data` for a bug.\n\ - `questions`: only what the plan says a person must decide, each naming the options; [] \ when none.\n\ - - `outside_change`: null unless `outside_code` or `both`, then `system` and `change`.\n\n\ + - `outside_change`: null unless `outside_code` or `both`, then `system` and `change`.{also}\n\n\ ```{FENCE}\n{{\"fix_location\": \"code\", \"cause\": \"...\", \"evidence\": {{\"basis\": \"feature\"}}, \"outside_change\": null, \"questions\": []}}\n```", problem = problem.describe(), intent = intent.as_str(), @@ -2529,6 +2546,7 @@ mod missing_block_tests { "proposal", "design", FEATURE_TASKS, + &[], ); assert!(p.contains("cut off before it closed"), "{p}"); assert!(p.contains("```fix_location.json"), "{p}"); @@ -2540,6 +2558,49 @@ mod missing_block_tests { assert_eq!(route(Some(&d)), Route::Code); } + /// A run's planner was sent back for a data migration's `release`, and + /// its revised block was cut off. The re-ask asked for the core fields + /// only, so the block came back without `release` and the plan went on + /// with that gap open. The re-ask now names what the checks need. + #[test] + fn the_reask_carries_what_the_checks_need_in_the_block() { + let gap = "The plan migrates data (`apps/cms/migrations/add-level/index.ts`). Write \ + `release` in the fix_location.json block: the fields it changes, an expand and \ + a separate contract migration, the fallback and its test, and the affected \ + counts per environment."; + let p = reask_prompt( + "Add a title size setting", + TicketIntent::Feature, + &BlockProblem::Unterminated, + "proposal", + "design", + FEATURE_TASKS, + &[gap.to_string()], + ); + assert!(p.contains("also need in the block"), "{p}"); + assert!( + p.contains("Write `release` in the fix_location.json block"), + "{p}" + ); + // Still one block and nothing else, and still small. + assert!(p.contains("nothing else"), "{p}"); + assert!(p.len() < 10_000, "{}", p.len()); + // Nothing asked: the prompt is as before. + let plain = reask_prompt( + "t", + TicketIntent::Feature, + &BlockProblem::Unterminated, + "p", + "d", + FEATURE_TASKS, + &[], + ); + assert!(!plain.contains("also need in the block"), "{plain}"); + // The planning step passes the release check's gaps to the re-ask. + let plan_src = include_str!("plan.rs"); + assert!(plan_src.contains("release_plan::plan_gaps(&files, &abilities.release);\n let again =\n reask_decision(")); + } + #[test] fn a_question_to_a_person_is_never_an_open_where_does_it_belong() { use common::run_questions::too_open; diff --git a/services/worker/src/passes/incidents/t_unrun_check_hold.rs b/services/worker/src/passes/incidents/t_unrun_check_hold.rs index 5aba5af73..9664a1352 100644 --- a/services/worker/src/passes/incidents/t_unrun_check_hold.rs +++ b/services/worker/src/passes/incidents/t_unrun_check_hold.rs @@ -114,6 +114,46 @@ fn a_check_the_change_really_failed_still_holds_with_ci_green() { assert_eq!(proof::without_settled_blocked(&body, true), None); } +/// The same pull request, decided again by the sweep after the fix above +/// shipped: still held, every 75 minutes, for a day. The decision only read +/// the repository's CI when CoderHelm's own feature checks had findings; +/// this pull request had none, so CI stayed "not green" without being asked +/// and the tooling line kept holding although CI had passed on the head. +#[test] +fn the_decision_reads_ci_when_only_a_tooling_line_holds() { + let body = the_description_as_written(); + let f = Facts { + draft: true, + body: body.clone(), + ..Default::default() + }; + assert!(f.feature.is_none(), "no feature findings, as in the run"); + assert!(ready::reads_ci(&f), "CI settles the line, so it is read"); + // A description with no line CI settles, and no feature findings, needs + // no CI read. + let plain = Facts { + draft: true, + body: "## Summary\nx\n".into(), + ..Default::default() + }; + assert!(!ready::reads_ci(&plain)); + // A check the change really didn't pass is not settled by CI: no read + // needed for it, and it still holds whatever CI says. + let real = format!( + "## Summary\nx\n\n{}", + proof::gaps_section(&[proof::check_item( + "The new-feature rules", + "two new blocks aren't registered in the schema index", + )]) + ); + assert!(!proof::ci_settles_a_hold(&real)); + // The gathering step asks the predicate, not the feature findings alone. + let ready_src = include_str!("../ready.rs"); + let gather = super::fixture::fn_src(ready_src, "async fn gather("); + assert!(gather.contains("if reads_ci(&f) {"), "{gather}"); + assert!(!gather.contains("if f.feature.is_some() {"), "{gather}"); +} + #[test] fn the_pipeline_writes_gate_errors_through_check_item() { let src = include_str!("../mod.rs"); diff --git a/services/worker/src/passes/plan.rs b/services/worker/src/passes/plan.rs index 76e4d35ae..683ae5021 100644 --- a/services/worker/src/passes/plan.rs +++ b/services/worker/src/passes/plan.rs @@ -1033,7 +1033,12 @@ Then the ```fix_location.json block described above."#, tokens_so_far = spent, "Planner gave no readable decision — asking again for the block only" ); - let again = reask_decision(state, provider, usage, msg, intent, &problem, &files).await; + // The re-ask carries what the plan's checks still need in the block + // (a data migration's `release`), so asking for the block alone + // never drops it. + let also = super::release_plan::plan_gaps(&files, &abilities.release); + let again = + reask_decision(state, provider, usage, msg, intent, &problem, &files, &also).await; let outcome = if again.is_some() { "asked the planner again for the block: got it" } else { @@ -1503,7 +1508,9 @@ fn needs_decision(tasks: &str) -> bool { /// Asks the planner once more for only its decision block: a fresh, small /// call with the plan it wrote, no tools, low effort. `None` when the reply -/// still has no block that reads or the call fails. +/// still has no block that reads or the call fails. `also`: what the plan's +/// checks need in the block too (see `fix_location::reask_prompt`). +#[allow(clippy::too_many_arguments)] async fn reask_decision( state: &WorkerState, provider: &ModelProvider, @@ -1512,6 +1519,7 @@ async fn reask_decision( intent: super::triage::TicketIntent, problem: &super::fix_location::BlockProblem, files: &PlanResult, + also: &[String], ) -> Option { let prompt = super::fix_location::reask_prompt( &msg.title, @@ -1520,6 +1528,7 @@ async fn reask_decision( &files.proposal, &files.design, &files.tasks, + also, ); let mut messages = vec![( "user".to_string(), diff --git a/services/worker/src/passes/proof.rs b/services/worker/src/passes/proof.rs index 1052a1136..eb087d998 100644 --- a/services/worker/src/passes/proof.rs +++ b/services/worker/src/passes/proof.rs @@ -1328,6 +1328,12 @@ pub fn holds_blocked_on(body: &str, ci_green: bool) -> bool { blocked_lines(body).any(|l| !blocked_line_settled(l, ci_green)) } +/// Whether the description has a blocked line CI green on the head would +/// settle: the decision has to read CI for it. +pub fn ci_settles_a_hold(body: &str) -> bool { + blocked_lines(body).any(|l| blocked_line_settled(l, true)) +} + /// The description without the blocked lines CI settled (see /// [`blocked_line_settled`]), the Open items section dropped when nothing is /// left in it. `None` when there is nothing to remove. diff --git a/services/worker/src/passes/ready.rs b/services/worker/src/passes/ready.rs index 243899025..e5c713423 100644 --- a/services/worker/src/passes/ready.rs +++ b/services/worker/src/passes/ready.rs @@ -614,7 +614,7 @@ async fn gather(ctx: &Ctx<'_>) -> Result { f.draft = pr["draft"].as_bool().unwrap_or(f.draft); f.body = pr["body"].as_str().unwrap_or("").to_string(); f.title = pr["title"].as_str().unwrap_or("").to_string(); - if f.feature.is_some() { + if reads_ci(&f) { let sha = pr["head"]["sha"].as_str().unwrap_or(""); f.ci = ci_on(gh, ctx.owner, ctx.repo, sha).await.map_err(|e| { Refused::of( @@ -640,6 +640,16 @@ async fn gather(ctx: &Ctx<'_>) -> Result { Ok(f) } +/// Whether the decision needs the repository's CI on the head: CoderHelm's +/// own feature findings weigh against it, and so does a description line for +/// a check CoderHelm's own tools couldn't run (CI green settles it, see +/// `proof::holds_blocked_on`). CI was once read only for the first: a pull +/// request whose one hold was such a line read CI as "not green" without +/// asking, and stayed a draft on every sweep although its CI had passed. +pub fn reads_ci(f: &Facts) -> bool { + f.feature.is_some() || super::proof::ci_settles_a_hold(&f.body) +} + /// Whether a check is CoderHelm's own (its review check, or any check its /// app reports): never the repository's CI. fn own_check(c: &serde_json::Value) -> bool {