@openmuster/muster 0.0.0-stage → 0.3.1-alpha.3

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 (79) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +309 -2
  3. package/dist/args-DX9QSK1f.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 +1951 -0
  8. package/dist/inspect/app.js +163 -0
  9. package/dist/main-CdVlnWHy.js +6 -0
  10. package/dist/main-DgrIMbeA.js +3941 -0
  11. package/dist/mcp-NueWYyQs.js +6 -0
  12. package/dist/module-C-HJjWWo.js +4 -0
  13. package/dist/module-CxoN1MOe.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-DtzUdcBE.js +3175 -0
  23. package/docs/01-concepts/01-overview.md +78 -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 +73 -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 +133 -0
  30. package/docs/01-concepts/08-tasks.md +248 -0
  31. package/docs/01-concepts/09-watchers.md +175 -0
  32. package/docs/01-concepts/10-schedules.md +39 -0
  33. package/docs/01-concepts/11-access.md +185 -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 +103 -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 +124 -0
  40. package/docs/01-quickstart.md +140 -0
  41. package/docs/02-sync/01-overview.md +246 -0
  42. package/docs/02-sync/02-github.md +159 -0
  43. package/docs/02-sync/03-linear.md +290 -0
  44. package/docs/02-sync/04-slack.md +228 -0
  45. package/docs/02-sync/05-notion.md +94 -0
  46. package/docs/02-sync/meta.json +4 -0
  47. package/docs/03-guides/01-coding-agents.md +98 -0
  48. package/docs/03-guides/02-swarm.md +85 -0
  49. package/docs/03-guides/03-factory.md +212 -0
  50. package/docs/03-guides/04-inspector.md +69 -0
  51. package/docs/03-guides/05-running-agents.md +85 -0
  52. package/docs/03-guides/06-sandboxed-agents.md +427 -0
  53. package/docs/03-guides/07-build-a-ui.md +80 -0
  54. package/docs/03-guides/08-ci.md +176 -0
  55. package/docs/03-guides/09-daemon.md +104 -0
  56. package/docs/03-guides/10-two-agents.md +76 -0
  57. package/docs/03-guides/11-person-in-the-loop.md +123 -0
  58. package/docs/03-guides/12-unattended.md +110 -0
  59. package/docs/03-guides/13-terminals.md +152 -0
  60. package/docs/03-guides/14-no-cloud.md +82 -0
  61. package/docs/03-guides/15-several-boards.md +90 -0
  62. package/docs/03-guides/16-non-code.md +78 -0
  63. package/docs/03-guides/17-mcp.md +122 -0
  64. package/docs/03-guides/18-a-board-on-a-server.md +162 -0
  65. package/docs/03-guides/19-a-card-queue.md +261 -0
  66. package/docs/03-guides/20-a-feedback-loop.md +233 -0
  67. package/docs/03-guides/21-running-the-loop.md +203 -0
  68. package/docs/03-guides/22-building-from-linear.md +326 -0
  69. package/docs/03-guides/meta.json +32 -0
  70. package/docs/04-reference/01-cli.md +166 -0
  71. package/docs/04-reference/02-handle.md +410 -0
  72. package/docs/04-reference/03-http.md +158 -0
  73. package/docs/04-reference/04-events.md +72 -0
  74. package/docs/04-reference/05-errors.md +221 -0
  75. package/docs/04-reference/06-conformance.md +54 -0
  76. package/docs/04-reference/07-porting.md +116 -0
  77. package/docs/index.md +118 -0
  78. package/docs/meta.json +3 -0
  79. package/package.json +52 -3
