@codyswann/lisa 5.10.0 → 5.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/all/copy-overwrite/scripts/check-third-party-review-evidence.mjs +241 -36
  2. package/all/copy-overwrite/scripts/lisa-gates.mjs +112 -2
  3. package/all/copy-overwrite/scripts/npm-updater-helper-graph.json +1 -1
  4. package/dist/core/lisa-owned-hash-ledger.d.ts.map +1 -1
  5. package/dist/core/lisa-owned-hash-ledger.js +34 -0
  6. package/dist/core/lisa-owned-hash-ledger.js.map +1 -1
  7. package/dist/core/nightly-e2e-guard-behavior-certificate.js +2 -2
  8. package/dist/core/upstream-evidence-manifest.d.ts.map +1 -1
  9. package/dist/core/upstream-evidence-manifest.js +9 -7
  10. package/dist/core/upstream-evidence-manifest.js.map +1 -1
  11. package/package.json +4 -4
  12. package/plugins/lisa/.claude-plugin/plugin.json +1 -1
  13. package/plugins/lisa/.codex-plugin/plugin.json +1 -1
  14. package/plugins/lisa/.codex-plugin/skills/lisa-drive-pr-to-merge/SKILL.md +20 -2
  15. package/plugins/lisa/.codex-plugin/skills/lisa-pull-request-review/SKILL.md +37 -10
  16. package/plugins/lisa/skills/lisa-drive-pr-to-merge/SKILL.md +20 -2
  17. package/plugins/lisa/skills/lisa-pull-request-review/SKILL.md +37 -10
  18. package/plugins/lisa-agy/plugin.json +1 -1
  19. package/plugins/lisa-agy/skills/lisa-drive-pr-to-merge/SKILL.md +20 -2
  20. package/plugins/lisa-agy/skills/lisa-pull-request-review/SKILL.md +37 -10
  21. package/plugins/lisa-cdk/.claude-plugin/plugin.json +1 -1
  22. package/plugins/lisa-cdk/.codex-plugin/plugin.json +1 -1
  23. package/plugins/lisa-cdk-agy/plugin.json +1 -1
  24. package/plugins/lisa-cdk-copilot/.claude-plugin/plugin.json +1 -1
  25. package/plugins/lisa-cdk-cursor/.claude-plugin/plugin.json +1 -1
  26. package/plugins/lisa-cdk-devin/.claude-plugin/plugin.json +1 -1
  27. package/plugins/lisa-cdk-devin/.devin-plugin/plugin.json +1 -1
  28. package/plugins/lisa-copilot/.claude-plugin/plugin.json +1 -1
  29. package/plugins/lisa-copilot/skills/lisa-drive-pr-to-merge/SKILL.md +20 -2
  30. package/plugins/lisa-copilot/skills/lisa-pull-request-review/SKILL.md +37 -10
  31. package/plugins/lisa-cursor/.claude-plugin/plugin.json +1 -1
  32. package/plugins/lisa-cursor/skills/lisa-drive-pr-to-merge/SKILL.md +20 -2
  33. package/plugins/lisa-cursor/skills/lisa-pull-request-review/SKILL.md +37 -10
  34. package/plugins/lisa-devin/.claude-plugin/plugin.json +1 -1
  35. package/plugins/lisa-devin/.devin-plugin/plugin.json +1 -1
  36. package/plugins/lisa-devin/skills/lisa-drive-pr-to-merge/SKILL.md +20 -2
  37. package/plugins/lisa-devin/skills/lisa-pull-request-review/SKILL.md +37 -10
  38. package/plugins/lisa-expo/.claude-plugin/plugin.json +1 -1
  39. package/plugins/lisa-expo/.codex-plugin/plugin.json +1 -1
  40. package/plugins/lisa-expo-agy/plugin.json +1 -1
  41. package/plugins/lisa-expo-copilot/.claude-plugin/plugin.json +1 -1
  42. package/plugins/lisa-expo-cursor/.claude-plugin/plugin.json +1 -1
  43. package/plugins/lisa-expo-devin/.claude-plugin/plugin.json +1 -1
  44. package/plugins/lisa-expo-devin/.devin-plugin/plugin.json +1 -1
  45. package/plugins/lisa-harper-fabric/.claude-plugin/plugin.json +1 -1
  46. package/plugins/lisa-harper-fabric/.codex-plugin/plugin.json +1 -1
  47. package/plugins/lisa-harper-fabric-agy/plugin.json +1 -1
  48. package/plugins/lisa-harper-fabric-copilot/.claude-plugin/plugin.json +1 -1
  49. package/plugins/lisa-harper-fabric-cursor/.claude-plugin/plugin.json +1 -1
  50. package/plugins/lisa-harper-fabric-devin/.claude-plugin/plugin.json +1 -1
  51. package/plugins/lisa-harper-fabric-devin/.devin-plugin/plugin.json +1 -1
  52. package/plugins/lisa-nestjs/.claude-plugin/plugin.json +1 -1
  53. package/plugins/lisa-nestjs/.codex-plugin/plugin.json +1 -1
  54. package/plugins/lisa-nestjs-agy/plugin.json +1 -1
  55. package/plugins/lisa-nestjs-copilot/.claude-plugin/plugin.json +1 -1
  56. package/plugins/lisa-nestjs-cursor/.claude-plugin/plugin.json +1 -1
  57. package/plugins/lisa-nestjs-devin/.claude-plugin/plugin.json +1 -1
  58. package/plugins/lisa-nestjs-devin/.devin-plugin/plugin.json +1 -1
  59. package/plugins/lisa-phaser/.claude-plugin/plugin.json +1 -1
  60. package/plugins/lisa-phaser/.codex-plugin/plugin.json +1 -1
  61. package/plugins/lisa-phaser-agy/plugin.json +1 -1
  62. package/plugins/lisa-phaser-copilot/.claude-plugin/plugin.json +1 -1
  63. package/plugins/lisa-phaser-cursor/.claude-plugin/plugin.json +1 -1
  64. package/plugins/lisa-phaser-devin/.claude-plugin/plugin.json +1 -1
  65. package/plugins/lisa-phaser-devin/.devin-plugin/plugin.json +1 -1
  66. package/plugins/lisa-rails/.claude-plugin/plugin.json +1 -1
  67. package/plugins/lisa-rails/.codex-plugin/plugin.json +1 -1
  68. package/plugins/lisa-rails-agy/plugin.json +1 -1
  69. package/plugins/lisa-rails-copilot/.claude-plugin/plugin.json +1 -1
  70. package/plugins/lisa-rails-cursor/.claude-plugin/plugin.json +1 -1
  71. package/plugins/lisa-rails-devin/.claude-plugin/plugin.json +1 -1
  72. package/plugins/lisa-rails-devin/.devin-plugin/plugin.json +1 -1
  73. package/plugins/lisa-typescript/.claude-plugin/plugin.json +1 -1
  74. package/plugins/lisa-typescript/.codex-plugin/plugin.json +1 -1
  75. package/plugins/lisa-typescript-agy/plugin.json +1 -1
  76. package/plugins/lisa-typescript-copilot/.claude-plugin/plugin.json +1 -1
  77. package/plugins/lisa-typescript-cursor/.claude-plugin/plugin.json +1 -1
  78. package/plugins/lisa-typescript-devin/.claude-plugin/plugin.json +1 -1
  79. package/plugins/lisa-typescript-devin/.devin-plugin/plugin.json +1 -1
  80. package/plugins/lisa-wiki/.claude-plugin/plugin.json +1 -1
  81. package/plugins/lisa-wiki/.codex-plugin/plugin.json +1 -1
  82. package/plugins/lisa-wiki-agy/plugin.json +1 -1
  83. package/plugins/lisa-wiki-copilot/.claude-plugin/plugin.json +1 -1
  84. package/plugins/lisa-wiki-cursor/.claude-plugin/plugin.json +1 -1
  85. package/plugins/lisa-wiki-devin/.claude-plugin/plugin.json +1 -1
  86. package/plugins/lisa-wiki-devin/.devin-plugin/plugin.json +1 -1
  87. package/plugins/src/base/skills/lisa-drive-pr-to-merge/SKILL.md +20 -2
  88. package/plugins/src/base/skills/lisa-pull-request-review/SKILL.md +37 -10
  89. package/typescript/copy-overwrite/.github/GITHUB_ACTIONS.md +0 -17
  90. package/typescript/copy-overwrite/scripts/check-skipped-required-checks.mjs +42 -10
