@sjawhar/claude-envoy 2.6.0 → 2.7.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 (26) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/.omp-plugin/plugin.json +1 -1
  3. package/AGENTS.md +13 -3
  4. package/dist/envoy-channel.js +68 -27
  5. package/legion/skills/legion-architect/SKILL.md +1 -1
  6. package/legion/skills/legion-architect/references/acceptance.md +49 -52
  7. package/legion/skills/legion-architect/references/design-gate.md +4 -5
  8. package/legion/skills/legion-architect/references/wake-routing.md +7 -16
  9. package/legion/skills/legion-controller/SKILL.md +2 -2
  10. package/legion/skills/legion-controller/references/admission.md +4 -5
  11. package/legion/skills/legion-controller/references/backlog-stewardship.md +3 -4
  12. package/legion/skills/legion-controller/references/escalation.md +8 -7
  13. package/legion/skills/legion-controller/references/finding-asks.md +1 -1
  14. package/legion/skills/legion-controller/references/session.md +1 -1
  15. package/legion/skills/legion-controller/references/slack-mentions.md +1 -1
  16. package/legion/skills/legion-controller/references/triage.md +1 -1
  17. package/legion/skills/legion-controller/references/wakes.md +6 -4
  18. package/legion/skills/legion-retro/SKILL.md +13 -19
  19. package/legion/skills/legion-worker/SKILL.md +12 -8
  20. package/legion/skills/legion-worker/references/conflicts-and-rewrites.md +3 -3
  21. package/legion/skills/legion-worker/references/merge-gate.md +110 -151
  22. package/legion/skills/legion-worker/references/pr-body.md +15 -14
  23. package/legion/skills/legion-worker/references/review-threads.md +4 -4
  24. package/package.json +2 -2
  25. package/src/legion-phase-hook.ts +25 -11
  26. package/legion/skills/legion-architect/references/merge-notices.md +0 -104
@@ -1,22 +1,19 @@
1
- # The merge gate: review, acceptance, retro, READY, the merge, and the production check
1
+ # The merge gate: review, acceptance, retro, the merge, and the production check
2
2
 
3
3
  Part of `skill://legion-worker`. Read it when you are the reviewer submitting a review or an
4
- approval, the tester on a look of its closed issue's production check, or the merger
5
- building READY. Every path it cites is in cybermonklabs/legion.
4
+ approval, the tester on a look of its closed issue's production check, or the merger merging
5
+ the pull request. Every path it cites is in cybermonklabs/legion.
6
6
 
7
7
  The order, in full: the tester's evidence green → the reviewer's approval of the head → the
8
- architect's acceptance, in `accepting` → retro → the merger's READY → the merge, which closes the
9
- issue → the production check after the close, which the project's `production_check` setting
10
- gives to a role or takes away. Every handoff is a record on the
11
- Dispatch issue, never a commit, so the head that merges carries none. Retro commits nothing
12
- (*Retro*, below), so the approved head is the head that merges. READY still lets a commit that
13
- changes only `docs/solutions/` stand, and a change whose every path is under `.legion/`, where
14
- handoffs lived before they moved to the Dispatch issue and which nothing writes or reads now, so
15
- nobody reviews a path there, whatever GitHub's compare says the change did to it.
16
- A conflict-forced merge goes back to the reviewer for a
17
- confirmation or a new round, as the fingerprint decides (*The reviewer*, below, and
18
- `skill://legion-worker/references/conflicts-and-rewrites.md`), unless READY refused it, and any
19
- other change to the head voids it.
8
+ architect's acceptance, in `accepting` → retro → the merger's merge of the head it read, which
9
+ closes the issue → the production check after the close, which the project's `production_check`
10
+ setting gives to a role or takes away. Every handoff is a record on the Dispatch issue, never a
11
+ commit, so the head that merges carries none. Retro commits nothing (*Retro*, below), so the
12
+ approved head is the head that merges, and no Legion check holds the head that merges to the head
13
+ the review approved in any case: a repository that wants its newest push reviewed says so in its
14
+ own rulesets. A conflict-forced merge goes back to the reviewer for a confirmation or a new round,
15
+ as the fingerprint decides (*The reviewer*, below, and
16
+ `skill://legion-worker/references/conflicts-and-rewrites.md`).
20
17
 
21
18
  ## The reviewer
22
19
 
@@ -82,8 +79,21 @@ other change to the head voids it.
82
79
  reviewed — always named by SHA — carrying every inline comment in that single
83
80
  call: `gh api --method POST repos/{owner}/{repo}/pulls/{number}/reviews --input body.json`
