@codyswann/lisa 4.100.2 → 4.100.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 (96) hide show
  1. package/dist/core/nightly-e2e-guard-behavior-certificate.js +2 -2
  2. package/dist/core/upstream-evidence-manifest.d.ts.map +1 -1
  3. package/dist/core/upstream-evidence-manifest.js +10 -5
  4. package/dist/core/upstream-evidence-manifest.js.map +1 -1
  5. package/package.json +4 -4
  6. package/plugins/lisa/.claude-plugin/plugin.json +1 -1
  7. package/plugins/lisa/.codex-plugin/plugin.json +1 -1
  8. package/plugins/lisa/.codex-plugin/skills/lisa-github-build-intake/SKILL.md +1 -1
  9. package/plugins/lisa/.codex-plugin/skills/lisa-track/SKILL.md +1 -1
  10. package/plugins/lisa/rules/reference/rejection-detection.md +2 -2
  11. package/plugins/lisa/skills/lisa-github-build-intake/SKILL.md +1 -1
  12. package/plugins/lisa/skills/lisa-track/SKILL.md +1 -1
  13. package/plugins/lisa-agy/plugin.json +1 -1
  14. package/plugins/lisa-agy/skills/lisa-github-build-intake/SKILL.md +1 -1
  15. package/plugins/lisa-agy/skills/lisa-track/SKILL.md +1 -1
  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/rules/reference/rejection-detection.md +2 -2
  25. package/plugins/lisa-copilot/skills/lisa-github-build-intake/SKILL.md +1 -1
  26. package/plugins/lisa-copilot/skills/lisa-track/SKILL.md +1 -1
  27. package/plugins/lisa-cursor/.claude-plugin/plugin.json +1 -1
  28. package/plugins/lisa-cursor/rules/rejection-detection-reference.mdc +2 -2
  29. package/plugins/lisa-cursor/skills/lisa-github-build-intake/SKILL.md +1 -1
  30. package/plugins/lisa-cursor/skills/lisa-track/SKILL.md +1 -1
  31. package/plugins/lisa-devin/.claude-plugin/plugin.json +1 -1
  32. package/plugins/lisa-devin/.devin-plugin/plugin.json +1 -1
  33. package/plugins/lisa-devin/rules/reference/rejection-detection.md +2 -2
  34. package/plugins/lisa-devin/skills/lisa-github-build-intake/SKILL.md +1 -1
  35. package/plugins/lisa-devin/skills/lisa-track/SKILL.md +1 -1
  36. package/plugins/lisa-expo/.claude-plugin/plugin.json +1 -1
  37. package/plugins/lisa-expo/.codex-plugin/plugin.json +1 -1
  38. package/plugins/lisa-expo-agy/plugin.json +1 -1
  39. package/plugins/lisa-expo-copilot/.claude-plugin/plugin.json +1 -1
  40. package/plugins/lisa-expo-cursor/.claude-plugin/plugin.json +1 -1
  41. package/plugins/lisa-expo-devin/.claude-plugin/plugin.json +1 -1
  42. package/plugins/lisa-expo-devin/.devin-plugin/plugin.json +1 -1
  43. package/plugins/lisa-harper-fabric/.claude-plugin/plugin.json +1 -1
  44. package/plugins/lisa-harper-fabric/.codex-plugin/plugin.json +1 -1
  45. package/plugins/lisa-harper-fabric-agy/plugin.json +1 -1
  46. package/plugins/lisa-harper-fabric-copilot/.claude-plugin/plugin.json +1 -1
  47. package/plugins/lisa-harper-fabric-cursor/.claude-plugin/plugin.json +1 -1
  48. package/plugins/lisa-harper-fabric-devin/.claude-plugin/plugin.json +1 -1
  49. package/plugins/lisa-harper-fabric-devin/.devin-plugin/plugin.json +1 -1
  50. package/plugins/lisa-nestjs/.claude-plugin/plugin.json +1 -1
  51. package/plugins/lisa-nestjs/.codex-plugin/plugin.json +1 -1
  52. package/plugins/lisa-nestjs-agy/plugin.json +1 -1
  53. package/plugins/lisa-nestjs-copilot/.claude-plugin/plugin.json +1 -1
  54. package/plugins/lisa-nestjs-cursor/.claude-plugin/plugin.json +1 -1
  55. package/plugins/lisa-nestjs-devin/.claude-plugin/plugin.json +1 -1
  56. package/plugins/lisa-nestjs-devin/.devin-plugin/plugin.json +1 -1
  57. package/plugins/lisa-openclaw/.claude-plugin/plugin.json +1 -1
  58. package/plugins/lisa-openclaw/.codex-plugin/plugin.json +1 -1
  59. package/plugins/lisa-openclaw-agy/plugin.json +1 -1
  60. package/plugins/lisa-openclaw-copilot/.claude-plugin/plugin.json +1 -1
  61. package/plugins/lisa-openclaw-cursor/.claude-plugin/plugin.json +1 -1
  62. package/plugins/lisa-openclaw-devin/.claude-plugin/plugin.json +1 -1
  63. package/plugins/lisa-openclaw-devin/.devin-plugin/plugin.json +1 -1
  64. package/plugins/lisa-phaser/.claude-plugin/plugin.json +1 -1
  65. package/plugins/lisa-phaser/.codex-plugin/plugin.json +1 -1
  66. package/plugins/lisa-phaser-agy/plugin.json +1 -1
  67. package/plugins/lisa-phaser-copilot/.claude-plugin/plugin.json +1 -1
  68. package/plugins/lisa-phaser-cursor/.claude-plugin/plugin.json +1 -1
  69. package/plugins/lisa-phaser-devin/.claude-plugin/plugin.json +1 -1
  70. package/plugins/lisa-phaser-devin/.devin-plugin/plugin.json +1 -1
  71. package/plugins/lisa-rails/.claude-plugin/plugin.json +1 -1
  72. package/plugins/lisa-rails/.codex-plugin/plugin.json +1 -1
  73. package/plugins/lisa-rails-agy/plugin.json +1 -1
  74. package/plugins/lisa-rails-copilot/.claude-plugin/plugin.json +1 -1
  75. package/plugins/lisa-rails-cursor/.claude-plugin/plugin.json +1 -1
  76. package/plugins/lisa-rails-devin/.claude-plugin/plugin.json +1 -1
  77. package/plugins/lisa-rails-devin/.devin-plugin/plugin.json +1 -1
  78. package/plugins/lisa-typescript/.claude-plugin/plugin.json +1 -1
  79. package/plugins/lisa-typescript/.codex-plugin/plugin.json +1 -1
  80. package/plugins/lisa-typescript-agy/plugin.json +1 -1
  81. package/plugins/lisa-typescript-copilot/.claude-plugin/plugin.json +1 -1
  82. package/plugins/lisa-typescript-cursor/.claude-plugin/plugin.json +1 -1
  83. package/plugins/lisa-typescript-devin/.claude-plugin/plugin.json +1 -1
  84. package/plugins/lisa-typescript-devin/.devin-plugin/plugin.json +1 -1
  85. package/plugins/lisa-wiki/.claude-plugin/plugin.json +1 -1
  86. package/plugins/lisa-wiki/.codex-plugin/plugin.json +1 -1
  87. package/plugins/lisa-wiki-agy/plugin.json +1 -1
  88. package/plugins/lisa-wiki-copilot/.claude-plugin/plugin.json +1 -1
  89. package/plugins/lisa-wiki-cursor/.claude-plugin/plugin.json +1 -1
  90. package/plugins/lisa-wiki-devin/.claude-plugin/plugin.json +1 -1
  91. package/plugins/lisa-wiki-devin/.devin-plugin/plugin.json +1 -1
  92. package/plugins/src/base/rules/reference/rejection-detection.md +2 -2
  93. package/plugins/src/base/skills/lisa-github-build-intake/SKILL.md +1 -1
  94. package/plugins/src/base/skills/lisa-track/SKILL.md +1 -1
  95. package/scripts/lisa-ci-failure-redispatch.mjs +216 -18
  96. package/scripts/lisa-ci-rework-route.mjs +24 -49
