@codyswann/lisa 8.1.1 → 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 (228) hide show
  1. package/dist/core/nightly-e2e-guard-behavior-certificate.js +2 -2
  2. package/dist/core/upstream-evidence-manifest.json +138 -11
  3. package/package.json +4 -4
  4. package/plugins/lisa/.claude-plugin/plugin.json +1 -1
  5. package/plugins/lisa/.codex-plugin/plugin.json +1 -1
  6. package/plugins/lisa/.codex-plugin/scripts/queue-contract-resolution.mjs +583 -0
  7. package/plugins/lisa/.codex-plugin/scripts/ready-queue-order.mjs +99 -25
  8. package/plugins/lisa/.codex-plugin/scripts/stale-blocker-comment.mjs +185 -0
  9. package/plugins/lisa/.codex-plugin/scripts/stale-blocker-confirm.mjs +130 -0
  10. package/plugins/lisa/.codex-plugin/scripts/stale-blocker-edges.mjs +466 -0
  11. package/plugins/lisa/.codex-plugin/scripts/stale-blocker-pending.mjs +257 -0
  12. package/plugins/lisa/.codex-plugin/scripts/stale-blocker-restore.mjs +180 -0
  13. package/plugins/lisa/.codex-plugin/scripts/stale-blocker-summary.mjs +222 -0
  14. package/plugins/lisa/.codex-plugin/scripts/stale-blocker-sweep.mjs +394 -0
  15. package/plugins/lisa/.codex-plugin/scripts/stale-blocker-verify.mjs +193 -0
  16. package/plugins/lisa/.codex-plugin/skills/lisa-atlassian-access/SKILL.md +1 -0
  17. package/plugins/lisa/.codex-plugin/skills/lisa-github-build-intake/SKILL.md +2 -7
  18. package/plugins/lisa/.codex-plugin/skills/lisa-jira-build-intake/SKILL.md +2 -0
  19. package/plugins/lisa/.codex-plugin/skills/lisa-linear-access/SKILL.md +44 -0
  20. package/plugins/lisa/.codex-plugin/skills/lisa-linear-build-intake/SKILL.md +2 -0
  21. package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/SKILL.md +127 -2
  22. package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/cli-queue.mjs +90 -20
  23. package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/cli-stale-links-results.mjs +254 -0
  24. package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/cli-stale-links.mjs +243 -0
  25. package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/cli-usage.mjs +60 -0
  26. package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/queue-github.mjs +68 -8
  27. package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/session-manager.mjs +49 -0
  28. package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/stale-links-github.mjs +196 -0
  29. package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/stale-links-state.mjs +173 -0
  30. package/plugins/lisa/scripts/ready-queue-order.mjs +99 -25
  31. package/plugins/lisa/scripts/stale-blocker-comment.mjs +185 -0
  32. package/plugins/lisa/scripts/stale-blocker-confirm.mjs +130 -0
  33. package/plugins/lisa/scripts/stale-blocker-edges.mjs +466 -0
  34. package/plugins/lisa/scripts/stale-blocker-pending.mjs +257 -0
  35. package/plugins/lisa/scripts/stale-blocker-restore.mjs +180 -0
  36. package/plugins/lisa/scripts/stale-blocker-summary.mjs +222 -0
  37. package/plugins/lisa/scripts/stale-blocker-sweep.mjs +394 -0
  38. package/plugins/lisa/scripts/stale-blocker-verify.mjs +193 -0
  39. package/plugins/lisa/skills/lisa-atlassian-access/SKILL.md +1 -0
  40. package/plugins/lisa/skills/lisa-github-build-intake/SKILL.md +2 -7
  41. package/plugins/lisa/skills/lisa-jira-build-intake/SKILL.md +2 -0
  42. package/plugins/lisa/skills/lisa-linear-access/SKILL.md +44 -0
  43. package/plugins/lisa/skills/lisa-linear-build-intake/SKILL.md +2 -0
  44. package/plugins/lisa/skills/lisa-session-manager/SKILL.md +127 -2
  45. package/plugins/lisa/skills/lisa-session-manager/scripts/cli-queue.mjs +90 -20
  46. package/plugins/lisa/skills/lisa-session-manager/scripts/cli-stale-links-results.mjs +254 -0
  47. package/plugins/lisa/skills/lisa-session-manager/scripts/cli-stale-links.mjs +243 -0
  48. package/plugins/lisa/skills/lisa-session-manager/scripts/cli-usage.mjs +60 -0
  49. package/plugins/lisa/skills/lisa-session-manager/scripts/queue-github.mjs +68 -8
  50. package/plugins/lisa/skills/lisa-session-manager/scripts/session-manager.mjs +49 -0
  51. package/plugins/lisa/skills/lisa-session-manager/scripts/stale-links-github.mjs +196 -0
  52. package/plugins/lisa/skills/lisa-session-manager/scripts/stale-links-state.mjs +173 -0
  53. package/plugins/lisa-agy/plugin.json +1 -1
  54. package/plugins/lisa-agy/scripts/ready-queue-order.mjs +99 -25
  55. package/plugins/lisa-agy/scripts/stale-blocker-comment.mjs +185 -0
  56. package/plugins/lisa-agy/scripts/stale-blocker-confirm.mjs +130 -0
  57. package/plugins/lisa-agy/scripts/stale-blocker-edges.mjs +466 -0
  58. package/plugins/lisa-agy/scripts/stale-blocker-pending.mjs +257 -0
  59. package/plugins/lisa-agy/scripts/stale-blocker-restore.mjs +180 -0
  60. package/plugins/lisa-agy/scripts/stale-blocker-summary.mjs +222 -0
  61. package/plugins/lisa-agy/scripts/stale-blocker-sweep.mjs +394 -0
  62. package/plugins/lisa-agy/scripts/stale-blocker-verify.mjs +193 -0
  63. package/plugins/lisa-agy/skills/lisa-atlassian-access/SKILL.md +1 -0
  64. package/plugins/lisa-agy/skills/lisa-github-build-intake/SKILL.md +2 -7
  65. package/plugins/lisa-agy/skills/lisa-jira-build-intake/SKILL.md +2 -0
  66. package/plugins/lisa-agy/skills/lisa-linear-access/SKILL.md +44 -0
  67. package/plugins/lisa-agy/skills/lisa-linear-build-intake/SKILL.md +2 -0
  68. package/plugins/lisa-agy/skills/lisa-session-manager/SKILL.md +127 -2
  69. package/plugins/lisa-agy/skills/lisa-session-manager/scripts/cli-queue.mjs +90 -20
  70. package/plugins/lisa-agy/skills/lisa-session-manager/scripts/cli-stale-links-results.mjs +254 -0
  71. package/plugins/lisa-agy/skills/lisa-session-manager/scripts/cli-stale-links.mjs +243 -0
  72. package/plugins/lisa-agy/skills/lisa-session-manager/scripts/cli-usage.mjs +60 -0
  73. package/plugins/lisa-agy/skills/lisa-session-manager/scripts/queue-github.mjs +68 -8
  74. package/plugins/lisa-agy/skills/lisa-session-manager/scripts/session-manager.mjs +49 -0
  75. package/plugins/lisa-agy/skills/lisa-session-manager/scripts/stale-links-github.mjs +196 -0
  76. package/plugins/lisa-agy/skills/lisa-session-manager/scripts/stale-links-state.mjs +173 -0
  77. package/plugins/lisa-cdk/.claude-plugin/plugin.json +1 -1
  78. package/plugins/lisa-cdk/.codex-plugin/plugin.json +1 -1
  79. package/plugins/lisa-cdk-agy/plugin.json +1 -1
  80. package/plugins/lisa-cdk-copilot/.claude-plugin/plugin.json +1 -1
  81. package/plugins/lisa-cdk-cursor/.claude-plugin/plugin.json +1 -1
  82. package/plugins/lisa-cdk-devin/.claude-plugin/plugin.json +1 -1
  83. package/plugins/lisa-cdk-devin/.devin-plugin/plugin.json +1 -1
  84. package/plugins/lisa-copilot/.claude-plugin/plugin.json +1 -1
  85. package/plugins/lisa-copilot/scripts/ready-queue-order.mjs +99 -25
  86. package/plugins/lisa-copilot/scripts/stale-blocker-comment.mjs +185 -0
  87. package/plugins/lisa-copilot/scripts/stale-blocker-confirm.mjs +130 -0
  88. package/plugins/lisa-copilot/scripts/stale-blocker-edges.mjs +466 -0
  89. package/plugins/lisa-copilot/scripts/stale-blocker-pending.mjs +257 -0
  90. package/plugins/lisa-copilot/scripts/stale-blocker-restore.mjs +180 -0
  91. package/plugins/lisa-copilot/scripts/stale-blocker-summary.mjs +222 -0
  92. package/plugins/lisa-copilot/scripts/stale-blocker-sweep.mjs +394 -0
  93. package/plugins/lisa-copilot/scripts/stale-blocker-verify.mjs +193 -0
  94. package/plugins/lisa-copilot/skills/lisa-atlassian-access/SKILL.md +1 -0
  95. package/plugins/lisa-copilot/skills/lisa-github-build-intake/SKILL.md +2 -7
  96. package/plugins/lisa-copilot/skills/lisa-jira-build-intake/SKILL.md +2 -0
  97. package/plugins/lisa-copilot/skills/lisa-linear-access/SKILL.md +44 -0
  98. package/plugins/lisa-copilot/skills/lisa-linear-build-intake/SKILL.md +2 -0
  99. package/plugins/lisa-copilot/skills/lisa-session-manager/SKILL.md +127 -2
  100. package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/cli-queue.mjs +90 -20
  101. package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/cli-stale-links-results.mjs +254 -0
  102. package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/cli-stale-links.mjs +243 -0
  103. package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/cli-usage.mjs +60 -0
  104. package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/queue-github.mjs +68 -8
  105. package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/session-manager.mjs +49 -0
  106. package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/stale-links-github.mjs +196 -0
  107. package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/stale-links-state.mjs +173 -0
  108. package/plugins/lisa-cursor/.claude-plugin/plugin.json +1 -1
  109. package/plugins/lisa-cursor/scripts/ready-queue-order.mjs +99 -25
  110. package/plugins/lisa-cursor/scripts/stale-blocker-comment.mjs +185 -0
  111. package/plugins/lisa-cursor/scripts/stale-blocker-confirm.mjs +130 -0
  112. package/plugins/lisa-cursor/scripts/stale-blocker-edges.mjs +466 -0
  113. package/plugins/lisa-cursor/scripts/stale-blocker-pending.mjs +257 -0
  114. package/plugins/lisa-cursor/scripts/stale-blocker-restore.mjs +180 -0
  115. package/plugins/lisa-cursor/scripts/stale-blocker-summary.mjs +222 -0
  116. package/plugins/lisa-cursor/scripts/stale-blocker-sweep.mjs +394 -0
  117. package/plugins/lisa-cursor/scripts/stale-blocker-verify.mjs +193 -0
  118. package/plugins/lisa-cursor/skills/lisa-atlassian-access/SKILL.md +1 -0
  119. package/plugins/lisa-cursor/skills/lisa-github-build-intake/SKILL.md +2 -7
  120. package/plugins/lisa-cursor/skills/lisa-jira-build-intake/SKILL.md +2 -0
  121. package/plugins/lisa-cursor/skills/lisa-linear-access/SKILL.md +44 -0
  122. package/plugins/lisa-cursor/skills/lisa-linear-build-intake/SKILL.md +2 -0
  123. package/plugins/lisa-cursor/skills/lisa-session-manager/SKILL.md +127 -2
  124. package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/cli-queue.mjs +90 -20
  125. package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/cli-stale-links-results.mjs +254 -0
  126. package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/cli-stale-links.mjs +243 -0
  127. package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/cli-usage.mjs +60 -0
  128. package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/queue-github.mjs +68 -8
  129. package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/session-manager.mjs +49 -0
  130. package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/stale-links-github.mjs +196 -0
  131. package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/stale-links-state.mjs +173 -0
  132. package/plugins/lisa-devin/.claude-plugin/plugin.json +1 -1
  133. package/plugins/lisa-devin/.devin-plugin/plugin.json +1 -1
  134. package/plugins/lisa-devin/scripts/ready-queue-order.mjs +99 -25
  135. package/plugins/lisa-devin/scripts/stale-blocker-comment.mjs +185 -0
  136. package/plugins/lisa-devin/scripts/stale-blocker-confirm.mjs +130 -0
  137. package/plugins/lisa-devin/scripts/stale-blocker-edges.mjs +466 -0
  138. package/plugins/lisa-devin/scripts/stale-blocker-pending.mjs +257 -0
  139. package/plugins/lisa-devin/scripts/stale-blocker-restore.mjs +180 -0
  140. package/plugins/lisa-devin/scripts/stale-blocker-summary.mjs +222 -0
  141. package/plugins/lisa-devin/scripts/stale-blocker-sweep.mjs +394 -0
  142. package/plugins/lisa-devin/scripts/stale-blocker-verify.mjs +193 -0
  143. package/plugins/lisa-devin/skills/lisa-atlassian-access/SKILL.md +1 -0
  144. package/plugins/lisa-devin/skills/lisa-github-build-intake/SKILL.md +2 -7
  145. package/plugins/lisa-devin/skills/lisa-jira-build-intake/SKILL.md +2 -0
  146. package/plugins/lisa-devin/skills/lisa-linear-access/SKILL.md +44 -0
  147. package/plugins/lisa-devin/skills/lisa-linear-build-intake/SKILL.md +2 -0
  148. package/plugins/lisa-devin/skills/lisa-session-manager/SKILL.md +127 -2
  149. package/plugins/lisa-devin/skills/lisa-session-manager/scripts/cli-queue.mjs +90 -20
  150. package/plugins/lisa-devin/skills/lisa-session-manager/scripts/cli-stale-links-results.mjs +254 -0
  151. package/plugins/lisa-devin/skills/lisa-session-manager/scripts/cli-stale-links.mjs +243 -0
  152. package/plugins/lisa-devin/skills/lisa-session-manager/scripts/cli-usage.mjs +60 -0
  153. package/plugins/lisa-devin/skills/lisa-session-manager/scripts/queue-github.mjs +68 -8
  154. package/plugins/lisa-devin/skills/lisa-session-manager/scripts/session-manager.mjs +49 -0
  155. package/plugins/lisa-devin/skills/lisa-session-manager/scripts/stale-links-github.mjs +196 -0
  156. package/plugins/lisa-devin/skills/lisa-session-manager/scripts/stale-links-state.mjs +173 -0
  157. package/plugins/lisa-expo/.claude-plugin/plugin.json +1 -1
  158. package/plugins/lisa-expo/.codex-plugin/plugin.json +1 -1
  159. package/plugins/lisa-expo-agy/plugin.json +1 -1
  160. package/plugins/lisa-expo-copilot/.claude-plugin/plugin.json +1 -1
  161. package/plugins/lisa-expo-cursor/.claude-plugin/plugin.json +1 -1
  162. package/plugins/lisa-expo-devin/.claude-plugin/plugin.json +1 -1
  163. package/plugins/lisa-expo-devin/.devin-plugin/plugin.json +1 -1
  164. package/plugins/lisa-harper-fabric/.claude-plugin/plugin.json +1 -1
  165. package/plugins/lisa-harper-fabric/.codex-plugin/plugin.json +1 -1
  166. package/plugins/lisa-harper-fabric-agy/plugin.json +1 -1
  167. package/plugins/lisa-harper-fabric-copilot/.claude-plugin/plugin.json +1 -1
  168. package/plugins/lisa-harper-fabric-cursor/.claude-plugin/plugin.json +1 -1
  169. package/plugins/lisa-harper-fabric-devin/.claude-plugin/plugin.json +1 -1
  170. package/plugins/lisa-harper-fabric-devin/.devin-plugin/plugin.json +1 -1
  171. package/plugins/lisa-nestjs/.claude-plugin/plugin.json +1 -1
  172. package/plugins/lisa-nestjs/.codex-plugin/plugin.json +1 -1
  173. package/plugins/lisa-nestjs-agy/plugin.json +1 -1
  174. package/plugins/lisa-nestjs-copilot/.claude-plugin/plugin.json +1 -1
  175. package/plugins/lisa-nestjs-cursor/.claude-plugin/plugin.json +1 -1
  176. package/plugins/lisa-nestjs-devin/.claude-plugin/plugin.json +1 -1
  177. package/plugins/lisa-nestjs-devin/.devin-plugin/plugin.json +1 -1
  178. package/plugins/lisa-phaser/.claude-plugin/plugin.json +1 -1
  179. package/plugins/lisa-phaser/.codex-plugin/plugin.json +1 -1
  180. package/plugins/lisa-phaser-agy/plugin.json +1 -1
  181. package/plugins/lisa-phaser-copilot/.claude-plugin/plugin.json +1 -1
  182. package/plugins/lisa-phaser-cursor/.claude-plugin/plugin.json +1 -1
  183. package/plugins/lisa-phaser-devin/.claude-plugin/plugin.json +1 -1
  184. package/plugins/lisa-phaser-devin/.devin-plugin/plugin.json +1 -1
  185. package/plugins/lisa-rails/.claude-plugin/plugin.json +1 -1
  186. package/plugins/lisa-rails/.codex-plugin/plugin.json +1 -1
  187. package/plugins/lisa-rails-agy/plugin.json +1 -1
  188. package/plugins/lisa-rails-copilot/.claude-plugin/plugin.json +1 -1
  189. package/plugins/lisa-rails-cursor/.claude-plugin/plugin.json +1 -1
  190. package/plugins/lisa-rails-devin/.claude-plugin/plugin.json +1 -1
  191. package/plugins/lisa-rails-devin/.devin-plugin/plugin.json +1 -1
  192. package/plugins/lisa-typescript/.claude-plugin/plugin.json +1 -1
  193. package/plugins/lisa-typescript/.codex-plugin/plugin.json +1 -1
  194. package/plugins/lisa-typescript-agy/plugin.json +1 -1
  195. package/plugins/lisa-typescript-copilot/.claude-plugin/plugin.json +1 -1
  196. package/plugins/lisa-typescript-cursor/.claude-plugin/plugin.json +1 -1
  197. package/plugins/lisa-typescript-devin/.claude-plugin/plugin.json +1 -1
  198. package/plugins/lisa-typescript-devin/.devin-plugin/plugin.json +1 -1
  199. package/plugins/lisa-wiki/.claude-plugin/plugin.json +1 -1
  200. package/plugins/lisa-wiki/.codex-plugin/plugin.json +1 -1
  201. package/plugins/lisa-wiki-agy/plugin.json +1 -1
  202. package/plugins/lisa-wiki-copilot/.claude-plugin/plugin.json +1 -1
  203. package/plugins/lisa-wiki-cursor/.claude-plugin/plugin.json +1 -1
  204. package/plugins/lisa-wiki-devin/.claude-plugin/plugin.json +1 -1
  205. package/plugins/lisa-wiki-devin/.devin-plugin/plugin.json +1 -1
  206. package/plugins/src/base/scripts/ready-queue-order.mjs +99 -25
  207. package/plugins/src/base/scripts/stale-blocker-comment.mjs +185 -0
  208. package/plugins/src/base/scripts/stale-blocker-confirm.mjs +130 -0
  209. package/plugins/src/base/scripts/stale-blocker-edges.mjs +466 -0
  210. package/plugins/src/base/scripts/stale-blocker-pending.mjs +257 -0
  211. package/plugins/src/base/scripts/stale-blocker-restore.mjs +180 -0
  212. package/plugins/src/base/scripts/stale-blocker-summary.mjs +222 -0
  213. package/plugins/src/base/scripts/stale-blocker-sweep.mjs +394 -0
  214. package/plugins/src/base/scripts/stale-blocker-verify.mjs +193 -0
  215. package/plugins/src/base/skills/lisa-atlassian-access/SKILL.md +1 -0
  216. package/plugins/src/base/skills/lisa-github-build-intake/SKILL.md +2 -7
  217. package/plugins/src/base/skills/lisa-jira-build-intake/SKILL.md +2 -0
  218. package/plugins/src/base/skills/lisa-linear-access/SKILL.md +44 -0
  219. package/plugins/src/base/skills/lisa-linear-build-intake/SKILL.md +2 -0
  220. package/plugins/src/base/skills/lisa-session-manager/SKILL.md +127 -2
  221. package/plugins/src/base/skills/lisa-session-manager/scripts/cli-queue.mjs +90 -20
  222. package/plugins/src/base/skills/lisa-session-manager/scripts/cli-stale-links-results.mjs +254 -0
  223. package/plugins/src/base/skills/lisa-session-manager/scripts/cli-stale-links.mjs +243 -0
  224. package/plugins/src/base/skills/lisa-session-manager/scripts/cli-usage.mjs +60 -0
  225. package/plugins/src/base/skills/lisa-session-manager/scripts/queue-github.mjs +68 -8
  226. package/plugins/src/base/skills/lisa-session-manager/scripts/session-manager.mjs +49 -0
  227. package/plugins/src/base/skills/lisa-session-manager/scripts/stale-links-github.mjs +196 -0
  228. package/plugins/src/base/skills/lisa-session-manager/scripts/stale-links-state.mjs +173 -0