@@ -240,6 +240,8 @@ export const EVIDENCE_SOURCES = Object.freeze({
240
240
  status: "status",
241
241
  /** `repos/{repo}/commits/{sha}/check-runs`. */
242
242
  checkRun: "check-run",
243
+ /** `repos/{repo}/pulls/{n}/reviews`, from the gate's `evidence.review_by` account (#4909). */
244
+ review: "review",
243
245
  });
244
246
 
245
247
  /** What the whole evaluation concluded. */
@@ -350,7 +352,7 @@ export function normalizeDescription(description) {
350
352
  * @param {object} options - Resolution inputs.
351
353
  * @param {object} options.gates - The `gates` block of `.lisa.config.json`.
352
354
  * @param {string} [options.moment] - Which moment to read. Defaults to the pull-request moment.
353
- * @returns {Array<{gateId: string, context: string, proof: string[], postedBy?: unknown}>} Declared reviewers.
355
+ * @returns {Array<{gateId: string, context: string, proof: string[], noWork: string[], postedBy?: unknown, reviewBy?: string}>} Declared reviewers.
354
356
  */
355
357
  export function configuredReviewers({ gates, moment = PULL_REQUEST }) {
356
358
  const reviewers = [];
@@ -366,7 +368,14 @@ export function configuredReviewers({ gates, moment = PULL_REQUEST }) {
366
368
  proof: [...EVIDENCE_DEFAULTS.proof, ...(entry.evidence.proof ?? [])].map(
367
369
  normalizeDescription
368
370
  ),
371
+ noWork: [...EVIDENCE_DEFAULTS.no_work, ...(entry.evidence.no_work ?? [])],
369
372
  ...(entry.posted_by === undefined ? {} : { postedBy: entry.posted_by }),
373
+ // A gate pinned by posted_by never takes the review route (#4916).
374
+ ...(entry.posted_by === undefined &&
375
+ typeof entry.evidence.review_by === "string" &&
376
+ entry.evidence.review_by.trim() !== ""
377
+ ? { reviewBy: entry.evidence.review_by.trim() }
378
+ : {}),
370
379
  });
371
380
  }
