@codyswann/lisa 4.99.2 → 4.99.3

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 (86) hide show
  1. package/all/copy-overwrite/scripts/check-third-party-review-evidence.mjs +236 -73
  2. package/dist/core/lisa-owned-hash-ledger.d.ts.map +1 -1
  3. package/dist/core/lisa-owned-hash-ledger.js +4 -0
  4. package/dist/core/lisa-owned-hash-ledger.js.map +1 -1
  5. package/dist/core/nightly-e2e-guard-behavior-certificate.js +2 -2
  6. package/dist/core/upstream-evidence-manifest.d.ts.map +1 -1
  7. package/dist/core/upstream-evidence-manifest.js +5 -2
  8. package/dist/core/upstream-evidence-manifest.js.map +1 -1
  9. package/package.json +4 -4
  10. package/plugins/lisa/.claude-plugin/plugin.json +1 -1
  11. package/plugins/lisa/.codex-plugin/plugin.json +1 -1
  12. package/plugins/lisa/.codex-plugin/skills/lisa-drive-pr-to-merge/SKILL.md +11 -4
  13. package/plugins/lisa/skills/lisa-drive-pr-to-merge/SKILL.md +11 -4
  14. package/plugins/lisa-agy/plugin.json +1 -1
  15. package/plugins/lisa-agy/skills/lisa-drive-pr-to-merge/SKILL.md +11 -4
  16. package/plugins/lisa-cdk/.claude-plugin/plugin.json +1 -1
  17. package/plugins/lisa-cdk/.codex-plugin/plugin.json +1 -1
  18. package/plugins/lisa-cdk-agy/plugin.json +1 -1
  19. package/plugins/lisa-cdk-copilot/.claude-plugin/plugin.json +1 -1
  20. package/plugins/lisa-cdk-cursor/.claude-plugin/plugin.json +1 -1
  21. package/plugins/lisa-cdk-devin/.claude-plugin/plugin.json +1 -1
  22. package/plugins/lisa-cdk-devin/.devin-plugin/plugin.json +1 -1
  23. package/plugins/lisa-copilot/.claude-plugin/plugin.json +1 -1
  24. package/plugins/lisa-copilot/skills/lisa-drive-pr-to-merge/SKILL.md +11 -4
  25. package/plugins/lisa-cursor/.claude-plugin/plugin.json +1 -1
  26. package/plugins/lisa-cursor/skills/lisa-drive-pr-to-merge/SKILL.md +11 -4
  27. package/plugins/lisa-devin/.claude-plugin/plugin.json +1 -1
  28. package/plugins/lisa-devin/.devin-plugin/plugin.json +1 -1
  29. package/plugins/lisa-devin/skills/lisa-drive-pr-to-merge/SKILL.md +11 -4
  30. package/plugins/lisa-expo/.claude-plugin/plugin.json +1 -1
  31. package/plugins/lisa-expo/.codex-plugin/plugin.json +1 -1
  32. package/plugins/lisa-expo-agy/plugin.json +1 -1
  33. package/plugins/lisa-expo-copilot/.claude-plugin/plugin.json +1 -1
  34. package/plugins/lisa-expo-cursor/.claude-plugin/plugin.json +1 -1
  35. package/plugins/lisa-expo-devin/.claude-plugin/plugin.json +1 -1
  36. package/plugins/lisa-expo-devin/.devin-plugin/plugin.json +1 -1
  37. package/plugins/lisa-harper-fabric/.claude-plugin/plugin.json +1 -1
  38. package/plugins/lisa-harper-fabric/.codex-plugin/plugin.json +1 -1
  39. package/plugins/lisa-harper-fabric-agy/plugin.json +1 -1
  40. package/plugins/lisa-harper-fabric-copilot/.claude-plugin/plugin.json +1 -1
  41. package/plugins/lisa-harper-fabric-cursor/.claude-plugin/plugin.json +1 -1
  42. package/plugins/lisa-harper-fabric-devin/.claude-plugin/plugin.json +1 -1
  43. package/plugins/lisa-harper-fabric-devin/.devin-plugin/plugin.json +1 -1
  44. package/plugins/lisa-nestjs/.claude-plugin/plugin.json +1 -1
  45. package/plugins/lisa-nestjs/.codex-plugin/plugin.json +1 -1
  46. package/plugins/lisa-nestjs-agy/plugin.json +1 -1
  47. package/plugins/lisa-nestjs-copilot/.claude-plugin/plugin.json +1 -1
  48. package/plugins/lisa-nestjs-cursor/.claude-plugin/plugin.json +1 -1
  49. package/plugins/lisa-nestjs-devin/.claude-plugin/plugin.json +1 -1
  50. package/plugins/lisa-nestjs-devin/.devin-plugin/plugin.json +1 -1
  51. package/plugins/lisa-openclaw/.claude-plugin/plugin.json +1 -1
  52. package/plugins/lisa-openclaw/.codex-plugin/plugin.json +1 -1
  53. package/plugins/lisa-openclaw-agy/plugin.json +1 -1
  54. package/plugins/lisa-openclaw-copilot/.claude-plugin/plugin.json +1 -1
  55. package/plugins/lisa-openclaw-cursor/.claude-plugin/plugin.json +1 -1
  56. package/plugins/lisa-openclaw-devin/.claude-plugin/plugin.json +1 -1
  57. package/plugins/lisa-openclaw-devin/.devin-plugin/plugin.json +1 -1
  58. package/plugins/lisa-phaser/.claude-plugin/plugin.json +1 -1
  59. package/plugins/lisa-phaser/.codex-plugin/plugin.json +1 -1
  60. package/plugins/lisa-phaser-agy/plugin.json +1 -1
  61. package/plugins/lisa-phaser-copilot/.claude-plugin/plugin.json +1 -1
  62. package/plugins/lisa-phaser-cursor/.claude-plugin/plugin.json +1 -1
  63. package/plugins/lisa-phaser-devin/.claude-plugin/plugin.json +1 -1
  64. package/plugins/lisa-phaser-devin/.devin-plugin/plugin.json +1 -1
  65. package/plugins/lisa-rails/.claude-plugin/plugin.json +1 -1
  66. package/plugins/lisa-rails/.codex-plugin/plugin.json +1 -1
  67. package/plugins/lisa-rails-agy/plugin.json +1 -1
  68. package/plugins/lisa-rails-copilot/.claude-plugin/plugin.json +1 -1
  69. package/plugins/lisa-rails-cursor/.claude-plugin/plugin.json +1 -1
  70. package/plugins/lisa-rails-devin/.claude-plugin/plugin.json +1 -1
  71. package/plugins/lisa-rails-devin/.devin-plugin/plugin.json +1 -1
  72. package/plugins/lisa-typescript/.claude-plugin/plugin.json +1 -1
  73. package/plugins/lisa-typescript/.codex-plugin/plugin.json +1 -1
  74. package/plugins/lisa-typescript-agy/plugin.json +1 -1
  75. package/plugins/lisa-typescript-copilot/.claude-plugin/plugin.json +1 -1
  76. package/plugins/lisa-typescript-cursor/.claude-plugin/plugin.json +1 -1
  77. package/plugins/lisa-typescript-devin/.claude-plugin/plugin.json +1 -1
  78. package/plugins/lisa-typescript-devin/.devin-plugin/plugin.json +1 -1
  79. package/plugins/lisa-wiki/.claude-plugin/plugin.json +1 -1
  80. package/plugins/lisa-wiki/.codex-plugin/plugin.json +1 -1
  81. package/plugins/lisa-wiki-agy/plugin.json +1 -1
  82. package/plugins/lisa-wiki-copilot/.claude-plugin/plugin.json +1 -1
  83. package/plugins/lisa-wiki-cursor/.claude-plugin/plugin.json +1 -1
  84. package/plugins/lisa-wiki-devin/.claude-plugin/plugin.json +1 -1
  85. package/plugins/lisa-wiki-devin/.devin-plugin/plugin.json +1 -1
  86. package/plugins/src/base/skills/lisa-drive-pr-to-merge/SKILL.md +11 -4
