@openmuster/muster 0.3.1-alpha.3 → 0.3.1-alpha.5
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.
- package/README.md +16 -10
- package/dist/{args-DX9QSK1f.js → args-CaFBa2IP.js} +305 -23
- package/dist/cli.js +3 -3
- package/dist/index.d.ts +67 -18
- package/dist/index.js +106 -41
- package/dist/inspect/app.js +79 -51
- package/dist/{main-DgrIMbeA.js → main-BeEB08iI.js} +397 -26
- package/dist/main-CLzQkYeG.js +6 -0
- package/dist/mcp-CAAZRJgv.js +6 -0
- package/dist/{module-C-HJjWWo.js → module-BX2IjSiv.js} +2 -2
- package/dist/{module-CxoN1MOe.js → module-D9KdbEpS.js} +1 -1
- package/dist/skills/board/SKILL.md +5 -0
- package/dist/{steps-DtzUdcBE.js → steps-FNDWY1P_.js} +16 -4
- package/docs/01-concepts/09-watchers.md +4 -32
- package/docs/01-concepts/10-schedules.md +1 -1
- package/docs/01-concepts/11-access.md +19 -3
- package/docs/01-concepts/13-budgets.md +66 -3
- package/docs/01-concepts/15-outgoing-webhooks.md +6 -19
- package/docs/01-concepts/16-workflows.md +22 -2
- package/docs/01-quickstart.md +74 -42
- package/docs/02-sync/01-overview.md +34 -2
- package/docs/02-sync/02-github.md +40 -19
- package/docs/02-sync/03-linear.md +103 -85
- package/docs/02-sync/04-slack.md +116 -111
- package/docs/02-sync/05-notion.md +46 -25
- package/docs/03-guides/01-coding-agents.md +51 -33
- package/docs/03-guides/02-swarm.md +30 -15
- package/docs/03-guides/03-factory.md +193 -80
- package/docs/03-guides/04-inspector.md +79 -29
- package/docs/03-guides/05-running-agents.md +62 -35
- package/docs/03-guides/06-sandboxed-agents.md +488 -305
- package/docs/03-guides/07-build-a-ui.md +86 -31
- package/docs/03-guides/08-ci.md +59 -36
- package/docs/03-guides/09-daemon.md +121 -53
- package/docs/03-guides/10-two-agents.md +31 -22
- package/docs/03-guides/11-person-in-the-loop.md +47 -34
- package/docs/03-guides/12-unattended.md +46 -27
- package/docs/03-guides/13-terminals.md +51 -39
- package/docs/03-guides/14-no-cloud.md +31 -19
- package/docs/03-guides/15-several-boards.md +61 -27
- package/docs/03-guides/16-non-code.md +29 -18
- package/docs/03-guides/17-mcp.md +37 -30
- package/docs/03-guides/18-a-board-on-a-server.md +66 -43
- package/docs/03-guides/19-a-card-queue.md +210 -121
- package/docs/03-guides/20-a-feedback-loop.md +298 -134
- package/docs/03-guides/21-running-the-loop.md +94 -64
- package/docs/03-guides/22-building-from-linear.md +81 -57
- package/docs/04-reference/01-cli.md +8 -0
- package/docs/04-reference/02-handle.md +10 -15
- package/docs/04-reference/03-http.md +1 -1
- package/docs/04-reference/04-events.md +2 -1
- package/docs/04-reference/05-errors.md +3 -0
- package/docs/04-reference/08-files.md +49 -0
- package/docs/index.md +22 -0
- package/package.json +1 -1
- package/dist/main-CdVlnWHy.js +0 -6
- package/dist/mcp-NueWYyQs.js +0 -6
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Build a UI
|
|
3
|
-
description: For building
|
|
3
|
+
description: For developers building their own page over a board in TypeScript. You end with a server that holds the board handle, snapshots tasks and threads, and reads events after a cursor, so the page stays live and the browser never holds a credential. Your app can also serve the board itself with team.fetch.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
##
|
|
6
|
+
## Hold the board handle on your server
|
|
7
7
|
|
|
8
|
-
The browser never holds the board's credential. Your server holds a
|
|
9
|
-
|
|
8
|
+
The browser never holds the board's credential. Your server holds a
|
|
9
|
+
[handle](../04-reference/02-handle.md#a-handle) and serves the page's
|
|
10
|
+
requests through it. With `MUSTER_URL` set, the handle calls a served board
|
|
11
|
+
with `MUSTER_TOKEN`. Without it, `board()` opens the board file on this
|
|
12
|
+
machine:
|
|
10
13
|
|
|
11
14
|
```ts lib/board.ts
|
|
12
15
|
import { board, http } from '@openmuster/muster'
|
|
@@ -16,10 +19,10 @@ export const team = process.env.MUSTER_URL
|
|
|
16
19
|
: board()
|
|
17
20
|
```
|
|
18
21
|
|
|
19
|
-
##
|
|
22
|
+
## Take a snapshot of the channel
|
|
20
23
|
|
|
21
|
-
Read
|
|
22
|
-
while you read
|
|
24
|
+
Read the channel's tasks and threads fresh each time. Read the cursor first,
|
|
25
|
+
so you miss nothing the board writes while you read:
|
|
23
26
|
|
|
24
27
|
```ts lib/snapshot.ts
|
|
25
28
|
import { team } from './board.ts'
|
|
@@ -34,8 +37,8 @@ export async function snapshot(channel: string) {
|
|
|
34
37
|
|
|
35
38
|
## Stay live
|
|
36
39
|
|
|
37
|
-
Ask for events after the cursor you hold, and take a new snapshot when
|
|
38
|
-
|
|
40
|
+
Ask for events after the cursor you hold, and take a new snapshot when there
|
|
41
|
+
are new events:
|
|
39
42
|
|
|
40
43
|
```ts lib/live.ts
|
|
41
44
|
import { team } from './board.ts'
|
|
@@ -46,35 +49,87 @@ export async function changed(after: number, channel: string) {
|
|
|
46
49
|
}
|
|
47
50
|
```
|
|
48
51
|
|
|
49
|
-
|
|
50
|
-
|
|
52
|
+
With a board behind `mu serve`, a page can keep the live feed of server-sent
|
|
53
|
+
events open instead: see
|
|
54
|
+
[The live feed](../04-reference/03-http.md#the-live-feed).
|
|
51
55
|
|
|
52
|
-
##
|
|
56
|
+
## Serve the board from your web app
|
|
53
57
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
58
|
+
Your app can serve the board itself, in place of `mu serve`:
|
|
59
|
+
[`team.fetch`](../04-reference/02-handle.md#mounting-it-in-a-web-app)
|
|
60
|
+
answers with what `mu serve` serves for this board. It serves only a board on
|
|
61
|
+
this machine, so leave `MUSTER_URL` unset on the server: on a handle for a
|
|
62
|
+
board at a URL, every request gets 403. These steps are for Next.js.
|
|
63
|
+
|
|
64
|
+
### Mount it on a route
|
|
65
|
+
|
|
66
|
+
Export `team.fetch` as the `GET` and `POST` of a catch-all route under
|
|
67
|
+
`/api/board`:
|
|
68
|
+
|
|
69
|
+
```ts app/api/board/[...path]/route.ts
|
|
70
|
+
import { team } from '@/lib/board'
|
|
71
|
+
|
|
72
|
+
export const GET = team.fetch, POST = team.fetch
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
To mount it at another path, or to answer for host names besides
|
|
76
|
+
`127.0.0.1`, `localhost` and `[::1]`, set `serve.base` and `serve.hosts`: see
|
|
77
|
+
[the options](../04-reference/02-handle.md#mounting-it-in-a-web-app).
|
|
78
|
+
|
|
79
|
+
### Keep one copy of muster in the process
|
|
80
|
+
|
|
81
|
+
Keep `serverExternalPackages: ['@openmuster/muster']` in `next.config.ts`,
|
|
82
|
+
so the process has one copy of muster.
|
|
83
|
+
|
|
84
|
+
### Leave the board's routes out of the proxy
|
|
85
|
+
|
|
86
|
+
If the app has a `proxy.ts` (or `middleware.ts`), leave the board's routes
|
|
87
|
+
out of its `matcher`. Next.js reads a body that passes through it into
|
|
88
|
+
memory and cuts it at 10 MB, under the board's limit for a file.
|
|
89
|
+
|
|
90
|
+
### Run the app where its tokens are made
|
|
91
|
+
|
|
92
|
+
Run the app with the same `HOME` or `MUSTER_CONFIG` as the `mu` that makes
|
|
93
|
+
its tokens. Every request needs a token from `mu token create`, and the app
|
|
94
|
+
checks it with the key kept in muster's config folder.
|
|
95
|
+
|
|
96
|
+
## Rules that keep a page stable while it updates
|
|
97
|
+
|
|
98
|
+
Follow these rules in your page:
|
|
99
|
+
|
|
100
|
+
- Never replace a newer snapshot with an older one, or a message with an older
|
|
101
|
+
revision of itself.
|
|
102
|
+
- Show your own writes at once, and drop that copy when the board confirms or
|
|
57
103
|
refuses them.
|
|
58
|
-
-
|
|
59
|
-
|
|
104
|
+
- Never let a live update move what someone is reading or overwrite what they
|
|
105
|
+
type.
|
|
106
|
+
- Keep the view in the URL.
|
|
107
|
+
|
|
108
|
+
`mu inspect` and the pages in `templates/swarm` and `templates/factory`
|
|
109
|
+
follow these rules.
|
|
60
110
|
|
|
61
|
-
|
|
62
|
-
built this way.
|
|
111
|
+
## When not to build your own page
|
|
63
112
|
|
|
64
|
-
|
|
113
|
+
Use something else for:
|
|
65
114
|
|
|
66
|
-
- **
|
|
115
|
+
- **Watching a board yourself:** `mu inspect` is that page already. See
|
|
67
116
|
[The inspector](./04-inspector.md).
|
|
68
|
-
- **
|
|
69
|
-
[watcher](../01-concepts/09-watchers.md) or `mu wait` needs no
|
|
117
|
+
- **Reacting to events without a person:** a
|
|
118
|
+
[watcher](../01-concepts/09-watchers.md#watchers) or `mu wait` needs no
|
|
119
|
+
page.
|
|
70
120
|
|
|
71
121
|
## What goes wrong
|
|
72
122
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
- **
|
|
79
|
-
|
|
80
|
-
|
|
123
|
+
Each item is the symptom, then the cause and the fix:
|
|
124
|
+
|
|
125
|
+
- **The token reaches the browser.** Anyone who opens the page can read a
|
|
126
|
+
token in the page's code. Keep `MUSTER_TOKEN` on the server, and give the
|
|
127
|
+
server a token limited to the channels the page shows.
|
|
128
|
+
- **The page misses an event.** Read the cursor before the snapshot, as in
|
|
129
|
+
[Take a snapshot of the channel](#take-a-snapshot-of-the-channel). If you
|
|
130
|
+
read the cursor after the snapshot, an event written in between is in
|
|
131
|
+
neither.
|
|
132
|
+
- **A channel shows nothing.** The server's token can't read the channel, so
|
|
133
|
+
for that token the channel doesn't exist: reads leave it out, and a write
|
|
134
|
+
there returns `not_found`. See
|
|
135
|
+
[Access](../01-concepts/11-access.md#tokens).
|
package/docs/03-guides/08-ci.md
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: CI
|
|
3
|
-
description: For a CI pipeline that reports to a board or waits on it.
|
|
3
|
+
description: For a continuous integration (CI) pipeline that reports to a board or waits on it. You end able to post results once even when a job retries, sign in with the job's OpenID Connect (OIDC) token, run a step as a task, and pause until a person approves.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
## Say what happened
|
|
7
7
|
|
|
8
|
+
Post what happened to a channel, as the `ci`
|
|
9
|
+
[profile](../01-concepts/06-actors.md):
|
|
10
|
+
|
|
8
11
|
```bash
|
|
9
12
|
mu post deploys "www@$GIT_SHA is live" --idempotency-key "deploy-$GIT_SHA" --as ci
|
|
10
13
|
mu post ci "the suite failed on main" --attach ./test.log --label kind=failure --as ci
|
|
11
14
|
```
|
|
12
15
|
|
|
13
|
-
The idempotency key makes a retried job post once. A runner on another
|
|
14
|
-
reaches the board with `MUSTER_URL` and a
|
|
16
|
+
The idempotency key makes a retried job post once. A runner on another
|
|
17
|
+
machine reaches the board with `MUSTER_URL` and a
|
|
18
|
+
[token](../01-concepts/11-access.md#tokens) limited to the channels it posts
|
|
15
19
|
in:
|
|
16
20
|
|
|
17
21
|
```bash
|
|
@@ -25,10 +29,11 @@ mu token create --as ci --can 'deploys=read,post' --can 'ci=read,post' --ttl 90d
|
|
|
25
29
|
|
|
26
30
|
A token made with `mu token create` is a secret you store in your CI and
|
|
27
31
|
rotate. A job on GitHub Actions or GitLab CI already has an identity: an OIDC
|
|
28
|
-
token its platform signs,
|
|
29
|
-
A
|
|
32
|
+
token its platform signs, whose claims name the repository and branch it runs
|
|
33
|
+
for. A board that [`mu serve`](../01-concepts/11-access.md#serve-a-board)
|
|
34
|
+
serves can accept that token instead, so there is no secret to store.
|
|
30
35
|
|
|
31
|
-
|
|
36
|
+
On the machine that serves the board, name the workloads you trust in
|
|
32
37
|
`~/.config/muster/oidc.json`, beside the board's key and never on a board,
|
|
33
38
|
then restart `mu serve`:
|
|
34
39
|
|
|
@@ -48,19 +53,29 @@ then restart `mu serve`:
|
|
|
48
53
|
}
|
|
49
54
|
```
|
|
50
55
|
|
|
56
|
+
Each trust has these fields:
|
|
57
|
+
|
|
51
58
|
| Field | Meaning |
|
|
52
59
|
| --- | --- |
|
|
53
60
|
| `issuer` | Who signs the job's token, exactly as its `iss` says. The board fetches that issuer's public keys, and nothing from any other |
|
|
54
|
-
| `audience` | Who the token must be made out to. Choose a name for this board, such as its URL, and ask the platform for a token with it.
|
|
55
|
-
| `sub` | Which workload, exactly, or a prefix ending in
|
|
61
|
+
| `audience` | Who the token must be made out to. Choose a name for this board, such as its URL, and ask the platform for a token with it. The board never reads it from a request |
|
|
62
|
+
| `sub` | Which workload, exactly, or a prefix ending in `*`. When several trusts fit a job, the most exact one applies |
|
|
56
63
|
| `as`, `can` | The profile the job writes as and the channels it may use: `read`, `post`, `react`, `label`. Never every channel, never `manage` |
|
|
57
64
|
| `ttl` | How long the board token lives: a minute to an hour, 15 minutes unless you say |
|
|
58
|
-
| `noSync` | `true` keeps what the job writes on the board
|
|
65
|
+
| `noSync` | `true` keeps what the job writes on the board only: no platform sync sends it on |
|
|
66
|
+
|
|
67
|
+
A `sub` follows these rules:
|
|
59
68
|
|
|
60
|
-
|
|
61
|
-
|
|
69
|
+
- A prefix's `*` comes right after a `:` or `/`, with an owner before it:
|
|
70
|
+
`repo:acme/api:*` is every branch of one repository, `repo:acme/*` every
|
|
71
|
+
repository of one organisation, and `repo:*` is refused.
|
|
72
|
+
- A trust with no `sub` is refused. A platform like GitLab.com signs for all
|
|
73
|
+
its customers under one issuer, so such a trust would let any of them in.
|
|
62
74
|
|
|
63
|
-
|
|
75
|
+
`mu serve` prints the workloads it trusts. If the file is wrong, `mu serve`
|
|
76
|
+
doesn't start, and names the trust and what it needs.
|
|
77
|
+
|
|
78
|
+
In the job, exchange the platform's token for a board token, once, and use
|
|
64
79
|
it for every command after. On GitHub Actions, with `permissions: id-token:
|
|
65
80
|
write` on the job:
|
|
66
81
|
|
|
@@ -93,8 +108,8 @@ notify:
|
|
|
93
108
|
`mu token exchange` reads the token from `MUSTER_OIDC_TOKEN`, or from stdin
|
|
94
109
|
with `mu token exchange -`; never from an argument, which other users of a
|
|
95
110
|
machine can read. It prints the board token and nothing else. It sends the
|
|
96
|
-
job's token only to the board's own URL
|
|
97
|
-
machine
|
|
111
|
+
job's token only to the board's own URL, over https, or over plain http to
|
|
112
|
+
this machine. It never sends it to wherever a redirect points.
|
|
98
113
|
|
|
99
114
|
What to know:
|
|
100
115
|
|
|
@@ -103,26 +118,28 @@ What to know:
|
|
|
103
118
|
workload when you need to tell them apart.
|
|
104
119
|
- `mu tasks claim --ready` offers a caller its own tasks, and the job's are
|
|
105
120
|
the ones made under `oidc:<name>`. To take tasks a person queued, claim by
|
|
106
|
-
ID, or pass `--from
|
|
107
|
-
-
|
|
108
|
-
tokens at a time. Exchange once in a job, not before every
|
|
121
|
+
ID, or pass `--from` with their ID from `mu actors`.
|
|
122
|
+
- The board accepts a platform's token once, and one workload holds at most
|
|
123
|
+
50 board tokens at a time. Exchange once in a job, not before every
|
|
124
|
+
command.
|
|
109
125
|
- A trust is as wide as its `sub`. A prefix lets in every branch or
|
|
110
126
|
repository it covers, forks' pull requests included where the platform
|
|
111
127
|
signs for them, and any of those jobs can use up the trust's 50 tokens for
|
|
112
128
|
the others. Trust an exact `sub` where you can.
|
|
113
|
-
-
|
|
114
|
-
for
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
129
|
+
- A token limited to some channels may store 100 MB of files a day. For a
|
|
130
|
+
trust, that is one allowance for all its jobs, however many tokens they
|
|
131
|
+
exchange for.
|
|
132
|
+
- `mu serve` keeps the record of which platform tokens were used in memory.
|
|
133
|
+
After `mu serve` restarts, a platform token that hasn't expired yet could
|
|
134
|
+
be exchanged once more, and so could one sent to a second process serving
|
|
135
|
+
the same board.
|
|
119
136
|
- Someone with no token can tell an issuer you trust from one you don't, and
|
|
120
137
|
a job from the same platform can tell whether it guessed your audience.
|
|
121
|
-
Neither
|
|
138
|
+
Neither grants access: only a matching `sub` does.
|
|
122
139
|
- Don't name a trust after a person: on the board the job reads as
|
|
123
140
|
`<name>`'s profile under `oidc:<name>`.
|
|
124
|
-
-
|
|
125
|
-
|
|
141
|
+
- `mu token list` lists the board token and `mu token revoke` revokes it,
|
|
142
|
+
like any other. It makes no tokens and approves no requests to join.
|
|
126
143
|
|
|
127
144
|
What goes wrong:
|
|
128
145
|
|
|
@@ -136,15 +153,21 @@ What goes wrong:
|
|
|
136
153
|
|
|
137
154
|
## Let a step be a task
|
|
138
155
|
|
|
156
|
+
[`mu tasks run`](../01-concepts/08-tasks.md#let-a-command-be-the-work) runs
|
|
157
|
+
a command as the work of a task:
|
|
158
|
+
|
|
139
159
|
```bash
|
|
140
160
|
mu tasks run 12 --result "tests pass" -- pnpm test
|
|
141
161
|
```
|
|
142
162
|
|
|
143
163
|
The task completes when the command exits 0 and fails otherwise, with the exit
|
|
144
|
-
code as its reason.
|
|
164
|
+
code as its reason. Tasks that [need](../01-concepts/08-tasks.md#needs) it
|
|
165
|
+
become ready when it succeeds.
|
|
145
166
|
|
|
146
167
|
## Gate on a person
|
|
147
168
|
|
|
169
|
+
Create a task for a person, and wait for it to complete:
|
|
170
|
+
|
|
148
171
|
```bash
|
|
149
172
|
mu tasks create releases "Approve the release of $GIT_SHA" --as ci
|
|
150
173
|
mu wait releases --type task.completed --timeout 2h
|
|
@@ -158,19 +181,19 @@ gate on your CI's own approval too.
|
|
|
158
181
|
## Hear about CI on the board
|
|
159
182
|
|
|
160
183
|
With GitHub sync, a workflow run that finishes on a pull request sets
|
|
161
|
-
`ci.<workflow>` on its thread ([GitHub](../02-sync/02-github.md)). An agent
|
|
162
|
-
on the label:
|
|
184
|
+
`ci.<workflow>` on its thread ([GitHub](../02-sync/02-github.md)). An agent
|
|
185
|
+
keeping pull requests green waits on the label:
|
|
163
186
|
|
|
164
187
|
```bash
|
|
165
188
|
mu wait web/prs --label 'ci.ci=failure' --timeout 1h
|
|
166
189
|
```
|
|
167
190
|
|
|
168
|
-
## When not to
|
|
191
|
+
## When not to use a board from CI
|
|
169
192
|
|
|
170
|
-
- **
|
|
171
|
-
person or an agent will read or wait on.
|
|
172
|
-
- **
|
|
173
|
-
completed a task. Use your CI's own approvals for a step
|
|
174
|
-
undone.
|
|
175
|
-
- **
|
|
193
|
+
- **Don't post a log nobody acts on.** Your CI already keeps its logs. Post
|
|
194
|
+
what a person or an agent will read or wait on.
|
|
195
|
+
- **Don't rely on a board for an approval that must be proved.** Nothing on
|
|
196
|
+
a board proves who completed a task. Use your CI's own approvals for a step
|
|
197
|
+
that can't be undone.
|
|
198
|
+
- **Don't wait long on a paid runner.** `mu wait --timeout 2h` keeps the job
|
|
176
199
|
running for as long as it waits.
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Keep the daemon running
|
|
3
|
-
description: For keeping schedules, watchers and sync running on a Mac across logins and crashes. mu daemon install adds a LaunchAgent per board, and on Linux you run mu daemon run under systemd or another supervisor.
|
|
3
|
+
description: For keeping schedules, watchers and sync running on a Mac across logins and crashes. mu daemon install adds a LaunchAgent per board, and on Linux you run mu daemon run under systemd or another supervisor. mu daemon check proves a watcher or an outgoing webhook answers.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
## Install
|
|
6
|
+
## Install the daemon on macOS
|
|
7
|
+
|
|
8
|
+
These commands install the daemon for this board, install it with secrets
|
|
9
|
+
passed in, show its status, and remove it:
|
|
7
10
|
|
|
8
11
|
```bash
|
|
9
12
|
mu daemon install
|
|
@@ -12,41 +15,100 @@ mu daemon status
|
|
|
12
15
|
mu daemon uninstall
|
|
13
16
|
```
|
|
14
17
|
|
|
15
|
-
`install` writes a LaunchAgent for this board and
|
|
16
|
-
|
|
18
|
+
`install` writes a LaunchAgent, a per-user macOS service, for this board and
|
|
19
|
+
loads it. The service starts at login, and launchd, the macOS service
|
|
20
|
+
manager, restarts it after a crash. `install` is for macOS only: on Linux,
|
|
17
21
|
run `mu daemon run` under your own service manager, such as a systemd user
|
|
18
22
|
unit.
|
|
19
23
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
+
The service works like this:
|
|
25
|
+
|
|
26
|
+
- **The service file holds what it needs.** It sets `PATH`, the board, the
|
|
27
|
+
config folder, and the [board module](../01-concepts/17-board-module.md) by
|
|
28
|
+
its absolute path, run from the folder you installed it from. launchd
|
|
29
|
+
starts a job with almost nothing else.
|
|
24
30
|
- **Secrets are yours to pass.** `--env NAME` writes that variable's value now
|
|
25
31
|
into the service file, which only you can read. Without it, a sync or an
|
|
26
32
|
outgoing webhook that names the secret can't start.
|
|
27
|
-
- **
|
|
33
|
+
- **A fault a restart can't fix stops it.** A module that fails to load, a
|
|
28
34
|
secret it names that isn't set, or a leftover `watchers.json`, `sync.json`
|
|
29
|
-
or `hooks.json` makes the daemon
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
[Porting](../04-reference/07-porting.md)
|
|
33
|
-
|
|
35
|
+
or `hooks.json` makes the daemon log the reason and exit cleanly. launchd
|
|
36
|
+
then leaves it stopped instead of restarting it indefinitely. Fix the cause
|
|
37
|
+
and install again. muster no longer reads those three files: move what
|
|
38
|
+
they list into the module, as [Porting](../04-reference/07-porting.md)
|
|
39
|
+
shows.
|
|
40
|
+
- **A daemon that keeps crashing stops itself.** See
|
|
41
|
+
[When the daemon keeps crashing](#when-the-daemon-keeps-crashing).
|
|
42
|
+
|
|
43
|
+
The daemon's log is in `~/.config/muster/logs/`.
|
|
44
|
+
|
|
45
|
+
## Check that a watcher wakes something
|
|
46
|
+
|
|
47
|
+
Name the [watcher](../01-concepts/09-watchers.md#watchers) to check, and, for
|
|
48
|
+
one on a subtree, the channel under it:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
mu daemon check lead
|
|
52
|
+
mu daemon check triage --in work/checks --timeout 10m
|
|
53
|
+
```
|
|
34
54
|
|
|
35
|
-
|
|
55
|
+
`check` writes a message the watcher's filter matches, then waits for a reply
|
|
56
|
+
in its thread. A reply proves the whole path: a host runs the watcher, the
|
|
57
|
+
filter matches, the gate lets it through, and the command wakes something
|
|
58
|
+
that answers. It prints who answered and how long it took.
|
|
59
|
+
|
|
60
|
+
- **Its message is built from the filter:** the watcher's channel, its labels,
|
|
61
|
+
a mention or words it asks for. A watcher on a subtree needs `--in` to say
|
|
62
|
+
which channel under it. It stays on the board, never synced.
|
|
63
|
+
- **It fails fast when nothing runs the watcher** (`watcher_not_running`),
|
|
64
|
+
before writing anything: no host holds its lease. If the daemon stopped
|
|
65
|
+
restarting, it says that instead (`daemon_stopped`).
|
|
66
|
+
- **A run that keeps failing is `wake_failed`,** after the five tries an
|
|
67
|
+
event gets, which take a few minutes. A command that runs but wakes nothing
|
|
68
|
+
that replies is `timeout`, with the thread to read.
|
|
69
|
+
- **Some watchers can't be checked with a message:** one that listens only
|
|
70
|
+
for task events, or only to a platform's users. Write what it listens for
|
|
71
|
+
by hand instead.
|
|
72
|
+
|
|
73
|
+
Whatever the command wakes has to reply. The agents in
|
|
74
|
+
[A software factory](./03-factory.md) and
|
|
75
|
+
[With your terminal](./13-terminals.md) read the thread and answer
|
|
76
|
+
it like any other.
|
|
77
|
+
|
|
78
|
+
## Check that an outgoing webhook arrives
|
|
79
|
+
|
|
80
|
+
Name the [outgoing webhook](../01-concepts/15-outgoing-webhooks.md) to
|
|
81
|
+
check, then see whether a host sends it:
|
|
36
82
|
|
|
37
|
-
|
|
83
|
+
```bash
|
|
84
|
+
mu daemon check phone
|
|
85
|
+
mu daemon status
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
`check` sends a signed ping to the hook's URL from this terminal and prints
|
|
89
|
+
what the receiver answered. Its event has the type `ping` and is not on the
|
|
90
|
+
board. The secret has to be set where you run it.
|
|
38
91
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
minutes and ticks clears the list.
|
|
92
|
+
- **`hook_failed`** when nothing answered, or the receiver refused it. A
|
|
93
|
+
`401` or `403` usually means the two sides hold different secrets.
|
|
94
|
+
- **It proves the URL and the secret, not the host.** Whether a host sends the
|
|
95
|
+
hooks is `mu daemon status`, and its log says what each hook sent.
|
|
44
96
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
97
|
+
## When the daemon keeps crashing
|
|
98
|
+
|
|
99
|
+
launchd restarts a crashed daemon after 30 seconds, indefinitely. muster adds
|
|
100
|
+
a restart guard of its own. Before it opens the board, the daemon records
|
|
101
|
+
each start in `~/.config/muster/daemon/`, in a file named for the board and
|
|
102
|
+
its location. A start that ends cleanly removes its record, and a run that
|
|
103
|
+
stays up 2 minutes and [ticks](../01-concepts/09-watchers.md#the-daemon)
|
|
104
|
+
clears the list.
|
|
105
|
+
|
|
106
|
+
If the daemon starts 5 times in 10 minutes and none of those runs stayed up,
|
|
107
|
+
the daemon doesn't open the board on the fifth start. It writes the reason to
|
|
108
|
+
its log and stays up doing nothing, so launchd has nothing to restart. An
|
|
109
|
+
hour after it stopped, it tries again as a first start, so a fault that went
|
|
110
|
+
away on its own costs an hour at most. To try now, check the status and
|
|
111
|
+
reset the guard:
|
|
50
112
|
|
|
51
113
|
```bash
|
|
52
114
|
mu daemon status
|
|
@@ -57,47 +119,53 @@ mu daemon reset
|
|
|
57
119
|
stopped since 2026-11-25T09:12:41.012Z: The daemon started 5 times in 10 minutes and never stayed up 2 minutes, so it has stopped restarting. It tries again at 2026-11-25T10:12:41.012Z, or now with mu daemon reset.
|
|
58
120
|
```
|
|
59
121
|
|
|
60
|
-
`status` shows how many quick starts
|
|
61
|
-
when it tries again. `mu daemon check` says `daemon_stopped`
|
|
62
|
-
`watcher_not_running`.
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
122
|
+
`status` shows how many quick starts the daemon has had, or that it has
|
|
123
|
+
stopped and when it tries again. `mu daemon check` says `daemon_stopped`
|
|
124
|
+
rather than `watcher_not_running`. `--board`, `--dir` and `--url` pick the
|
|
125
|
+
board for each of these, as they do for `mu daemon run`.
|
|
126
|
+
|
|
127
|
+
Read the log for what failed, fix it, and run `mu daemon reset`. It clears
|
|
128
|
+
the list, and a stopped daemon starts within a few seconds. If the service is
|
|
129
|
+
installed but not running, `mu daemon reset` starts it. `mu daemon install`
|
|
130
|
+
clears the list too.
|
|
67
131
|
|
|
68
132
|
The same applies under systemd or any supervisor that restarts on failure,
|
|
69
133
|
since the guard is in `mu daemon run` itself.
|
|
70
134
|
|
|
71
135
|
Some failures aren't crashes, and never count:
|
|
72
136
|
|
|
73
|
-
- **A board at a URL that can't be reached yet
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
137
|
+
- **A board at a URL that can't be reached yet:** at login before the network
|
|
138
|
+
is up, for example, or while its server restarts. The daemon logs the error
|
|
139
|
+
on the first failed try, then on the 2nd, 4th, 8th and so on in a row. It
|
|
140
|
+
waits up to 30 seconds between tries.
|
|
141
|
+
- **A board that opens but can't tick:** one whose file can't be read, for
|
|
142
|
+
example. The daemon logs the error the same way and waits up to 30 seconds
|
|
143
|
+
between ticks. It never counts as having stayed up.
|
|
79
144
|
|
|
80
|
-
##
|
|
145
|
+
## Run one daemon per board
|
|
81
146
|
|
|
82
147
|
Each board has its own service, named for the board. `MUSTER_BOARD` and
|
|
83
|
-
`MUSTER_DIR` at install time
|
|
148
|
+
`MUSTER_DIR` at install time set which board it is.
|
|
84
149
|
|
|
85
150
|
Only one process ticks for a board. If `mu serve` is already running for it,
|
|
86
|
-
the daemon says so and exits
|
|
87
|
-
leaves the ticking to the daemon.
|
|
151
|
+
the daemon says so and exits. If the daemon is already running, `mu serve`
|
|
152
|
+
serves the board and leaves the ticking to the daemon.
|
|
153
|
+
|
|
154
|
+
Whichever process ticks holds the board's `tick`
|
|
155
|
+
[lease](../01-concepts/09-watchers.md#the-daemon), a row in the board's own
|
|
156
|
+
file that it renews every 5 seconds.
|
|
88
157
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
crash costs at most half a minute of ticking, and no lock file is left to
|
|
95
|
-
clear.
|
|
158
|
+
A second process that finds the lease held watches it for a few seconds. If
|
|
159
|
+
the holder renews, the second process says so and exits. If it doesn't,
|
|
160
|
+
because the daemon was killed and launchd has just restarted it, the lease
|
|
161
|
+
lapses within 30 seconds and the new process takes over. A crash costs at
|
|
162
|
+
most 30 seconds of ticking, and leaves no lock file to clear.
|
|
96
163
|
|
|
97
|
-
|
|
98
|
-
one says so and exits 0. Run the daemon, or `mu serve`, on that
|
|
164
|
+
For a board at a URL, the server it is on does the ticking: `mu daemon run`
|
|
165
|
+
against one says so and exits 0. Run the daemon, or `mu serve`, on that
|
|
166
|
+
machine.
|
|
99
167
|
|
|
100
|
-
##
|
|
168
|
+
## Run the daemon under systemd or another supervisor
|
|
101
169
|
|
|
102
170
|
The daemon is a plain foreground command, `mu daemon run`. Under systemd or
|
|
103
171
|
any other supervisor, run that, restart it on failure, and treat exit 0 as
|