84
81
  with `commit_id`, `event` (`REQUEST_CHANGES` or `APPROVE`), `body` (with the
85
- Legion footer), and a `comments[]` array of `{path, line, side, body}`, one entry per
82
+ Legion footer, which names the head the review read:
83
+ `<!-- legion: {"session":"<session-id>","phase":"review","head":"<the head you reviewed>"} -->`),
84
+ and a `comments[]` array of `{path, line, side, body}`, one entry per
86
85
  finding — never one `pr review` call per finding (each submission fires a `pr-review` wake).
86
+ That `head` is the full 40-character SHA of the head whose diff and checks you read, which is
87
+ the `commit_id` you submit with, and never the head GitHub shows at the moment you submit:
88
+ read `gh pr view <n> --repo <owner>/<repo> --json headRefOid --jq .headRefOid` before you
89
+ submit, and where it names another head a push landed under you, so review that head and
90
+ submit at it rather than renaming the footer to a head you have not read.
91
+ The daemon takes that head as the review's own word for the code it read, and cannot take GitHub's
92
+ `commit_id` for the review instead, which GitHub rewrites onto the pull request's current head,
93
+ so its record of a review can name a head the review never saw.
94
+ A review whose footer names another head, or no head, decides no round:
95
+ it is set aside, the round stays open and the
96
+ architect is told the reason when the review's own webhook arrived, so the reviewer submits again at the head it read.
87
97
  A `COMMENT` decides nothing. After a
88
98
  forward merge, compute the fingerprint (*The unchanged-diff check* in
89
99
  `skill://legion-worker/references/conflicts-and-rewrites.md`) at the
@@ -92,10 +102,7 @@ other change to the head voids it.
92
102
  and the fingerprint — a confirmation, not a round; no thermo pass, no thread pass. Equal and
93
103
  that review was `COMMENT` or `REQUEST_CHANGES`: continue that round against the new head;
94
104
  nothing restarts. Different, or either run printed no fingerprint: a new round — thermo again,
95
- one review. A return whose task's `Reason:` names a READY refusal is never a confirmation, even
96
- after a forward merge, and a no-fix `REQUEST_CHANGES` that answered one is never continued: the round
97
- after it reviews the refused change in full from the last `APPROVE` (*Retro's commits do not
98
- void the reviewer's approval* below).
105
+ one review.
99
106
  - Answer every thread you opened, and every thread a bot opened that is none of Legion's role
100
107
  Apps, as `skill://legion-worker/references/review-threads.md` says; the same reference says
101
108
  when every thread is settled enough to approve, and resolving one never gates your approval.
@@ -108,17 +115,14 @@ other change to the head voids it.
108
115
  `stuckApprovedOtherCode` in `packages/daemon/internal/workflow/review.go`, and the cases "the
109
116
  approval, then a push" and "a push, then the approval of the head before it" in
110
117
  `packages/daemon/internal/workflow/review_test.go`). GitHub runs the branch's workflows on that
111
- push, as on every push. Wait for that head's required checks to be
112
- green, and approve only then. The daemon sends nothing back for a red at a head the review App
113
- pushed (`PlannedRed` in `classify/decisions.go`), so your own read is the only one. A red you
114
- approve over reaches nobody: the tree runs on to the merge, where GitHub holds the pull request
115
- under the base branch's required checks until someone reads them. A red there is a
118
+ push, as on every push. Wait for that head's required checks to be green, and approve only
119
+ then: nothing but your own read catches a check your prose broke, since the daemon moves the
120
+ issue for no check at all. A red you approve over reaches nobody who will act on it: the tree
121
+ runs on to the merge, where GitHub holds the pull request under the base branch's required
122
+ checks until someone reads them. A red there is a
116
123
  `REQUEST_CHANGES` when the code is at fault, and your own commit to fix when your prose broke
117
124
  it. The architect reads your prose commits at its acceptance (*The architect's acceptance*,
118
- below), and that read is no new round. A round after a READY refusal is the one exception. Its
119
- approval needs the tester's results to be at the head, or at an ancestor with only paths
120
- under `.legion/` changed since. So there you fix no prose yourself, and you name each prose
121
- finding in a `REQUEST_CHANGES`.
125
+ below), and that read is no new round.
122
126
 
123
127
  A reviewer's phase ends with its completion, not with its review. Every round records a handoff
124
128
  and takes this order: read CI as above; write the handoff and record it with
@@ -126,13 +130,17 @@ and takes this order: read CI as above; write the handoff and record it with
126
130
  code is a `REQUEST_CHANGES` naming the check, never an approval. A request for changes does not
127
131
  wait, since it stands whatever CI says and the issue leaves reviewing with it. The approval waits
128
132
  on nothing either: it ends the round whatever CI says at the head it names, since the round reads