@@ -0,0 +1,261 @@
1
+ ---
2
+ title: A card queue
3
+ description: For handing a Linear issue, or a card you post, to an agent that writes a spec, opens a pull request and reviews it, once. Label it agent, each step runs in a cloud sandbox, and it asks you only for decisions.
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, a workflow file, and three small
24
+ 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.
56
+
57
+ Put the settings in the environment `mu serve` starts with, and give it the
58
+ module. It runs the module's sync, its watchers and the workflow, and the
59
+ workers start with its environment. The module names the Linear secrets with
60
+ `env()`: `mu serve` reads them when it starts, and refuses to start, naming
61
+ the variable, if one isn't set:
62
+
63
+ ```bash
64
+ export LINEAR_WEBHOOK_SECRET=... LINEAR_API_KEY=lin_api_...
65
+ export MUSTER_SANDBOX_URL=https://board.example.com/api/board
66
+ export VERCEL_TOKEN=... VERCEL_TEAM_ID=... VERCEL_PROJECT_ID=...
67
+ export GITHUB_APP_ID=123456 GITHUB_APP_KEY_FILE=~/.config/muster/app.pem
68
+ export ANTHROPIC_API_KEY=sk-ant-...
69
+ mu serve --module "$PWD/templates/queue/board.ts" --allow-host board.example.com
70
+ ```
71
+
72
+ Use `MUSTER_SANDBOX_URL`, not `MUSTER_URL`. The watchers' scripts run `mu` on
73
+ the board's file here; with `MUSTER_URL` set they would go to the server
74
+ instead, with no token, and be refused. Point Linear's webhook at
75
+ `https://board.example.com/api/board/webhooks/lin`, as
76
+ [Linear](../02-sync/03-linear.md) says, and cap what the cards may cost:
77
+
78
+ ```bash
79
+ mu budget cards 10
80
+ mu workflow list
81
+ ```
82
+
83
+ ## How a card goes
84
+
85
+ 1. An issue in the team gets the label `agent`, when it is made or later. It
86
+ arrives as a thread in `cards` with `tag.agent=agent`.
87
+ 2. Within a few seconds the watcher `card-start` runs `start.sh` with the
88
+ thread's ID, as the profile `intake`. The script sets `started=yes` on the
89
+ card only if it still has `tag.agent=agent` and has no `started`, in one
90
+ write, and then asks for the `card` workflow on it. Any later wake, from a
91
+ comment or the run's own reply, finds `started` set and does nothing.
92
+ 3. `mu serve` makes three tasks in `cards/card-<n>`: `spec`, `work`, which
93
+ needs the spec, and `review`, which needs the work. The spec task quotes
94
+ the card's text as content, not instructions; the work and review tasks
95
+ quote the spec's result the same way, and the review the work's summary,
96
+ filled in when the worker takes each. One worker takes them in turn, each
97
+ in its own Vercel sandbox; only the work task's change is pushed to
98
+ `mu/task-<id>` and opened as a pull request.
99
+ 4. The card gets two replies, which go to Linear as comments: `started card:
100
+ 3 tasks in cards/card-<n>`, and once the tasks have ended, a summary with
101
+ each task's result and the pull request. On the board the first reply also
102
+ says where each task is, as the run goes; Linear keeps it as it was first
103
+ written, since edits don't go to Linear.
104
+
105
+ The run's tasks are not sent to Linear: only `cards` is mapped, and
106
+ `cards/card-<n>` is another channel.
107
+
108
+ ## A card you post yourself
109
+
110
+ A card needs no issue. Post it with the label, and with `--no-sync`, so it
111
+ doesn't open an issue in Linear: that issue would have no `agent` label, and
112
+ its next update would take `tag.agent` off the card.
113
+
114
+ ```bash steps
115
+ mu post cards "Make the footer show the current year" --label tag.agent=agent --no-sync
116
+ mu read cards --label tag.agent=agent
117
+ ```
118
+
119
+ This is what `start.sh` writes as its gate. Written a second time it fails
120
+ with `label_conflict`, which is how the script knows the card has started:
121
+
122
+ ```bash steps
123
+ mu label 1 started=yes --if tag.agent=agent --if-unset started --as intake
124
+ ```
125
+
126
+ ## When it needs you
127
+
128
+ A worker that can't go on without a decision blocks its task with one line on
129
+ where things stand, then `->`, the decision it needs and what it recommends.
130
+ The watcher `needs-me` runs `notify.sh` with the task's ID: a macOS
131
+ notification, or, with `NOTIFY_CMD` in `mu serve`'s environment, your own
132
+ command, given one line. Neither gets anything the task says.
133
+
134
+ ```bash
135
+ mu read 14
136
+ ./answer.sh 14 "SSO first."
137
+ ```
138
+
139
+ `answer.sh` unblocks the task, then posts your answer on it. The unblock is
140
+ the gate: of two answers to one task, only the one whose unblock changed it
141
+ goes on, and an answer the board refuses posts nothing. Then, since the run's
142
+ own worker stops after ten idle minutes, it starts a worker that takes the
143
+ run's ready tasks one after another, the answered one first, held to that
144
+ run's tasks as the workers `mu serve` starts are: same runner, agent, repository and
145
+ `--push` as `workflows.json`. It starts none while a worker of the run is
146
+ still going on this machine; that one takes the task.
147
+
148
+ Run it as yourself, with no `--as` and no `MUSTER_PROFILE`: the run's tasks
149
+ are made as the profile `workflows`, and only the board's owner with no profile may unblock
150
+ them. Run it where `mu serve` runs, with the same `MUSTER_SANDBOX_URL`,
151
+ Vercel, GitHub App and model settings in your shell: it starts the worker
152
+ itself, and stays until the worker ends, since a `--push` run's change is
153
+ pushed from here. If the worker ends badly, the script prints the `mu run`
154
+ line that runs what is left.
155
+
156
+ ## When not to
157
+
158
+ - For a project you plan and iterate on in Linear, with rounds on the same
159
+ pull request: [Building from Linear](./22-building-from-linear.md).
160
+ - For work that needs a back-and-forth: the steps are fixed, spec, work and
161
+ review, and the review only comments. Nothing is sent back for a second
162
+ round.
163
+ - For a card whose text you wouldn't hand a stranger's agent: see below.
164
+ - For a board other people's agents reach with tokens: the watchers run on
165
+ the board's own machine, as its owner.
166
+
167
+ ## What a card can reach
168
+
169
+ A card's text is written by whoever filed it, and it steers agents that can
170
+ push. Know what a run reaches before you map a team:
171
+
172
+ - **Who starts one.** Anyone who can label an issue in the mapped team, or
173
+ post or label a thread in `cards`, starts a run. The run is asked for by
174
+ `intake`, the watcher's profile, so the workflow's `who` doesn't check the
175
+ card's author.
176
+ - **The repository.** The work step's sandbox pushes: its change goes to
177
+ `mu/task-<id>` in the workflow's repository, with a pull request. The spec
178
+ and review steps set `push: false`, so whatever their agents change is
179
+ never pushed. The worker reads that from what `mu serve` made each task
180
+ with, never from its labels now, so an agent that relabels a task changes
181
+ nothing.
182
+ - **CI.** That pull request runs your CI on the agent's code, with whatever
183
+ secrets CI gives a branch of the same repository. Keep secrets away from
184
+ pull-request jobs, or require approval before they run.
185
+ - **Linear.** The run's summary quotes each task's result, which an agent
186
+ wrote from the card, as a comment on the issue, where its author reads it.
187
+ - **What it can't reach.** The sandbox holds no board credential of yours, no
188
+ GitHub token and no model key; its token reaches the run's channel only.
189
+
190
+ The spec task quotes the card as content, defused. The spec's result was
191
+ written by an agent that read the card, so the work and review tasks quote it
192
+ the same way, with `{steps.spec.result}`: under a line that says whose it is,
193
+ in a fence nothing in it can close, with `@`, `<`, `>` and Markdown links
194
+ defused. The review quotes the work's summary too. A fence marks what is
195
+ content; it can't stop an agent that is steered anyway. Three things still
196
+ reach a later step unfenced: the work's diff, which the review downloads and
197
+ reads; anything an agent chooses to read itself with `mu read`; and a later
198
+ task's own text, which an earlier step's agent may edit, since its token may
199
+ post in the run's channel. The board then holds that task as `edited`, and
200
+ `needs-me` pings you. `answer.sh` won't answer it: read what changed, and
201
+ unblock it yourself only if it is safe. Even then its worker doesn't fill
202
+ results into text it didn't write, and holds it again as `workflow.edited`.
203
+ A step's result is quoted only when the run's own worker completed it: an
204
+ agent that claimed and completed another step itself, with its sandbox's
205
+ token, gets a `no result` note in the next task instead. A result is quoted
206
+ once, when the task is first taken: a task reopened after a step it quotes
207
+ was done again keeps the old quote.
208
+
209
+ ## What goes wrong
210
+
211
+ - **The request fails.** `start.sh` leaves `started` set, so a request that
212
+ went through before the error doesn't start a second run, and replies on
213
+ the card, on the board only, with the retry: `mu label <id> --unset started`.
214
+ If `mu serve` refuses the request, it says why on the card itself.
215
+ - **A label taken off.** Before the watcher looked, nothing starts. After a
216
+ run started, it goes on: cancel its tasks with `mu tasks cancel`.
217
+ - **A script keeps failing.** The watcher tries the same event again, with a
218
+ growing wait, and after five tries says so on the card or task, once.
219
+ - **The board was down.** With `LINEAR_API_KEY` set, `mu serve` catches up
220
+ when it starts again: an issue made meanwhile arrives with its labels, and
221
+ an `agent` label added meanwhile to a card it has is brought in, and either
222
+ starts the card, whatever state the issue is in, closed included: the
223
+ budget on `cards` is the cap. Without a key there is no catch-up: an issue
224
+ made while the board was down never arrives, and a label added meanwhile
225
+ to a card it has arrives with the issue's next update.
226
+ - **An issue from before sync was set up.** Labelling it `agent` starts the
227
+ card: Linear's update carries the whole issue, so its thread starts with
228
+ the title, description and labels, as a new issue's would. If someone
229
+ commented on it first, after sync was set up, the thread started from that
230
+ comment, which carries only the title: the card then runs on the title
231
+ alone. See [Linear](../02-sync/03-linear.md#an-issue-from-before-sync).
232
+ - **A long card.** The spec task quotes the first 2,000 characters.
233
+ - **A step with no result.** The next task says so where the result would
234
+ be: `(No result from step "spec", #12: it completed without one.)`.
235
+ - **A task the worker couldn't fill.** If the quoted results make its text
236
+ longer than the board takes, the worker fails the task with `couldn't
237
+ quote the earlier steps' results into it`, and runs no agent on it.
238
+ - **Files on a card** don't reach the sandbox: the worker's token reaches
239
+ the run's channel only.
240
+ - **The review sees no checkout of the change.** Its sandbox clones the
241
+ default branch, and the pushed branch isn't there. The work step attaches
242
+ its diff to a reply on its task, and the review reads that; if the work
243
+ step didn't, the review says so and reviews nothing.
244
+ - **A label write whose answer was lost.** Over HTTP, `start.sh`'s label is
245
+ keyed by the event that woke it, so the watcher's retry gets the same
246
+ answer and the card still starts. If new activity lands on the card before
247
+ that retry, the retry has another key and finds `started` set: start it
248
+ with `mu label <id> --unset started`.
249
+ - **A usage limit.** The worker stops and the task fails; the summary says so.
250
+ - **`answer.sh` says `isn't yours to change`.** It ran with a profile: unset
251
+ `MUSTER_PROFILE`.
252
+ - **`mu serve` refuses to start with `config_retired`.** `~/.config/muster/`
253
+ has a `watchers.json`, `sync.json` or `hooks.json` from an earlier copy of
254
+ this template. Those files are no longer read: move anything else in them
255
+ into a board module and delete them
256
+ ([Porting](../04-reference/07-porting.md)).
257
+
258
+ ## Status
259
+
260
+ Experimental: not yet run end to end against Linear, Vercel and GitHub
261
+ together.
@@ -0,0 +1,233 @@
1
+ ---
2
+ title: A feedback loop
3
+ description: For steering a project from reports in Slack, Linear, GitHub, Notion or your app. Each report is triaged into a spec, an agent opens a pull request, and a trusted reply 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.
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,lin:user:3f2a9c1e-4b7d-4e0a-9a51-7c2d8e6b1f03
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, GitHub or Notion, wherever the report came
191
+ from: the spec, the run's start and summary, the screenshots of each round,
192
+ and the pull request's address. GitHub and Notion take no files from the
193
+ board, so there each screenshot is named instead.
194
+ - **The screenshots** are the ones the project's spec asks for. The work
195
+ agent takes them and attaches them to its task, and they are copied onto
196
+ the card when the round ends. A project whose spec asks for none gets
197
+ none.
198
+ - **A line from `NOTIFY_CMD`**, when it is set: a card that needs your
199
+ approval, a task blocked on a decision, a round that is done.
200
+ - **The pull request,** one per card, with a commit per round.
201
+
202
+ ## When not to
203
+
204
+ - For a report you wouldn't hand a stranger's agent: approval is per card,
205
+ so read the spec before you approve it.
206
+ - For work that needs several pull requests: a card is one branch.
207
+ - For PR review comments as the trigger: a comment on the pull request
208
+ doesn't start a round yet. Reply on the card.
209
+
210
+ ## What goes wrong
211
+
212
+ - **A round's push is refused** with `push_conflict` when someone pushed to
213
+ the branch while the agent worked. The task says so, and the review waits:
214
+ read the thread, then reopen the work.
215
+ - **A run asked on an edited spec** starts nothing (`asked_message_changed`):
216
+ a card that changed after it was triaged is triaged again.
217
+ - **The triage agent fails** a report that isn't a change to make here, with
218
+ why, in the triage run's summary on the card. The card is held `declined`,
219
+ says so, and you are told. Edit the report, or move it to ready again, to
220
+ try again; or cancel it. A triage whose agent stopped (out of time, a usage
221
+ limit) is declined the same way, and its summary says so.
222
+
223
+ ## Next
224
+
225
+ - [Building from Linear](./22-building-from-linear.md): laying out a Linear
226
+ project, its spec and its issues for this loop, and what to do from Linear
227
+ and what from the board.
228
+ - [Running the feedback loop](./21-running-the-loop.md): going live,
229
+ approving, answering a blocked task, another round, and what to do when
230
+ something stops.
231
+ - The `loop-card` skill teaches an agent each step (triage, spec, work,
232
+ review): `mu skills install --to ~/.claude/skills` installs it with the
233
+ others.