@codyswann/lisa 8.1.0 → 8.2.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 (237) hide show
  1. package/all/copy-overwrite/scripts/lib/npm-update-bun.mjs +8 -3
  2. package/all/copy-overwrite/scripts/lib/npm-update-cache-seed.mjs +145 -0
  3. package/all/copy-overwrite/scripts/lib/npm-update-helper-inventory.mjs +1 -0
  4. package/all/copy-overwrite/scripts/lib/npm-update-prepare.mjs +34 -6
  5. package/all/copy-overwrite/scripts/npm-updater-helper-graph.json +14 -3
  6. package/dist/core/lisa-owned-hash-ledger.json +24 -2
  7. package/dist/core/nightly-e2e-guard-behavior-certificate.js +2 -2
  8. package/dist/core/upstream-evidence-manifest.json +158 -17
  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/scripts/queue-contract-resolution.mjs +583 -0
  13. package/plugins/lisa/.codex-plugin/scripts/ready-queue-order.mjs +99 -25
  14. package/plugins/lisa/.codex-plugin/scripts/stale-blocker-comment.mjs +185 -0
  15. package/plugins/lisa/.codex-plugin/scripts/stale-blocker-confirm.mjs +130 -0
  16. package/plugins/lisa/.codex-plugin/scripts/stale-blocker-edges.mjs +466 -0
  17. package/plugins/lisa/.codex-plugin/scripts/stale-blocker-pending.mjs +257 -0
  18. package/plugins/lisa/.codex-plugin/scripts/stale-blocker-restore.mjs +180 -0
  19. package/plugins/lisa/.codex-plugin/scripts/stale-blocker-summary.mjs +222 -0
  20. package/plugins/lisa/.codex-plugin/scripts/stale-blocker-sweep.mjs +394 -0
  21. package/plugins/lisa/.codex-plugin/scripts/stale-blocker-verify.mjs +193 -0
  22. package/plugins/lisa/.codex-plugin/skills/lisa-atlassian-access/SKILL.md +1 -0
  23. package/plugins/lisa/.codex-plugin/skills/lisa-github-build-intake/SKILL.md +2 -7
  24. package/plugins/lisa/.codex-plugin/skills/lisa-jira-build-intake/SKILL.md +2 -0
  25. package/plugins/lisa/.codex-plugin/skills/lisa-linear-access/SKILL.md +44 -0
  26. package/plugins/lisa/.codex-plugin/skills/lisa-linear-build-intake/SKILL.md +2 -0
  27. package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/SKILL.md +127 -2
  28. package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/cli-queue.mjs +90 -20
  29. package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/cli-stale-links-results.mjs +254 -0
  30. package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/cli-stale-links.mjs +243 -0
  31. package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/cli-usage.mjs +60 -0
  32. package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/queue-github.mjs +68 -8
  33. package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/session-manager.mjs +49 -0
  34. package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/stale-links-github.mjs +196 -0
  35. package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/stale-links-state.mjs +173 -0
  36. package/plugins/lisa/scripts/ready-queue-order.mjs +99 -25
  37. package/plugins/lisa/scripts/stale-blocker-comment.mjs +185 -0
  38. package/plugins/lisa/scripts/stale-blocker-confirm.mjs +130 -0
  39. package/plugins/lisa/scripts/stale-blocker-edges.mjs +466 -0
  40. package/plugins/lisa/scripts/stale-blocker-pending.mjs +257 -0
  41. package/plugins/lisa/scripts/stale-blocker-restore.mjs +180 -0
  42. package/plugins/lisa/scripts/stale-blocker-summary.mjs +222 -0
  43. package/plugins/lisa/scripts/stale-blocker-sweep.mjs +394 -0
  44. package/plugins/lisa/scripts/stale-blocker-verify.mjs +193 -0
  45. package/plugins/lisa/skills/lisa-atlassian-access/SKILL.md +1 -0
  46. package/plugins/lisa/skills/lisa-github-build-intake/SKILL.md +2 -7
  47. package/plugins/lisa/skills/lisa-jira-build-intake/SKILL.md +2 -0
  48. package/plugins/lisa/skills/lisa-linear-access/SKILL.md +44 -0
  49. package/plugins/lisa/skills/lisa-linear-build-intake/SKILL.md +2 -0
  50. package/plugins/lisa/skills/lisa-session-manager/SKILL.md +127 -2
  51. package/plugins/lisa/skills/lisa-session-manager/scripts/cli-queue.mjs +90 -20
  52. package/plugins/lisa/skills/lisa-session-manager/scripts/cli-stale-links-results.mjs +254 -0
  53. package/plugins/lisa/skills/lisa-session-manager/scripts/cli-stale-links.mjs +243 -0
  54. package/plugins/lisa/skills/lisa-session-manager/scripts/cli-usage.mjs +60 -0
  55. package/plugins/lisa/skills/lisa-session-manager/scripts/queue-github.mjs +68 -8
  56. package/plugins/lisa/skills/lisa-session-manager/scripts/session-manager.mjs +49 -0
  57. package/plugins/lisa/skills/lisa-session-manager/scripts/stale-links-github.mjs +196 -0
  58. package/plugins/lisa/skills/lisa-session-manager/scripts/stale-links-state.mjs +173 -0
  59. package/plugins/lisa-agy/plugin.json +1 -1
  60. package/plugins/lisa-agy/scripts/ready-queue-order.mjs +99 -25
  61. package/plugins/lisa-agy/scripts/stale-blocker-comment.mjs +185 -0
  62. package/plugins/lisa-agy/scripts/stale-blocker-confirm.mjs +130 -0
  63. package/plugins/lisa-agy/scripts/stale-blocker-edges.mjs +466 -0
  64. package/plugins/lisa-agy/scripts/stale-blocker-pending.mjs +257 -0
  65. package/plugins/lisa-agy/scripts/stale-blocker-restore.mjs +180 -0
  66. package/plugins/lisa-agy/scripts/stale-blocker-summary.mjs +222 -0
  67. package/plugins/lisa-agy/scripts/stale-blocker-sweep.mjs +394 -0
  68. package/plugins/lisa-agy/scripts/stale-blocker-verify.mjs +193 -0
  69. package/plugins/lisa-agy/skills/lisa-atlassian-access/SKILL.md +1 -0
  70. package/plugins/lisa-agy/skills/lisa-github-build-intake/SKILL.md +2 -7
  71. package/plugins/lisa-agy/skills/lisa-jira-build-intake/SKILL.md +2 -0
  72. package/plugins/lisa-agy/skills/lisa-linear-access/SKILL.md +44 -0
  73. package/plugins/lisa-agy/skills/lisa-linear-build-intake/SKILL.md +2 -0
  74. package/plugins/lisa-agy/skills/lisa-session-manager/SKILL.md +127 -2
  75. package/plugins/lisa-agy/skills/lisa-session-manager/scripts/cli-queue.mjs +90 -20
  76. package/plugins/lisa-agy/skills/lisa-session-manager/scripts/cli-stale-links-results.mjs +254 -0
  77. package/plugins/lisa-agy/skills/lisa-session-manager/scripts/cli-stale-links.mjs +243 -0
  78. package/plugins/lisa-agy/skills/lisa-session-manager/scripts/cli-usage.mjs +60 -0
  79. package/plugins/lisa-agy/skills/lisa-session-manager/scripts/queue-github.mjs +68 -8
  80. package/plugins/lisa-agy/skills/lisa-session-manager/scripts/session-manager.mjs +49 -0
  81. package/plugins/lisa-agy/skills/lisa-session-manager/scripts/stale-links-github.mjs +196 -0
  82. package/plugins/lisa-agy/skills/lisa-session-manager/scripts/stale-links-state.mjs +173 -0
  83. package/plugins/lisa-cdk/.claude-plugin/plugin.json +1 -1
  84. package/plugins/lisa-cdk/.codex-plugin/plugin.json +1 -1
  85. package/plugins/lisa-cdk-agy/plugin.json +1 -1
  86. package/plugins/lisa-cdk-copilot/.claude-plugin/plugin.json +1 -1
  87. package/plugins/lisa-cdk-cursor/.claude-plugin/plugin.json +1 -1
  88. package/plugins/lisa-cdk-devin/.claude-plugin/plugin.json +1 -1
  89. package/plugins/lisa-cdk-devin/.devin-plugin/plugin.json +1 -1
  90. package/plugins/lisa-copilot/.claude-plugin/plugin.json +1 -1
  91. package/plugins/lisa-copilot/scripts/ready-queue-order.mjs +99 -25
  92. package/plugins/lisa-copilot/scripts/stale-blocker-comment.mjs +185 -0
  93. package/plugins/lisa-copilot/scripts/stale-blocker-confirm.mjs +130 -0
  94. package/plugins/lisa-copilot/scripts/stale-blocker-edges.mjs +466 -0
  95. package/plugins/lisa-copilot/scripts/stale-blocker-pending.mjs +257 -0
  96. package/plugins/lisa-copilot/scripts/stale-blocker-restore.mjs +180 -0
  97. package/plugins/lisa-copilot/scripts/stale-blocker-summary.mjs +222 -0
  98. package/plugins/lisa-copilot/scripts/stale-blocker-sweep.mjs +394 -0
  99. package/plugins/lisa-copilot/scripts/stale-blocker-verify.mjs +193 -0
  100. package/plugins/lisa-copilot/skills/lisa-atlassian-access/SKILL.md +1 -0
  101. package/plugins/lisa-copilot/skills/lisa-github-build-intake/SKILL.md +2 -7
  102. package/plugins/lisa-copilot/skills/lisa-jira-build-intake/SKILL.md +2 -0
  103. package/plugins/lisa-copilot/skills/lisa-linear-access/SKILL.md +44 -0
  104. package/plugins/lisa-copilot/skills/lisa-linear-build-intake/SKILL.md +2 -0
  105. package/plugins/lisa-copilot/skills/lisa-session-manager/SKILL.md +127 -2
  106. package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/cli-queue.mjs +90 -20
  107. package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/cli-stale-links-results.mjs +254 -0
  108. package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/cli-stale-links.mjs +243 -0
  109. package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/cli-usage.mjs +60 -0
  110. package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/queue-github.mjs +68 -8
  111. package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/session-manager.mjs +49 -0
  112. package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/stale-links-github.mjs +196 -0
  113. package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/stale-links-state.mjs +173 -0
  114. package/plugins/lisa-cursor/.claude-plugin/plugin.json +1 -1
  115. package/plugins/lisa-cursor/scripts/ready-queue-order.mjs +99 -25
  116. package/plugins/lisa-cursor/scripts/stale-blocker-comment.mjs +185 -0
  117. package/plugins/lisa-cursor/scripts/stale-blocker-confirm.mjs +130 -0
  118. package/plugins/lisa-cursor/scripts/stale-blocker-edges.mjs +466 -0
  119. package/plugins/lisa-cursor/scripts/stale-blocker-pending.mjs +257 -0
  120. package/plugins/lisa-cursor/scripts/stale-blocker-restore.mjs +180 -0
  121. package/plugins/lisa-cursor/scripts/stale-blocker-summary.mjs +222 -0
  122. package/plugins/lisa-cursor/scripts/stale-blocker-sweep.mjs +394 -0
  123. package/plugins/lisa-cursor/scripts/stale-blocker-verify.mjs +193 -0
  124. package/plugins/lisa-cursor/skills/lisa-atlassian-access/SKILL.md +1 -0
  125. package/plugins/lisa-cursor/skills/lisa-github-build-intake/SKILL.md +2 -7
  126. package/plugins/lisa-cursor/skills/lisa-jira-build-intake/SKILL.md +2 -0
  127. package/plugins/lisa-cursor/skills/lisa-linear-access/SKILL.md +44 -0
  128. package/plugins/lisa-cursor/skills/lisa-linear-build-intake/SKILL.md +2 -0
  129. package/plugins/lisa-cursor/skills/lisa-session-manager/SKILL.md +127 -2
  130. package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/cli-queue.mjs +90 -20
  131. package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/cli-stale-links-results.mjs +254 -0
  132. package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/cli-stale-links.mjs +243 -0
  133. package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/cli-usage.mjs +60 -0
  134. package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/queue-github.mjs +68 -8
  135. package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/session-manager.mjs +49 -0
  136. package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/stale-links-github.mjs +196 -0
  137. package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/stale-links-state.mjs +173 -0
  138. package/plugins/lisa-devin/.claude-plugin/plugin.json +1 -1
  139. package/plugins/lisa-devin/.devin-plugin/plugin.json +1 -1
  140. package/plugins/lisa-devin/scripts/ready-queue-order.mjs +99 -25
  141. package/plugins/lisa-devin/scripts/stale-blocker-comment.mjs +185 -0
  142. package/plugins/lisa-devin/scripts/stale-blocker-confirm.mjs +130 -0
  143. package/plugins/lisa-devin/scripts/stale-blocker-edges.mjs +466 -0
  144. package/plugins/lisa-devin/scripts/stale-blocker-pending.mjs +257 -0
  145. package/plugins/lisa-devin/scripts/stale-blocker-restore.mjs +180 -0
  146. package/plugins/lisa-devin/scripts/stale-blocker-summary.mjs +222 -0
  147. package/plugins/lisa-devin/scripts/stale-blocker-sweep.mjs +394 -0
  148. package/plugins/lisa-devin/scripts/stale-blocker-verify.mjs +193 -0
  149. package/plugins/lisa-devin/skills/lisa-atlassian-access/SKILL.md +1 -0
  150. package/plugins/lisa-devin/skills/lisa-github-build-intake/SKILL.md +2 -7
  151. package/plugins/lisa-devin/skills/lisa-jira-build-intake/SKILL.md +2 -0
  152. package/plugins/lisa-devin/skills/lisa-linear-access/SKILL.md +44 -0
  153. package/plugins/lisa-devin/skills/lisa-linear-build-intake/SKILL.md +2 -0
  154. package/plugins/lisa-devin/skills/lisa-session-manager/SKILL.md +127 -2
  155. package/plugins/lisa-devin/skills/lisa-session-manager/scripts/cli-queue.mjs +90 -20
  156. package/plugins/lisa-devin/skills/lisa-session-manager/scripts/cli-stale-links-results.mjs +254 -0
  157. package/plugins/lisa-devin/skills/lisa-session-manager/scripts/cli-stale-links.mjs +243 -0
  158. package/plugins/lisa-devin/skills/lisa-session-manager/scripts/cli-usage.mjs +60 -0
  159. package/plugins/lisa-devin/skills/lisa-session-manager/scripts/queue-github.mjs +68 -8
  160. package/plugins/lisa-devin/skills/lisa-session-manager/scripts/session-manager.mjs +49 -0
  161. package/plugins/lisa-devin/skills/lisa-session-manager/scripts/stale-links-github.mjs +196 -0
  162. package/plugins/lisa-devin/skills/lisa-session-manager/scripts/stale-links-state.mjs +173 -0
  163. package/plugins/lisa-expo/.claude-plugin/plugin.json +1 -1
  164. package/plugins/lisa-expo/.codex-plugin/plugin.json +1 -1
  165. package/plugins/lisa-expo-agy/plugin.json +1 -1
  166. package/plugins/lisa-expo-copilot/.claude-plugin/plugin.json +1 -1
  167. package/plugins/lisa-expo-cursor/.claude-plugin/plugin.json +1 -1
  168. package/plugins/lisa-expo-devin/.claude-plugin/plugin.json +1 -1
  169. package/plugins/lisa-expo-devin/.devin-plugin/plugin.json +1 -1
  170. package/plugins/lisa-harper-fabric/.claude-plugin/plugin.json +1 -1
  171. package/plugins/lisa-harper-fabric/.codex-plugin/plugin.json +1 -1
  172. package/plugins/lisa-harper-fabric-agy/plugin.json +1 -1
  173. package/plugins/lisa-harper-fabric-copilot/.claude-plugin/plugin.json +1 -1
  174. package/plugins/lisa-harper-fabric-cursor/.claude-plugin/plugin.json +1 -1
  175. package/plugins/lisa-harper-fabric-devin/.claude-plugin/plugin.json +1 -1
  176. package/plugins/lisa-harper-fabric-devin/.devin-plugin/plugin.json +1 -1
  177. package/plugins/lisa-nestjs/.claude-plugin/plugin.json +1 -1
  178. package/plugins/lisa-nestjs/.codex-plugin/plugin.json +1 -1
  179. package/plugins/lisa-nestjs-agy/plugin.json +1 -1
  180. package/plugins/lisa-nestjs-copilot/.claude-plugin/plugin.json +1 -1
  181. package/plugins/lisa-nestjs-cursor/.claude-plugin/plugin.json +1 -1
  182. package/plugins/lisa-nestjs-devin/.claude-plugin/plugin.json +1 -1
  183. package/plugins/lisa-nestjs-devin/.devin-plugin/plugin.json +1 -1
  184. package/plugins/lisa-phaser/.claude-plugin/plugin.json +1 -1
  185. package/plugins/lisa-phaser/.codex-plugin/plugin.json +1 -1
  186. package/plugins/lisa-phaser-agy/plugin.json +1 -1
  187. package/plugins/lisa-phaser-copilot/.claude-plugin/plugin.json +1 -1
  188. package/plugins/lisa-phaser-cursor/.claude-plugin/plugin.json +1 -1
  189. package/plugins/lisa-phaser-devin/.claude-plugin/plugin.json +1 -1
  190. package/plugins/lisa-phaser-devin/.devin-plugin/plugin.json +1 -1
  191. package/plugins/lisa-rails/.claude-plugin/plugin.json +1 -1
  192. package/plugins/lisa-rails/.codex-plugin/plugin.json +1 -1
  193. package/plugins/lisa-rails-agy/plugin.json +1 -1
  194. package/plugins/lisa-rails-copilot/.claude-plugin/plugin.json +1 -1
  195. package/plugins/lisa-rails-cursor/.claude-plugin/plugin.json +1 -1
  196. package/plugins/lisa-rails-devin/.claude-plugin/plugin.json +1 -1
  197. package/plugins/lisa-rails-devin/.devin-plugin/plugin.json +1 -1
  198. package/plugins/lisa-typescript/.claude-plugin/plugin.json +1 -1
  199. package/plugins/lisa-typescript/.codex-plugin/plugin.json +1 -1
  200. package/plugins/lisa-typescript-agy/plugin.json +1 -1
  201. package/plugins/lisa-typescript-copilot/.claude-plugin/plugin.json +1 -1
  202. package/plugins/lisa-typescript-cursor/.claude-plugin/plugin.json +1 -1
  203. package/plugins/lisa-typescript-devin/.claude-plugin/plugin.json +1 -1
  204. package/plugins/lisa-typescript-devin/.devin-plugin/plugin.json +1 -1
  205. package/plugins/lisa-wiki/.claude-plugin/plugin.json +1 -1
  206. package/plugins/lisa-wiki/.codex-plugin/plugin.json +1 -1
  207. package/plugins/lisa-wiki-agy/plugin.json +1 -1
  208. package/plugins/lisa-wiki-copilot/.claude-plugin/plugin.json +1 -1
  209. package/plugins/lisa-wiki-cursor/.claude-plugin/plugin.json +1 -1
  210. package/plugins/lisa-wiki-devin/.claude-plugin/plugin.json +1 -1
  211. package/plugins/lisa-wiki-devin/.devin-plugin/plugin.json +1 -1
  212. package/plugins/src/base/scripts/ready-queue-order.mjs +99 -25
  213. package/plugins/src/base/scripts/stale-blocker-comment.mjs +185 -0
  214. package/plugins/src/base/scripts/stale-blocker-confirm.mjs +130 -0
  215. package/plugins/src/base/scripts/stale-blocker-edges.mjs +466 -0
  216. package/plugins/src/base/scripts/stale-blocker-pending.mjs +257 -0
  217. package/plugins/src/base/scripts/stale-blocker-restore.mjs +180 -0
  218. package/plugins/src/base/scripts/stale-blocker-summary.mjs +222 -0
  219. package/plugins/src/base/scripts/stale-blocker-sweep.mjs +394 -0
  220. package/plugins/src/base/scripts/stale-blocker-verify.mjs +193 -0
  221. package/plugins/src/base/skills/lisa-atlassian-access/SKILL.md +1 -0
  222. package/plugins/src/base/skills/lisa-github-build-intake/SKILL.md +2 -7
  223. package/plugins/src/base/skills/lisa-jira-build-intake/SKILL.md +2 -0
  224. package/plugins/src/base/skills/lisa-linear-access/SKILL.md +44 -0
  225. package/plugins/src/base/skills/lisa-linear-build-intake/SKILL.md +2 -0
  226. package/plugins/src/base/skills/lisa-session-manager/SKILL.md +127 -2
  227. package/plugins/src/base/skills/lisa-session-manager/scripts/cli-queue.mjs +90 -20
  228. package/plugins/src/base/skills/lisa-session-manager/scripts/cli-stale-links-results.mjs +254 -0
  229. package/plugins/src/base/skills/lisa-session-manager/scripts/cli-stale-links.mjs +243 -0
  230. package/plugins/src/base/skills/lisa-session-manager/scripts/cli-usage.mjs +60 -0
  231. package/plugins/src/base/skills/lisa-session-manager/scripts/queue-github.mjs +68 -8
  232. package/plugins/src/base/skills/lisa-session-manager/scripts/session-manager.mjs +49 -0
  233. package/plugins/src/base/skills/lisa-session-manager/scripts/stale-links-github.mjs +196 -0
  234. package/plugins/src/base/skills/lisa-session-manager/scripts/stale-links-state.mjs +173 -0
  235. package/scripts/record-npm-update-dual-lock-seed.mjs +203 -0
  236. package/scripts/two-channel-couplings.json +1 -1
  237. package/typescript/copy-overwrite/.prettierignore +1 -0
