@codyswann/lisa 7.0.3 → 7.1.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 (175) hide show
  1. package/all/copy-overwrite/scripts/lib/work-item-estimate-calibration.mjs +131 -0
  2. package/all/copy-overwrite/scripts/lib/work-item-estimate-check.mjs +15 -5
  3. package/all/copy-overwrite/scripts/lisa-estimate.mjs +29 -3
  4. package/dist/core/lisa-owned-hash-ledger.d.ts.map +1 -1
  5. package/dist/core/lisa-owned-hash-ledger.js +18 -0
  6. package/dist/core/lisa-owned-hash-ledger.js.map +1 -1
  7. package/dist/core/nightly-e2e-guard-behavior-certificate.js +2 -2
  8. package/dist/core/upstream-evidence-manifest.d.ts.map +1 -1
  9. package/dist/core/upstream-evidence-manifest.js +46 -17
  10. package/dist/core/upstream-evidence-manifest.js.map +1 -1
  11. package/dist/utils/usage-accounting.d.ts.map +1 -1
  12. package/dist/utils/usage-accounting.js +3 -1
  13. package/dist/utils/usage-accounting.js.map +1 -1
  14. package/package.json +4 -4
  15. package/plugins/lisa/.claude-plugin/plugin.json +1 -1
  16. package/plugins/lisa/.codex-plugin/plugin.json +1 -1
  17. package/plugins/lisa/.codex-plugin/skills/lisa-github-validate-issue/SKILL.md +2 -0
  18. package/plugins/lisa/.codex-plugin/skills/lisa-jira-validate-ticket/SKILL.md +2 -0
  19. package/plugins/lisa/.codex-plugin/skills/lisa-linear-validate-issue/SKILL.md +2 -0
  20. package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/SKILL.md +45 -15
  21. package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/cli-runtime.mjs +1 -0
  22. package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/cli-usage.mjs +10 -3
  23. package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/cli-workers.mjs +52 -1
  24. package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/orphan-sweep.mjs +2 -20
  25. package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/session-manager.mjs +5 -1
  26. package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/take-check.mjs +110 -0
  27. package/plugins/lisa/.codex-plugin/skills/lisa-track/SKILL.md +11 -1
  28. package/plugins/lisa/.codex-plugin/skills/lisa-tracker-claim/SKILL.md +1 -0
  29. package/plugins/lisa/.codex-plugin/skills/lisa-usage-accounting/references/estimate.md +25 -2
  30. package/plugins/lisa/rules/reference/work-item-definition-of-ready.md +7 -2
  31. package/plugins/lisa/skills/lisa-github-validate-issue/SKILL.md +2 -0
  32. package/plugins/lisa/skills/lisa-jira-validate-ticket/SKILL.md +2 -0
  33. package/plugins/lisa/skills/lisa-linear-validate-issue/SKILL.md +2 -0
  34. package/plugins/lisa/skills/lisa-session-manager/SKILL.md +45 -15
  35. package/plugins/lisa/skills/lisa-session-manager/scripts/cli-runtime.mjs +1 -0
  36. package/plugins/lisa/skills/lisa-session-manager/scripts/cli-usage.mjs +10 -3
  37. package/plugins/lisa/skills/lisa-session-manager/scripts/cli-workers.mjs +52 -1
  38. package/plugins/lisa/skills/lisa-session-manager/scripts/orphan-sweep.mjs +2 -20
  39. package/plugins/lisa/skills/lisa-session-manager/scripts/session-manager.mjs +5 -1
  40. package/plugins/lisa/skills/lisa-session-manager/scripts/take-check.mjs +110 -0
  41. package/plugins/lisa/skills/lisa-track/SKILL.md +11 -1
  42. package/plugins/lisa/skills/lisa-tracker-claim/SKILL.md +1 -0
  43. package/plugins/lisa/skills/lisa-usage-accounting/references/estimate.md +25 -2
  44. package/plugins/lisa-agy/plugin.json +1 -1
  45. package/plugins/lisa-agy/skills/lisa-github-validate-issue/SKILL.md +2 -0
  46. package/plugins/lisa-agy/skills/lisa-jira-validate-ticket/SKILL.md +2 -0
  47. package/plugins/lisa-agy/skills/lisa-linear-validate-issue/SKILL.md +2 -0
  48. package/plugins/lisa-agy/skills/lisa-session-manager/SKILL.md +45 -15
  49. package/plugins/lisa-agy/skills/lisa-session-manager/scripts/cli-runtime.mjs +1 -0
  50. package/plugins/lisa-agy/skills/lisa-session-manager/scripts/cli-usage.mjs +10 -3
  51. package/plugins/lisa-agy/skills/lisa-session-manager/scripts/cli-workers.mjs +52 -1
  52. package/plugins/lisa-agy/skills/lisa-session-manager/scripts/orphan-sweep.mjs +2 -20
  53. package/plugins/lisa-agy/skills/lisa-session-manager/scripts/session-manager.mjs +5 -1
  54. package/plugins/lisa-agy/skills/lisa-session-manager/scripts/take-check.mjs +110 -0
  55. package/plugins/lisa-agy/skills/lisa-track/SKILL.md +11 -1
  56. package/plugins/lisa-agy/skills/lisa-tracker-claim/SKILL.md +1 -0
  57. package/plugins/lisa-agy/skills/lisa-usage-accounting/references/estimate.md +25 -2
  58. package/plugins/lisa-cdk/.claude-plugin/plugin.json +1 -1
  59. package/plugins/lisa-cdk/.codex-plugin/plugin.json +1 -1
  60. package/plugins/lisa-cdk-agy/plugin.json +1 -1
  61. package/plugins/lisa-cdk-copilot/.claude-plugin/plugin.json +1 -1
  62. package/plugins/lisa-cdk-cursor/.claude-plugin/plugin.json +1 -1
  63. package/plugins/lisa-cdk-devin/.claude-plugin/plugin.json +1 -1
  64. package/plugins/lisa-cdk-devin/.devin-plugin/plugin.json +1 -1
  65. package/plugins/lisa-copilot/.claude-plugin/plugin.json +1 -1
  66. package/plugins/lisa-copilot/rules/reference/work-item-definition-of-ready.md +7 -2
  67. package/plugins/lisa-copilot/skills/lisa-github-validate-issue/SKILL.md +2 -0
  68. package/plugins/lisa-copilot/skills/lisa-jira-validate-ticket/SKILL.md +2 -0
  69. package/plugins/lisa-copilot/skills/lisa-linear-validate-issue/SKILL.md +2 -0
  70. package/plugins/lisa-copilot/skills/lisa-session-manager/SKILL.md +45 -15
  71. package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/cli-runtime.mjs +1 -0
  72. package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/cli-usage.mjs +10 -3
  73. package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/cli-workers.mjs +52 -1
  74. package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/orphan-sweep.mjs +2 -20
  75. package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/session-manager.mjs +5 -1
  76. package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/take-check.mjs +110 -0
  77. package/plugins/lisa-copilot/skills/lisa-track/SKILL.md +11 -1
  78. package/plugins/lisa-copilot/skills/lisa-tracker-claim/SKILL.md +1 -0
  79. package/plugins/lisa-copilot/skills/lisa-usage-accounting/references/estimate.md +25 -2
  80. package/plugins/lisa-cursor/.claude-plugin/plugin.json +1 -1
  81. package/plugins/lisa-cursor/rules/work-item-definition-of-ready-reference.mdc +7 -2
  82. package/plugins/lisa-cursor/skills/lisa-github-validate-issue/SKILL.md +2 -0
  83. package/plugins/lisa-cursor/skills/lisa-jira-validate-ticket/SKILL.md +2 -0
  84. package/plugins/lisa-cursor/skills/lisa-linear-validate-issue/SKILL.md +2 -0
  85. package/plugins/lisa-cursor/skills/lisa-session-manager/SKILL.md +45 -15
  86. package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/cli-runtime.mjs +1 -0
  87. package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/cli-usage.mjs +10 -3
  88. package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/cli-workers.mjs +52 -1
  89. package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/orphan-sweep.mjs +2 -20
  90. package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/session-manager.mjs +5 -1
  91. package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/take-check.mjs +110 -0
  92. package/plugins/lisa-cursor/skills/lisa-track/SKILL.md +11 -1
  93. package/plugins/lisa-cursor/skills/lisa-tracker-claim/SKILL.md +1 -0
  94. package/plugins/lisa-cursor/skills/lisa-usage-accounting/references/estimate.md +25 -2
  95. package/plugins/lisa-devin/.claude-plugin/plugin.json +1 -1
  96. package/plugins/lisa-devin/.devin-plugin/plugin.json +1 -1
  97. package/plugins/lisa-devin/rules/reference/work-item-definition-of-ready.md +7 -2
  98. package/plugins/lisa-devin/skills/lisa-github-validate-issue/SKILL.md +2 -0
  99. package/plugins/lisa-devin/skills/lisa-jira-validate-ticket/SKILL.md +2 -0
  100. package/plugins/lisa-devin/skills/lisa-linear-validate-issue/SKILL.md +2 -0
  101. package/plugins/lisa-devin/skills/lisa-session-manager/SKILL.md +45 -15
  102. package/plugins/lisa-devin/skills/lisa-session-manager/scripts/cli-runtime.mjs +1 -0
  103. package/plugins/lisa-devin/skills/lisa-session-manager/scripts/cli-usage.mjs +10 -3
  104. package/plugins/lisa-devin/skills/lisa-session-manager/scripts/cli-workers.mjs +52 -1
  105. package/plugins/lisa-devin/skills/lisa-session-manager/scripts/orphan-sweep.mjs +2 -20
  106. package/plugins/lisa-devin/skills/lisa-session-manager/scripts/session-manager.mjs +5 -1
  107. package/plugins/lisa-devin/skills/lisa-session-manager/scripts/take-check.mjs +110 -0
  108. package/plugins/lisa-devin/skills/lisa-track/SKILL.md +11 -1
  109. package/plugins/lisa-devin/skills/lisa-tracker-claim/SKILL.md +1 -0
  110. package/plugins/lisa-devin/skills/lisa-usage-accounting/references/estimate.md +25 -2
  111. package/plugins/lisa-expo/.claude-plugin/plugin.json +1 -1
  112. package/plugins/lisa-expo/.codex-plugin/plugin.json +1 -1
  113. package/plugins/lisa-expo-agy/plugin.json +1 -1
  114. package/plugins/lisa-expo-copilot/.claude-plugin/plugin.json +1 -1
  115. package/plugins/lisa-expo-cursor/.claude-plugin/plugin.json +1 -1
  116. package/plugins/lisa-expo-devin/.claude-plugin/plugin.json +1 -1
  117. package/plugins/lisa-expo-devin/.devin-plugin/plugin.json +1 -1
  118. package/plugins/lisa-harper-fabric/.claude-plugin/plugin.json +1 -1
  119. package/plugins/lisa-harper-fabric/.codex-plugin/plugin.json +1 -1
  120. package/plugins/lisa-harper-fabric-agy/plugin.json +1 -1
  121. package/plugins/lisa-harper-fabric-copilot/.claude-plugin/plugin.json +1 -1
  122. package/plugins/lisa-harper-fabric-cursor/.claude-plugin/plugin.json +1 -1
  123. package/plugins/lisa-harper-fabric-devin/.claude-plugin/plugin.json +1 -1
  124. package/plugins/lisa-harper-fabric-devin/.devin-plugin/plugin.json +1 -1
  125. package/plugins/lisa-nestjs/.claude-plugin/plugin.json +1 -1
  126. package/plugins/lisa-nestjs/.codex-plugin/plugin.json +1 -1
  127. package/plugins/lisa-nestjs-agy/plugin.json +1 -1
  128. package/plugins/lisa-nestjs-copilot/.claude-plugin/plugin.json +1 -1
  129. package/plugins/lisa-nestjs-cursor/.claude-plugin/plugin.json +1 -1
  130. package/plugins/lisa-nestjs-devin/.claude-plugin/plugin.json +1 -1
  131. package/plugins/lisa-nestjs-devin/.devin-plugin/plugin.json +1 -1
  132. package/plugins/lisa-phaser/.claude-plugin/plugin.json +1 -1
  133. package/plugins/lisa-phaser/.codex-plugin/plugin.json +1 -1
  134. package/plugins/lisa-phaser-agy/plugin.json +1 -1
  135. package/plugins/lisa-phaser-copilot/.claude-plugin/plugin.json +1 -1
  136. package/plugins/lisa-phaser-cursor/.claude-plugin/plugin.json +1 -1
  137. package/plugins/lisa-phaser-devin/.claude-plugin/plugin.json +1 -1
  138. package/plugins/lisa-phaser-devin/.devin-plugin/plugin.json +1 -1
  139. package/plugins/lisa-rails/.claude-plugin/plugin.json +1 -1
  140. package/plugins/lisa-rails/.codex-plugin/plugin.json +1 -1
  141. package/plugins/lisa-rails-agy/plugin.json +1 -1
  142. package/plugins/lisa-rails-copilot/.claude-plugin/plugin.json +1 -1
  143. package/plugins/lisa-rails-cursor/.claude-plugin/plugin.json +1 -1
  144. package/plugins/lisa-rails-devin/.claude-plugin/plugin.json +1 -1
  145. package/plugins/lisa-rails-devin/.devin-plugin/plugin.json +1 -1
  146. package/plugins/lisa-typescript/.claude-plugin/plugin.json +1 -1
  147. package/plugins/lisa-typescript/.codex-plugin/plugin.json +1 -1
  148. package/plugins/lisa-typescript-agy/plugin.json +1 -1
  149. package/plugins/lisa-typescript-copilot/.claude-plugin/plugin.json +1 -1
  150. package/plugins/lisa-typescript-cursor/.claude-plugin/plugin.json +1 -1
  151. package/plugins/lisa-typescript-devin/.claude-plugin/plugin.json +1 -1
  152. package/plugins/lisa-typescript-devin/.devin-plugin/plugin.json +1 -1
  153. package/plugins/lisa-wiki/.claude-plugin/plugin.json +1 -1
  154. package/plugins/lisa-wiki/.codex-plugin/plugin.json +1 -1
  155. package/plugins/lisa-wiki-agy/plugin.json +1 -1
  156. package/plugins/lisa-wiki-copilot/.claude-plugin/plugin.json +1 -1
  157. package/plugins/lisa-wiki-cursor/.claude-plugin/plugin.json +1 -1
  158. package/plugins/lisa-wiki-devin/.claude-plugin/plugin.json +1 -1
  159. package/plugins/lisa-wiki-devin/.devin-plugin/plugin.json +1 -1
  160. package/plugins/src/base/rules/reference/work-item-definition-of-ready.md +7 -2
  161. package/plugins/src/base/skills/lisa-github-validate-issue/SKILL.md +2 -0
  162. package/plugins/src/base/skills/lisa-jira-validate-ticket/SKILL.md +2 -0
  163. package/plugins/src/base/skills/lisa-linear-validate-issue/SKILL.md +2 -0
  164. package/plugins/src/base/skills/lisa-session-manager/SKILL.md +45 -15
  165. package/plugins/src/base/skills/lisa-session-manager/scripts/cli-runtime.mjs +1 -0
  166. package/plugins/src/base/skills/lisa-session-manager/scripts/cli-usage.mjs +10 -3
  167. package/plugins/src/base/skills/lisa-session-manager/scripts/cli-workers.mjs +52 -1
  168. package/plugins/src/base/skills/lisa-session-manager/scripts/orphan-sweep.mjs +2 -20
  169. package/plugins/src/base/skills/lisa-session-manager/scripts/session-manager.mjs +5 -1
  170. package/plugins/src/base/skills/lisa-session-manager/scripts/take-check.mjs +110 -0
  171. package/plugins/src/base/skills/lisa-track/SKILL.md +11 -1
  172. package/plugins/src/base/skills/lisa-tracker-claim/SKILL.md +1 -0
  173. package/plugins/src/base/skills/lisa-usage-accounting/references/estimate.md +25 -2
  174. package/scripts/two-channel-couplings.json +1 -1
  175. package/typescript/copy-overwrite/.prettierignore +1 -0