129
- no CI verdict, and a red the daemon reads later — at that head or any above it — is the code's red
130
- and resumes the implementer from wherever the issue is (reviewing, retro or merging) without the
131
- reviewer. A head your own push changed is the exception. The daemon marks it a planned red and
132
- sends nothing back for it, so wait for its checks yourself (*Fix a prose-only finding yourself*,
133
- above). The daemon moves the issue once both are in — the decision GitHub reports and your
134
- completion, in either order — so a review posted without a completion leaves the issue in
135
- reviewing until you finish.
133
+ no CI verdict, and a settlement the daemon reads later — at that head or any above it — moves the
134
+ issue nowhere. The daemon names each check GitHub reported, with the conclusion GitHub gave it,
135
+ in one message to the tree's architect, the worker of the issue's current phase and the
136
+ implementer, and judges none of them: a red is the implementer's to fix or re-run, the
137
+ architect's to decide on, and GitHub's to hold the merge for. So the reviewer's own read before
138
+ it approves is the only read that decides anything. A review that names an older head reviews
139
+ code the pull request no longer has. The daemon moves the issue once all three are in — the
140
+ decision GitHub reports, your completion, in either order, and GitHub's own answer that the
141
+ approved head is one the issue may advance on — so a review posted without a completion leaves
142
+ the issue in reviewing until you finish, and an approved head GitHub answers `blocked` for leaves
143
+ it there until that answer comes clean.
136
144
 
137
145
  ## The architect's acceptance
138
146
 
@@ -158,28 +166,22 @@ reviewing until you finish.
158
166
  a root's checks are proven at its own head, in its last round. No `after_merge` result is
159
167
  asked here: it is recorded after the close, where the project opens a check (*The production
160
168
  check after the close*, below).
161
- CI red at the head in `accepting` returns the issue to `implementing` as it does in review. A
162
- head the review App pushed is the exception: the daemon marks it a planned red and acts on it
163
- nowhere, and GitHub holds the merge under the base branch's own rules.
169
+ CI red at the head in `accepting` moves nothing, as it moves nothing anywhere: the daemon names
170
+ the checks GitHub reported and leaves the decision to the roles it told. Read the head's checks
171
+ on GitHub yourself before you accept, and send a red head back with `request_backward_move`.
164
172
 
165
173
  ## Retro
166
174
 
167
175
  - **Retro commits nothing.** It reads the evidence, writes what the work taught as a
168
176
  `dispatch comment` on the issue for the skill librarian, brings the PR body up to date and
169
- completes (`skill://legion-retro` gives the steps), so the approved head is the head READY
170
- names. Anything above the approved
171
- head voids the approval, except a change whose every path is under `.legion/` and a commit
172
- that changes only `docs/solutions/`, which READY still lets through: READY is refused
173
- `READY_UNREVIEWED_CHANGE`, naming the paths, and the merger tells the architect, who has it send
174
- the head back to review instead of completing, the move's reason naming the refusal's code and
175
- what it found. `READY_UNREVIEWED_CHANGE` has more causes than a path outside retro's own; every
176
- one of them sends the head back to review and none is an error to retry, and the complete list,
177
- with each remedy, is the merger's own role prompt part.
178
- A conflict merge pushed above the approved head with no review round after it
179
- brings the base's paths above that head, so READY refuses it the same way; one sent back through
180
- `implementing` by the conflict procedure gets its confirmation before READY runs. A READY
181
- refusal's return reaches the reviewer as a new round, never a fingerprint confirmation. Retro
182
- removes nothing.
177
+ completes (`skill://legion-retro` gives the steps), so the approved head is the head the merger
178
+ merges. Nothing in Legion compares that head with the one the approval named either: a
179
+ repository that wants a push made after the approval reviewed says so in its own rulesets (a
180
+ stale review dismissed, a review required again), and GitHub holds the merge to them. A
181
+ conflict merge pushed above the approved head still goes back to the reviewer for a
182
+ confirmation or a new round, as the fingerprint decides
183
+ (`skill://legion-worker/references/conflicts-and-rewrites.md`), because the branch's own
184
+ procedure says so and not because any Legion check refuses the head. Retro removes nothing.
183
185
  - **Retro brings the PR body's path-derived content up to date before it completes.** Whatever the
184
186
  repository's instructions derive from the pull request's changed paths (a checklist named for
185
187
  each class of path, read by a required check), retro recomputes for the whole diff at its head
@@ -189,97 +191,54 @@ reviewing until you finish.
189
191
 
190
192
  ## The merger
191
193
 
