@sjawhar/claude-envoy 4.10.0 → 4.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/.omp-plugin/plugin.json +1 -1
  3. package/AGENTS.md +43 -497
  4. package/dist/codex-hook.js +9 -3
  5. package/dist/dispatch.js +9 -3
  6. package/dist/envoy-channel.js +10 -4
  7. package/dist/session-hook.js +9 -3
  8. package/legion/skills/legion-architect/SKILL.md +88 -66
  9. package/legion/skills/legion-architect/references/acceptance.md +89 -258
  10. package/legion/skills/legion-architect/references/decomposition.md +94 -213
  11. package/legion/skills/legion-architect/references/design-gate.md +88 -353
  12. package/legion/skills/legion-architect/references/wake-routing.md +51 -43
  13. package/legion/skills/legion-controller/SKILL.md +50 -181
  14. package/legion/skills/legion-controller/references/admission.md +25 -54
  15. package/legion/skills/legion-controller/references/backlog-stewardship.md +23 -119
  16. package/legion/skills/legion-controller/references/consolidation.md +9 -93
  17. package/legion/skills/legion-controller/references/daily-report.md +21 -99
  18. package/legion/skills/legion-controller/references/escalation.md +16 -118
  19. package/legion/skills/legion-controller/references/finding-asks.md +31 -162
  20. package/legion/skills/legion-controller/references/park-asks.md +33 -0
  21. package/legion/skills/legion-controller/references/parked-decisions.md +20 -264
  22. package/legion/skills/legion-controller/references/session.md +26 -84
  23. package/legion/skills/legion-controller/references/slack-mentions.md +18 -134
  24. package/legion/skills/legion-controller/references/triage.md +18 -89
  25. package/legion/skills/legion-controller/references/wakes.md +22 -549
  26. package/legion/skills/legion-controller/references/weekly-audit.md +9 -90
  27. package/legion/skills/legion-oracle/SKILL.md +19 -28
  28. package/legion/skills/legion-retro/SKILL.md +54 -93
  29. package/legion/skills/legion-retro/references/learnings.md +21 -33
  30. package/legion/skills/legion-retro/references/pr-body-content.md +21 -37
  31. package/legion/skills/legion-worker/SKILL.md +50 -64
  32. package/legion/skills/legion-worker/references/ci-checks.md +16 -84
  33. package/legion/skills/legion-worker/references/conflicts-and-rewrites.md +34 -93
  34. package/legion/skills/legion-worker/references/default-branch-check.md +22 -60
  35. package/legion/skills/legion-worker/references/findings.md +25 -180
  36. package/legion/skills/legion-worker/references/foreign-path.md +14 -22
  37. package/legion/skills/legion-worker/references/gvisor.md +20 -0
  38. package/legion/skills/legion-worker/references/merge-gate.md +43 -419
  39. package/legion/skills/legion-worker/references/plan-tests.md +8 -28
  40. package/legion/skills/legion-worker/references/pr-body.md +19 -218
  41. package/legion/skills/legion-worker/references/review-threads.md +16 -70
  42. package/legion/skills/legion-worker/references/tools.md +31 -578
  43. package/legion/skills/legion-worker/references/withheld-capability.md +12 -163
  44. package/legion/skills/simplify-settled-diff/SKILL.md +23 -41
  45. package/legion/skills/simplify-settled-diff/references/personas/code-quality-reviewer.md +14 -14
  46. package/legion/skills/simplify-settled-diff/references/personas/code-reuse-reviewer.md +4 -4
  47. package/legion/skills/simplify-settled-diff/references/personas/efficiency-reviewer.md +8 -8
  48. package/package.json +1 -1
  49. package/skills/agent-secrets/SKILL.md +46 -312
  50. package/skills/agent-secrets/references/store-a-secret.md +9 -0
  51. package/skills/approval-review/SKILL.md +20 -76
  52. package/skills/asd-ste100/SKILL.md +43 -85
  53. package/skills/asd-ste100/examples/before-after.md +18 -53
  54. package/skills/dispatch/SKILL.md +1 -1
  55. package/skills/dispatch-writing-specs/SKILL.md +1 -1
  56. package/skills/envoy/SKILL.md +56 -126
  57. package/skills/envoy/references/check-settlement.md +26 -43
  58. package/skills/envoy/references/deliveries.md +26 -144
  59. package/skills/envoy/references/legion.md +12 -45
  60. package/skills/envoy/references/roles.md +11 -9
  61. package/skills/envoy/references/sources.md +13 -25
  62. package/skills/outside-message/SKILL.md +24 -81
  63. package/skills/plain-words/SKILL.md +24 -55
  64. package/skills/thermonuclear-code-quality/SKILL.md +16 -26
  65. package/skills/thermonuclear-deep-review/SKILL.md +22 -31
  66. package/legion/skills/legion-worker/references/cleanup-deletion.md +0 -22
  67. package/legion/skills/legion-worker/references/systematic-rename.md +0 -19
  68. package/skills/asd-ste100/references/writing-rules.md +0 -59
  69. package/skills/plain-words/references/mechanics.md +0 -49
