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
67 changes: 66 additions & 1 deletion services/worker/src/passes/completeness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,14 @@ pub enum Section {
/// yet, at the very top: the PR stays a draft while any is listed (see
/// `own_review`).
OpenFindings,
/// Reviewers whose standing request for changes is still open, above
/// everything: a reader never ships over an objection without seeing it
/// (see [`objections_section`]).
Objections,
}

impl Section {
const ALL: [Section; 8] = [
const ALL: [Section; 9] = [
Section::Links,
Section::Mirrors,
Section::MergeOrder,
Expand All @@ -140,6 +144,7 @@ impl Section {
Section::OpenItems,
Section::Unfinished,
Section::OpenFindings,
Section::Objections,
];

/// Its start and end markers.
Expand All @@ -162,6 +167,7 @@ impl Section {
Section::OpenItems => (super::proof::UNVERIFIED_START, super::proof::UNVERIFIED_END),
Section::Unfinished => (super::proof::UNFINISHED_START, super::proof::UNFINISHED_END),
Section::OpenFindings => (super::own_review::START, super::own_review::END),
Section::Objections => (OBJECTIONS_START, OBJECTIONS_END),
}
}
}
Expand Down Expand Up @@ -197,6 +203,7 @@ pub struct Owned {
pub open_items: String,
pub unfinished: String,
pub open_findings: String,
pub objections: String,
}

impl Owned {
Expand All @@ -210,6 +217,7 @@ impl Owned {
Section::OpenItems => &mut self.open_items,
Section::Unfinished => &mut self.unfinished,
Section::OpenFindings => &mut self.open_findings,
Section::Objections => &mut self.objections,
}
}

Expand Down Expand Up @@ -381,9 +389,39 @@ pub fn assemble(rest: &str, owned: &Owned) -> String {
format!("{open_findings}\n\n{body}")
};
}
// Open reviewer objections go above even those.
let objections = owned.objections.trim();
if !objections.is_empty() {
body = if body.is_empty() {
objections.to_string()
} else {
format!("{objections}\n\n{body}")
};
}
format!("{body}{footer}")
}

pub const OBJECTIONS_START: &str = "<!-- coderhelm:objections -->";
pub const OBJECTIONS_END: &str = "<!-- /coderhelm:objections -->";

/// The reviewers whose latest verdict still requests changes, for the top of
/// the description. Logins are written in backticks so nobody is notified.
/// Empty when nobody objects.
pub fn objections_section(blocking_by: &[String]) -> String {
if blocking_by.is_empty() {
return String::new();
}
let who = blocking_by
.iter()
.map(|l| format!("`{}`", plain(l)))
.collect::<Vec<_>>()
.join(", ");
format!(
"{OBJECTIONS_START}\n**Open reviewer objection:** {who} requested changes and has not \
approved since. Settle it before merging.\n{OBJECTIONS_END}"
)
}