192
- - The merger resolves no review thread: the reviewer's approval already judged them, and READY
193
- requires no thread state beyond it. It quotes what sits above the approved head with
194
- `cd -- "$LEGION_WORKSPACE" && jj -R "$LEGION_WORKSPACE" git fetch && jj -R
195
- "$LEGION_WORKSPACE" diff --from <approved-sha> --to <tip-sha> --summary` in READY; the daemon,
196
- not the merger, holds those commits to retro's: READY reads GitHub's compare of the round's
197
- approved head with READY's head and refuses any other path (`READY_UNREVIEWED_CHANGE`), and a
198
- round with no recorded approval (`READY_NOT_APPROVED`).
199
- *The READY packet* is
200
- `READY #<n> at <current sha> (approved at <approved sha>) for <KEY> (<pr url>)`
201
- (the shape `packages/daemon/internal/prompts/roles/merger.md` defines), then the PR body's
202
- `Outcome:` line and its `Not proven / risk:` value — every bullet under that label joined with
203
- `; ` on the one READY line, or `none` — quoted from the `## For the reviewer` block at that same
204
- head (or one line saying the body carries no brief — the packet still goes out), then the
205
- `--summary` output and the PR body's gate facts. The READY packet names each `before_merge`
206
- check with its latest result and with whether a pass stands, as `dispatch results --issue
207
- <issue>` prints them; a check with no pass standing at the head is reported to the architect
208
- instead of completing.
209
- - READY is `handoff_complete` with `ready: true` and the packet as its `summary`; the merger runs
210
- no pre-flight of its own, and its completion reports the commit the workspace stands on. READY's
211
- checks run in the daemon, which reads the pull request's head on GitHub and refuses, before
212
- recording anything, on each ground the merger's role prompt names in its `Go daemon workflow`
213
- part, by its code and with its remedy. That part is the one complete list of READY's refusals. A
214
- refusal records nothing; the merger reports it to the architect unless it says to complete
215
- again, and never pushes a commit to make CI run. On success the daemon posts the packet as a
216
- `dispatch message` on the issue, publishes it to the project's merge queue role when one is set,
217
- and says on the issue when that role has no live holder; the answer's `note` says when READY was
218
- published on a pull request a person already merged, whose head can no longer change, or carries
219
- the by-hand note of a pull request a person merges.
220
- - **The daemon submits the merge the moment READY is accepted, unless the answer says a person
221
- merges it.** It queues a `ready_merge` outbox row for the head READY named, and the row, as the
222
- implement App, reads GitHub and then the record: while the issue still awaits that READY head, a
223
- base with a merge queue gets the pull request enqueued once GitHub reports it mergeable now
224
- (`CLEAN`, `UNSTABLE` or `HAS_HOOKS`); otherwise a pull request GitHub reports mergeable now is
225
- squash-merged, and one in a repository that allows auto-merge is armed. Every request carries
226
- READY's head as GitHub's expected head, so GitHub refuses it once the head has moved. On a
227
- merge-queue base the row never arms auto-merge: while a required check still runs, or anything
228
- else keeps GitHub from reporting the pull request mergeable, it waits, reading GitHub again on
229
- the outbox's backoff, and enters the queue once GitHub does. In a repository that allows neither a
230
- merge queue nor auto-merge, the row waits the same way until GitHub reports the pull request
231
- mergeable — a required check finishing, a required review a person gives — and then merges it. An
232
- arm or a queue entry is not the end: the row keeps reading GitHub until GitHub reports the pull
233
- request merged at READY's head. Once it has seen the arm or entry, it never submits that head
234
- again after someone else removes it: the merge queue taking the pull request out because the merge
235
- failed (GitHub's reason `failed_checks`, or an unexplained reason with a check that failed, timed
236
- out, failed to start, needed action or went stale on the commit the queue built for its
237
- `merge_group` CI) sends the issue back to `implementing`, the implementer's task naming each
238
- failing check and its run, as a red head does; any other removal (a person dequeues it,
239
- cancelling its runs, or turns auto-merge off, GitHub turns it off, the queue finds a conflict)
240
- ends the row and is told to the architect once
241
- (`merge-removed`). Two removals are submitted again: the implement App's own disarm sent before
242
- READY that GitHub applied late (auto-merge `manually_disabled`, or a `manual` dequeue, by that
243
- App), and auto-merge a close turned off, which the reopen at READY's head undid. GitHub's
244
- rules decide each answer: the daemon bypasses
245
- none, and a person may merge it first. A refusal a retry would meet again (squash merges disabled,
246
- a permission the App lacks) ends the row and is told to the architect once (`merge-refused`), with
247
- GitHub's message. While the record still awaits READY's head, GitHub showing the pull request
248
- closed or at another head is a webhook not yet applied, so the row waits for the two to agree.
249
- Only once GitHub's last change to the pull request is more than 10 minutes old, however long the
250
- row waited before, does the row end and tell the architect once (`merge-stalled`). A merge the
251
- daemon submitted that GitHub has not completed within an hour of READY's acceptance tells the
252
- issue's architect once (`merge-waiting`) and goes on waiting: nothing is withdrawn, the merge
253
- stands, the issue stays in `awaiting_merge`, and the architect reads the pull request for what
254
- GitHub waits on — a required check that never ran or failed, a review only a person can give, a
255
- queue that has not landed it — and asks a person for what no worker can do. A reopen at
256
- READY's head reuses the row, starts it over as though nothing had been armed, and takes it from a
257
- run that read the record before the reopen. Any other failure retries.
258
- No role runs `gh pr merge`. When the answer's `note` begins `MANUAL_MERGE_REQUIRED:` (the pull
259
- request touches a path the project's `merge.by_hand` names), READY stands but the daemon submits
260
- nothing: the merger tells the architect the note and the head, and a person merges under the
261
- repository's rules. While an earlier auto-merge disarm for that pull request remains unfinished,
262
- a by-hand READY refuses `READY_DISARM_PENDING`; retry it once the disarm finishes, so a stale
263
- ordinary arm cannot merge the person-only head. Ordinary READY does not wait for the disarm. The
264
- daemon tells that READY with the note at its head and the packet's `Merge:` line replaced, so the
265
- issue and the merge queue role are never asked to arm it. A READY the design gate refused is
266
- submitted by the daemon once every gated step of the root's design gate is open, when the
267
- approval that opens the last closed one moves the issue to `awaiting_merge`; the refusal named
268
- one step and the version to approve, and no second READY is asked for however many steps held
269
- it. A push that moves the head past a READY the gate holds voids it before then:
270
- the architect is told `READY_HEAD_MOVED` and has the merger build a new READY at the new head.
271
- The packet's second line records the step,
272
- `Merge: the daemon submits pull request #<n> at <head> once READY is accepted`.
273
- - **The daemon disarms a merge no READY covers.** Auto-merge stays enabled across pushes, and the
274
- expected head is checked only when it is enabled, so the daemon itself disables the pull
275
- request's auto-merge and takes it out of a merge queue, as the implement App, on any push or
276
- reopen but one landing on an awaiting READY's head, when READY is withdrawn (a push or reopen
277
- moved the head past it, its CI turned red, or it conflicts with its base, each of which sends the
278
- issue back to `implementing`), when a child is set back to `todo`, and when the issue leaves the
279
- workflow. A by-hand READY covers no arm, so whoever arms it is undone. A `ready_merge` row whose
280
- READY the record has left, or whose pull request the record holds closed, submits nothing; a pull
281
- request reopened at an awaiting READY's head gets that head's merge submitted again. No role runs
282
- a disarm.
194
+ - The merger resolves no review thread: the reviewer's approval already judged them, and the
195
+ merge requires no thread state beyond it. It writes no file, commits nothing and pushes
196
+ nothing.
197
+ - **The merge is the merger's own act, at the head it read.** It reads the pull request
198
+ (`gh pr view <n> --json number,title,url,state,baseRefName,headRefOid,mergeStateStatus`), and
199
+ every step below names that `headRefOid`:
200
+ - *The message, before the merge.* GitHub's default squash message,
201
+ `squash_merge_commit_message` of `COMMIT_MESSAGES`, joins every commit message of the pull
202
+ request, which puts the tree's `Dispatch:` keys and its `Omp-Session:` trailers on the
203
+ default branch. So the merger writes the message itself,
204
+ `--subject '<pull request title> (#<n>)' --body ''`, on every merge, whatever the repository's
205
+ setting says. It reads that setting first all the same
206
+ (`gh api "repos/<o>/<r>" --jq '[.squash_merge_commit_title, .squash_merge_commit_message] | @tsv'`),
207
+ because the merge-queue path below can pass no message.
208
+ - *The merge.*
209
+ `gh pr merge <n> --squash --match-head-commit <head> --subject '<pull request title> (#<n>)' --body ''`,
210
+ as the implement App, so
211
+ GitHub refuses the merge once the head has moved under it: merging at a named head is how bors
212
+ and Prow's Tide merge only what they tested. On a base with a merge queue — a `merge_queue`
213
+ rule among the base branch's rules — it enqueues the pull request instead, with GraphQL
214
+ `enqueuePullRequest` and the same head as `expectedHeadOid`, because `gh pr merge` on such a
215
+ base turns auto-merge on while a required check is pending, which arms the pull request rather
216
+ than queueing it. `enqueuePullRequest` takes no message, so where that base's
217
+ `squash_merge_commit_message` reads `COMMIT_MESSAGES` the queue would commit the branch's
218
+ messages and nothing the merger passes can stop it: it enqueues nothing, completes nothing,
219
+ and tells the architect, naming the setting and that only a person can change it to `PR_BODY`
220
+ or `BLANK`. It never turns auto-merge on; the daemon submits no merge and changes no
221
+ merge setting of any pull request.
222
+ - *The watch.* On a merge-queue base it reads the pull request until GitHub merges it or takes
223
+ it out of the queue, and acts on a removal: a head the queue took out over its own
224
+ `merge_group` checks is work to fix, so the issue goes back; a person's dequeue is that
225
+ person's decision, reported to the architect. A removal is never a merge.
226
+ - *A failed merge is the merger's decision.* Wait for what GitHub waits for (a required check
227
+ still running, a required review only a person can give) and merge again; merge again at the
228
+ head it re-reads when a push moved it, or when GitHub refused while it was still computing
229
+ mergeability; send the issue back with `request_backward_move` when the head itself must
230
+ change (a conflict with the base, a check that failed); or tell the architect what no
231
+ worker can do — a repository setting or an App permission only a person can change — with
232
+ GitHub's own answer quoted. The repository's required reviews and checks decide what may
233
+ merge: Legion bypasses none, and a review only a person can give is waited for.
234
+ - *The completion* is `handoff_complete` with the ordinary two-sentence `summary`, which names the
235
+ pull request, the head merged and the merge commit. It records the merger's phase row and moves
236
+ nothing: no Dispatch message, no publish, no phase. What moves the issue is the daemon's own
237
+ reading of the merged pull request, which writes `done` — before the completion or after it,
238
+ whichever comes second. The daemon refuses that completion only as it refuses any phase
239
+ worker's: `HANDOFF_NOT_CURRENT_PHASE` (the issue left `merging`), `HANDOFF_STALE_GENERATION`,
240
+ `HANDOFF_NO_RUN`, `HANDOFF_ALREADY_RECORDED` and `TREE_LINGERING`. It reads neither the head,
241
+ nor its checks, nor the approval: every one of those reads is the merger's own, above.
283
242
 