@@ -81,6 +81,23 @@ the manager.
81
81
  entry, exactly as before. A plain all-digit entry is a login here but a numeric id to
82
82
  `item-answer`, so `validate` warns about it; write `login:<v>` or `id:<v>` instead. The `queue`
83
83
  output echoes the entries as `operators`.
84
+ - **Taking an item: assign it to "me".** This is the one statement of the rule; every step below
85
+ that takes, files or moves an item follows it.
86
+ 1. Every item the manager takes is assigned to "me" when it has no assignee: dispatching or
87
+ claiming it, releasing it (Blocked to Ready), re-dispatching or retrying it, or driving it
88
+ as the manager. Never replace an existing assignee: an item assigned to someone other than
89
+ "me" or an operator is never taken, and an operator's assignment is never overwritten.
90
+ 2. Every item the manager files (a promotion ticket, a split child, a follow-up, the retirement
91
+ proposal) is created assigned to "me", unless an operator or another person was named as its
92
+ owner.
93
+ 3. A state move the manager makes on an unassigned item sets the assignee to "me" in the same
94
+ `lisa-tracker-write` update, and the read-back confirms both.
95
+ 4. Before `spawn`, re-read the item with `lisa-tracker-read` and pass its live assignees as
96
+ `--assignees '<json>'`: `[]` when unassigned, GitHub `[{"login":…,"id":…}]` with the REST
97
+ numeric `.assignees[].id`, Jira accountIds, Linear user ids. `spawn` refuses an unassigned
98
+ item, or one held by anyone but "me" or an operator, with exit 5 and launches nothing. An
99
+ unassigned item at that point is a failed claim: assign it to "me", read it back, and spawn
100
+ again; never dispatch it unassigned. `foreign` means someone else holds it: leave it.
84
101
  - **Workers** start only through `spawn`. The worker prompt is exactly