@@ -106,6 +106,15 @@
106
106
  * `CHANGES_REQUESTED` is a blocking objection whatever its body, because its
107
107
  * content commonly lives entirely in inline threads.
108
108
  *
109
+ * ## Only a writer can stand in for a reviewer (#4628)
110
+ *
111
+ * The substitute marker is plain text, and anyone who can comment can type
112
+ * it. A substitute counts only when the marker is the comment's first line and
113
+ * its author holds write, maintain or admin permission — the merge-path gate's
114
+ * rule, so the two arms never publish opposite verdicts for one head. A
115
+ * permission that cannot be read fails closed. Every marker that is not
116
+ * counted is printed with its author and the reason, never dropped silently.
117
+ *
109
118
  * ## Never re-request a review to refresh it
110
119
  *
111
120
  * Re-requesting OVERWRITES the existing status rather than adding to it. Under
@@ -681,22 +690,147 @@ export function substituteMarker({ context, sha }) {
681
690
  }
682
691
 
683
692
  /**
684
- * Whether a substitute review was posted for this reviewer at this commit.
693
+ * Why a comment carrying this reviewer's marker at this head was not counted.
694
+ *
695
+ * Each one is printed beside the comment's author, so a refused marker is
696
+ * never silent: an operator who posted one learns why it did not stand, and a
697
+ * stranger's marker is visible as exactly that (#4628).
698
+ */
699
+ export const SUBSTITUTE_REFUSALS = Object.freeze({
700
+ /** The marker appears in the comment, but not as its whole first line. */
701
+ notFirstLine: "not the first line",
702
+ /** The author's permission was read, and it is not write, maintain or admin. */
703
+ noWriteAccess: "no write access",
704
+ /** The author's permission could not be read, so it fails closed. */
705
+ permissionUnreadable: "permission unreadable",
706
+ });
707
+
708
+ /**
709
+ * One permission answer per login for the life of the reader.
685
710
  *
686
- * Both halves must match. A substitute posted for a different reviewer says
687
- * nothing about this one, and one posted against an earlier head reviewed code
688
- * that is no longer what would merge — review evidence decays on every push.
711
+ * The reader answers `true` for a writer, `false` for anyone else, and `null`
712
+ * — or throws — when the permission could not be read. Anything that is not a
713
+ * boolean is unreadable, which can only leave a substitute uncounted.
714
+ * @param {(login: string) => boolean|null} canWrite - The permission reader.
715
+ * @returns {(login: string) => boolean|null} The same answers, each read once.
716
+ */
717
+ function rememberPermissions(canWrite) {
718
+ const seen = new Map();
719
+ return login => {
720
+ if (!seen.has(login)) seen.set(login, askPermission(canWrite, login));
721
+ return seen.get(login);
722
+ };
723
+ }
724
+
725
+ /**
726
+ * Ask a permission reader once, failing closed.
727
+ *
728
+ * A bot login (`…[bot]`) is answered `false` without asking: a bot is never a
729
+ * repository collaborator, so the answer is known, and reading it would only
730
+ * turn a certain "no write access" into a noisy "permission unreadable". The
731
+ * merge-path gate refuses the same author.
732
+ * @param {(login: string) => boolean|null} canWrite - The permission reader.
733
+ * @param {string} login - The comment author.
734
+ * @returns {boolean|null} The answer, or null when it could not be read.
735
+ */
736
+ function askPermission(canWrite, login) {
737
+ if (login.endsWith("[bot]")) return false;
738
+ // probe-direction: fail-closed — a reader that throws or answers anything but a boolean is unreadable.
739
+ try {
740
+ const answer = canWrite(login);
741
+ return typeof answer === "boolean" ? answer : null;
742
+ } catch {
743
+ return null;
744
+ }
745
+ }
746
+
747
+ /** A permission reader that can read nothing: every marker stays uncounted. */
748
+ const UNREAD_PERMISSIONS = () => null;
749
+
750
+ /**
751
+ * Why one comment carrying the marker does not count, or null when it does.
752
+ * @param {string} body - The comment body, which contains the marker.
753
+ * @param {string} marker - The marker for this reviewer at this head.
754
+ * @param {() => boolean|null} isWriter - The author's permission, read on demand.
755
+ * @returns {string|null} One of {@link SUBSTITUTE_REFUSALS}, or null.
756
+ */
757
+ function substituteRefusal(body, marker, isWriter) {
758
+ if (body.split("\n")[0].replace(/\r$/u, "") !== marker) {
759
+ return SUBSTITUTE_REFUSALS.notFirstLine;
760
+ }
761
+ const writer = isWriter();
762
+ if (writer === null) return SUBSTITUTE_REFUSALS.permissionUnreadable;
763
+ return writer ? null : SUBSTITUTE_REFUSALS.noWriteAccess;
764
+ }
765
+
766
+ /**
767
+ * Judge every comment that carries this reviewer's marker at this commit.
768
+ *
769
+ * The merge-path gate's rule (`check-skipped-required-checks.mjs`
770
+ * `substitutesAtHead`), applied here so the two arms stop publishing opposite
771
+ * verdicts for one head (#4528, #4628). The repository is public, so anyone
772
+ * can type the marker:
773
+ *
774
+ * - the marker must be the comment's FIRST LINE, ignoring a trailing `\r` —
775
+ * a comment that quotes it, such as instructions or a pasted log, is not a
776
+ * review;
777
+ * - the author must hold write, maintain or admin permission — only someone
778
+ * who could have merged anyway can vouch for a review. A login the
779
+ * permission reader rejects, and a bot, which is no collaborator, never
780
+ * count;
781
+ * - a permission that cannot be read fails closed.
782
+ *
783
+ * Both halves of the marker must match as well. A substitute posted for a
784
+ * different reviewer says nothing about this one, and one posted against an
785
+ * earlier head reviewed code that is no longer what would merge — review
786
+ * evidence decays on every push. A comment that carries neither this
787
+ * reviewer's nor this head's marker is not a candidate, so it is not refused.
788
+ *
789
+ * The rule is duplicated rather than imported, as the gate's marker is: the
790
+ * two scripts ship from different template trees. A parity test feeds both the
791
+ * same comments and expects the same decisions.
689
792
  * @param {object} options - Search inputs.
690
- * @param {ReadonlyArray<{body?: string}>} options.comments - Issue comments on the pull request.
793
+ * @param {ReadonlyArray<{body?: string, user?: {login?: string}}>} options.comments - Issue comments on the pull request.
691
794
  * @param {string} options.context - The reviewer's status context.
692
795
  * @param {string} options.sha - The head commit.
693
- * @returns {boolean} Whether a matching substitute exists.
796
+ * @param {(login: string) => boolean|null} [options.canWrite] - Whether a login holds write access; null when unreadable. Absent reads nothing, so nothing counts.
797
+ * @returns {{counted: boolean, refused: Array<{author: string, reason: string}>}} Whether a writer's substitute stands, and every marker that does not.
694
798
  */
