Public: anyone can read this; the crew can change it.

Revert "A reviewer judges a pull by its issue and the direction's rules, not by where…" #16542

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

revert-16514 → main 0 commits

  • Merged. revert-16514 was merged into main as 1e141c3.

Review

Sign in to review this change.
5 files changed +4 −92
src/crew/brief.ts +1 −1
@@ -617,7 +617,7 @@ function taskBody(input: TaskInput): string {
617617 ...designPrincipleLines(input.repo),
618618 ]
619619 : []),
620 "- True to its issue and the direction: it does what the issue asked, and breaks none of the direction's rules, and the preview shows it working. The direction's order says what starts first; it is not a ground for a change request.",
620 "- True to the direction: it does what the issue asked and nothing the direction did not, and the preview shows it working.",
621621 ...(input.policy === undefined
622622 ? []
623623 : [
src/crew/repeat_checks.ts +3 −21
@@ -7,10 +7,9 @@
77 */
88
99 import type { App } from "../app.ts";
10 import { addComment, createIssue, listComments } from "../core/issues.ts";
10 import { createIssue } from "../core/issues.ts";
1111 import type { Repo } from "../core/repos.ts";
12 import type { Group } from "../flow/repeats.ts";
13 import { WEEK_MS, aboutDirection, directionLine, dueGroups, keepFinding, proposalBody, retireLanded } from "../flow/repeats.ts";
12 import { dueGroups, keepFinding, proposalBody, retireLanded } from "../flow/repeats.ts";
1413
1514 export const EVERY_MS = 6 * 3_600_000;
1615 export const PER_SWEEP = 2;
@@ -28,10 +27,7 @@ export async function sweepRepeats(app: App, repo: Repo, now = new Date()): Prom
2827 swept.set(repo.id, now.getTime());
2928 const retired = retireLanded(app.db, repo.id, now);
3029 const proposed: number[] = [];
31 const due = await dueGroups(app.db, repo.id, now);
32 const cited = due.find(aboutDirection);
33 if (cited) tellOwner(app, repo, cited, now);
34 for (const g of due.filter((x) => !aboutDirection(x)).slice(0, PER_SWEEP)) {
30 for (const g of (await dueGroups(app.db, repo.id, now)).slice(0, PER_SWEEP)) {
3531 const made = createIssue(app.db, {
3632 repoId: repo.id,
3733 authorId: g.findings[0]!.authorId,
@@ -45,17 +41,3 @@ export async function sweepRepeats(app: App, repo: Repo, now = new Date()): Prom
4541 }
4642 return { proposed, retired };
4743 }
48
49 const OWNER_LINE = "Reviewers cited the direction in ";
50
51 /**
52 * One line on the direction's issue, at most one a week: a repeated citation is the owner's to
53 * read, not a lint to write.
54 */
55 function tellOwner(app: App, repo: Repo, g: Group, now: Date): void {
56 if (repo.directionIssueId === null) return;
57 const week = now.getTime() - WEEK_MS;
58 const told = listComments(app.db, repo.directionIssueId).some((c) => c.body.startsWith(OWNER_LINE) && new Date(c.createdAt).getTime() > week);
59 if (told) return;
60 addComment(app.db, { issueId: repo.directionIssueId, authorId: g.findings[0]!.authorId, body: directionLine(g, `/${repo.ownerName}/${repo.name}/settings`) });
61 }
src/flow/repeats.ts −18
@@ -249,24 +249,6 @@ export function perPull(db: Database, repoId: string, from: Date, to: Date, publ
249249 return { comments: found.length, pulls, per: pulls === 0 ? 0 : Math.round((found.length / pulls) * 10) / 10 };
250250 }
251251
252 /**
253 * A finding that cites the direction ("the owner's order is pipeline first", "the direction says")
254 * is the owner's to settle in the direction's own field, not a check to write (#16250: #16164 asked
255 * for a lint of what the direction had made a reviewer say).
256 */
257 export const citesDirection = (text: string): boolean => /\bdirection\b|\bowner'?s\s+(?:order|shares)\b/i.test(text);
258
259 /** A group is about the direction when most of its findings cite it. */
260 export const aboutDirection = (g: Group): boolean => g.findings.filter((f) => citesDirection(f.text)).length * 2 > g.findings.length;
261
262 /**
263 * The one line for the owner: what reviewers keep citing, a sample, and where the direction is
264 * written.
265 */
266 export function directionLine(g: Group, settingsPath: string): string {
267 return `Reviewers cited the direction in ${g.findings.length} reviews this week, for example "${g.sample.replace(/\s+/g, " ").slice(0, 200)}". If that is not what you meant, rewrite it in the Direction field: ${settingsPath}#f-direction`;
268 }
269
270252 /** The issue body that asks for the check, naming the comments. */
271253 export function proposalBody(g: Group, now: Date): string {
272254 const named = g.findings
test/crew-review-rounds.test.ts −31
@@ -48,34 +48,3 @@ describe("the reviewer's rounds", () => {
4848 expect(p).toContain("approve when only those remain");
4949 });
5050 });
51
52 describe("the reviewer's reading of the direction (#16250)", () => {
53 const withDirection = (autonomyDirection: string) =>
54 taskPrompt({
55 reason: "review",
56 agent: { user: { username: "rev", displayName: "" }, brief: "" },
57 repo: { ownerName: "alice", name: "square", defaultBranch: "main", autonomyDirection },
58 issue: { number: 7, title: "t" },
59 branch: "b",
60 forgeUrl: "http://forge.test",
61 isApp: false,
62 comments: [],
63 reviews: [],
64 reviewComments: [],
65 since: "",
66 } as unknown as TaskInput);
67
68 test("the line judges by the issue and the direction's rules, and order is no ground", () => {
69 const p = withDirection("x");
70 expect(p).toContain("True to its issue and the direction: it does what the issue asked, and breaks none of the direction's rules");
71 expect(p).toContain("The direction's order says what starts first; it is not a ground for a change request.");
72 expect(p).not.toContain("nothing the direction did not");
73 });
74
75 test("a changed direction is in the next review's brief", () => {
76 expect(withDirection("Pipeline first.")).toContain("Pipeline first.");
77 const next = withDirection("Shares and order are for starting work.");
78 expect(next).toContain("Shares and order are for starting work.");
79 expect(next).not.toContain("Pipeline first.");
80 });
81 });
test/review-repeats.test.ts −21
@@ -304,24 +304,3 @@ describe(BOX_RULE, () => {
304304 expect(await dueGroups(app.db, r.value.id, now)).toEqual([]);
305305 });
306306 });
307
308 describe("a finding that cites the direction (#16250)", () => {
309 test("opens no lint issue; one line on the direction's issue, once a week", async () => {
310 const r2 = await createRepo(app, builder, { name: "dirrepo", visibility: "public" });
311 if (!r2.ok) throw new Error(String(r2.error));
312 const dir = createIssue(app.db, { repoId: r2.value.id, authorId: builder.id, title: "Direction: x" });
313 if (!dir.ok) throw new Error(dir.error);
314 app.db.query(`UPDATE repo SET direction_issue_id = ?1 WHERE id = ?2`).run(dir.value.id, r2.value.id);
315 const was = repo;
316 repo = r2.value;
317 for (let i = 0; i < REPEATS; i++) reviewed("Explain why this goes ahead of the pipeline, the direction's order says pipeline first");
318 repo = was;
319 const fresh = { ...r2.value, directionIssueId: dir.value.id };
320 const moves = await sweepRepeats(app, fresh, now);
321 expect(moves.proposed).toEqual([]);
322 const lines = app.db.query<{ body: string }, [string]>(`SELECT body FROM comment WHERE issue_id = ?1`).all(dir.value.id);
323 expect(lines).toHaveLength(1);
324 expect(lines[0]!.body).toContain("Reviewers cited the direction in 4 reviews");
325 expect(lines[0]!.body).toContain("/settings#f-direction");
326 });
327 });

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs