@sjawhar/claude-envoy 2.11.0 → 2.11.2

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.
@@ -1,28 +1,41 @@
1
1
  # Decisions on a parked tree
2
2
 
3
- A parked tree is a root handed to Legion (the `legion` label) whose Dispatch status is `backlog`
4
- or `icebox` and whose `issues.<KEY>.phase` in `read_state` is `done`. Its architect is suspended
5
- or gone, so nobody inside the tree hears what a person says on it. The Go daemon sends you each
6
- such decision as `parked-decision on <KEY>`; the walk below finds one sent while no controller
7
- ran. You decide whether the tree runs again, unless the park is not your own hold. When it
8
- runs, its architect's start task, or the catch-up of a later launch, names each decision the
9
- daemon relayed, and both spec versions when the approved one is not the current one, so you need
10
- not tell it.
3
+ A parked tree is a root handed to Legion (the `legion` label) whose Dispatch status is `backlog` or
4
+ `icebox` and whose `issues.<KEY>.phase` in `read_state` is `done`. Its architect is suspended or
5
+ gone, so nobody inside the tree hears what a person says on it. The Go daemon sends you each such
6
+ decision as `parked-decision on <KEY>`; the walk below finds one sent while no controller ran. When
7
+ the park is your own hold, you decide whether such a decision runs the tree again; whoever made the
8
+ park, you start the tree when a person asks you to. When it runs, its architect's start task, or the
9
+ catch-up of a later launch, names each decision the daemon relayed, and both spec versions when the
10
+ approved one is not the current one, so you need not tell it.
11
11
 
12
12
  ## Backlog and icebox
13
13
 
14
14
  A park means "should not run now", and a parked root keeps its `legion` label. A parked root runs