@@ -0,0 +1,394 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Plan one cycle's clean-up of stale "blocked by" links (CodySwannGT/lisa#5065).
4
+ *
5
+ * A stale link is a "blocked by" relationship on an open item whose blocker
6
+ * is resolved (`stale-blocker-edges.mjs` decides that). Left in place it makes
7
+ * finished work look like it is still holding the queue, and an operator who
8
+ * sees every item "waiting on" something cannot tell which ones really are.
9
+ *
10
+ * This module writes nothing. It returns, per item, the vendor action that
11
+ * removes each stale link, the GitHub body with just those `Blocked by` refs
12
+ * taken out, and one plain-English comment a non-technical operator can read.
13
+ * The caller (the session manager's Reconcile step, or any agent's intake)
14
+ * performs each action through its vendor access layer and reads it back.
15
+ *
16
+ * Never touched: a blocker that is still open, one in another project or
17
+ * repository, and one that could not be read (reported instead). An item in
18
+ * the blocked role is left to the Blocked sweep, which decides by branch
19
+ * containment (`blocker-edge-resolution.mjs`) and escalates a cancelled
20
+ * blocker rather than dropping it. Outside that role intake already ignores a
21
+ * resolved blocker, so removing the link only removes a false signal.
22
+ *
23
+ * Idempotent: each comment carries one `[lisa-stale-blocker-link]` marker per
24
+ * blocker. The caller posts it only after the removal reads back, so a marker
25
+ * proves the link was removed once. A link that is back after that was put
26
+ * back by a person; it is kept and reported, never removed twice.
27
+ * @module stale-blocker-sweep
28
+ */
29
+
30
+ import {
31
+ blockerResolution,
32
+ isRemovable,
33
+ githubBlockerEdges,
34
+ isResolved,
35
+ jiraBlockerEdges,
36
+ linearBlockerEdges,
37
+ removeBlockedByRefs,
38
+ } from "./stale-blocker-edges.mjs";
39
+ import {
40
+ commentsOf,
41
+ formatStaleLinkComment,
42
+ markedBlockers,
43
+ staleLinkCommentAdf,
44
+ } from "./stale-blocker-comment.mjs";
45
+ import {
46
+ normalizeGithubIssue,
47
+ normalizeJiraIssue,
48
+ normalizeLinearIssue,
49
+ } from "./ready-queue-order.mjs";
50
+ import { tallySweep } from "./stale-blocker-summary.mjs";
51
+
52
+ export {
53
+ STALE_LINK_MARKER,
54
+ STALE_LINK_POSTERS,
55
+ formatStaleLinkComment,
56
+ markerLine,
57
+ staleLinkCommentAdf,
58
+ } from "./stale-blocker-comment.mjs";
59
+ export {
60
+ summarizeStaleLinkSweep,
61
+ summarizeVerifiedSweep,
62
+ } from "./stale-blocker-summary.mjs";
63
+
64
+ /**
65
+ * One item's planned clean-up.
66
+ * @typedef {object} StaleLinkPlan
67
+ * @property {string} ref - The item
68
+ * @property {{ op: string, linkId?: string, relationId?: string, endpoint?: string }[]} actions - Removals to perform
69
+ * @property {string | null} body - GitHub body with the stale refs taken out, or null
70
+ * @property {string[]} removed - Blocker refs whose links go
71
+ * @property {string} comment - The one operator comment, posted after read-back
72
+ * @property {{ type: "doc", version: 1, content: object[] } | null} commentAdf - The same comment as ADF, for Jira; null elsewhere
73
+ * @property {number} remainingBlockers - Links left that still hold the item (open or unreadable)
74
+ * @property {boolean} becomesClaimable - A ready leaf item with nothing left holding it
75
+ * @property {string[]} edges - The planned links by identity ({@link edgeIdentity})
76
+ * @property {{ blockerRef: string, source: string, actionId: string, linkType?: string }[]} links - The planned links, recreatable
77
+ * @property {{ stale: {blockerRef: string, verdict: string}[], real: {blockerRef: string, verdict: string}[], crossProject: {blockerRef: string, verdict: string}[], inaccessible: {blockerRef: string, verdict: string}[] }} render - The judged links the comment describes
78
+ */
79
+
80
+ /** Items cleaned per cycle by default; the rest wait for the next cycle. */
81
+ export const DEFAULT_MAX_STALE_ITEMS = 10;
82
+
83
+ /**
84
+ * @param {unknown} value
85
+ * @returns {string}
86
+ */
87
+ const text = value => (typeof value === "string" ? value : "");
88
+
89
+ /**
90
+ * One raw item in the shape the plan judges.
91
+ * @param {string} tracker - `github`, `jira` or `linear`
92
+ * @param {Record<string, any>} raw
93
+ * @returns {{ ref: string, project: string, names: string[], edges: object[], body: string, repo: string, comments: object[], statusKnown: boolean, closed: boolean, relationsRead: boolean, container: boolean }}
94
+ */
95
+ export function normalizeStaleLinkItem(tracker, raw) {
96
+ return { ...itemShape(tracker, raw), ...itemFacts(tracker, raw) };
97
+ }
98
+
99
+ /** Linear state types that mean the item itself is finished. */
100
+ const LINEAR_CLOSED_TYPES = new Set(["completed", "canceled"]);
101
+
102
+ /**
103
+ * What the sweep needs to know about the item itself, beyond its links:
104
+ * - `closed`: finished since it was listed; confirm writes nothing to it.
105
+ * - `relationsRead`: the read carried its blocker relation list at all. A
106
+ * read without one cannot show a link is gone, so nothing is confirmed
107
+ * from it (a present but empty list is a real "none left").
108
+ * - `container`: the queue's own container rule, so "ready to start" means
109
+ * what the queue will actually offer.
110
+ * @param {string} tracker
111
+ * @param {Record<string, any>} raw
112
+ * @returns {{ closed: boolean, relationsRead: boolean, container: boolean }}
113
+ */
114
+ function itemFacts(tracker, raw) {
115
+ if (tracker === "github") {
116
+ const repo = text(raw?.repo).toLowerCase();
117
+ return {
118
+ closed: text(raw?.state).toLowerCase() === "closed",
119
+ relationsRead:
120
+ isList(raw?.nativeBlockers) &&
121
+ Boolean(raw?.bodyBlockers) &&
122
+ typeof raw.bodyBlockers === "object",
123
+ container:
124
+ normalizeGithubIssue(raw ?? {}, { repo })?.isContainer === true,
125
+ };
126
+ }
127
+ if (tracker === "jira") {
128
+ return {
129
+ closed: raw?.fields?.status?.statusCategory?.key === "done",
130
+ relationsRead: Array.isArray(raw?.fields?.issuelinks),
131
+ container: normalizeJiraIssue(raw ?? {}).isContainer === true,
132
+ };
133
+ }
134
+ return {
135
+ closed: LINEAR_CLOSED_TYPES.has(text(raw?.state?.type).toLowerCase()),
136
+ relationsRead: isList(raw?.inverseRelations),
137
+ container: normalizeLinearIssue(raw ?? {}).isContainer === true,
138
+ };
139
+ }
140
+
141
+ /**
142
+ * @param {unknown} value
143
+ * @returns {boolean} An array, or a `{nodes: [...]}` connection
144
+ */
145
+ const isList = value =>
146
+ Array.isArray(value) || Array.isArray(/** @type {any} */ (value)?.nodes);
147
+
148
+ /**
149
+ * The item's ref, project, status names, edges, body and comments.
150
+ * @param {string} tracker
151
+ * @param {Record<string, any>} raw
152
+ * @returns {{ ref: string, project: string, names: string[], edges: object[], body: string, repo: string, comments: object[], statusKnown: boolean }}
153
+ */
154
+ function itemShape(tracker, raw) {
155
+ if (tracker === "github") {
156
+ const repo = text(raw?.repo).toLowerCase();
157
+ return {
158
+ ref: `${repo}#${raw?.number}`,
159
+ project: repo,
160
+ names: (raw?.labels ?? []).map(l => text(l?.name ?? l).toLowerCase()),
161
+ edges: githubBlockerEdges(raw),
162
+ body: text(raw?.body),
163
+ repo,
164
+ comments: commentsOf(raw),
165
+ // A GitHub item's labels are its status, and having none is a real
166
+ // answer ("not in any lane").
167
+ statusKnown: true,
168
+ };
169
+ }
170
+ const ref = tracker === "jira" ? text(raw?.key) : text(raw?.identifier);
171
+ const state = tracker === "jira" ? raw?.fields?.status : raw?.state;
172
+ const names = [text(state?.name).toLowerCase()].filter(Boolean);
173
+ return {
174
+ ref,
175
+ project:
176
+ text(raw?.team?.key).toUpperCase() || ref.split("-")[0].toUpperCase(),
177
+ names,
178
+ edges: tracker === "jira" ? jiraBlockerEdges(raw) : linearBlockerEdges(raw),
179
+ body: "",
180
+ repo: "",
181
+ comments: commentsOf(raw),
182
+ // Without its own status the item might be Blocked, and a Blocked item's
183
+ // links belong to the Blocked sweep, so an unread status removes nothing.
184
+ statusKnown: names.length > 0,
185
+ };
186
+ }
187
+
188
+ /**
189
+ * Sort one item's edges into what the sweep may remove and what it keeps.
190
+ * @param {ReturnType<typeof normalizeStaleLinkItem>} item
191
+ * @param {readonly string[]} doneRoles - Terminal done roles: a link to one is stale
192
+ * @param {readonly string[]} [landedRoles] - Intermediate done roles: holds nothing, link kept
193
+ * @returns {{ stale: object[], real: object[], crossProject: object[], inaccessible: object[], keptByPerson: object[], landed: object[] }}
194
+ */
195
+ export function sortEdges(item, doneRoles, landedRoles = []) {
196
+ const marked = markedBlockers(item.comments);
197
+ const out = {
198
+ stale: [],
199
+ real: [],
200
+ crossProject: [],
201
+ inaccessible: [],
202
+ keptByPerson: [],
203
+ landed: [],
204
+ };
205
+ for (const edge of item.edges) {
206
+ const verdict = blockerResolution(
207
+ edge,
208
+ doneRoles,
209
+ item.project,
210
+ landedRoles
211
+ );
212
+ const judged = { ...edge, verdict };
213
+ if (verdict === "inaccessible") out.inaccessible.push(judged);
214
+ else if (edge.project.toLowerCase() !== item.project.toLowerCase())
215
+ out.crossProject.push(judged);
216
+ else if (!isResolved(verdict)) out.real.push(judged);
217
+ // Landed (an intermediate done rung): holds nothing, but the blocker is
218
+ // not finished, so its link stays.
219
+ else if (!isRemovable(verdict)) out.landed.push(judged);
220
+ else if (marked.has(edge.blockerRef)) out.keptByPerson.push(judged);
221
+ else out.stale.push(judged);
222
+ }
223
+ return out;
224
+ }
225
+
226
+ /**
227
+ * The vendor action that removes one stale edge.
228
+ * @param {string} tracker
229
+ * @param {Record<string, any>} edge
230
+ * @param {ReturnType<typeof normalizeStaleLinkItem>} item
231
+ * @returns {Record<string, unknown> | null} null for a body ref (the body edit covers it)
232
+ */
233
+ function removalAction(tracker, edge, item) {
234
+ if (tracker === "jira") return { op: "unlink", linkId: edge.actionId };
235
+ if (tracker === "linear") {
236
+ return { op: "delete-relation", relationId: edge.actionId };
237
+ }
238
+ if (edge.source === "github-body") return null;
239
+ const number = item.ref.split("#")[1];
240
+ return {
241
+ op: "delete-dependency",
242
+ endpoint: `repos/${item.repo}/issues/${number}/dependencies/blocked_by/${edge.actionId}`,
243
+ };
244
+ }
245
+
246
+ /**
247
+ * One link's identity: where it lives and, for a vendor relation, its id.
248
+ * @param {{ blockerRef: string, source?: string, actionId?: string }} edge
249
+ * @returns {string}
250
+ */
251
+ export const edgeIdentity = edge =>
252
+ [text(edge.source), text(edge.actionId), edge.blockerRef].join("|");
253
+
254
+ /**
255
+ * The parts of a judged edge the comment needs.
256
+ * @param {{ blockerRef: string, verdict: string }} edge
257
+ * @returns {{ blockerRef: string, verdict: string }}
258
+ */
259
+ const judgedRef = edge => ({
260
+ blockerRef: edge.blockerRef,
261
+ verdict: edge.verdict,
262
+ });
263
+
264
+ /**
265
+ * How many of an item's links still hold it up: an open blocker (in this
266
+ * project or another) or one that could not be read. A resolved link the
267
+ * sweep leaves in place, cross-project or put back by a person, holds
268
+ * nothing, exactly as `countUnresolvedBlockers` counts it for the queue.
269
+ * @param {ReturnType<typeof sortEdges>} sorted
270
+ * @returns {number}
271
+ */
272
+ export const unresolvedCount = sorted =>
273
+ sorted.real.length +
274
+ sorted.inaccessible.length +
275
+ sorted.crossProject.filter(edge => !isResolved(edge.verdict)).length;
276
+
277
+ /**
278
+ * The plan for one item with at least one stale edge.
279
+ * @param {{ tracker: string, item: ReturnType<typeof normalizeStaleLinkItem>, sorted: ReturnType<typeof sortEdges>, ready: boolean, poster?: string, posterName?: string }} input
280
+ * @returns {StaleLinkPlan}
281
+ */
282
+ export function itemPlan({ tracker, item, sorted, ready, poster, posterName }) {
283
+ const bodyRefs = sorted.stale
284
+ .filter(edge => edge.source === "github-body")
285
+ .map(edge => edge.blockerRef);
286
+ const holds = unresolvedCount(sorted);
287
+ const comment = formatStaleLinkComment(sorted, poster, posterName);
288
+ return {
289
+ ref: item.ref,
290
+ actions: sorted.stale
291
+ .map(edge => removalAction(tracker, edge, item))
292
+ .filter(Boolean),
293
+ body:
294
+ bodyRefs.length > 0
295
+ ? removeBlockedByRefs(item.body, bodyRefs, item.repo)
296
+ : null,
297
+ removed: [...new Set(sorted.stale.map(edge => edge.blockerRef))],
298
+ comment,
299
+ // Jira Cloud's REST v3 comment body is ADF; the other trackers take text.
300
+ commentAdf: tracker === "jira" ? staleLinkCommentAdf(comment) : null,
301
+ remainingBlockers: holds,
302
+ // What the comment describes, so a writer can re-render it for only the
303
+ // removals that read back as done (`stale-blocker-verify.mjs`).
304
+ render: {
305
+ stale: sorted.stale.map(edge => judgedRef(edge)),
306
+ real: sorted.real.map(edge => judgedRef(edge)),
307
+ crossProject: sorted.crossProject.map(edge => judgedRef(edge)),
308
+ inaccessible: sorted.inaccessible.map(edge => judgedRef(edge)),
309
+ },
310
+ // The removals the confirm step may still make, by relationship, so a
311
+ // link added since the plan to the same blocker is never swept up.
312
+ edges: sorted.stale.map(edgeIdentity),
313
+ // Enough of each planned link to recreate it if its blocker reopens
314
+ // between the confirm and the delete (`stale-blocker-restore.mjs`).
315
+ links: sorted.stale.map(edge => ({
316
+ blockerRef: edge.blockerRef,
317
+ source: edge.source,
318
+ actionId: edge.actionId,
319
+ ...(edge.linkType ? { linkType: edge.linkType } : {}),
320
+ })),
321
+ becomesClaimable: ready && holds === 0 && !item.container,
322
+ };
323
+ }
324
+
325
+ /**
326
+ * Whether an item is in the ready role, and whether in the blocked role.
327
+ * @param {ReturnType<typeof normalizeStaleLinkItem>} item
328
+ * @param {{ ready?: string, blocked?: string } | undefined} roles
329
+ * @returns {{ ready: boolean, inBlocked: boolean }}
330
+ */
331
+ export function itemRoles(item, roles) {
332
+ const ready = text(roles?.ready).toLowerCase();
333
+ const blocked = text(roles?.blocked).toLowerCase();
334
+ return {
335
+ ready: ready !== "" && item.names.includes(ready),
336
+ inBlocked: blocked !== "" && item.names.includes(blocked),
337
+ };
338
+ }
339
+
340
+ /**
341
+ * Plan this cycle's stale-link clean-up. Writes nothing.
342
+ * @param {{
343
+ * tracker: "github" | "jira" | "linear",
344
+ * items: readonly Record<string, any>[],
345
+ * doneRoles: readonly string[],
346
+ * landedRoles?: readonly string[],
347
+ * roles: { ready?: string, blocked?: string },
348
+ * max?: number,
349
+ * poster?: "session-manager" | "build-intake",
350
+ * posterName?: string,
351
+ * failures?: Record<string, { attempts?: number }>,
352
+ * }} input - `failures` is the record of items whose planned removals did
353
+ * not happen (`stale-blocker-pending.mjs`); they go after every other
354
+ * candidate, so a removal that keeps failing cannot spend the cap
355
+ * @returns {{ plans: StaleLinkPlan[], deferred: string[], report: import("./stale-blocker-summary.mjs").StaleLinkReport }}
356
+ */
357
+ export function planStaleLinkSweep(input) {
358
+ const max = input.max ?? DEFAULT_MAX_STALE_ITEMS;
359
+ const failed = ref => Number(input.failures?.[ref]?.attempts ?? 0);
360
+ const judged = (input.items ?? [])
361
+ .map(raw => normalizeStaleLinkItem(input.tracker, raw))
362
+ .map(item => ({
363
+ item,
364
+ ...itemRoles(item, input.roles),
365
+ sorted: sortEdges(item, input.doneRoles, input.landedRoles),
366
+ }));
367
+ const candidates = judged
368
+ .filter(
369
+ entry =>
370
+ // An item whose blocker list could not be read (a failed native
371
+ // dependency read) plans nothing: it is reported, never touched.
372
+ entry.item.relationsRead &&
373
+ entry.item.statusKnown &&
374
+ !entry.inBlocked &&
375
+ entry.sorted.stale.length > 0
376
+ )
377
+ .sort(
378
+ (a, b) =>
379
+ failed(a.item.ref) - failed(b.item.ref) ||
380
+ Number(b.ready) - Number(a.ready) ||
381
+ a.item.ref.localeCompare(b.item.ref)
382
+ );
383
+ const taken = candidates.slice(0, Math.max(0, max));
384
+ const plans = taken.map(entry =>
385
+ itemPlan({
386
+ tracker: input.tracker,
387
+ ...entry,
388
+ poster: input.poster,
389
+ posterName: input.posterName,
390
+ })
391
+ );
392
+ const deferred = candidates.slice(taken.length).map(entry => entry.item.ref);
393
+ return { plans, deferred, report: tallySweep(judged, plans, deferred) };
394
+ }
@@ -0,0 +1,193 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * What a stale-link clean-up actually did, read back from the tracker after
4
+ * the writes (CodySwannGT/lisa#5065).
5
+ *
6
+ * The marker comment says "I removed the link", and a later cycle trusts the
7
+ * marker: a link that is back after its marker was posted is treated as put
8
+ * back by a person and never removed again. So a marker may be posted ONLY
9
+ * for a removal the read-back confirms. A deletion that failed (an outage, or
10
+ * an MCP-only substrate that cannot delete links) leaves its link in place
11
+ * with no marker, and the next cycle simply plans it again.
12
+ *
13
+ * A confirmed removal whose comment then fails to post is not lost: the
14
+ * writer keeps it as a PENDING comment (`stale-blocker-pending.mjs`) and
15
+ * retries just that comment on its own. Its link is already gone, so no
16
+ * later plan would ever see it again, and it is never mistaken for a link a
17
+ * person kept.
18
+ * @module stale-blocker-verify
19
+ */
20
+
21
+ import {
22
+ formatStaleLinkComment,
23
+ markedBlockers,
24
+ staleLinkCommentAdf,
25
+ } from "./stale-blocker-comment.mjs";
26
+ import { isResolved } from "./stale-blocker-edges.mjs";
27
+ import { splitReopened, verdictNow } from "./stale-blocker-restore.mjs";
28
+ import {
29
+ itemRoles,
30
+ normalizeStaleLinkItem,
31
+ sortEdges,
32
+ unresolvedCount,
33
+ } from "./stale-blocker-sweep.mjs";
34
+
35
+ /**
36
+ * The result of reading one item back after its writes.
37
+ * @typedef {object} StaleLinkResult
38
+ * @property {string} ref - The item
39
+ * @property {string[]} confirmed - Planned removals the read-back shows gone
40
+ * @property {string[]} stillPresent - Planned removals still on the item
41
+ * @property {{ blockerRef: string, verdict: string }[]} restored - Removed links whose blocker reopened (or could not be read) after the confirm: put back, no marker
42
+ * @property {object[]} restore - The vendor actions that put them back
43
+ * @property {string | null} comment - The comment for the confirmed removals only, or null
44
+ * @property {object | null} commentAdf - The same as ADF for Jira, else null
45
+ * @property {boolean} becameReady - A ready leaf item that nothing holds any more
46
+ * @property {{ real: number, inaccessible: string[] }} blockersBefore - The plan's view of what still held the item
47
+ * @property {{ real: number, inaccessible: string[] }} blockersAfter - The read-back's view, with the later blocker reads applied
48
+ */
49
+
50
+ /** Buckets whose edges a later, unresolved verdict moves into `real`. */
51
+ const KEPT_BUCKETS = ["stale", "crossProject", "keptByPerson", "landed"];
52
+
53
+ /**
54
+ * Apply the blocker reads taken AFTER the item read-back to the links still
55
+ * on the item: a planned removal whose delete failed may have reopened since
56
+ * the read-back, and then it holds the item again. Membership stays as the
57
+ * read-back shows it; only verdicts move.
58
+ * @param {ReturnType<typeof sortEdges>} sorted
59
+ * @param {Map<string, string>} later - Blocker ref -> verdict now
60
+ * @returns {ReturnType<typeof sortEdges>}
61
+ */
62
+ function withLaterVerdicts(sorted, later) {
63
+ const moved = { real: [], inaccessible: [] };
64
+ const out = { ...sorted };
65
+ for (const bucket of KEPT_BUCKETS) {
66
+ out[bucket] = (sorted[bucket] ?? []).filter(edge => {
67
+ const verdict = later.get(edge.blockerRef);
68
+ if (verdict === undefined || isResolved(verdict)) return true;
69
+ const judged = { ...edge, verdict };
70
+ if (verdict === "inaccessible") moved.inaccessible.push(judged);
71
+ else moved.real.push(judged);
72
+ return false;
73
+ });
74
+ }
75
+ return {
76
+ ...out,
77
+ real: [...sorted.real, ...moved.real],
78
+ inaccessible: [...sorted.inaccessible, ...moved.inaccessible],
79
+ };
80
+ }
81
+
82
+ /**
83
+ * @param {{ real?: readonly object[], inaccessible?: readonly { blockerRef: string }[] }} groups
84
+ * @returns {{ real: number, inaccessible: string[] }}
85
+ */
86
+ const holding = groups => ({
87
+ real: (groups.real ?? []).length,
88
+ inaccessible: (groups.inaccessible ?? []).map(edge => edge.blockerRef),
89
+ });
90
+
91
+ /**
92
+ * Read one item back after its writes and say what is confirmed.
93
+ * @param {{
94
+ * tracker: "github" | "jira" | "linear",
95
+ * plan: { ref: string, removed: readonly string[], links?: readonly { blockerRef: string, source: string, actionId: string, linkType?: string }[], render: Record<string, { blockerRef: string, verdict: string }[]> },
96
+ * after: Record<string, any>,
97
+ * blockersNow: Record<string, Record<string, any> | null>,
98
+ * doneRoles: readonly string[],
99
+ * landedRoles?: readonly string[],
100
+ * roles: { ready?: string, blocked?: string },
101
+ * poster?: "session-manager" | "build-intake",
102
+ * posterName?: string,
103
+ * }} input - `after` is the raw item read after the writes, with its blockers
104
+ * @returns {StaleLinkResult}
105
+ */
106
+ export function verifyStaleLinkRemoval(input) {
107
+ const item = normalizeStaleLinkItem(input.tracker, input.after);
108
+ if (item.ref !== input.plan.ref) {
109
+ throw new Error(
110
+ `The read-back is ${item.ref}, but the plan is for ${input.plan.ref}.`
111
+ );
112
+ }
113
+ if (!item.relationsRead) {
114
+ // probe-direction: fail-closed — a read-back with no relation list would
115
+ // make every planned link look gone, so nothing is confirmed from it and
116
+ // the next cycle plans the removals again.
117
+ throw new Error(
118
+ `The read-back of ${item.ref} has no blocker relation list; read it with its links.`
119
+ );
120
+ }
121
+ if (!input.blockersNow || typeof input.blockersNow !== "object") {
122
+ // probe-direction: fail-closed — without each removed blocker read again
123
+ // after the delete, a blocker reopened in between cannot be told apart.
124
+ throw new Error(
125
+ `Verifying ${item.ref} needs each removed blocker as read after the delete (blockersNow).`
126
+ );
127
+ }
128
+ const present = new Set(item.edges.map(edge => edge.blockerRef));
129
+ const gone = input.plan.removed.filter(ref => !present.has(ref));
130
+ const stillPresent = input.plan.removed.filter(ref => present.has(ref));
131
+ const { confirmed, restored, restore } = splitReopened({
132
+ tracker: input.tracker,
133
+ item,
134
+ gone,
135
+ links: input.plan.links ?? [],
136
+ blockersNow: input.blockersNow,
137
+ doneRoles: input.doneRoles,
138
+ landedRoles: input.landedRoles,
139
+ });
140
+ // A comment already posted for a removal (its marker is live on the item:
141
+ // a saved plan verified again after it posted) is never owed twice.
142
+ const marked = markedBlockers(item.comments);
143
+ const done = new Set(confirmed.filter(ref => !marked.has(ref)));
144
+ const render = input.plan.render ?? {};
145
+ const later = new Map(
146
+ stillPresent
147
+ .filter(ref => Object.hasOwn(input.blockersNow, ref))
148
+ .map(ref => [
149
+ ref,
150
+ verdictNow(input.tracker, item, ref, input.blockersNow[ref], input),
151
+ ])
152
+ );
153
+ // The removed links keep their planned reasons; everything still on the
154
+ // item is described as the read-back shows it now, with the later blocker
155
+ // reads applied: the same view that decides `becameReady`.
156
+ const sorted = withLaterVerdicts(
157
+ sortEdges(item, input.doneRoles, input.landedRoles),
158
+ later
159
+ );
160
+ const comment =
161
+ done.size === 0
162
+ ? null
163
+ : formatStaleLinkComment(
164
+ {
165
+ stale: (render.stale ?? []).filter(e => done.has(e.blockerRef)),
166
+ real: sorted.real,
167
+ crossProject: sorted.crossProject,
168
+ inaccessible: sorted.inaccessible,
169
+ },
170
+ input.poster,
171
+ input.posterName
172
+ );
173
+ return {
174
+ ref: item.ref,
175
+ confirmed,
176
+ stillPresent,
177
+ restored,
178
+ restore,
179
+ comment,
180
+ commentAdf:
181
+ comment !== null && input.tracker === "jira"
182
+ ? staleLinkCommentAdf(comment)
183
+ : null,
184
+ becameReady:
185
+ confirmed.length > 0 &&
186
+ itemRoles(item, input.roles).ready &&
187
+ !item.container &&
188
+ restored.length === 0 &&
189
+ unresolvedCount(sorted) === 0,
190
+ blockersBefore: holding(render),
191
+ blockersAfter: holding(sorted),
192
+ };
193
+ }
@@ -370,6 +370,7 @@ Substrate column meanings (ordering per `credential-substrate-precedence`):
370
370
  | `comments key:<K>` (read; all comments, paginated) — **not** `comment`, which is the write | (not exposed) | `mcp__plugin_atlassian_atlassian__getJiraIssue` (comment field only; may be capped — page via curl when `total` exceeds what it returned) | `GET https://<SITE>/rest/api/3/issue/<K>/comment?startAt=<n>&maxResults=100&orderBy=created` |
371
371
  | `comment key:<K> body:<B>` | guarded fallback only: `acli jira workitem comment add --key <K> --body "<B>"` + post-read tenant assertion | `mcp__plugin_atlassian_atlassian__addCommentToJiraIssue` | `POST https://api.atlassian.com/ex/jira/<CLOUDID>/rest/api/3/issue/<K>/comment` |
372
372
  | `link from:<K> to:<K2> type:<T>` | guarded fallback only: `acli jira workitem link create --in <K> --out <K2> --type "<T>" --yes` + direction and tenant assertion (see direction note) | `mcp__plugin_atlassian_atlassian__createJiraIssueLink` | `POST https://api.atlassian.com/ex/jira/<CLOUDID>/rest/api/3/issueLink` |
373
+ | `unlink link-id:<ID>` — removes one issue link by its `issuelinks[].id` (the session manager's stale-blocker-link sweep, CodySwannGT/lisa#5065); read the ticket back and confirm the link is gone | (not exposed) | (not exposed: the Atlassian MCP has no link delete; on an MCP-only substrate report the link as not removed and leave it) | `DELETE https://api.atlassian.com/ex/jira/<CLOUDID>/rest/api/3/issueLink/<ID>` |
373
374
  | `remote-links key:<K>` | (not exposed) | `mcp__plugin_atlassian_atlassian__getJiraIssueRemoteIssueLinks` | `GET https://<SITE>/rest/api/3/issue/<K>/remotelink` |
374
375
  | `search-issues jql:<J>` | `acli jira workitem search --jql "<J>" --json` | `mcp__plugin_atlassian_atlassian__searchJiraIssuesUsingJql` | `POST https://<SITE>/rest/api/3/search/jql` |
375
376
  | `list-projects` | `acli jira project list --paginate --json` | `mcp__plugin_atlassian_atlassian__getVisibleJiraProjects` | `GET https://<SITE>/rest/api/3/project/search` |
@@ -489,14 +489,9 @@ This gate never blocks a legitimate flat Task/Bug: those have no open children a
489
489
 
490
490
  Resolve local `#123` references against the candidate issue's repo. Resolve qualified refs and GitHub issue URLs against their named repo. For each blocker, read the blocker issue's status labels with `gh issue view <number> --repo <owner>/<repo> --json labels,state`.
491
491
 
492
- Default cleared blocker labels for GitHub build intake are:
492
+ Judge each blocker with the one shared rule every tracker uses, never a GitHub-local copy: `githubBlockerEdges` and `countUnresolvedBlockers` from `scripts/stale-blocker-edges.mjs`, with `terminalDoneRoles` and `landedDoneRoles` reading the configured env-aware done labels from `.lisa.config.json` (CodySwannGT/lisa#5065). That covers native `blocked_by` dependencies (`gh api repos/<owner>/<repo>/issues/<number>/dependencies/blocked_by`, whose `repository_url` names each blocker's repo) and these body lines. A blocker is cleared when it is closed (including cancelled) or carries ANY configured done label (every env rung of the `done` map, for example `status:on-dev`, `status:on-stg` and `status:done`); an open blocker on any other label, and an inaccessible one, is active. The session manager's queue and stale-link sweep judge by the same function, so intake and the manager always agree. Run the stale-link clean-up below for this candidate FIRST, whether or not an active blocker remains: an item with one open and one closed blocker otherwise keeps the closed blocker's link until the open one clears. Only then, if any blocker is active, skip the candidate without changing lifecycle labels, without posting "Claimed", and without dispatching the lifecycle. Record it under "Skipped (active blockers)" in the summary and include the active blocker refs. Keep any dependency-hold comment idempotent with a `[claude-build-intake]` prefix.
493
493
 
494
- - `status:code-review`
495
- - `status:on-dev`
496
- - `status:on-stg`
497
- - `status:done`
498
-
499
- A blocker is active if it is open and has no cleared status label. Treat `status:ready`, `status:in-progress`, missing status labels, and inaccessible blockers as active. Closed blockers are cleared. If any blocker is active, skip the candidate without changing lifecycle labels, without posting "Claimed", and without dispatching the lifecycle. Record it under "Skipped (active blockers)" in the summary and include the active blocker refs. Keep any dependency-hold comment idempotent with a `[claude-build-intake]` prefix.
494
+ **Stale blocker links** (CodySwannGT/lisa#5065). Before the active-blocker skip above, and so before the claim, judge each "blocked by" edge of this item with the shared rule in `scripts/stale-blocker-edges.mjs` (`blockerResolution` against `terminalDoneRoles`, which reads the configured terminal done role from `.lisa.config.json`; never a hardcoded name). A blocker closed in the tracker, in that done role, or cancelled never holds the claim, and only those links are removed. A blocker in any other configured done label (an intermediate env rung such as `status:on-dev` or `status:on-stg`, from `landedDoneRoles`) has merged to a non-production environment: it does not hold the item, so dependents proceed, but it is not finished, so its link is never removed. The clean-up never claims: a candidate that still has an active blocker afterwards is skipped as above. On a runtime with the session manager running, its Reconcile step removes those links every cycle. Every other runtime (Codex, Cursor, OpenCode, Antigravity, Copilot, Devin) has no session manager, so intake does the same clean-up for this one item: pass its read bundle to `planStaleLinkSweep` from `scripts/stale-blocker-sweep.mjs` (`max: 1`, `poster: "build-intake"`, so the comment carries this skill's `[claude-build-intake]` prefix). Right before writing, re-read the item and each blocker it names and pass that fresh read to `confirmStaleLinkPlan` from `scripts/stale-blocker-confirm.mjs`, which keeps only links that are still stale and rebuilds a GitHub body from the fresh body; write nothing when its `plan` is null. Before any write, record the confirmed plan with `recordInFlight` from `scripts/stale-blocker-pending.mjs` in `.lisa/stale-links-inflight.json` (it refuses an item that still has an unverified entry, so an earlier plan's removed links are never overwritten: do not claim or clean that item until the entry is verified), and settle it with `settleInFlight` only once `verifyStaleLinkRemoval` has read the item back and every other record (pending comment, owed restores) is saved; an item with an in-flight entry is not claimed; when the read-back fails, count it with `failedInFlight` and leave the entry, and at the start of the next run verify each entry still there again (never repeat its deletes) before anything else. Perform the confirmed plan's actions with `gh api -X DELETE <endpoint>` for a native dependency and a `lisa-tracker-write` body update for a `Blocked by` line, then read the item back, and each removed blocker again, and pass both to `verifyStaleLinkRemoval` from `scripts/stale-blocker-verify.mjs` (`blockersNow`: `{<ref>: <the blocker as read now>}`). A removed link whose blocker reopened in between (or can no longer be read) comes back in `restored` with no marker: perform its `restore` actions straight away (`add-dependency` with `gh api -X POST <endpoint> -F issue_id=<issueId>`, `body` through `lisa-tracker-write`), record those links as owed with `recordRestores(owed, result, plan.links, now)` in `.lisa/stale-links-restores.json`, read the item back, and settle the links it shows present with `settleRestores(owed, ref, presentRefs)`; name each in the summary. While an item still owes a restore it is not claimed (it would look unblocked while its blocker is open): at the start of the next run re-read it, perform `restoreActions` for the links still missing, and settle again. Only that item waits; every other ready item is still claimed, and a failed plan, verify or comment holds nothing. Post a comment only for the removals it confirms: its `comment` covers only links the read-back shows gone, so no marker is ever posted for a link whose deletion failed, and that link is simply planned again next run. A confirmed removal whose comment fails to post is owed: record it with `addPending` from `scripts/stale-blocker-pending.mjs` in `.lisa/stale-links-pending.json`, retry each owed comment on its own at the start of the next run (settling that one entry with `settlePending(pending, ref, removed)` after it posts, or counting a failure with `failedPending(pending, ref, removed)`; an item can owe more than one comment, and each settles on its own), and list any still owed under "Errors" in the summary. On a runtime whose workspace does not survive between runs, that file is lost with it; the summary's Errors entry, which quotes the comment, is then the only record, and the gap is stated there. Report the stale-link line from `summarizeVerifiedSweep` (scripts/stale-blocker-summary.mjs) over the verified results, never the plan's summary. Its `[lisa-stale-blocker-link]` markers make a re-run post nothing new. An open, cross-project or unreadable blocker is never touched; an unreadable one is named in the summary. Items in `$BLOCKED` are not cleaned here: they belong to the containment check in `lisa-repair-intake`.
500
495
 
501
496
  #### 3b. Claim
502
497
 
@@ -378,6 +378,8 @@ Post via `lisa-atlassian-access` `operation: comment key: <TICKET> body: "<messa
378
378
 
379
379
  This gate never blocks a legitimate flat Task/Bug: those have no open children and a leaf type, so they fall straight through to the claim in 3b.
380
380
 
381
+ **Stale blocker links** (CodySwannGT/lisa#5065). Still before the claim, judge each "blocked by" edge of this item with the shared rule in `scripts/stale-blocker-edges.mjs` (`blockerResolution` against `terminalDoneRoles`, which reads the configured terminal done role from `.lisa.config.json`; never a hardcoded name). A blocker closed in the tracker, in that done role, or cancelled never holds the claim, and only those links are removed. A blocker in any other configured done status (an intermediate env rung such as `On Dev` or `On Stg`, from `landedDoneRoles`) has merged to a non-production environment: it does not hold the claim, but it is not finished, so its link is never removed. On a runtime with the session manager running, its Reconcile step removes those links every cycle. Every other runtime (Codex, Cursor, OpenCode, Antigravity, Copilot, Devin) has no session manager, so intake does the same clean-up for this one item: pass its read bundle to `planStaleLinkSweep` from `scripts/stale-blocker-sweep.mjs` (`max: 1`, `poster: "build-intake"`, so the comment carries this skill's `[claude-build-intake]` prefix). Right before writing, re-read the item and each blocker it names and pass that fresh read to `confirmStaleLinkPlan` from `scripts/stale-blocker-confirm.mjs`, which keeps only links that are still stale and rebuilds a GitHub body from the fresh body; write nothing when its `plan` is null. Before any write, record the confirmed plan with `recordInFlight` from `scripts/stale-blocker-pending.mjs` in `.lisa/stale-links-inflight.json` (it refuses an item that still has an unverified entry, so an earlier plan's removed links are never overwritten: do not claim or clean that item until the entry is verified), and settle it with `settleInFlight` only once `verifyStaleLinkRemoval` has read the item back and every other record (pending comment, owed restores) is saved; an item with an in-flight entry is not claimed; when the read-back fails, count it with `failedInFlight` and leave the entry, and at the start of the next run verify each entry still there again (never repeat its deletes) before anything else. Perform the confirmed plan's actions through `lisa-atlassian-access` (`unlink link-id:<id>`), then read the item back, and each removed blocker again, and pass both to `verifyStaleLinkRemoval` from `scripts/stale-blocker-verify.mjs` (`blockersNow`: `{<ref>: <the blocker as read now>}`). A removed link whose blocker reopened in between (or can no longer be read) comes back in `restored` with no marker: perform its `restore` actions straight away (`link` through `lisa-atlassian-access` `operation: link from:<from> to:<to> type:<type>`), record those links as owed with `recordRestores(owed, result, plan.links, now)` in `.lisa/stale-links-restores.json`, read the item back, and settle the links it shows present with `settleRestores(owed, ref, presentRefs)`; name each in the summary. While an item still owes a restore it is not claimed (it would look unblocked while its blocker is open): at the start of the next run re-read it, perform `restoreActions` for the links still missing, and settle again. Only that item waits; every other ready item is still claimed, and a failed plan, verify or comment holds nothing. Post a comment only for the removals it confirms: its `comment` (as its `commentAdf` document, because Jira Cloud's REST v3 comment body is ADF) covers only links the read-back shows gone, so no marker is ever posted for a link whose deletion failed, and that link is simply planned again next run. A confirmed removal whose comment fails to post is owed: record it with `addPending` from `scripts/stale-blocker-pending.mjs` in `.lisa/stale-links-pending.json`, retry each owed comment on its own at the start of the next run (settling that one entry with `settlePending(pending, ref, removed)` after it posts, or counting a failure with `failedPending(pending, ref, removed)`; an item can owe more than one comment, and each settles on its own), and list any still owed under "Errors" in the summary. On a runtime whose workspace does not survive between runs, that file is lost with it; the summary's Errors entry, which quotes the comment, is then the only record, and the gap is stated there. Report the stale-link line from `summarizeVerifiedSweep` (scripts/stale-blocker-summary.mjs) over the verified results, never the plan's summary. Its `[lisa-stale-blocker-link]` markers make a re-run post nothing new. An open, cross-project or unreadable blocker is never touched; an unreadable one is named in the summary. Items in `$BLOCKED` are not cleaned here: they belong to the containment check in `lisa-repair-intake`.
382
+
381
383
  #### 3b. Claim
382
384
 
383
385
  Before the claim mutation, apply `claim-time-guards` — **Value before claim**, or **Worth doing** in `lisa-track` on runtimes without the rule tree (Antigravity). A ready label establishes neither value nor permission to expand scope. Respect the preceding human-hold gate; a declined incidental item consumes this cycle's one processed disposition.