372
381
  return reviewers.sort((left, right) =>
@@ -388,17 +397,28 @@ export function configuredReviewers({ gates, moment = PULL_REQUEST }) {
388
397
  * @param {string} normalised - An already-normalised description.
389
398
  * @returns {boolean} Whether a shipped no-work phrase appears in it.
390
399
  */
391
- function readsAsNoWork(normalised) {
392
- return EVIDENCE_DEFAULTS.no_work.some(phrase =>
400
+ function readsAsNoWork(normalised, noWork = EVIDENCE_DEFAULTS.no_work) {
401
+ return noWork.some(phrase =>
393
402
  normalised.includes(normalizeDescription(phrase))
394
403
  );
395
404
  }
396
405
 
406
+ /**
407
+ * The words a reviewer is judged by when no gate declared any: Lisa's shipped
408
+ * phrases alone.
409
+ */
410
+ const SHIPPED_REVIEWER_WORDS = Object.freeze({
411
+ proof: Object.freeze(EVIDENCE_DEFAULTS.proof.map(normalizeDescription)),
412
+ noWork: EVIDENCE_DEFAULTS.no_work,
413
+ });
414
+
397
415
  /**
398
416
  * @typedef {object} ReviewerShape
399
417
  * @property {string} context - The status context or check-run name it reports under.
400
418
  * @property {string[]} proof - The normalised reviewed-when allowlist.
401
419
  * @property {unknown} [postedBy] - The app id a check run must come from, exactly as declared; absent for any app. When declared, no commit status counts.
420
+ * @property {ReadonlyArray<string>} [noWork] - Phrases that say the reviewer did no work: Lisa's shipped ones plus the gate's `evidence.no_work` (#4909). Absent means the shipped ones alone.
421
+ * @property {string} [reviewBy] - The account whose pull-request review at the head counts as this reviewer's evidence, from `evidence.review_by` (#4909).
402
422
  */
403
423
 
404
424
  /**
@@ -429,19 +449,37 @@ function readsAsNoWork(normalised) {
429
449
  */
430
450
 
431
451
  /**
432
- * The one structured first line that says a review completed.
452
+ * CodeRabbit's structured first line for a review that completed (#4547).
433
453
  *
434
- * Byte-identical to the line `check-skipped-required-checks.mjs` recognises
435
- * (#4547), and matched the same way: exactly, as the first physical line, on a
436
- * run that completed with `success`. Duplicated rather than imported because
437
- * the two scripts ship from different template trees and a host that has this
438
- * one need not have that one; `tests/integration/third-party-review-check-run-cli`
439
- * holds both provers to the same answers.
454
+ * Kept as a named example, not as a rule: it is credited because it has the
455
+ * generic `Result: Success - <phrase>` shape (see {@link structuredSuccessPhrase}) and its phrase, `Review completed`,
456
+ * is a shipped proof phrase. A different reviewer is credited the same way
457
+ * through the phrases its gate declares in `evidence.proof` (#4909).
440
458
  */
441
459
  export const COMPLETED_REVIEW_RESULT = "Result: Success - Review completed";
442
460
 
443
- /** The proof phrase that line stands for. */
444
- const COMPLETED_REVIEW_PROOF = "Review completed";
461
+ /**
462
+ * The phrase a structured success line names, or null.
463
+ *
464
+ * Reads `Result: Success - <phrase>` (CodeRabbit's {@link COMPLETED_REVIEW_RESULT}
465
+ * is one instance) with any spacing around the words, by
466
+ * plain string steps rather than a regular expression, so no input can make it
467
+ * backtrack. The same steps are in `check-skipped-required-checks.mjs`;
468
+ * duplicated rather than imported because the two scripts ship from different
469
+ * template trees, and the parity tests hold the two provers to the same
470
+ * answers.
471
+ * @param {string} line - A first summary line.
472
+ * @returns {string|null} The trimmed phrase, or null when the line has another shape.
473
+ */
474
+ function structuredSuccessPhrase(line) {
475
+ if (!line.startsWith("Result:")) return null;
476
+ const outcome = line.slice("Result:".length).trimStart();
477
+ if (!outcome.startsWith("Success")) return null;
478
+ const rest = outcome.slice("Success".length).trimStart();
479
+ if (!rest.startsWith("-")) return null;
480
+ const phrase = rest.slice(1).trim();
481
+ return phrase === "" ? null : phrase;
482
+ }
445
483
 
446
484
  /** What a summary that is present but not text is reported as. */
447
485
  const MALFORMED_SUMMARY = "Malformed check-run summary";
@@ -502,14 +540,14 @@ function readStatusEvidence({ reviewer, statuses }) {
502
540
  return answer(EVIDENCE_READINGS.pending);
503
541
  }
504
542
  if (normalised === "") return answer(EVIDENCE_READINGS.empty);
543
+ // Denial first, as the check-run reading and the TypeScript checker do.
544
+ if (readsAsNoWork(normalised, reviewer.noWork)) {
545
+ return answer(EVIDENCE_READINGS.noWork);
546
+ }
505
547
  if (reviewer.proof.includes(normalised)) {
506
548
  return answer(EVIDENCE_READINGS.reviewed, true);
507
549
  }
508
- return answer(
509
- readsAsNoWork(normalised)
510
- ? EVIDENCE_READINGS.noWork
511
- : EVIDENCE_READINGS.unrecognised
512
- );
550
+ return answer(EVIDENCE_READINGS.unrecognised);
513
551
  }
514
552
 
515
553
  /**
@@ -536,38 +574,50 @@ function looksLikeResult(line) {
536
574
  * 3. A summary that is not text is never read: it stands for no phrase, and
537
575
  * the report carries the value it actually was.
538
576
  * 4. A first summary line that reads as no-work decides next.
539
- * 5. `Result: Success - Review completed`, as the whole first line of a run
540
- * that completed with `success`, stands for the proof phrase
541
- * `Review completed`. This is the ONLY route from a summary to credit.
577
+ * 5. `Result: Success - <phrase>`, as the whole first line of a run that
578
+ * completed with `success`, stands for `<phrase>` when the reviewer
579
+ * declares that phrase as proof. CodeRabbit's
580
+ * {@link COMPLETED_REVIEW_RESULT} is one instance (#4909).
542
581
  * 6. Any other result-shaped first line is authoritative as it stands, so a
543
582
  * failed or unknown result cannot inherit a positive title.
544
- * 7. A plain first line keeps the title, and later lines are never read.
583
+ * 7. A plain first line that is itself a declared proof phrase, on a run
584
+ * that completed with `success`, stands for that phrase, so a reviewer
585
+ * that writes its verdict in the summary rather than the title is read by
586
+ * its own declared words (#4909).
587
+ * 8. Any other plain first line keeps the title, and later lines are never
588
+ * read.
545
589
  *
546
590
  * `text` is what decided, verbatim, for the report; `canonical` is what the
547
591
  * allowlist compares. They differ only in rules 3 and 5.
548
592
  * @param {RawCheckRun} run - One raw check run.
593
+ * @param {{proof: ReadonlyArray<string>, noWork?: ReadonlyArray<string>}} [reviewer] - The reviewer's declared words; Lisa's shipped ones when absent.
549
594
  * @returns {{text: string, canonical: string}} The run's words.
550
595
  */
551
- export function checkRunResult(run) {
596
+ export function checkRunResult(run, reviewer = SHIPPED_REVIEWER_WORDS) {
552
597
  const output = run?.output ?? {};
553
598
  const title = typeof output.title === "string" ? output.title : "";
554
599
  const said = (/** @type {string} */ text) => ({ text, canonical: text });
555
- if (readsAsNoWork(normalizeDescription(title))) return said(title);
600
+ const noWork = reviewer.noWork ?? EVIDENCE_DEFAULTS.no_work;
601
+ const declares = (/** @type {string} */ phrase) =>
602
+ reviewer.proof.includes(normalizeDescription(phrase));
603
+ if (readsAsNoWork(normalizeDescription(title), noWork)) return said(title);
556
604
  const summary = output.summary;
557
605
  if (summary === null || summary === undefined) return said(title);
558
606
  if (typeof summary !== "string") {
559
607
  return { text: JSON.stringify(summary), canonical: MALFORMED_SUMMARY };
560
608
  }
561
609
  const firstLine = summary.split(/\r?\n/u, 1)[0] ?? "";
562
- if (readsAsNoWork(normalizeDescription(firstLine))) return said(firstLine);
563
- if (
564
- run?.status === "completed" &&
565
- run?.conclusion === "success" &&
566
- firstLine === COMPLETED_REVIEW_RESULT
567
- ) {
568
- return { text: firstLine, canonical: COMPLETED_REVIEW_PROOF };
610
+ if (readsAsNoWork(normalizeDescription(firstLine), noWork)) {
611
+ return said(firstLine);
612
+ }
613
+ const succeeded =
614
+ run?.status === "completed" && run?.conclusion === "success";
615
+ const structured = structuredSuccessPhrase(firstLine);
616
+ if (succeeded && structured !== null && declares(structured)) {
617
+ return { text: firstLine, canonical: structured };
569
618
  }
570
619
  if (looksLikeResult(firstLine)) return said(firstLine);
620
+ if (succeeded && declares(firstLine)) return said(firstLine);
571
621
  return said(title);
572
622
  }
573
623
 
@@ -669,7 +719,7 @@ export function selectReviewerCheckRun({ reviewer, runs, sha }) {
669
719
  function readCheckRunEvidence({ reviewer, run }) {
670
720
  const status = typeof run.status === "string" ? run.status : "";
671
721
  const conclusion = typeof run.conclusion === "string" ? run.conclusion : null;
672
- const { text, canonical } = checkRunResult(run);
722
+ const { text, canonical } = checkRunResult(run, reviewer);
673
723
  const settled = status === "completed";
674
724
  const normalised = normalizeDescription(text);
675
725
  let reading = EVIDENCE_READINGS.unrecognised;
@@ -677,13 +727,16 @@ function readCheckRunEvidence({ reviewer, run }) {
677
727
  reading = EVIDENCE_READINGS.pending;
678
728
  } else if (!settled) {
679
729
  reading = EVIDENCE_READINGS.unrecognised;
730
+ } else if (readsAsNoWork(normalised, reviewer.noWork)) {
731
+ // Denial first, as the TypeScript checker reads a description: a
732
+ // project's no-work phrase that overlaps a proof phrase then withholds
733
+ // credit instead of granting it.
734
+ reading = EVIDENCE_READINGS.noWork;
680
735
  } else if (
681
736
  conclusion === "success" &&
682
737
  reviewer.proof.includes(normalizeDescription(canonical))
683
738
  ) {
684
739
  reading = EVIDENCE_READINGS.reviewed;
685
- } else if (readsAsNoWork(normalised)) {
686
- reading = EVIDENCE_READINGS.noWork;
687
740
  } else if (conclusion !== "success") {
688
741
  reading = EVIDENCE_READINGS.unsuccessful;
689
742
  } else if (normalised === "") {
@@ -694,6 +747,9 @@ function readCheckRunEvidence({ reviewer, run }) {
694
747
  reviewed: reading === EVIDENCE_READINGS.reviewed,
695
748
  reading,
696
749
  observed: text,
750
+ // The phrase that decided the run, which the objection check compares:
751
+ // `Result: Success - Changes requested` objects like a bare line does.
752
+ objection: normalizeDescription(canonical),
697
753
  state: settled ? (conclusion ?? status) : status || null,
698
754
  source: EVIDENCE_SOURCES.checkRun,
699
755
  checkRunId: run.id ?? null,
@@ -755,6 +811,86 @@ function pinnedWithoutRun(reviewer, checkRuns) {
755
811
  };
756
812
  }
757
813
 
814
+ /** Review states that mean the reviewer submitted a review it wrote. */
815
+ const SUBMITTED_REVIEW_STATES = new Set([
816
+ "APPROVED",
817
+ "COMMENTED",
818
+ "CHANGES_REQUESTED",
819
+ ]);
820
+
821
+ /**
822
+ * Whether the reviewer said nothing at the head: no status or run at all, or
823
+ * an empty one that passed. Only silence may be replaced by the reviewer's own
824
+ * review; an empty status that failed or errored is a denial.
825
+ * @param {{reading: string, state?: string|null}} reading - The status or run reading.
826
+ * @returns {boolean} Whether a review may stand in.
827
+ */
828
+ function saidNothing(reading) {
829
+ if (reading.reading === EVIDENCE_READINGS.absent) return true;
830
+ return (
831
+ reading.reading === EVIDENCE_READINGS.empty &&
832
+ String(reading.state ?? "").toLowerCase() === "success"
833
+ );
834
+ }
835
+
836
+ /**
837
+ * The reviewer's own submitted pull-request review at this head, if its gate
838
+ * names the account that writes it (`evidence.review_by`, #4909).
839
+ *
840
+ * Some reviewers post no status and no check run: they only submit a review.
841
+ * Without this they read `absent` on every pull request, and every merge then
842
+ * needs a substitute. The review must be on the exact head commit — a review
843
+ * of an earlier commit read different code — and must come from the named
844
+ * account, compared case-insensitively as GitHub compares logins. A
845
+ * `CHANGES_REQUESTED` review proves the reviewer read the code; whether it
846
+ * still blocks the merge is the separate objection check's question.
847
+ * @param {object} options - Reading inputs.
848
+ * @param {ReviewerShape} options.reviewer - One declared reviewer.
849
+ * @param {ReadonlyArray<{commit_id?: string, state?: string, submitted_at?: string, id?: unknown, user?: {login?: string}}>|null|undefined} options.reviews - Review objects on the head's pull requests; null when the read failed.
850
+ * @param {string|undefined} options.sha - The head commit.
851
+ * @returns {Omit<EvidenceReading, "ignoredCheckRuns" | "ignoredStatuses">|null} A reviewed reading, or null when no such review stands.
852
+ */
853
+ function readReviewEvidence({ reviewer, reviews, sha }) {
854
+ if (reviewer.reviewBy === undefined || typeof sha !== "string") return null;
855
+ const login = reviewer.reviewBy.toLowerCase();
856
+ const mine = reviewsAtHead(reviews ?? [], sha)
857
+ .filter(
858
+ review =>
859
+ String(review?.user?.login ?? "").toLowerCase() === login &&
860
+ review?.user?.type === "Bot" &&
861
+ SUBMITTED_REVIEW_STATES.has(String(review?.state ?? "").toUpperCase())
862
+ )
863
+ .sort((left, right) =>
864
+ String(left?.submitted_at ?? "").localeCompare(
865
+ String(right?.submitted_at ?? "")
866
+ )
867
+ );
868
+ const latest = mine.at(-1);
869
+ if (latest === undefined) return null;
870
+ const state = String(latest.state).toUpperCase();
871
+ const body = typeof latest.body === "string" ? latest.body : "";
872
+ const firstLine = body.trim().split(/\r?\n/u, 1)[0] ?? "";
873
+ if (readsAsNoWork(normalizeDescription(firstLine), reviewer.noWork)) {
874
+ // The review itself says the reviewer skipped the code.
875
+ return {
876
+ context: reviewer.context,
877
+ reviewed: false,
878
+ reading: EVIDENCE_READINGS.noWork,
879
+ observed: firstLine,
880
+ state,
881
+ source: EVIDENCE_SOURCES.review,
882
+ };
883
+ }
884
+ return {
885
+ context: reviewer.context,
886
+ reviewed: true,
887
+ reading: EVIDENCE_READINGS.reviewed,
888
+ observed: `${state} review by ${reviewer.reviewBy}`,
889
+ state,
890
+ source: EVIDENCE_SOURCES.review,
891
+ };
892
+ }
893
+
758
894
  /**
759
895
  * Read one reviewer's evidence at one commit, from both representations.
760
896
  *
@@ -773,9 +909,65 @@ function pinnedWithoutRun(reviewer, checkRuns) {
773
909
  * `.statuses` from `repos/{owner}/{repo}/commits/{sha}/status`, newest first; null when the read failed.
774
910
  * @param {ReadonlyArray<RawCheckRun>|null} [options.checkRuns] - Runs read for the reviewer's name; null when the read failed, absent when none were read.
775
911
  * @param {string} [options.sha] - The head commit, which every check run must report on.
912
+ * @param {ReadonlyArray<object>|null} [options.reviews] - Review objects on the head's pull requests, read only for a reviewer whose gate names `evidence.review_by`; null when the read failed.
776
913
  * @returns {EvidenceReading} The reading.
777
914
  */
778
- export function readReviewerEvidence({ reviewer, statuses, checkRuns, sha }) {
915
+ export function readReviewerEvidence({
916
+ reviewer,
917
+ statuses,
918
+ checkRuns,
919
+ sha,
920
+ reviews,
921
+ }) {
922
+ const reading = readStatusOrRunEvidence({
923
+ reviewer,
924
+ statuses,
925
+ checkRuns,
926
+ sha,
927
+ });
928
+ if (reading.reviewed || reviewer.reviewBy === undefined) return reading;
929
+ // A review stands in only where the reviewer said nothing at the head. A
930
+ // status or run that said "no work", failed, or said anything else is a
931
+ // denial, and a review from the same account never overrides a denial.
932
+ if (!saidNothing(reading)) return reading;
933
+ // An empty passed run can hide a denial in the same reviewer's status, and
934
+ // an unread run or status list can hide one too. Only silence on both
935
+ // surfaces, both read, may be replaced by a review.
936
+ if (checkRuns === null || statuses === null) return reading;
937
+ if (
938
+ !saidNothing(readStatusEvidence({ reviewer, statuses: statuses ?? [] }))
939
+ ) {
940
+ return reading;
941
+ }
942
+ // posted_by accepts only that app's check run; a review carries no app id,
943
+ // so a pinned gate never takes the review route (validateGates also
944
+ // refuses the pair, but the config is not validated at run time).
945
+ if (reviewer.postedBy !== undefined) return reading;
946
+ const fromReview = readReviewEvidence({ reviewer, reviews, sha });
947
+ if (fromReview !== null) {
948
+ return {
949
+ ...fromReview,
950
+ ignoredCheckRuns: reading.ignoredCheckRuns,
951
+ ignoredStatuses: reading.ignoredStatuses,
952
+ };
953
+ }
954
+ // A review read that failed could have held the evidence, so an absence
955
+ // is not proven; say the read failed instead.
956
+ return reviews === null && reading.reading === EVIDENCE_READINGS.absent
957
+ ? { ...reading, reading: EVIDENCE_READINGS.unreadable }
958
+ : reading;
959
+ }
960
+
961
+ /**
962
+ * Read one reviewer's evidence from its statuses and check runs alone.
963
+ * @param {object} options - Reading inputs, as {@link readReviewerEvidence} takes them.
964
+ * @param {ReviewerShape} options.reviewer - One declared reviewer.
965
+ * @param {ReadonlyArray<{context?: string, state?: string, description?: string}>|null} [options.statuses] - Statuses on the commit; null when the read failed.
966
+ * @param {ReadonlyArray<RawCheckRun>|null} [options.checkRuns] - Runs read for the reviewer's name; null when the read failed.
967
+ * @param {string} [options.sha] - The head commit.
968
+ * @returns {EvidenceReading} The reading.
969
+ */
970
+ function readStatusOrRunEvidence({ reviewer, statuses, checkRuns, sha }) {
779
971
  const { run, ignored } = selectReviewerCheckRun({
780
972
  reviewer,
781
973
  runs: checkRuns,
@@ -1034,13 +1226,14 @@ export function reviewStanding({ reviews, sha }) {
1034
1226
  * this project declared no third-party reviewer, which is a legitimate state
1035
1227
  * that must be SAID rather than passed through in silence.
1036
1228
  * @param {object} options - Decision inputs.
1037
- * @param {Array<{gateId: string, context: string, proof: string[], postedBy?: unknown}>} options.reviewers - Declared reviewers.
1229
+ * @param {Array<{gateId: string, context: string, proof: string[], postedBy?: unknown, reviewBy?: string}>} options.reviewers - Declared reviewers.
1038
1230
  * @param {ReadonlyArray<object>|null} options.statuses - Statuses on the head commit; null when the read failed.
1039
1231
  * @param {Record<string, ReadonlyArray<RawCheckRun>|null>} [options.checkRuns] -
1040
1232
  * Check runs read for each reviewer's context, keyed by that context; a null
1041
1233
  * entry is a read that failed, and a missing key is a reviewer whose runs
1042
1234
  * were not read.
1043
1235
  * @param {ReadonlyArray<{body?: string, user?: {login?: string}}>|null} options.comments - Issue comments on the pull request; null when they could not all be read, which counts no substitute.
1236
+ * @param {ReadonlyArray<object>|null} [options.reviews] - Review objects on the pull request, for reviewers whose gate names `evidence.review_by`; null when the read failed.
1044
1237
  * @param {string} options.sha - The head commit.
1045
1238
  * @param {boolean|null} [options.isPullRequestHead] - Whether an open pull request has this commit as its head; null when the read failed.
1046
1239
  * @param {(login: string) => boolean|null} [options.canWrite] -
@@ -1053,6 +1246,7 @@ export function reviewEvidenceVerdict({
1053
1246
  statuses,
1054
1247
  checkRuns,
1055
1248
  comments,
1249
+ reviews = [],
1056
1250
  sha,
1057
1251
  isPullRequestHead = true,
1058
1252
  canWrite = UNREAD_PERMISSIONS,
@@ -1088,6 +1282,7 @@ export function reviewEvidenceVerdict({
1088
1282
  ? checkRuns[reviewer.context]
1089
1283
  : undefined,
1090
1284
  sha,
1285
+ reviews,
1091
1286
  });
1092
1287
  if (reading.reviewed) {
1093
1288
  return { ...reading, gateId: reviewer.gateId, substituted: false };
@@ -1229,7 +1424,9 @@ function evidenceSignal(evidence, substitutes) {
1229
1424
  // not cancelled by another reviewer's substitute.
1230
1425
  if (
1231
1426
  readings.some(
1232
- reading => normalizeDescription(reading.observed) === OBJECTING_PROOF
1427
+ reading =>
1428
+ (reading.objection ?? normalizeDescription(reading.observed)) ===
1429
+ OBJECTING_PROOF
1233
1430
  )
1234
1431
  ) {
1235
1432
  return engagedSignal(
@@ -2589,6 +2786,14 @@ export function main(argv, io = {}) {
2589
2786
  pulls ?? []
2590
2787
  )
2591
2788
  : [],
2789
+ // Read only when some reviewer is proven by its review, so a project
2790
+ // whose reviewers all report through statuses spends no extra call.
2791
+ reviews:
2792
+ evaluated && reviewers.some(reviewer => reviewer.reviewBy)
2793
+ ? (io.reviews ?? (numbers => readReviews(repo, numbers)))(
2794
+ pulls ?? []
2795
+ )
2796
+ : [],
2592
2797
  sha: opts.sha,
2593
2798
  isPullRequestHead,
2594
2799
  canWrite,
@@ -4267,6 +4267,7 @@ function validateMoment(id, moment, value, known, interceptor, gateRun) {
4267
4267
  );
4268
4268
  }
4269
4269
  problems.push(...validateEvidence(id, moment, entry.evidence ?? {}));
4270
+ problems.push(...validateReviewByPin(id, moment, entry));
4270
4271
  } else if (entry.evidence !== undefined) {
4271
4272
  // Evidence describes what an AWAITED signal's description proves. Declared
4272
4273
  // without an `await`, there is no signal and no description, so the block
@@ -4436,10 +4437,21 @@ function validateEvidence(id, moment, evidence) {
4436
4437
  }
4437
4438
  }
4438
4439
  for (const field of ["proof", "no_work"]) {
4439
- if (evidence[field] !== undefined && !Array.isArray(evidence[field])) {
4440
+ if (evidence[field] === undefined) continue;
4441
+ if (!Array.isArray(evidence[field])) {
4440
4442
  problems.push(`${where}.${field} must be an array of phrases`);
4443
+ } else if (
4444
+ evidence[field].some(
4445
+ phrase => typeof phrase !== "string" || phrase.trim() === ""
4446
+ )
4447
+ ) {
4448
+ problems.push(
4449
+ `${where}.${field} must hold only non-empty phrases. An empty ` +
4450
+ `no-work phrase matches every description.`
4451
+ );
4441
4452
  }
4442
4453
  }
4454
+ problems.push(...validatePhraseOverlap(where, evidence));
4443
4455
  problems.push(...validateReviewerFlag(where, evidence));
4444
4456
  return problems;
4445
4457
  }
@@ -4460,7 +4472,8 @@ function validateEvidence(id, moment, evidence) {
4460
4472
  * @returns {string[]} Problems.
4461
4473
  */
4462
4474
  function validateReviewerFlag(where, evidence) {
4463
- if (evidence.reviewer === undefined) return [];
4475
+ // review_by without reviewer: true is read by nothing; say so (#4916).
4476
+ if (evidence.reviewer === undefined) return validateReviewBy(where, evidence);
4464
4477
  if (typeof evidence.reviewer !== "boolean") {
4465
4478
  return [
4466
4479
  `${where}.reviewer is ${JSON.stringify(evidence.reviewer)}; expected ` +
@@ -4468,8 +4481,13 @@ function validateReviewerFlag(where, evidence) {
4468
4481
  `third-party code review, so any other value silently declares nothing.`,
4469
4482
  ];
4470
4483
  }
4484
+ const reviewBy = validateReviewBy(where, evidence);
4485
+ if (reviewBy.length > 0) return reviewBy;
4471
4486
  if (evidence.reviewer !== true) return [];
4472
4487
  if (Array.isArray(evidence.proof) && evidence.proof.length > 0) return [];
4488
+ // A reviewer proven by its own submitted review states its evidence by
4489
+ // naming the account, so it needs no status phrase (#4909).
4490
+ if (typeof evidence.review_by === "string") return [];
4473
4491
  return [
4474
4492
  `${where}.reviewer is true but no ${where}.proof phrase is declared. The ` +
4475
4493
  `reviewed-when phrase is an ALLOWLIST — only a description that matches ` +
@@ -4479,6 +4497,98 @@ function validateReviewerFlag(where, evidence) {
4479
4497
  ];
4480
4498
  }
4481
4499
 
4500
+ /**
4501
+ * Refuse a no-work phrase that a proof phrase contains (#4909).
4502
+ *
4503
+ * A description is denied when it CONTAINS a no-work phrase and credited when
4504
+ * it EQUALS a proof phrase, so a proof phrase holding a no-work phrase can
4505
+ * never be credited, and a project that wrote both meant something it will
4506
+ * not get. Shipped phrases count on both sides, since both lists are merged.
4507
+ * @param {string} where - The declaration path, for the message.
4508
+ * @param {object} evidence - The evidence block.
4509
+ * @returns {string[]} Problems.
4510
+ */
4511
+ function validatePhraseOverlap(where, evidence) {
4512
+ const phrases = (/** @type {unknown} */ list) =>
4513
+ (Array.isArray(list) ? list : [])
4514
+ .filter(phrase => typeof phrase === "string" && phrase.trim() !== "")
4515
+ .map(phrase => phrase.trim().replace(/\s+/gu, " ").toLowerCase());
4516
+ const proof = [...EVIDENCE_DEFAULTS.proof, ...phrases(evidence.proof)];
4517
+ const noWork = [...EVIDENCE_DEFAULTS.no_work, ...phrases(evidence.no_work)];
4518
+ const clashes = proof.flatMap(reviewed =>
4519
+ noWork
4520
+ .filter(denied => reviewed.includes(denied))
4521
+ .map(denied => `"${reviewed}" contains "${denied}"`)
4522
+ );
4523
+ if (clashes.length === 0) return [];
4524
+ return [
4525
+ `${where}: a proof phrase contains a no_work phrase (${clashes.join(", ")}). ` +
4526
+ `A description holding a no-work phrase is always read as no work, so ` +
4527
+ `that proof phrase could never count.`,
4528
+ ];
4529
+ }
4530
+
4531
+ /**
4532
+ * Refuse `review_by` alongside `posted_by` (#4909).
4533
+ *
4534
+ * `posted_by` says only that app's check run speaks for the reviewer. A review
4535
+ * route would accept a submitted review instead, which carries no app id, so
4536
+ * the two together would quietly widen the pin.
4537
+ * @param {string} id - Gate id.
4538
+ * @param {string} moment - Moment key.
4539
+ * @param {object} entry - The moment's declaration.
4540
+ * @returns {string[]} Problems.
4541
+ */
4542
+ function validateReviewByPin(id, moment, entry) {
4543
+ if (entry?.evidence?.review_by === undefined) return [];
4544
+ if (entry.posted_by === undefined) return [];
4545
+ return [
4546
+ `gates.${id}.${moment}: evidence.review_by and posted_by cannot both be ` +
4547
+ `set. posted_by accepts only that app's check run, and a review carries ` +
4548
+ `no app id, so declaring both would weaken the pin.`,
4549
+ ];
4550
+ }
4551
+
4552
+ /**
4553
+ * Validate `evidence.review_by`, the account whose submitted pull-request
4554
+ * review at the head is the reviewer's evidence (#4909).
4555
+ *
4556
+ * It must be a non-empty login, and it means something only on a third-party
4557
+ * reviewer: on any other awaited signal nothing reads it, and a key that looks
4558
+ * obeyed and is not is refused rather than ignored.
4559
+ * @param {string} where - The declaration path, for the message.
4560
+ * @param {object} evidence - The evidence block.
4561
+ * @returns {string[]} Problems.
4562
+ */
4563
+ function validateReviewBy(where, evidence) {
4564
+ if (evidence.review_by === undefined) return [];
4565
+ if (
4566
+ typeof evidence.review_by !== "string" ||
4567
+ evidence.review_by.trim() === ""
4568
+ ) {
4569
+ return [
4570
+ `${where}.review_by is ${JSON.stringify(evidence.review_by)}; expected ` +
4571
+ `the reviewer's GitHub login, such as "greptile-apps[bot]".`,
4572
+ ];
4573
+ }
4574
+ if (!evidence.review_by.trim().endsWith("[bot]")) {
4575
+ return [
4576
+ `${where}.review_by is ${JSON.stringify(evidence.review_by)}; expected ` +
4577
+ `a GitHub App's bot login ending in "[bot]", such as ` +
4578
+ `"greptile-apps[bot]". A plain account name could be any user, and ` +
4579
+ `anyone can submit a review on a public repository.`,
4580
+ ];
4581
+ }
4582
+ if (evidence.reviewer !== true) {
4583
+ return [
4584
+ `${where}.review_by is set but ${where}.reviewer is not true. Only a ` +
4585
+ `third-party code reviewer is proven by its own review, so nothing ` +
4586
+ `would read this key.`,
4587
+ ];
4588
+ }
4589
+ return [];
4590
+ }
4591
+
4482
4592
  /**
4483
4593
  * Validate a gate's declared needs.
4484
4594
  * @param {string} id Gate id.
@@ -1505,7 +1505,7 @@
1505
1505
  "children": []
1506
1506
  },
1507
1507
  "lisa-gates.mjs": {
1508
- "sha256": "95156e0e0b998ed9b444af97911accbe7764f6b4611376bad24539295fb9633d",
1508
+ "sha256": "9186dd6047a6e2fc45cad907f0b770f7845122f08e3b3513cf04c5a69bd9a9c9",
1509
1509
  "staticImports": [
1510
1510
  "lib/gate-pass-cache.mjs",
1511
1511
  "lib/invoked-as-script.mjs",
@@ -1 +1 @@
1
- {"version":3,"file":"lisa-owned-hash-ledger.d.ts","sourceRoot":"","sources":["../../src/core/lisa-owned-hash-ledger.ts"],"names":[],"mappings":"AACA,6EAA6E;AAE7E;;;;;;;GAOG;AACH,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAC3C,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAu3FjC,CAAC;AAEH;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,+BAA+B,EAAE,QAAQ,CACpD,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CA0xFjC,CAAC"}
1
+ {"version":3,"file":"lisa-owned-hash-ledger.d.ts","sourceRoot":"","sources":["../../src/core/lisa-owned-hash-ledger.ts"],"names":[],"mappings":"AACA,6EAA6E;AAE7E;;;;;;;GAOG;AACH,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAC3C,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAw4FjC,CAAC;AAEH;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,+BAA+B,EAAE,QAAQ,CACpD,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CA2yFjC,CAAC"}