@@ -1,13 +1,10 @@
1
1
  # PR body, recorded results, and the simplify pass
2
2
 
3
- Part of `skill://legion-worker`. Read it before you write or edit any line of the pull request
4
- body, record a result against one of the issue's checks, read another phase's results, or run the
5
- simplify pass. Every path it cites is in cybermonklabs/legion.
3
+ Read it before you edit the pull request body, record or read a check's result, or run the simplify pass.
6
4
 
7
5
  ## The pull request body template
8
6
 
9
- The implementer writes the PR body from this template from the moment the PR opens, and every
10
- later phase keeps it current rather than replacing it:
7
+ The implementer writes the body from this template when the pull request opens; later phases keep it current. Edit the live body: read it (`gh api repos/{owner}/{repo}/pulls/{number} --jq .body`), change your lines, write it back (`--method PATCH ... -F body=@body.md`).
11
8
 
12
9
  ```
13
10
  ## For the reviewer
@@ -46,229 +43,33 @@ order. Each is the line `dispatch result` printed when the result was recorded,
46
43
  **Chain:** stacked on <base bookmark> frozen at <sha> / not stacked.
47
44
  ```
48
45
 
49
- ## Never waiting on CI
50
-
51
- Before the push and the hand-off, the implementer runs the repository's fast local checks for the
52
- paths it changed: the tests it added or changed, by name, and the build or vet of the packages it
53
- touched. It runs no whole test suite: CI runs the suites when it pushes, and a red job comes back
54
- to it (below). Then it pushes and completes. It never waits for, watches or polls the pull request's remote CI
55
- (`gh run watch`, `gh pr checks --watch`, `sleep` around `gh run view`) and never sleeps in a loop
56
- (the step's spaced reads of the pull request's head after a push are the one sleep this rule
57
- allows, and they read no check; `skill://legion-worker`, *Every role pushes its own commits*,
58
- gives them).
59
- Under the Go daemon a check that settles red on the head moves the issue nowhere: the daemon names
60
- every check GitHub reported, with the conclusion GitHub gave it, in one message to the architect
61
- that owns the issue, the worker of the issue's current phase and the implementer, and judges none
62
- of them.
63
- That message is the implementer's to act on while it still works the issue: a red that failed on
64
- its own is re-run once (`gh run rerun <run-id> --failed`), woken by the pull request's checks
65
- event (`skill://envoy`, *Wait for CI or a merge*: subscribe, then end the turn) and never by a
66
- sleep loop; a red at the code is fixed, which the reviewer asks for anyway, since it reads the
67
- head's checks on GitHub before it approves; and a red only GitHub can settle is GitHub's, which
68
- holds the merge for it under the base branch's own rules.
69
- A merge-group run is never re-run: the implementer finishes its round instead, and the pull request
70
- is tested again when it is queued again.
71
-
72
- A pull-request body edit re-runs a check that judges the body at once, on the head as it is. While
73
- the pull request conflicts with its base (GitHub shows it `CONFLICTING`), no workflow triggered
74
- `on: pull_request` runs for any of its activity types, so a body edit re-judges nothing there; a
75
- push cures it only once the pull request is mergeable, so the implementer forward-merges a
76
- conflicting one first (*Reintegrating the base* in
77
- `skill://legion-worker/references/conflicts-and-rewrites.md`). So when a required check has not
78
- appeared at the head, read `gh pr view <n> --json mergeStateStatus` first. `DIRTY` means the head
79
- conflicts with its base: GitHub builds no merge ref for it and creates no `pull_request` run, and
80
- the cure is that forward merge. Other runs can be green beside the missing one, because a
81
- `pull_request_target` run is built from the base and needs no merge ref, so its pass says nothing
82
- about whether the head merges.
46
+ GitHub refuses a body over 65,536 characters: past about 48,000, link evidence rather than inline it.
83
47
 
