@codyswann/lisa 5.9.1 → 5.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/dist/core/nightly-e2e-guard-behavior-certificate.js +2 -2
  2. package/dist/core/nightly-e2e-guard-behavior-certificate.js.map +1 -1
  3. package/dist/core/upstream-evidence-manifest.d.ts.map +1 -1
  4. package/dist/core/upstream-evidence-manifest.js +4 -3
  5. package/dist/core/upstream-evidence-manifest.js.map +1 -1
  6. package/package.json +4 -4
  7. package/plugins/lisa/.claude-plugin/plugin.json +1 -1
  8. package/plugins/lisa/.codex-plugin/plugin.json +1 -1
  9. package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/SKILL.md +11 -4
  10. package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/orphan-buckets.mjs +63 -15
  11. package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/orphan-sweep.mjs +1 -0
  12. package/plugins/lisa/skills/lisa-session-manager/SKILL.md +11 -4
  13. package/plugins/lisa/skills/lisa-session-manager/scripts/orphan-buckets.mjs +63 -15
  14. package/plugins/lisa/skills/lisa-session-manager/scripts/orphan-sweep.mjs +1 -0
  15. package/plugins/lisa-agy/plugin.json +1 -1
  16. package/plugins/lisa-agy/skills/lisa-session-manager/SKILL.md +11 -4
  17. package/plugins/lisa-agy/skills/lisa-session-manager/scripts/orphan-buckets.mjs +63 -15
  18. package/plugins/lisa-agy/skills/lisa-session-manager/scripts/orphan-sweep.mjs +1 -0
  19. package/plugins/lisa-cdk/.claude-plugin/plugin.json +1 -1
  20. package/plugins/lisa-cdk/.codex-plugin/plugin.json +1 -1
  21. package/plugins/lisa-cdk-agy/plugin.json +1 -1
  22. package/plugins/lisa-cdk-copilot/.claude-plugin/plugin.json +1 -1
  23. package/plugins/lisa-cdk-cursor/.claude-plugin/plugin.json +1 -1
  24. package/plugins/lisa-cdk-devin/.claude-plugin/plugin.json +1 -1
  25. package/plugins/lisa-cdk-devin/.devin-plugin/plugin.json +1 -1
  26. package/plugins/lisa-copilot/.claude-plugin/plugin.json +1 -1
  27. package/plugins/lisa-copilot/skills/lisa-session-manager/SKILL.md +11 -4
  28. package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/orphan-buckets.mjs +63 -15
  29. package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/orphan-sweep.mjs +1 -0
  30. package/plugins/lisa-cursor/.claude-plugin/plugin.json +1 -1
  31. package/plugins/lisa-cursor/skills/lisa-session-manager/SKILL.md +11 -4
  32. package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/orphan-buckets.mjs +63 -15
  33. package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/orphan-sweep.mjs +1 -0
  34. package/plugins/lisa-devin/.claude-plugin/plugin.json +1 -1
  35. package/plugins/lisa-devin/.devin-plugin/plugin.json +1 -1
  36. package/plugins/lisa-devin/skills/lisa-session-manager/SKILL.md +11 -4
  37. package/plugins/lisa-devin/skills/lisa-session-manager/scripts/orphan-buckets.mjs +63 -15
  38. package/plugins/lisa-devin/skills/lisa-session-manager/scripts/orphan-sweep.mjs +1 -0
  39. package/plugins/lisa-expo/.claude-plugin/plugin.json +1 -1
  40. package/plugins/lisa-expo/.codex-plugin/plugin.json +1 -1
  41. package/plugins/lisa-expo-agy/plugin.json +1 -1
  42. package/plugins/lisa-expo-copilot/.claude-plugin/plugin.json +1 -1
  43. package/plugins/lisa-expo-cursor/.claude-plugin/plugin.json +1 -1
  44. package/plugins/lisa-expo-devin/.claude-plugin/plugin.json +1 -1
  45. package/plugins/lisa-expo-devin/.devin-plugin/plugin.json +1 -1
  46. package/plugins/lisa-harper-fabric/.claude-plugin/plugin.json +1 -1
  47. package/plugins/lisa-harper-fabric/.codex-plugin/plugin.json +1 -1
  48. package/plugins/lisa-harper-fabric-agy/plugin.json +1 -1
  49. package/plugins/lisa-harper-fabric-copilot/.claude-plugin/plugin.json +1 -1
  50. package/plugins/lisa-harper-fabric-cursor/.claude-plugin/plugin.json +1 -1
  51. package/plugins/lisa-harper-fabric-devin/.claude-plugin/plugin.json +1 -1
  52. package/plugins/lisa-harper-fabric-devin/.devin-plugin/plugin.json +1 -1
  53. package/plugins/lisa-nestjs/.claude-plugin/plugin.json +1 -1
  54. package/plugins/lisa-nestjs/.codex-plugin/plugin.json +1 -1
  55. package/plugins/lisa-nestjs-agy/plugin.json +1 -1
  56. package/plugins/lisa-nestjs-copilot/.claude-plugin/plugin.json +1 -1
  57. package/plugins/lisa-nestjs-cursor/.claude-plugin/plugin.json +1 -1
  58. package/plugins/lisa-nestjs-devin/.claude-plugin/plugin.json +1 -1
  59. package/plugins/lisa-nestjs-devin/.devin-plugin/plugin.json +1 -1
  60. package/plugins/lisa-phaser/.claude-plugin/plugin.json +1 -1
  61. package/plugins/lisa-phaser/.codex-plugin/plugin.json +1 -1
  62. package/plugins/lisa-phaser-agy/plugin.json +1 -1
  63. package/plugins/lisa-phaser-copilot/.claude-plugin/plugin.json +1 -1
  64. package/plugins/lisa-phaser-cursor/.claude-plugin/plugin.json +1 -1
  65. package/plugins/lisa-phaser-devin/.claude-plugin/plugin.json +1 -1
  66. package/plugins/lisa-phaser-devin/.devin-plugin/plugin.json +1 -1
  67. package/plugins/lisa-rails/.claude-plugin/plugin.json +1 -1
  68. package/plugins/lisa-rails/.codex-plugin/plugin.json +1 -1
  69. package/plugins/lisa-rails-agy/plugin.json +1 -1
  70. package/plugins/lisa-rails-copilot/.claude-plugin/plugin.json +1 -1
  71. package/plugins/lisa-rails-cursor/.claude-plugin/plugin.json +1 -1
  72. package/plugins/lisa-rails-devin/.claude-plugin/plugin.json +1 -1
  73. package/plugins/lisa-rails-devin/.devin-plugin/plugin.json +1 -1
  74. package/plugins/lisa-typescript/.claude-plugin/plugin.json +1 -1
  75. package/plugins/lisa-typescript/.codex-plugin/plugin.json +1 -1
  76. package/plugins/lisa-typescript-agy/plugin.json +1 -1
  77. package/plugins/lisa-typescript-copilot/.claude-plugin/plugin.json +1 -1
  78. package/plugins/lisa-typescript-cursor/.claude-plugin/plugin.json +1 -1
  79. package/plugins/lisa-typescript-devin/.claude-plugin/plugin.json +1 -1
  80. package/plugins/lisa-typescript-devin/.devin-plugin/plugin.json +1 -1
  81. package/plugins/lisa-wiki/.claude-plugin/plugin.json +1 -1
  82. package/plugins/lisa-wiki/.codex-plugin/plugin.json +1 -1
  83. package/plugins/lisa-wiki-agy/plugin.json +1 -1
  84. package/plugins/lisa-wiki-copilot/.claude-plugin/plugin.json +1 -1
  85. package/plugins/lisa-wiki-cursor/.claude-plugin/plugin.json +1 -1
  86. package/plugins/lisa-wiki-devin/.claude-plugin/plugin.json +1 -1
  87. package/plugins/lisa-wiki-devin/.devin-plugin/plugin.json +1 -1
  88. package/plugins/src/base/skills/lisa-session-manager/SKILL.md +11 -4
  89. package/plugins/src/base/skills/lisa-session-manager/scripts/orphan-buckets.mjs +63 -15
  90. package/plugins/src/base/skills/lisa-session-manager/scripts/orphan-sweep.mjs +1 -0
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-nestjs",
3
- "version": "5.9.1",
3
+ "version": "5.10.1",
4
4
  "description": "NestJS-specific skills (GraphQL, TypeORM) and hooks (hand-written migration warning)",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-nestjs",
