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
7 changes: 7 additions & 0 deletions docs/incidents/ow_one_verdict_per_finding.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# ow. `ow_one_verdict_per_finding`

**What happened:** CoderHelm's own pull request fixed a sport filter that listed one sport twice. A later review listed findings under "Holding the merge" that the same review said no longer applied: the earlier dropdown thread, whose code the fix rounds had replaced, and two findings the review itself kept as notes because they came late. On CoderHelm's own pull request each late note was also chained into its open work, which is named as holding the merge, so each of those findings had two verdicts in one review.

**The guarantee:** Every finding has one state before the review is written: blocking, a note, settled, or no longer applying. A thread that is resolved, settled by this review or about code no longer in the change, a finding raised late, and an earlier hold the review now calls a note never hold the merge. "Holding the merge" lists only what still blocks at the head with its thread open. The finished body is checked before it is posted: no finding listed as holding is also called a note, settled or no longer applying.

**Where it's enforced:** `passes::review_one_verdict` (`settle`, `check`, `enforce`), called by `review_pr` before the verdict is made and before the review is posted; `review_pr::closed_threads`; the `gone` thread status (`review_agent::GONE`, `review_rules::settles`).
7 changes: 7 additions & 0 deletions docs/incidents/ox_findings_raised_first.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# ox. `ox_findings_raised_first`

**What happened:** On the same pull request as `ow`, a review three rounds in raised "A parallel structure next to an existing one" and "A test out of proportion to the change" on code unchanged since the first review, and said they should have been raised then. On CoderHelm's own pull request each late note was still work that held the merge, so each cost a push and a review. The checks that find them started running after the earlier rounds were reviewed. Three more ways a first review left findings for later were open: the checks with no model ran only when the head's tree could be read, a diff over its room lost the files in its middle, and a review that ran out of tool steps answered as if it were done.

**The guarantee:** Every check runs on every review, the first included, with or without the tree. The reviewer's diff names every changed file and lists the ones it cut. A review that runs out of steps goes on in a second pass over what it didn't reach. A finding a later review raises on lines unchanged since the previous one never blocks: it is a note saying the previous review missed it, or that the check that found it started after it. On CoderHelm's own pull request it is still sent to the coder in this round's work. A miss is recorded for the reviewer's rewards and lessons; a new check's finding is not.

**Where it's enforced:** `review_policy::hold_late_blockers` (`Late::missed`, `NEW_CHECK_NOTE`), `review_rules::CHECKS_STARTED`, `rewards::record_missed` and `RewardKind::FindingMissed`, `review_agent::format_diff`, `review_agent::generate_review` (`ran_out_of_steps`, `continue_prompt`, `merge_review`), and the checks block in `review_pr`.
7 changes: 7 additions & 0 deletions docs/incidents/oy_review_fix_loop_ends.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# oy. `oy_review_fix_loop_ends`

**What happened:** A data-pipeline run's own review raised something new each round: a model finding in round 2, "A test out of proportion to the change" in round 3, and in round 4 "A parallel structure next to an existing one" that named as new a function the main branch had had for months (the branch only added a parameter to it). Each held the merge, so the run went review, fix, review every ten minutes for nine fix rounds, past its spend ceiling. The review on the pull request stayed on an old head the whole time, and a person had to ask for a re-review.

**The guarantee:** The parallel-structure check reads both sides against the base, so a definition the base already has is never new. After the first review, the smallest-change checks that a reason may keep give notes, and a finding on lines unchanged since the previous review is a note. Late notes join a round that has work that holds, and never start one, so the run ends once only notes are left. Every head the run pushes gets the PR reviewer's review posted, news or not.

**Where it's enforced:** `minimal_change::parallel_structures`; `review_policy::hold_late_blockers` (`ADVISORY_LATE_NOTE`) and `review_rules::advisory_check`; the work list in `review_pr`; `review_pr::own_head_is_new`; the run's review step in `resume` (`review_for_run` on every head).
13 changes: 13 additions & 0 deletions docs/incidents/oz_reviewer_converges.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# oz. `oz_reviewer_converges`

**What happened:** The fix on the pull request of `ow` and `ox` was right by its third commit. CI and the preview's end-to-end run were green, and a person's product answers were built. The review still requested changes for six more rounds on two generic findings. "A parallel structure next to an existing one" never named the function it duplicated. "A test out of proportion to the change" moved from one test file to the next as each was trimmed, and landed on a test whose cases the review had asked to restore. CoderHelm's own fix rounds deferred both as making no progress, and the review kept blocking. A person had answered that the path pages should cover both rows; the run reverted that work as out of scope, and a later review called it missing.

