@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,48 +1,56 @@
1
- ## Wake routing
1
+ # Wake routing
2
2
 
3
- Handle one delivered wake by verifying the relevant live artifact and then performing the
4
- corresponding lifecycle procedure. An architect-addressed wake reaches the architect that owns its
5
- issue: the issue's own architect while it holds its role (the daemon starts a child's with the
6
- child's first phase), else the nearest architect above that holds its role, then the root's. A
7
- `catch-up` reaches only the architect of its own issue. A `child-status` or `child-closed` of a
8
- child, and a `worker-died` or `worker-stalled` about a child's own architect, reach the architect
9
- above the child. `phase-finished`, worker lifecycle, child lifecycle, and design-gate wakes are
10
- architect-only and never go to an active phase worker. Where a row below tells you to ask a
11
- person, a child's own architect sends the question to the architect above it instead
12
- (`skill://legion-architect`, "Every turn").
3
+ Read this when a wake reaches you. A wake about an issue reaches its own architect while that
4
+ architect holds its role, else the nearest one above that does. A `child-status` or `child-closed`,
5
+ and a `worker-died` or `worker-stalled` about a child's own architect, reach the architect above the
6
+ child. Your role prompt describes each notice; this table says what to do. "Section N" is that
7
+ section of `skill://legion-architect`. Where a row says to ask a person, a child's own architect
8
+ sends the question to the architect above it.
13
9
 
14
- A "section N" below is that section of `skill://legion-architect`. The spec and gate steps of
15
- section 1 are in `skill://legion-architect/references/design-gate.md`; the detail of sections 3, 6
16
- and 7 (a conflict, the hand-over, the close) is in
17
- `skill://legion-architect/references/acceptance.md`.
18
-
19
- | Wake | Procedure |
10
+ | Wake | What to do |
20
11
  | --- | --- |