284
243
  ## The production check after the close
285
244
 
@@ -287,16 +246,16 @@ reviewing until you finish.
287
246
  after the close.** `projects.<KEY>.production_check` in the project's `legion.yaml` takes `off`
288
247
  or `tester`, and a project that names no key gets `tester`, so by default the tester works the
289
248
  check; the loader refuses every other value, naming the key and the value it read. Where the
290
- setting names the tester, the merge makes the daemon write `done` and hand the check task to
291
- the tester's live session. Where it is `off` nothing is opened at all — no record, no
249
+ setting names the tester, the daemon reads that merge, writes `done` and hands the check task
250
+ to the tester's live session. Where it is `off` nothing is opened at all — no record, no
292
251
  bound and no look — and the merged close is like any other done: every claim of the issue is
293
252
  retired and its pod released with the disk it ran on. A merged root still lingers its tree with
294
253
  every claim suspended, as before. On a root whose tree still runs, the merge is recorded and
295
- the root waits in `awaiting_merge` until the last other issue of its tree is done or parked,
296
- the check opening with that close. Its first line, which tells it from a phase task in a
297
- resumed session, is `Production check of <KEY>: <title>.`, naming the repository, the pull
298
- request, the merge commit, the look's number, its wake (`the merge`, for the first) and whether
299
- it is the last.
254
+ the root stays in `merging` on its merged pull request until the last other issue of its tree
255
+ is done or parked, the check opening with that close. Its first line, which tells it from a
256
+ phase task in a resumed session, is `Production check of <KEY>: <title>.`, naming the
257
+ repository, the pull request, the merge commit, the look's number, its wake (`the merge`, for
258
+ the first) and whether it is the last.
300
259
  - **The check's record holds the role that works it, written when the check opened.** Changing the