85
102
  `/lisa:implement <REF> managedBy=<manager-name>`; `lisa-implement` owns what `managedBy=` means.
86
103
  Never start a worker another way, and never reuse a worker for another item or a new attempt.
@@ -229,7 +246,8 @@ In this order, every time:
229
246
  leaves a pending question the next cycle finishes, never a marker nobody will remove.
230
247
  3. **Tracker.** One `lisa-tracker-write` update: apply `marker` (add the label, or, when
231
248
  `marker.type` is `role`, move the item to the `blocked` role), for `exhausted` also move the
232
- item to the `blocked` role (`move`), and post `comment` as a comment. Use only the names
249
+ item to the `blocked` role (`move`), and post `comment` as a comment. When that update moves
250
+ an unassigned item, it also assigns it to "me" ("Taking an item"). Use only the names
233
251
  `mark-plan` returned; never hard-code one.
234
252
  4. **Read back** with `lisa-tracker-read`: the marker (and the move) landed and the comment is
235
253
  there. Never claim a mark you did not read back.
@@ -373,7 +391,8 @@ leave the ledger as it is (`markedAt` stays null), carry on with the cycle and e
373
391
  - **`[<REF>] DONE: …` / `[<REF>] FAILED: …` from a worker:**
374
392
  `ledger finish <ref> --status DONE|FAILED --sender <sender>` (reason on STDIN) and post one line
375
393
  to Telegram. On `FAILED`, also move the item to the `blocked`
376
- role through `lisa-tracker-write` with a comment `[lisa-session-manager] Worker failed: <reason>`,
394
+ role through `lisa-tracker-write` with a comment `[lisa-session-manager] Worker failed: <reason>`
395
+ (assigning "me" in the same update when it is unassigned: "Taking an item"),
377
396
  and read both back with `lisa-tracker-read`. When the reason says a
378
397
  design or product decision is needed, mark it instead ("Mark and move on", `--kind decision`).
379
398
 
@@ -475,9 +494,9 @@ shows them.
475
494
  |---|---|
476
495
  | `working`, `waiting`, `finished` | Nothing. |
477
496
  | `requestion` | With Telegram: re-send the pending question once, then re-record it with `ledger set-question` (same text, new message id); that restarts the re-ping clock. With no channel: nothing to re-send; leave it pending. |