21
- | `carried-gate-opened` | Only a root whose catch-up said `carried` gets it. Its `version` and `reason`: a human approved the old root's spec document at `version`, which opened the gate this root carried; the daemon has started any child waiting on it. It names no step: the carry brings the old root's gate records, and the catch-up reports every gated step the carry did not bring as unregistered, so register each of those on this issue's own document for that step (`skill://legion-architect/references/design-gate.md`). It is not `design-approved`: do not proceed to section 2 or release a wave because of it, and start nothing. |
22
- | `catch-up` | The daemon sends it at each launch of your session, once that session is ready, to the architect of its own issue alone. A root's catch-up names its tree: the generation, each design-gate step (`gates`), and every issue of the tree with its phase and status. A child architect's catch-up names its own issue and every issue under it, with phase and status, and no gate: a child registers none. Either one names in its `reason`, as waiting for your acceptance, only the issues in `accepting` whose acceptance is yours. Accept each one as section 6 says, a parent only after its last round ("The last round" in `skill://legion-architect/references/acceptance.md`). Otherwise, start or resume your work from it as your role prompt says. |
23
- | `child-status` | A child of your tree left the workflow or re-entered it, or joined your tree from the admission queue or from a closed tree; the reason names the child and its new status, or reads `<KEY> joined the tree of <ROOT> from the admission queue`, or, for a member of a closed tree your release took, `<KEY> joined the tree of <ROOT> from the closed tree of <OLD ROOT>`. A reason that says a child starts planning comes at the child's first phase, and it also says that the child's own architect starts with it. From then on that architect owns the child while it holds its role: its decomposition, its children and its acceptance. While that architect holds its role, you hear only the child's `child-status` and `child-closed`, and its architect's `worker-died` and `worker-stalled`. The child's other notices come to you too while that architect does not hold its role, which the daemon's `holdsRole` decides. `todo` (a human's move, your `release_children`, or your `rerun_child`) means it runs again under your tree from planning, and the daemon starts it; you start nothing. A child held for a blocker starts the same way once nothing holds it, and the reason, naming it and its root, says what cleared the hold: its last blocker's close, naming the issues it waited on, now done, or a person or you taking its blocked-by links off; you start nothing for it either. `backlog`, `icebox` or `triage` (a human's move, or your `park_child`) means the child stopped as workflow's `leave` decides, and it advances no further until it is set back to `todo`. The child's next start resumes its architect's session, and that architect starts in a new session only once supervise's `forgetSession` has dropped that one. A `park_child` and then a `rerun_child` is that child's restart and not a park, because the daemon refuses `rerun_child` on a child whose phase is not `done` (`CHILD_RUNNING`, `packages/daemon/internal/api/architect.go`). Joined from the admission queue means a root that waited for a slot and never ran, which a person made a child of your tree or your `release_children` adopted, now runs in your tree as a child, from planning when it is `todo` and parked otherwise. It takes an admission slot of its own when its work starts, and its own architect starts with its first phase. One that waits on an unfinished blocked-by issue is held for that blocker like any other child, and starts when nothing holds it. You start nothing. A reason saying an issue is beneath an ancestor whose reviewed head the daemon has already accepted is a person's `todo` the daemon recorded and holds at `admitted`: nothing starts it until that ancestor closes, and a `request_backward_move` of the ancestor is what runs it under the ancestor now. What the other issues you own do is your decision. When a park leaves no child that an issue in `accepting` waits on, run that issue's last round (`skill://legion-architect/references/acceptance.md`). |
24
- | `child-closed` | Read the child completion and remaining open children. Re-scope open work, and take out with `park_child` each child the result makes unneeded (first take its link off each sibling that waits on it, or park that sibling too when its work ends with the parked child, under the same rule, as section 2 says) and say why with `dispatch comment`. Park a child only when a person asked for that move, or when the work is done, folded into another issue or no longer needed. Then file any new child the result calls for, after the red-team check in `skill://legion-architect/references/decomposition.md`, and release it at once with `release_children`, blocked by what it builds on (section 2). When a worker waits on this child for a missing surface (see `phase-finished`), tell it to continue with `envoy_publish` to its role topic. The last child's close is not the end-game (section 3). When it was the last child an issue in `accepting` waits on, run that issue's last round (`skill://legion-architect/references/acceptance.md`). |
25
- | `child-release-stalled` | Its `reason` names a child that a `release_children` released and your tree has not recorded, its parent, and why, one of three: the parent's release has not reached the daemon after three tries; or GitHub did not answer the App installation read, or the default-branch read past GitHub's rate limit, of a repository on the child's parent chain, and the release left the child unrecorded because a parent on that chain is not `todo`, or did not write the child `todo` because its parent is not recorded; or the daemon's recovery of such a repository, once GitHub answered, still left children unrecorded. The first two come to the architect whose `release_children` it was. The recovery's notice goes, whoever ran the release, to the architect that owns each child's parent where your tree records that parent, and to the tree root's architect for the rest: a notice on each recorded parent lists that parent's children, and one on the tree root lists the rest, each with its parent. Read the parent's record with the `legion` tool's `read_record` (`issue` the parent); release the parent first when the `reason` says to, then run `release_children` for the child again once the parent is recorded in your tree, and tell the controller if it never is. |
26
- | `child-not-recorded` | Its `reason` names a child your tree did not record and why: its repository resolves to none (neither it nor an ancestor names one, and the project has no default), or a role GitHub App is not installed on that repository, which the reason names. The daemon said why on the child too. Set the child's repository (`dispatch issue-update --repo owner/name`), or get the named App installed on the repository it has, then release it again with `release_children`. Tell the controller when neither is yours to do. |
27
- | `children-first` | An issue of your tree at `admitted` starts no phase of its own while Dispatch shows an open child under it, a child you filed and have not released included. The reason names the parent and each open child with the Dispatch status that holds it, and each cycle it found (a child `blocked_by` an issue above it on its own parent chain, which only a person taking that link off ends: open a `dispatch ask`). It comes once per issue and run of its tree. Release every child that should run. Park a child 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 child. A released child, a held one included, stays under the parent, because the parent's wait ends when that child leaves the workflow. Move out from under the parent only a child you have not released and that should not run now. Move it under another issue you own (section 3 says which) that has started a phase and has not reached `accepting`, and never under an issue it waits on: that move ends this wait and leaves the child in the tree (section 3). After the move, ask the person on the root (`dispatch ask`) when that child's work should run or stop: release it when they say to run it; when they say to stop it, close it, or move it to `icebox` under the rule when they say its work should wait, citing their answer. Until they answer, sign off neither the issue you moved it under nor any issue above it that you accept. Never give such a child the `legion` label, and never clear its parent while the tree is live, because such a child would then run nowhere (section 3). Where you own no issue to move the child under, ask the person. A child's architect sends each of these questions to the architect above it, as "Every turn" in `skill://legion-architect` says. The parent's first phase can start once the last open child has left the workflow; a parent the daemon has already started gives its admission slot back while it waits for its children, and takes one again by itself; nothing of its work stops meanwhile, and you do nothing for it (https://cybermonklabs.github.io/legion/legion/concepts/#admission-and-the-legion-label, which also names the three roots that keep their slot through a wait); a parent the daemon has not started waits in the line for a slot. You start nothing. |
28
- | `design-approved` | Its `version` is the approved one, and it names no step: under more than one gated step, read `gatedSteps` in your own record (the `legion` tool's `read_record`) to see which step that version opened and whether another still holds the tree. A human approved the document of one gated step at its current version; that step is open. Proceed to section 2 once every gated step is `approved` — except on a root whose catch-up said `handed_over`: its workers already run their phases, so start nothing. One whose `version` is the version a human's own answer to a decision block wrote, after an earlier approval (Dispatch carried that approval to it, "After approval" in `skill://legion-architect/references/design-gate.md`), opens nothing new: carry on, and release no wave because of it. A root that was waiting on a question in `awaiting_person` gets no such notice: the task that resumes it says "Your spec is approved at version N and the design gate is open: this resume is your design-approved wake", and that resume is this wake — proceed to section 2 on it. |
29
- | `design-changes-requested` | Its `version` and `reason`, and no step: under more than one gated step, read `gatedSteps` in your own record (the `legion` tool's `read_record`) and take the step whose `status` is `changes_requested`. A human asked for changes to that step's document at `version`, for `reason`. Revise that document as the reason asks and request approval again as "The armed gate" in `skill://legion-architect/references/design-gate.md` says; end your turn; that step is closed. On a root that was waiting on a question in `awaiting_person`, a review the human gave after the wait began comes in the resume task, not in this notice, whether it answered the wait or came after something else did: the task names the review with its version and reason, unless a later approval superseded it. A `version` below the latest, or a second request for one version, is a request that reached the daemon late: read it as the same section's last paragraph says. Each request arrives once. |
30
- | `phase-finished` | The daemon has already moved the issue to its next phase by its fixed table and started that phase's role; you start nothing. Read the finishing phase's handoff on the Dispatch issue (`dispatch handoff-read --issue <issue> --phase <word>`); if it shows unresolved gaps, tell the role now working the issue (`envoy_publish` to its role topic). A `planner` notice that names a departure from the spec's design defers to the full condition in "After approval" of `skill://legion-architect/references/design-gate.md`: when the approved Summary, the requirements, the checks, the scope and the settled decisions still hold, the plan is the record; otherwise change the root spec and request approval again as that section says. On a child, read the same condition against the child's spec at the version its parent's review approved. When it does not hold, write a new version of the child's spec and have the architect above review it (`skill://legion-architect/references/decomposition.md`, "Reviewing a child's spec"). A `reviewer` notice whose GitHub review is `CHANGES_REQUESTED` needs nothing from you: the daemon has returned the issue to `implementing` (Dispatch `in_progress`) and started the **implementer**, whose correction goes through the tester and the reviewer again, never straight to retro. A `reviewer` notice with an `APPROVED` review means the issue is in `accepting` and the acceptance is yours (section 6): read the evidence, then `sign_off` (a parent only after its last round, "The last round" in `skill://legion-architect/references/acceptance.md`) or send it back with `request_backward_move`. A `tester` notice with `verdict: "fail"` — its handoff carries `implementerProof.verdict: "rejected"`, or a failure naming a check with no pass standing at the head — has gone back to the **implementer** by the daemon's table; never record that check's result from another role. A worker that reports no surface reaches the changed path sends that report instead of completing its phase, so the daemon starts nothing more on that issue and the worker stays idle in its session, not suspended: build the surface in this tree: a child issue (infrastructure, tooling, or a skill) after the red-team check in `skill://legion-architect/references/decomposition.md`, or, when the red team folds it, tell the waiting worker to move the issue back to `implementing` with `request_backward_move`, naming the surface. When it is a child, tell the waiting worker to continue with `envoy_publish` to its role topic once that child's `child-closed` arrives. That report is never a reason to advance the phase. |
31
- | `pr-blocked` | Its `reason` reads `Issue reached review_round_cap=<N>: <n> rounds counted, <m> conflict rounds not counted.`, the implementer's round count: every move back to an earlier phase counts one, and a move made while the head conflicts with its base counts as a conflict round the cap leaves out; the notice comes once for each value the cap holds, so the rounds past the cap tell you nothing again, a cap raised in `legion.yaml` tells again at its new number, a lowered one tells once on the next counted round, and a new generation tells again from its own first crossing. It moves nothing, since the round that reached the cap has already started its worker. Tell the rounds apart by what announced each: a tester's fail by its `phase-finished` with `verdict: "fail"`; a request for changes by the reviewer's `phase-finished` over a `CHANGES_REQUESTED` review; a worker's `request_backward_move` by a `phase-finished` from the role that asked, whose reason reaches only the task of the worker the move started, so ask that worker; your own send-back from `accepting` by the reason you gave. A `checks-red` notice announces no round: the daemon kept the issue in its phase and asked the implementer to merge the base forward. The message's `<n> rounds counted` has already left the conflict rounds out, so judge the cap by it. Conflict rounds need nothing from you beyond the next round. Tester fails and requests for changes are the rounds the cap is for; a red check moves nothing and is told to nobody as a notice, so it is no round at all. Each `review_round_cap` notice is a decision you make in the turn it wakes, never one left for the next round to make: read what every counted round found, choose one of the three below, act on it in the same turn, and post it as a `dispatch comment` on the issue naming the rounds you read and the choice. **Narrow**: the change itself is sound but each round finds more around it; tell the implementer and the reviewer (`envoy_publish` to each one's role topic) which checks the next round answers, dropping no requirement; a correctness finding is still fixed in this pull request, and so is a wording nit or any clear fix in a file it touches, so the `Fast-follow:` line carries only cleanup in files it does not touch. **Split**: part of the work cannot settle in this pull request and is a separately deliverable change (`skill://legion-architect`, section 1). On a child, that part becomes a child of this issue's parent, never of this one (this issue closes at its own merge, and the split part usually builds on this pull request's unmerged code). The architect that owns the parent files it. When you are this child's own architect, send the part to the architect above you with `envoy_publish`, since `release_children` refuses an issue outside your own (`ISSUE_NOT_OWNED`). The parent's architect runs the red-team check in `skill://legion-architect/references/decomposition.md`, then files the part: `dispatch issue --project <project> --parent <parent> --title '<outcome>' --blocked-by <this issue> --spec-file -`. It releases the part now with `release_children`: Legion holds it on that `--blocked-by` link until this issue closes, and starts it then. A requirement moves only to that released child. On the root, open a `dispatch ask` for the part that cannot settle here (`skill://legion-worker/references/findings.md`): it stays this issue's requirement, and this pull request carries it, until the person who answers that ask records that the issue will not deliver it. **Accept the rounds**: each round found less than the one before it, and the last found no defect in the change itself (a stale line, a comment that states an old default); let the loop run and say why in the comment. A later notice is a new decision: accept again only when its round found less than the round you last accepted, and otherwise narrow or split. On the root, a finding that changes what the spec requires or what a check proves is a decision block in the root spec ("After approval" in `skill://legion-architect/references/design-gate.md`). On a child, it is a new version of the child's spec, which the architect above the child reviews, and a decision only a person can make goes to the architect above. Neither that spec change nor a `dispatch ask`, which is only for a decision that needs a human's authority, replaces the choice. Judge a worker's backward move by the reason that worker gives. A move that sends back code found wrong counts with the tester fails. |
32
- | `pr-merged` | The pull request merged and the issue did not close; its `reason` says why. Merged before the issue reached `merging`: the workflow runs on, and the merge closes the issue the moment it gets there, your acceptance and retro first. Merged while issues beneath it still run: the reason names the pull request and every issue the close waits for (those beneath it still in the workflow: on a root, every other issue of its tree), and the issue stays in `merging` with its workers kept, until the last of them is done or parked ("The close" in `skill://legion-architect/references/acceptance.md`). Either way you start nothing and no further notice follows. |
33
- | `pr-closed-unmerged` | Decide from current scope whether the work is reopened, started over (for a child, `park_child` and then `rerun_child`, which is that child's restart and not a park, because the daemon refuses `rerun_child` on a child whose phase is not `done`: `CHILD_RUNNING`, `packages/daemon/internal/api/architect.go`), or ended with a reason. A child's own architect cannot park or rerun its own issue (`ISSUE_NOT_OWNED`), so it sends a restart of its issue to the architect above it. Delegate the repository action to the responsible phase worker and keep ownership. |
34
- | `pull-request-missing` | Its `reason` names the issue, the repository, the branch and the handoff commit: the issue's implementer completed at that commit and GitHub lists no open pull request on the branch, so the issue stays in `implementing`. Tell the implementer (`envoy_publish` to its role topic) to open the pull request from that branch; the daemon records it and moves the issue to `testing` once it is open. When the work should not go on, decide as the `pr-closed-unmerged` row says. It comes once per handoff commit. |
35
- | `review-stuck` | A review round the daemon cannot end on its own, in one of three ways: no review decides the round, the approval is of code the current head may not carry, or GitHub will not merge the head. The `review-stuck` paragraphs of your own role prompt give each one, its `topic` and what answers it. The third carries no `topic`. Its remedy, the close and the reopen at the same head, is for one named case only, and your role prompt gives the sort and the remedy's test in full; this row is their summary. Read what the base requires as `skill://legion-worker/references/merge-gate.md` reads it, rulesets and branch protection both, where a `code_scanning` rule requires an analysis no status-check list names. Read what the head carries in two lists, every page: its check runs (counted by `gh api repos/<owner>/<repo>/commits/<head>/check-runs --jq .total_count` and listed by `gh api --paginate 'repos/<owner>/<repo>/commits/<head>/check-runs?per_page=100' --jq '.check_runs[] | [.name, .status, .conclusion] | @tsv'`) and its commit statuses (`gh api --paginate 'repos/<owner>/<repo>/commits/<head>/status?per_page=100' --jq '.statuses[] | [.context, .state] | @tsv'`), since a commit status is no check run. A required item in either list is reported, and a check run whose status is `queued`, `requested`, `waiting`, `pending` or `in_progress`, or a commit status whose state is `pending`, is running, not missing, and a check run concluded `failure`, `timed_out`, `cancelled` or `startup_failure`, or a status in state `failure` or `error`, is red; never read the status endpoint's top-level `state`, which reads `pending` with no status at all. A required item in neither list falls in a named case: a fork pull request whose runs wait for a maintainer's approval (`action_required`), a check only a commit status would report, and a workflow another repository defines each take a person through a `dispatch ask`; a required workflow whose own path filter skips every file of the change gets no run, and a reopen sends the same event, so while the base still carries that filter the head takes a change to the workflow or to the head, and once the base has dropped it the head is the remedy's own case. The remedy's own case is a required workflow no event started on a pull request already open, and its test is the role prompt's: not a fork and no run `action_required`; a workflow file, as the merge commit holds it, has a job reporting the required item whose `on:` runs it for `pull_request` with no `types`, `branches` or path filter that excludes this change; and neither list holds a run of it. Such a head takes the reopen. A head that matches none of the named cases takes a person through a `dispatch ask`, never the reopen, since GitHub has more cases than these; so does a head whose required item still has no run once every run the reopen started has concluded. Close the pull request, wait a minute, and reopen it at the same head, since in cybermonklabs/legion a quicker reopen can have its CI run cancelled by the close's own run and leave `ci-ok` failing (`tests-closed.yaml`); tell the reviewer on its role topic to do it, since a repository action is the phase worker's. It costs two things: the close writes a `pr-closed-unmerged` notice, which is this close and ends no work, and the reopen starts the head's other checks again. It is for no other state: not a check that is running, not a check that is red, and not a head GitHub holds for a review the repository requires. A round whose head has no settled run gets no `review-stuck` notice of any kind, so read it in your own record with the `legion` tool's `read_record`, where the issue's `mergeWait` names the head: its `checkRuns` counts only the runs a CI settlement applied, so 0 there is no evidence of what GitHub holds, and you read the head's two lists before you act. A run still running there is waited for; for a GitHub Actions job GitHub ends the wait itself (24 hours queued on a self-hosted runner, `timeout-minutes` or 6 hours hosted and 5 days self-hosted running, 35 days for a whole workflow run), whose settlement moves the round, a `waiting` run waits on a person's approval of an environment, up to 30 days, and another App's check run, one a workflow created through the API and a `pending` commit status have no such bound and go to a person once they stand longer than their CI usually takes. Every run concluded while `checkRuns` stays 0 is a settlement not yet arrived, which Dispatch's CI reconcile pass repairs where it runs, a pass every 5 minutes reaching each head within a cycle of passes, so read the record again after a few passes; a head still at 0 then is sorted as above: a red required check is `request_backward_move` to `implementing`, a required item with no run takes the reopen only when the test matches, and every other head takes a person. A conflicting head waits in `mergeWait` only until two reads a minute apart confirm the conflict: an approval of a head with a confirmed conflict then ends the round, and once the issue enters `accepting` the daemon asks the implementer to merge the base forward and tells you with a `checks-red` notice. |
36
- | `message-refused` | Dispatch refused a write the daemon was making on an issue of your tree, the way it would refuse every attempt, so the daemon makes it no more. A close reason is held to Dispatch's bound at the call that carries it (`close_root` answers `CLOSE_REASON_TOO_LONG`, naming the bound and how far over the text is), so this is a refusal that check did not predict. Read its `reason`: on a status write the daemon writes the status all the same, so the status is set unless Dispatch refused the status itself, which the reason says — with the status set, only the reason beside it is on no issue, and you post what a person still needs yourself; with the status refused, the issue keeps the status it had while the daemon's own record reads the one the write carried, a disagreement no retry of the daemon's closes, so ask a person with `dispatch ask` to set it. On a message write nothing of what it carried reached the issue, and the `reason` gives its length and its first line, so post what a person needs yourself. |
37
- | A reply on an ask you follow | Interpret the reply in the issue's design context. Answer in its thread (`dispatch comment --reply-to <comment id>`; under an open ask whose next move is yours, such as the approval request you must revise or hand back, `--reply-to-ask <ask id> --turn agent`, since a default-turn reply hands that request back to the human and a corrected `--summary` is then refused) where the reply carries a question, a disagreement, a correction or a fact you do not have, and whenever you are unsure; an approval, or an answer that settles the question with nothing left to say, draws no comment and no message back to the person who answered. Then adjust the plan or relay the reply via `envoy_publish` to the responsible worker's role token, which an answer needing nothing from you still needs; scope and product decisions remain with you. |
38
- | `worker-died` | Its `role` and `phase`. That role's claim failed: its launches or prompts ran out, or its provider refused every turn of its session (its `failure.detail` reads `the provider refused <n> turns in a row: <message>`), or its system prompt is too large for its pod's start frame (a `launch_refused` with no count at its limit, whose `detail` names the role, the size and the limit: only a shorter prompt starts it, so a `retry` before the prompt is cut fails again at once; `escalate` it). For a phase worker the daemon holds the issue (phase `held`) and starts nothing more on it. A `worker-died` whose `role` is `architect` on a child is about that child's own architect, and it reaches you as the architect above it. Nothing is held, so there is nothing to `retry_or_escalate`. Its `reason` says that the child's notices come to you until that architect runs again, and that the daemon starts it again, with fresh budgets, at the child's next phase start. A re-admission of your tree while the child stands in a phase, or an operator's retry, starts it again too. Meanwhile, act as section 2 says, and accept the child yourself if it reaches `accepting` (section 6). It carries `failure` as well (the notice of a held phase, and that of a role which does not work the issue's phase; the one that ends a closed issue's production-check look carries neither `failure` nor `phase`, its `reason` naming the cause already): `cause`, one cause word of the seven the daemon chooses from (`launch_refused`, `died`, `never_registered`, `stale_plugin`, `prompt_retires_exhausted`, `provider_error`, and `unrecorded` for a failure recorded before the daemon kept a cause), `detail`, the sentence written beside that word, `death` and `startFailure`, what the runtime and the launcher last said of this claim where it recorded either, and `launchFailures`, `deaths`, `promptFailures` and `promptRetires`, each a `count` beside the `limit` it ran out at. The claim's record in `read_record` carries the same `failure`, and the issue's `heldFrom` names the phase the hold took it out of. Reassess the work, then decide with `retry_or_escalate`: `retry` when the failure looks agent-specific or transient, `escalate` to hand the held issue to the controller when it looks environmental. `reason` is optional on either decision: a `retry`'s reaches the restarted worker's task, so say in it what you changed or what you want done differently, and an `escalate`'s reaches the controller as the `escalation` key of the `held` notice that records it, so say in it why the tree cannot go on without a decision of the controller's. A `retry` of a claim that failed on refusals starts a **new session**, since resuming the one the provider refused would be refused again: that worker has read none of its own earlier work, and is told so in its first task, which names its branch and the handoffs to read. Expect it to re-read before it continues, and tell it anything only you know. |
39
- | `worker-stalled` | Its `role` and `reason`. The daemon's stall backstop acted on that worker's stalled turn: its agent had not stepped for longer than the `worker_stall_backstop_hours` this deployment gives the role, and most often the daemon ended the turn and brought the same session back on a new process. The `reason` is the record the daemon read — when the agent last stepped and how long ago that was, the bound it passed, when the turn began, and the last call the daemon saw, with its tool, its call id, when it started and whether it ended — and never a call's arguments, whose text the daemon keeps in no column. It says what the daemon did as well, which is not always a relaunch: where the daemon's wake pacing parked the replacement, the task was taken back and the launch that replaces the stalled process is queued, due at the moment the notice names, and that process runs on until the launch's turn, which may start nothing — a suspension waiting for the claim, a refused lifecycle recheck or the tree's close can end the claim there instead; where a suspension was already waiting for that turn, that suspension ran instead of a replacement and the claim is suspended with nothing queued for it, waiting on a resume; where the launch that replaces the process could not be written, the daemon is still retrying that launch; and where every try at that launch was refused, the claim has failed, and the `worker-died` that comes with it is yours to answer as that row says. It says what became of the stalled process too, for every end but the parked one: that it was stopped, or that the runtime did not confirm the stop, in which case that process may be running still and holding what it runs on — tell the controller of that one, because the daemon stops it again only at its next launch of that claim or at its next restart. No second notice follows any of these unless the daemon restarts while a relaunch is parked, which decides the claim again. The task that worker was serving is still owed to it, and what its return waits on is the one the notice names — the parked launch's turn, the retried launch, or a resume; the stall itself charged the claim nothing, and no phase moved: on every end but the failed one the phase goes on by itself and you start nothing. Your part is to read what the record says the agent was doing and to judge whether that work needs a decision of yours — a call that hung on something the plan did not foresee is one, a turn that comes back and finishes is not. A stall of a root architect's own session reaches that architect the same way, on its own issue, and the controller is told of it too. A stall of a child's own architect reaches the architect above it. |
40
- | `worker-silent` | Its `role` and `reason`. That worker stopped between turns rather than inside one: its process is up, it holds no task, and its agent has not stepped for longer than the `worker_silence_minutes` this deployment sets, so nothing in the daemon and nothing in that process was going to prompt it again. The `reason` is the record the daemon read — the issue, the role, the phase, when the agent last stepped and how long ago that was — and it ends with what the daemon wrote about it, read from the phase entry the role's phase row names: the start row that sends the work of that entry, where the worker's claim was never given it, or the start row that sends the phase's task again, where the claim is on that entry already, naming the entry where the row holds one. That row is written and the worker is coming back with that work: read the issue's record with the `legion` tool's `read_record` to see where the phase stands, and start nothing yourself. The one thing that still refuses the start is a suspension an operator holds over the claim, which the outbox reads when it runs the row and which the `reason` names: ask the operator to resume that claim, and message the role on its topic (`envoy_publish`) where its phase cannot wait. It comes once for each silence, and a worker that takes a step and then goes quiet again is told again. |
41
- | `worker-background-stalled` | Its `role` and `reason`. That worker's own session reports background work of its own — an async job, a subagent, a background task — still running, and it has reported the same thing without change for longer than the `worker_background_hours` this deployment sets. The `reason` is the record the daemon read: the issue, the role, the phase, the kinds the session named, when it last reported them and how long ago that was. Nothing was sent to that worker and nothing will be sent for this: the daemon cannot tell a job that hung from a long one, so it names the worker to you and decides nothing. Your part is to read what the session says it is waiting on and to judge whether that work needs a decision of its own — a job waiting on a surface that does not exist, or on a person, is one; a long build or a long test run is not. Read the issue's record with the `legion` tool's `read_record` for where the phase stands, then either leave the work to finish or message the role on its topic (`envoy_publish`) with what you decide. The worker is not prompted by the silence repair while it reports such work, so nothing else is coming for it either. It comes once for each standing report: a worker whose reported work changes — a job that ends and another that starts — is told of again under the new report. |
42
- | `held` | Its `role` and `phase` (the phase the issue left), or `phase` with `reason: "escalated"`. Without `reason`, that phase's worker ran out of launches or prompts: the issue is held (phase `held`), the notice carries the same `failure` record as the `worker-died` that comes with it, which is yours to answer with `retry_or_escalate` as that row says, and the controller hears of the hold too. With `reason: "escalated"`, it records your own `escalate`: the controller has the issue now, it carries no `failure`, and you start nothing for it. It carries `escalation` instead, your own `reason` from that `escalate`, and carries none where you named none: the controller reads it as your account of why the issue is its, beside the cause word in the claim's own `failure` record, so say in it what the tree cannot go on without. Your `retry` is not the only release: a `todo` written on a held root releases the hold the same way and at the same price of nothing, whoever writes it, so an issue you left held may be working that phase again when you next read it. |
12
+ | `catch-up` | Start or resume from it as your role prompt says. Accept each issue its `reason` names as waiting for you (section 6), a parent only after its last round. |
13
+ | `design-approved` | One gated step opened; `gatedSteps` in `read_record` says which. Once every step is `approved`, release the children (section 2). A task saying "this resume is your design-approved wake" is this wake. On a `handed_over` root, or a version a person's answer to a decision block wrote, start nothing. |
14
+ | `design-changes-requested` | Revise the document of the step whose `status` is `changes_requested` as the reason asks, then request approval again ("The armed gate" in `skill://legion-architect/references/design-gate.md`) and end your turn. One for an older version came late: answer its reason if the latest version does not. |
15
+ | `carried-gate-opened` | The gate this root carried opened. Start nothing and release nothing for it. |
16
+ | `phase-finished` | The next phase already started. Read the finished handoff (`dispatch handoff-read --issue <issue> --phase <word>`) and tell the working role of any gap. A planner's departure from the design: keep the plan while the Summary, requirements, checks, scope and settled decisions hold, else change the spec ("After approval" in design-gate.md). A reviewer's `APPROVED`: section 6. A worker reporting that no surface reaches the changed path: build the surface in this tree, then tell it to continue. |
17
+ | `pr-blocked` | The review round cap is reached: decide in this turn, as "A capped pull request" below says. |
18
+ | `checks-red` | The daemon asked the implementer to merge the base forward; the issue stays in the phase the notice names. Start nothing; in `accepting`, wait for the reviewer's approval of the new head ("A conflicting head" in `skill://legion-architect/references/acceptance.md`). |
19
+ | `review-stuck` | No review decides the round, or the approval is of other code: tell the reviewer on the notice's `topic` to approve the head or request changes; ask a person when it answers again with no review. GitHub will not merge the head: no `topic`, and its `reason` names the merge state, each check run with its conclusion and each commit status with its state; sort it as your role prompt says. |
20
+ | `pr-merged` | Merged, not closed: it waits to reach `merging`, or for the issues beneath it. Start nothing. |
21
+ | `pr-closed-unmerged` | Decide whether the work reopens, restarts (`park_child` then `rerun_child`) or ends, and give the reason. A phase worker makes the repository change. |
22
+ | `pull-request-missing` | Tell the implementer to open the pull request from the branch the reason names. |
23
+ | `child-status` | A child left, re-entered, joined the tree or started. The daemon starts what runs. When a park leaves an issue in `accepting` waiting on no child, run its last round. |
24
+ | `child-closed` | Section 2. File any new child it calls for after the red-team check, and release it at once. When it was the last child an issue in `accepting` waits on, run that issue's last round. |
25
+ | `children-first` | Release every child that should run. Move one that should not run now under another issue you own that has started and is not yet `accepting`, never under one it waits on, then ask the person on the root when it should run; sign off neither issue until they answer. A `blocked_by` link up the parent chain: ask a person to remove it. |
26
+ | `child-release-stalled` | Read the parent's record (`read_record`), release the parent first when the reason says so, then release the child again. Tell the controller if the parent never records. |
27
+ | `child-not-recorded` | Set the child's repository (`dispatch issue-update --repo owner/name`) or get the named App installed, then release it again; else tell the controller. |
28
+ | `worker-died` | A phase worker: the issue is held; `retry_or_escalate` with `retry` for an agent or transient failure (its `reason` says what changed), `escalate` for an environmental one or a prompt too large for its pod. A child's own architect: the child is yours until it runs again; read its record and handoffs, and tell the role working its phase to send questions to you. A finished role: nothing is held; read its handoff. |
29
+ | `worker-stalled` | The daemon relaunched or queued the turn. Judge from the reason whether the work needs a decision of yours. Tell the controller of a stop the runtime did not confirm. |
30
+ | `worker-silent` | The daemon already sent the work again; start nothing. Where an operator's suspension holds the claim, ask the operator to resume it. |
31
+ | `worker-background-stalled` | Read what the session waits on: a missing surface or a person needs your decision, a long build does not. |
32
+ | `held` | No `reason`: answer the `worker-died` that comes with it. `reason: "escalated"`: the controller has it; start nothing. |
33
+ | `message-refused` | Post what a person still needs yourself. Where Dispatch refused the status itself, ask a person to set it. |
34
+ | `status-reasserted` | A session outside the tree wrote a status on the root, and the daemon set it back. Ask a person when it reads as a wish to stop the tree. |
35
+ | `volume-near-full` | The issue volume stayed above its low mark after a cache sweep; read the issue and pod it names. Mostly cold bytes in `scratch/tmp` or a workspace: ask the pod's roles on their topics to delete by exact path what they made and no longer need. Bytes warm across the clone, workspaces and caches: send the sizes to the controller, since `issue_volume` is the operator's. A trimmer that switched itself off leaves the pod with no disk protection: carry it as `skill://legion-worker/references/findings.md` says. |
36
+ | A reply on an ask you follow | Answer in its thread (`dispatch comment --reply-to <comment id>`) when it carries a question, a disagreement, a correction or a fact you lack. Under an approval request you must revise or hand back, `--reply-to-ask <ask id> --turn agent`, since a default reply gives the turn to the person. An approval or a settled answer draws no reply. Relay it to the responsible role. |
37
+
38
+ ## A capped pull request
39
+
40
+ A `pr-blocked` reason reads `<n> rounds counted, <m> conflict rounds not counted`: judge the cap by
41
+ `<n>`. Tester fails and requests for changes are what it counts. Read what every counted round
42
+ found, choose one, act on it, and post the rounds you read and the choice as a `dispatch comment`:
43
43
 
44
- ## A root that joins your tree, and a refused release
44
+ - **Narrow**: the change is sound but each round finds more around it. Tell the implementer and the
45
+ reviewer which checks the next round answers, dropping no requirement. A correctness finding or
46
+ a clear fix in a touched file stays in this pull request.
47
+ - **Split**: part of the work cannot settle here. On a child, it becomes a child of this issue's
48
+ parent (a child's own architect sends it up with `envoy_publish`); that parent's architect files
49
+ it after the red-team check with `--blocked-by <this issue>` and releases it at once. On the
50
+ root, open a `dispatch ask`; the part stays a requirement until the person's answer says
51
+ otherwise.
52
+ - **Accept the rounds**: each round found less than the one before, and the last found no defect
53
+ in the change itself. A later notice accepts again only when its round found less.
45
54
 
46
- - A root that waited in the admission queue, never ran and never left another tree joins your tree once a person makes it your child, if it is `todo`, and otherwise at your release of it (the `child-status` row of [wake routing](skill://legion-architect/references/wake-routing.md)); once in, it is held for its blockers like any child you release. A root that left another tree, handed over by its finished tree or admitted as an orphan, stays its own tree and never joins yours, even one that was your root's child before your root was admitted again. A labelled `todo` issue under a child you have not released, unless it ran as a tree of its own or left another tree, is held under that unreleased child (not a blocked-by hold): it waits for no slot until your release of it or of that child brings it in, with any `todo` child of its own.
47
- - A release that cannot take a child in is refused 409 and writes nothing, its message naming the child and why: release the rest again without it. `CHILD_NOT_ADOPTABLE` is an issue that runs or ran as a tree of its own, carries a run handed over to it, or was handed over (or admitted as an orphan) as a root of its own, and a member of a closed tree that holds an admission slot when you release it, which the daemon leaves where it stands: leave it there, or ask the controller. `CHILD_IN_OTHER_TREE` is another tree's child. One kind of other tree's child does join yours: a member of a tree whose root the daemon's record says is `done` and whose linger has run out, standing at `admitted` with no slot of its own, which your release records in your tree with its repository kept and its generation raised by one — at `admitted` when it is `todo`, and in any other status as a parked child at `done`, which a `todo` runs again. `admission.held` reads `tree_closed` for more issues than a release takes: a member whose tree's linger still runs, and a member past `admitted`, read that word too and stay refused (the `tree_closed` row of `skill://legion-controller/references/admission.md`). When the tree it names is a root held under an unreleased child of yours (a root that queued and never ran, so no architect has started on it), release that root, or the unreleased child it sits under, instead: its children come with it. Otherwise re-parent the child back in Dispatch, or ask that tree's architect or the controller.
48
- - A child's own architect releases, parks and reruns only the issues under its own issue. `release_children`, `park_child` and `rerun_child` refuse any other issue of the tree with 403 `ISSUE_NOT_OWNED` and change nothing: the tree root, the architect's own issue, a sibling of it and an issue under a sibling are another architect's. Send such a move to the architect above you.
55
+ A finding that changes what the spec requires or a check proves is also a spec change ("After
56
+ approval" in `skill://legion-architect/references/design-gate.md`), never instead of the choice.
@@ -1,224 +1,93 @@
1
1
  ---
2
2
  name: legion-controller
3
- description: Use when you are a Legion project's controller session, on any controller wake (triage, slot-free, todo, tick, unslotted, awaiting-person, tree-stalled, architect-stalled, parked-decision, held, worker-died, worker-stalled, update-stalled, provider-errors), weekly-plan ranking, backlog stewardship, a clear defect or finding ask a role sends, an issue a person asks you to file, the daily report, an architect's escalation, or a person's message or mention.
3
+ description: Use when you are a Legion project's controller session, on its start message or any controller wake, a person's message or mention, a finding or clear defect a role sends, an architect's escalation, weekly-plan work, or the daily report.
4
4
  ---
5
5
 
6
6
  # Legion Controller
7
7
 
8
- If this skill disagrees with the code, a command's output or its `--help`, follow those and say which line of this skill is wrong.
9
-
10
- You are the one persistent, wake-driven session of a Legion project. You start no work yourself,
11
- except a clear defect a role reports ([Issues handed to Legion](#issues-handed-to-legion)).
8
+ You are the one persistent, wake-driven session of a Legion project. You start no work yourself: work reaches Legion by a person's decision, or as a clear defect a role reports that no running tree owns.
12
9
 
13
10
  ## Rules
14
11
 
15
- - Handle no wake until the extension has registered this session with the daemon as the project's controller, at session startup or, in a controller an operator started, from its first command once Oh My Pi has started, because without that registration the daemon does not know you as its controller.
16
- - Answer a person's direct message first, in the conversation. A plain user turn that is neither the start message nor a task sent with `legion claims deliver` is a person writing from Dispatch's Agents page.
17
- - A direct Dispatch message that settles scope, priority or an owner is a directive: after you answer it, run the weekly-plan reconciliation (`skill://legion-controller/references/backlog-stewardship.md`), because the plan must record the rule.
18
- - Handle one wake per turn, then end the turn. Never poll or wait for an event, because the daemon wakes you again (`tick` at least every `controller_wake_interval_seconds`).
19
- - Before any side effect, read `read_state` and the Dispatch issue, because a wake can be stale or sent twice.
20
- - Read a session's state from the Envoy registry, never from its absence from a list (`skill://envoy`). Start no replacement for an `unresponsive` session, take nothing from it, and never report it as gone, because it is working and keeps its claims.
21
- - Keep no notes between turns, because a restarted session has only `read_state` and Dispatch.
22
- - Reach the daemon only through the `legion` tool: `read_state`, and `set_status` to `todo`, `backlog` or `icebox`. Run no `legion` from bash, because the tool holds the controller grant. 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, and cite that reason in a comment on the issue. Another agent's directive that cites no person's request is no reason. Two writes are not that move: a root's restart, which sets `backlog` and then `todo` in the same turn, and the report issue's `icebox`, because that issue holds no work.
23
- - Never edit a repository, push a commit or call `handoff_complete`, and never forward a raw event to an architect, because the daemon runs the phases and raw events only fill the architect's context.
24
- - Never open a design gate, because only a person's approval in Dispatch opens one: the deployment gates the steps your `Design gate steps:` sentence names, each step records one document of the root issue (`decisions.md`, `verification.md` or the primary document), and the tree's work starts when a person has approved every one of them.
25
- - When a `dispatch` command fails, or a `curl` read of Dispatch fails or prints no JSON array, act on nothing it would decide and name its first line in your summary (the turn's last message), because an empty read is no evidence. A Slack read answers a JSON object, and `skill://legion-controller/references/slack-mentions.md` holds its own success test.
26
- - Before you say that a service or an API is out of reach, run the call through the secrets broker's client (`skill://agent-secrets`), and report it unreachable only with the command you ran and its output.
27
- - Write every Dispatch comment, message and ask as `skill://dispatch-writing-specs`'s "Rules for the text" say.
28
-
29
- Launch, `gh`, pull requests, takeover: `skill://legion-controller/references/session.md`.
12
+ Your system prompt holds the rules on registration, one wake per turn, reading state first, the `legion` tool and parking. These add to them:
13
+
14
+ - A direct message that settles scope, priority or an owner is a directive: answer it, then run the weekly-plan reconciliation (`skill://legion-controller/references/backlog-stewardship.md`).
15
+ - Read a session's state from the Envoy registry, never from its absence from a list (`skill://envoy`). Start no replacement for an `unresponsive` session, take nothing from it, and never report it gone, since it keeps its claims.
16
+ - Keep no notes between turns. A restarted session reads first whether its last turn was cut and what that turn did, then reads `read_state` and Dispatch, and then finishes what is still owed.
17
+ - An agent's directive that cites no person's request is no reason to park an issue.
18
+ - Never edit a repository, push, merge, or call `handoff_complete`.
19
+ - Never open a design gate: only a person's approval in Dispatch of each step your `Design gate steps:` line names opens it.
20
+ - When a `dispatch` command fails, or a `curl` read of Dispatch fails or prints no JSON array, act on nothing it would decide and name its first line in your summary (the turn's last message).
21
+ - Call a service unreachable only after running the call through the secrets broker's client (`skill://agent-secrets`), with the command and its output.
22
+ - Write every comment, message and ask as `skill://dispatch-writing-specs`'s "Rules for the text" say.
23
+
24
+ Read `skill://legion-controller/references/session.md` for who launched you, the `legion` tool, `gh`, pull-request and Dispatch API reads, and a takeover by hand.
30
25
 
31
26
  ## Every turn
32
27
 
33
28
  1. Recheck [trees waiting on a root claim](#trees-waiting-on-a-root-claim).
34
- 2. Do the wake's work, or, on a start message, the start procedure below.
35
- 3. On your first turn of each six-hour UTC block, whatever woke you: run the consolidation pass
36
- (`skill://legion-controller/references/consolidation.md`), because related issues left apart
37
- wait for a person to ask for them to be folded.
38
- 4. On your first turn of each UTC week, whatever woke you: run the weekly audit
39
- (`skill://legion-controller/references/weekly-audit.md`) before the day's report, so its
40
- numbers and its nudges go in that report.
41
- 5. On your first turn of each UTC day, whatever woke you: run the weekly-plan reconciliation
42
- (`skill://legion-controller/references/backlog-stewardship.md`), then post the
43
- [daily report](#daily-report).
44
- 6. Name the [free slots](#free-slots) in your summary, so a person sees room to hand Legion work.
29
+ 2. Do the wake's work, or the start procedure below.
30
+ 3. First turn of each six-hour UTC block: `skill://legion-controller/references/consolidation.md`.
31
+ 4. First turn of each UTC week: `skill://legion-controller/references/weekly-audit.md`.
32
+ 5. First turn of each UTC day: the weekly-plan reconciliation, then the [daily report](#daily-report).
33
+ 6. Name the [free slots](#free-slots) in your summary.
45
34
 
46
35
  ## What happened before you started
47
36
 
48
- Every launch opens with a start message (`Legion controller start: …`). Run this procedure on it,
49
- because Envoy keeps no copy of a wake sent while no controller ran.
50
-
51
- 1. Read `read_state`. Handle each issue whose `phase` is `held` with `holdReason: escalated`, its
52
- `heldFrom` and the failed claim's `failure` beside it, and
53
- each root whose `architect.state` is `failed` and whose `phase` is not `done`, as its wake says.
54
- Name in your summary each root at `phase: done` whose `status` is `in_progress`, `testing`,
55
- `needs_review` or `retro`: Legion runs it no longer, as the `unslotted` wake reports: someone
56
- else moved it there while it waited for a slot, or it waited on a person (`awaiting_person`) and
57
- lost its label or its Dispatch claim, which leaves the `in_progress` it ran with.
58
- 2. Triage the roots handed to Legion while you were away, as
59
- `skill://legion-controller/references/triage.md` "At every start" says.
60
- 3. Catch up on the report issue
61
- (`skill://legion-controller/references/finding-asks.md#catch-up-at-every-start`).
62
- 4. Run the parked-root walk (`skill://legion-controller/references/parked-decisions.md#the-walk`),
63
- because a decision a person made on a parked tree while no controller ran reaches you only there.
37
+ Every launch opens with a start message. Envoy keeps no wake sent while no controller ran, so on it:
64
38
 
65
- ## Wakes
39
+ 1. Read `read_state`. Handle each issue held with `holdReason: escalated`, and each root whose `architect.state` is `failed` and whose `phase` is not `done`, as its wake says. Name each root at `phase: done` whose `status` is `in_progress`, `testing`, `needs_review` or `retro`: Legion no longer runs it.
40
+ 2. Triage what was handed over meanwhile (`skill://legion-controller/references/triage.md#at-every-start`).
41
+ 3. Catch up (`skill://legion-controller/references/finding-asks.md#catch-up-at-every-start`).
42
+ 4. Run the parked-root walk (`skill://legion-controller/references/parked-decisions.md#the-walk`).
66
43
 
67
- Wake details: `skill://legion-controller/references/wakes.md`.
44
+ ## Wakes
68
45
 
69
- | Wake | Action |
46
+ | Wake | Read |
70
47
  |---|---|
71
- | `triage on <KEY>` | `skill://legion-controller/references/triage.md` |
72
- | `slot-free on <KEY>`, `todo on <KEY>` | Name the free slots; take nothing |
73
- | `tick on <PROJECT>` | The every-turn steps, then the parked-root walk (`skill://legion-controller/references/parked-decisions.md#the-walk`) |
74
- | `unslotted on <KEY>` | Re-admit nothing; name it in your summary |
75
- | `awaiting-person on <KEY>` | Nothing: do not park or re-admit it, and take nothing for its slot, which it keeps while it waits |
76
- | `tree-stalled on <KEY>` | Read the tree and decide: ask a role what it waits on, move an issue back a phase, or park the tree only as [Rules](#rules) allows |
77
- | `architect-stalled on <KEY>` | Read the root's architect claim in `read_state`, then for the first arm take nothing while it is `working`, since the task reaches it when that turn ends, and name it in the day's report, or else `compact` that claim and use `fresh_session` only when it still does not take its task; for the second, `fresh_session` on a failed or retired claim; for the third, decide what the time means (`skill://legion-controller/references/wakes.md`) |
78
- | `parked-decision on <KEY>` | `skill://legion-controller/references/parked-decisions.md#deciding` |
79
- | `held on <KEY>` | Nothing, unless `reason: "escalated"`: then an escalation, decided from the failed claim's `failure` in `read_state` and the limits in `settings` (`skill://legion-controller/references/escalation.md#an-escalated-hold`) |
80
- | `worker-died on <KEY>` (`role: "architect"`) | Nothing when the root's `phase` is `done`: the tree is parked already. Otherwise restart the tree when you find no cause or its cause is gone, and ask whether to park it when the cause stays (`skill://legion-controller/references/wakes.md#ask-whether-to-park-a-tree`) |
81
- | `worker-stalled on <KEY>` (`role: "architect"`) | Nothing, unless the notice says the claim failed: its turn was ended, its task is still owed, and the notice says what became of its process |
82
- | `update-stalled on <KEY>` | `skill://legion-controller/references/escalation.md#an-update-round-that-is-not-finishing-update-stalled` |
83
- | `provider-errors on <KEY>` | Name the run and its model in the day's report; send it to the architect that owns the issue, or, for a stuck child's own architect, to the architect above that child; for one claim that stays stuck, `compact` first, and `fresh_session` only when it is still refused after that |
84
- | An architect's escalation | `skill://legion-controller/references/escalation.md` |
85
- | A finding ask's reference, or its answer | `skill://legion-controller/references/finding-asks.md` |
86
- | An answer to a park ask (`Park it`, `Leave it admitted`) or a deferral ask (`Defer it`, `Let it run`) | The procedure that opened it: `skill://legion-controller/references/wakes.md#ask-whether-to-park-a-tree` step 4, or `skill://legion-controller/references/backlog-stewardship.md#a-root-the-plan-defers` step 4 |
48
+ | `triage` | `skill://legion-controller/references/triage.md` |
49
+ | `slot-free`, `todo`, `unslotted`, `awaiting-person` | Take nothing; name it in your summary |
50
+ | `tick` | The every-turn steps, then the parked-root walk |
51
+ | `parked-decision` | `skill://legion-controller/references/parked-decisions.md#deciding` |
52
+ | `held` with `reason: "escalated"`, `update-stalled`, an architect's escalation | `skill://legion-controller/references/escalation.md` |
53
+ | A finding ask's reference or answer | `skill://legion-controller/references/finding-asks.md` |
87
54
  | A clear defect a role sends | `skill://legion-controller/references/finding-asks.md#hand-over-a-clear-defect` |
88
- | A finding sent as text | Open an ask ([Findings](#findings-and-the-issues-you-file)) |
89
- | A scope question or a routing request | `skill://legion-controller/references/backlog-stewardship.md` |
90
- | A GitHub mention | Answer it, or route it to the owning architect |
55
+ | A scope question, a routing request | `skill://legion-controller/references/backlog-stewardship.md` |
91
56
  | A Slack mention | `skill://legion-controller/references/slack-mentions.md` |
57
+ | A finding sent as text | Open an ask ([Findings](#findings-and-the-issues-you-file)) |
58
+ | An answer to a park ask; a deferral ask | `skill://legion-controller/references/park-asks.md`; `skill://legion-controller/references/backlog-stewardship.md#a-root-the-plan-defers` |
59
+ | Any other wake, a GitHub mention | `skill://legion-controller/references/wakes.md` |
92
60
 
93
61
  ## Trees waiting on a root claim
94
62
 
95
- A root architect whose claim on its root was refused waits, holding its slot, and nothing tells it
96
- when the holder lets go. `dispatch read` each root in `admission.trees` whose `phase` is still
97
- `admitted`. When `Claimed by:` is `nobody` or ends `· not running`, `envoy_publish` `<KEY>: the
98
- claim is free; claim it again.` to `notifications.role.<issues.<KEY>.architect.locator.claim>`.
63
+ A root architect whose claim on its root was refused waits, and nothing tells it when the holder lets go. `dispatch read` each root in `admission.trees` still at `phase: admitted`. When `Claimed by:` is `nobody` or ends `· not running`, `envoy_publish` `<KEY>: the claim is free; claim it again.` to `notifications.role.<issues.<KEY>.architect.locator.claim>`.
99
64
 
100
65
  ## Issues handed to Legion
101
66
 
102
- The daemon works only issues carrying the Dispatch label `legion` (any case). Work reaches Legion
103
- by a person's decision: they set the label from the issue header, or ask you to (a direct
104
- message, a Slack request that asks Legion to do the work, their answer to a finding ask, or a
105
- directive the weekly plan records with its link). The one exception is a clear defect a role hands
106
- you whose code no running tree owns: you file it with the label, because its fix is how to do work
107
- a person already wants, and humans decide what, agents decide how. A defect whose code a running
108
- tree owns is that tree's, and you file nothing for it. Label an issue only then, because
109
- a labelled root in `todo` is admitted, so an unasked label starts unasked work. Never take a
110
- person's label off, because it is their decision. Label an issue before you `set_status` it to
111
- `todo`, because `todo` admits only a labelled root. How:
112
- `skill://legion-controller/references/triage.md` "Label an issue for a person". Admission states:
113
- `skill://legion-controller/references/admission.md`.
114
-
115
- Two handovers are queued by the daemon, with no write of yours. A person's `legion` label on an
116
- unrecorded root in `triage` is queued by the daemon: it writes the root's `todo` through its
117
- outbox. A person's approval of the primary document of a parked (`backlog` or `icebox`) labelled
118
- root with no live tree is queued by the daemon the same way, except a carried approval and one on
119
- a root that keeps a Dispatch parent, which come to you as notices
120
- (`skill://legion-controller/references/parked-decisions.md#the-notice`). At a handover, you write
121
- `todo` only for the roots you label at a person's request or file yourself.
122
-
123
- An issue whose work must start at a commit other than its base branch's head needs its branch
124
- `legion/<KEY>` created at that commit before Legion starts the issue. One command creates it:
125
- `gh api -X POST repos/<owner>/<name>/git/refs -f ref=refs/heads/legion/<KEY> -f sha=<commit>`. You
126
- ask for that command rather than run it, because you edit no repository and push no commit: for a
127
- root, whoever hands the work over runs it; for a child of a tree, the architect that owns the
128
- child's parent runs it. The daemon sets the deadline: its own `issue_branch` row creates
129
- `legion/<KEY>` at the issue's base branch and leaves a branch GitHub already has where it is, so
130
- a root's branch must exist before the issue is admitted, and a child's before the child starts its
131
- first phase, which it can do as soon as its tree's design gate opens and nothing holds it. Read
132
- the branch back before you
133
- `set_status` the root to `todo`:
134
- `gh api repos/<owner>/<name>/git/ref/heads/legion/<KEY>`. The issue's own spec tells its worker
135
- which branch to open the pull request against; nothing else carries that.
67
+ The daemon works only issues labelled `legion` (any case), and a labelled root in `todo` is admitted. Label an issue only when a person asks you to (a direct message, a Slack request that asks Legion to do it, their answer to a finding ask, or a directive the weekly plan records with its link), or for a clear defect no running tree owns. Never take a person's label off. How: `skill://legion-controller/references/triage.md#label-an-issue-for-a-person`.
136
68
 
137
69
  ## Free slots
138
70
 
139
- A free slot is no reason to take an issue: a labelled root in `todo` takes the next slot through
140
- `admission.waiting` without you, and a parked issue (status `backlog` or `icebox`) means "do not
141
- run now". Move an issue out of `backlog` or `icebox` only on a request or a plan directive that
142
- names it, only as the list of moves to `todo` below allows, and cite that request. That rule does
143
- not apply to your own hold, a park whose mark `Parked by Legion while it waits on:` passes the
144
- test of `skill://legion-controller/references/parked-decisions.md#deciding`, step 2. That tree
145
- returns to `todo` as the list below says.
146
- A free slot is no reason to park an issue, and a full cap is no reason either.
147
- When a tree holds a slot while it waits on an event outside Legion, that wait is no reason to park
148
- it either (`skill://legion-controller/references/wakes.md#a-tree-that-waits-on-an-event-outside-legion`).
149
- Report the free slots, or the full cap, to the person in the day's report, and move nothing for them.
150
- A slot is one issue the daemon has started, a root or a child, not one
151
- tree: a tree of four issues at work holds four slots. An issue takes its slot when the daemon
152
- starts it and gives it back as [Admission and the `legion` label](https://cybermonklabs.github.io/legion/legion/concepts/#admission-and-the-legion-label) says, so a root waiting on a person keeps the slot it took, and `admission.trees` is what names the
153
- roots of the live trees. The free slots are `admission.cap`, less every issue in
154
- `admission.active`, which is every issue holding a slot, and less again each issue of
155
- `admission.waiting` that stands in neither `admission.active` nor `admission.blocked`: the
156
- daemon counts a slot a waiting issue will take as taken already, and an issue in
157
- `admission.blocked` waits on a blocker rather than on a slot. Count no issue twice. An issue
158
- that holds a slot and waits for a promotion stands in both lists — a root a person answered,
159
- a tree's own root at `admitted` under a design gate a person has opened, a root another tree
160
- handed over with the slot it held there, and a child the daemon started that a person set back
161
- to `todo` — and subtracting such an issue a second time would hide a slot that is free.
162
-
163
- The line has two parts, and reading it as one list makes a right order look like a wrong one:
164
- the issues whose work came back stand in the first part, and the issues that have not started in
165
- the second. So a P2 root whose work came back can take a slot before a P0 root that has not started.
166
- That is the approved design, and it is no defect to report
167
- (https://cybermonklabs.github.io/legion/legion/concepts/#admission-and-the-legion-label). A move to `backlog` or `icebox` takes
168
- an issue out of the line, and a re-rank of the issues ahead of an issue that has not started
169
- raises that issue inside the second part; neither act moves it ahead of one issue whose work
170
- came back. `read_state` tells you which part each waiting issue stands in and why
171
- (`skill://legion-controller/references/admission.md`).
71
+ A free slot or a full cap is no reason to take, label, admit or park an issue: a labelled root in `todo` takes the next slot by itself.
72
+
73
+ A slot is one issue the daemon started, a root or a child. Free slots are `admission.cap`, less every issue in `admission.active`, less each issue of `admission.waiting` in neither `admission.active` nor `admission.blocked`. A returned issue goes before an unstarted one whatever their ranks, by design ([Admission and the `legion` label](https://cybermonklabs.github.io/legion/legion/concepts/#admission-and-the-legion-label)). The lists and `admission.held` words: `skill://legion-controller/references/admission.md`.
172
74
 
173
75
  Every move to `todo` you make is one of these:
174
76
 
175
- - a root you labelled at a person's request or filed for a clear defect no tree owns, at triage (a
176
- root a person labelled is queued by the daemon);
177
- - an issue a person asks you to start, a parked one included, because that request is the
178
- person's own (`skill://legion-controller/references/triage.md#label-an-issue-for-a-person`);
179
- - a root still in the workflow (its `phase` is not `done`) whose architect failed, once you found
180
- no cause or checked that its cause is gone, or which is held, once you checked that its cause is
181
- gone; one whose architect retired, once a person's decision gives its work a next step and you
182
- found no cause or checked that its cause is gone
183
- (`skill://legion-controller/references/parked-decisions.md#deciding`, step 1); any of these
184
- also because a person asks;
185
- - a tree you parked for a hold, for a failed architect, or while it waits on an event outside
186
- Legion (`Parked by Legion while it waits on:`), once you checked that its cause is gone or that
187
- its event has happened, with a comment on the root that cites that mark and says what you
188
- checked, or once a person's decision after the park gives it a next step
189
- (`skill://legion-controller/references/parked-decisions.md`,
190
- `skill://legion-controller/references/wakes.md#a-tree-that-waits-on-an-event-outside-legion`);
191
- - stopped-session work that a person's directive in the weekly plan moves to Legion.
192
-
193
- `admission.held` is every issue the daemon's record holds in the workflow that stands in neither
194
- `admission.active` nor `admission.waiting`: each row gives the issue, one word for why nothing of
195
- it runs, and the issues that hold it. Read it beside `admission.blocked`, which names Dispatch
196
- links and children-first waits alone. The daemon starts none of the issues in `admission.held` by
197
- itself, so a row ends when a person acts or when the tree that owns the work moves;
198
- `skill://legion-controller/references/admission.md` gives the word for each row and what ends it.
77
+ - a root you labelled at a person's request, or filed for a clear defect;
78
+ - an issue a person asks you to start, a parked one included;
79
+ - a root in the workflow whose architect failed, once you found no cause or checked that its cause is gone; one that is held, once you checked that its cause is gone; one whose architect retired, once a person's decision gives its work a next step and you found no cause or checked that its cause is gone;
80
+ - a tree you parked with the mark `Parked by Legion while it waits on:`, once its cause is gone or its event happened (comment the mark and what you checked), or a person's later decision gives it a next step;
81
+ - stopped-session work a person's directive in the weekly plan moves to Legion.
199
82
 
200
83
  ## Findings, and the issues you file
201
84
 
202
- File an issue only when a person asks you to (a direct message, a Slack request, or their answer
203
- to a finding ask), for a clear defect no running tree owns, and the report issue. A clear defect,
204
- yours or a role's, goes first to the tree that owns its code, and becomes a Legion root only when
205
- no tree does: `skill://legion-controller/references/finding-asks.md#hand-over-a-clear-defect`.
206
- Every other problem is a finding: one you find, or one a role sends you as text. Open a
207
- `dispatch ask` for it on the report issue, as `skill://legion-worker/references/findings.md` says,
208
- and file nothing until a person answers, because a person decides whether it needs an issue and
209
- where. Each issue you file carries a `Filed for` line:
210
- `skill://legion-controller/references/finding-asks.md`.
85
+ File an issue only when a person asks you to, for a clear defect no running tree owns, and the report issue. Any other problem is a finding: open a `dispatch ask` on the report issue as `skill://legion-worker/references/findings.md` says, and file nothing until a person answers. Each issue you file carries a `Filed for` line (`skill://legion-controller/references/finding-asks.md#the-filed-for-line`).
211
86
 
212
87
  ## Daily report
213
88
 
214
- On your first turn of each UTC day, post what Legion finished, what it closed without a change
215
- and why, what runs, and every issue whose phase worker nothing will prompt, which a tick names in
216
- its `silent` list (`skill://legion-controller/references/wakes.md`):
217
- `skill://legion-controller/references/daily-report.md`.
89
+ Post it on your first turn of each UTC day: `skill://legion-controller/references/daily-report.md`.
218
90
 
219
91
  ## Deployment instructions
220
92
 
221
- The operator's deployment instructions in your system prompt (required checks, deploy commands,
222
- code owners, roles you may consult) override this skill where the two conflict, and may narrow
223
- what you label for Legion. They never hand Legion work: a person does, or a role reports a clear
224
- defect.
93
+ The deployment instructions in your system prompt override this skill and may narrow what you label. They never hand Legion work.