84
48
  ## The brief for the human
85
49
 
86
- `## For the reviewer` is written for the person who merges; `## Verification` below it stays the
87
- ledger the reviewer and merger check against GitHub. The implementer writes `Outcome`, `Why`,
88
- `Change`, `Proven by`, and `Size` when the pull request opens, and keeps them true after every
89
- push; `Outcome` is a sentence a user of the repository would recognise, never "fix bug" or a file
90
- name, and `Why` ends with the Dispatch key, never a URL. The reviewer writes `Look at first` and
91
- `Not proven / risk` at each round, into the live body (`gh api
92
- repos/{owner}/{repo}/pulls/{number} --jq .body`, edit, then `--method PATCH ... -F body=@body.md`);
93
- `Not proven / risk` copies every claim recorded as unproven before the merge — the tester's
94
- `failures`, the reviewer's own review, any proof-check comment already on the pull request —
95
- word for word, and `none` is a finding while one stands. The merger reads `Outcome` and
96
- `Not proven / risk` from the body at the head it merges, and a stale `Outcome` that no
97
- longer describes the diff is a finding against the implementer, not a line the merger rewrites.
50
+ The implementer keeps `Outcome`, `Why`, `Change`, `Proven by` and `Size` true after every push. At each round the reviewer writes `Look at first`, and `Not proven / risk`, copying word for word every claim recorded as unproven (the tester's `failures`, its own review, a proof-check comment). A requirement there is unmet, unless only the deploy can show it and the plan names its observation. A stale `Outcome` is a finding against the implementer; the merger rewrites nothing.
98
51
 
99
52
  ## What a result is
100
53
 
101
- **A check** is a `check` block of the issue's Verification document (`verification.md`). It names
102
- the requirements it serves, where a person reaches the change (`surface`: `browser`, `cli` or
103
- `api`), what to `run`, `when` it runs (`before_merge`, `after_merge` or `default_branch`) and its
104
- `negative_control`. A check with `ci_check` names the CI check run that proves it in place of a
105
- `run` (`skill://legion-worker/references/ci-checks.md`). The architect writes the checks with the
106
- spec; nothing else decides what must be proved.
107
-
108
- **A result** is one run of one check, recorded with
109
- `dispatch result --issue <issue> --check <block id> --role <your role> --verdict pass --commit <sha>`,
110
- with `--surface`, `--run`, `--observed` and `--negative-control` as the check asks for them. Each
111
- of these flags takes text and refuses a bare `-`. Text from a file or from stdin goes in
112
- `--run-file`, `--observed-file` or `--negative-control-file`. Only one of them per call may read
113
- stdin (`-`). The command prints the pull request body's line for it, and that line goes into the
114
- body unchanged.
115
- The surface is **production-like** — the repository's real-process test harness and fixtures, a
116
- sandbox repository, a real browser, a development stack, staging, or a local stack with real migrations,
117
- one that has the resource the change touches — and `--run` or `--observed` carries a **link** to
118
- that run, screenshot or e2e; human review does not replace user-facing verification, and a green
119
- unit suite is not it. A unit or integration test is a regression lock, never a check's result,
120
- except as the CI job that a check's `ci_check` names.
121
- The agent that develops the change records its results this way before the merge, and whatever
122
- blocks a check is fixed, not skipped (*When no surface reaches the changed path*, below).
123
-
124
- **Record a result after the commit is pushed.** Dispatch asks GitHub whether the repository of
125
- the check's issue holds the commit, and refuses a result at one it does not hold with `400
126
- RESULT_COMMIT_UNKNOWN`, naming the commit and the repository; a commit that is still only local
127
- is such a commit. Where Dispatch cannot read the repository at all it stores the result as
128
- before, and says so when the results are read.
54
+ - **A check** is a `check` block of the issue's Verification document: what it `serves`, its `surface` (`browser`, `cli` or `api`), its `run`, its `when` (`before_merge`, `after_merge` or `default_branch`) and its `negative_control`. The architect writes the checks; one carrying `ci_check` is CI's (`skill://legion-worker/references/ci-checks.md`).
55
+ - **A result** is one run of one check: `dispatch result --issue <issue> --check <block id> --role <your role> --verdict pass --commit <sha>`, with `--surface`, `--run`, `--observed` and `--negative-control`. These refuse a bare `-`: use `--run-file` and its kin, one reading stdin per call. Put the printed line into the body unchanged.
56
+ - The surface is production-like (the real-process harness, a sandbox repository, a real browser, a development stack, staging) and has the resource the change touches; `--run` or `--observed` links to the run. A unit or integration test is a regression lock, never a result, except as the job a `ci_check` names.
57
+ - Record a result only after its commit is pushed (`400 RESULT_COMMIT_UNKNOWN`).
58
+ - **A check that cannot fail is not a result.** The negative control shows it failing on a deliberately wrong input. A documented procedure counts only when it ran: reading it is not a run.
59
+ - A `before_merge` result stands while its commit is the head of an open pull request Dispatch attributes to the check's issue (`packages/envoy/internal/dispatch/delivery/attribution.go`), or the final head of a merged one, and while no part of the check's block has changed. So after a push, record each check with no `ci_check` again.
129
60
 
130
- **A check that cannot fail is not a result.** Before a check counts as evidence, show it
131
- failing: the negative control is that demonstration, run on the same command with a deliberately
132
- wrong input or call. A check whose pass survives empty output, a missing file or the wrong head
133
- proves nothing about the change. A documented procedure counts only when it ran: reading it, or
134
- reading the document that describes it, is not a run, and a procedure no surface available to
135
- you can run is reported under *When no surface reaches the changed path* below, never passed.
136
-
137
- **A result proves the head it was recorded at.** A `before_merge` result proves its commit while
138
- that commit is still the head of an open pull request of the check's issue, or the final head of
139
- a merged one, and while the check's words have not changed since; an `after_merge` result proves
140
- a commit the branch its own issue's pull request merged into carries, or the repository's default
141
- branch does — that default branch alone where Dispatch knows of no merge of that issue — and a
142
- `default_branch` result only a commit the repository's default branch carries.
143
- A push moves the head, with no Dispatch write of anyone's, so each check with no `ci_check` is
144
- recorded again at the new head. `dispatch results --issue <issue>` prints each check with the
145
- results recorded against it and the commit each one was recorded at;
146
- `dispatch read --issue <issue>` names each requirement of the spec no check serves.
147
- Where a result's commit stands is read, not stored. A `before_merge` result is compared only with
148
- the heads of the pull requests attributed to the check's issue, with no fallback to the default
149
- branch. Dispatch attributes a pull request to the first issue its five ranked sources name in the
150
- pull request's repository (`packages/envoy/internal/dispatch/delivery/attribution.go`): the issue
151
- whose external link is the pull request, the issue linked to a GitHub issue its body cites, a key
152
- in its head branch, a key in its title or body, and a key in its commit messages. So a result reads
153
- as at another commit (`older` in a client before pi-envoy 17.1.0) when its commit is an earlier
154
- head, when no attributed head is its commit, as when the pull request is attributed to another
155
- issue, or when any field of the check changed after it was recorded.
156
-
157
- **An issue is proved by its own checks.** Approval is gated by the `before_merge` checks of its
158
- own Verification document, read at its own head, so a result a child recorded proves nothing for
159
- a root — it was recorded at the child's head — and a child never records the result that proves
160
- a root's check. A child carrying part of a root's requirement proves it with a check on its own
161
- Verification document whose `serves` names that requirement. A root's own checks are proven at
162
- its own head, or, for an `after_merge` check, on the branch the root's pull request merged into
163
- or on the repository's default branch, in its last round.
61
+ ## The rules every phase's evidence follows
164
62
 
165
- **An issue with no `before_merge` check is a named gap.** One with no Verification document, or
166
- with none holding a `before_merge` check, has no evidence of its own. The tester names the gap
167
- in its handoff and the reviewer in its review, and neither sends the issue back for it; both
168
- tell the architect, who writes the checks, and the architect's acceptance comment names the gap
169
- and decides there, the only gate on such an issue.
63
+ - The tester tries to break the changed surface (wrong and boundary inputs, the second and the concurrent run, the party it must refuse) and writes the red test for a way no test would catch. Lint, types and the unit and integration suites are CI's: read them on GitHub at the head, rerun no lane as evidence, and wait for none.
64
+ - After a forward merge, the tester reruns each check the merge can reach (`skill://legion-worker/references/conflicts-and-rewrites.md`) and records each other check with no `ci_check` at the new head unrun, its `--observed` naming the earlier pass and why the merge misses it. A class search that finds an instance, or a parent's last round, takes a full test round.
65
+ - The implementer runs `skill://simplify-settled-diff` once per pull request, in its first implementing round, after its own results and before it completes, whatever the diff touches, a docs-only diff included. Applied: rerun the fast local checks and the issue's checks the simplify diff touches, and record them at the applied head. A defect the pass reports is fixed outside the pass and the results recorded again, never dropped as out of scope; the `Thermo` line names the count and the fixing commit.
66
+ - The reviewer's pair runs at the head each round reviews, over the diff that round reads, when that diff touches runtime code; the `Thermo` line records the range it read, and earlier rounds' pair halves stay beside it.
170
67
 
171
- ## The rules every phase's evidence follows
68
+ ## Never waiting on CI
172
69
 
173
- - **The implementer records a result for every `before_merge` check before its phase completes,
174
- and writes the `Checks` lines when the pull request opens.** A check carrying `ci_check` is
175
- CI's: the implementer records nothing for it and copies its `Pull request line` from
176
- `dispatch results` (`skill://legion-worker/references/ci-checks.md`).
177
- A check with no surface yet is the report of *When no surface reaches the changed path* below,
178
- never a check left unrecorded. The results are on the Dispatch issue, the lines in the
179
- PR body, because the reviewer and the merger verify facts on GitHub and never from a handoff.
180
- The `implement` handoff carries none: Dispatch holds them, and the tester reads them with
181
- `dispatch results`.
182
- What a handoff does carry is `head`, the 40-character lower-case commit its work was done
183
- against, which the completion sends to the daemon.
184
- - **The tester judges the implementer's results and records its own.** It runs and records no
185
- check with `ci_check`, whose result `dispatch results` derives from that CI job's run, conclusion
186
- and `completed_at` at the head, and it runs no check whose `run` is a whole test suite in the pod:
187
- that check's words are wrong, and the architect rewrites it with `ci_check`. A derived fail, or a run that
188
- concluded `skipped`, `neutral` or `cancelled`, is a test failure. A run still going, or GitHub
189
- unread, goes in `implementerProof.how` and fails no round. A name no run answers once the head's
190
- checks have settled goes to the architect as a finding. It re-runs the
191
- implementer's command or drives the same surface independently, and records the verdict in
192
- its `test` handoff as `implementerProof` (`{verdict, how}`). The tester runs the
193
- application, not CI again, and by hand it drives only the changed behaviour on the real surface,
194
- the negative controls, and named test files that no CI lane selects. Try to break the changed surface — wrong and boundary inputs, the
195
- second and the concurrent run, the party it must refuse — judge whether the implementer's tests
196
- would catch the ways it breaks, writing the red test for one that none would, and
197
- read CI on GitHub at the head you are judging for everything static: lint, types and the unit
198
- and integration suites are CI's, read there and recorded for no later step, except a `ci_check` job, and no CI lane is
199
- rerun as evidence. A lane GitHub shows `queued` or `in progress` is read as such: the tester
200
- never waits for it, since a required red that settles sends the work back from `testing` and
201
- the reviewer reads the head's checks before it approves.
202
- A `before_merge` check the implementer left with no pass standing at the head is a test failure, not a gap
203
- for the tester to fill: record it in `failures` (each `{check, evidence}`, `check` the block id)
204
- with `implementerProof.verdict: "rejected"`, complete the phase with
205
- `verdict: "fail"`, and the daemon returns the issue to the implementer — the agent that developed the change owns
206
- proving it (a rejected verdict, or `failed > 0`, always comes with the failure recorded in
207
- `failures`). A check whose `run` is a whole test suite is the exception: its words are wrong, so
208
- while the architect rewrites it, it fails no round, and the tester names it in
209
- `implementerProof.how` and sends it to the architect. Otherwise record your own result for each
210
- `before_merge` check before you complete,
211
- and put each printed line in the body. A code path whose first execution is after merge — a
212
- deploy workflow's inline step, a post-merge helper, a production-only resource — is a check
213
- marked `after_merge`, recorded after the merge on a look of the production check by the role
214
- the project's `production_check` names — the tester, unless the setting is `off`, where the
215
- close opens no check and nothing records it — unless the implementer can execute it against a
216
- development stack before then; if no surface can reach it, the
217
- tester names that missing surface as the blocker instead of passing the phase. Environment or
218
- secret-scrub evidence (e.g. "`LEGION_*`/`DISPATCH_*`/`ENVOY_*` unset") is recorded once, in
219
- its `test` handoff, and only when a check calls for it — never
220
- re-pasted into the PR body each round. After a forward merge of the base, read what the merge
221
- changed since the commit your results name.
222
- For a merge of the base, `git show --remerge-diff <merge>` shows its resolution, and `git diff --stat <merge>^1 <merge>` lists the files the base brought in.
223
- A check those files or the resolution can reach runs again, and a check the merge was made for has no pass to carry.
224
- Record every other check with no `ci_check` again at the new head without running it, its
225
- `--observed` naming the earlier pass and why the merge cannot reach what the check drives.
226
- Search the merge head for the class of every finding of every earlier review round: an
227
- instance it finds is a failure, recorded under `failures`. The real-surface verification is
228
- repeated whole in a parent's last round, which the architect or the implementer's
229
- forward-merge comment names to you: then run a full test round.
230
- - **The implementer runs `skill://simplify-settled-diff` once per pull request, in its first
231
- implementing round, after its own results and before it completes that round,
232
- whatever the diff touches, a docs-only diff included.** The daemon starts no implementing round
233
- between a clean review and the approval, so this is the one slot before the tester and the
234
- reviewer read the head; a later round answering a review runs no second pass. It is scoped to
235
- the pull request's own diff at that head: nothing applied leaves the head as it is; applied →
236
- the implementer re-runs its fast local checks and the issue's own checks on the applied head
237
- for the surface the simplify diff touched, since a refactor that "preserves behaviour" is a
238
- claim until it is executed, and records each result at that head before it completes.
239
- That cost is why 0-applied is the expected outcome and a pass that applies is spent sparingly.
240
- The pass covers every file of the diff, workflow YAML and documentation with the code, and a
241
- defect it reports is fixed outside the pass with the results recorded again, never dropped as
242
- out of scope; the `Thermo` line's `defects reported` half names how many and the commit that
243
- fixed them, so a head that moved for a reported defect is not recorded as `0 applied` alone.
244
- The reviewer's pair runs at the head each round reviews, over the diff that round reads (the
245
- whole change, or the difference from the commit the round's task names as
246
- `Last reviewed commit:`), when that diff touches runtime code. Record both in the `Thermo` line,
247
- the pair half with the range the pair read. When a later round's pair reads only a range, the
248
- pair half of each earlier round stays in the line beside the new one, because a range is read
249
- on top of the round that read the code up to its start.
250
- - **No deferrals** is the body's rule (*PR body, review, and the merge gate* in
251
- `skill://legion-worker`): a wording nit, and any clear fix in a file this pull request touches,
252
- is made in the running round: a later round costs a CI pass and another review. A requirement on the `Not proven / risk:` line is unmet, not declared away, unless only
253
- the deploy can show it and the plan names its observation;
254
- the `Fast-follow:` line never carries one, and reads `none` or names only cleanup in files
255
- this pull request does not touch. A base frozen for others to stack on is
256
- never rewritten (*A wrong pushed commit* in
257
- `skill://legion-worker/references/conflicts-and-rewrites.md`); the `Chain` line records it.
258
- - **GitHub refuses a pull request body over 65,536 characters.** Each verification round links its
259
- evidence (the run, the comment) rather than inlining it once the body passes about 48,000
260
- characters; a `Check` line keeps its evidence in the result on Dispatch and links the rest.
70
+ - A red check that failed on its own is re-run once with `gh run rerun <run-id> --failed`, and its settlement waited for as `skill://envoy` says, never by sleeping. A merge-group run is never re-run.
71
+ - A required check missing at the head: read `gh pr view <n> --json mergeStateStatus` first. `DIRTY` means the head conflicts with its base, so no `pull_request` run starts and a body edit re-judges nothing: merge the base forward. A green `pull_request_target` run beside it proves nothing.
261
72
 
