@openmuster/muster 0.0.0-stage → 0.3.1-alpha.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.
Files changed (75) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +309 -2
  3. package/dist/args-DHgAmYge.js +7043 -0
  4. package/dist/cli.d.ts +1 -0
  5. package/dist/cli.js +31 -0
  6. package/dist/index.d.ts +2138 -0
  7. package/dist/index.js +1938 -0
  8. package/dist/inspect/app.js +163 -0
  9. package/dist/main-A4nHL5oa.js +3941 -0
  10. package/dist/main-CuIC8iF4.js +6 -0
  11. package/dist/mcp-GkdeWAnr.js +6 -0
  12. package/dist/module-CT_R33MB.js +4 -0
  13. package/dist/module-DOkWwWoU.js +439 -0
  14. package/dist/skills/board/SKILL.md +214 -0
  15. package/dist/skills/board/references/build-a-ui.md +63 -0
  16. package/dist/skills/board/references/claude.md +54 -0
  17. package/dist/skills/board/references/codex.md +61 -0
  18. package/dist/skills/board/references/software-factory.md +89 -0
  19. package/dist/skills/board/references/swarm.md +165 -0
  20. package/dist/skills/configure-factory/SKILL.md +116 -0
  21. package/dist/skills/loop-card/SKILL.md +95 -0
  22. package/dist/steps-ByzmEzLQ.js +3175 -0
  23. package/docs/01-concepts/01-overview.md +73 -0
  24. package/docs/01-concepts/02-boards.md +71 -0
  25. package/docs/01-concepts/03-channels.md +56 -0
  26. package/docs/01-concepts/04-threads.md +75 -0
  27. package/docs/01-concepts/05-labels.md +65 -0
  28. package/docs/01-concepts/06-actors.md +66 -0
  29. package/docs/01-concepts/07-events.md +126 -0
  30. package/docs/01-concepts/08-tasks.md +244 -0
  31. package/docs/01-concepts/09-watchers.md +172 -0
  32. package/docs/01-concepts/10-schedules.md +39 -0
  33. package/docs/01-concepts/11-access.md +182 -0
  34. package/docs/01-concepts/12-files-and-data.md +79 -0
  35. package/docs/01-concepts/13-budgets.md +35 -0
  36. package/docs/01-concepts/14-runners.md +102 -0
  37. package/docs/01-concepts/15-outgoing-webhooks.md +177 -0
  38. package/docs/01-concepts/16-workflows.md +350 -0
  39. package/docs/01-concepts/17-board-module.md +122 -0
  40. package/docs/01-quickstart.md +141 -0
  41. package/docs/02-sync/01-overview.md +239 -0
  42. package/docs/02-sync/02-github.md +158 -0
  43. package/docs/02-sync/03-linear.md +290 -0
  44. package/docs/02-sync/04-slack.md +232 -0
  45. package/docs/02-sync/05-notion.md +92 -0
  46. package/docs/03-guides/01-coding-agents.md +98 -0
  47. package/docs/03-guides/02-swarm.md +85 -0
  48. package/docs/03-guides/03-factory.md +216 -0
  49. package/docs/03-guides/04-inspector.md +53 -0
  50. package/docs/03-guides/05-running-agents.md +73 -0
  51. package/docs/03-guides/06-sandboxed-agents.md +441 -0
  52. package/docs/03-guides/07-build-a-ui.md +61 -0
  53. package/docs/03-guides/08-ci.md +168 -0
  54. package/docs/03-guides/09-daemon.md +103 -0
  55. package/docs/03-guides/10-two-agents.md +76 -0
  56. package/docs/03-guides/11-person-in-the-loop.md +123 -0
  57. package/docs/03-guides/12-unattended.md +110 -0
  58. package/docs/03-guides/13-terminals.md +153 -0
  59. package/docs/03-guides/14-no-cloud.md +82 -0
  60. package/docs/03-guides/15-several-boards.md +71 -0
  61. package/docs/03-guides/16-non-code.md +69 -0
  62. package/docs/03-guides/17-mcp.md +126 -0
  63. package/docs/03-guides/18-a-board-on-a-server.md +162 -0
  64. package/docs/03-guides/19-a-card-queue.md +261 -0
  65. package/docs/03-guides/20-a-feedback-loop.md +225 -0
  66. package/docs/03-guides/21-running-the-loop.md +196 -0
  67. package/docs/04-reference/01-cli.md +166 -0
  68. package/docs/04-reference/02-handle.md +409 -0
  69. package/docs/04-reference/03-http.md +157 -0
  70. package/docs/04-reference/04-events.md +72 -0
  71. package/docs/04-reference/05-errors.md +221 -0
  72. package/docs/04-reference/06-conformance.md +52 -0
  73. package/docs/04-reference/07-porting.md +116 -0
  74. package/docs/index.md +103 -0
  75. package/package.json +52 -3