3
- "version": "5.9.1",
3
+ "version": "5.10.1",
4
4
  "description": "NestJS-specific skills (GraphQL, TypeORM) and hooks (hand-written migration warning)",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-phaser",
3
- "version": "5.9.1",
3
+ "version": "5.10.1",
4
4
  "description": "Phaser 4 game-development rules for TypeScript projects",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-phaser",
3
- "version": "5.9.1",
3
+ "version": "5.10.1",
4
4
  "description": "Phaser 4 game-development rules for TypeScript projects",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-phaser",
3
- "version": "5.9.1",
3
+ "version": "5.10.1",
4
4
  "description": "Phaser 4 game-development rules for TypeScript projects",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-phaser",
3
- "version": "5.9.1",
3
+ "version": "5.10.1",
4
4
  "description": "Phaser 4 game-development rules for TypeScript projects",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-phaser",
3
- "version": "5.9.1",
3
+ "version": "5.10.1",
4
4
  "description": "Phaser 4 game-development rules for TypeScript projects",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-phaser",
3
- "version": "5.9.1",
3
+ "version": "5.10.1",
4
4
  "description": "Phaser 4 game-development rules for TypeScript projects",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-phaser",
3
- "version": "5.9.1",
3
+ "version": "5.10.1",
4
4
  "description": "Phaser 4 game-development rules for TypeScript projects",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-rails",
