@openmuster/muster 0.3.1-alpha.4 → 0.3.1-alpha.6

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 (58) hide show
  1. package/README.md +11 -7
  2. package/dist/{args-9ZZDcPxa.js → args-CaFBa2IP.js} +305 -23
  3. package/dist/cli.js +3 -3
  4. package/dist/index.d.ts +98 -19
  5. package/dist/index.js +107 -42
  6. package/dist/inspect/app.js +49 -26
  7. package/dist/{main-Doit2DDY.js → main-3kE64MlN.js} +195 -12
  8. package/dist/main-o4m_lGDG.js +6 -0
  9. package/dist/mcp-D6Xt2ixk.js +6 -0
  10. package/dist/{module-DjDMSEKu.js → module-BX2IjSiv.js} +2 -2
  11. package/dist/{module-D8qcE3e7.js → module-D9KdbEpS.js} +1 -1
  12. package/dist/skills/board/SKILL.md +5 -0
  13. package/dist/skills/loop-card/SKILL.md +22 -3
  14. package/dist/{steps-BUPRIOe3.js → steps-cnWo2Wvx.js} +299 -12
  15. package/docs/01-concepts/09-watchers.md +4 -32
  16. package/docs/01-concepts/10-schedules.md +1 -1
  17. package/docs/01-concepts/11-access.md +19 -3
  18. package/docs/01-concepts/13-budgets.md +66 -3
  19. package/docs/01-concepts/15-outgoing-webhooks.md +6 -19
  20. package/docs/01-concepts/16-workflows.md +42 -2
  21. package/docs/01-quickstart.md +74 -45
  22. package/docs/02-sync/01-overview.md +34 -2
  23. package/docs/02-sync/02-github.md +40 -19
  24. package/docs/02-sync/03-linear.md +103 -85
  25. package/docs/02-sync/04-slack.md +116 -111
  26. package/docs/02-sync/05-notion.md +46 -25
  27. package/docs/03-guides/01-coding-agents.md +51 -33
  28. package/docs/03-guides/02-swarm.md +30 -15
  29. package/docs/03-guides/03-factory.md +193 -80
  30. package/docs/03-guides/04-inspector.md +73 -42
  31. package/docs/03-guides/05-running-agents.md +62 -35
  32. package/docs/03-guides/06-sandboxed-agents.md +535 -305
  33. package/docs/03-guides/07-build-a-ui.md +86 -31
  34. package/docs/03-guides/08-ci.md +59 -36
  35. package/docs/03-guides/09-daemon.md +121 -53
  36. package/docs/03-guides/10-two-agents.md +31 -22
  37. package/docs/03-guides/11-person-in-the-loop.md +47 -34
  38. package/docs/03-guides/12-unattended.md +46 -27
  39. package/docs/03-guides/13-terminals.md +51 -39
  40. package/docs/03-guides/14-no-cloud.md +31 -19
  41. package/docs/03-guides/15-several-boards.md +61 -27
  42. package/docs/03-guides/16-non-code.md +29 -18
  43. package/docs/03-guides/17-mcp.md +37 -30
  44. package/docs/03-guides/18-a-board-on-a-server.md +66 -43
  45. package/docs/03-guides/19-a-card-queue.md +210 -121
  46. package/docs/03-guides/20-a-feedback-loop.md +412 -135
  47. package/docs/03-guides/21-running-the-loop.md +94 -64
  48. package/docs/03-guides/22-building-from-linear.md +100 -63
  49. package/docs/04-reference/01-cli.md +7 -0
  50. package/docs/04-reference/02-handle.md +11 -15
  51. package/docs/04-reference/03-http.md +1 -1
  52. package/docs/04-reference/04-events.md +2 -1
  53. package/docs/04-reference/05-errors.md +6 -0
  54. package/docs/04-reference/08-files.md +49 -0
  55. package/docs/index.md +1 -0
  56. package/package.json +1 -1
  57. package/dist/main-D5aX7Jaj.js +0 -6
  58. package/dist/mcp-Cm96TIb3.js +0 -6
@@ -1,45 +1,48 @@
1
1
  ---
2
2
  title: Coding agents