15
- again when a person sets it to `todo`, when a wake tells you to re-admit it (`worker-died`,
16
- `held`), or when it is your own hold (a park you marked `Parked by Legion while it waits on:`, step
17
- 2 of **Deciding**) and a person's decision after the park gives its work a next step, as below.
15
+ again when a person sets it to `todo`, or when it is your own hold (a park you marked
16
+ `Parked by Legion while it waits on:`, step 2 of **Deciding**) and a person's decision after the
17
+ park gives its work a next step, as below.
18
+ A parked root that is your own hold also runs again when you checked that the hold's cause or the
19
+ architect's cause is gone, or that the event it waits on has happened, as the wakes reference
20
+ says (the `held` and `worker-died` wakes, and
21
+ [A tree that waits on an event outside Legion](skill://legion-controller/references/wakes.md#a-tree-that-waits-on-an-event-outside-legion)):
22
+ you set it to `todo` with a comment on the root that cites the park's mark and says what you
23
+ checked.
24
+ [The walk](#the-walk) makes that check at every start and on each `tick`.
18
25
  Every other park, a person's, another session's or an operator's `legion status`, stays parked
19
- until whoever parked it sets it to `todo`.
26
+ until a person sets it to `todo`, the daemon queues a person's approval of its spec (**The
27
+ notice**, the paragraph that begins "A person's own approval"), or a person asks you to start it:
28
+ that request is a person's move, as the list of moves to `todo` in
29
+ [Free slots](skill://legion-controller/SKILL.md#free-slots) says.
20
30
 
21
31
  A held root is not a parked one. It stands at `phase: held` and is still in the workflow, and a
22
32
  `todo` on it releases the hold instead of starting a new run: the issue returns to the phase its
23
33
  hold came from and that phase's role starts again, at the same generation
24
- (`skill://legion-controller/references/wakes.md`, the `held` wake). The recipe below, `backlog`
25
- and then `todo`, is for a root that is parked or lingers, and it is what re-admits a tree.
34
+ (`skill://legion-controller/references/wakes.md`, the `held` wake). A root that is parked or
35
+ lingers takes `todo` alone, and that `todo` re-admits its tree. The pair `backlog` and then `todo`
36
+ (step 1 of **Deciding**) is for a root still in the workflow whose architect has stopped, a held
37
+ root included, where `todo` alone would only release the hold. The `backlog` write takes that
38
+ tree out of the workflow, so the `todo` after it re-admits the tree.
26
39
 
27
40
  ## The notice
28
41
 
@@ -47,25 +60,31 @@ A person's own approval of a parked root's own spec (its primary document), when
47
60
  live, is no notice either: it is that person's handover, and the daemon sets the root `todo`
48
61
  itself, whoever parked it (`admission: queued a person's handover`, `source=approval`). Two
49
62
  approvals of a root's spec are not that handover and still come as notices: a carried approval,
50
- which Dispatch writes in the person's name when their answer to a decision block was the whole
51
- change since the version they approved, and an approval on a root that keeps a Dispatch parent,
52
- as a child a linger handed to Legion does. The other spec notices are a request for changes and
53
- an approval of a document that is not the root's primary one.
63
+ which Dispatch writes in the person's name with a reason that begins
64
+ `Carried forward from the approval of version`, when their answer to a decision block was the
65
+ whole change since the version they approved or when a later version's text is the text of the
66
+ version they approved, and an approval on a root that keeps a Dispatch parent, as a child a linger
67
+ handed to Legion does. The other spec notices are a request for changes and an approval of a
68
+ document that is not the root's primary one.
54
69
 
55
70
  ## Deciding
56
71
 
57
72
  1. **Where the tree stands.** Read `issues.<root>` with `read_state`.
58
73
  - Its `phase` is not `done`: the tree runs. When `architect.state` is `failed` or `retired`,
59
74
  nobody in the tree heard the decision: skip step 2 and judge it in steps 3 and 4. A decision
60
- that gives the work a next step re-admits the tree as the `worker-died` section of
61
- [the wakes reference](skill://legion-controller/references/wakes.md) says
62
- (`set_status` of the root to `backlog`, then to `todo`), not to `todo` alone. On a root at
63
- `phase: held`, `todo` alone releases that hold and starts the held phase's worker, which
64
- leaves the failed architect where it is, so the park before it is what gives the tree an
65
- architect again. Answer a question as step 4 says, and leave the tree as it is. In that reply
66
- and in the root's copy, write `<root>'s architect has stopped, so it` for
67
- `<root> is parked, so its architect`, `The tree waits.` for `The tree stays parked.`, and
68
- `backlog, then todo,` for `todo`.
75
+ that gives the work a next step re-admits the tree (`set_status` of the root to `backlog`,
76
+ then to `todo`, not to `todo` alone) as the `worker-died` section of
77
+ [the wakes reference](skill://legion-controller/references/wakes.md) says, once that section
78
+ finds no cause or finds it gone; while the cause stays, the tree stays admitted under that
79
+ section's park ask. That pair is a restart and not a park. On a root at `phase: held`, `todo`
80
+ alone releases that hold and starts the held phase's worker, which leaves the failed
81
+ architect where it is, so the `backlog` write before it is what gives the tree an architect
82
+ again.
83
+ You park an issue in `backlog` or `icebox` only when a person asked for that move, or when the work is done, folded into another issue or no longer needed, and cite that reason in a comment on the issue.
84
+ Answer a question as step 4 says, and leave the tree as it is. In that reply and in the
85
+ root's copy, write `<root>'s architect has stopped, so it` for `<root> is parked, so its
86
+ architect`, `The tree waits.` for `The tree stays parked.`, and `backlog, then todo,` for
87
+ `todo`.
69
88
  Otherwise the tree already heard the decision: do nothing.
70
89
  - Its `phase` is `done`: read the root's Dispatch status (`dispatch read --issue <root>`).
71
90
  `backlog` or `icebox`: go on. `done`: the tree finished; set nothing and name `ref` in your
@@ -81,9 +100,13 @@ an approval of a document that is not the root's primary one.
81
100
  legion-daemon:<PROJECT>` and, after it and at most 10 minutes after it, `Events:` show a
82
101
  `comment.created` from a session (any controller session: its id changes when the controller
83
102
  restarts or is taken over) that begins `Parked by Legion while it waits on:`. That is the mark
84
- you post on the root, in the same turn, when you park a tree for a hold (the `held` section of
85
- [the wakes reference](skill://legion-controller/references/wakes.md)), and for no other
86
- park: a park a person asks for, or one you make at triage, gets no mark. The window pairs the
103
+ you post on the root, in the same turn, when you park a tree on a person's answer to the
104
+ `dispatch ask` you opened for a hold, for a failed architect or for a tree that waits on an
105
+ event outside Legion (the `held`, `worker-died` and
106
+ [A tree that waits on an event outside Legion](skill://legion-controller/references/wakes.md#a-tree-that-waits-on-an-event-outside-legion)
107
+ sections of [the wakes reference](skill://legion-controller/references/wakes.md)), and for no
108
+ other park: a park a person asks for on their own, without your ask, or one you make at
109
+ triage, gets no mark. The window pairs the
87
110
  mark with the park it was posted for: `set_status` writes the status to Dispatch before it
88
111
  returns, so the mark's line follows the park's within the turn, and a mark older than the park
89
112
  line belongs to an earlier park. Every other park is someone else's: a person's (`user
@@ -125,19 +148,29 @@ an approval of a document that is not the root's primary one.
125
148
  `todo` releases no hold. Post one comment on the issue where the decision was made
126
149
  (`dispatch comment --issue <KEY> --body-file -`): `Parked decision read: <ref> by <login>
127
150
  gives this tree its next step (<one sentence>). Legion runs it again.`
128
- - Any other park, or you cannot read who parked the tree: set nothing, since you move only a
129
- hold of your own ([Free slots](skill://legion-controller/SKILL.md#free-slots)).
130
- Post one comment there: `Parked decision read: <ref> by <login> gives this tree its next
131
- step (<one sentence>).`, then the sentence for that park, then `Its architect then starts
151
+ - Any other park, or you cannot read who parked the tree, when the decision's own words ask
152
+ Legion to start the tree: that is a person's request to start it
153
+ ([Free slots](skill://legion-controller/SKILL.md#free-slots)). Set the root to `todo`
154
+ (`set_status`) and post one comment on the issue where the decision was made:
155
+ `Parked decision read: <ref> by <login> asks Legion to start this tree. Legion runs it
156
+ again.`
157
+ - Any other park, or you cannot read who parked the tree, in any other case: set nothing. A
158
+ decision that only gives the work a next step is no request to start it.
159
+ Post one comment on the issue where the decision was made: `Parked decision read: <ref> by
160
+ <login> gives this tree its next step (<one sentence>).`, then the sentence for that park,
161
+ then `Its architect then starts
132
162
  with this decision.` For a comment that is no reply on an ask, leave out the last sentence:
133
163
  the daemon relays no such comment. The sentence for the park:
134
- - A person's or another session's: `<parker> parked the tree, so it stays parked until they
135
- set it to todo.`, with the login for a person and `session <id>` for a session.
164
+ - A person's or another session's: `<parker> parked the tree, so it stays parked until a
165
+ person sets it to todo, approves its spec when it has no parent, or asks Legion to start
166
+ it.`, with the login for a person and `session <id>` for a session.
136
167
  - One by `session legion-daemon:<PROJECT>` with no mark: `The tree was parked through Legion
137
168
  (session legion-daemon:<PROJECT>) for no hold of its own, so it stays parked until a
138
- person sets it to todo.`
169
+ person sets it to todo, approves its spec when it has no parent, or asks Legion to start
170
+ it.`
139
171
  - One you cannot read: `Its last 10 events do not show who parked the tree, so it stays
140
- parked until whoever parked it sets it to todo.`
172
+ parked until a person sets it to todo, approves its spec when it has no parent, or asks
173
+ Legion to start it.`
141
174
  - It only questions the work: a question, a doubt about the premise, a request for changes that
142
175
  only asks why. Leave it parked and answer the question in one reply:
143
176
  - Answer from the record when it holds the answer: the issue and its spec (`dispatch read`,
@@ -175,9 +208,10 @@ an approval of a document that is not the root's primary one.
175
208
 
176
209
  At every start (step 4 of the start procedure) and on each `tick`:
177
210
 
178
- 1. List the parked roots: `dispatch issues --project <PROJECT> --status backlog --label legion
179
- --limit 250 --offset 0`, then the same with `--status icebox`, each paged as
180
- [At every start](skill://legion-controller/references/triage.md#at-every-start) pages triage.
211
+ 1. List the parked roots:
212
+ `dispatch issues --project <PROJECT> --status backlog --label legion --all`, then the same
213
+ with `--status icebox`. `--all` reads every match in one request, as
214
+ [At every start](skill://legion-controller/references/triage.md#at-every-start) reads triage.
181
215
  Keep the rows that `read_state` records under `issues` at phase `done`.
182
216
  2. For each, read the root (`dispatch read --issue <root>`), then its children
183
217
  (`dispatch read --ref dispatch://<root>/children`) and each child (`dispatch read --issue
@@ -190,8 +224,9 @@ At every start (step 4 of the start procedure) and on each `tick`:
190
224
  `artifact.approved` or `artifact.changes_requested` event, with the approval request's
191
225
  `ask.answered` at the same time, is one decision whose `ref` is `dispatch://<KEY>/spec`, and
192
226
  the issue's `Spec approval:` line shows a request's reason. Skip an `artifact.approved` only
193
- when it is the person's handover, which the daemon queues itself (the paragraph under **The
194
- notice**), and with it the approval request's `ask.answered` at the same time. It is that
227
+ when it is the person's handover, which the daemon queues itself (**The notice**, the paragraph
228
+ that begins "A person's own approval"), and with it the approval request's `ask.answered` at the
229
+ same time. It is that
195
230
  handover when all three hold: the root's `parent` is `null`; the event's `payload.artifact_id`
196
231
  is the root's `primary_artifact_id`; and its `payload.reason` does not begin `Carried forward
197
232
  from the approval of version`. The events `curl` of
@@ -211,3 +246,28 @@ At every start (step 4 of the start procedure) and on each `tick`:
211
246
  notice does not depend on that window.
212
247
  4. Decide each tree's decisions as **Deciding** says, its step 1 included. An event of those types
213
248
  that is older than the park goes in your summary when **Deciding** step 2 says so.
249
+ 5. Take each root of step 1's list whose park is your own hold (**Deciding**, step 2) and whose
250
+ tree had no decision that step 4 judged in this walk: the next walk checks a root whose tree
251
+ had a decision. The mark of each root you take, the first line of the
252
+ `Parked by Legion while it waits on:` comment that **Deciding** step 2 pairs with the park,
253
+ names the cause or the event that the tree waits on. When that comment cites an ask's answer,
254
+ the root's `Asked whether to park:` comment that names that ask gives the `<key>` of the same
255
+ wait on its second line
256
+ (`skill://legion-controller/references/wakes.md#ask-whether-to-park-a-tree`). Check that wait
257
+ now:
258
+ - For an `event:` key, read what its reference names: the issue, the pull request, the
259
+ release, the deploy run, or the message or comment that names what the tree waits on.
260
+ - For any other mark, check the cause that the mark names. That is a mark with a `held` or an
261
+ `architect failed:` key, or a mark with no park ask: its comment cites no ask, or cites an
262
+ ask that no `Asked whether to park:` comment names. A mark with no park ask comes from an
263
+ escalated hold that an earlier Legion parked at once. Judge whether the cause is gone with
264
+ the test of step 3 of
265
+ [An escalated hold](skill://legion-controller/references/escalation.md#an-escalated-hold).
266
+ A live row of `read_state`'s `capabilities` speaks only for a session that runs, and the
267
+ parked tree runs none. So the lack of such a row is no evidence that the cause is gone.
268
+
269
+ When the event has happened or the cause is gone, set the root to `todo` (`set_status`). Post
270
+ one comment on the root (`dispatch comment --issue <root> --body-file -`) that cites the mark
271
+ and says what you checked, as the wakes reference says. When the event has not happened, the
272
+ cause stays, or you cannot tell, move nothing. Name the root and what it waits on in your
273
+ summary.
@@ -33,8 +33,12 @@ answer to your ask, a mention), Envoy or Slack. No `legion controller start` can
33
33
  `settings` (the daemon's resolved `legion.yaml`, with no credential in it).
34
34
  - `op: "set_status"` with `issue` and `status` (`todo`, `backlog` or `icebox`) moves an issue. Each
35
35
  call mints its grant in-process from the secret the session registered with, so a stale secret
36
- fails it with a 403. You cannot set `done`: only an issue's architect or the daemon closes an
37
- issue.
36
+ fails it with a 403.
37
+ Move an issue to `backlog` or `icebox` only when a person asked for that move, or when the work is done, folded into another issue or no longer needed.
38
+ Cite that reason in a comment on the issue. Two writes are not that move: a root's restart,
39
+ which sets `backlog` and then `todo` in the same turn, and the report issue's `icebox`, because
40
+ that issue holds no work. You cannot set `done`: only an issue's architect or the daemon closes
41
+ an issue.
38
42
 
39
43
  ## `gh`
40
44
 
@@ -142,8 +142,9 @@ architect for it, whatever it asks. For a person's mention, take the first of th
142
142
  deployment instructions state. Reply with the new issue's key, its title, the link and assignee
143
143
  the `Created` line names (naming nobody, Dispatch assigns the issue to your token's owner, or,
144
144
  under the shared token, to the project's default assignee when a person set one),
145
- and whether Legion will take it: with the label, triage admits it in its next turn unless the
146
- request, the weekly plan or the deployment instructions say to wait.
145
+ and whether Legion will take it: with the label, triage admits it in its next turn unless a
146
+ person's request says to wait or puts it out of scope. That request is the request itself, the
147
+ deployment instructions, or a line of the weekly plan that names the person's request behind it.
147
148
  - **Something an issue's architect owns.** A question about a tree's design, a change of direction,
148
149
  a decision only the tree's architect can make about an issue Legion runs. Find the tree: follow
149
150
  `Links:` up through each `child_of` parent with `dispatch read` until you reach the issue
@@ -56,15 +56,21 @@ Read this on a `triage` wake, at every start, and when a person hands you an iss
56
56
  catch-up reads that reply as done.
57
57
  3. Admit it (`set_status` to `todo`) only when you labelled it at a person's request, you filed it
58
58
  yourself (for a person, or for a clear defect no tree owns), or a person answered `Admit it`,
59
- unless the request, the weekly plan or the deployment instructions say to wait or put it out of
60
- scope:
61
- `legion({ op: "set_status", issue: "<issue>", status: "todo" })`.
62
- 4. When one of those says to wait, park it with `set_status` to `backlog`, or `icebox` when the
63
- request asks for a longer deferral, instead of leaving it in `triage`; the label stays. Never
64
- park a root for lack of a free slot, because in `todo` the daemon's waiting line already holds
65
- it until a slot frees.
59
+ unless a person's request says to wait or puts it out of scope:
60
+ `legion({ op: "set_status", issue: "<issue>", status: "todo" })`. The operator's deployment
61
+ instructions are such a request. A line of your own weekly plan is not, unless that line names
62
+ the person's request behind it.
63
+ 4. When a person's request says to wait, park it with `set_status` to `backlog`, or `icebox` when
64
+ the request asks for a longer deferral, instead of leaving it in `triage`; the label stays.
65
+ Park a root only when a person asked for that move, or when the work is done, folded into another issue or no longer needed.
66
+ Never park a root for lack of a free slot, because in `todo` the daemon's waiting line already
67
+ holds it until a slot frees: admit it as step 3 says, and report the capacity to the person in
68
+ the day's report.
66
69
  5. For a root you admitted or parked, comment on the issue (`dispatch comment`) what you decided
67
- and why. For a root you admitted, say in that comment who will be asked: `Assigned to <login>,
70
+ and why. For a root you parked, cite in that comment why: the person's request behind the park
71
+ (the deployment instructions as that file, or the request the plan's line names), or that the
72
+ work is done, folded into another issue (name it) or no longer needed.
73
+ For a root you admitted, say in that comment who will be asked: `Assigned to <login>,
68
74
  who will get this tree's questions and its design approval`, or, when `Assignee:` says
69
75
  `unassigned`, `Unassigned — nobody's Inbox shows this tree's questions or its design approval
70
76
  until someone takes it from the issue header (Assignee, beside Priority)`. Promise the design
@@ -15,7 +15,9 @@ label, and on each later change while it stays in `triage`, the change that adds
15
15
  included. Triage the root as `skill://legion-controller/references/triage.md` says. A person's
16
16
  label on a `triage` root wakes nobody: the root is queued by the daemon (its own `todo` write). A
17
17
  person's approval of a parked (`backlog` or `icebox`) labelled root's spec is queued by the daemon
18
- the same way and wakes nobody.
18
+ the same way and wakes nobody, except a carried approval and one on a root that keeps a Dispatch
19
+ parent, which come as notices
20
+ (`skill://legion-controller/references/parked-decisions.md#the-notice`).
19
21
 
20
22
  ## `slot-free on <KEY>` (`{kind: "slot-free"}`)
21
23
 
@@ -78,9 +80,13 @@ handler refuses a fact of another generation.
78
80
  So read the issue's record for every entry rather than taking its architect as told:
79
81
  `read_state`'s `issues.<KEY>` gives its phase and each role's claim, and says whether the worker
80
82
  has moved since the tick was queued.
81
- Where the architect of that issue is itself a claim that is not answering — its claim reads
82
- `failed`, or the Envoy registry shows its session gone — `fresh_session` on that architect, because
83
- a notice sent to a claim that reads nothing reaches nobody and the work stands still.
83
+ Where the architect of that issue is itself a claim that is not answering, a notice sent to it
84
+ reaches nobody and the work stands still. When the tree's architect claim reads `failed`
85
+ (`issues.<ROOT>.architect.state`, `<ROOT>` being the silent issue's `tree`), act as the
86
+ `worker-died` section below says, with `<ROOT>` as its `<KEY>`: restart the tree when you find no
87
+ cause or its cause is gone, and otherwise ask the person whether to park it, with no relaunch
88
+ while the cause stays. When its claim does not read `failed` and the Envoy registry shows its
89
+ session gone, `fresh_session` on that architect.
84
90
  Name each silent issue in the day's report, with its role and the length of its silence.
85
91
 
86
92
  ## `unslotted on <KEY>` (`{kind: "unslotted", reason}`)
@@ -162,16 +168,120 @@ releases the hold only on a root standing at `phase: held`: a root whose tree li
162
168
  `phase: done` is re-admitted by the same `todo` at a new generation, and a held child comes back
163
169
  at `admitted` with a new generation of its own.
164
170
 
165
- When an escalated hold's cause is not gone, park the tree: `set_status` the root to `backlog`,
166
- then, in the same turn, post one comment on the root (`dispatch comment --issue <root>
167
- --body-file -`) whose first line is `Parked by Legion while it waits on: <the hold's cause>`, the
168
- cause being what you found the held phase waits on (the payload's `phase` and `role`, and the held
169
- issue's `dispatch read`). That mark is what makes the park Legion's own hold
170
- (`skill://legion-controller/references/parked-decisions.md#deciding`, step 2). Set the root back to
171
- `todo` only when you checked that the hold's cause is gone, a person asks, or a person's decision
172
- after the park gives its work a next step (that reference's step 4), because the park took the tree
173
- out of the workflow: the `todo` after it starts a new generation of the tree, from its architect,
174
- and releases no hold.
171
+ When an escalated hold's cause is not gone, do not park the tree. The tree stays admitted and
172
+ keeps its slot. Ask the person whether to park it, as
173
+ [Ask whether to park a tree](#ask-whether-to-park-a-tree) says. Its `<cause>` is what the held
174
+ phase waits on: the payload's `phase` and `role`, and the held issue's `dispatch read`. Its
175
+ `<key>` is `held <ISSUE> in <heldFrom> (<role>) at <failure.at>`: `<ISSUE>` is the held issue's
176
+ key, `<heldFrom>` is `issues.<ISSUE>.heldFrom`, `<role>` is the role of that phase, whose claim
177
+ failed, and `<failure.at>` is that claim's `issues.<ISSUE>.workers.<role>.claim.failure.at`,
178
+ exactly as `read_state` gives it. Where `failure.at` is absent, the key ends `generation <n>` in
179
+ place of `at <failure.at>`. `<n>` is `issues.<ISSUE>.generation` in `read_state`. The next
180
+ failure gets a new key, so a `Left admitted` answers only the failure it was given for.
181
+ Park the tree only when a person asked for that move, or when the work is done, folded into another issue or no longer needed.
182
+ A person's `Park it` answer to that ask is such a request. Only a park on that answer carries the
183
+ mark. Cite the ask's answer in the comment you post with the park, and make that comment's first
184
+ line `Parked by Legion while it waits on: <the hold's cause>`, because that mark is what makes the
185
+ park Legion's own hold (`skill://legion-controller/references/parked-decisions.md#deciding`,
186
+ step 2). Set the root of a park with that mark back to `todo` only when you checked that the
187
+ hold's cause is gone, a person asks, or a person's decision after the park gives its work a next
188
+ step (that reference's step 4), because the park took the tree out of the workflow: the `todo`
189
+ after it starts a new generation of the tree, from its architect, and releases no hold. For a
190
+ `todo` after your check, post one comment on the root
191
+ (`dispatch comment --issue <root> --body-file -`) that cites the park's
192
+ `Parked by Legion while it waits on:` mark and says what you checked.
193
+
194
+ ## Ask whether to park a tree
195
+
196
+ The `held` wake's escalated hold, a tree that waits on an event outside Legion, and the
197
+ `worker-died` wake send you here when a tree's wait has a cause that stays, with that cause as
198
+ `<cause>`. Each of those sections also gives the cause a fixed key, `<key>`: its text is the same
199
+ at every run, while the text of `<cause>` can change from one run to the next. The tree stays
200
+ admitted and keeps its slot while you ask. A comment or a reply from any session counts as yours
201
+ here, because the controller's session id changes when it restarts or is taken over.
202
+
203
+ 1. Look for the ask you opened for this key already. List the root's comments that name an ask:
204
+
205
+ ```text
206
+ notes=$(curl -sS --fail-with-body -H "Authorization: Bearer $(cat "$DISPATCH_TOKEN_FILE")" "$DISPATCH_URL/api/v1/issues/<root>/comments") || { echo "Dispatch read failed" >&2; exit 1; }
207
+ printf '%s' "$notes" | jq -cn 'input | if type == "array" then [.[] | select(.author.kind == "session" and (.body | startswith("Asked whether to park: "))) | {id, created_at, body}] else error("Dispatch did not answer the list") end'
208
+ ```
209
+
210
+ Take the newest of them whose second line is exactly `<key>`. Compare that line alone, and not
211
+ the `<cause>` text under it. Read the ask its first line names
212
+ (`dispatch read --ref '<that reference>'`):
213
+ - It is open: open nothing and post nothing.
214
+ - It is resolved with no answer: open nothing and post nothing for this key. The day's report
215
+ names the tree and that ask, as `skill://legion-controller/references/daily-report.md` says.
216
+ - It is answered, and no reply of yours under it starts `Parked dispatch://`,
217
+ `Not parked dispatch://` or `Left admitted dispatch://`: act on its answer now (step 4).
218
+ - Your reply under it starts `Left admitted dispatch://`: the person chose to leave the tree
219
+ admitted for this key. Open nothing and post nothing.
220
+ - Your reply under it starts `Parked dispatch://`: the tree runs again after that park, so its
221
+ wait now is a new one. Go on to step 2.
222
+ - Your reply under it starts `Not parked dispatch://`: that ask is spent, because its `Park it`
223
+ came when the root was `done` or the tree no longer had the wait that `<key>` names. Go on
224
+ to step 2: a new wait asks again.
225
+
226
+ With no such comment, go on to step 2.
227
+ 2. Open a `dispatch ask` on the report issue that names the root and `<cause>` and asks the person
228
+ whether to park the tree, with the options `Park it` and `Leave it admitted`. The ask also says
229
+ that, after a park on `Park it`, Legion sets the root back to `todo` when the wait that
230
+ `<cause>` names ends (the cause is gone, or the event happens). Follow it
231
+ (`dispatch follow --ask '<ref>' --action follow`), as
232
+ `skill://legion-controller/references/finding-asks.md#follow-it` says, so that its answer
233
+ reaches you. Post one comment on the root (`dispatch comment --issue <root> --body-file -`).
234
+ Make its first line `Asked whether to park: dispatch://<REPORT KEY>/ask/<id>`. Make its second
235
+ line `<key>`, exactly as the section of the cause gives it. Write `<cause>` on the lines under
236
+ the key.
237
+ 3. Name the tree and the ask's reference in the day's report while the ask is open.
238
+ 4. Act on the ask's newest answer. The start procedure's catch-up sends every answer that has no
239
+ reply here, so an answer can come after the root is `done` or after its cause is gone.
240
+ - `Park it`, when the root's `phase` is not `done` and the tree still has the wait that `<key>`
241
+ names: park the tree. Post the park's comment as the section of its cause says: the
242
+ `held` wake's escalated hold, a tree that waits on an event outside Legion, or the
243
+ `worker-died` wake. That comment cites the answer, and its first line is the mark
244
+ `Parked by Legion while it waits on: <cause>`.
245
+ - `Park it` in any other case: move nothing, and say in your reply what you checked.
246
+ - `Leave it admitted`: move nothing.
247
+
248
+ That `<key>` is the second line of the root's comment that names this ask. The tree still has
249
+ the wait that `<key>` names when the section of its cause, applied to `read_state` now, builds
250
+ that same `<key>`. Compare the two keys exactly, as step 1 compares the second line. A cause
251
+ that is gone, an issue no longer at `phase: held`, or an architect no longer `failed` builds no
252
+ key. For an `event:` key, that is when the tree still waits on that event.
253
+
254
+ In each case, reply under the ask with what you did, its first line exactly
255
+ `Parked dispatch://<root>`, `Not parked dispatch://<root>` or `Left admitted dispatch://<root>`:
256
+ `dispatch comment --issue <REPORT KEY> --reply-to-ask '<ask id>' --body-file -`. Dispatch
257
+ refuses to resolve an answered ask, so that reply is the ask's record: step 1 and the start
258
+ procedure's catch-up
259
+ (`skill://legion-controller/references/finding-asks.md#catch-up-at-every-start`, step 3) read
260
+ it.
261
+
262
+ ## A tree that waits on an event outside Legion
263
+
264
+ A running tree can hold a slot while it waits on an event outside Legion: a deploy, another
265
+ project's release, a vendor, or a person outside the company. Do not park it: the tree stays
266
+ admitted and keeps its slot. Ask the person whether to park it, as
267
+ [Ask whether to park a tree](#ask-whether-to-park-a-tree) says, with the event as `<cause>`. Its
268
+ `<key>` is `event: <the event>`. `<the event>` is the one thing the tree waits on, named by a
269
+ fixed reference: an issue's `dispatch://` reference, a pull request's or a release's URL, or the
270
+ deploy's run URL. For a vendor or a person outside the company, it is the `dispatch://`
271
+ reference of the message or comment that names what the tree waits on. Choose that reference at
272
+ the first ask. After that, copy it exactly from the second line of that ask's comment on the
273
+ root. A tree in which an issue stands at `phase: held` with `holdReason: escalated` takes the
274
+ `held` key above for that issue, and a tree whose root's `architect.state` is `failed` takes the
275
+ `architect failed:` key below. Neither takes the `event:` key, whichever wake or pass brought the
276
+ tree to you.
277
+ Park the tree only when a person asked for that move, or when the work is done, folded into another issue or no longer needed.
278
+ A person's `Park it` answer to that ask is such a request. Only a park on that answer carries the
279
+ mark: cite the ask's answer in the park's comment, whose first line is
280
+ `Parked by Legion while it waits on: <the event>`, the mark that makes the park Legion's own hold
281
+ (`skill://legion-controller/references/parked-decisions.md#deciding`, step 2).
282
+ Set the root of a park with that mark back to `todo` once you checked that the event has
283
+ happened, a person asks, or a person's decision after the park gives its work a next step, as the
284
+ escalated hold above says.
175
285
 
176
286
  ## `worker-died on <KEY>` (`role: "architect"`)
177
287
 
@@ -181,10 +291,25 @@ notice of the tree goes to that architect, so nobody inside the tree can act. Ch
181
291
  parked: do nothing (a failed architect reads `failed` until the tree closes). Otherwise look for
182
292
  the cause. `issues.<KEY>.architect.failure` holds the record the `held` wake above describes. Read
183
293
  after it an open `capabilities` row whose `detail` names the architect's session, or the
184
- architect's last message on the root issue. When you find none, or it is gone, re-admit the tree
185
- (`set_status` the root to `backlog`, then to `todo`: a new generation whose architect starts with
186
- fresh budgets). When it stays, park the tree (`set_status` the root to `backlog`) and say why on
187
- the issue, because a relaunch would fail the same way.
294
+ architect's last message on the root issue. When you find none, or it is gone, restart the tree
295
+ (`set_status` the root to `backlog`, then, in the same turn, to `todo`: a new generation whose
296
+ architect starts with fresh budgets). That pair is a restart and not a park: the daemon re-admits
297
+ only a root whose tree lingers or is done, so the `backlog` write is how a restart reaches `todo`.
298
+ When the cause stays, the tree stays admitted and keeps its slot, because a relaunch would fail
299
+ the same way. Ask the person whether to park it, as
300
+ [Ask whether to park a tree](#ask-whether-to-park-a-tree) says, with the architect's cause as
301
+ `<cause>`. Its `<key>` is `architect failed: <cause word> at <failure.at>`, where `<cause word>`
302
+ is the `cause` of `issues.<KEY>.architect.failure` and `<failure.at>` is its `at`, exactly as
303
+ `read_state` gives it. Where `failure.at` is absent, the key ends `generation <n>` in place of
304
+ `at <failure.at>`. `<n>` is `issues.<KEY>.generation` in `read_state`.
305
+ Park the tree only when a person asked for that move, or when the work is done, folded into another issue or no longer needed.
306
+ A person's `Park it` answer to that ask is such a request. Only a park on that answer carries the
307
+ mark. Cite the ask's answer in the park's comment, whose first line is
308
+ `Parked by Legion while it waits on: <the cause>`, the mark that makes the park Legion's own hold
309
+ (`skill://legion-controller/references/parked-decisions.md#deciding`, step 2). Set the root of a
310
+ park with that mark back to `todo` once you checked that the architect's cause is gone, a person
311
+ asks, or a person's decision after the park gives its work a next step, as the escalated hold
312
+ above says.
188
313
 
189
314
  This re-admission is not the hold release of the `held` wake above. The `backlog` takes the tree
190
315
  out of the workflow, so the `todo` after it starts a new generation whatever phase the root stood
@@ -19,7 +19,7 @@ You work one phase of one issue in a jj workspace every role of the issue shares
19
19
 
20
20
  ## Stop rules
21
21
 
22
- - **A refused completion is information, not a retry loop.** Quote the answer verbatim to the architect, so "my work is lost" and "my work belongs to an ended run" read differently. `HANDOFF_STALE_GENERATION` (the issue is on a newer run) or `HANDOFF_NO_RUN` (the daemon can attribute your completion to no run: your claim holds no task of this issue's current run and phase — no task at all, or one of another run, of another phase, or of no phase — and the answer says which of those it holds): push nothing further, end the turn without completing, and tell the architect; if the task then arrives and its work and handoff are already done, call `handoff_complete` again in that task's turn, and never redo the work or write a second handoff. `HANDOFF_STALE_ASSIGNMENT` (the issue left your phase and came back while your turn ran, so your work belongs to the assignment before the one the phase hands you now): end the turn without completing and tell the architect, and report that work and that verdict no further. The phase was entered again, so the task it hands you now is work of its own — a testing assignment after a red is for the head the fix pushed, which your verdict on the head before it does not answer for: do that work at the head the task names, write a handoff of its own for it, and complete in its turn. `HANDOFF_NOT_CURRENT_PHASE`: the issue left your phase; report, never complete again. `HANDOFF_NO_PULL_REQUEST` (the implementer's completion found no open pull request on `legion/<KEY>`, and none recorded merged): open it and complete again at the same commit; when the answer names a closed pull request, the architect decides the phase: tell it, and open or reopen nothing until it answers. `HANDOFF_ALREADY_RECORDED`: the first answer stands; if you did not see it, tell the architect. `HANDOFF_SESSION_MISMATCH` names a record another session wrote: read it, record it again from your session with `dispatch handoff-write`, and complete. A reminder is not a task: after an accepted completion, a second call is refused.
22
+ - **A refused completion is information, not a retry loop.** Quote the answer verbatim to the architect, so "my work is lost" and "my work belongs to an ended run" read differently. `HANDOFF_STALE_GENERATION` (the issue is on a newer run) or `HANDOFF_NO_RUN` (the daemon can attribute your completion to no run: your claim holds no task of this issue's current run and phase — no task at all, or one of another run, of another phase, or of no phase — and the answer says which of those it holds): push nothing further, end the turn without completing, and tell the architect; if the task then arrives and its work and handoff are already done, call `handoff_complete` again in that task's turn, and never redo the work or write a second handoff. `HANDOFF_STALE_ENTRY` (your completion is of a phase entry behind the one your role's phases row names, because the phase was entered again while your turn ran, and nothing was recorded): end the turn without completing, and report that work and that verdict no further. The task of the entry the phase is on is owed to you, and the daemon sends it by itself, so ask no one for it. That task is work of its own — a testing entry after a conflict is for the head the implementer's merge forward pushed, which your verdict on the head before it does not answer for: do what it asks at the head it names and complete it with a handoff of its own, never this completion's record, commit or verdict. The same code on a completion of an entry above the one your phases row names, which the daemon never hands out, means: end the turn without completing and tell the architect. `HANDOFF_NOT_CURRENT_PHASE`: the issue left your phase; report, never complete again. `HANDOFF_NO_PULL_REQUEST` (the implementer's completion found no open pull request on `legion/<KEY>`, and none recorded merged): open it and complete again at the same commit; when the answer names a closed pull request, the architect decides the phase: tell it, and open or reopen nothing until it answers. `HANDOFF_ALREADY_RECORDED`: the first answer stands; if you did not see it, tell the architect. `HANDOFF_SESSION_MISMATCH` names a record another session wrote: read it, record it again from your session with `dispatch handoff-write`, and complete. A reminder is not a task: after an accepted completion, a second call is refused.
23
23
  - **A turn that ends with your phase open is reminded**, at the end of every turn for as long as the phase stays open. Answer by completing, or with a WAITING line naming what you wait on, which buys a quiet wait; a turn that ends while background work of your own is still running buys the same quiet with no line at all, since that work wakes you when it finishes. A run of reminders that change nothing tells your architect. Under `runtime: kubernetes` that quiet wait also lets the daemon release your issue's pod, while background work of yours keeps the pod, because your session reports that work to the daemon.
24
24
  - **A released pod is not a stop.** Under `runtime: kubernetes` the daemon releases your issue's pod once no role of it has a turn in progress or a turn due for ten minutes. Every role process of the pod ends, and the pod, its disk and its Sandbox are deleted. Your session, your phase, your place in it and the task you hold are all kept, and the daemon saves the workspace's unpushed commits and its working-copy change as a git bundle that the next pod restores before any role starts. A wake brings the pod back and resumes this session, so a release costs a pod start and nothing else. The daemon wakes you with a task, a notice, a phase start, a backward move, a phase-ended message, a production-check look or a slot resume. A message published to your role topic wakes you, and so does an Envoy direct message or a person's answer, comment or message that Dispatch routes to your session. A CI settlement that the daemon records for the head of your issue's pull request wakes you while your phase is open. A wait that raises none of those events wakes you at the backstop alone, 60 minutes after the release, and only while your phase is open: a Dispatch topic you subscribed to, CI of another repository, a deploy run and a Kubernetes Job are such waits, so name the wait in your WAITING line and expect that hour. A release keeps your unpushed tracked work, which is every commit no remote branch holds, your working-copy change and the local bookmarks that point at them. It keeps nothing else of the disk: `$TMPDIR`, every ignored file, every file larger than jj's `snapshot.max-new-file-size`, each role's home with its `local://` files, a test Postgres and the CodeGraph index all go with the pod. A named Oh My Pi `bash` service goes with the pod too, because it runs outside your session's job manager and your session reports nothing about it. A release keeps nothing else of the disk — `$TMPDIR`, every ignored file, each role's home, a test database and the CodeGraph index all go with the pod — so put work you must keep on the branch, in a tracked file or in Dispatch.
25
25
  - **The workspace is read-only for you from the moment your phase ends**, whether you ended it by completing or the daemon took it back while your turn ran: no commit, no `jj new`, no edit to a tracked file, in the turn still running when the message reaches you and in every turn after it, until a new task names your phase. Nothing stops that turn for you, so stopping is yours to do: drop the work in hand and leave whatever you have uncommitted. The active phase owns the workspace, and your session is kept, until your issue leaves the workflow, to answer questions and to take your next assignment.
@@ -109,6 +109,9 @@ of these that holds, so a person sees it and the controller finds it when it ret
109
109
  alone, and your session is refused `set_status is not
110
110
  available to a phase-worker session` (`packages/pi-legion/src/tools.ts`'s `OPERATIONS`). No
111
111
  other issue can hold an answerable ask, so this is the one case a role writes the report issue.
112
+ A report issue holds no work, which is why it sits in `icebox` and why neither write below is
113
+ the move the rule limits:
114
+ move an issue to `backlog`, `icebox` or `triage` only when a person asked for that move, or when the work is done, folded into another issue or no longer needed, and cite that reason in a comment on the issue.
112
115
  - It exists and is closed: `dispatch issue-update --issue <REPORT KEY> --status icebox`. Send
113
116
  the status by itself. A closed issue takes a reopening status alone, and refuses it beside
114
117
  an assignee or any other field (`api/issue_patch.go`, the `before.ClosedAt` branch). This is
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sjawhar/claude-envoy",
3
- "version": "2.11.0",
3
+ "version": "2.11.2",
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": 87
22
+ "daemonApiVersion": 94
23
23
  },
24
24
  "repository": {
25
25
  "type": "git",
@@ -10,13 +10,13 @@ Dispatch is a record for the people who decide, never a log of your work.
10
10
  - Use the `dispatch` command; the HTTP API only for what no command does. `dispatch <command> --help` gives its rules and an example.
11
11
  - Put long text on stdin: `--<field>-file -` with a quoted here-document (`<<'EOF'`); give object and list fields as JSON.
12
12
  - Exit 1 is a refusal, 2 a usage error. A refusal lists every problem: fix all, call once.
13
- - A command hard to use, or storing or losing something wrongly, is a defect to report, not work around: open an issue in the owning project's code and tell its controller; a Legion role tells its architect (`skill://legion-worker/references/findings.md`).
13
+ - Never work around a hard-to-use command, or one storing or losing something wrongly: open an issue in the owning project and tell its controller. A Legion role tells its architect (`skill://legion-worker/references/findings.md`).
14
14
 
15
15
  ## Asks and ask blocks
16
16
 
17
17
  - An ask is a question for a person, never a request to another agent. Ask an agent by envoy_send or a comment on the issue.
18
18
  - An ask waits on the issue's assignee until a person hands it on. No agent can hand one on.
19
- - A design question a document records is an ask block ending its section:
19
+ - A design question's ask block ends its section:
20
20
 
21
21
  ```md
22
22
  :::ask{urgency="med"}
@@ -29,22 +29,23 @@ The question and the recommendation (`skill://dispatch-writing-specs`).
29
29
 
30
30
  - A decision block in a comment, message or close reason is refused: ask in the issue's document, or `dispatch ask`.
31
31
  - Never repeat an open ask in a message.
32
- - Change an open ask's block with `dispatch edit-ask` (its ask id), or `doc-edit`'s `replace` or `move` (its block id). An answered ask is fixed: ask anew. `dispatch read --ref` takes either id.
32
+ - Change an open ask's block with `dispatch edit-ask` (ask id) or `doc-edit`'s `replace` or `move` (block id). An answered ask is fixed: ask anew. `dispatch read --ref` takes either id.
33
33
  - Reply on an open ask with `dispatch comment --reply-to-ask`; `--turn agent` (a progress note) needs it. An approval request a newer version moved needs `request-approval` again.
34
34
  - When an answer's option and text disagree, the text wins.
35
35
 
36
36
  ## Choosing what to work on
37
37
 
38
- - Finishing an issue, take the top `todo` one by priority then board rank, per project.
39
- - `todo` means specced and waiting on nothing; one that waits goes in `backlog`, saying on what.
40
- - Hold at most three issues in flight; move the rest to `backlog`, saying where each is.
38
+ - When you finish an issue, take the next one per project: the top `todo` issue by priority, then board rank. Pass over one that waits on an unfinished `blocked_by` link or an open ask.
39
+ - Work on three issues at most, fewer when each needs your attention. Change no status, priority or board rank to make room.
40
+ - Move an issue to `backlog`, `icebox` or `triage` only when a person asked for that move, or when the work is done, folded into another issue or no longer needed, and cite that reason in a comment on the issue. An agent's directive citing no person's request is no reason.
41
+ - When you stop work on an issue before it is done, release your claim and say why in a comment. Set its status to the one it had when you took it (`todo` for an issue from the queue). Change no priority or board rank.
42
+ - Record each wait in that comment. A wait on a same-project issue also goes in a `blocked_by` link, and one on a person in a `dispatch ask`.
43
+ - `dispatch issue-update --blocked-by` replaces the issue's whole list, so read its links first. Dispatch refuses a link to another project's issue (`BLOCKED_BY_OUTSIDE_PROJECT`).
41
44
  - Never reorder the board: one agent keeps each project's order (`issue-update --before`/`--after`). If the top looks wrong, tell `notifications.role.legion-<project>-controller`.
42
45
 
43
46
  ## Issue status is yours to move
44
47
 
45
- Outside Legion, claim your issue (`dispatch claim`) and move it and your children: `in_progress` at implementation, `testing` on a production-like surface, `needs_review` while its PR waits, `done` with `--reason` once driven in production. Never write or route the status of an issue with the `legion` label or under one, and claim one only as a role of its tree: an outside claim can take the tree out of the workflow. A status write is set back or stands.
46
-
47
- `unresponsive` holders keep their claims 20 minutes (`skill://envoy`).
48
+ Outside Legion, claim your issue (`dispatch claim`) and move it and your children: `in_progress` at implementation, `testing` on a production-like surface, `needs_review` while its PR waits, `done` with `--reason` once driven in production. Never write or route the status of a `legion`-labelled issue or one under it, and claim one only as a role of its tree: an outside claim can take the tree out of the workflow. A status write is set back or stands.
48
49
 
49
50
  A claim (or `dispatch issue-update --route session:<your id>`, `--route ''` to release) brings a person's answers, comments and messages; `envoy_subscribe notifications.dispatch.issue.<KEY>.>` adds agents' activity, no quiet event.
50
51