301
260
  setting moves no check already open: a check keeps the role it opened with, and a check open
302
261
  before this release carries the implementer. Only that role may report on it, so a report from
@@ -19,7 +19,7 @@ later phase keeps it current rather than replacing it:
19
19
  **Look at first:** <one to three `path:line` places where a wrong decision would hurt> (the reviewer writes this line)
20
20
  **Proven by:** <the surface and the run of the check the change turns on, one line>
21
21
  **Not proven / risk:**
22
- - <one line per claim recorded as unproven before READY>, or the single word `none` (the reviewer writes this line; `none` is invalid while such a claim stands)
22
+ - <one line per claim recorded as unproven before the merge>, or the single word `none` (the reviewer writes this line; `none` is invalid while such a claim stands)
23
23
  **Size:** <files changed, +added/−removed>
24
24
 
25
25
  ## Verification
@@ -51,15 +51,17 @@ then pushes and completes. It never waits for, watches or polls the pull request
51
51
  (the step's spaced reads of the pull request's head after a push are the one sleep this rule
52
52
  allows, and they read no check; `skill://legion-worker`, *Every role pushes its own commits*,
53
53
  gives them).
54
- Under the Go daemon a check or workflow the base branch requires that settles red on the head,
55
- before the completion or after it, sends the work back to `implementing` with the failing checks
56
- named, however many reds came before it.
57
- The one CI result an implementer waits for is a re-run: when its task names a red that
58
- failed on its own in a `pull_request` run, it re-runs the failed jobs once (`gh run rerun <run-id> --failed`) and completes once
59
- the re-run settles green, woken by the pull request's checks event (`skill://envoy`, *Wait for
60
- CI or a merge*: subscribe, then end the turn), never by a sleep loop.
61
- A merge-group run is never re-run: the implementer finishes its round instead, and the pull request is tested again when it is queued again.
62
- A completion while that red still stands is sent back, at once for a required check and at the daemon's next read of the runs (within two minutes) for a required workflow.
54
+ Under the Go daemon a check that settles red on the head moves the issue nowhere: the daemon names
55
+ every check GitHub reported, with the conclusion GitHub gave it, in one message to the tree's
56
+ architect, the worker of the issue's current phase and the implementer, and judges none of them.
57
+ That message is the implementer's to act on while it still works the issue: a red that failed on
58
+ its own is re-run once (`gh run rerun <run-id> --failed`), woken by the pull request's checks
59
+ event (`skill://envoy`, *Wait for CI or a merge*: subscribe, then end the turn) and never by a
60
+ sleep loop; a red at the code is fixed, which the reviewer asks for anyway, since it reads the
61
+ head's checks on GitHub before it approves; and a red only GitHub can settle is GitHub's, which
62
+ holds the merge for it under the base branch's own rules.
63
+ A merge-group run is never re-run: the implementer finishes its round instead, and the pull request
64
+ is tested again when it is queued again.
63
65
 