3
- "version": "5.9.1",
3
+ "version": "5.10.1",
4
4
  "description": "Ruby on Rails-specific hooks — RuboCop linting/formatting and ast-grep scanning on edit",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-rails",
3
- "version": "5.9.1",
3
+ "version": "5.10.1",
4
4
  "description": "Ruby on Rails-specific skills and hooks for RuboCop and ast-grep scanning on edit.",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-rails",
3
- "version": "5.9.1",
3
+ "version": "5.10.1",
4
4
  "description": "Ruby on Rails-specific hooks — RuboCop linting/formatting and ast-grep scanning on edit",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-rails",
3
- "version": "5.9.1",
3
+ "version": "5.10.1",
4
4
  "description": "Ruby on Rails-specific hooks — RuboCop linting/formatting and ast-grep scanning on edit",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-rails",
3
- "version": "5.9.1",
3
+ "version": "5.10.1",
4
4
  "description": "Ruby on Rails-specific hooks — RuboCop linting/formatting and ast-grep scanning on edit",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-rails",
3
- "version": "5.9.1",
3
+ "version": "5.10.1",
4
4
  "description": "Ruby on Rails-specific hooks — RuboCop linting/formatting and ast-grep scanning on edit",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-rails",
3
- "version": "5.9.1",
3
+ "version": "5.10.1",
4
4
  "description": "Ruby on Rails-specific hooks — RuboCop linting/formatting and ast-grep scanning on edit",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-typescript",
3
- "version": "5.9.1",
3
+ "version": "5.10.1",
4
4
  "description": "TypeScript-specific hooks — Prettier formatting, ESLint linting, ast-grep scanning, and error-suppression blocking on edit",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-typescript",
3
- "version": "5.9.1",
3
+ "version": "5.10.1",
4
4
  "description": "TypeScript-specific hooks for formatting, linting, and ast-grep scanning on edit.",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-typescript",
