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
2 changes: 1 addition & 1 deletion docs/PLAN.md

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion plugin/scripts/lib/handoff.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,13 @@ export function reviewPost({ issue, review, diff, entries = [], ok = true, split
const first = Object.entries(diffLines(diff)).find(([, v]) => v.lines.size);
placeholder = true;
// A pass that judged no entry (reviewMissed) is not a clean pass: the placeholder says so.
// An entry not met with no comment (assigned by a decision, or its finding already open) is in the body.
const said =
review && judgedNone(review, entries)
? "the reviewer judged none of the acceptance entries; this is not a clean pass."
: "no findings; the pass ran and returned nothing line-tied.";
: judged.some((a) => !a.met && !(splitPart && a.deferred))
? "no new line findings; the review body lists the acceptance entries not met."
: "no findings; the pass ran and returned nothing line-tied.";
comments = [{ path: first?.[0] ?? null, line: first ? (first[1].first ?? Math.min(...first[1].lines)) : null, side: "RIGHT", body: `${PLACEHOLDER_MARKER}\nPendulum reviewer: ${said}` }];
}
const checked = "checked the shared contracts the diff changes against their callers";
Expand Down
20 changes: 19 additions & 1 deletion plugin/scripts/review.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,13 @@ export async function headMovedFrom({ repo, prNumber, own, token, before = null
return now.head.sha;
}

/**
* Pendulum's open findings (`open`) a not-met entry may rely on for its comment (handoff.mjs reviewPost `open`): those
* whose answer the last stage's check left without a verdict (`unjudged`, checkState) are judged again after the review
* goes up and may be resolved then, so they are left out and their entries get their comment (#638).
*/
export const settledOpen = (open, unjudged) => open.filter((c) => !unjudged.some((id) => String(id) === String(c.id)));

/**
* The review comments the answer pass gets: every open one, but after a first review that found nothing (its
* placeholder) only the third-party reviewers' and code scanning's (`from`). A later pass that found nothing leaves the
Expand Down Expand Up @@ -1827,10 +1834,21 @@ async function main() {
// Pendulum's own findings still open on the PR from an earlier review (never a third party's or a writer's comment):
// an entry judged not met again gets no second comment beside its open one. Read only when an earlier review of
// Pendulum's exists and this answer judges an entry not met; unread, each such entry gets its comment as before.
// One whose answer the last stage's check got no verdict on is judged again after this review goes up and may be
// resolved then, so it holds no entry back (settledOpen); with that record unread, none does.
const openFindings =
!alreadyReviewed && !scope.first && (reviewOf(answer).acceptance || []).some((a) => !a.met)
? await unaddressedReviewComments(repo, pr.number, reviewerLogin, { ...token, reviewIds: await pendulumReviewIds() }).then(
(open) => open.filter((c) => !c.from && !c.writer),
async (open) => {
const mine = open.filter((c) => !c.from && !c.writer);
if (!mine.length) return mine;
const rec = await readAnswerRounds(repo, { issue, prNumber: pr.number, objectiveLabel: inputs.objectiveLabel }, token).catch((e) => {
if (outageMet(e)) throw e;
log(`open findings: the answer-rounds record could not be read (${String(e?.message || e).slice(0, 120)})`);
return null;
});
return rec ? settledOpen(mine, checkState(rec).unjudged) : [];
},
(e) => {
// Unread because of an outage (network.mjs outageMet): the stage ends on it, as on any read.
if (outageMet(e)) throw e;
Expand Down
9 changes: 9 additions & 0 deletions plugin/test/exit.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { input, parseArgs, resolveInputs } from "../scripts/lib/inputs.mjs";
import { EXIT_PROMPT, acceptanceEntries, capReached, commandPaths, decideExit, deniedHostsFix, fenceDecidable, isHostName, diffLines, entryKey, fixScopeReason, fixScopeRefused, isPlaceholder, marker, namesPath, parseExitRecord, parseFindings, parseReview, protectedPaths, setupPaths, snapComments, pushRefusal, toolchainFile, workflowScopeRefused, workspaceDeclarations } from "../scripts/lib/logic.mjs";
import { noReviewReason, reviewMissed, reviewAnswer, reviewCallEnd, reviewCallTimeout, reviewPost, reviewProduced, reviewRetry } from "../scripts/lib/handoff.mjs";
import { exitRecord, scopeRefusal } from "../scripts/lib/session.mjs";
import { settledOpen } from "../scripts/review.mjs";

const ok = { ok: true };
const pr = (body = "## Acceptance\nok", draft = false) => ({ exists: true, draft, body });
Expand Down Expand Up @@ -216,6 +217,14 @@ test("#634: an entry whose finding is already open on the PR gets no second not-
assert.deepEqual(post.comments.map((c) => c.body), ["acceptance B: not met."]);
});

test("#638: an open finding about to be judged again holds back no not-met comment", () => {
const diff = readFileSync(join(import.meta.dirname, "fixtures", "sample.diff"), "utf8");
const review = { comments: [], acceptance: [{ entry: "A", met: false, path: "src/a.ts", line: 3, evidence: "" }] };
const open = [{ id: 5, path: "src/a.ts", line: 3, body: "acceptance A: not met. the limit is gone" }];
const post = reviewPost({ issue: 7, review, diff, entries: [{ id: "A", text: "a" }], open: settledOpen(open, [5]) });
assert.deepEqual(post.comments.map((c) => c.body), ["acceptance A: not met."]);
});

test("review: a reviewer call always has a wall-clock cap; past the stage's deadline none starts (#2660)", () => {
// exec treats a timeout of 0 as no timer: a call started with nothing left would run until the job itself is cut.
assert.equal(reviewCallTimeout(0), null);
Expand Down