64
66
  A pull-request body edit re-runs a check that judges the body at once, on the head as it is. While
65
67
  the pull request conflicts with its base (GitHub shows it `CONFLICTING`), no workflow triggered
@@ -77,11 +79,10 @@ push; `Outcome` is a sentence a user of the repository would recognise, never "f
77
79
  name, and `Why` ends with the Dispatch key, never a URL. The reviewer writes `Look at first` and
78
80
  `Not proven / risk` at each round, into the live body (`gh api
79
81
  repos/{owner}/{repo}/pulls/{number} --jq .body`, edit, then `--method PATCH ... -F body=@body.md`);
80
- `Not proven / risk` copies every claim recorded as unproven before READY — the tester's
82
+ `Not proven / risk` copies every claim recorded as unproven before the merge — the tester's
81
83
  `failures`, the reviewer's own review, any proof-check comment already on the pull request —
82
- word for word, and `none` is a finding while one stands. The merger quotes `Outcome` and
83
- `Not proven / risk` from the body at the head its READY packet names
84
- (*The READY packet* in `skill://legion-worker/references/merge-gate.md`); a stale `Outcome` that no
84
+ word for word, and `none` is a finding while one stands. The merger reads `Outcome` and
85
+ `Not proven / risk` from the body at the head it merges, and a stale `Outcome` that no
85
86
  longer describes the diff is a finding against the implementer, not a line the merger rewrites.
86
87
 
87
88
  ## What a result is
@@ -70,8 +70,8 @@ opened that is none of Legion's role Apps, with one reply in your own words. A b
70
70
  cannot accept becomes your own: say what stands and request changes. Approve once each of those
71
71
  threads carries your answer and no finding stands, read in `gh api graphql` — quote those answers
72
72
  in the approval. Your approval never waits on a resolution: resolution is the pull request author's
73
- App's. A review bot that is red while a thread it opened still stands is CI like any other, and
74
- you re-run nothing: when the base branch requires its check, that red sends the work back to the
75
- implementer, who answers or fixes each of the bot's threads, resolves them with its own `gh` (the
73
+ you re-run nothing: that red moves the issue nowhere, but the base branch holds the merge for a
74
+ check it requires, so the
75
+ implementer answers or fixes each of the bot's threads, resolves them with its own `gh` (the
76
76
  ones you named to it, above, and its own), and pushes, and the bot runs again on that push. The
77
- merger resolves nothing: READY requires no thread state beyond what your approval already judged.
77
+ merger resolves nothing: the merge requires no thread state beyond what your approval already judged.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sjawhar/claude-envoy",
3
- "version": "2.6.0",
3
+ "version": "2.7.0",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Claude Code plugin for Legion's Envoy bus",
6
6
  "type": "module",