**The guarantee:** On every review, before the verdict:
- a blocking finding names its file, its line, and what it conflicts with or asks for;
- a generic finding doesn't move to another file;
- a finding never asks the opposite of an earlier request;
- a finding CoderHelm's own rounds deferred holds no more unless new code gives it new evidence;
- a person's answer decides scope;
- once each ticket criterion is proven both ways with CI green, whatever is left that isn't a shown defect is a follow-up note on an approval.

**Where it's enforced:** `passes::review_discipline` (`judge` and its rules, `criteria_met` reading the run's two-way proofs), called by `review_pr` after the severity pass; `review_rules::anchor_line`; `review_pr::settle_own_findings` (a deferred finding's thread no longer holds).
7 changes: 7 additions & 0 deletions services/common/src/rewards/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ pub enum RewardKind {
RereviewRequested,
/// An alert named a merged CoderHelm change.
IncidentLinked,
/// A review raised a finding late: on lines unchanged since an earlier
/// review of the same pull request had read them. The earlier review
/// missed it.
FindingMissed,
}

impl RewardKind {
Expand All @@ -71,6 +75,7 @@ impl RewardKind {
RewardKind::TimeToMerge,
RewardKind::RereviewRequested,
RewardKind::IncidentLinked,
RewardKind::FindingMissed,
];

pub fn key(self) -> &'static str {
Expand All @@ -91,6 +96,7 @@ impl RewardKind {
RewardKind::TimeToMerge => "time_to_merge",
RewardKind::RereviewRequested => "rereview_requested",
RewardKind::IncidentLinked => "incident_linked",
RewardKind::FindingMissed => "finding_missed",
}
}

Expand All @@ -117,6 +123,7 @@ impl RewardKind {
RewardKind::TimeToMerge => "Time to merge",
RewardKind::RereviewRequested => "Re-review requested",
RewardKind::IncidentLinked => "Alert tied to a merged change",
RewardKind::FindingMissed => "Review comment missed by an earlier review",
}
}

Expand Down
3 changes: 3 additions & 0 deletions services/common/src/rewards/exemplars.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,9 @@ pub fn finding_reason(kind: RewardKind) -> String {
RewardKind::FindingAccepted => "The author changed the code it pointed at",
RewardKind::FindingDismissed => "The team pushed back and the comment was judged wrong",
RewardKind::FindingIgnored => "Still open when the pull request closed",
RewardKind::FindingMissed => {
"Raised late, on code an earlier review of the same pull request had read"
}
_ => "",
}
.to_string()
Expand Down
4 changes: 4 additions & 0 deletions services/common/src/rewards/score.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ pub fn default_weight(kind: RewardKind) -> f64 {
// the team decides otherwise.
RewardKind::RereviewRequested => 0.0,
RewardKind::IncidentLinked => -2.5,
// Every finding belongs in the first review of the code: one raised
// rounds later cost the author a push and a review each round.
RewardKind::FindingMissed => -1.0,
}
}

Expand Down Expand Up @@ -329,6 +332,7 @@ mod tests {
RewardKind::PrReverted,
RewardKind::CiFixRounds,
RewardKind::IncidentLinked,
RewardKind::FindingMissed,
] {
assert!(score(&ev("t", k, 1.0), &w) < 0.0, "{k:?}");
}
Expand Down
3 changes: 2 additions & 1 deletion services/worker/src/agent/anthropic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1261,7 +1261,8 @@ pub async fn converse_tool_loop(
}

/// The note the loop sends when every tool step is used.
const TOOLS_OFF_NOTE: &str = "[SYSTEM NOTE] You have used every tool step. Tools are now off. \
pub(crate) const TOOLS_OFF_NOTE: &str =
"[SYSTEM NOTE] You have used every tool step. Tools are now off. \
Write your final answer NOW, in exactly the format you were asked for, using what you have \
already learned. Where something is still unknown, say so in the answer instead of guessing.";