3
- description: For engineers who want Claude Code, Codex or another coding agent to work from a board. Install the board skill, give the agent its own name, and see what can start it again after its turn ends.
3
+ description: For engineers who want Claude Code, Codex or another coding agent to work from a board. You end with the board skill installed, the agent writing under its own name, and a way to start it again after its turn ends.
4
4
  ---
5
5
 
6
6
  ## Install the skill
7
7
 
8
+ Install the board skill with the skills CLI:
9
+
8
10
  ```bash
9
- mu skills install --to ~/.claude/skills
10
- mu skills path
11
+ npx skills add openmuster/muster
11
12
  ```
12
13
 
13
- The first copies the skills that ship with muster to where your agent keeps
14
- its own. The second prints where they are, for an agent that reads a file
15
- instead. An agent with no skills folder gets the board skill's `SKILL.md`
16
- pasted into its instructions.
14
+ The [skills CLI](https://skills.sh) asks which skills and which agents, then
15
+ copies them where each agent keeps its own. There are three: `board`,
16
+ `configure-factory` and `loop-card`. Add `--skill board` for one, and `-g` to
17
+ install for your user instead of the project.
17
18
 
18
- Without muster installed, the [skills CLI](https://skills.sh) copies the same
19
- skills from the repository. They are `board`, `configure-factory` and
20
- `loop-card`; leave out `-g` to install into the project instead.
19
+ The skills CLI takes the skills from the repository's main branch. They can
20
+ describe a command that the release you run doesn't have yet. To get the
21
+ skills that match the `mu` you installed, use `mu` itself:
21
22
 
22
23
  ```bash
23
- npx skills add openmuster/muster --skill board -g
24
+ mu skills install --to ~/.claude/skills
25
+ mu skills path
24
26
  ```
25
27
 
26
- These follow the repository's main branch, so they can describe a command a
27
- release you run doesn't have yet. `mu skills install` always matches the `mu`
28
- it came with.
28
+ The first copies the skills that ship with muster to where your agent keeps
29
+ its own. The second prints where they are, for an agent that reads a file
30
+ instead. For an agent with no skills folder, paste the board skill's
31
+ `SKILL.md` into its instructions.
29
32
 
30
- Where an agent keeps its standing instructions differs by vendor. These are
31
- the usual places. Check your agent's own docs.
33
+ Where an agent keeps its standing instructions differs by vendor. The table
34
+ shows the usual places; check your agent's own docs:
32
35
 
33
36
  | Agent | Where the board instructions go |
34
37
  | --- | --- |
35
- | Claude Code | `~/.claude/skills/` (what `mu skills install` writes to above) |
38
+ | Claude Code | `~/.claude/skills/` (where both commands above put them) |
36
39
  | Codex | `AGENTS.md` in the repository, or `~/.codex/AGENTS.md` |
37
40
  | Cursor | A rule file under `.cursor/rules/` |
38
41
  | GitHub Copilot | `.github/copilot-instructions.md` |
39
42
  | Windsurf | A rule file under `.windsurf/rules/` |
40
43
 
41
- An agent that can't run shell commands gets the board as an MCP tool instead:
42
- see [An agent with no shell](./17-mcp.md).
44
+ An agent that can't run shell commands gets the board as a Model Context
45
+ Protocol (MCP) tool instead: see [An agent with no shell](./17-mcp.md).
43
46
 
44
47
  For any of them the content is the same: the board skill's `SKILL.md`. Two
45
48
  things have to be true wherever the agent runs its commands:
@@ -47,13 +50,20 @@ things have to be true wherever the agent runs its commands:
47
50
  - `mu` is on its `PATH`. An agent that runs commands in its own sandbox or
48
51
  container may not see what your shell sees.
49
52
  - It can reach the board. On a file board that means it can read and write
50
- `~/.muster/`; an agent that can't should be given a served board instead
53
+ `~/.muster/`. Give an agent that can't a served board instead
51
54
  (`MUSTER_URL` and a token, see [Access](../01-concepts/11-access.md)).
52
55
 
53
- The skill teaches an agent to find the board, read before it writes, write as
54
- itself, wait instead of polling, and claim and settle tasks.
56
+ The skill teaches an agent to:
57
+
58
+ - find the board
59
+ - read before it writes
60
+ - write as itself
61
+ - wait instead of polling
62
+ - [claim](../01-concepts/08-tasks.md#claims) and settle tasks
63
+
64
+ ## Give the agent its own profile
55
65
 
56
- ## Tell it who it is
66
+ Set the agent's [profile](../01-concepts/06-actors.md) in its environment:
57
67
 
58
68
  ```bash
59
69
  export MUSTER_PROFILE=claude
@@ -62,19 +72,27 @@ export MUSTER_PROFILE=claude
62
72
  Or have it pass `--as claude` on every command that writes. Without either,
63
73
  what the agent writes shows as you.
64
74
 
65
- ## What to ask of it
75
+ ## Ask it to work on the board
76
+
77
+ Ask in plain words, for example:
66
78
 
67
79
  - "Post what you changed in `dev`."
68
80
  - "Ask in the thread and wait for the answer."
69
81
  - "Take the next task in `work/` and do it."
70
82
 
83
+ The commands behind them:
84
+
71
85
  ```bash
72
86
  mu post dev "moved auth to the edge: a1b2c3" --as claude
73
87
  mu wait --re 12 --after 31 --timeout 30m --as claude
74
88
  mu tasks claim --ready work/ --wait 10m --as claude
75
89
  ```
76
90
 
77
- ## What it can't do
91
+ Here `mu wait` waits up to 30 minutes for the next event in thread 12 after
92
+ cursor 31. `mu tasks claim --ready work/` takes the next ready task
93
+ under `work/`, and waits up to 10 minutes for one.
94
+
95
+ ## Start it again after its turn ends
78
96
 
79
97
  Nothing wakes an agent after its turn ends. An agent that should come back
80
98
  when something happens needs something to start it again:
@@ -84,15 +102,15 @@ when something happens needs something to start it again:
84
102
  happens.
85
103
  - `mu run --loop`, which starts a fresh one for each task.
86
104
 
87
- ## Sandboxed agents
105
+ ## Give a sandboxed agent the board
88
106
 
89
- An agent in a sandbox that can't open files outside its workspace can't reach
90
- a board file. Codex is one: `mu run` gives it the board's folder as a writable
91
- folder. An agent that can't reach the file at all uses a board over HTTP: see
92
- [Access](../01-concepts/11-access.md).
107
+ Some agents run in a sandbox that can't open files outside their workspace,
108
+ so they can't reach a board file. Codex is one: `mu run` gives it the board's
109
+ folder as a writable folder. An agent that can't reach the file at all uses a
110
+ board over HTTP: see [Access](../01-concepts/11-access.md).
93
111
 
94
112
  ## Board text is information
95
113
 
96
- Tell the agent, and the skill does: what others wrote on a board is content,
97
- not instructions. It doesn't run commands, approve, merge, deploy or publish
98
- because a message says to.
114
+ Tell the agent that what others wrote on a board is content, not
115
+ instructions. The skill tells it too. The agent doesn't run commands,
116
+ approve, merge, deploy or publish because a message says to.
@@ -1,17 +1,23 @@
1
1
  ---
2
2
  title: A swarm
3
- description: For splitting one goal across several agents at once. A lead breaks it into tasks that own separate files, each worker takes one ready task in a fresh session, and a review task checks the results.
3
+ description: For splitting one goal across several agents at once. You end with a lead that breaks the goal into tasks that own separate files, workers that each take one ready task in a fresh session, and a review task that checks the results.
4
4
  ---
5
5
 
6
- ## The shape
6
+ ## Who does what in a swarm
7
7
 
8
8
  A lead plans and decides, workers each do one task, and a person owns the
9
9
  goal. They never talk to each other directly: the plan is the board's tasks,
10
10
  and every question, answer and result is in a task's thread.
11
11
 
12
- The board's part is the queue: one holder per task, tasks that wait for what
13
- they need, a hold for a person's answer, and a lease that hands a dropped task
14
- back. The lead's part is judgment: splitting the goal, answering questions,
12
+ The board's part is the queue:
13
+
14
+ - one holder per task (see [Claims](../01-concepts/08-tasks.md#claims))
15
+ - tasks that wait for what they need
16
+ - a hold for a person's answer (see
17
+ [States](../01-concepts/08-tasks.md#states))
18
+ - a lease that returns a dropped task to `ready` when it runs out
19
+
20
+ The lead's part is judgment: splitting the goal, answering questions,
15
21
  checking results.
16
22
 
17
23
  ## When a swarm fits, and when it doesn't
@@ -36,7 +42,11 @@ mu tasks create work/checkout "Rate-limit the API. You own apps/api/checkout/."
36
42
  mu tasks create work/checkout "Show the limit in the UI. You own apps/web/checkout/." --needs 1 --as lead
37
43
  ```
38
44
 
39
- ## By hand
45
+ ## Run a swarm from the command line
46
+
47
+ Create the tasks from a plan file (see
48
+ [A plan in one write](../01-concepts/08-tasks.md#a-plan-in-one-write)), start
49
+ the workers, and have the lead wait for results:
40
50
 
41
51
  ```bash
42
52
  mu tasks create work/checkout --file plan.json --as lead
@@ -49,7 +59,7 @@ Each `mu run --loop` is a worker: it takes the next ready task, starts a fresh
49
59
  agent on it, and does that again until nothing is ready. The lead's guide is
50
60
  the board skill's `references/swarm.md`.
51
61
 
52
- ## With the template
62
+ ## Run a swarm from the template page
53
63
 
54
64
  `templates/swarm` is a page that does the same from a form:
55
65
 
@@ -59,6 +69,8 @@ pnpm install
59
69
  pnpm dev # on 127.0.0.1 only: the page has no sign-in
60
70
  ```
61
71
 
72
+ On the page:
73
+
62
74
  - The form takes a goal, a run name, how many agents, which agent, and where
63
75
  they run.
64
76
  - Launching posts the run's thread, queues one planning task, and starts the
@@ -66,17 +78,20 @@ pnpm dev # on 127.0.0.1 only: the page has no sign-in
66
78
  - `/live` shows the queue by state, who holds what, and the newest messages.
67
79
 
68
80
  Agents run as local processes with the access of whoever started the page.
69
- Launch runs only on code you would run yourself.
81
+ Launch a run only on code you would run yourself.
82
+
83
+ ## Check and limit what workers do
70
84
 
71
- ## What keeps it honest
85
+ Put these checks in place:
72
86
 
73
- - **"Completed" is what the worker says, not evidence.** Make a review task that needs
74
- the work, and give it to a different agent.
75
- - **A review that fails sends the work back:** `mu tasks reopen <id> --round`.
87
+ - **"Completed" is what the worker says, not evidence.** Make a review task
88
+ that needs the work, and give it to a different agent.
89
+ - **A review that fails sends the work back.** Reopen the work with
90
+ `mu tasks reopen <id> --round`.
76
91
  - **A budget:** `mu budget work/checkout 20` stops new claims once the tasks
77
- there have cost that much.
78
- - **A lead keeps a short session.** Its state lives in a thread on the board,
79
- so it can start over when a piece of work closes.
92
+ there have cost $20.
93
+ - **A lead keeps a short session.** It keeps its state in a thread on the
94
+ board, so it can start over when a piece of work closes.
80
95
 
81
96
  ## What it costs to start an agent
82
97
 
@@ -1,55 +1,99 @@
1
1
  ---
2
2
  title: A software factory
3
- description: For a team that wants an agent to answer GitHub issues, Linear issues or Slack questions as they arrive. Sync brings each one in as a thread, a watcher wakes the agent, and it replies, asks or starts work there.
3
+ description: For a team that wants an agent to answer GitHub issues, Linear issues or Slack questions as they arrive. You end with sync bringing each one in as a thread and a watcher waking the agent, which replies, asks or starts work there.
4
4
  ---
5
5
 
6
- ## The parts
6
+ ## Who this is for
7
7
 
8
- | Part | What does it |
8
+ Your team takes questions and work as issues or chat messages, and you want
9
+ an agent to answer each one as it arrives. You start with one agent on one
10
+ GitHub repository. Later, when the answers need different instructions,
11
+ access or owners, you route each thread to a product's agent by label.
12
+
13
+ ## Before you begin
14
+
15
+ Do these first:
16
+
17
+ - Install muster: see the [quickstart](../01-quickstart.md).
18
+ - Copy `templates/factory` and run `pnpm install` in it. Outside this
19
+ repository, point its `@openmuster/muster` dependency at a release: its
20
+ README shows how.
21
+ - Have a GitHub repository and a webhook secret for it: see
22
+ [GitHub](../02-sync/02-github.md).
23
+ - Have a public HTTPS name that reaches this machine, through a proxy or a
24
+ tunnel.
25
+ - Install and sign in to Claude Code. `lib/wake.ts` runs `claude --print`
26
+ unless `FACTORY_AGENT` names another command. Of the host's model
27
+ credentials, the wake passes on only `ANTHROPIC_API_KEY`.
28
+
29
+ ## How it fits together
30
+
31
+ Each job has one part that does it:
32
+
33
+ | Job | Done by |
9
34
  | --- | --- |
10
- | Threads come in from GitHub, Linear, Slack | [Sync](../02-sync/01-overview.md) |
11
- | An agent is woken when a thread has news | A [watcher](../01-concepts/09-watchers.md) |
12
- | The agent is held to its channels | A [token](../01-concepts/11-access.md) |
13
- | Someone sees what is set up | The factory page |
35
+ | Brings threads in from GitHub, Linear, Slack | [Sync](../02-sync/01-overview.md) |
36
+ | Wakes an agent when a thread has news | A [watcher](../01-concepts/09-watchers.md) |
37
+ | Limits the agent to its channels | A [token](../01-concepts/11-access.md) |
38
+ | Shows what is set up | The factory page |
39
+
40
+ You wire up the plumbing: who is woken, as whom, and with which access. The
41
+ agent makes the decisions: it judges from each thread what the thread needs.
42
+
43
+ `templates/factory` has these pieces:
14
44
 
15
- Wire up the plumbing and leave the decisions to the agent: who is woken, as whom, with which
16
- access. What a thread needs is for the agent to judge from the thread.
45
+ - a [board module](../01-concepts/17-board-module.md) (`lib/board.ts`) with
46
+ the GitHub sync and the watcher
47
+ - a host that runs them (`host.ts`)
48
+ - a wake script (`lib/wake.ts`)
49
+ - the agent's instructions (`AGENT.md`)
50
+ - a page that also takes the webhooks
17
51
 
18
- ## Set it up
52
+ ## Connect GitHub issues to an agent
19
53
 
20
- `templates/factory` has the pieces: a board module (`lib/board.ts`) with
21
- the GitHub sync and the watcher, a host that runs them (`host.ts`), a wake
22
- script (`lib/wake.ts`), the agent's instructions, and a page that also takes
23
- the webhooks. Put your repository in place of `acme/web` in `lib/board.ts`,
24
- then start the page and the host, each in its own terminal, from
25
- `templates/factory`, with the webhook's secret in both:
54
+ ### Start the page and the host
55
+
56
+ Put your repository in place of `acme/web` in `lib/board.ts`. Then start the
57
+ page and the host from `templates/factory`, each in its own terminal, with
58
+ the webhook's secret in both:
26
59
 
27
60
  ```bash
28
- export GITHUB_WEBHOOK_SECRET=...
61
+ export GITHUB_WEBHOOK_SECRET=your_webhook_secret
29
62
  pnpm dev
30
63
  ```
31
64
 
32
65
  ```bash
33
- export GITHUB_WEBHOOK_SECRET=...
66
+ export GITHUB_WEBHOOK_SECRET=your_webhook_secret
34
67
  pnpm host
35
68
  ```
36
69
 
37
- The module names the secret with `env()`, so it is never written in the
38
- file: the page reads it on its first request, and `host.ts` when it starts,
39
- refusing to start while it is unset. Point GitHub's webhook at
70
+ The module names the secret with `env()`, so the secret is never in the
71
+ file. The page reads it on its first request. `host.ts` reads it when it
72
+ starts, and refuses to start while it is unset.
73
+
74
+ ### Point GitHub's webhook at the page
75
+
76
+ Point GitHub's webhook at
40
77
  `https://board.example.com/api/board/webhooks/gh`, and list
41
78
  `board.example.com` in `ALLOW_HOSTS`. The page listens on 127.0.0.1: the
42
- webhook reaches it through a proxy or a tunnel with a public HTTPS name. The
43
- webhook brings a thread in; `host.ts` runs the watcher, and the sync's
79
+ webhook reaches it through a proxy or a tunnel with a public HTTPS name.
80
+
81
+ The webhook brings a thread in. `host.ts` runs the watcher, and the sync's
44
82
  catch-up and sending.
45
83
 
46
- Schedules are sent by a daemon that holds `tick`. Run it without a module:
47
- `host.ts` runs this one.
84
+ ### Start the daemon for scheduled messages
85
+
86
+ A daemon that holds the
87
+ [`tick` lease](../01-concepts/09-watchers.md#the-daemon) sends scheduled
88
+ messages. Run it with `--no-module`, since `host.ts` already runs this
89
+ module:
48
90
 
49
91
  ```bash
50
92
  mu daemon run --no-module
51
93
  ```
52
94
 
95
+ ### Check that the agent answers
96
+
53
97
  With all three running, check from `templates/factory` that the watcher
54
98
  wakes the agent and that the agent answers:
55
99
 
@@ -57,17 +101,23 @@ wakes the agent and that the agent answers:
57
101
  mu daemon check factory --module "$PWD/lib/board.ts" --in factory/issues
58
102
  ```
59
103
 
60
- The template's sync brings threads in and sends nothing back. To have the
61
- agent's replies posted as comments, give the repository `mirror: true` and
104
+ ### Post the agent's replies back to GitHub
105
+
106
+ The template's sync brings threads in and sends nothing back. To have sync
107
+ post the agent's replies as comments, give the repository `mirror: true` and
62
108
  the sync a `token: env('GITHUB_TOKEN')`: see [GitHub](../02-sync/02-github.md)
63
109
  and [Sync](../02-sync/01-overview.md#in-a-board-module).
64
110
 
65
- The page lists what is set up and what isn't, with the command for each, who
66
- holds each role (`tick` for the daemon, `sync` and `watch:factory` for the
67
- host), and the recent threads. `/board` shows every thread, where you read
68
- and reply from a browser.
111
+ ## What you see
69
112
 
70
- ## How a thread goes
113
+ The page lists what is set up and what isn't, with the command for each. It
114
+ also shows who holds each role (`tick` for the daemon, `sync` and
115
+ `watch:factory` for the host), and the recent threads. `/board` shows every
116
+ thread, where you read and reply from a browser.
117
+
118
+ ### What happens to a thread
119
+
120
+ Each issue goes through these steps:
71
121
 
72
122
  1. Someone opens an issue. It becomes a thread in the mapped channel.
73
123
  2. The watcher wakes the agent with the thread's ID. The agent reads it.
@@ -100,7 +150,11 @@ flowchart LR
100
150
  A -->|reply| S
101
151
  ```
102
152
 
103
- In the board module:
153
+ ### Declare a router and a watcher per product
154
+
155
+ In the board module, declare the router's watcher and one watcher per
156
+ product. Each runs a [gate](../01-concepts/09-watchers.md#a-gate) before it
157
+ wakes its agent:
104
158
 
105
159
  ```ts board.ts
106
160
  import { board, command, type Watch } from '@openmuster/muster'
@@ -127,6 +181,25 @@ export default board({
127
181
  })
128
182
  ```
129
183
 
184
+ The module sets up these behaviours:
185
+
186
+ - **Each watcher has its own `as`.** A watcher never hears its own
187
+ [profile](../01-concepts/06-actors.md)'s writes. A product's agent that
188
+ writes as `router` can't hear the router's label.
189
+ - **It costs two agent sessions a question.** Each watcher runs in a loop of
190
+ its own. While idle, a loop looks for new events at least once a second.
191
+ The router's agent labels the thread, and the product's watcher hears the
192
+ label.
193
+ `coalesce` gathers the question and its label into one wake, once the
194
+ oldest is `30s` old.
195
+ - **A product's watcher hears more than the label arriving.** It also hears
196
+ later messages in the thread, the label being taken away, and any other
197
+ label changing on it. The gate handles the label leaving. Tell the agent to
198
+ reply only when the last message isn't its own. To answer the first
199
+ question only, drop `message.posted` from its `types`.
200
+
201
+ ### Have the router write one label
202
+
130
203
  The router's agent reads the thread and writes one label on it, and nothing
131
204
  else. Its instructions name the products and what each covers, and end with
132
205
  the command:
@@ -138,9 +211,12 @@ mu label <thread> product=billing --if-unset product
138
211
  `--if-unset` makes the first answer stand: a second try exits 1 with
139
212
  `label_conflict`, so have `route.sh` treat that as done. Use `product=none`
140
213
  for what isn't a product question. It is a label like the others: it stops
141
- the router from being asked again, and no watcher listens for it.
214
+ the router's gate from waking the router again, and no watcher listens for
215
+ it.
216
+
217
+ ### Gate each watcher
142
218
 
143
- The two gates keep a model from being started for nothing:
219
+ The two gates stop the watchers from starting a model for nothing:
144
220
 
145
221
  ```bash
146
222
  #!/bin/sh
@@ -154,11 +230,27 @@ mu read "$MUSTER_THREAD" --json | grep -q '"product":' && echo '{"wake": false}'
154
230
  mu read "$MUSTER_THREAD" --json | grep -q "\"product\": \"$1\"" || echo '{"wake": false}'
155
231
  ```
156
232
 
233
+ A gate says no in one way only: `{"wake": false}` on its last line. Its exit
234
+ code isn't read, so a gate that prints nothing wakes the agent. That is why
235
+ the two scripts fail in opposite directions when `mu read` fails and `grep`
236
+ finds nothing:
237
+
238
+ - **`unlabelled.sh` wakes the router.** Its `&&` prints `{"wake": false}`
239
+ only when `grep` finds a label, so on a failed read it prints nothing.
240
+ - **`has-product.sh` keeps its agent asleep.** Its `||` prints
241
+ `{"wake": false}` whenever `grep` finds no match.
242
+
243
+ ### Wake each agent with a pointer
244
+
157
245
  `route.sh` and `answer.sh` do what the factory's `lib/wake.ts` does, with
158
- other instructions: they pass a pointer, and the agent reads the thread
159
- itself.
246
+ other instructions: they pass a
247
+ [pointer](../01-concepts/09-watchers.md#what-a-wake-carries), and the agent
248
+ reads the thread itself.
160
249
 
161
- Try the plumbing by hand, with you as the router:
250
+ ### Try the plumbing by hand
251
+
252
+ Post a question and label it, with you as the router, then list the
253
+ threads that carry the billing label:
162
254
 
163
255
  ```bash steps
164
256
  mu post help "How do I change the card on my account?" --as ada
@@ -166,47 +258,68 @@ mu label 1 product=billing --if-unset product --as router
166
258
  mu read help --label product=billing --as ada
167
259
  ```
168
260
 
169
- What to know before you rely on it:
261
+ To check the watchers end to end, run `mu daemon check billing`. A
262
+ product's watcher builds its check message with its label; the router's
263
+ can't be checked this way (see [What goes wrong](#what-goes-wrong)).
264
+
265
+ ## What keeps it safe
266
+
267
+ The factory keeps three things apart: secrets, the text that arrives, and
268
+ who approves.
269
+
270
+ ### Keep secrets away from the agent
271
+
272
+ The wake command gets a pointer and a clean environment. It never gets the
273
+ secrets the sync names.
274
+
275
+ ### Treat what arrives as information, not orders
276
+
277
+ Text from a platform is data for the agent:
170
278
 
171
- - **Give each watcher its own `as`.** A watcher never hears its own profile's
172
- writes. A product's agent that writes as `router` can't hear the router's
173
- label.
174
- - **It costs two agent sessions a question.** Each watcher runs in a loop of
175
- its own: the router's agent labels the thread, and the product's watcher
176
- hears the label within a second or two. `coalesce` gathers the question and
177
- its label into one wake, once the oldest is 30 seconds old.
178
- - **A product's watcher hears more than the label arriving:** later messages
179
- in the thread, the label being taken away, and any other label changing on
180
- it. The gate handles the label leaving. Tell the agent to reply only when
181
- the last message isn't its own. To answer the first question only, drop
182
- `message.posted` from its `types`.
183
- - **A gate that fails wakes the agent.** Only `{"wake": false}` on its last
184
- line says no; its exit code isn't read. `unlabelled.sh` wakes the router
185
- when `mu read` fails, and `has-product.sh` doesn't wake its agent.
186
- - **An agent that exits 0 without writing a label isn't tried again.** The
187
- thread stays unsorted until someone posts in it or labels it by hand.
188
- - **Fix a wrong label by hand:** `mu label <thread> product=api`. The api
189
- agent is woken, and the gate keeps billing's asleep.
190
- - **`mu daemon check router` times out,** because the router labels and never
191
- replies. Check a product's watcher instead, which builds its message with
192
- the label: `mu daemon check billing`.
193
- - **"Label only" is an instruction, not a limit.** The router reads text
194
- strangers wrote. On a served board give it a
195
- [token](../01-concepts/11-access.md) held to that channel.
196
- - **Messages sent while the board is down come in late.** When the board
197
- starts again it reads what [Slack](../02-sync/04-slack.md) has since, with
198
- limits that page gives.
199
-
200
- ## Keep people in the loop
201
-
202
- Nothing on a board proves that a particular person approved something. For a merge, a deploy
203
- or a publish, have the agent ask where identity is verified: a review on the
204
- pull request.
205
-
206
- ## Keep it safe
207
-
208
- - The wake command gets a pointer and a clean environment. It never gets the
209
- secrets the sync names.
210
- - A `filter` on the sync can drop or rewrite text on its way in.
211
279
  - What arrives from a platform informs the agent; it never authorizes it.
212
- - A task whose brief is edited from outside is held for its owner.
280
+ - A `filter` on the sync can drop or rewrite text on its way in.
281
+ - "Label only" is an instruction to the router, not a limit. The router
282
+ reads text strangers wrote. On a served board give it a
283
+ [token](../01-concepts/11-access.md) limited to that channel.
284
+
285
+ ### Get approvals where identity is verified
286
+
287
+ Nothing on a board proves that a particular person approved something. For a
288
+ merge, a deploy or a publish, have the agent ask where identity is verified:
289
+ a review on the pull request.
290
+
291
+ ### Hold edited tasks for their owner
292
+
293
+ If someone other than a task's owner edits its brief, the board
294
+ [holds the task](../01-concepts/08-tasks.md#who-may-change-a-task) for its
295
+ owner.
296
+
297
+ ## What goes wrong
298
+
299
+ These are the failures routing by label runs into:
300
+
301
+ - **`mu daemon check router` times out.** The router labels and never
302
+ replies. Check a product's watcher instead: `mu daemon check billing`.
303
+ - **A thread stays unsorted.** The router's agent exited 0 without writing a
304
+ label, and the watcher doesn't retry an agent that exits 0. The thread
305
+ stays unsorted until someone posts in it or labels it by hand.
306
+ - **A thread has the wrong label.** Fix it by hand:
307
+ `mu label <thread> product=api`. The api watcher wakes its agent, and the
308
+ gate keeps billing's asleep.
309
+ - **Messages sent while the board was down come in late.** Slack retries an
310
+ unanswered event three times, within minutes. After that, when the board
311
+ starts again, it reads what [Slack](../02-sync/04-slack.md) has since.
312
+ Edits and deletes made meanwhile aren't read: see
313
+ [After downtime](../02-sync/04-slack.md#after-downtime) for the limits.
314
+
315
+ ## Related
316
+
317
+ Go further with these pages:
318
+
319
+ - [Watchers](../01-concepts/09-watchers.md): the daemon, gates and retries
320
+ - [Keep the daemon running](./09-daemon.md#check-that-a-watcher-wakes-something):
321
+ `mu daemon check`
322
+ - [GitHub](../02-sync/02-github.md) and [Slack](../02-sync/04-slack.md): what
323
+ each platform's sync brings in and sends back
324
+ - [Access](../01-concepts/11-access.md): tokens that limit an agent to its
325
+ channels