@@ -24,6 +24,8 @@ operation: list-issues [team:<ID>] [project:<ID>] [label:<NAME>] [state:<NAME>]
24
24
  operation: get-issue id:<ID>
25
25
  operation: save-issue payload:{...} [lifecycle_role:<ROLE>] [env:<KEY>]
26
26
  operation: list-workflow-states team:<ID>
27
+ operation: delete-relation id:<ID>
28
+ operation: create-relation issue:<IDENTIFIER> related:<IDENTIFIER> type:blocks
27
29
  operation: create-workflow-state payload:{...}
28
30
  operation: list-comments (issue_id:<ID> | project_id:<ID>)
29
31
  operation: save-comment (issue_id:<ID> | project_id:<ID>) body:"..."
@@ -295,6 +297,48 @@ Set `isTeamDefault` per node by comparing `node.id` against
295
297
  the team's default, resolve the default through the team record and join on `id`
296
298
  the same way.
297
299
 
300
+ ## `delete-relation` — remove one relation by its own id
301
+
302
+ `delete-relation id:<ID>` deletes one issue relation by the relation's `id` (the
303
+ `inverseRelations` / `relations` node id, never an issue id). The session
304
+ manager's stale-blocker-link sweep uses it to drop a `blocks` relation whose
305
+ blocker is already finished (CodySwannGT/lisa#5065). Delete by relation id
306
+ only: never "update" a relation to remove it, because `issueRelationCreate`
307
+ converts an existing relation instead of adding one (CodySwannGT/lisa#3605).
308
+
309
+ ```graphql
310
+ mutation($id:String!){ issueRelationDelete(id:$id){ success } }
311
+ ```
312
+
313
+ Read the issue back and confirm the relation is gone before reporting success.
314
+ The Linear MCP exposes no relation delete, so on an MCP-only substrate report
315
+ `Error: delete-relation needs the LINEAR_API_KEY GraphQL path` and leave the
316
+ relation in place.
317
+
318
+ ## `create-relation` — put back one `blocks` relation
319
+
320
+ `create-relation issue:<blocker> related:<blocked> type:blocks` recreates the
321
+ relation "`<blocker>` blocks `<blocked>`". The stale-blocker-link sweep uses it
322
+ only to put back a relation it removed when the blocker reopened between its
323
+ confirm and its delete (CodySwannGT/lisa#5065). Resolve both identifiers to
324
+ issue ids first, and create it only after a read shows no relation between the
325
+ two issues: `issueRelationCreate` converts an existing relation instead of
326
+ adding a second one (CodySwannGT/lisa#3605), so it must never be used to edit.
327
+
328
+ ```graphql
329
+ mutation($issueId:String!,$relatedIssueId:String!){
330
+ issueRelationCreate(input:{issueId:$issueId,relatedIssueId:$relatedIssueId,type:blocks}){
331
+ success issueRelation { id }
332
+ }
333
+ }
334
+ ```
335
+
336
+ Read the blocked issue back and confirm the `blocks` relation is in its
337
+ `inverseRelations` before reporting success. The Linear MCP exposes no relation
338
+ create with this guarantee, so on an MCP-only substrate report
339
+ `Error: create-relation needs the LINEAR_API_KEY GraphQL path` and name the
340
+ relation in the run's errors so a person can put it back.
341
+
298
342
  ## `save-comment` / `list-comments` — an Issue **or** a Project
299
343
 
300
344
  Both comment operations take **either** `issue_id:` or `project_id:`. Exactly one
@@ -377,6 +377,8 @@ Post via `lisa-linear-access operation: save-comment` with:
377
377
 
378
378
  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.
379
379
 
380
+ **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 state (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-linear-access` (`delete-relation 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 (`create-relation` through `lisa-linear-access` `operation: create-relation issue:<issue> related:<relatedIssue> type:blocks`), 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`.
381
+
380
382
  #### 3b. Claim
381
383
 
382
384
  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.
@@ -580,6 +580,131 @@ just as long. Sweep both every cycle, after `classify` and before Dispatch:
580
580
  A failure anywhere in this sweep is one transcript line: it never holds dispatch and never makes
581
581
  the cycle `recovery-required`.
582
582
 
583
+ **Stale blocker links** (CodySwannGT/lisa#5065). A "blocked by" link to work that is already
584
+ finished makes the item look stuck when it is not, and an operator who sees every item waiting on
585
+ something cannot tell which ones really are. Clear those links every cycle, before Dispatch, so an
586
+ item held back only by them is claimable in this same cycle:
587
+
588
+ 1. **Plan.** GitHub: `node "$SM/session-manager.mjs" stale-links-plan --tracker github --project-root "$ROOT"`
589
+ (it reads open issues, their native `blocked_by` dependencies and their `Blocked by` body lines
590
+ through `gh`). Jira / Linear: fetch every open item that has a blocker through
591
+ `lisa-atlassian-access` (the item's own `status`, plus `issuelinks` with each linked issue's
592
+ status and status category) or `lisa-linear-access` (the item's own `state { name }`, plus
593
+ `inverseRelations` with `id`, `type`, and the blocking issue's `identifier`, `team.key` and
594
+ `state { name type }`), with each item's comments, **paging until the last page**. The item's
595
+ own status is required: an item whose status is missing could be Blocked, so the plan leaves
596
+ all its links alone and lists it in `report.unknownStatus`. Write `{"complete":true,"items":[...]}` to
597
+ `.lisa/session-manager/stale-links-input.json` and run
598
+ `stale-links-plan --tracker jira|linear --input .lisa/session-manager/stale-links-input.json --project-root "$ROOT"`.
599
+ The plan writes nothing. A blocker is stale when it is closed in its tracker or sits in the
600
+ configured terminal done role (`.lisa.config.json`, never a hardcoded name). A blocker in an
601
+ intermediate done rung (`status:on-dev`, `On Stg`) has merged to a non-production environment:
602
+ it does not hold the item (the queue and intake treat it as cleared), but it is not finished,
603
+ so its link is never removed. A cancelled
604
+ blocker (GitHub `not_planned` or `duplicate`, Linear `canceled`) is treated as resolved, because
605
+ intake already ignores it, and the comment says it was cancelled. A blocker that is still open,
606
+ in another project or repository, or could not be read is never touched; an unreadable one is
607
+ listed in `report.inaccessible`. Items in the `blocked` role are left to the Blocked sweep
608
+ below, which decides by branch containment. `--max` caps the items per cycle (default 10); the
609
+ rest are `deferred` to the next cycle. Items whose planned removals did not happen in an earlier
610
+ cycle (recorded by `stale-links-verify`) are planned after every other candidate, so removals
611
+ that keep failing cannot take every slot; a removal that later succeeds clears the record.
612
+ 2. **Confirm, then act** on each entry of `plans`. The plan is a snapshot: a blocker can be
613
+ reopened, or a person can edit the item, before you write. So first re-read the item **and
614
+ every blocker it names**, then write that one entry to
615
+ `.lisa/session-manager/stale-links-entry.json` and run
616
+ `stale-links-confirm --tracker github --plan .lisa/session-manager/stale-links-entry.json --project-root "$ROOT"`
617
+ (GitHub re-reads the issue, each blocker and the comments itself). For Jira and Linear, put the
618
+ fresh raw item, with its own status, each blocker's current status and the comments, in
619
+ `.lisa/session-manager/stale-links-fresh.json` and add `--input` with that path. Its `plan`
620
+ keeps only the links that are still stale: a reopened blocker is in `skipped` as
621
+ `blocker-not-resolved` and keeps its link, a missing item status skips every link as
622
+ `status-unknown`, an item closed since the plan skips as `item-closed`, only the planned links
623
+ themselves are kept (a link added since the plan, even to the same blocker, is never removed),
624
+ and the GitHub `body` is rebuilt from the fresh
625
+ body, so a concurrent edit survives. When `plan` is null, write nothing for that item. Also
626
+ skip it (one transcript line, no write) when it gained a person's assignee since the plan.
627
+ A non-null `plan` is recorded in flight (`.lisa/session-manager/stale-links-inflight.json`)
628
+ before you write anything, and stays there until a verify reads the item back and every other
629
+ record is saved, so a read-back that fails after the deletes is retried in step 3 instead of
630
+ being lost. While it is in flight, `queue` holds the item (reason `removal-unverified`). Confirm
631
+ refuses an item that still has an unverified entry, so an earlier plan's removed links are
632
+ never overwritten: skip that item this cycle (one transcript line); step 3 verifies it.
633
+ Then perform each of the confirmed plan's `actions` and nothing else, straight away. No tracker
634
+ offers a conditional delete ("remove this link only if its blocker is still finished"), so a
635
+ blocker can still reopen between this re-read and the write; verify below catches that and
636
+ puts the link back. A sub-second window remains between the delete and that re-read, during
637
+ which the link is briefly absent while its blocker is open. A queue read in that moment could
638
+ see the item as unblocked; the restore follows straight after, and that residual window is the
639
+ one gap no tracker API lets the sweep close.
640
+ - `delete-dependency` (GitHub): `gh api -X DELETE <endpoint>`.
641
+ - `body` (GitHub, when not null): write it as the issue body through `lisa-tracker-write`. It
642
+ differs from the fresh body only in the `Blocked by` refs it removes.
643
+ - `unlink` (Jira): `lisa-atlassian-access` `operation: unlink link-id:<linkId>`.
644
+ - `delete-relation` (Linear): `lisa-linear-access` `operation: delete-relation id:<relationId>`.
645
+ Then **verify**: write the confirmed entry to `.lisa/session-manager/stale-links-entry.json` and
646
+ run `stale-links-verify --tracker <t> --plan .lisa/session-manager/stale-links-entry.json --project-root "$ROOT"`
647
+ (GitHub reads the item back itself; Jira and Linear take the item as read back now in
648
+ `--input`, with its blocker relation list and its comments; without the relation list verify
649
+ refuses it, nothing is confirmed, and the entry stays in flight for step 3). It also reads every removed blocker again: GitHub itself; for Jira and
650
+ Linear, write `{"<ref>": <the blocker as read now, with its status / state and team>}` for
651
+ each planned removal to `.lisa/session-manager/stale-links-blockers.json` and add
652
+ `--blockers` with that path. A removed link whose blocker is no longer finished (reopened,
653
+ back in an intermediate done rung, or unreadable) is in `restored`, with no marker: perform its
654
+ `restore` actions straight away (`add-dependency`: `gh api -X POST <endpoint> -F
655
+ issue_id=<issueId>`; `body`: write it through `lisa-tracker-write`; `link` (Jira):
656
+ `lisa-atlassian-access` `operation: link from:<from> to:<to> type:<type>`; `create-relation`
657
+ (Linear): `lisa-linear-access` `operation: create-relation issue:<issue> related:<relatedIssue>
658
+ type:blocks`), then read the item back with
659
+ `stale-links-restored --ref <ref> --tracker <t> --project-root "$ROOT"` (GitHub reads it itself;
660
+ Jira and Linear add `--input` with the item as read now). Verify recorded those links as owed in
661
+ `.lisa/session-manager/stale-links-restores.json`, and `queue` holds the item (reason
662
+ `restore-owed`) until this read-back shows every one present; its `restore` lists fresh actions
663
+ for any still missing. Name each restored link in the cycle's transcript line. Its `confirmed` lists the removals the read-back shows gone and `stillPresent` the
664
+ ones that did not happen. Its `comment` (Jira: `commentAdf`, the same text as an ADF document,
665
+ because Jira Cloud's REST v3 comment body is ADF) covers ONLY the confirmed removals, so a
666
+ `[lisa-stale-blocker-link] blocker=<ref>` marker is never posted for a link that is still there:
667
+ a failed or impossible deletion (for example an MCP-only substrate) leaves no marker, and the
668
+ next cycle plans it again. When `comment` is null, post nothing. Otherwise the CLI has already
669
+ recorded it as pending; post it through `lisa-tracker-write`, then run
670
+ `stale-links-posted --ref <ref> --removed <its confirmed, comma-separated> --project-root "$ROOT"` (on a failed post, add `--failed`;
671
+ it stays pending). It also records any `stillPresent` removal for the next plan's ordering.
672
+ Keep every verify output for step 4. A link that comes back after its marker
673
+ was posted was put back by a person; the plan reports it in `report.keptByPerson` and never
674
+ removes it again.
675
+ 3. **Retry what is owed.** Run `stale-links-pending --project-root "$ROOT"`, before Dispatch.
676
+ - For each `unverified` entry (a confirmed plan whose read-back failed), write its `plan` to
677
+ `.lisa/session-manager/stale-links-entry.json` and run the step 2 verify again (never the
678
+ deletes); a removal whose comment already posted is never owed twice.
679
+ - For each item in `restores`, run `stale-links-restored` as in step 2 and perform any
680
+ `restore` actions it returns, then run it again; the item stays held from Dispatch
681
+ (`restore-owed`) until it reports nothing owed. Every other item still dispatches.
682
+ - For each `pending` entry, post its `comment` (Jira:
683
+ `commentAdf`) on its `ref` through `lisa-tracker-write`, on its own, whatever the new plan
684
+ says, and settle that one entry with `stale-links-posted --ref <ref> --removed <its removed, comma-separated> --project-root "$ROOT"` (`--failed` when it fails again). An item can owe more than one comment; each settles on its own. Its
685
+ links are already gone, so no plan will ever see them again; this is the only place the
686
+ operator's explanation for them still comes from.
687
+ 4. **Report.** The plan's `summary` describes intentions only ("planned", "would become ready"),
688
+ so never report it as done. Write `{"report":<the plan's report>,"results":[<each verify
689
+ output>]}` to `.lisa/session-manager/stale-links-results.json` and run
690
+ `stale-links-report --input .lisa/session-manager/stale-links-results.json --project-root "$ROOT"`. Its `summary` is
691
+ built from the verified results, with planned-but-not-done removals and deferred items counted
692
+ separately, e.g. `stale links: cleared 12 stale blocker links on 7 items; 3 now ready to start;
693
+ 2 planned removals not done (retried next cycle); 4 items left for the next cycle; 29 real
694
+ blockers remain on 18 items.` Put that in the cycle's transcript line and in the recorded run
695
+ summary. Send Telegram nothing for this sweep unless `report.inaccessible` is non-empty and its
696
+ list changed since the last cycle: then one line naming the blockers that could not be opened.
697
+
698
+ A failure anywhere in this sweep is one transcript line and never makes the cycle
699
+ `recovery-required`. It holds dispatch for one item only: an item owed a restore (a blocker link
700
+ put back, not yet read back present) is held with reason `restore-owed`, an item whose removals
701
+ ran but were never read back with `removal-unverified`, and an item whose blocker list could not
702
+ be read with `blockers-unreadable`, until a later read clears it. A failed plan,
703
+ confirm, verify or comment holds nothing, and every other item still dispatches. Other runtimes have no session manager, so build intake runs the
704
+ same shared rule on the item it is about to claim (each `lisa-*-build-intake` skill's "Stale blocker
705
+ links" step); the rule itself lives in `scripts/stale-blocker-edges.mjs` and
706
+ `scripts/stale-blocker-sweep.mjs`, plain Node any agent can run.
707
+
583
708
  **Blocked.** List the items in the `blocked` role (paged to completion, same access paths as the
584
709
  queue below). For each:
585
710
 
@@ -760,7 +885,7 @@ Skip while `capacity` reports `paused`. Otherwise:
760
885
  ### 3. Report and record
761
886
 
762
887
  If anything changed, write one transcript line, e.g.
763
- `cycle: 2 running/4 cap, dispatched <TEAM>-124, released <TEAM>-125, 1 question pending`. Then record
888
+ `cycle: 2 running/4 cap, dispatched <TEAM>-124, released <TEAM>-125, 1 question pending; stale links: cleared 2 stale blocker links on 1 item; 4 real blockers remain on 3 items` (the verified `stale-links-report` line). Then record
764
889
  the run outcome (next section).
765
890
 
766
891
  ## Run outcome
@@ -771,7 +896,7 @@ session `start` creates), every cycle ends in **exactly one** of the six outcome
771
896
  | This cycle | Run outcome |
772
897
  |---|---|
773
898
  | No dispatch, no state change, no question relayed or newly pending. The summary still states the denominator: "swept N ready, 0 dispatchable; R running/C cap". | `nothing-needed` |
774
- | At least one of: a worker spawned and seen live in `status`; a Blocked→Ready release written and read back; an orphan finished, returned or re-dispatched, or a hold lifted, written and read back; an answer delivered and its marker removed (`SendMessage` acknowledged, or `resume` returned a session id), or recorded on the item and read back before its marker was removed; a stalled or `blocked-on-prompt` item retried. | `change-proved` |
899
+ | At least one of: a worker spawned and seen live in `status`; a Blocked→Ready release written and read back; a stale blocker link removed and confirmed by `stale-links-verify`; an orphan finished, returned or re-dispatched, or a hold lifted, written and read back; an answer delivered and its marker removed (`SendMessage` acknowledged, or `resume` returned a session id), or recorded on the item and read back before its marker was removed; a stalled or `blocked-on-prompt` item retried. | `change-proved` |
775
900
  | An item was marked human-needed ("Mark and move on": marker and question comment written and read back), in any of the four cases, including an `exhausted` item moved to the `blocked` role, or a marked item whose question comment was re-posted after `item-answer` reported `no-question-comment`; or a worker `FAILED` moved the item to the `blocked` role with its reason comment, both read back. The summary names each ref and where to answer it. | `candidate-proposed` |
776
901
  | No item was newly marked, but a pending question was re-sent on Telegram (`requestion`) and awaits the operator, and nothing else changed. | `approval-requested` |
777
902
  | The tracker, a configured Telegram or `claude` was unreachable; Telegram is configured but was unavailable or unpaired (a question stayed pending with no Telegram message id); a human-needed mark could not be written or read back, or no marker is configured; an answer for a finished worker, an `exhausted` item or a `decision` no worker has picked up could not be posted on the item or read back (its question stays pending); a worker `FAILED`'s move to the `blocked` role could not be written or read back; a spawn failed after the claim (the item went back to Ready); a worker classified `setup-gap` (the item went back to Ready); the capacity probe failed. | `recovery-required` |
@@ -17,7 +17,12 @@
17
17
  * Both tiers leave out items routed to a repo with a recorded setup gap
18
18
  * (#4820) and list every gap once as `setupGaps`, with the command that
19
19
  * clears it, so the manager reports it in plain language instead of
20
- * re-dispatching there every cycle.
20
+ * re-dispatching there every cycle. They also leave out an item owed a
21
+ * stale-link restore (`restore-owed`, CodySwannGT/lisa#5065): a blocker link
22
+ * put back after its blocker reopened, not yet read back present, so the
23
+ * item would otherwise look unblocked while that blocker is open. An item
24
+ * whose stale-link removals ran but were never read back is held the same
25
+ * way (`removal-unverified`): its blocker may have reopened since.
21
26
  *
22
27
  * The GitHub fetches live in queue-github.mjs and JSON input in
23
28
  * json-input.mjs (re-exported here), to keep each module under the line
@@ -39,10 +44,15 @@ import {
39
44
  validOrAbsent,
40
45
  } from "./cli-runtime.mjs";
41
46
  import { resolveHumanGatePolicy } from "../../../scripts/human-gate-act.mjs";
47
+ import {
48
+ landedDoneRoles,
49
+ terminalDoneRoles,
50
+ } from "../../../scripts/stale-blocker-edges.mjs";
42
51
  import { readJsonFile } from "./json-input.mjs";
43
52
  import { readLedger } from "./ledger.mjs";
44
53
  import { blockingGapRepo, listSetupGaps } from "./ledger-setup-gaps.mjs";
45
54
  import { fetchGithubBacklog, fetchGithubQueue } from "./queue-github.mjs";
55
+ import { readInFlight, readRestores } from "./stale-links-state.mjs";
46
56
 
47
57
  export { parseJson, readJsonFile } from "./json-input.mjs";
48
58
 
@@ -53,15 +63,17 @@ const NORMALIZERS = { jira: normalizeJiraIssue, linear: normalizeLinearIssue };
53
63
  * @param {unknown} envelope - `{complete, pages, items}`
54
64
  * @param {string} where - Where it came from, for messages
55
65
  * @param {"jira"|"linear"} tracker - Vendor
66
+ * @param {readonly string[]} doneRoles - Configured terminal done names, so
67
+ * a blocker there counts as finished (#5065)
56
68
  * @returns {{ items: object[], pages: unknown }} Normalized items
57
69
  */
58
- function normalizeEnvelope(envelope, where, tracker) {
70
+ function normalizeEnvelope(envelope, where, tracker, judging) {
59
71
  asSetupError(() => assertPagedToCompletion(envelope));
60
72
  if (!Array.isArray(envelope.items)) {
61
73
  throw new CliError(`${where}: items must be an array.`, 2);
62
74
  }
63
75
  return {
64
- items: envelope.items.map(NORMALIZERS[tracker]),
76
+ items: envelope.items.map(item => NORMALIZERS[tracker](item, judging)),
65
77
  pages: envelope.pages ?? null,
66
78
  };
67
79
  }
@@ -73,15 +85,21 @@ function normalizeEnvelope(envelope, where, tracker) {
73
85
  * @param {object} ctx - CLI context
74
86
  * @param {"jira"|"linear"} tracker - Vendor
75
87
  * @param {boolean} withBacklog - Whether the backlog tier is required
88
+ * @param {ReturnType<typeof loadProject>} project - Loaded project
76
89
  * @returns {{ items: object[], pages: unknown, backlog: { items: object[], pages: unknown } | null }} Normalized items
77
90
  */
78
- function readEnvelopeQueue(ctx, tracker, withBacklog) {
91
+ function readEnvelopeQueue(ctx, tracker, withBacklog, project) {
79
92
  const file = ctx.values.input;
80
93
  if (!file) {
81
94
  throw new CliError(`queue --tracker ${tracker} needs --input <file>.`, 2);
82
95
  }
83
96
  const envelope = readJsonFile(file);
84
- const ready = normalizeEnvelope(envelope, file, tracker);
97
+ const config = { tracker, global: project.global, local: project.local };
98
+ const judging = {
99
+ doneRoles: terminalDoneRoles(config),
100
+ landedRoles: landedDoneRoles(config),
101
+ };
102
+ const ready = normalizeEnvelope(envelope, file, tracker, judging);
85
103
  if (!withBacklog) return { ...ready, backlog: null };
86
104
  if (!envelope.backlog) {
87
105
  throw new CliError(
@@ -93,7 +111,12 @@ function readEnvelopeQueue(ctx, tracker, withBacklog) {
93
111
  }
94
112
  return {
95
113
  ...ready,
96
- backlog: normalizeEnvelope(envelope.backlog, `${file} backlog`, tracker),
114
+ backlog: normalizeEnvelope(
115
+ envelope.backlog,
116
+ `${file} backlog`,
117
+ tracker,
118
+ judging
119
+ ),
97
120
  };
98
121
  }
99
122
 
@@ -131,6 +154,46 @@ function withoutPending(order, waiting) {
131
154
  };
132
155
  }
133
156
 
157
+ /**
158
+ * Move items held by the stale-link state out of `ordered` into `excluded`:
159
+ * `restore-owed` until `stale-links-restored` reads their put-back links
160
+ * present, and `removal-unverified` until `stale-links-verify` reads back a
161
+ * removal whose read-back failed. Only those items wait; every other item
162
+ * still dispatches.
163
+ * @param {{ordered: {ref: string}[], excluded: {ref: string, reason: string}[]}} order - Ordered tier
164
+ * @param {Map<string, string>} held - Lower-cased ref -> reason
165
+ * @returns {{ordered: {ref: string}[], excluded: {ref: string, reason: string}[]}} Filtered tier
166
+ */
167
+ function withoutStaleLinkHolds(order, held) {
168
+ const reasonOf = item => held.get(String(item.ref).toLowerCase());
169
+ return {
170
+ ...order,
171
+ ordered: order.ordered.filter(item => reasonOf(item) === undefined),
172
+ excluded: [
173
+ ...order.excluded,
174
+ ...order.ordered
175
+ .filter(item => reasonOf(item) !== undefined)
176
+ .map(item => ({ ref: item.ref, reason: reasonOf(item) })),
177
+ ],
178
+ };
179
+ }
180
+
181
+ /**
182
+ * The items the stale-link state holds, by lower-cased ref.
183
+ * @param {string} root - Project root
184
+ * @returns {Map<string, string>} Ref -> reason
185
+ */
186
+ function staleLinkHolds(root) {
187
+ const key = ref => ref.toLowerCase();
188
+ return new Map([
189
+ ...Object.keys(readInFlight(root)).map(ref => [
190
+ key(ref),
191
+ "removal-unverified",
192
+ ]),
193
+ ...Object.keys(readRestores(root)).map(ref => [key(ref), "restore-owed"]),
194
+ ]);
195
+ }
196
+
134
197
  /**
135
198
  * Move items routed to a repo with a recorded setup gap out of `ordered` into
136
199
  * `excluded` with reason `setup-gap:<repo>` (#4820). Retrying cannot fix a
@@ -182,7 +245,7 @@ export async function queue(ctx) {
182
245
  ...fetchGithubQueue(ctx, project),
183
246
  backlog: backlogPickup ? fetchGithubBacklog(ctx, project) : null,
184
247
  }
185
- : readEnvelopeQueue(ctx, tracker, backlogPickup);
248
+ : readEnvelopeQueue(ctx, tracker, backlogPickup, project);
186
249
  const ledger = await readLedger(ctx.root);
187
250
  const me = ctx.values.me ?? ledger.control.me ?? null;
188
251
  const operators = config?.operatorIds ?? [];
@@ -200,10 +263,14 @@ export async function queue(ctx) {
200
263
  const waiting = pendingRefs(ledger);
201
264
  const gaps = ledger.control.setupGaps;
202
265
  const multiRepo = Boolean(config?.repos);
203
- const order = withoutSetupGaps(
204
- withoutPending(orderReadyQueue(items, policy), waiting),
205
- gaps,
206
- multiRepo
266
+ const held = staleLinkHolds(ctx.root);
267
+ const order = withoutStaleLinkHolds(
268
+ withoutSetupGaps(
269
+ withoutPending(orderReadyQueue(items, policy), waiting),
270
+ gaps,
271
+ multiRepo
272
+ ),
273
+ held
207
274
  );
208
275
  const json = {
209
276
  tracker,
@@ -219,16 +286,19 @@ export async function queue(ctx) {
219
286
  // An item both Ready and in the backlog fetch is Ready work; never twice.
220
287
  const readyRefs = new Set(items.map(item => item.ref));
221
288
  const backlogItems = backlog.items.filter(item => !readyRefs.has(item.ref));
222
- const tier = withoutSetupGaps(
223
- withoutPending(
224
- orderBacklogQueue(backlogItems, {
225
- ...policy,
226
- validationFailures: ledger.validationFailures,
227
- }),
228
- waiting
289
+ const tier = withoutStaleLinkHolds(
290
+ withoutSetupGaps(
291
+ withoutPending(
292
+ orderBacklogQueue(backlogItems, {
293
+ ...policy,
294
+ validationFailures: ledger.validationFailures,
295
+ }),
296
+ waiting
297
+ ),
298
+ gaps,
299
+ multiRepo
229
300
  ),
230
- gaps,
231
- multiRepo
301
+ held
232
302
  );
233
303
  return {
234
304
  json: {