262
73
  ## When no surface reaches the changed path
263
74
 
264
- No surface reaches the changed path is a report to the architect, never a reason to complete the phase.
265
- Say which surface is missing and what it would have to do — a rig that can spawn the role, a
266
- sandbox that holds the resource, a credential, a command that does not exist yet — and send it to
267
- the architect with `envoy_publish` to its role topic. The architect builds it in this tree
268
- (infrastructure, tooling, or a skill), in an open pull request or a child issue, and resumes you
269
- once it lands. A code path whose first execution would be after the merge — a deploy workflow's
270
- inline step, a post-merge helper, a production-only resource — is a check marked `after_merge`,
271
- recorded once the merge reaches production by the role the project's `production_check` names,
272
- on the look its own `wake_at` brought back, and no reason to leave a `before_merge` check
273
- unrecorded. Completing with a unit suite as the only evidence, where no `ci_check` names it, is
274
- the failure this rule stops.
75
+ Report it to the architect with `envoy_publish`, naming the missing surface and what it would have to do (a rig, a sandbox holding the resource, a credential, a command), and do not complete. The architect builds it and resumes you. A code path that first runs after the merge (a deploy workflow's inline step, a post-merge helper, a production-only resource) is an `after_merge` check instead, recorded after the merge by the role the project's `production_check` names (under `off` nothing records it), unless the implementer can run it against a development stack before then.
@@ -1,77 +1,23 @@
1
1
  # Review threads
2
2
 
3
- Part of `skill://legion-worker`. Read it when you reply on or resolve a review thread, list a pull
4
- request's threads, or adjudicate a bot's finding: the implementer after every push that answers a
5
- review, and the reviewer on every re-review. Every path it cites is in cybermonklabs/legion.
3
+ Read it when you reply on, list or resolve a review thread, or judge a bot's finding.
6
4
 
7
- Three facts govern every thread, whoever opened it.
5
+ - Reply on each thread you answer, one disposition reply per thread: the implementer's `Fixed in <commit>: <one line>` or `Declined: <reason>`, the reviewer's reason in its own words. No reply resolves anything.
6
+ - Only the pull request's author can resolve its threads, and the implementer opens every Legion pull request. So the implementer resolves each thread it answered, and each bot thread the reviewer accepted and named to it by node id, one call per thread, never in bulk and never a thread it has not read:
8
7
 
9
- - **Reply on each thread you answer, one disposition reply per thread.** Every open review thread
10
- gets its own reply naming the fixing commit or the reason it isn't a defect: the implementer's
11
- `Fixed in <commit>: <one line>` or `Declined: <reason>`; the reviewer's reasons in its own words —
12
- the commit that fixed it, why it is not a defect, or what still stands. No word in a reply
13
- resolves anything, and nothing reads a reply for a magic form: a thread is resolved only by the
14
- resolution below, after its reply.
15
- - **Resolve each thread you have answered, one thread per call, never in bulk, never a thread you
16
- have not read.** GitHub grants `resolveReviewThread` to the pull request's author, and the
17
- implementer opens every Legion pull request (`docs/site/src/content/docs/legion/running-legion.md`,
18
- "The GitHub Apps"), so the implementer resolves every thread, its own and the ones the
19
- reviewer accepted:
20
- - The **implementer**, after every push that answers a review and before its `handoff_complete`,
21
- resolves each thread it answered with its own `gh`, one thread per call:
8
+ ```bash
9
+ gh api graphql -f query='mutation($id:ID!){resolveReviewThread(input:{threadId:$id}){thread{isResolved}}}' -F id=<thread node id>
10
+ ```
22
11
 
23
- ```bash
24
- gh api graphql -f query='mutation($id:ID!){resolveReviewThread(input:{threadId:$id}){thread{isResolved}}}' -F id=<thread node id>
25
- ```
12
+ When GitHub refuses, send the thread and GitHub's message to the architect with `envoy_publish`; never skip it.
13
+ - The implementer records each thread in the PR body's `Threads` section, stamped with the head it just pushed.
14
+ - The reviewer lists the threads, replies, and names the threads it accepted to the implementer by node id (on the implementer's role topic, or in its review body):
26
15
 
27
- A thread a bot opened (a CI bot's, or an App-routed person's) it answers the same way; the
28
- reviewer adjudicates the finding. The bot threads the reviewer accepted, which the reviewer
29
- names to the implementer by node id (below), the implementer resolves with the same call, one
30
- per thread, as soon as the message reaches it or as part of answering that review, and records
31
- in the PR body's `Threads` section too; never one the reviewer did not name. When GitHub refuses
32
- a resolution, report the thread and GitHub's message to the architect with `envoy_publish`,
33
- which opens a `dispatch ask` for a human to resolve it by hand; never skip it silently.
34
- - The **reviewer** cannot resolve a thread as its own App: GitHub refuses the review App
35
- `resolveReviewThread` on the implementer's pull request, so it replies, and names the threads
36
- it accepted to the implementer, who resolves them. List the pull request's threads:
16
+ ```bash
17
+ gh api graphql --paginate -f query='query($o:String!,$r:String!,$n:Int!,$endCursor:String){repository(owner:$o,name:$r){pullRequest(number:$n){reviewThreads(first:100,after:$endCursor){pageInfo{hasNextPage endCursor} nodes{id isResolved comments(last:1){nodes{author{login} body}}}}}}}' -F o=<owner> -F r=<repo> -F n=<number>
18
+ ```
37
19
 
38
- ```bash
39
- gh api graphql --paginate -f query='query($o:String!,$r:String!,$n:Int!,$endCursor:String){repository(owner:$o,name:$r){pullRequest(number:$n){reviewThreads(first:100,after:$endCursor){pageInfo{hasNextPage endCursor} nodes{id isResolved comments(last:1){nodes{author{login} body}}}}}}}' -F o=<owner> -F r=<repo> -F n=<number>
40
- ```
41
-
42
- `--paginate` follows the thread pages, which it prints as one JSON object per page, so add
43
- `--slurp` when you want a single document; `comments(last:1)` needs no paging of its own.
44
-
45
- Reply on each thread you answer, then tell the implementer the node ids of exactly the threads
46
- you accepted — a bot's findings you adjudicated — never one you have not read: an
47
- `envoy_publish` to the implementer's role topic (it is live on the issue and answers while you
48
- wait; its topic is yours from the `Legion addressing` line with `-implementer` as the last part), or your review body, which
49
- it reads at its next round. The implementer resolves exactly those with its own `gh`. GitHub
50
- cannot tell a CI bot from a person whose `gh` is routed to an App, so such a thread may be a
51
- person's finding: accept it only when the finding itself is settled (a genuine Minor is settled
52
- by being judged Minor), since the resolution says you judged it.
53
- - **A reviewer who disagrees with a resolution replies and unresolves it.** Resolution is a
54
- judgment, not a ledger entry: a thread the implementer resolved whose finding still stands gets
55
- the reviewer's reply saying what stands and is unresolved, and a finding the reviewer cannot
56
- accept becomes its own, with a `REQUEST_CHANGES` naming it.
57
-
58
- ## The PR body's `Threads` section
59
-
60
- The implementer records each thread it answered in the PR body's `Threads` section
61
- (`skill://legion-worker/references/pr-body.md`), stamped with the head it just pushed: the thread's
62
- id, its disposition (`fixed in <commit-sha> — <one line>` or `not a defect — <reason>`), and the
63
- head that answered it. The reviewer verifies thread state in `gh api graphql`, never from that
64
- section: it is the implementer's record, and GitHub is the fact.
65
-
66
- ## The reviewer, on a re-review
67
-
68
- When you re-review after a corrective push, answer every thread you opened, and every thread a bot
69
- opened that is none of Legion's role Apps, with one reply in your own words. A bot's finding you
70
- cannot accept becomes your own: say what stands and request changes. Approve once each of those
71
- threads carries your answer and no finding stands, read in `gh api graphql` — quote those answers
72
- in the approval. Your approval never waits on a resolution: resolution is the pull request author's
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
- ones you named to it, above, and its own), and pushes, and the bot runs again on that push. The
77
- merger resolves nothing: the merge requires no thread state beyond what your approval already judged.
20
+ `--paginate` prints one JSON object per page; add `--slurp` for one document.
21
+ - GitHub cannot tell a CI bot from a person whose `gh` acts as an App, so accept such a thread only when its finding is settled.
22
+ - A reviewer who disagrees with a resolution replies and unresolves it; a finding it cannot accept becomes its own `REQUEST_CHANGES`.
23
+ - The reviewer verifies thread state in `gh api graphql`, never from the `Threads` section, and its approval never waits on a resolution. The merger resolves nothing.