Expand Down
19 changes: 17 additions & 2 deletions services/worker/src/passes/incidents/bt_proof_answer_closes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,23 @@ fn what_is_left_after_every_approach_is_a_note_on_a_ready_pull_request() {
let mut own_open = open.clone();
let settled = crate::passes::review_pr::settle_own_findings(&l, &mut findings, &mut own_open);
assert!(own_open.is_empty());
assert!(settled.is_empty(), "a note never clears the merge hold");
assert!(findings[0].holds_merge());
// Deferred after every approach with no progress, it holds the merge no
// more: its thread is settled, and the review makes the finding a
// follow-up unless new code gives it new evidence (`review_discipline`).
assert_eq!(
settled.len(),
1,
"a deferred note no longer holds the merge"
);
let deferred = crate::passes::review_discipline::deferred_items(&l);
crate::passes::review_discipline::judge(
&mut findings,
&crate::passes::review_discipline::Facts {
deferred: &deferred,
..Default::default()
},
);
assert!(!findings[0].holds_merge());
// A completion on that verdict completes: nothing more to do.
assert_eq!(
ledger::completion(Some(("REQUEST_CHANGES", HEAD)), HEAD, &l),
Expand Down
197 changes: 197 additions & 0 deletions services/worker/src/passes/incidents/ow_one_verdict_per_finding.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
//! ow. CoderHelm's own pull request fixed a sport filter that listed one
//! sport twice. A later review of it listed findings under "Holding the
//! merge" that the same review said no longer applied: the earlier thread
//! about the dropdown, whose code the fix rounds had replaced, and two
//! findings the review itself had kept as notes ("on code that hasn't
//! changed since my previous review, so these are notes and don't change
//! the verdict"). On CoderHelm's own pull request every late note was also
//! chained into its open work, and that work is named as holding the merge,
//! so each of those findings had two verdicts in one review.
//!
//! Guarantee: one state per finding before the body is written
//! (`review_one_verdict::settle`): a thread that is resolved, settled by
//! this review or about code no longer in the change, a finding raised
//! late, and an earlier hold the review now calls a note never hold the
//! merge; "Holding the merge" is built only from what still blocks at the
//! head. The finished body is checked before it is posted
//! (`review_one_verdict::enforce`): no finding listed as holding is also
//! called a note, settled or no longer applying.

use crate::passes::own_review;
use crate::passes::review_agent::{verdict_heading, Finding};
use crate::passes::review_one_verdict::{self as one, Key, State};
use crate::passes::review_policy::{self, demote, named_holding, LATE_NOTE};
use crate::passes::review_verdict::{HoldKind, Verdict};

const FILTERS: &str = "apps/web/src/utils/filterMaps.ts";
const TEST: &str = "apps/web/src/test/components/filter-nav-sport-grid.test.tsx";

/// The earlier thread: its code was replaced by the fix rounds.
fn earlier_thread_line() -> String {
own_review::thread_line(
FILTERS,
632,
"**Drop-ins sport dropdown can now list one sport twice**\n\nTwo sport ids share a slug.",
)
}

/// The two findings the review raised late, as the checks wrote them.
fn late() -> Vec<Finding> {
let mut out: Vec<Finding> = crate::passes::review_rules::wider_findings(&[
crate::passes::minimal_change::Widening {
kind: crate::passes::minimal_change::Kind::Parallel,
path: FILTERS.into(),
what: "`dedupeSportOptionsBySlug` next to the existing `dedupeSportsBySlug`".into(),
},
crate::passes::minimal_change::Widening {
kind: crate::passes::minimal_change::Kind::TestSize,
path: TEST.into(),
what: "236 added lines against 41 lines of changed code".into(),
},
]);
for f in out.iter_mut() {
demote(f, LATE_NOTE);
}
out
}

/// The model's summary, as it wrote it.
const SUMMARY: &str = "The fix keeps one option per sport slug. The earlier dropdown comment \
on `apps/web/src/utils/filterMaps.ts` about listing one sport twice no longer applies: \
the new helper replaced that code.";

/// The review's body from its parts, the way `review_pr` writes them.
fn body(verdict: &Verdict, notes: usize, summary: &str, held_late: &[Finding]) -> String {
format!(
"{}\n\n_{}_\n\n{summary}{}",
verdict_heading(verdict, notes),
verdict.why(0, notes),
one::late_markdown(held_late)
)
}

/// What the review did: late notes chained into CoderHelm's open work, the
/// earlier thread still open, and every one named as holding.
#[test]
fn the_old_assembly_gave_findings_two_verdicts_and_the_check_names_them() {
let held = late();
let own_open = own_review::required(&[], &held);
let open = [(FILTERS.to_string(), 632u64, earlier_thread_line())];
let open: Vec<(String, u64, String)> = open
.iter()
.map(|(p, l, t)| (p.clone(), *l, format!("**{t}**")))
.collect();
let verdict = Verdict::from_holding(named_holding(&[], &open, &[], false, &own_open, &[]));
assert_eq!(verdict.holding().len(), 3);
let b = body(&verdict, held.len(), SUMMARY, &held);
let found = one::check(&b);
assert_eq!(found.len(), 3, "{found:#?}\n{b}");
assert!(found.iter().any(|c| c.state == State::NoLongerApplies));
assert_eq!(
found.iter().filter(|c| c.state == State::Note).count(),
2,
"{found:#?}"
);
// The last word before posting removes the words that contradict the
// hold, so even this body would never go out with two verdicts.
let (fixed, _) = one::enforce(&b);
assert!(one::check(&fixed).is_empty(), "{fixed}");
}

/// What the review does now: one state per finding, then the body.
#[test]
fn every_finding_has_one_verdict() {
let held = late();
// Late findings are not part of the open work that holds the merge.
let own_open = own_review::required(&[], &[]);
assert!(own_open.is_empty());
// On their own, late notes start no round: nothing holds, the draft
// isn't held, and the run ends (`review_pr` writes the work list only
// when something in it holds).
let own_late = one::late_lines(&held);
assert_eq!(own_late.len(), 2);
assert!(own_late.iter().all(|l| l.contains(one::LATE_MARK)));
let src = include_str!("../review_pr.rs");
assert!(src.contains("let own_open: Vec<String> = if own_open.is_empty() {"));

let open = vec![(FILTERS.to_string(), 632u64, earlier_thread_line())];
let late_keys: Vec<Key> = held.iter().map(Key::of_finding).collect();
let settled = one::settle(one::Inputs {
holding: named_holding(&[], &open, &[], false, &own_open, &[]),
late: &late_keys,
prose: SUMMARY,
..Default::default()
});
assert!(settled.holding.is_empty(), "{:?}", settled.holding);
assert_eq!(settled.entries[0].state, State::NoLongerApplies);
let verdict = Verdict::from_holding(settled.holding);
assert_eq!(verdict.event(), "APPROVE");
let b = body(&verdict, held.len(), &settled.prose, &held);
assert!(one::check(&b).is_empty(), "{b}");
assert!(!b.contains(one::HOLDING_HEAD));
assert!(b.contains("my previous review, which missed them"));
}

/// A thread a person resolved, or one about a file the pull request no
/// longer changes, never holds; one the review called gone settles even a
/// required rule.
#[test]
fn resolved_and_gone_threads_never_hold() {
use crate::clients::github::BotReviewThread;
let thread = |id: &str, path: &str, resolved: bool| BotReviewThread {
id: id.into(),
root_id: 1,
path: path.into(),
line: 632,
outdated: false,
body: "**Drop-ins sport dropdown can now list one sport twice**".into(),
replies: vec![],
resolved,
resolved_by_person: resolved,
};
let threads = vec![
thread("t1", FILTERS, true),
thread("t2", "apps/web/src/old.ts", false),
];
let changed = vec![FILTERS.to_string()];
let closed = crate::passes::review_pr::closed_threads(&threads, &[], &[], &changed);
assert_eq!(closed.len(), 2);
assert_eq!(closed[0].1, State::Settled);
assert_eq!(closed[1].1, State::NoLongerApplies);
assert!(crate::passes::review_rules::settles(
crate::passes::review_rules::REQUIRED_MARK,
crate::passes::review_agent::GONE
));
let settled = one::settle(one::Inputs {
holding: vec![crate::passes::review_verdict::Holding::new(
HoldKind::KeptFromEarlier,
earlier_thread_line(),
)],
closed: &closed,
..Default::default()
});
assert!(settled.holding.is_empty());
}

/// The review settles before it writes, and checks the body before it
/// posts.
#[test]
fn the_review_settles_before_it_writes_and_checks_before_it_posts() {
let src = include_str!("../review_pr.rs");
let settle = src.find("review_one_verdict::settle(").expect("settle");
let verdict = src
.find("let mut final_verdict = super::review_verdict::Verdict::from_holding(one.holding)")
.expect("the verdict comes from the settled holds");
assert!(settle < verdict);
let enforce = src
.find("review_one_verdict::enforce(&full_body)")
.expect("enforce");
let post = src[enforce..]
.find("review_verdict::post(")
.expect("posted after the check");
assert!(post > 0);
// Late findings are never chained into the open work that holds.
assert!(src.contains("super::own_review::required(&findings, &[])"));
assert!(!src.contains("super::own_review::required(&findings, &held_late)"));
let _ = review_policy::NEW_CHECK_NOTE;
}
Loading
Loading