@@ -43,10 +43,19 @@
43
43
  *
44
44
  * Repo-only: this is the Lisa monorepo's own automation and is deliberately
45
45
  * NOT shipped to host projects (CodySwannGT/lisa#4607, Out of Scope).
46
+ *
47
+ * What supersedes a marker (CodySwannGT/lisa#4707): a later comment carrying
48
+ * a Lisa marker that is not a claim, posted by a trusted author — the
49
+ * workflow's identity, the item's author, or a configured
50
+ * `sessionManager.trustedAuthorIds` entry. Supersession by trusted author was
51
+ * chosen over explicit-only supersession (a `[lisa-ci-cleared]` edit or a
52
+ * newer `[lisa-ci-failed]` marker) because a trusted human-gate hold posted
53
+ * after the marker must still stop CI rework.
46
54
  * @module scripts/lisa-ci-failure-redispatch
47
55
  */
48
56
  import { spawnSync } from "node:child_process";
49
57
  import { readFileSync } from "node:fs";
58
+ import { join } from "node:path";
50
59
  import process from "node:process";
51
60
 
52
61
  import { invokedAsScript } from "../all/copy-overwrite/scripts/lib/invoked-as-script.mjs";
@@ -54,6 +63,7 @@ import {
54
63
  soleWorkItem,
55
64
  trackerContract,
56
65
  } from "../all/copy-overwrite/scripts/lisa-work-item.mjs";
66
+ import { parseIdEntries } from "../plugins/src/base/scripts/operator-id-kinds.mjs";
57
67
 
58
68
  const SHA = /^[0-9a-f]{40}$/u;
59
69
  /**
@@ -68,6 +78,13 @@ export const FAILURE_MARKER =
68
78
  export const CLEARED_MARKER = /<!-- \[lisa-ci-cleared\] run=\d+ -->/u;
69
79
  /** Any Lisa lifecycle marker — the claim, attempt, and CI markers alike. */
70
80
  export const LISA_MARKER = /\[(?:lisa-[a-z0-9-]+|claude-build-intake)\]/u;
81
+ /**
82
+ * Dispatch-bookkeeping markers: the lifecycle claim, build intake's legacy
83
+ * claim, and the session manager's own notes (stop, release, worker failed,
84
+ * answer delivered). None of them says anything about the PR's checks.
85
+ */
86
+ const CLAIM_MARKERS =
87
+ /\[(?:lisa-tracker-claim|claude-build-intake|lisa-session-manager)\]/gu;
71
88
  const NO_REQUIRED = /no (?:required )?checks reported/iu;
72
89
  /** Read every page of a REST list as one array of pages. */
73
90
  const PAGINATE = Object.freeze(["--paginate", "--slurp"]);
@@ -392,6 +409,158 @@ export function trustedAuthor(comment) {
392
409
  return MARKER_AUTHORS.includes(comment.user?.login ?? "");
393
410
  }
394
411
 
412
+ /**
413
+ * True when every Lisa marker the comment carries is a claim marker. A claim
414
+ * is dispatch bookkeeping: the session manager claims an item before its
415
+ * worker reads the markers, and a re-claim can post another claim comment,
416
+ * so a claim says nothing about the PR's checks and never supersedes.
417
+ * @param {object} comment - Item comment.
418
+ * @returns {boolean} Whether it is a claim-only comment.
419
+ */
420
+ export function claimOnly(comment) {
421
+ const body = String(comment.body ?? "");
422
+ return (
423
+ LISA_MARKER.test(body) &&
424
+ !LISA_MARKER.test(body.replaceAll(CLAIM_MARKERS, ""))
425
+ );
426
+ }
427
+
428
+ /**
429
+ * True when a comment posted after an uncleared failure marker means the
430
+ * marker no longer describes the item (CodySwannGT/lisa#4707). It must carry
431
+ * a Lisa marker and not be claim-only; a failure marker counts only from
432
+ * {@link MARKER_AUTHORS}, any other marker only from a `trust`ed author.
433
+ * Anyone can comment on a public repository, so an outsider's `[lisa-x] hi`
434
+ * must not turn CI rework off.
435
+ * @param {object} comment - A later item comment.
436
+ * @param {(comment: object) => boolean} trust - Whose markers count.
437
+ * @returns {boolean} Whether it supersedes the marker.
438
+ */
439
+ export function supersedes(comment, trust) {
440
+ const body = String(comment.body ?? "");
441
+ if (!LISA_MARKER.test(body) || claimOnly(comment)) return false;
442
+ return FAILURE_MARKER.test(body) ? trustedAuthor(comment) : trust(comment);
443
+ }
444
+
445
+ /**
446
+ * Whether a configured `sessionManager.trustedAuthorIds` entry names a GitHub
447
+ * comment author. Only a `login:` entry matches a login; a plain entry, like
448
+ * an `id:` entry, matches the numeric account id only — the same reading
449
+ * `isTrustedAuthor` in ready-queue-order gives it — because a freed login can
450
+ * be re-registered by someone else, and nobody picks their own numeric id
451
+ * (#4571, #4623).
452
+ * @param {{kind: string, value?: string}} entry - Parsed entry.
453
+ * @param {{login?: string, id?: number|string}|undefined} user - Comment author.
454
+ * @returns {boolean} Whether it matches.
455
+ */
456
+ function entryNames(entry, user) {
457
+ const kind = entry.kind === "plain" ? "id" : entry.kind;
458
+ if (kind === "login")
459
+ return typeof user?.login === "string" && user.login === entry.value;
460
+ if (kind === "id") return user?.id != null && String(user.id) === entry.value;
461
+ return false;
462
+ }
463
+
464
+ /**
465
+ * True when two GitHub users are the same account, by numeric id. A side with
466
+ * no id is never a match: a login can be freed and re-registered by someone
467
+ * else, so a login alone does not prove the item's author wrote a comment.
468
+ * @param {object|null|undefined} a - A user.
469
+ * @param {object|null|undefined} b - Another user.
470
+ * @returns {boolean} Whether they match.
471
+ */
472
+ function sameUser(a, b) {
473
+ if (a?.id == null || b?.id == null) return false;
474
+ return String(a.id) === String(b.id);
475
+ }
476
+
477
+ /**
478
+ * Build the trusted-author predicate for later non-failure markers: the
479
+ * workflow's identity ({@link MARKER_AUTHORS}), a configured
480
+ * `sessionManager.trustedAuthorIds` entry, or the item's author. The item's
481
+ * author is read lazily — only when a later marker from someone else needs
482
+ * judging — and at most once.
483
+ * @param {{trustedAuthorIds?: unknown, itemAuthor: () => object|null}} input - Configured entries and the author reader.
484
+ * @returns {(comment: object) => boolean} The predicate.
485
+ */
486
+ export function markerTrust({ trustedAuthorIds, itemAuthor }) {
487
+ const entries = parseIdEntries(trustedAuthorIds);
488
+ const author = { read: false, user: null };
489
+ return comment => {
490
+ if (trustedAuthor(comment)) return true;
491
+ if (entries.some(entry => entryNames(entry, comment.user))) return true;
492
+ if (!author.read) Object.assign(author, { read: true, user: itemAuthor() });
493
+ return sameUser(comment.user, author.user);
494
+ };
495
+ }
496
+
497
+ /**
498
+ * Read the work item's author (the REST issue's `user`). Throws naming the
499
+ * call when the read fails, so a caller falls back the way it does for any
500
+ * failed read.
501
+ * @param {string} number - Issue number.
502
+ * @param {string} repo - Repository.
503
+ * @param {Function} gh - Runner.
504
+ * @returns {object|null} The author, or null when the issue names none.
505
+ */
506
+ export function readItemAuthor(number, repo, gh) {
507
+ return readJson(gh, ["api", `repos/${repo}/issues/${number}`]).user ?? null;
508
+ }
509
+
510
+ /**
511
+ * The producer's item-author read: like {@link readItemAuthor}, but a failed
512
+ * read is no author rather than a failed run. The author only ever decides
513
+ * whether a later marker is trusted, so failing closed — "not trusted" —
514
+ * keeps the run deciding on the evidence it has. The route helper keeps the
515
+ * throwing read, because its failed reads route to the normal path.
516
+ * @param {string} number - Issue number.
517
+ * @param {string} repo - Repository.
518
+ * @param {Function} gh - Runner.
519
+ * @returns {object|null} The author, or null when it cannot be read.
520
+ */
521
+ function readItemAuthorOrNull(number, repo, gh) {
522
+ try {
523
+ return readItemAuthor(number, repo, gh);
524
+ } catch {
525
+ return null;
526
+ }
527
+ }
528
+
529
+ /**
530
+ * The `sessionManager.trustedAuthorIds` committed in `.lisa.config.json`.
531
+ * `.lisa.config.local.json` is deliberately NOT read: the producer runs in
532
+ * CI on a fresh checkout, where no local override exists, so a helper that
533
+ * read one would trust people the producer does not and the two dispatch
534
+ * paths would disagree. Fails safe: a missing or malformed config, or a list
535
+ * that is not an array, trusts nobody beyond the bot and the item's author.
536
+ * @param {string} [root] - Project root.
537
+ * @returns {unknown[]} Configured entries.
538
+ */
539
+ export function readTrustedAuthorIds(root = process.cwd()) {
540
+ try {
541
+ const config = JSON.parse(
542
+ readFileSync(join(root, ".lisa.config.json"), "utf8")
543
+ );
544
+ const declared = config?.sessionManager?.trustedAuthorIds;
545
+ return Array.isArray(declared) ? declared : [];
546
+ } catch {
547
+ return [];
548
+ }
549
+ }
550
+
551
+ /**
552
+ * The tracker contract with the configured trusted authors attached, unless
553
+ * the caller already supplied them. Both CLIs read through this so the two
554
+ * dispatch paths trust the same people.
555
+ * @param {object} contract - Tracker contract.
556
+ * @param {string} [root] - Project root.
557
+ * @returns {object} Contract carrying `trustedAuthorIds`.
558
+ */
559
+ export function withTrustedAuthors(contract, root) {
560
+ if (contract.trustedAuthorIds !== undefined) return contract;
561
+ return { ...contract, trustedAuthorIds: readTrustedAuthorIds(root) };
562
+ }
563
+
395
564
  /**
396
565
  * True when the item gained `lane` after `comment` was posted. Comments alone
397
566
  * cannot say a claim happened: a claim path that posts its claim comment once
@@ -427,20 +596,46 @@ function readEvents(number, repo, gh) {
427
596
  }
428
597
 
429
598
  /**
430
- * True when `comment` is the newest comment carrying any Lisa marker — nothing
431
- * (a claim, an attempt, a hold) has happened to the item since it was posted.
599
+ * True when `comment` is the newest counted Lisa marker on the item: no later
600
+ * comment supersedes it (see {@link supersedes}). This is the one predicate
601
+ * both dispatch paths use — the producer here and the route helper
602
+ * `scripts/lisa-ci-rework-route.mjs` — so they cannot disagree
603
+ * (CodySwannGT/lisa#4707).
432
604
  * @param {object[]} comments - Item comments, oldest first.
433
605
  * @param {object} comment - The marker comment.
606
+ * @param {(comment: object) => boolean} [trust] - Whose non-failure markers
607
+ * count; build it with {@link markerTrust}. Defaults to the bot only.
434
608
  * @returns {boolean} Whether it is the newest.
435
609
  */
436
- export function isNewestLisaMarker(comments, comment) {
437
- // A forged failure marker counts for nothing, including as "something newer".
438
- const marked = comments.filter(
439
- c =>
440
- LISA_MARKER.test(c.body ?? "") &&
441
- (trustedAuthor(c) || !FAILURE_MARKER.test(c.body ?? ""))
610
+ export function isNewestLisaMarker(comments, comment, trust = trustedAuthor) {
611
+ const index = comments.findIndex(c => c.id === comment.id);
612
+ return (
613
+ index !== -1 && !comments.slice(index + 1).some(c => supersedes(c, trust))
614
+ );
615
+ }
616
+
617
+ /**
618
+ * True when nothing has happened to the item since `marker`, so a lane write
619
+ * on its behalf is still safe: it is the newest counted marker (the shared
620
+ * predicate the route helper uses), no claim-only comment follows it, and
621
+ * the label history shows no claim since. A claim never makes the marker
622
+ * stale for routing, but it may mean the lane has moved, so the lane paths
623
+ * veto on it where the route helper does not — on ANY claim-only comment,
624
+ * whoever posted it: skipping a lane write is the safe direction, and routing
625
+ * is unaffected.
626
+ * @param {object} ctx - Resolved context.
627
+ * @param {object} marker - The marker comment.
628
+ * @returns {boolean} Whether the item is untouched since.
629
+ */
630
+ function untouchedSince(ctx, marker) {
631
+ const { view, lanes, trust } = ctx;
632
+ const index = view.comments.findIndex(c => c.id === marker.id);
633
+ const claimedSince = view.comments.slice(index + 1).some(claimOnly);
634
+ return (
635
+ isNewestLisaMarker(view.comments, marker, trust) &&
636
+ !claimedSince &&
637
+ !laneGainedSince(ctx.events(), marker, lanes.claimed)
442
638
  );
443
- return marked.at(-1)?.id === comment.id;
444
639
  }
445
640
 
446
641
  /**
@@ -463,8 +658,7 @@ function planFailure(ctx) {
463
658
  if (
464
659
  claimed &&
465
660
  !CLEARED_MARKER.test(existing.body) &&
466
- isNewestLisaMarker(view.comments, existing) &&
467
- !laneGainedSince(ctx.events(), existing, lanes.claimed)
661
+ untouchedSince(ctx, existing)
468
662
  )
469
663
  return {
470
664
  ...known,
@@ -534,12 +728,10 @@ function planClear(ctx) {
534
728
  }));
535
729
  const unclaimed =
536
730
  view.labels.includes(lanes.ready) && !view.labels.includes(lanes.claimed);
537
- const newest = open.find(c => isNewestLisaMarker(view.comments, c));
538
- if (
539
- unclaimed &&
540
- newest !== undefined &&
541
- !laneGainedSince(ctx.events(), newest, lanes.claimed)
542
- ) {
731
+ const newest = open.find(c =>
732
+ isNewestLisaMarker(view.comments, c, ctx.trust)
733
+ );
734
+ if (unclaimed && newest !== undefined && untouchedSince(ctx, newest)) {
543
735
  actions.push({
544
736
  kind: ACTION.relabel,
545
737
  item,
@@ -635,6 +827,12 @@ export function planRedispatch({ run, repository, contract, gh }) {
635
827
  lanes: contract.lifecycle,
636
828
  // Read lazily: only a lane repair or restore needs the label history.
637
829
  events: () => readEvents(view.number, contract.repository, gh),
830
+ // The same supersession rule the route helper applies (#4707).
831
+ trust: markerTrust({
832
+ trustedAuthorIds: contract.trustedAuthorIds,
833
+ itemAuthor: () =>
834
+ readItemAuthorOrNull(view.number, contract.repository, gh),
835
+ }),
638
836
  };
639
837
  if (verdict === "fail") return planFailure(ctx);
640
838
  if (verdict === "pass")
@@ -947,7 +1145,7 @@ export function main(argv, deps = {}) {
947
1145
  let source;
948
1146
  try {
949
1147
  options = parseArgs(argv);
950
- const contract = deps.contract ?? trackerContract();
1148
+ const contract = withTrustedAuthors(deps.contract ?? trackerContract());
951
1149
  source = {
952
1150
  contract,
953
1151
  ...loadEvent(options, contract, deps.gh ?? liveGh, env),
@@ -15,9 +15,12 @@
15
15
  * answer. It reads the item's comments — which the caller must do BEFORE it
16
16
  * posts its own claim comment, a newer Lisa marker that would hide the signal —
17
17
  * and, when the newest counted marker is an uncleared failure marker, verifies
18
- * the PR it names. The marker patterns, the trusted-author predicate, the
19
- * newest-marker predicate and the comment reader are imported from the
20
- * producer script so the two cannot drift.
18
+ * the PR it names. The marker patterns, the trusted-author predicates, the
19
+ * newest-marker predicate (claim comments never count; any other later Lisa
20
+ * marker counts only from `github-actions[bot]`, the item's author, or a
21
+ * configured `sessionManager.trustedAuthorIds` entry — #4707) and the
22
+ * comment and author readers are imported from the producer script so the
23
+ * two cannot drift.
21
24
  *
22
25
  * Read-only: it never writes to the tracker. Every failed read routes to the
23
26
  * normal path, because building again is recoverable and a wrong route is not.
@@ -39,12 +42,14 @@ import {
39
42
  CLEARED_MARKER,
40
43
  FAILURE_MARKER,
41
44
  MARKER_AUTHORS,
42
- LISA_MARKER,
43
45
  isNewestLisaMarker,
44
46
  liveGh,
47
+ markerTrust,
48
+ readItemAuthor,
45
49
  readItemComments,
46
50
  recordedGh,
47
51
  trustedAuthor,
52
+ withTrustedAuthors,
48
53
  } from "./lisa-ci-failure-redispatch.mjs";
49
54
 
50
55
  /**
@@ -76,14 +81,6 @@ const FAILURE_LINE =
76
81
  const ITEM_NUMBER = /^[1-9]\d*$/u;
77
82
  const ITEM_REF = /^([A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+)#([1-9]\d*)$/u;
78
83
  const REPO = /^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/u;
79
- /**
80
- * Dispatch-bookkeeping markers: the lifecycle claim, build intake's legacy
81
- * claim, and the session manager's own notes (stop, release, worker failed,
82
- * answer delivered). None of them says anything about the PR's checks.
83
- */
84
- const CLAIM_MARKERS =
85
- /\[(?:lisa-tracker-claim|claude-build-intake|lisa-session-manager)\]/gu;
86
-
87
84
  /**
88
85
  * A decision to resolve and implement the item the normal way.
89
86
  * @param {string} reason - Short reason code.
@@ -114,42 +111,16 @@ function carriesFailure(comment) {
114
111
  }
115
112
 
116
113
  /**
117
- * True when every Lisa marker the comment carries is a claim marker.
118
- * @param {object} comment - Item comment.
119
- * @returns {boolean} Whether it is a claim-only comment.
120
- */
121
- function claimOnly(comment) {
122
- const body = String(comment.body ?? "");
123
- return (
124
- LISA_MARKER.test(body) &&
125
- !LISA_MARKER.test(body.replaceAll(CLAIM_MARKERS, ""))
126
- );
127
- }
128
-
129
- /**
130
- * The producer's newest-marker test with claim comments left out. The
131
- * session manager claims an item before its worker runs this helper, and a
132
- * re-claim can post another claim comment, so a claim posted after the
133
- * failure marker must not hide it: an uncleared marker on an open, bound PR
134
- * still means the PR is red, whoever claimed the item since. Forged failure
135
- * markers are already left out by the producer's predicate.
136
- * @param {object[]} comments - Item comments, oldest first.
137
- * @param {object} marker - The failure marker comment.
138
- * @returns {boolean} Whether it is the newest counted marker.
139
- */
140
- function isNewestCountedMarker(comments, marker) {
141
- return isNewestLisaMarker(
142
- comments.filter(c => c === marker || !claimOnly(c)),
143
- marker
144
- );
145
- }
146
-
147
- /**
148
- * Pick the failure marker that could count, or say why none does.
114
+ * Pick the failure marker that could count, or say why none does. Whether a
115
+ * later comment supersedes it is the producer's one predicate
116
+ * (`isNewestLisaMarker` with `markerTrust`): claim comments never count, and
117
+ * any other later Lisa marker counts only from a trusted author
118
+ * (CodySwannGT/lisa#4707).
149
119
  * @param {object[]} comments - Item comments, oldest first.
120
+ * @param {(comment: object) => boolean} trust - Whose later markers count.
150
121
  * @returns {{marker?: object, decision?: object}} The marker or a decision.
151
122
  */
152
- function judgeMarker(comments) {
123
+ function judgeMarker(comments, trust) {
153
124
  const marker = comments
154
125
  .filter(c => carriesFailure(c) && trustedAuthor(c))
155
126
  .at(-1);
@@ -169,11 +140,11 @@ function judgeMarker(comments) {
169
140
  ),
170
141
  };
171
142
  }
172
- if (!isNewestCountedMarker(comments, marker))
143
+ if (!isNewestLisaMarker(comments, marker, trust))
173
144
  return {
174
145
  decision: implement(
175
146
  "not-newest",
176
- "a newer Lisa marker (not a claim) was posted after the [lisa-ci-failed] marker, so it no longer describes the item"
147
+ "a trusted author posted a newer Lisa marker (not a claim) after the [lisa-ci-failed] marker, so it no longer describes the item"
177
148
  ),
178
149
  };
179
150
  if (CLEARED_MARKER.test(marker.body))
@@ -297,7 +268,11 @@ export function decideRoute({ item, contract, gh, repository }) {
297
268
  const ref = `${repo}#${item}`;
298
269
  try {
299
270
  const comments = readItemComments(String(item), repo, gh);
300
- const { marker, decision } = judgeMarker(comments);
271
+ const trust = markerTrust({
272
+ trustedAuthorIds: contract.trustedAuthorIds,
273
+ itemAuthor: () => readItemAuthor(String(item), repo, gh),
274
+ });
275
+ const { marker, decision } = judgeMarker(comments, trust);
301
276
  if (decision) return decision;
302
277
  return routeMarker({
303
278
  marker,
@@ -364,7 +339,7 @@ export function main(argv, deps = {}) {
364
339
  const write = deps.write ?? (line => process.stdout.write(`${line}\n`));
365
340
  try {
366
341
  const options = parseArgs(argv);
367
- const contract = deps.contract ?? trackerContract();
342
+ const contract = withTrustedAuthors(deps.contract ?? trackerContract());
368
343
  const gh = options.payload
369
344
  ? recordedGh(JSON.parse(readFileSync(options.payload, "utf8")).gh)
370
345
  : (deps.gh ?? liveGh);