478
- | `stalled`, `dead` | Read the item. If it left the `claimed` role, a human moved it: do not retry or move it; `ledger finish <ref> --status FAILED` with reason "left the claimed role outside the manager". Otherwise check for a merged PR first (`gh pr list --state merged --search <ref>` in the item's repo dir). If merged, leave the state change to Lisa's lifecycle and `ledger finish <ref> --status DONE` with reason "PR merged". Otherwise `claude stop <worker>` if it is still listed, then `spawn` a **fresh** attempt when capacity allows (the CLI counts attempts). |
497
+ | `stalled`, `dead` | Read the item. If it left the `claimed` role, a human moved it: do not retry or move it; `ledger finish <ref> --status FAILED` with reason "left the claimed role outside the manager". Otherwise check for a merged PR first (`gh pr list --state merged --search <ref>` in the item's repo dir). If merged, leave the state change to Lisa's lifecycle and `ledger finish <ref> --status DONE` with reason "PR merged". Otherwise `claude stop <worker>` if it is still listed, then re-read the item (after the stop, so a reassignment in the meantime is seen) and `spawn` a **fresh** attempt when capacity allows, with that re-read's `--assignees` ("Taking an item"; the CLI counts attempts). |
479
498
  | `setup-gap` | The worker's first prompt never ran: `setupGap.kind` is `unknown-command` (Lisa's plugin is not visible in that repo, so `/lisa:implement` is unknown there) or `prompt-blocked` (a `UserPromptSubmit` hook rejected the prompt; `setupGap.detail` is what the hook said). Retrying cannot fix it. `claude stop <worker>` if it is still listed, `ledger finish <ref> --status FAILED --setup-gap` with reason "setup gap: <kind>: <detail>" (the spawn is not counted as an attempt). Then read the item: If it left the `claimed` role, a human moved it: respect that and do not move it back to the `ready` role. Otherwise move the item back to the `ready` role. Either way post one plain-language line naming the repo and the fix to Telegram, do not respawn it, do not dispatch to that repo again until the operator fixes it, and end the cycle `recovery-required` with that line as the summary. `classify` has already recorded the repo's setup gap, so later cycles' `queue` leaves that repo out and `spawn` refuses it until the operator fixes the repo and runs `ledger clear-setup-gap <repo>` (`.` on a single-repo project); include that command in the line. |
480
- | `blocked-on-prompt` | The live worker is stuck on a prompt nobody attached can answer: its agent row reports `waitingFor` (e.g. "permission prompt") other than waiting on its own subagent. It will never proceed on its own, however its logs change. `claude stop <worker>` if it is still listed, then `spawn` a **fresh** attempt when capacity allows (the CLI counts attempts; at `stall.maxAttempts` it classifies `exhausted` instead). Send the operator one plain-English line naming the item, the `waitingFor` text, and that the worker was stopped and a fresh attempt starts when capacity allows (Telegram when configured, else the cycle summary). This is once per occurrence: the fresh worker is not blocked, so the same occurrence never repeats. Not a `setup-gap`: the first prompt ran, so the attempt counts and the item stays claimed. |
499
+ | `blocked-on-prompt` | The live worker is stuck on a prompt nobody attached can answer: its agent row reports `waitingFor` (e.g. "permission prompt") other than waiting on its own subagent. It will never proceed on its own, however its logs change. `claude stop <worker>` if it is still listed, then re-read the item and `spawn` a **fresh** attempt when capacity allows, with its `--assignees` ("Taking an item"; the CLI counts attempts; at `stall.maxAttempts` it classifies `exhausted` instead). Send the operator one plain-English line naming the item, the `waitingFor` text, and that the worker was stopped and a fresh attempt starts when capacity allows (Telegram when configured, else the cycle summary). This is once per occurrence: the fresh worker is not blocked, so the same occurrence never repeats. Not a `setup-gap`: the first prompt ran, so the attempt counts and the item stays claimed. |
481
500
  | `exhausted` | Attempts reached `stall.maxAttempts`. Stop the worker if listed, `ledger finish <ref> --status FAILED`, then follow "Mark and move on" with `--kind exhausted` and, as the reason, how many attempts failed and how each ended: it moves the item to the `blocked` role and marks it for a human. |
482
501
 
483
502
  Why a worker started with `--dangerously-skip-permissions` reaches a permission prompt at all is
@@ -535,11 +554,13 @@ just as long. Sweep both every cycle, after `classify` and before Dispatch:
535
554
  or is in the `review` role; leave it where it is. A later cycle that still sees a recent refusal puts the item
536
555
  in `return`, or in `parked` when a person holds it or it is in the `review` role, and retries
537
556
  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
557
+ - `return`: move it to the `ready` role with the entry's `comment` (assigning "me" in the same
558
+ update when it is unassigned: "Taking an item", rule 3). A merged item whose
539
559
  completion was refused, and an item whose pull request was closed without merging, land here
540
560
  with a comment that names that pull request, so the next agent builds on the earlier work.
541
- - `redispatch`: an open pull request and no worker. Claim it (`reused`) and `spawn` it exactly
542
- as Dispatch steps 2.3 and 2.4, ahead of new items, while `capacity` says `can_spawn`. A
561
+ - `redispatch`: an open pull request and no worker. Claim it (`reused`), assigning it to "me"
562
+ when it is unassigned ("Taking an item"), and `spawn` it exactly as Dispatch steps 2.3 and
563
+ 2.4, ahead of new items, while `capacity` says `can_spawn`. A
543
564
  spawn that reaches `stall.maxAttempts` follows the `exhausted` row above.
544
565
  - `parked`: post the entry's `comment` only when `reasonOnItem` is false. An item in the
545
566
  `review` role with an open pull request is parked, never re-dispatched: it is waiting on
@@ -565,12 +586,13 @@ queue below). For each:
565
586
  rule); never treat "blocker closed" as "unblocked".
566
587
  2. Pipe `{labels,body,comments,edges}` as JSON to `blocked-plan --ref <ref>`. Act on `action`:
567
588
  - `release`: dissolve the edges and move the item to the `ready` role in one `lisa-tracker-write`
568
- update, with a comment `[lisa-session-manager] Released: <reason>`; read it back with `lisa-tracker-read` and confirm the
569
- role changed before you claim it did. Notify Telegram.
589
+ update, with a comment `[lisa-session-manager] Released: <reason>`, setting the assignee to
590
+ "me" in that same update when the item is unassigned ("Taking an item"); read it back with
591
+ `lisa-tracker-read` and confirm the role (and the assignee) changed before you claim it did. Notify Telegram.
570
592
  - `decide` (access-only; a blocker was closed NOT PLANNED): relay nothing to the operator. Make
571
593
  the call from the item's and blocker's evidence: re-scope the item to build without the
572
594
  dependency (dissolve the edge and move it to the `ready` role), drop an edge that no longer applies, or
573
- close the item. Post `[lisa-session-manager] Decision: <which> — <why>` in the same
595
+ close the item; a move of an unassigned item also assigns it to "me" ("Taking an item"). Post `[lisa-session-manager] Decision: <which> — <why>` in the same
574
596
  `lisa-tracker-write` update, and read it back before you claim it landed. Notify Telegram.
575
597
  - `keep` with a manager question pending: "Waiting on a human" above handles it.
576
598
  - `keep`, `escalate`, `skip-human-gate`: leave it. Gate self-blocks and clarification blocks
@@ -665,13 +687,17 @@ Skip while `capacity` reports `paused`. Otherwise:
665
687
  entries, which on GitHub is the assignee's numeric id from the REST issue's
666
688
  `.assignees[].id` (not the `id` of a GraphQL-backed `--json assignees` read, which is a node
667
689
  id), on Jira the accountId and on Linear the user id; plain entries as "me" is compared; the
668
- claim assigns only an unassigned item, so an operator's item keeps the operator); anything
669
- else means skip. Then
690
+ claim assigns only an unassigned item, so an operator's item keeps the operator), or on
691
+ `claimed` or `reused` with no assignee, which goes on to the re-read below and its
692
+ assignment repair; anything else (an unsuccessful claim, or an assignee who is neither
693
+ "me" nor an operator) means skip. Then
670
694
  re-read the item with `lisa-tracker-read`: if the re-read shows an assignee that is neither
671
695
  "me" nor an operator, or shows the state did not change to the `claimed` role, skip it
672
- (someone else holds it, or the claim did not land).
696
+ (someone else holds it, or the claim did not land). If it shows no assignee at all, the
697
+ claim failed to assign: assign it to "me" ("Taking an item") and re-read before going on.
673
698
  Never spawn on the claim's word alone.
674
- 4. **Spawn.** `spawn <ref> [--repo <key>]`.
699
+ 4. **Spawn.** `spawn <ref> --assignees '<json>' [--repo <key>]`, with the assignees the step 3
700
+ re-read showed ("Taking an item", rule 4).
675
701
  - exit 0: post `[<REF>] started in <repo> (<name>)` to Telegram.
676
702
  - exit 3 (no capacity): move the item back to the `ready` role and stop dispatching.