3
- "version": "5.9.1",
3
+ "version": "5.10.1",
4
4
  "description": "TypeScript-specific hooks — Prettier formatting, ESLint linting, ast-grep scanning, and error-suppression blocking on edit",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-typescript",
3
- "version": "5.9.1",
3
+ "version": "5.10.1",
4
4
  "description": "TypeScript-specific hooks — Prettier formatting, ESLint linting, ast-grep scanning, and error-suppression blocking on edit",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-typescript",
3
- "version": "5.9.1",
3
+ "version": "5.10.1",
4
4
  "description": "TypeScript-specific hooks — Prettier formatting, ESLint linting, ast-grep scanning, and error-suppression blocking on edit",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-typescript",
3
- "version": "5.9.1",
3
+ "version": "5.10.1",
4
4
  "description": "TypeScript-specific hooks — Prettier formatting, ESLint linting, ast-grep scanning, and error-suppression blocking on edit",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-typescript",
3
- "version": "5.9.1",
3
+ "version": "5.10.1",
4
4
  "description": "TypeScript-specific hooks — Prettier formatting, ESLint linting, ast-grep scanning, and error-suppression blocking on edit",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-wiki",
3
- "version": "5.9.1",
3
+ "version": "5.10.1",
4
4
  "description": "LLM Wiki — a distributable, git-native markdown knowledge base for Claude Code and Codex",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-wiki",
3
- "version": "5.9.1",
3
+ "version": "5.10.1",
4
4
  "description": "Distributable LLM Wiki kernel — ingest, query, lint, and maintain a git-native markdown knowledge base across Claude and Codex.",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-wiki",
3
- "version": "5.9.1",
3
+ "version": "5.10.1",
4
4
  "description": "LLM Wiki — a distributable, git-native markdown knowledge base for Claude Code and Codex",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-wiki",
3
- "version": "5.9.1",
3
+ "version": "5.10.1",
4
4
  "description": "LLM Wiki — a distributable, git-native markdown knowledge base for Claude Code and Codex",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-wiki",
3
- "version": "5.9.1",
3
+ "version": "5.10.1",
4
4
  "description": "LLM Wiki — a distributable, git-native markdown knowledge base for Claude Code and Codex",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-wiki",
3
- "version": "5.9.1",
3
+ "version": "5.10.1",
4
4
  "description": "LLM Wiki — a distributable, git-native markdown knowledge base for Claude Code and Codex",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-wiki",
3
- "version": "5.9.1",
3
+ "version": "5.10.1",
4
4
  "description": "LLM Wiki — a distributable, git-native markdown knowledge base for Claude Code and Codex",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -498,7 +498,7 @@ just as long. Sweep both every cycle, after `classify` and before Dispatch:
498
498
  Write `{"complete":true,"items":[{ref,role,labels,body,comments,assignees,updatedAt}],"holds":[{ref,role,labels,body,comments,assignees,updatedAt}]}`
499
499
  to `.lisa/session-manager/orphan-input.json`: refs canonical as dispatch uses them, comments
500
500
  as `{id,author,body,createdAt}` with the author's stable id and the comment's own posting