695
- export function substitutePosted({ comments, context, sha }) {
799
+ export function judgeSubstitutes({
800
+ comments,
801
+ context,
802
+ sha,
803
+ canWrite = UNREAD_PERMISSIONS,
804
+ }) {
696
805
  const marker = substituteMarker({ context, sha });
697
- return (comments ?? []).some(comment =>
698
- String(comment?.body ?? "").includes(marker)
699
- );
806
+ const permission = rememberPermissions(canWrite);
807
+ const judged = (comments ?? [])
808
+ .map(comment => ({
809
+ body: String(comment?.body ?? ""),
810
+ author: String(comment?.user?.login ?? ""),
811
+ }))
812
+ .filter(({ body }) => body.includes(marker))
813
+ .map(({ body, author }) => ({
814
+ author,
815
+ reason: substituteRefusal(body, marker, () => permission(author)),
816
+ }));
817
+ return {
818
+ counted: judged.some(entry => entry.reason === null),
819
+ refused: judged.filter(entry => entry.reason !== null),
820
+ };
821
+ }
822
+
823
+ /**
824
+ * Whether a writer posted a substitute review for this reviewer at this commit.
825
+ * @param {object} options - Search inputs, as {@link judgeSubstitutes} takes them.
826
+ * @param {ReadonlyArray<{body?: string, user?: {login?: string}}>} options.comments - Issue comments on the pull request.
827
+ * @param {string} options.context - The reviewer's status context.
828
+ * @param {string} options.sha - The head commit.
829
+ * @param {(login: string) => boolean|null} [options.canWrite] - Whether a login holds write access.
830
+ * @returns {boolean} Whether a writer's first-line substitute exists.
831
+ */
832
+ export function substitutePosted(options) {
833
+ return judgeSubstitutes(options).counted;
700
834
  }
701
835
 
702
836
  /**
@@ -784,10 +918,13 @@ export function reviewStanding({ reviews, sha }) {
784
918
  * Check runs read for each reviewer's context, keyed by that context; a null
785
919
  * entry is a read that failed, and a missing key is a reviewer whose runs
786
920
  * were not read.
787
- * @param {ReadonlyArray<{body?: string}>} options.comments - Issue comments on the pull request.
921
+ * @param {ReadonlyArray<{body?: string, user?: {login?: string}}>} options.comments - Issue comments on the pull request.
788
922
  * @param {string} options.sha - The head commit.
789
923
  * @param {boolean|null} [options.isPullRequestHead] - Whether an open pull request has this commit as its head; null when the read failed.
790
- * @returns {{outcome: string, sha: string, readings: Array<EvidenceReading & {gateId: string, substituted: boolean}>}} The verdict.
924
+ * @param {(login: string) => boolean|null} [options.canWrite] -
925
+ * Whether a comment author holds write access; null when unreadable. Absent
926
+ * reads nothing, so no substitute counts — see {@link judgeSubstitutes}.
927
+ * @returns {{outcome: string, sha: string, readings: Array<EvidenceReading & {gateId: string, substituted: boolean, substituteRefusals?: Array<{author: string, reason: string}>}>}} The verdict.
791
928
  */
792
929
  export function reviewEvidenceVerdict({
793
930
  reviewers,
@@ -796,6 +933,7 @@ export function reviewEvidenceVerdict({
796
933
  comments,
797
934
  sha,
798
935
  isPullRequestHead = true,
936
+ canWrite = UNREAD_PERMISSIONS,
799
937
  }) {
800
938
  if ((reviewers ?? []).length === 0) {
801
939
  return {
@@ -818,6 +956,7 @@ export function reviewEvidenceVerdict({
818
956
  readings: [],
819
957
  };
820
958
  }
959
+ const permission = rememberPermissions(canWrite);
821
960
  const readings = reviewers.map(reviewer => {
822
961
  const reading = readReviewerEvidence({
823
962
  reviewer,
@@ -828,12 +967,20 @@ export function reviewEvidenceVerdict({
828
967
  : undefined,
829
968
  sha,
830
969
  });
970
+ if (reading.reviewed) {
971
+ return { ...reading, gateId: reviewer.gateId, substituted: false };
972
+ }
973
+ const judged = judgeSubstitutes({
974
+ comments,
975
+ context: reviewer.context,
976
+ sha,
977
+ canWrite: permission,
978
+ });
831
979
  return {
832
980
  ...reading,
833
981
  gateId: reviewer.gateId,
834
- substituted:
835
- !reading.reviewed &&
836
- substitutePosted({ comments, context: reviewer.context, sha }),
982
+ substituted: judged.counted,
983
+ substituteRefusals: judged.refused,
837
984
  };
838
985
  });
839
986
  if (readings.every(reading => reading.reviewed)) {
@@ -928,12 +1075,13 @@ const allSubstituted = (contexts, substitutes) =>
928
1075
  /**
929
1076
  * What the config-declared reviewer says about arming.
930
1077
  *
931
- * The prover's own `substituted` outcome counts a marker ANYWHERE in ANY
932
- * comment, which is right for the response arm and wrong here: arming turns a
933
- * blocking verdict into a merge, so a substitute counts only as the first line
934
- * of a comment by someone with write access — the classifier's rule, for the
935
- * same reason. A `Changes requested` proof proves the reviewer worked, not that
936
- * the head may merge.
1078
+ * A substitute counts here only as the first line of a comment by someone with
1079
+ * write access — the classifier's rule, for the same reason: arming turns a
1080
+ * blocking verdict into a merge. The response arm's own `substituted` outcome
1081
+ * applies the same rule, over every page of comments, since #4628; the arm
1082
+ * still reads the substitutes itself because it answers for every context at
1083
+ * once. A `Changes requested` proof proves the reviewer worked, not that the
1084
+ * head may merge.
937
1085
  * @param {{outcome: string, readings?: ReadonlyArray<{context: string, reviewed: boolean, observed?: string|null}>}} evidence - This prover's verdict.
938
1086
  * @param {ReadonlySet<string>} substitutes - Contexts a writer substituted for at this head.
939
1087
  * @returns {{engaged: boolean, action: string, reason: string, viaSubstitute?: boolean}} The signal.
@@ -1259,7 +1407,8 @@ export function armDecision({
1259
1407
  * @property {string|null} observed - The words that decided, verbatim.
1260
1408
  * @property {string|null} state - The state, conclusion or lifecycle seen.
1261
1409
  * @property {string|null} [source] - One of {@link EVIDENCE_SOURCES}.
1262
- * @property {boolean} [substituted] - Whether a substitute stands in.
1410
+ * @property {boolean} [substituted] - Whether a writer's substitute stands in.
1411
+ * @property {Array<{author: string, reason: string}>} [substituteRefusals] - Markers not counted, by whom, and why.
1263
1412
  * @property {Array<{id: unknown, reason: string}>} [ignoredCheckRuns] - Runs set aside, and why.
1264
1413
  */
1265
1414
 
@@ -1310,12 +1459,17 @@ export function humanReport(verdict) {
1310
1459
  );
1311
1460
  }
1312
1461
  const stood = reading.substituted
1313
- ? "a local adversarial review was posted in its place"
1462
+ ? "a writer's local adversarial review was posted in its place"
1314
1463
  : "NOTHING stands in its place";
1464
+ const refused = (reading.substituteRefusals ?? []).map(
1465
+ entry =>
1466
+ ` substitute marker by @${entry.author || "(unknown author)"} not counted: ${entry.reason}`
1467
+ );
1315
1468
  return [
1316
1469
  ` NOT REVIEWED ${reading.context} (${reading.reading}): ${seen}`,
1317
1470
  ` observed: ${READING_SENTENCES[reading.reading]}`,
1318
1471
  ` ${stood}`,
1472
+ ...refused,
1319
1473
  ...ignored,
1320
1474
  ].join("\n");
1321
1475
  });
@@ -1480,21 +1634,6 @@ function readHeadPulls(repo, sha) {
1480
1634
  .map(pull => pull.number);
1481
1635
  }
1482
1636
 
1483
- /**
1484
- * Issue comments on the given pull requests.
1485
- * @param {string} repo - `owner/repo`.
1486
- * @param {number[]} numbers - Pull request numbers.
1487
- * @returns {ReadonlyArray<object>} The comments.
1488
- */
1489
- function readComments(repo, numbers) {
1490
- return numbers.flatMap(number => {
1491
- const comments = ghJson(
1492
- `repos/${repo}/issues/${number}/comments?per_page=100`
1493
- );
1494
- return Array.isArray(comments) ? comments : [];
1495
- });
1496
- }
1497
-
1498
1637
  /**
1499
1638
  * Which check-run reader a run uses.
1500
1639
  *
@@ -1553,51 +1692,64 @@ const FIRST_LINE_MARKER = new RegExp(
1553
1692
  /**
1554
1693
  * Whether a login holds write access to the repository.
1555
1694
  *
1556
- * probe-direction: fail-closed — any failure to read the permission answers
1557
- * `false`, which can only leave a substitute uncounted, never count one. A bot author such as
1558
- * `github-actions[bot]` is not a collaborator and never counts.
1695
+ * probe-direction: fail-closed — a permission that cannot be read answers
1696
+ * `null`, reported as "permission unreadable", and a login outside the gate's
1697
+ * pattern answers `false`; both can only leave a substitute uncounted, never
1698
+ * count one. The pattern is the merge-path gate's own,
1699
+ * `^[A-Za-z0-9-]+(\[bot\])?$`, so the two arms judge the same logins. A
1700
+ * bot author such as `github-actions[bot]` is no collaborator, so the
1701
+ * remembering reader answers it `false` before this is ever asked.
1559
1702
  * @param {string} repo - `owner/repo`.
1560
1703
  * @param {string} login - The comment author.
1561
- * @returns {boolean} Whether the login may stand in for a reviewer.
1704
+ * @returns {boolean|null} Whether the login may stand in for a reviewer; null when unreadable.
1562
1705
  */
1563
1706
  function fetchWritePermission(repo, login) {
1564
- if (!/^[A-Za-z0-9-]+$/u.test(login)) return false;
1565
- try {
1566
- const permission = boundedExecFileSync(
1567
- "gh",
1568
- [
1569
- "api",
1570
- `repos/${repo}/collaborators/${encodeURIComponent(login)}/permission`,
1571
- "--jq",
1572
- ".permission",
1573
- ],
1574
- { encoding: "utf8" }
1575
- ).trim();
1576
- return SUBSTITUTE_WRITER_PERMISSIONS.has(permission);
1577
- } catch {
1578
- return false;
1579
- }
1707
+ if (!/^[A-Za-z0-9-]+(\[bot\])?$/u.test(login)) return false;
1708
+ const body = /** @type {{permission?: unknown}|null} */ (
1709
+ ghJson(
1710
+ `repos/${repo}/collaborators/${encodeURIComponent(login)}/permission`
1711
+ )
1712
+ );
1713
+ const permission = body?.permission;
1714
+ return typeof permission === "string"
1715
+ ? SUBSTITUTE_WRITER_PERMISSIONS.has(permission)
1716
+ : null;
1717
+ }
1718
+
1719
+ /**
1720
+ * The permission reader a run uses: the injected one, or a live read.
1721
+ *
1722
+ * Shared by the reading and the `--arm` decision, and remembered per login, so
1723
+ * one run asks about each comment author once.
1724
+ * @param {{canWrite?: (login: string) => boolean|null}} io - Injected side effects.
1725
+ * @param {string} repo - `owner/repo`, possibly empty.
1726
+ * @returns {(login: string) => boolean|null} The remembered reader.
1727
+ */
1728
+ function permissionReader(io, repo) {
1729
+ const validRepo = /^[^/\s]+\/[^/\s]+$/u.test(repo);
1730
+ return rememberPermissions(
1731
+ io.canWrite ??
1732
+ (login => (validRepo ? fetchWritePermission(repo, login) : null))
1733
+ );
1580
1734
  }
1581
1735
 
1582
1736
  /**
1583
1737
  * The contexts a writer posted a first-line substitute for at this head.
1584
1738
  *
1585
- * Stricter than the response arm on purpose, because here a match arms a
1739
+ * The same rule as {@link judgeSubstitutes}, because here a match arms a
1586
1740
  * merge: the marker must be the comment's FIRST LINE (a comment that quotes
1587
1741
  * it is not a review), and the author must hold write access (anyone who can
1588
- * comment can type the marker).
1742
+ * comment can type the marker). It answers for every context at once, which
1743
+ * is what the arm needs; the reading names the refusals.
1589
1744
  * @param {ReadonlyArray<{body?: string, user?: {login?: string}}>} comments - Pull request comments.
1590
1745
  * @param {string} sha - The head commit.
1591
- * @param {(login: string) => boolean} canWrite - Whether a login holds write access.
1746
+ * @param {(login: string) => boolean|null} canWrite - Whether a login holds write access; null when unreadable.
1592
1747
  * @returns {Set<string>} The substituted contexts.
1593
1748
  */
1594
1749
  export function writerSubstitutes(comments, sha, canWrite) {
1595
1750
  const found = new Set();
1596
- const seen = new Map();
1597
- const writer = login => {
1598
- if (!seen.has(login)) seen.set(login, canWrite(login) === true);
1599
- return seen.get(login);
1600
- };
1751
+ const permission = rememberPermissions(canWrite);
1752
+ const writer = login => permission(login) === true;
1601
1753
  for (const comment of comments ?? []) {
1602
1754
  const firstLine = String(comment?.body ?? "")
1603
1755
  .split("\n")[0]
@@ -1762,9 +1914,10 @@ function loadVacuityReport(path, read) {
1762
1914
  * @param {{write: (text: string) => void}} context.out - Stdout.
1763
1915
  * @param {string} context.repo - `owner/repo`, possibly empty.
1764
1916
  * @param {number[]|null|undefined} context.pulls - Head pull requests already read, if any.
1917
+ * @param {(login: string) => boolean|null} context.canWrite - The run's remembered permission reader.
1765
1918
  * @returns {number} The exit code.
1766
1919
  */
1767
- function writeArmDecision(verdict, { opts, io, out, repo, pulls }) {
1920
+ function writeArmDecision(verdict, { opts, io, out, repo, pulls, canWrite }) {
1768
1921
  const readFile = io.readFile ?? (path => readFileSync(path, "utf8"));
1769
1922
  const validRepo = /^[^/\s]+\/[^/\s]+$/u.test(repo);
1770
1923
  const numbers =
@@ -1785,9 +1938,6 @@ function writeArmDecision(verdict, { opts, io, out, repo, pulls }) {
1785
1938
  : heads.length === 0
1786
1939
  ? []
1787
1940
  : (io.reviews ?? (list => readReviews(repo, list)))(heads);
1788
- const canWrite =
1789
- io.canWrite ??
1790
- (login => (validRepo ? fetchWritePermission(repo, login) : false));
1791
1941
  const decision = armDecision({
1792
1942
  evidence: verdict,
1793
1943
  vacuity: loadVacuityReport(opts["vacuity-report"], readFile),
@@ -1828,7 +1978,11 @@ function writeArmDecision(verdict, { opts, io, out, repo, pulls }) {
1828
1978
  * @param {(numbers: number[]) => ReadonlyArray<object>} [io.comments] - Comment reader.
1829
1979
  * @param {(path: string) => string} [io.readFile] - Reader for `--vacuity-report` and `required-checks.json`.
1830
1980
  * @param {(numbers: number[]) => ReadonlyArray<object>|null} [io.reviews] - Review-object reader, `--arm` only.
1831
- * @param {(login: string) => boolean} [io.canWrite] - Write-permission reader, `--arm` only.
1981
+ * @param {(login: string) => boolean|null} [io.canWrite] -
1982
+ * Write-permission reader for substitute authors: true for write, maintain
1983
+ * or admin, false otherwise, null (or a throw) when unreadable. Used by the
1984
+ * reading and by `--arm`; absent, it reads
1985
+ * `repos/{repo}/collaborators/{login}/permission`.
1832
1986
  * @param {() => boolean} [io.requiredChecks] - Whether `required-checks.json` declares an evidence-bearing check, `--arm` only.
1833
1987
  * @param {{write: (text: string) => void}} [io.out] - Stdout.
1834
1988
  * @param {{write: (text: string) => void}} [io.err] - Stderr.
@@ -1868,6 +2022,7 @@ export function main(argv, io = {}) {
1868
2022
  : (io.pulls ?? (sha => readHeadPulls(repo, sha)))(opts.sha);
1869
2023
  const isPullRequestHead = pulls === null ? null : pulls.length > 0;
1870
2024
  const evaluated = reviewers.length > 0 && woken && isPullRequestHead === true;
2025
+ const canWrite = permissionReader(io, repo);
1871
2026
  const verdict = !woken
1872
2027
  ? {
1873
2028
  outcome: EVIDENCE_OUTCOMES.notAConfiguredReviewer,
@@ -1881,15 +2036,23 @@ export function main(argv, io = {}) {
1881
2036
  ? checkRunsByContext(reviewers, opts.sha, checkRunReader(io, repo))
1882
2037
  : {},
1883
2038
  comments: evaluated
1884
- ? (io.comments ?? (numbers => readComments(repo, numbers)))(
2039
+ ? (io.comments ?? (numbers => readAllComments(repo, numbers)))(
1885
2040
  pulls ?? []
1886
2041
  )
1887
2042
  : [],
1888
2043
  sha: opts.sha,
1889
2044
  isPullRequestHead,
2045
+ canWrite,
1890
2046
  });
1891
2047
  if (opts.arm) {
1892
- return writeArmDecision(verdict, { opts, io, out, repo, pulls });
2048
+ return writeArmDecision(verdict, {
2049
+ opts,
2050
+ io,
2051
+ out,
2052
+ repo,
2053
+ pulls,
2054
+ canWrite,
2055
+ });
1893
2056
  }
1894
2057
  out.write(
1895
2058
  `${opts.json ? JSON.stringify(verdict, null, 2) : humanReport(verdict)}\n`
@@ -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,CAwyEjC,CAAC;AAEH;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,+BAA+B,EAAE,QAAQ,CACpD,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CA2sEjC,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,CA0yEjC,CAAC;AAEH;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,+BAA+B,EAAE,QAAQ,CACpD,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CA6sEjC,CAAC"}
@@ -425,8 +425,10 @@ export const LISA_OWNED_HASH_LEDGER = Object.freeze({
425
425
  "73897b268225395433f2ea15191b86c2df7588ccc57b0d4701e47b4fc917612a",
426
426
  "7654d9f809815ca178d1a81f2757ba1cda06fbc2f15a89ea538625c5a38b65c9",
427
427
  "95f91f2a74ed4e523d064d5d374eadd1c1114f03a3a4fa41532c9b0fd32089de",
428
+ "a30f25440b418f81d21f4afc8c7eb637a97ff518f330af6532a8dc5beb57ccc7",
428
429
  "abe7221e1cfcee930b4fa3788eccb8a25ee4d499c3b90dc568f3862796c94de0",
429
430
  "d00a4c3225efb5c9385a4d5290baf28d39bff08b3a6c40563af777dcb7ec0d99",
431
+ "f74f4fd1e6d44511a358b9aada80600bb6be62228eb65f67dfb20284ec9b35bd",
430
432
  "fda72314a6f74394b8d54e7fcf0bd4957d8ad08c05c07791dddc591ff1e4d28f",
431
433
  ]),
432
434
  "scripts/check-threshold-ratchet.mjs": Object.freeze([
@@ -2766,8 +2768,10 @@ export const LISA_OWNED_HASH_HISTORY_DERIVED = Object.freeze({
2766
2768
  "73897b268225395433f2ea15191b86c2df7588ccc57b0d4701e47b4fc917612a",
2767
2769
  "7654d9f809815ca178d1a81f2757ba1cda06fbc2f15a89ea538625c5a38b65c9",
2768
2770
  "95f91f2a74ed4e523d064d5d374eadd1c1114f03a3a4fa41532c9b0fd32089de",
2771
+ "a30f25440b418f81d21f4afc8c7eb637a97ff518f330af6532a8dc5beb57ccc7",
2769
2772
  "abe7221e1cfcee930b4fa3788eccb8a25ee4d499c3b90dc568f3862796c94de0",
2770
2773
  "d00a4c3225efb5c9385a4d5290baf28d39bff08b3a6c40563af777dcb7ec0d99",
2774
+ "f74f4fd1e6d44511a358b9aada80600bb6be62228eb65f67dfb20284ec9b35bd",
2771
2775
  "fda72314a6f74394b8d54e7fcf0bd4957d8ad08c05c07791dddc591ff1e4d28f",
2772
2776
  ]),
2773
2777
  "scripts/check-threshold-ratchet.mjs": Object.freeze([