677
703
  - exit 4 (a live worker holds it): if the ledger has no item for it, record it with
@@ -692,6 +718,9 @@ Skip while `capacity` reports `paused`. Otherwise:
692
718
  message as the summary.
693
719
  - `already-recorded` (the operator was told when it was recorded): post nothing and
694
720
  continue with the next item.
721
+ - exit 5 (not taken; nothing launched): `reason` `unassigned` means assign the item to "me"
722
+ through `lisa-tracker-write`, read it back, and spawn again with the new assignees;
723
+ `foreign` means someone else holds it, so leave it where it is and continue.
695
724
  - any other exit: move the item back to the `ready` role, notify Telegram, continue.
696
725
  3. **Backlog tier, lowest priority.** Only when `backlogPickup` is on, every `ordered` item has been
697
726
  taken or skipped, and `capacity` still says `can_spawn`. Ready work always wins: never promote a
@@ -767,7 +796,8 @@ tracker-derived), it holds when BOTH: a date-filtered tracker search finds no it
767
796
  `claimed` role in the trailing 14 days, AND this cycle found zero Ready candidates. Then record
768
797
  `policy-obsolete` and file **one** proposal through `lisa-tracker-write`, deduped on the marker
769
798
  `[lisa-session-manager-retirement]` (search open and closed items for it first; never match on the
770
- title), proposing `/lisa:tear-down-automations session-manager` or a longer `interval`. Keep running.
799
+ title), proposing `/lisa:tear-down-automations session-manager` or a longer `interval`, assigned to "me"
800
+ ("Taking an item", rule 2). Keep running.
771
801
 
772
802
  Record with the summary (one plain line, the contract's exemplar voice) on STDIN:
773
803
 
@@ -32,6 +32,7 @@ export const EXIT = Object.freeze({
32
32
  SETUP: 2,
33
33
  NO_CAPACITY: 3,
34
34
  LIVE_WORKER: 4,
35
+ NOT_TAKEN: 5,
35
36
  });
36
37
 
37
38
  /** The config files Lisa reads, local over global per key. */
@@ -14,7 +14,8 @@ prints a bare path); errors go to stderr. Untrusted text (answers, questions,
14
14
  reasons, Telegram messages, summaries) is read from STDIN, never from argv.
15
15
 
16
16
  Exit codes: 0 ok; 1 a command failed (claude, tmux or gh error); 2 bad repo,