/// `body` with one of CoderHelm's sections set to `text` (empty removes it),
/// every section in its place.
pub fn with_section(body: &str, section: Section, text: String) -> String {
Expand Down Expand Up @@ -931,6 +969,32 @@ mod tests {
use super::*;
use crate::passes::fix_location::{EndToEndStep, FixLocation};

#[test]
fn an_open_reviewer_objection_goes_first_and_leaves_when_settled() {
assert_eq!(objections_section(&[]), "");
let s = objections_section(&["alice".into(), "bob".into()]);
assert!(s.contains("`alice`, `bob` requested changes"), "{s}");
assert!(!s.contains('@'), "nobody is notified: {s}");
let rest = "Source ticket: OPS-1\n\n**Summary** x";
let owned = Owned {
open_findings: format!(
"{}\nfinding\n{}",
crate::passes::own_review::START,
crate::passes::own_review::END
),
objections: s.clone(),
..Default::default()
};
let body = assemble(rest, &owned);
assert!(body.starts_with(OBJECTIONS_START), "{body}");
// Kept through a rewrite, and gone once nobody objects.
let (kept, _) = take_owned(&body);
assert_eq!(kept.objections, s);
let settled = with_section(&body, Section::Objections, objections_section(&[]));
assert!(!settled.contains("coderhelm:objections"), "{settled}");
assert!(settled.contains("**Summary** x"));
}

fn step(step: &str, by: &str, owner: &str, repo: &str) -> EndToEndStep {
EndToEndStep {
step: step.into(),
Expand Down Expand Up @@ -1117,6 +1181,7 @@ mod tests {
let owned = Owned {
unfinished: String::new(),
open_findings: String::new(),
objections: String::new(),
links: String::new(),
mirrors: mirrors_section(&[Mirror {
path: "envs/prod/users.tf".into(),
Expand Down
19 changes: 19 additions & 0 deletions services/worker/src/passes/fix_location.rs
Original file line number Diff line number Diff line change
Expand Up @@ -712,11 +712,17 @@ pub fn planner_guidance(intent: TicketIntent) -> String {
pub const MISSING_DATA_GUIDANCE: &str = r#"## Missing or wrong data (a record that should show and doesn't, a wrong value)

Trace the record through every layer it passes, in order, and find the FIRST layer where it is wrong or missing. That layer is where the fault is.
- Reproduce first, past every cache: add a cache-busting query parameter to the page or API URL and confirm the response was a cache miss.
- Name the layers first: where the record starts (a source system or warehouse), where it is stored (the app database), where it is copied for reading (a search index, a cache), and where it is shown (the page or API). Record each one in `evidence.layers`: the repository or system that holds it, and what the record looks like there.
- The code that produces a layer is often in another of the team's repositories (a sync, an indexer or a pipeline job in a data or pipelines repository). When a search in this repository finds nothing, search the team's other repositories by the same names before you call a step unknown; pass `repo` to `search_code`, `read_file_lines` and `list_directory`. Read only; the fix still goes where the fault is.
- Look records up by their stable ids, never by display names: names can be hidden, renamed or shared by several records. When two findings disagree about one record (the same record under two ids, two values for one field), settle which is right before you build on either.
- Before reading a field's meaning from its name, read the code that writes it. A field can be copied from another field or filled by a default, and then its name says nothing.
- For an incremental sync, compare the record's change time (`updated_at` or the like) with the sync's cursor or last run mark, and read the sync's recent runs and warnings, before you suspect a business rule. A record changed before the cursor moved past it, or a run that failed or warned, explains a missing record without any rule being wrong.
- Every layer looking healthy while the person still can't see the record means the trace is incomplete, not done. Find the exact query the client sends (its filters, sort, page size), run it, and remove one filter at a time until the record comes back. Diff its fields against a similar record that does show.
- In every date comparison, check the time zone of each side: a stored wall-clock time compared with a UTC instant shifts records across the boundary.
- Measure the blast radius: how many records share the defect, and which other pages, queries or paths use the same filter. The fix covers every one of them.
- A fix is proven only when the real API response or page shows the record. A matching filter or a passing test is not that proof: until that check runs, call the fix unproven and name the exact check.
- Never print or fetch credentials to answer a question (production secrets, API keys, tokens). If one reaches a tool's output, stop using it and put "rotate this credential" first in what you report.
- When the ticket is about production, check production data directly with the connected sources.
- Use the team's own tools and data sources first (the tools named for this team, its saved lookups, its knowledge bases); they were built for exactly these questions. Never guess what a lookup can show.
- When the next step is one you can't take (a job only a person can run, access you don't have), don't ask an open question: set `fix_location` to `unknown` and fill `next_step` with that one action and what each outcome would mean."#;
Expand Down Expand Up @@ -1408,6 +1414,19 @@ mod investigation_tests {
"check production data directly",
"the team's own tools and data sources first",
"`next_step`",
"cache-busting query parameter",
"cache miss",
"the trace is incomplete, not done",
"exact query the client sends",
"remove one filter at a time",
"similar record that does show",
"time zone of each side",
"blast radius",
"covers every one of them",
"real API response or page",
"call the fix unproven and name the exact check",
"Never print or fetch credentials",
"rotate this credential",
] {
assert!(MISSING_DATA_GUIDANCE.contains(want), "{want}");
}
Expand Down
2 changes: 1 addition & 1 deletion services/worker/src/passes/plan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use crate::WorkerState;
/// any change to how plans are made or what a plan must carry, so a plan
/// written by an older planner is never reused.
pub const PLANNER_VERSION: &str =
"2026-11-04.intent-history-env-near-match-stop-rules-data-rules-cross-repo-asking";
"2026-11-04.intent-history-env-near-match-stop-rules-data-rules-cross-repo-asking-reproduce";

/// The openspec file holding the plan's end-to-end checklist, readable.
pub const END_TO_END_FILE: &str = "end_to_end.md";
Expand Down
33 changes: 33 additions & 0 deletions services/worker/src/passes/pr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,9 @@ const SHAPE_RULES: &str = "\
- CoderHelm adds these sections itself, from the plan and the coder's notes: the existing block \
the change copies, the merge order of a multi-repo change, **Not in this PR** and **Open items**. \
Don't write them, and don't add a warning or note banner anywhere.
- Verification says the change works only where its real output (the real API response or page) \
was checked and shows it. A matching filter or a passing test is not that; otherwise write \
**Unproven** and the exact check a person should run.
- Write real values: every path, name and id in full, with its environment filled in \
(`/app/prod/db-password`, never `/app//db-password`), never a template left as `${env}`, `<env>`, \
`{}` or empty backticks.
Expand Down Expand Up @@ -1489,6 +1492,7 @@ fn owned_sections(plan: &PlanResult, proof: &Proof<'_>, repo: &str) -> super::co
),
review_fixes: String::new(),
open_findings: String::new(),
objections: String::new(),
// A small failing-test fix carries no open items or questions.
open_items: if small_test_fix {
String::new()
Expand Down Expand Up @@ -1711,6 +1715,27 @@ Return ONLY the markdown body text, then a line `{CHANGES_MARK}` and one bullet
super::completeness::assemble(&rest, &kept)
};
let body = super::release_plan::put_section(&body, &release_section);
// A reviewer's standing request for changes is stated at the top. An
// unreadable review list keeps whatever the description said before.
let body = match super::review_actions::fetch_approvals(
github,
owner,
repo,
pr_number,
pr["head"]["sha"].as_str().unwrap_or(""),
)
.await
{
Ok(a) => super::completeness::with_section(
&body,
super::completeness::Section::Objections,
super::completeness::objections_section(&a.blocking_by),
),
Err(e) => {
warn!(pr_number, error = %e, "Could not read the PR's reviews; objections left as they were");
body
}
};
if body == current {
return None;
}
Expand Down Expand Up @@ -1937,6 +1962,14 @@ mod refresh_tests {
writer_system,
};

#[test]
fn verification_claims_only_what_the_real_output_showed() {
let rules = super::SHAPE_RULES;
assert!(rules.contains("real output (the real API response or page)"));
assert!(rules.contains("A matching filter or a passing test is not that"));
assert!(rules.contains("**Unproven** and the exact check a person should run"));
}

#[test]
fn checks_only_a_person_can_do_become_verification_steps() {
assert_eq!(manual_instructions(""), "");
Expand Down
8 changes: 8 additions & 0 deletions services/worker/src/passes/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ pub const CODER_RULES: &str = "
- Logging: INFO only for actual changes and decisions; diagnostics go to DEBUG. Never add an INFO log that fires for every record or on every scheduled run.
- Never leave \"unconfirmed\", \"not verified\" or \"not measured\" for something a connected source could answer: look it up. When no connected source can reach it, say exactly which source is missing.
- A lookup that failed or came back empty (an empty list, no rows) confirms nothing about the system: it is not a payload. Find out why (a wrong path, a parent id from another record, a wrong table) and read again until a real record comes back.
- \"Fixed\" means seen fixed in the real output (the real API response or page). A matching filter or a passing unit test is not that. When you can't run that check, write `- Unconfirmed [external:<the page or API>]:` saying the fix is unproven and the exact check a person should run.
- Never run a command that prints credentials, and never fetch production secrets or API keys to answer a question. If a secret reaches a tool's output, stop using it and start your summary with \"Rotate this credential\" and where it appeared.

## Reading another system's data (every change that does)
- Actual data first, always: before deciding how to read another system's records, read real ones (a payload, a row) for the ticket's records and a broad sample of others, and list every field on them. Decide from what you saw, never from names in the code, a schema or a guess.
Expand Down Expand Up @@ -2054,6 +2056,12 @@ mod tests {
assert!(CODER_RULES.contains("fixtures from real payloads"));
assert!(CODER_RULES.contains("No manual backfills or one-off scripts"));
assert!(CODER_RULES.contains("no hard-coded ids, names, seasons or prices"));
// Fixed means seen fixed; secrets never printed or fetched.
assert!(CODER_RULES.contains("seen fixed in the real output"));
assert!(CODER_RULES.contains("A matching filter or a passing unit test is not that"));
assert!(CODER_RULES.contains("the fix is unproven and the exact check a person should run"));
assert!(CODER_RULES.contains("Never run a command that prints credentials"));
assert!(CODER_RULES.contains("Rotate this credential"));
assert!(EVIDENCE_OUTPUT.contains("`Evidence:`"));
}

Expand Down
Loading