From c03769d61e293e3397b751369e3404218ce0406e Mon Sep 17 00:00:00 2001 From: Nam Rodriguez Date: Wed, 4 Nov 2026 19:08:18 -0500 Subject: [PATCH] Investigations reproduce past caches, fixes are claimed only on the real output, and open objections lead the description Missing-or-wrong-data investigations now reproduce first past every cache, treat "healthy at every layer" while the person still can't see the record as an incomplete trace, run the client's exact query and drop one filter at a time, diff against a similar record that shows, check the time zone of both sides of every date comparison, and fix every path that shares the defect. A fix counts as proven only when the real API response or page shows it; a matching filter or a passing test is not that. The coder records an unproven fix as an Unconfirmed line with the exact check a person should run, and the PR description's Verification section says Unproven the same way. The coder and planner never print or fetch credentials to answer a question, and lead their report with "rotate this credential" if one reaches a tool's output. When a pull request's description is rewritten, reviewers whose latest verdict still requests changes are named at the top of it, and the note goes once nobody objects. An unreadable review list leaves the note as it was. --- services/worker/src/passes/completeness.rs | 67 +++++++++++++++++++++- services/worker/src/passes/fix_location.rs | 19 ++++++ services/worker/src/passes/plan.rs | 2 +- services/worker/src/passes/pr.rs | 33 +++++++++++ services/worker/src/passes/proof.rs | 8 +++ 5 files changed, 127 insertions(+), 2 deletions(-) diff --git a/services/worker/src/passes/completeness.rs b/services/worker/src/passes/completeness.rs index a37f8561a..6c21c6b2a 100644 --- a/services/worker/src/passes/completeness.rs +++ b/services/worker/src/passes/completeness.rs @@ -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, @@ -140,6 +144,7 @@ impl Section { Section::OpenItems, Section::Unfinished, Section::OpenFindings, + Section::Objections, ]; /// Its start and end markers. @@ -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), } } } @@ -197,6 +203,7 @@ pub struct Owned { pub open_items: String, pub unfinished: String, pub open_findings: String, + pub objections: String, } impl Owned { @@ -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, } } @@ -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 = ""; +pub const OBJECTIONS_END: &str = ""; + +/// 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::>() + .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 { @@ -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(), @@ -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(), diff --git a/services/worker/src/passes/fix_location.rs b/services/worker/src/passes/fix_location.rs index 3be05ba89..2238f800d 100644 --- a/services/worker/src/passes/fix_location.rs +++ b/services/worker/src/passes/fix_location.rs @@ -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."#; @@ -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}"); } diff --git a/services/worker/src/passes/plan.rs b/services/worker/src/passes/plan.rs index 40e3382f2..cd02d095c 100644 --- a/services/worker/src/passes/plan.rs +++ b/services/worker/src/passes/plan.rs @@ -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"; diff --git a/services/worker/src/passes/pr.rs b/services/worker/src/passes/pr.rs index d6c847a76..4458097ee 100644 --- a/services/worker/src/passes/pr.rs +++ b/services/worker/src/passes/pr.rs @@ -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}`, ``, \ `{}` or empty backticks. @@ -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() @@ -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; } @@ -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(""), ""); diff --git a/services/worker/src/passes/proof.rs b/services/worker/src/passes/proof.rs index c2b12fad3..3f313cbac 100644 --- a/services/worker/src/passes/proof.rs +++ b/services/worker/src/passes/proof.rs @@ -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:]:` 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. @@ -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:`")); }