17
- bad config or bad usage; 3 no capacity; 4 a live worker already holds the ref.
17
+ bad config or bad usage; 3 no capacity; 4 a live worker already holds the ref;
18
+ 5 spawn refused an item that was not taken (unassigned or someone else's).
18
19
 
19
20
  Workers and capacity
20
21
  capacity [--max-workers <n>]
@@ -24,10 +25,16 @@ Workers and capacity
24
25
  (capacity and spawn also take --meminfo <file>, a TEST-ONLY flag that
25
26
  reads memory from a Linux meminfo file instead of this host. Skills
26
27
  never pass it.)
27
- spawn <ref> [--repo <key>] [--max-workers <n>]
28
+ spawn <ref> --assignees <json> [--repo <key>] [--max-workers <n>]
29
+ --assignees is required: the JSON array of the item's live assignees
30
+ as read back from the tracker, [] when unassigned (GitHub [{login,id}]
31
+ with the REST numeric id; Jira accountIds; Linear user ids).
28
32
  Checks, in order: repo dir resolves and has .lisa.config.json (exit 2);
29
33
  capacity (exit 3, stdout = capacity report); no live wk- worker for the
30
- ref (exit 4, stdout = {ref,worker,sessionId}); no recorded setup gap
34
+ ref (exit 4, stdout = {ref,worker,sessionId}); --assignees present (exit
35
+ 2) and the item taken: at least one assignee, every one "me" (ledger
36
+ control.me) or a sessionManager.operatorIds entry (exit 5, stdout =
37
+ {ref,reason:"unassigned"|"foreign",me,foreign}); no recorded setup gap
31
38
  for the repo (exit 2, nothing launched or recorded: fix the repo, then
32
39
  ledger clear-setup-gap <repo>); no pending question in
33
40
  the ledger for the ref (exit 2: clear it first). Then runs, with cwd = repo
@@ -5,7 +5,9 @@
5
5
  * `spawn` is the one that starts yolo-mode sessions, so its checks run in a
6
6
  * fixed order and each has its own exit code the manager skill branches on:
7
7
  * the repo must be a Lisa repo (2), there must be capacity (3), and no live
8
- * worker may already hold the ref (4). Only then does it run
8
+ * worker may already hold the ref (4), and the item must be taken: its
9
+ * read-back assignees (`--assignees`) name "me" or an operator and nobody
10
+ * else (5, take-check.mjs). Only then does it run
9
11
  * `claude --bg`, with the cwd set to the routed repo and every `TELEGRAM_*`
10
12
  * variable removed from the worker's environment. A repo whose workspace
11
13
  * trust was never accepted is exit 2 too (see worker-launch.mjs). So is a
@@ -25,6 +27,8 @@ import { createHash } from "node:crypto";
25
27
  import { readFile } from "node:fs/promises";
26
28
 
27
29
  import { computeCapacity, readMachineStats } from "./capacity.mjs";
30
+ import { parseJson } from "./json-input.mjs";
31
+ import { judgeTake } from "./take-check.mjs";
28
32
  import {
29
33
  CliError,
30
34
  EXIT,
@@ -260,6 +264,7 @@ export async function spawn(ctx) {
260
264
  }
261
265
 
262
266
  const ledger = await readLedger(ctx.root);
267
+ refuseUntaken(ctx, config, ledger, ref);
263
268
  const repo = key ?? ".";
264
269
  refuseSetupGap(ledger, repo);
265
270
  // A spawn no longer clears a pending question (lisa#4571), and a worker
@@ -299,6 +304,52 @@ export async function spawn(ctx) {
299
304
  return { json: { ref, name, sessionId, repo, cwd: repoDir, firstPrompt } };
300
305
  }
301
306
 
307
+ /**
308
+ * Refuse, with exit 5, an item that was not taken: the assign-on-take rule.
309
+ * `--assignees` is the JSON array of the item's live assignees as the
310
+ * manager read them back (`[]` when nobody is assigned): GitHub
311
+ * `{login, id}` objects, Jira accountIds, Linear user ids. Missing or not an
312
+ * array is exit 2, so no caller can skip the check by leaving it out.
313
+ * @param {object} ctx - CLI context
314
+ * @param {{operatorIds?: unknown}} config - Session-manager config
315
+ * @param {Awaited<ReturnType<typeof readLedger>>} ledger - Ledger
316
+ * @param {string} ref - Item ref
317
+ * @returns {void}
318
+ */
319
+ function refuseUntaken(ctx, config, ledger, ref) {
320
+ const raw = ctx.values.assignees;
321
+ const assignees =
322
+ raw === undefined ? undefined : parseJson(raw, "--assignees");
323
+ if (!Array.isArray(assignees)) {
324
+ throw new CliError(
325
+ `spawn needs --assignees: the JSON array of ${ref}'s live assignees ` +
326
+ "as read back from the tracker ([] when unassigned).",
327
+ EXIT.SETUP
328
+ );
329
+ }
330
+ const me = ledger.control.me ?? null;
331
+ const project = loadProject(ctx.root);
332
+ const verdict = judgeTake(assignees, {
333
+ me,
334
+ operatorIds: config.operatorIds,
335
+ tracker: project.local?.tracker ?? project.global?.tracker,
336
+ });
337
+ if (verdict.ok) return;
338
+ const message =
339
+ verdict.reason === "unassigned"
340
+ ? `${ref} is unassigned; nothing was spawned. Assign it to "me" ` +
341
+ `(${me ?? "not recorded: run ledger control --me <id>"}), read it ` +
342
+ "back, and spawn again."
343
+ : `${ref} is assigned to someone other than "me" or an operator ` +
344
+ `(${verdict.foreign.join(", ")}); nothing was spawned. Leave it.`;
345
+ throw new CliError(message, EXIT.NOT_TAKEN, {
346
+ ref,
347
+ reason: verdict.reason,
348
+ me,
349
+ foreign: verdict.foreign,
350
+ });
351
+ }
352
+
302
353
  /**
303
354
  * The ledger row for `ref`, or exit 2.
304
355
  * @param {Awaited<ReturnType<typeof readLedger>>} ledger - Ledger
@@ -22,11 +22,11 @@
22
22
  * @module session-manager/orphan-sweep
23
23
  */
24
24
  import {
25
- entryMatches,
26
25
  idComparableValues,
27
26
  parseIdEntries,
28
27
  } from "../../../scripts/operator-id-kinds.mjs";
29
28
  import { holdDigest, judgeHold } from "./orphan-holds.mjs";
29
+ import { assigneeFields, isMeOrOperator } from "./take-check.mjs";
30
30
  import { FINISH_RETRY_HOURS, classifyOrphan } from "./orphan-buckets.mjs";
31
31
 
32
32
  export {
@@ -62,22 +62,6 @@ function idOrNull(value) {
62
62
  return Number.isSafeInteger(value) ? String(value) : null;
63
63
  }
64
64
 
65
- /**
66
- * The fields one assignee is compared on, the way `queue` compares them: a
67
- * plain string is the tracker's normalized id (GitHub login, Jira accountId,
68
- * Linear user id); a `{login, id}` object adds the kind-keyed fields.
69
- * @param {unknown} assignee - One assignee as the tracker gave it
70
- * @returns {{plain: string|null, login: string|null, id: string|null}} Fields
71
- */
72
- function assigneeFields(assignee) {
73
- if (assignee !== null && typeof assignee === "object") {
74
- const login = idOrNull(assignee.login);
75
- const id = idOrNull(assignee.id ?? assignee.accountId);
76
- return { plain: login ?? id, login, id };
77
- }
78
- return { plain: idOrNull(assignee), login: null, id: null };
79
- }
80
-
81
65
  /**
82
66
  * Whether any assignee is neither "me" nor an operator.
83
67
  * @param {unknown} assignees - The item's assignees
@@ -87,9 +71,7 @@ function assigneeFields(assignee) {
87
71
  function heldBySomeoneElse(assignees, who) {
88
72
  return (Array.isArray(assignees) ? assignees : []).some(assignee => {
89
73
  const fields = assigneeFields(assignee);
90
- if (fields.plain === null) return false;
91
- if (who.me !== null && fields.plain === who.me) return false;
92
- return !who.operators.some(entry => entryMatches(entry, fields));
74
+ return fields.plain !== null && !isMeOrOperator(fields, who);
93
75
  });
94
76
  }
95
77
 
@@ -69,7 +69,11 @@ const MEASURE = { "max-workers": text, meminfo: text };
69
69
  /** Each subcommand: handler, accepted flags, and how many positionals. */
70
70
  const COMMANDS = {
71
71
  capacity: { run: capacity, options: MEASURE, positionals: 0 },
72
- spawn: { run: spawn, options: { ...MEASURE, repo: text }, positionals: 1 },
72
+ spawn: {
73
+ run: spawn,
74
+ options: { ...MEASURE, repo: text, assignees: text },
75
+ positionals: 1,
76
+ },
73
77
  resume: { run: resume, options: {}, positionals: 1 },
74
78
  classify: { run: classify, options: {}, positionals: 1 },
75
79
  status: { run: status, options: {}, positionals: 0 },
@@ -0,0 +1,110 @@
1
+ /**
2
+ * The assign-on-take rule (CodySwannGT/lisa#5029), as a check `spawn` runs
3
+ * before it launches anything.
4
+ *
5
+ * The rule (runbook "Fixed facts", "Taking an item"): every item the manager
6
+ * takes is assigned to "me" when it has no assignee, and nothing is ever
7
+ * dispatched unassigned. The claim step used to do the assigning implicitly,
8
+ * and the dispatch step accepted the claim's word for it, so an item the
9
+ * manager released, re-dispatched or drove itself could reach a worker with
10
+ * nobody named on it. `spawn` now needs the assignees the manager read back
11
+ * from the tracker (`--assignees`) and refuses, with exit 5, an item that is
12
+ * unassigned or held by anyone other than "me" or an operator.
13
+ *
14
+ * An assignee is compared exactly as the queue and the orphan sweep compare
15
+ * one: a plain string is the tracker's normalized id (GitHub login, Jira
16
+ * accountId, Linear user id), and a `{login, id}` object (GitHub, with the
17
+ * REST numeric id) also matches `login:` and `id:` operator entries.
18
+ * Pure: no I/O.
19
+ * @module session-manager/take-check
20
+ */
21
+ import {
22
+ entryMatches,
23
+ parseIdEntries,
24
+ } from "../../../scripts/operator-id-kinds.mjs";
25
+
26
+ /**
27
+ * A trimmed id string, or null. Numeric ids become strings.
28
+ * @param {unknown} value - Raw id
29
+ * @returns {string | null} Comparable id
30
+ */
31
+ function idOrNull(value) {
32
+ if (typeof value === "string" && value.trim() !== "") return value.trim();
33
+ return Number.isSafeInteger(value) ? String(value) : null;
34
+ }
35
+
36
+ /**
37
+ * The fields one assignee is compared on: a plain string is the tracker's
38
+ * normalized id (GitHub login, Jira accountId, Linear user id); a
39
+ * `{login, id}` object adds the kind-keyed fields.
40
+ * @param {unknown} assignee - One assignee as the tracker gave it
41
+ * @returns {{plain: string|null, login: string|null, id: string|null}} Fields
42
+ */
43
+ export function assigneeFields(assignee) {
44
+ if (assignee !== null && typeof assignee === "object") {
45
+ const login = idOrNull(assignee.login);
46
+ const id = idOrNull(assignee.id ?? assignee.accountId);
47
+ return { plain: login ?? id, login, id };
48
+ }
49
+ return { plain: idOrNull(assignee), login: null, id: null };
50
+ }
51
+
52
+ /**
53
+ * The fields `spawn` compares one read-back assignee on. A plain string means
54
+ * what the tracker's normalized id is: on GitHub a login (so `login:` entries
55
+ * match it and `id:` entries never do, since anyone can pick an all-digit
56
+ * login), and on Jira and Linear an account id (so `id:` entries match it).
57
+ * With no known tracker it keeps `assigneeFields`' plain-only reading.
58
+ * @param {unknown} assignee - One assignee as read back
59
+ * @param {string | undefined} tracker - `github`, `jira` or `linear`
60
+ * @returns {{plain: string|null, login: string|null, id: string|null}} Fields
61
+ */
62
+ function takenFields(assignee, tracker) {
63
+ const fields = assigneeFields(assignee);
64
+ if (typeof assignee !== "string" || fields.plain === null) return fields;
65
+ if (tracker === "github") return { ...fields, login: fields.plain };
66
+ if (tracker === "jira" || tracker === "linear") {
67
+ return { ...fields, id: fields.plain };
68
+ }
69
+ return fields;
70
+ }
71
+
72
+ /**
73
+ * Whether one assignee is "me" or an operator.
74
+ * @param {{plain: string|null, login: string|null, id: string|null}} fields - Assignee fields
75
+ * @param {{me: string|null, operators: object[]}} who - Identities
76
+ * @returns {boolean} True for "me" or an operator
77
+ */
78
+ export function isMeOrOperator(fields, who) {
79
+ if (fields.plain === null) return false;
80
+ if (who.me !== null && fields.plain === who.me) return true;
81
+ return who.operators.some(entry => entryMatches(entry, fields));
82
+ }
83
+
84
+ /**
85
+ * Judge whether an item may be dispatched under the assign-on-take rule.
86
+ * @param {unknown} assignees - The item's live assignees, as read back
87
+ * @param {{me?: string|null, operatorIds?: unknown, tracker?: string}} identities - "Me"
88
+ * (`ledger control.me`), `sessionManager.operatorIds`, and the project's
89
+ * tracker, which says what a plain assignee string is
90
+ * @returns {{ok: true} | {ok: false, reason: "unassigned"|"foreign", foreign: string[]}}
91
+ * `unassigned`: nobody is named, so assign "me" and read it back first;
92
+ * `foreign`: someone other than "me" or an operator holds it, so leave it
93
+ */
94
+ export function judgeTake(assignees, identities) {
95
+ const who = {
96
+ me: idOrNull(identities.me),
97
+ operators: parseIdEntries(identities.operatorIds),
98
+ };
99
+ const named = (Array.isArray(assignees) ? assignees : [])
100
+ .map(assignee => takenFields(assignee, identities.tracker))
101
+ .filter(fields => fields.plain !== null);
102
+ if (named.length === 0)
103
+ return { ok: false, reason: "unassigned", foreign: [] };
104
+ const foreign = named
105
+ .filter(fields => !isMeOrOperator(fields, who))
106
+ .map(fields => fields.plain);
107
+ return foreign.length === 0
108
+ ? { ok: true }
109
+ : { ok: false, reason: "foreign", foreign };
110
+ }
@@ -125,7 +125,15 @@ Otherwise:
125
125
 
126
126
  3. Read the binding back through `node scripts/lisa-work-item.mjs current` and require it to equal the canonical reference. If binding fails, stop before durable project work.
127
127
  - A detached-HEAD worktree is valid at this stage: the binding records `branch: null` as a pending state. Create the feature branch only after the gate succeeds, then run `node scripts/lisa-work-item.mjs attach-branch`. Commit preparation and validation fail closed until that attachment succeeds.
128
- 4. **Ignore guard before any write.** A host can receive these skills before its shipped `.gitignore` entry, so prove the path is ignored first, from the worktree root: `git check-ignore -q .lisa/work-item-context.md || printf '%s\n' '.lisa/work-item-context.md' >> "$(git rev-parse --git-common-dir)/info/exclude"`, then re-run `git check-ignore -q .lisa/work-item-context.md`. If it is still not ignored, stop and report — do not write the bundle. If an `.easignore` exists and `grep -qxF '.lisa/work-item-context.md' .easignore` fails, stop and report instead of writing: EAS uploads read `.easignore`, which is derived from `.gitignore`, not from `info/exclude`. Then write the full resolved work-item context — the live vendor read bundle, unedited, every comment included — to the worktree-local, git-ignored `<worktree root>/.lisa/work-item-context.md`, then return this structured result (the file is the context; a summary in the reply never substitutes for it). When a `caller_bundle_path` was forwarded for this work item and the file already exists, do not overwrite it — it holds the caller's bundle (or a previous run's) and is left for the resolver step. Otherwise this is the first write; when `lisa-implement` forwarded a `caller_bundle_path`, its resolver step then keeps the bundle at that path as the base and appends only what this live read adds, and in every case finishes it with the `## Comment inventory` section:
128
+ 4. **Token estimate before any work** (`work-item-definition-of-ready`, gate S21; contract in the `lisa-usage-accounting` skill's `references/estimate.md`). Write the item's live body to a scratch file and run `node scripts/lisa-estimate.mjs check --phase claim --body-file <file>`. Exit 0 (`PASS`, or `N/A` because `workItem.estimate.required` is `false`) → continue. Exit 1 because the estimate is missing → estimate it now, yourself; never ask a person and never stop for one:
129
+ 1. Pick a first token range and a recommended model from `workItem.estimate.models` (`node scripts/lisa-estimate.mjs config` prints them) by reading the item: scope, files it touches, type, how much verification it needs.
130
+ 2. Calibrate it. Fetch the bodies of up to 20 comparable finished items in this repository — same type, closed or done, carrying a `## Lisa Estimate` section — as a JSON array (GitHub: `gh issue list --repo <org>/<repo> --state closed --label <type label> --search '"Lisa Estimate" in:body' --limit 20 --json body`. Jira and Linear projects can serve several repositories, so scope those searches to this one by its `repo:<name>` label (the repo marker in the `config-resolution` rule; `<name>` is this repository's short name). Jira: through `lisa-atlassian-access`, `operation: search-issues jql:"project = <KEY> AND labels = \"repo:<name>\" AND issuetype = <type> AND statusCategory = Done AND text ~ \"Lisa Estimate\" ORDER BY resolved DESC"`, the first 20. Linear: through `lisa-linear-access`, `operation: list-issues team:<ID> label:repo:<name> state_type:["completed"]`. A listing may not carry full descriptions and has no body search, so read each candidate with `lisa-linear-access` `operation: get-issue id:<ID>` and keep the first 20 that carry the item's type label and a `## Lisa Estimate` section in that full description. Save each item's description as markdown text in `[{"body": "..."}]`). Run `node scripts/lisa-estimate.mjs calibrate --tokens-low <n> --tokens-high <n> --history-file <file>` and use the range and `basis` it prints. With no history it says so; keep your range.
131
+ 3. Render and write it: `node scripts/lisa-estimate.mjs render --tokens-low <n> --tokens-high <n> --model <id> --basis "<basis>" --body-file <file>` prints the whole body with the section in place. Write that body back through `lisa-tracker-write` (update), read the item back, and rerun the claim-phase check on the stored body; it must exit 0.
132
+
133
+ Exit 1 because a present estimate is malformed → re-render it the same way.
134
+
135
+ An estimate failure never blocks the work. The item is already claimed, and stopping here would strand it in the claimed state with no trace of why. When a check exits 2, calibration or rendering fails, or the written body does not read back with a passing claim-phase check, continue to step 5 with `estimate_outcome: failed` and `estimate_failure: <reason>`, and post one comment on the item through `lisa-tracker-write` that a non-technical reader can follow, for example: "Lisa could not record a cost estimate for this item before starting work, because the project's estimate settings could not be read. The work is going ahead without one. What it actually cost will still be recorded when it is done." Name the real reason in plain words, not an exit code. Record `estimate_outcome: present|written|failed|n/a` in the result.
136
+ 5. **Ignore guard before any write.** A host can receive these skills before its shipped `.gitignore` entry, so prove the path is ignored first, from the worktree root: `git check-ignore -q .lisa/work-item-context.md || printf '%s\n' '.lisa/work-item-context.md' >> "$(git rev-parse --git-common-dir)/info/exclude"`, then re-run `git check-ignore -q .lisa/work-item-context.md`. If it is still not ignored, stop and report — do not write the bundle. If an `.easignore` exists and `grep -qxF '.lisa/work-item-context.md' .easignore` fails, stop and report instead of writing: EAS uploads read `.easignore`, which is derived from `.gitignore`, not from `info/exclude`. Then write the full resolved work-item context — the live vendor read bundle, unedited, every comment included — to the worktree-local, git-ignored `<worktree root>/.lisa/work-item-context.md`, then return this structured result (the file is the context; a summary in the reply never substitutes for it). When a `caller_bundle_path` was forwarded for this work item and the file already exists, do not overwrite it — it holds the caller's bundle (or a previous run's) and is left for the resolver step. Otherwise this is the first write; when `lisa-implement` forwarded a `caller_bundle_path`, its resolver step then keeps the bundle at that path as the base and appends only what this live read adds, and in every case finishes it with the `## Comment inventory` section:
129
137
 
130
138
  ```text
131
139
  tracker_provider: jira|github|linear
@@ -136,6 +144,8 @@ Otherwise:
136
144
  gate_reason: <the act a person must perform>|null
137
145
  claim_outcome: claimed|reused|held-by-gate|blocked-ci-loop
138
146
  binding_outcome: verified|skipped-human-gate|skipped-ci-loop
147
+ estimate_outcome: present|written|failed|n/a
148
+ estimate_failure: <plain-English reason>|null
139
149
  route: implement|ci-rework pr=<n>|blocked pr=<n>
140
150
  failing_checks: <comma-separated check names from the marker comment>|none
141
151
  head_ref: <the pull request's head branch>|null
@@ -33,3 +33,4 @@ Thin dispatcher. `$ARGUMENTS` must contain exactly one canonical work-item refer
33
33
  - A fresh claim uses the same idempotency lock as the three build-intake Phase 3b flows: move configured ready to configured claimed, or place an unlaned backlog leaf directly in claimed; assign to the authenticated user only when unassigned; never replace an existing owner.
34
34
  - Fail closed if the mutation or post-write read cannot prove the claimed-or-later state. A tracker outage is a blocker, not permission to work untracked.
35
35
  - This skill claims existing work only. It never creates a ticket and never writes the worktree binding.
36
+ - A claim does not satisfy the token-estimate gate (S21). `lisa-track` step 4 runs the claim-phase check right after the claim and, when the item has no estimate, writes one before any work begins. Every dispatch path (direct `lisa-implement`, the build-intake flows, the session manager) reaches work through `lisa-track`, so that step is the single owner.
@@ -64,8 +64,31 @@ stored bytes.
64
64
  file items they cannot estimate. Validator gate S21 (`lisa-estimate.mjs check`) refuses only an
65
65
  estimate that is present and wrong: no parseable token, an inverted range, a model outside
66
66
  `models`, or a dollar range that disagrees with the price table the token names.
67
- - **Before work begins:** required. The claiming agent estimates a claimed item that lacks one and
68
- writes it before doing any work. It never asks a person.
67
+ - **Before work begins:** required. `lisa-track` step 4, which every dispatch path runs right
68
+ after the claim, checks with `lisa-estimate.mjs check --phase claim`. A claimed item without an
69
+ estimate fails that check, and the claiming agent estimates it and writes it before doing any
70
+ work. It never asks a person.
71
+ If estimating itself fails, the work still goes ahead: the agent records
72
+ `estimate_outcome: failed` and posts a plain-English comment on the item saying why.
69
73
  - **When the config is off:** nothing about estimates blocks; the check reports `N/A`.
70
74
 
75
+ ## Calibration
76
+
77
+ Estimates improve by learning from finished work. Before rendering, the claiming agent fetches up
78
+ to 20 comparable finished items (same repository, same type, carrying a `## Lisa Estimate`
79
+ section) as a JSON array of bodies and runs:
80
+
81
+ ```bash
82
+ node scripts/lisa-estimate.mjs calibrate --tokens-low 1M --tokens-high 2M --history-file <items.json>
83
+ ```
84
+
85
+ For each item with both an estimate and a complete actual (its `## Lisa Usage` rollup
86
+ `total_tokens`, counted only when every run in the ledger has a full token count), the ratio is
87
+ the actual over the estimate's midpoint. The median ratio scales the new range, and the printed
88
+ `basis` (for example "calibrated x2 (median actual/estimate) from 3 comparable finished item(s)")
89
+ goes into the section. Items whose actual is unknown or partial — no ledger, any run with
90
+ `unavailable` telemetry, or a `measured-subset` entry — are skipped, never counted as zero or as
91
+ the sum of only the known runs. With
92
+ no usable history the range is unchanged and the basis says "no calibration history".
93
+
71
94
  The recommended model is recorded only. It does not choose which model or agent runs the work.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-expo",
3
- "version": "7.0.3",
3
+ "version": "7.1.0",
4
4
  "description": "Expo/React Native-specific skills, agents, rules, and MCP servers",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-expo",
3
- "version": "7.0.3",
3
+ "version": "7.1.0",
4
4
  "description": "Expo and React Native-specific skills, agents, rules, and MCP servers.",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-expo",
3
- "version": "7.0.3",
3
+ "version": "7.1.0",
4
4
  "description": "Expo/React Native-specific skills, agents, rules, and MCP servers",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-expo",
3
- "version": "7.0.3",
3
+ "version": "7.1.0",
4
4
  "description": "Expo/React Native-specific skills, agents, rules, and MCP servers",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-expo",
3
- "version": "7.0.3",
3
+ "version": "7.1.0",
4
4
  "description": "Expo/React Native-specific skills, agents, rules, and MCP servers",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-expo",
3
- "version": "7.0.3",
3
+ "version": "7.1.0",
4
4
  "description": "Expo/React Native-specific skills, agents, rules, and MCP servers",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-expo",
3
- "version": "7.0.3",
3
+ "version": "7.1.0",
4
4
  "description": "Expo/React Native-specific skills, agents, rules, and MCP servers",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-harper-fabric",
3
- "version": "7.0.3",
3
+ "version": "7.1.0",
4
4
  "description": "Harper/Fabric-specific rules for TypeScript component apps",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-harper-fabric",
3
- "version": "7.0.3",
3
+ "version": "7.1.0",
4
4
  "description": "Harper/Fabric-specific Lisa rules for TypeScript component apps.",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-harper-fabric",
3
- "version": "7.0.3",
3
+ "version": "7.1.0",
4
4
  "description": "Harper/Fabric-specific rules for TypeScript component apps",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-harper-fabric",
3
- "version": "7.0.3",
3
+ "version": "7.1.0",
4
4
  "description": "Harper/Fabric-specific rules for TypeScript component apps",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-harper-fabric",
3
- "version": "7.0.3",
3
+ "version": "7.1.0",
4
4
  "description": "Harper/Fabric-specific rules for TypeScript component apps",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-harper-fabric",
3
- "version": "7.0.3",
3
+ "version": "7.1.0",
4
4
  "description": "Harper/Fabric-specific rules for TypeScript component apps",
5
5
  "author": {
6
6
  "name": "Cody Swann"