@@ -19,7 +19,7 @@
19
19
  "AGENTS.md"
20
20
  ],
21
21
  "legion": {
22
- "daemonApiVersion": 85
22
+ "daemonApiVersion": 86
23
23
  },
24
24
  "repository": {
25
25
  "type": "git",
@@ -41,6 +41,15 @@ import { configuredValue } from "./claude-session"
41
41
  * appended to that turn as its next step (`deliver`/`step` in
42
42
  * `packages/daemon/internal/claudebridge/bridge.go`), which would destroy the turn boundary the
43
43
  * whole split exists for.
44
+ *
45
+ * A turn Claude Code ended on an API error fires `StopFailure` rather than `Stop`, and that is
46
+ * the provider refusing the turn: it earns no continuation, since the host would turn one into
47
+ * another turn at once and the provider would refuse that one the same way. It does arm one
48
+ * timer, because the task that refused turn carried ended with it and nothing else would wake
49
+ * this worker, so a single transient refusal would otherwise leave the issue idle. What stops
50
+ * the reminding for good is the runner's record check, which drops every reminder once the
51
+ * daemon has failed this role's claim — the refused turns themselves are counted by the bridge,
52
+ * which reports each turn's outcome to the daemon (INFRA-714).
44
53
  */
45
54
 
46
55
  /** The tool's name: Claude Code shows it as `mcp__legion__legion_phase_hook`, and a hook entry
@@ -516,7 +525,9 @@ export function createPhaseHookEndpoint(deps: PhaseHookDeps): PhaseHookEndpoint
516
525
  stopHookActive: event.stopHookActive ?? "",
517
526
  backgroundWork,
518
527
  })
519
- const reminded = await reminder.settle(event.lastAssistantMessage ?? "", {
528
+ const reminded = await reminder.settle({
529
+ kind: "settle",
530
+ lastAssistantText: event.lastAssistantMessage ?? "",
520
531
  backgroundWork,
521
532
  })
522
533
  // After the settle, so the report carries the wake that settle armed. The daemon
@@ -526,13 +537,17 @@ export function createPhaseHookEndpoint(deps: PhaseHookDeps): PhaseHookEndpoint
526
537
  return reminded === undefined ? {} : { decision: "block", reason: reminded }
527
538
  }
528
539
  case "StopFailure": {
529
- // The turn ended on an API error. Claude Code ignores whatever this hook returns, so
530
- // this event cannot carry a continuation: the machine is told so and arms the reminder
531
- // its settle earned itself, under every guard an armed reminder has. This is the one
532
- // event of the five the pod measurements did not cover; it records only, so a
533
- // `StopFailure` that never fires costs the reminder after an API-error turn and nothing
534
- // else.
535
- await reminder.settle(event.lastAssistantMessage ?? "", { canContinue: false })
540
+ // Claude Code runs this instead of `Stop` when the turn ended on an API error, and
541
+ // `${last_assistant_message}` is then the error text itself rather than anything the
542
+ // worker said ("Hooks reference", code.claude.com/docs/en/hooks). So this is the
543
+ // provider refusing the turn, and the machine takes it as one: it earns no
544
+ // continuation, because the next turn would be refused the same way, and one timer,
545
+ // because nothing else would wake this worker once the task that turn carried ended
546
+ // with it. What ends a session the provider keeps refusing is the daemon failing its
547
+ // claim on the outcomes the bridge reports, which the timer's own record check reads.
548
+ // Claude Code ignores whatever this hook returns, which costs nothing now that there
549
+ // is nothing to return.
550
+ await reminder.settle({ kind: "refused", message: event.lastAssistantMessage ?? "" })
536
551
  return {}
537
552
  }
538
553
  case "PostToolUse":
@@ -550,9 +565,8 @@ export function createPhaseHookEndpoint(deps: PhaseHookDeps): PhaseHookEndpoint
550
565
  // Claude Code's stdin from the bridge and never this process, so what a turn means is
551
566
  // read from the prompt itself. The turn is declared first, which makes every armed
552
567
  // timer stale, and the pending one is dropped outright: the runner's generation guard
553
- // answers the same for the timers it armed, and the one this endpoint arms itself (the
554
- // `StopFailure` reminder) obeys the same rule that way rather than through a second
555
- // guard of its own.
568
+ // answers the same for the timers it armed, and dropping the one timer this server
569
+ // holds is the plainest way to say the same thing.
556
570
  reminder.turnStarted()
557
571
  dropTimer()
558
572
  const prompt = event.prompt ?? ""