501
- time (a refusal comment with no `createdAt` never ages out of its 24-hour park), assignees as `{login,id}` objects on GitHub (the REST
501
+ time (a refusal comment with no `createdAt` never ages out of its 24-hour window), assignees as `{login,id}` objects on GitHub (the REST
502
502
  `.assignees[].id`) and as the account or user id on Jira and Linear, and each hold's `role` as
503
503
  the lifecycle role it is in (`ready`, `claimed`, `review`, `blocked`, `done`), so a lift never
504
504
  moves an item that is in a lane back to the `ready` role. On Jira and Linear a hold with no
@@ -528,9 +528,16 @@ just as long. Sweep both every cycle, after `classify` and before Dispatch:
528
528
  - `doneReady`: the pull request merged. In the item's repo dir run
529
529
  `node scripts/lisa-work-item.mjs finish --ref <ref> --pr-url <prUrl>`. If it refuses, post
530
530
  one comment that starts `[lisa-session-manager] Cannot complete:` and says, in plain words,
531
- why the item cannot complete yet. Later cycles see that comment and park the item, then retry
532
- finishing once it is more than 24 hours old.
533
- - `return`: move it to the `ready` role with the entry's `comment`.
531
+ why the item cannot complete yet. Then, when the entry has a `returnComment`, re-read the item
532
+ and leave it in place if a person now holds it; otherwise move the item to the `ready` role
533
+ with that comment: the code work is merged, so the next agent finishes only
534
+ the missing step instead of redoing it. An entry with no `returnComment` is held by a person
535
+ or is in the `review` role; leave it where it is. A later cycle that still sees a recent refusal puts the item
536
+ in `return`, or in `parked` when a person holds it or it is in the `review` role, and retries
537
+ finishing once the refusal is more than 24 hours old.
538
+ - `return`: move it to the `ready` role with the entry's `comment`. A merged item whose
539
+ completion was refused, and an item whose pull request was closed without merging, land here
540
+ with a comment that names that pull request, so the next agent builds on the earlier work.
534
541
  - `redispatch`: an open pull request and no worker. Claim it (`reused`) and `spawn` it exactly
535
542
  as Dispatch steps 2.3 and 2.4, ahead of new items, while `capacity` says `can_spawn`. A
536
543
  spawn that reaches `stall.maxAttempts` follows the `exhausted` row above.
@@ -21,15 +21,16 @@ export const SWEEP_COMMENT_PREFIX = "[lisa-session-manager]";
21
21
 
22
22
  /**
23
23
  * How the comment the manager posts when `lisa-work-item.mjs finish`
24
- * refuses an item begins. A later cycle that sees a recent one parks the
25
- * item instead of trying to finish it again every cycle.
24
+ * refuses an item begins. A later cycle that sees a recent one does not try
25
+ * to finish it again: it returns the item to Ready (or parks it, when a
26
+ * person holds it).
26
27
  */
27
28
  export const FINISH_REFUSED_PREFIX = `${SWEEP_COMMENT_PREFIX} Cannot complete:`;
28
29
 
29
30
  /**
30
- * How long a refusal parks an item. After that, finishing is retried: the
31
- * refusal's cause (a missing deploy, a slow check) is often fixed by then,
32
- * and a park with no end would strand a merged item for good.
31
+ * How long a refusal stops finishing from being retried. After that it is
32
+ * retried: the refusal's cause (a missing deploy, a slow check) is often
33
+ * fixed by then.
33
34
  */
34
35
  export const FINISH_RETRY_HOURS = 24;
35
36
 
@@ -164,22 +165,65 @@ function completionRefused(item, policy) {
164
165
  }
165
166
 
166
167
  /**
167
- * The bucket for a merged item: finish it, unless completion was already
168
- * refused within the retry window, in which case it waits for whatever the
169
- * refusal named.
170
- * @param {{ref: string, pr: {url?: string}, comments?: unknown}} item - Item
168
+ * The note on a merged item sent back to Ready because it could not complete:
169
+ * the code work is done, so the next agent finishes only the missing step.
170
+ * @param {string | undefined} prUrl - The merged pull request
171
+ * @returns {string} Comment body
172
+ */
173
+ export function mergedReturnComment(prUrl) {
174
+ return (
175
+ `${SWEEP_COMMENT_PREFIX} Returned to Ready: its pull request ${prUrl ?? ""} is merged, ` +
176
+ "so the code work is done, but the item could not be completed and no worker is " +
177
+ `finishing it. The \`${FINISH_REFUSED_PREFIX}\` comment says what is missing. ` +
178
+ "The next agent should finish only that step and not redo the merged work."
179
+ );
180
+ }
181
+
182
+ /**
183
+ * The bucket for a merged item. With no recent refusal it is finished. When
184
+ * completion was refused (a deploy not yet verified, say), the code work is
185
+ * done but nobody is finishing the rest, so it goes back to the `ready` role
186
+ * with a note that only the missing step is left (CodySwannGT/lisa#4906). A
187
+ * held item stays parked: returning it would spend a person's hold. So does an
188
+ * item in the `review` role: it is already past the build and waiting on
189
+ * review, deploy or verification — often the very step completion refused on —
190
+ * so returning it to Ready would move it backwards.
191
+ * @param {{ref: string, role?: unknown, pr: {url?: string}, comments?: unknown}} item - Item
171
192
  * @param {{now: number, finishRetryMs: number}} policy - Resolved policy
172
193
  * @returns {{bucket: string, entry: object}} Bucket and its entry
173
194
  */
174
195
  function mergedBucket(item, policy) {
175
196
  const { ref, pr } = item;
176
- if (completionRefused(item, policy)) {
177
- const reason =
178
- "its pull request merged but completion was refused; the refusal on the item says why";
197
+ const held = isHeld(item, policy);
198
+ const inReview = item.role === "review";
199
+ if (!completionRefused(item, policy)) {
200
+ const reason = "its pull request merged; only completion is missing";
201
+ // When this cycle's finish is refused, the manager returns the item with
202
+ // `returnComment` straight away, unless a person holds it or it is in
203
+ // review.
204
+ const back =
205
+ held || inReview ? {} : { returnComment: mergedReturnComment(pr.url) };
206
+ return {
207
+ bucket: "doneReady",
208
+ entry: { ref, prUrl: pr.url, reason, ...back },
209
+ };
210
+ }
211
+ if (held || inReview) {
212
+ const reason = held
213
+ ? "its pull request merged but completion was refused, and a person holds it"
214
+ : "in review: its pull request merged but completion was refused; the refusal on the item says why";
179
215
  return { bucket: "parked", entry: { ref, reason, reasonOnItem: true } };
180
216
  }
181
- const reason = "its pull request merged; only completion is missing";
182
- return { bucket: "doneReady", entry: { ref, prUrl: pr.url, reason } };
217
+ return {
218
+ bucket: "return",
219
+ entry: {
220
+ ref,
221
+ prUrl: pr.url,
222
+ reason:
223
+ "its pull request merged but completion was refused, and no worker is finishing it",
224
+ comment: mergedReturnComment(pr.url),
225
+ },
226
+ };
183
227
  }
184
228
 
185
229
  /**
@@ -222,12 +266,16 @@ export function classifyOrphan(item, policy) {
222
266
  }
223
267
  if (state === "open") return openBucket(item);
224
268
  const age = ageInWords(policy.now - new Date(item.updatedAt).getTime());
269
+ const earlier =
270
+ state === "closed"
271
+ ? ` An earlier pull request, ${pr.url ?? ""}, was closed without merging; reuse or learn from it rather than starting over.`
272
+ : "";
225
273
  return {
226
274
  bucket: "return",
227
275
  entry: {
228
276
  ref,
229
277
  reason: "no live worker and no open or merged pull request",
230
- comment: `${SWEEP_COMMENT_PREFIX} Returned to Ready: claimed ${age} with no live worker and no open or merged pull request.`,
278
+ comment: `${SWEEP_COMMENT_PREFIX} Returned to Ready: claimed ${age} with no live worker and no open or merged pull request.${earlier}`,
231
279
  },
232
280
  };
233
281
  }
@@ -33,6 +33,7 @@ export {
33
33
  FINISH_REFUSED_PREFIX,
34
34
  FINISH_RETRY_HOURS,
35
35
  SWEEP_COMMENT_PREFIX,
36
+ mergedReturnComment,
36
37
  } from "./orphan-buckets.mjs";
37
38
 
38
39
  /** At most this many writes per cycle unless the caller says otherwise. */