@@ -0,0 +1,261 @@
1
+ ---
2
+ title: A card queue
3
+ description: Label a Linear issue for the agent, and get a spec, a pull request and a review back on it; you answer only what it asks.
4
+ ---
5
+
6
+ ## Who this is for
7
+
8
+ You keep work as cards, Linear issues or threads you post yourself, and want
9
+ an agent to take a card from start to finish: write a spec, make the change
10
+ as a pull request, and review it. You only want to hear about a card when the
11
+ agent needs a decision from you.
12
+
13
+ **You need:** muster on the machine that holds the board, `mu serve` reached
14
+ through a tunnel or a proxy, a Vercel project for the sandboxes, a GitHub App
15
+ installed on the repository, a model key, and for Linear cards a Linear key
16
+ and webhook. See [Agents in cloud sandboxes](./06-sandboxed-agents.md) for
17
+ the Vercel and GitHub parts. `"runner": "e2b"` in `workflows.json` runs the
18
+ steps in E2B sandboxes instead, with `E2B_API_KEY` and `MUSTER_E2B_TEMPLATE`
19
+ in place of the Vercel settings.
20
+
21
+ ## The parts
22
+
23
+ `templates/queue` is a board module for muster's own daemon, a workflow
24
+ file, and three small scripts:
25
+
26
+ | File | What it does |
27
+ | --- | --- |
28
+ | `board.ts` | The board module. Its sync maps Linear team `ENG` to the channel `cards`, both ways. Its watcher `card-start` runs `start.sh` for a card labelled `tag.agent=agent`; `needs-me` runs `notify.sh` when a task under `cards/` blocks |
29
+ | `workflows.json` | The `card` workflow: spec, work and review tasks, one Vercel worker, `--push` for the work step only |
30
+ | `start.sh` | Marks the card `started` and asks for the `card` workflow on it, once |
31
+ | `notify.sh` | Tells you a task is blocked, with its ID only |
32
+ | `answer.sh` | Unblocks a blocked task, posts your answer, and starts a worker on the rest of its run |
33
+
34
+ ```mermaid
35
+ flowchart LR
36
+ L[Linear issue labelled agent] -->|sync| C[thread in cards, tag.agent=agent]
37
+ C -->|card-start| S[start.sh: started=yes, mu workflow run card]
38
+ S --> R[cards/card-n: spec, work, review]
39
+ R -->|started, then a summary| C
40
+ C -->|sync| L
41
+ R -->|task.blocked| N[needs-me: notify.sh]
42
+ N --> Y[you: answer.sh]
43
+ Y --> R
44
+ ```
45
+
46
+ ## Set it up
47
+
48
+ ```bash
49
+ cp templates/queue/workflows.json ~/.config/muster/
50
+ ```
51
+
52
+ Then edit the copy: `repo` is your repository's https address. In
53
+ `board.ts`, `ENG` is your Linear team's key. `board.ts` stays in
54
+ `templates/queue`, and names the scripts beside it by their full paths,
55
+ wherever it is run from. If `~/.config/muster/` has a `watchers.json`,
56
+ `sync.json` or `hooks.json` from an earlier copy of this template, move
57
+ anything else in them into a board module and delete them: those files are no
58
+ longer read, and `mu serve` refuses to start while one is there
59
+ ([Porting](../04-reference/07-porting.md)).
60
+
61
+ Put the settings in the environment `mu serve` starts with, and give it the
62
+ module. It runs the module's sync, its watchers and the workflow, and the
63
+ workers start with its environment. The module names the Linear secrets with
64
+ `env()`: `mu serve` reads them when it starts, and refuses to start, naming
65
+ the variable, if one isn't set:
66
+
67
+ ```bash
68
+ export LINEAR_WEBHOOK_SECRET=... LINEAR_API_KEY=lin_api_...
69
+ export MUSTER_SANDBOX_URL=https://board.example.com/api/board
70
+ export VERCEL_TOKEN=... VERCEL_TEAM_ID=... VERCEL_PROJECT_ID=...
71
+ export GITHUB_APP_ID=123456 GITHUB_APP_KEY_FILE=~/.config/muster/app.pem
72
+ export ANTHROPIC_API_KEY=sk-ant-...
73
+ mu serve --module "$PWD/templates/queue/board.ts" --allow-host board.example.com
74
+ ```
75
+
76
+ Use `MUSTER_SANDBOX_URL`, not `MUSTER_URL`. The watchers' scripts run `mu` on
77
+ the board's file here; with `MUSTER_URL` set they would go to the server
78
+ instead, with no token, and be refused. Point Linear's webhook at
79
+ `https://board.example.com/api/board/webhooks/lin`, as
80
+ [Linear](../02-sync/03-linear.md) says, and cap what the cards may cost:
81
+
82
+ ```bash
83
+ mu budget cards 10
84
+ mu workflow list
85
+ ```
86
+
87
+ ## How a card goes
88
+
89
+ 1. An issue in the team gets the label `agent`, when it is made or later. It
90
+ arrives as a thread in `cards` with `tag.agent=agent`.
91
+ 2. Within a few seconds the watcher `card-start` runs `start.sh` with the
92
+ thread's ID, as the profile `intake`. The script sets `started=yes` on the
93
+ card only if it still has `tag.agent=agent` and has no `started`, in one
94
+ write, and then asks for the `card` workflow on it. Any later wake, from a
95
+ comment or the daemon's own reply, finds `started` set and does nothing.
96
+ 3. The daemon makes three tasks in `cards/card-<n>`: `spec`, `work`, which
97
+ needs the spec, and `review`, which needs the work. The spec task quotes
98
+ the card's text as content, not instructions; the work and review tasks
99
+ quote the spec's result the same way, and the review the work's summary,
100
+ filled in when the worker takes each. One worker takes them in turn, each
101
+ in its own Vercel sandbox; only the work task's change is pushed to
102
+ `mu/task-<id>` and opened as a pull request.
103
+ 4. The card gets two replies, which go to Linear as comments: `started card:
104
+ 3 tasks in cards/card-<n>`, and once the tasks have ended, a summary with
105
+ each task's result and the pull request. On the board the first reply also
106
+ says where each task is, as the run goes; Linear keeps it as it was first
107
+ written, since edits don't go to Linear.
108
+
109
+ The run's tasks are not sent to Linear: only `cards` is mapped, and
110
+ `cards/card-<n>` is another channel.
111
+
112
+ ## A card you post yourself
113
+
114
+ A card needs no issue. Post it with the label, and with `--no-sync`, so it
115
+ doesn't open an issue in Linear: that issue would have no `agent` label, and
116
+ its next update would take `tag.agent` off the card.
117
+
118
+ ```bash steps
119
+ mu post cards "Make the footer show the current year" --label tag.agent=agent --no-sync
120
+ mu read cards --label tag.agent=agent
121
+ ```
122
+
123
+ This is what `start.sh` writes as its gate. Written a second time it fails
124
+ with `label_conflict`, which is how the script knows the card has started:
125
+
126
+ ```bash steps
127
+ mu label 1 started=yes --if tag.agent=agent --if-unset started --as intake
128
+ ```
129
+
130
+ ## When it needs you
131
+
132
+ A worker that can't go on without a decision blocks its task with one line on
133
+ where things stand, then `->`, the decision it needs and what it recommends.
134
+ The watcher `needs-me` runs `notify.sh` with the task's ID: a macOS
135
+ notification, or, with `NOTIFY_CMD` in the daemon's environment, your own
136
+ command, given one line. Neither gets anything the task says.
137
+
138
+ ```bash
139
+ mu read 14
140
+ ./answer.sh 14 "SSO first."
141
+ ```
142
+
143
+ `answer.sh` unblocks the task, then posts your answer on it. The unblock is
144
+ the gate: of two answers to one task, only the one whose unblock changed it
145
+ goes on, and an answer the board refuses posts nothing. Then, since the run's
146
+ own worker stops after ten idle minutes, it starts a worker that takes the
147
+ run's ready tasks one after another, the answered one first, held to that
148
+ run's tasks as the daemon's workers are: same runner, agent, repository and
149
+ `--push` as `workflows.json`. It starts none while a worker of the run is
150
+ still going on this machine; that one takes the task.
151
+
152
+ Run it as yourself, with no `--as` and no `MUSTER_PROFILE`: the run's tasks
153
+ are the daemon's, and only the board's owner with no profile may unblock
154
+ them. Run it where `mu serve` runs, with the same `MUSTER_SANDBOX_URL`,
155
+ Vercel, GitHub App and model settings in your shell: it starts the worker
156
+ itself, and stays until the worker ends, since a `--push` run's change is
157
+ pushed from here. If the worker ends badly, the script prints the `mu run`
158
+ line that runs what is left.
159
+
160
+ ## When not to
161
+
162
+ - For work that needs a back-and-forth: the steps are fixed, spec, work and
163
+ review, and the review only comments. Nothing is sent back for a second
164
+ round.
165
+ - For a card whose text you wouldn't hand a stranger's agent: see below.
166
+ - For a board other people's agents reach with tokens: the watchers run on
167
+ the board's own machine, as its owner.
168
+
169
+ ## What a card can reach
170
+
171
+ A card's text is written by whoever filed it, and it steers agents that can
172
+ push. Know what a run reaches before you map a team:
173
+
174
+ - **Who starts one.** Anyone who can label an issue in the mapped team, or
175
+ post or label a thread in `cards`, starts a run. The run is asked for by
176
+ `intake`, the watcher's profile, so the workflow's `who` doesn't check the
177
+ card's author.
178
+ - **The repository.** The work step's sandbox pushes: its change goes to
179
+ `mu/task-<id>` in the workflow's repository, with a pull request. The spec
180
+ and review steps set `push: false`, so whatever their agents change is
181
+ never pushed. The worker reads that from what the daemon made each task
182
+ with, never from its labels now, so an agent that relabels a task changes
183
+ nothing.
184
+ - **CI.** That pull request runs your CI on the agent's code, with whatever
185
+ secrets CI gives a branch of the same repository. Keep secrets away from
186
+ pull-request jobs, or require approval before they run.
187
+ - **Linear.** The run's summary quotes each task's result, which an agent
188
+ wrote from the card, as a comment on the issue, where its author reads it.
189
+ - **What it can't reach.** The sandbox holds no board credential of yours, no
190
+ GitHub token and no model key; its token reaches the run's channel only.
191
+
192
+ The spec task quotes the card as content, defused. The spec's result was
193
+ written by an agent that read the card, so the work and review tasks quote it
194
+ the same way, with `{steps.spec.result}`: under a line that says whose it is,
195
+ in a fence nothing in it can close, with `@`, `<`, `>` and Markdown links
196
+ defused. The review quotes the work's summary too. A fence marks what is
197
+ content; it can't stop an agent that is steered anyway. Three things still
198
+ reach a later step unfenced: the work's diff, which the review downloads and
199
+ reads; anything an agent chooses to read itself with `mu read`; and a later
200
+ task's own text, which an earlier step's agent may edit, since its token may
201
+ post in the run's channel. The board then holds that task as `edited`, and
202
+ `needs-me` pings you. `answer.sh` won't answer it: read what changed, and
203
+ unblock it yourself only if it is safe. Even then its worker doesn't fill
204
+ results into text it didn't write, and holds it again as `workflow.edited`.
205
+ A step's result is quoted only when the run's own worker completed it: an
206
+ agent that claimed and completed another step itself, with its sandbox's
207
+ token, gets a `no result` note in the next task instead. A result is quoted
208
+ once, when the task is first taken: a task reopened after a step it quotes
209
+ was done again keeps the old quote.
210
+
211
+ ## What goes wrong
212
+
213
+ - **The request fails.** `start.sh` leaves `started` set, so a request that
214
+ went through before the error doesn't start a second run, and replies on
215
+ the card, on the board only, with the retry: `mu label <id> --unset started`.
216
+ If the daemon refuses the request, it says why on the card itself.
217
+ - **A label taken off.** Before the watcher looked, nothing starts. After a
218
+ run started, it goes on: cancel its tasks with `mu tasks cancel`.
219
+ - **A script keeps failing.** The watcher tries the same event again, with a
220
+ growing wait, and after five tries says so on the card or task, once.
221
+ - **The board was down.** With `LINEAR_API_KEY` set, `mu serve` catches up
222
+ when it starts again: an issue made meanwhile arrives with its labels, and
223
+ an `agent` label added meanwhile to a card it has is brought in, and either
224
+ starts the card, whatever state the issue is in, closed included: the
225
+ budget on `cards` is the cap. Without a key there is no catch-up: an issue
226
+ made while the board was down never arrives, and a label added meanwhile
227
+ to a card it has arrives with the issue's next update.
228
+ - **An issue from before sync was set up.** Labelling it `agent` starts the
229
+ card: Linear's update carries the whole issue, so its thread starts with
230
+ the title, description and labels, as a new issue's would. If someone
231
+ commented on it first, after sync was set up, the thread started from that
232
+ comment, which carries only the title: the card then runs on the title
233
+ alone. See [Linear](../02-sync/03-linear.md#an-issue-from-before-sync).
234
+ - **A long card.** The spec task quotes the first 2,000 characters.
235
+ - **A step with no result.** The next task says so where the result would
236
+ be: `(No result from step "spec", #12: it completed without one.)`.
237
+ - **A task the worker couldn't fill.** If the quoted results make its text
238
+ longer than the board takes, the worker fails the task with `couldn't
239
+ quote the earlier steps' results into it`, and runs no agent on it.
240
+ - **Files on a card** don't reach the sandbox: the worker's token reaches
241
+ the run's channel only.
242
+ - **The review sees no checkout of the change.** Its sandbox clones the
243
+ default branch, and the pushed branch isn't there. The work step attaches
244
+ its diff to a reply on its task, and the review reads that; if the work
245
+ step didn't, the review says so and reviews nothing.
246
+ - **A label write whose answer was lost.** Over HTTP, `start.sh`'s label is
247
+ keyed by the event that woke it, so the daemon's retry gets the same
248
+ answer and the card still starts. If new activity lands on the card before
249
+ that retry, the retry has another key and finds `started` set: start it
250
+ with `mu label <id> --unset started`.
251
+ - **A usage limit.** The worker stops and the task fails; the summary says so.
252
+ - **`answer.sh` says `isn't yours to change`.** It ran with a profile: unset
253
+ `MUSTER_PROFILE`.
254
+
255
+ ## Not tried live
256
+
257
+ The template is covered by tests: a Linear issue starting a run through the
258
+ module's watchers, the real scripts and the daemon's workflow tick; the
259
+ module run by `mu daemon run --module`; and `mu serve --module` taking
260
+ Linear's webhook and commenting back on the issue, with workers and Linear's
261
+ API as stand-ins. It has not been run against Linear, Vercel and GitHub together.
@@ -0,0 +1,225 @@
1
+ ---
2
+ title: A feedback loop
3
+ description: Feedback from Slack, Linear, GitHub or your own app becomes a card; an agent makes the change as a pull request; a comment on the card starts another round on the same pull request.
4
+ ---
5
+
6
+ ## Who this is for
7
+
8
+ You build something with agents and want to steer it from wherever you are:
9
+ a report in Slack, a Linear issue, a Notion page, a button in the app itself. Each report
10
+ should become a card with a proper title and spec, the change should come
11
+ back as a pull request with screenshots, and a reply on the card should send
12
+ it round again, on the same pull request, until it is right.
13
+
14
+ **You need:** what [A card queue](./19-a-card-queue.md) needs (muster where
15
+ the board is, `mu serve` behind a tunnel or a proxy, a Vercel project for the
16
+ sandboxes, a GitHub App on the repository, a model key), and the keys for
17
+ the sources you sync.
18
+
19
+ ## The parts
20
+
21
+ `templates/loop` is a board module and a workflow file:
22
+
23
+ ```mermaid
24
+ flowchart LR
25
+ S[Slack, Linear, GitHub, Notion, app, inspector] -->|a thread| C[card in cards/source, held triage]
26
+ C -->|intake| T[triage run: a title and a spec]
27
+ T -->|promote| R[the spec, a reply on the card]
28
+ R -->|trusted author, or approved=yes| W[card run: spec, work, review]
29
+ W -->|work pushes mu/task-id| P[pull request]
30
+ W -->|settled| C
31
+ C -->|a trusted reply| W
32
+ ```
33
+
34
+ - **A card is a thread and a task.** Its hold says where it is: `backlog`
35
+ while it is parked, `planning` while an agent shapes it with you, `triage`, `approval`, `working`,
36
+ `declined` when the triage made no card, `done` when its run was approved
37
+ but it couldn't be completed, or `edited` when its author changed the
38
+ report.
39
+ - **Each source has its own channel** under `cards/`: `cards/slack`,
40
+ `cards/linear`, `cards/github`, `cards/notion`, `cards/app`. A card's runs are in channels
41
+ under its own, so the card is what Slack and Linear mirror.
42
+ - **The triage agent writes the card.** It reads the report and the
43
+ repository, changes nothing, and completes with a title on the first line,
44
+ then what to change and how to check it. The spec goes on the card as a
45
+ reply, written as `triage`, only when the triage run's own worker completed
46
+ it (`workflowResult`).
47
+ - **The card run quotes that reply** with `{on.text}`, fenced as content,
48
+ not instructions. The triage step alone reads the report.
49
+
50
+ ## Set it up
51
+
52
+ ```bash
53
+ cp templates/loop/workflows.json ~/.config/muster/
54
+ export LOOP_TRUSTED=slack:user:U0123,gh:user:octocat
55
+ mu serve --module "$PWD/templates/loop/board.ts" --allow-host board.example.com
56
+ ```
57
+
58
+ Edit `board.ts` for your Slack channel's ID, your Linear team's key and your
59
+ repository, and `workflows.json` for your repository. Put the settings in the
60
+ environment `mu serve` starts with, as for [a card queue](./19-a-card-queue.md#set-it-up),
61
+ with the secrets `board.ts` names in `env()`.
62
+
63
+ ## Who may start work
64
+
65
+ `LOOP_TRUSTED` is a comma-separated list of actor IDs: a Slack user is
66
+ `<sync key>:user:<their ID>`, an app posting with a token you made is
67
+ `<your principal>+<its profile>`. You, as yourself with no profile, always
68
+ are. Read it each time a card moves, so a change takes effect at once.
69
+
70
+ - **A trusted author's report** is worked as soon as it is triaged, as long
71
+ as it is as they first wrote it.
72
+ - **Anyone else's** waits, held `approval`, and you are told. Someone trusted
73
+ labels it `approved=yes` (`mu label 12 approved=yes`, or in the inspector).
74
+ A label by anyone else does nothing.
75
+ - **An author sync couldn't name** is never trusted, nor a GitHub author:
76
+ GitHub's sync names one by login, which can change hands, so a GitHub
77
+ issue always waits for an approval.
78
+ - **The work never reads the report.** The card run quotes the spec that was
79
+ triaged (and approved, where it had to be) with `{on.text}`, never the
80
+ report itself.
81
+
82
+ ## Stages
83
+
84
+ A card starts where its source says. Only a ready card is triaged; a parked
85
+ one waits, and nothing runs for it.
86
+
87
+ | Stage | Notion Status | Linear state | Anywhere else: `stage` label | The card |
88
+ | --- | --- | --- | --- | --- |
89
+ | backlog | Not started | Backlog | `stage=backlog` | held `backlog` |
90
+ | planning | Planning | Triage | `stage=planning` | held `planning`, with a planner |
91
+ | ready | Ready | Todo | `stage=ready`, or none | triaged, then `approval` or `working` |
92
+ | working | In progress, written by the loop | In Progress, written by the loop | | held `working` |
93
+ | done | Done, written by the loop | Done, written by the loop | | completed |
94
+ | canceled | | Canceled, Duplicate | | canceled |
95
+
96
+ - **The source's status moves the card.** Move a Notion page to Ready, or a
97
+ Linear issue to Todo, and its card is triaged. Move it back to Not started
98
+ or Backlog and it is parked again, unless a run is going: then it stays
99
+ `working`, and the card says so.
100
+ - **Only the source's own sync moves it.** A card's source is read from how
101
+ the board recorded its first message, never from a label. A `state` label
102
+ anyone else sets moves nothing, and is never read later.
103
+ - **Sources without a status** (Slack, GitHub, your app, the inspector) are
104
+ ready when they come in. Someone trusted parks one with
105
+ `mu label 12 stage=backlog`, and starts it with `stage=ready`. Anyone
106
+ else's `stage` label does nothing.
107
+ - **A status the loop doesn't know** parks the card.
108
+ - **The loop writes the status back:** In progress when the work starts, and
109
+ Done when the review completes with `approve`, which also completes the
110
+ card. A write that fails is said on the card, as `loop`, and the card goes
111
+ on. Notion's integration needs the "Update content" capability for it.
112
+ Linear's status is written by the same OAuth app its sync comments as
113
+ (`LINEAR_CLIENT_ID`, `LINEAR_CLIENT_SECRET`), even when a `LINEAR_API_KEY`
114
+ is also set; with no app, by that key. The loop asks for the app's token
115
+ with its sync's scopes: Linear ends an app's earlier tokens when one is
116
+ asked for with other scopes, the sync's among them. A sync given its own
117
+ `scopes` needs the same `scopes` in its `SOURCES` entry.
118
+ - **A parked card that is edited** stays parked, and is triaged from its new
119
+ text when it is moved to ready.
120
+
121
+ The mapping is `SOURCES` in `board.ts`, by sync key. `LOOP_STAGES` replaces
122
+ an entry with JSON in the same shape:
123
+
124
+ ```bash
125
+ export LOOP_STAGES='{"nt":{"type":"notion","token":"NOTION_TOKEN","stages":{"inbox":"backlog","go":"ready"},"write":{"working":"doing","done":"shipped"}}}'
126
+ ```
127
+
128
+ ## Planning
129
+
130
+ A card in planning gets an agent that shapes it with the people who asked,
131
+ before anything is built: the `planning` workflow, one step that reads the
132
+ report and the repository and changes nothing.
133
+
134
+ - **It answers on the card,** as `planner`: its questions, numbered, then the
135
+ card as it stands (a title, what to change, how to check it), and how it
136
+ would split a change too big for one pull request.
137
+ - **Each trusted reply is its next round,** on the same task: the comments go
138
+ to it, fenced as content, and it answers again. Replies made while it
139
+ works wait for its answer. Anyone else's replies aren't shown to it.
140
+ - **Move it to ready** (Ready, Todo, or `stage=ready`) when the card is
141
+ right. The triage writes the spec from the newest plan and what was said
142
+ on the card since it, and what was said in planning starts no round of the
143
+ work.
144
+ - **Edit the report** in planning and a new planner starts from the new
145
+ text; the old plan is not shown to the triage.
146
+ - One planner per card. Moved back to planning later, it goes on when
147
+ someone replies.
148
+
149
+ ## Related and duplicate cards
150
+
151
+ Each triage is shown the other cards, newest first, by number, hold and
152
+ first line, as many as fit in what a run quotes (2,000 characters, after the
153
+ plan when there is one). The list is a reply on the card, written as `cards` and kept on
154
+ the board: it never reaches Slack, Linear or Notion. The triage step quotes
155
+ it with `{on.text}`, as content.
156
+
157
+ - **Related:** a triage result that starts with `related: #36, #16` labels
158
+ the card `related=36,16` and says so on the card, by number only: the card
159
+ is mirrored where it came from, and another card's words may be private to
160
+ its own source. When both cards are
161
+ Linear issues of the same sync, the issues are related in Linear too.
162
+ - **The same request:** `duplicate-of: #36` holds the card `duplicate`, with
163
+ its spec on it, and you are told. Someone trusted labels it `approved=yes`
164
+ to work it anyway, or you cancel it. A duplicate the triage wrote no card
165
+ for is triaged again when it is moved to ready.
166
+ - **A public source sees only public cards.** What a triage writes is
167
+ mirrored where its card came from, so a card from a public source (GitHub
168
+ issues; `LOOP_PUBLIC` lists the channels, comma separated) is shown only
169
+ other public cards. A card from Slack, Linear, Notion or your app sees all.
170
+ - **Only cards of this loop count.** A number that isn't another card's (the
171
+ card itself, a run's task, any other thread) is left out. The lines are
172
+ taken off the spec.
173
+ - **Nothing is split.** A report that asks for several things is one card;
174
+ the spec can list follow-ups for you to file.
175
+
176
+ ## Another round
177
+
178
+ A reply on the card by someone trusted, once its run has ended, is another
179
+ round. The comment goes to the work task, the work and then its review are
180
+ sent back (`mu tasks reopen <id> --round`), and a worker takes them. The work
181
+ starts from its branch: see
182
+ [Another round on the same pull request](./06-sandboxed-agents.md#another-round-on-the-same-pull-request).
183
+ A comment made while a round runs waits for it to end. A round's reply on
184
+ the card says which comments it took; comments too long for one round wait
185
+ for the next. A card that is done comes back the
186
+ same way: a trusted reply reopens it, and its status is In progress again.
187
+
188
+ ## What you see
189
+
190
+ - **The card** in Slack, Linear or GitHub, wherever the report came from:
191
+ the spec, the run's start and summary, the screenshots of each round, and
192
+ the pull request's address.
193
+ - **A line from `NOTIFY_CMD`**, when it is set: a card that needs your
194
+ approval, a task blocked on a decision, a round that is done.
195
+ - **The pull request,** one per card, with a commit per round.
196
+
197
+ ## When not to
198
+
199
+ - For a report you wouldn't hand a stranger's agent: approval is per card,
200
+ so read the spec before you approve it.
201
+ - For work that needs several pull requests: a card is one branch.
202
+ - For PR review comments as the trigger: a comment on the pull request
203
+ doesn't start a round yet. Reply on the card.
204
+
205
+ ## What goes wrong
206
+
207
+ - **A round's push is refused** with `push_conflict` when someone pushed to
208
+ the branch while the agent worked. The task says so, and the review waits:
209
+ read the thread, then reopen the work.
210
+ - **A run asked on an edited spec** starts nothing (`asked_message_changed`):
211
+ a card that changed after it was triaged is triaged again.
212
+ - **The triage agent fails** a report that isn't a change to make here, with
213
+ why, in the triage run's summary on the card. The card is held `declined`,
214
+ says so, and you are told. Edit the report, or move it to ready again, to
215
+ try again; or cancel it. A triage whose agent stopped (out of time, a usage
216
+ limit) is declined the same way, and its summary says so.
217
+
218
+ ## Next
219
+
220
+ - [Running the feedback loop](./21-running-the-loop.md): going live,
221
+ approving, answering a blocked task, another round, and what to do when
222
+ something stops.
223
+ - The `loop-card` skill teaches an agent each step (triage, spec, work,
224
+ review): `mu skills install --to ~/.claude/skills` installs it with the
225
+ others.