@crvouga/homelab 0.24.0 → 0.25.0
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 +11 -11
- package/docs/consumer-setup.md +31 -31
- package/docs/releasing.md +6 -4
- package/examples/fleet.json +0 -1
- package/mise.lock +29 -29
- package/mise.toml +1 -1
- package/package.json +3 -2
- package/schema/fleet.schema.json +0 -4
- package/schema/output/fleet-sync.schema.json +23 -0
- package/src/cli/fleet-sync-checkout.ts +10 -1
- package/src/cli/fleet-sync-output.ts +18 -0
- package/src/cli/fleet-sync-progress.ts +11 -2
- package/src/cli/fleet-sync-remote.ts +32 -0
- package/src/definition.ts +0 -1
- package/src/manager-sync.ts +14 -0
- package/src/package-info.ts +104 -6
- package/src/worker-policy.ts +1 -3
package/README.md
CHANGED
|
@@ -376,17 +376,17 @@ hand, on the manager or on a worker it is about to converge, before anything
|
|
|
376
376
|
is changed. [docs/state.md](docs/state.md#day-to-day) says how to keep or discard
|
|
377
377
|
one.
|
|
378
378
|
|
|
379
|
-
| Block | What it declares
|
|
380
|
-
| ---------- |
|
|
381
|
-
| `source` | The Git repository nodes accept code from (this one, or your fork)
|
|
382
|
-
| `state` | The bucket that holds the fleet state; never its credentials
|
|
383
|
-
| `secrets` | Where secrets are kept: `env`, `file`, `sops` or `vault`
|
|
384
|
-
| `manager` | The one macOS manager
|
|
385
|
-
| `workers` | The Ubuntu workers
|
|
386
|
-
| `services` | The proxy's public origin and the monitoring dashboard and accounts
|
|
387
|
-
| `worker` | Policy every worker must meet
|
|
388
|
-
| `ides` | The IDEs the fleet runs; `["t3"]` when absent
|
|
389
|
-
| `t3` | T3
|
|
379
|
+
| Block | What it declares |
|
|
380
|
+
| ---------- | ------------------------------------------------------------------------- |
|
|
381
|
+
| `source` | The Git repository nodes accept code from (this one, or your fork) |
|
|
382
|
+
| `state` | The bucket that holds the fleet state; never its credentials |
|
|
383
|
+
| `secrets` | Where secrets are kept: `env`, `file`, `sops` or `vault` |
|
|
384
|
+
| `manager` | The one macOS manager |
|
|
385
|
+
| `workers` | The Ubuntu workers |
|
|
386
|
+
| `services` | The proxy's public origin and the monitoring dashboard and accounts |
|
|
387
|
+
| `worker` | Policy every worker must meet |
|
|
388
|
+
| `ides` | The IDEs the fleet runs; `["t3"]` when absent |
|
|
389
|
+
| `t3` | T3 mesh access between enrolled machines, and shared settings (`profile`) |
|
|
390
390
|
|
|
391
391
|
### Supported IDEs
|
|
392
392
|
|
package/docs/consumer-setup.md
CHANGED
|
@@ -158,37 +158,37 @@ npx @crvouga/homelab state --example > fleet.json
|
|
|
158
158
|
Then replace every placeholder. Each field, from
|
|
159
159
|
[`schema/fleet.schema.json`](../schema/fleet.schema.json):
|
|
160
160
|
|
|
161
|
-
| Field
|
|
162
|
-
|
|
|
163
|
-
| `version`
|
|
164
|
-
| `source.repository`
|
|
165
|
-
| `state`
|
|
166
|
-
| `secrets`
|
|
167
|
-
| `manager.id`
|
|
168
|
-
| `manager.os`
|
|
169
|
-
| `manager.network.tailscaleName`
|
|
170
|
-
| `manager.network.user`
|
|
171
|
-
| `manager.neverSleepOnPower`
|
|
172
|
-
| `workers[].id`
|
|
173
|
-
| `canary`
|
|
174
|
-
| `workers[].ssh`
|
|
175
|
-
| `workers[].os`
|
|
176
|
-
| `workers[].network.tailscaleName`
|
|
177
|
-
| `workers[].network.sshPort`
|
|
178
|
-
| `workers[].network.user`
|
|
179
|
-
| `workers[].network.t3Port`
|
|
180
|
-
| `services.proxy.endpoint`
|
|
181
|
-
| `services.monitoring.hubPort`
|
|
182
|
-
| `services.monitoring.publicUrl`
|
|
183
|
-
| `services.monitoring.managerAccount`
|
|
184
|
-
| `services.monitoring.viewerAccount`
|
|
185
|
-
| `ubuntu`
|
|
186
|
-
| `worker.requiredCapabilities`
|
|
187
|
-
| `worker.githubLogin`
|
|
188
|
-
| `github` (optional)
|
|
189
|
-
| `worker.vaultUser`
|
|
190
|
-
| `worker.toolchain
|
|
191
|
-
| `worker.unattendedSudo`, `
|
|
161
|
+
| Field | Value |
|
|
162
|
+
| ------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
|
|
163
|
+
| `version` | `3` |
|
|
164
|
+
| `source.repository` | `https://github.com/crvouga/homelab.git`, or your fork if you publish one. Machines only accept code from it. |
|
|
165
|
+
| `state` | `{ "bucket", "endpoint"?, "region"?, "prefix"? }` or `{ "directory": "/absolute/path" }`. Never credentials. |
|
|
166
|
+
| `secrets` | See [secrets](#secrets). |
|
|
167
|
+
| `manager.id` | A short lowercase id, `^[a-z][a-z0-9-]{0,62}$`, e.g. `manager-mac`. |
|
|
168
|
+
| `manager.os` | `"macOS"` |
|
|
169
|
+
| `manager.network.tailscaleName` | The manager's MagicDNS name: `tailscale status --json` → `.Self.DNSName` without the trailing dot. |
|
|
170
|
+
| `manager.network.user` | The manager's login name (`id -un`). |
|
|
171
|
+
| `manager.neverSleepOnPower` | `true` (workers depend on the manager's services). |
|
|
172
|
+
| `workers[].id` | A short lowercase id. The first reachable worker is the canary: a new revision must pass there before the others get it. |
|
|
173
|
+
| `canary` | Optional: the id of the worker to prefer as canary. When it is unreachable, the next reachable worker is used. |
|
|
174
|
+
| `workers[].ssh` | The worker's alias in the manager's `~/.ssh/config`. |
|
|
175
|
+
| `workers[].os` | `"linux"` |
|
|
176
|
+
| `workers[].network.tailscaleName` | The worker's MagicDNS name (from `tailscale status --json` → `.Peer[].DNSName` on the manager). |
|
|
177
|
+
| `workers[].network.sshPort` | `22` unless the worker's sshd listens elsewhere. |
|
|
178
|
+
| `workers[].network.user` | The worker account (`ssh WORKER_ALIAS id -un`). |
|
|
179
|
+
| `workers[].network.t3Port` | `3773` |
|
|
180
|
+
| `services.proxy.endpoint` | The public HTTPS origin of the CLI proxy, e.g. `https://cli-proxy.example.com`. |
|
|
181
|
+
| `services.monitoring.hubPort` | `8443` |
|
|
182
|
+
| `services.monitoring.publicUrl` | The public HTTPS origin of the monitoring dashboard. |
|
|
183
|
+
| `services.monitoring.managerAccount` | The email of the monitoring account the manager enrolls machines with. |
|
|
184
|
+
| `services.monitoring.viewerAccount` | The email of the read-only account visitors are signed in as. |
|
|
185
|
+
| `ubuntu` | `{ "release": "26.04", "architectures": ["amd64", "arm64"] }`: a release of the [support matrix](support-matrix.md). |
|
|
186
|
+
| `worker.requiredCapabilities` | Normally all of `github`, `vault`, `t3`, `toolchain`, `workstation`, `worker`. |
|
|
187
|
+
| `worker.githubLogin` | The GitHub login every worker must be signed in as. |
|
|
188
|
+
| `github` (optional) | Who the manager signs in to GitHub as, per-node tokens, required scopes; see [GitHub](github.md). |
|
|
189
|
+
| `worker.vaultUser` | The Vault user each worker's token is issued for. |
|
|
190
|
+
| `worker.toolchain` | `"mise.lock"` (fixed). |
|
|
191
|
+
| `worker.unattendedSudo`, `neverSleep` | `true` (fixed policy). |
|
|
192
192
|
|
|
193
193
|
Use the same values in every place they repeat. Validate before going on:
|
|
194
194
|
|
package/docs/releasing.md
CHANGED
|
@@ -18,8 +18,9 @@ release pins (a dependency of the package), falling back to a Bun on `PATH`.
|
|
|
18
18
|
|
|
19
19
|
Machines do not run the package. `sync` rebuilds every machine from one
|
|
20
20
|
git commit of this repository, and the package says which: the Release
|
|
21
|
-
workflow writes the commit it publishes from
|
|
22
|
-
|
|
21
|
+
workflow writes the commit it publishes from, and that commit's date, into
|
|
22
|
+
the package's `package.json` as `gitHead` and `gitCommittedAt`
|
|
23
|
+
([`src/package-info.ts`](../src/package-info.ts) reads them). Run
|
|
23
24
|
from the package, `sync` fetches that commit from the repository
|
|
24
25
|
`fleet.json` names under `source` into a cache the manager owns, and converges
|
|
25
26
|
the manager and every worker from checkouts of it. So a version of the package
|
|
@@ -42,8 +43,9 @@ Release. The commit messages choose the bump:
|
|
|
42
43
|
| otherwise any `feat:` | minor |
|
|
43
44
|
| otherwise | patch |
|
|
44
45
|
|
|
45
|
-
`package.json` stays at `0.0.0-development` and carries no `gitHead
|
|
46
|
-
workflow stamps the version
|
|
46
|
+
`package.json` stays at `0.0.0-development` and carries no `gitHead` or
|
|
47
|
+
`gitCommittedAt`; the workflow stamps the version, the commit and its date
|
|
48
|
+
into the package it publishes, so
|
|
47
49
|
nobody edits a version or runs `npm publish` by hand after the one-time setup
|
|
48
50
|
below. Merges that land while a release runs
|
|
49
51
|
wait, and the newest one releases everything since the last tag. A run that
|
package/examples/fleet.json
CHANGED
package/mise.lock
CHANGED
|
@@ -1410,63 +1410,63 @@ checksum = "sha256:98ee2ce86421b2e2ff24b4d3c081883487694371b8ca2e40e125f413677a5
|
|
|
1410
1410
|
url = "https://dl.k8s.io/v1.37.3/bin/windows/amd64/kubectl.exe"
|
|
1411
1411
|
|
|
1412
1412
|
[[tools.litestream]]
|
|
1413
|
-
version = "0.5.
|
|
1413
|
+
version = "0.5.19"
|
|
1414
1414
|
backend = "aqua:benbjohnson/litestream"
|
|
1415
|
-
specifiers = ["0.5.
|
|
1415
|
+
specifiers = ["0.5.19"]
|
|
1416
1416
|
|
|
1417
1417
|
[tools.litestream."platforms.linux-arm64"]
|
|
1418
|
-
checksum = "sha256:
|
|
1418
|
+
checksum = "sha256:031b0929c903a52b3a90177f16c168b837bd01978027237806fdca88bbd970f9"
|
|
1419
1419
|
checksum_source = "mise-versions"
|
|
1420
|
-
url = "https://github.com/benbjohnson/litestream/releases/download/v0.5.
|
|
1421
|
-
url_api = "https://api.github.com/repos/benbjohnson/litestream/releases/assets/
|
|
1420
|
+
url = "https://github.com/benbjohnson/litestream/releases/download/v0.5.19/litestream-0.5.19-linux-arm64.tar.gz"
|
|
1421
|
+
url_api = "https://api.github.com/repos/benbjohnson/litestream/releases/assets/823447946"
|
|
1422
1422
|
|
|
1423
1423
|
[tools.litestream."platforms.linux-arm64-musl"]
|
|
1424
|
-
checksum = "sha256:
|
|
1424
|
+
checksum = "sha256:031b0929c903a52b3a90177f16c168b837bd01978027237806fdca88bbd970f9"
|
|
1425
1425
|
checksum_source = "mise-versions"
|
|
1426
|
-
url = "https://github.com/benbjohnson/litestream/releases/download/v0.5.
|
|
1427
|
-
url_api = "https://api.github.com/repos/benbjohnson/litestream/releases/assets/
|
|
1426
|
+
url = "https://github.com/benbjohnson/litestream/releases/download/v0.5.19/litestream-0.5.19-linux-arm64.tar.gz"
|
|
1427
|
+
url_api = "https://api.github.com/repos/benbjohnson/litestream/releases/assets/823447946"
|
|
1428
1428
|
|
|
1429
1429
|
[tools.litestream."platforms.linux-x64"]
|
|
1430
|
-
checksum = "sha256:
|
|
1430
|
+
checksum = "sha256:35d6df14ea5462e442a56f819318a6fd305ae7d9f8a5d9b71b27662124c2ec87"
|
|
1431
1431
|
checksum_source = "mise-versions"
|
|
1432
|
-
url = "https://github.com/benbjohnson/litestream/releases/download/v0.5.
|
|
1433
|
-
url_api = "https://api.github.com/repos/benbjohnson/litestream/releases/assets/
|
|
1432
|
+
url = "https://github.com/benbjohnson/litestream/releases/download/v0.5.19/litestream-0.5.19-linux-x86_64.tar.gz"
|
|
1433
|
+
url_api = "https://api.github.com/repos/benbjohnson/litestream/releases/assets/823447949"
|
|
1434
1434
|
|
|
1435
1435
|
[tools.litestream."platforms.linux-x64-baseline"]
|
|
1436
|
-
checksum = "sha256:
|
|
1436
|
+
checksum = "sha256:35d6df14ea5462e442a56f819318a6fd305ae7d9f8a5d9b71b27662124c2ec87"
|
|
1437
1437
|
checksum_source = "mise-versions"
|
|
1438
|
-
url = "https://github.com/benbjohnson/litestream/releases/download/v0.5.
|
|
1439
|
-
url_api = "https://api.github.com/repos/benbjohnson/litestream/releases/assets/
|
|
1438
|
+
url = "https://github.com/benbjohnson/litestream/releases/download/v0.5.19/litestream-0.5.19-linux-x86_64.tar.gz"
|
|
1439
|
+
url_api = "https://api.github.com/repos/benbjohnson/litestream/releases/assets/823447949"
|
|
1440
1440
|
|
|
1441
1441
|
[tools.litestream."platforms.linux-x64-musl"]
|
|
1442
|
-
checksum = "sha256:
|
|
1442
|
+
checksum = "sha256:35d6df14ea5462e442a56f819318a6fd305ae7d9f8a5d9b71b27662124c2ec87"
|
|
1443
1443
|
checksum_source = "mise-versions"
|
|
1444
|
-
url = "https://github.com/benbjohnson/litestream/releases/download/v0.5.
|
|
1445
|
-
url_api = "https://api.github.com/repos/benbjohnson/litestream/releases/assets/
|
|
1444
|
+
url = "https://github.com/benbjohnson/litestream/releases/download/v0.5.19/litestream-0.5.19-linux-x86_64.tar.gz"
|
|
1445
|
+
url_api = "https://api.github.com/repos/benbjohnson/litestream/releases/assets/823447949"
|
|
1446
1446
|
|
|
1447
1447
|
[tools.litestream."platforms.linux-x64-musl-baseline"]
|
|
1448
|
-
checksum = "sha256:
|
|
1448
|
+
checksum = "sha256:35d6df14ea5462e442a56f819318a6fd305ae7d9f8a5d9b71b27662124c2ec87"
|
|
1449
1449
|
checksum_source = "mise-versions"
|
|
1450
|
-
url = "https://github.com/benbjohnson/litestream/releases/download/v0.5.
|
|
1451
|
-
url_api = "https://api.github.com/repos/benbjohnson/litestream/releases/assets/
|
|
1450
|
+
url = "https://github.com/benbjohnson/litestream/releases/download/v0.5.19/litestream-0.5.19-linux-x86_64.tar.gz"
|
|
1451
|
+
url_api = "https://api.github.com/repos/benbjohnson/litestream/releases/assets/823447949"
|
|
1452
1452
|
|
|
1453
1453
|
[tools.litestream."platforms.macos-arm64"]
|
|
1454
|
-
checksum = "sha256:
|
|
1454
|
+
checksum = "sha256:83c521ee9d024e3edce9c96c53ec2c9bbda252e935638b1b61dfdd861635c227"
|
|
1455
1455
|
checksum_source = "mise-versions"
|
|
1456
|
-
url = "https://github.com/benbjohnson/litestream/releases/download/v0.5.
|
|
1457
|
-
url_api = "https://api.github.com/repos/benbjohnson/litestream/releases/assets/
|
|
1456
|
+
url = "https://github.com/benbjohnson/litestream/releases/download/v0.5.19/litestream-0.5.19-darwin-arm64.tar.gz"
|
|
1457
|
+
url_api = "https://api.github.com/repos/benbjohnson/litestream/releases/assets/823448063"
|
|
1458
1458
|
|
|
1459
1459
|
[tools.litestream."platforms.macos-x64"]
|
|
1460
|
-
checksum = "sha256:
|
|
1460
|
+
checksum = "sha256:7e5f1d1d98645d6d7c60570a99f9dd720e92f9818478d20e1954b2ba67190b66"
|
|
1461
1461
|
checksum_source = "mise-versions"
|
|
1462
|
-
url = "https://github.com/benbjohnson/litestream/releases/download/v0.5.
|
|
1463
|
-
url_api = "https://api.github.com/repos/benbjohnson/litestream/releases/assets/
|
|
1462
|
+
url = "https://github.com/benbjohnson/litestream/releases/download/v0.5.19/litestream-0.5.19-darwin-x86_64.tar.gz"
|
|
1463
|
+
url_api = "https://api.github.com/repos/benbjohnson/litestream/releases/assets/823447945"
|
|
1464
1464
|
|
|
1465
1465
|
[tools.litestream."platforms.macos-x64-baseline"]
|
|
1466
|
-
checksum = "sha256:
|
|
1466
|
+
checksum = "sha256:7e5f1d1d98645d6d7c60570a99f9dd720e92f9818478d20e1954b2ba67190b66"
|
|
1467
1467
|
checksum_source = "mise-versions"
|
|
1468
|
-
url = "https://github.com/benbjohnson/litestream/releases/download/v0.5.
|
|
1469
|
-
url_api = "https://api.github.com/repos/benbjohnson/litestream/releases/assets/
|
|
1468
|
+
url = "https://github.com/benbjohnson/litestream/releases/download/v0.5.19/litestream-0.5.19-darwin-x86_64.tar.gz"
|
|
1469
|
+
url_api = "https://api.github.com/repos/benbjohnson/litestream/releases/assets/823447945"
|
|
1470
1470
|
|
|
1471
1471
|
[[tools.ninja]]
|
|
1472
1472
|
version = "1.13.2"
|
package/mise.toml
CHANGED
|
@@ -25,7 +25,7 @@ azure-cli = { version = "2.94.0", lazy = true }
|
|
|
25
25
|
# CLI proxy backups on the manager (cliproxy/scripts/install-dependencies).
|
|
26
26
|
restic = { version = "0.20.0", os = ["linux", "macos"], lazy = true }
|
|
27
27
|
# Replicates the fleet state database to the storage bucket (src/state).
|
|
28
|
-
litestream = { version = "0.5.
|
|
28
|
+
litestream = { version = "0.5.19", os = ["linux", "macos"], lazy = true }
|
|
29
29
|
pnpm = "12.25.1"
|
|
30
30
|
"npm:@yarnpkg/cli-dist" = "4.19.0"
|
|
31
31
|
deno = "2.9.8"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crvouga/homelab",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.25.0",
|
|
4
4
|
"description": "Keeps a set of development machines in sync: one manager and many workers",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "github:crvouga/homelab",
|
|
@@ -73,5 +73,6 @@
|
|
|
73
73
|
"engines": {
|
|
74
74
|
"node": ">=22"
|
|
75
75
|
},
|
|
76
|
-
"gitHead": "
|
|
76
|
+
"gitHead": "29f68ea25349af4bcc3fc0315aba6ec39d7a282f",
|
|
77
|
+
"gitCommittedAt": "2026-12-02"
|
|
77
78
|
}
|
package/schema/fleet.schema.json
CHANGED
|
@@ -470,7 +470,6 @@
|
|
|
470
470
|
"vaultUser",
|
|
471
471
|
"toolchain",
|
|
472
472
|
"unattendedSudo",
|
|
473
|
-
"persistentT3",
|
|
474
473
|
"neverSleep"
|
|
475
474
|
],
|
|
476
475
|
"properties": {
|
|
@@ -505,9 +504,6 @@
|
|
|
505
504
|
"unattendedSudo": {
|
|
506
505
|
"const": true
|
|
507
506
|
},
|
|
508
|
-
"persistentT3": {
|
|
509
|
-
"const": true
|
|
510
|
-
},
|
|
511
507
|
"neverSleep": {
|
|
512
508
|
"const": true
|
|
513
509
|
},
|
|
@@ -52,6 +52,19 @@
|
|
|
52
52
|
}
|
|
53
53
|
},
|
|
54
54
|
"desiredRevision": { "type": ["string", "null"] },
|
|
55
|
+
"homelab": {
|
|
56
|
+
"description": "The homelab release this run is: its version, the commit it runs from and that commit's date.",
|
|
57
|
+
"type": "object",
|
|
58
|
+
"required": ["version", "revision", "committedAt"],
|
|
59
|
+
"properties": {
|
|
60
|
+
"version": { "type": "string" },
|
|
61
|
+
"revision": { "type": ["string", "null"] },
|
|
62
|
+
"committedAt": {
|
|
63
|
+
"type": ["string", "null"],
|
|
64
|
+
"pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$"
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
},
|
|
55
68
|
"selectedBy": {
|
|
56
69
|
"description": "What selected the desired revision: the installed package, --revision, --rollback, the manager's schedule, the HEAD of the checkout converge was started in, or the revision already approved.",
|
|
57
70
|
"type": "object",
|
|
@@ -113,6 +126,16 @@
|
|
|
113
126
|
},
|
|
114
127
|
"desiredRevision": { "type": ["string", "null"] },
|
|
115
128
|
"appliedRevision": { "type": ["string", "null"] },
|
|
129
|
+
"homelab": {
|
|
130
|
+
"description": "The release this node runs. version is null when its commit is not the run's: the commit and its date still name the older one.",
|
|
131
|
+
"type": "object",
|
|
132
|
+
"required": ["version", "revision", "committedAt"],
|
|
133
|
+
"properties": {
|
|
134
|
+
"version": { "type": ["string", "null"] },
|
|
135
|
+
"revision": { "type": ["string", "null"] },
|
|
136
|
+
"committedAt": { "type": ["string", "null"] }
|
|
137
|
+
}
|
|
138
|
+
},
|
|
116
139
|
"durationMs": { "type": "number" },
|
|
117
140
|
"earlierChecks": {
|
|
118
141
|
"type": "array",
|
|
@@ -3,7 +3,13 @@ import { readFileSync } from 'node:fs';
|
|
|
3
3
|
import { homedir } from 'node:os';
|
|
4
4
|
import { join } from 'node:path';
|
|
5
5
|
import { prepareSource } from '../machine/source';
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
encodeRelease,
|
|
8
|
+
PACKAGE_ROOT,
|
|
9
|
+
packageInfo,
|
|
10
|
+
RELEASE_ENV,
|
|
11
|
+
releaseIdentity,
|
|
12
|
+
} from '../package-info';
|
|
7
13
|
import {
|
|
8
14
|
encodeSelection,
|
|
9
15
|
SELECTED_BY_ENV,
|
|
@@ -89,6 +95,9 @@ export async function runFromCheckout(
|
|
|
89
95
|
if (!repository || !script) return null;
|
|
90
96
|
// The run script makes its checkout from this repository.
|
|
91
97
|
process.env['HOMELAB_REPO'] = repository;
|
|
98
|
+
// The checkout's own package stays at the development version, so the
|
|
99
|
+
// process that starts it says which release this run is.
|
|
100
|
+
process.env[RELEASE_ENV] = encodeRelease(releaseIdentity());
|
|
92
101
|
// It is given --revision, which does not say what selected the revision.
|
|
93
102
|
if (source.selection)
|
|
94
103
|
process.env[SELECTED_BY_ENV] = encodeSelection(revision, source.selection);
|
|
@@ -2,6 +2,7 @@ import { SLOW_NODE_MS, slowest } from './fleet-sync-timing';
|
|
|
2
2
|
import { Chalk, type ChalkInstance } from 'chalk';
|
|
3
3
|
import type { ManagerNode, ManagerReport } from '../manager-sync';
|
|
4
4
|
import { selectionText } from '../revision-selection';
|
|
5
|
+
import { releaseLine } from '../package-info';
|
|
5
6
|
import { blocking, type Check, type Status } from '../types';
|
|
6
7
|
|
|
7
8
|
/** Report columns: each owns the checks whose id matches. A check matches the
|
|
@@ -130,6 +131,7 @@ export function managerText(
|
|
|
130
131
|
`${c.dim('report ')} ${options.reportPath} ${c.dim('(full JSON; or rerun with --json)')}`
|
|
131
132
|
);
|
|
132
133
|
lines.push(...selectedLine(c, report));
|
|
134
|
+
lines.push(...releaseLines(c, report));
|
|
133
135
|
if (report.enrolled?.length)
|
|
134
136
|
lines.push(`${c.dim('enrolled ')} ${report.enrolled.join(', ')}`);
|
|
135
137
|
if (report.candidates)
|
|
@@ -159,6 +161,21 @@ function slowLines(c: ChalkInstance, nodes: ManagerNode[]): string[] {
|
|
|
159
161
|
});
|
|
160
162
|
}
|
|
161
163
|
|
|
164
|
+
/** `release w1 952dd2ba7785 (2026-12-01)`, for a node that does not run
|
|
165
|
+
* this release: its commit and date, so the older one is visible.
|
|
166
|
+
*/
|
|
167
|
+
function releaseLines(c: ChalkInstance, report: ManagerReport): string[] {
|
|
168
|
+
const current = report.homelab?.revision ?? null;
|
|
169
|
+
return report.nodes.flatMap((node) => {
|
|
170
|
+
const revision = node.homelab?.revision;
|
|
171
|
+
if (!revision || revision === current) return [];
|
|
172
|
+
const date = node.homelab?.committedAt ?? 'unknown';
|
|
173
|
+
return [
|
|
174
|
+
`${c.dim('release ')} ${node.node} ${revision.slice(0, 12)} (${date})`,
|
|
175
|
+
];
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
|
|
162
179
|
/** `selected by --revision; replaces 0123456789ab`, when the report says. */
|
|
163
180
|
function selectedLine(c: ChalkInstance, report: ManagerReport): string[] {
|
|
164
181
|
if (!report.selectedBy) return [];
|
|
@@ -210,6 +227,7 @@ function header(
|
|
|
210
227
|
verdict,
|
|
211
228
|
`${c.dim('revision')} ${(report.desiredRevision ?? 'none').slice(0, 12)}`,
|
|
212
229
|
];
|
|
230
|
+
if (report.homelab) parts.unshift(c.dim(releaseLine(report.homelab)));
|
|
213
231
|
if (options.durationMs !== undefined)
|
|
214
232
|
parts.push(`${c.dim('in')} ${duration(options.durationMs)}`);
|
|
215
233
|
return parts.join(' ');
|
|
@@ -3,12 +3,15 @@ import ora, { type Ora } from 'ora';
|
|
|
3
3
|
import type { ManagerNode } from '../manager-sync';
|
|
4
4
|
import { blocking } from '../types';
|
|
5
5
|
import { duration } from './fleet-sync-output';
|
|
6
|
+
import { releaseLine, type ReleaseIdentity } from '../package-info';
|
|
6
7
|
|
|
7
8
|
/** Live progress on stderr. A terminal gets one spinner with an elapsed timer
|
|
8
9
|
* and a persisted line per finished step; anything else (pipes, CI, agents)
|
|
9
|
-
* gets timestamped lines plus a heartbeat each minute, never color.
|
|
10
|
+
* gets timestamped lines plus a heartbeat each minute, never color. Every
|
|
11
|
+
* sync opens with the homelab release it runs, before the first machine.
|
|
10
12
|
*/
|
|
11
13
|
export interface SyncProgress {
|
|
14
|
+
open(release: ReleaseIdentity): void;
|
|
12
15
|
step(node: string, phase: string): void;
|
|
13
16
|
finished(node: ManagerNode): void;
|
|
14
17
|
stop(): void;
|
|
@@ -18,7 +21,7 @@ export function syncProgress(
|
|
|
18
21
|
enabled: boolean,
|
|
19
22
|
stream: NodeJS.WriteStream = process.stderr
|
|
20
23
|
): SyncProgress {
|
|
21
|
-
if (!enabled) return { step() {}, finished() {}, stop() {} };
|
|
24
|
+
if (!enabled) return { open() {}, step() {}, finished() {}, stop() {} };
|
|
22
25
|
const live =
|
|
23
26
|
Boolean(stream.isTTY) &&
|
|
24
27
|
process.env['NO_COLOR'] === undefined &&
|
|
@@ -45,6 +48,9 @@ function spinnerProgress(stream: NodeJS.WriteStream): SyncProgress {
|
|
|
45
48
|
spinner = null;
|
|
46
49
|
};
|
|
47
50
|
return {
|
|
51
|
+
open(release) {
|
|
52
|
+
stream.write(`${c.dim(releaseLine(release))}\n`);
|
|
53
|
+
},
|
|
48
54
|
step(node, phase) {
|
|
49
55
|
settle();
|
|
50
56
|
label = `${c.bold(node)} ${phase}`;
|
|
@@ -85,6 +91,9 @@ function lineProgress(stream: NodeJS.WriteStream): SyncProgress {
|
|
|
85
91
|
timer = null;
|
|
86
92
|
};
|
|
87
93
|
return {
|
|
94
|
+
open(release) {
|
|
95
|
+
stream.write(`${releaseLine(release)}\n`);
|
|
96
|
+
},
|
|
88
97
|
step(node, phase) {
|
|
89
98
|
clear();
|
|
90
99
|
const started = Date.now();
|
|
@@ -20,6 +20,11 @@ import { authorizePrivilege } from './fleet-sync-privilege';
|
|
|
20
20
|
import { authorizeVault } from './fleet-sync-vault';
|
|
21
21
|
import { managerFailure } from '../manager-failure';
|
|
22
22
|
import { managerText, stdoutColor } from './fleet-sync-output';
|
|
23
|
+
import {
|
|
24
|
+
commitDate,
|
|
25
|
+
releaseIdentity,
|
|
26
|
+
type ReleaseIdentity,
|
|
27
|
+
} from '../package-info';
|
|
23
28
|
import { syncProgress, type SyncProgress } from './fleet-sync-progress';
|
|
24
29
|
import { saveReport } from './fleet-sync-report';
|
|
25
30
|
import { synchronizeMonitoring } from './fleet-sync-monitoring';
|
|
@@ -103,6 +108,8 @@ export async function selected(
|
|
|
103
108
|
const { nodes, definition: scoped } = active;
|
|
104
109
|
const notes = [...records, ...active.checks];
|
|
105
110
|
const ui = interfaceOptions(options);
|
|
111
|
+
const release = releaseIdentity();
|
|
112
|
+
ui.progress.open(release);
|
|
106
113
|
const planFingerprint = createHash('sha256')
|
|
107
114
|
.update(
|
|
108
115
|
JSON.stringify({ revision: options.revision, definition: scoped, nodes })
|
|
@@ -193,6 +200,8 @@ export async function selected(
|
|
|
193
200
|
).finally(() => ui.progress.stop());
|
|
194
201
|
if (options.enrollment) reportEnrollment(report, options.enrollment);
|
|
195
202
|
reportSelection(report, options);
|
|
203
|
+
report.homelab = release;
|
|
204
|
+
recordNodeReleases(report, release, settings.workspace);
|
|
196
205
|
notes.push(
|
|
197
206
|
...(await meshChecks(canonical, nodes, run, Boolean(options.apply)))
|
|
198
207
|
);
|
|
@@ -374,6 +383,29 @@ function enrollmentRequired(
|
|
|
374
383
|
return failed(report);
|
|
375
384
|
}
|
|
376
385
|
|
|
386
|
+
/** Each node records the release it runs. The run's own commit is this
|
|
387
|
+
* release; an older one keeps its commit and date, with no version.
|
|
388
|
+
*/
|
|
389
|
+
function recordNodeReleases(
|
|
390
|
+
report: ManagerReport,
|
|
391
|
+
release: ReleaseIdentity,
|
|
392
|
+
workspace: string
|
|
393
|
+
): void {
|
|
394
|
+
for (const node of report.nodes) {
|
|
395
|
+
const revision = node.appliedRevision ?? node.desiredRevision;
|
|
396
|
+
const current = revision === release.revision;
|
|
397
|
+
node.homelab = {
|
|
398
|
+
version: current ? release.version : null,
|
|
399
|
+
revision,
|
|
400
|
+
committedAt: current
|
|
401
|
+
? release.committedAt
|
|
402
|
+
: revision
|
|
403
|
+
? commitDate(revision, workspace)
|
|
404
|
+
: null,
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
|
|
377
409
|
function failed(report: ReturnType<typeof managerFailure>): CommandOutcome {
|
|
378
410
|
return {
|
|
379
411
|
exitCode: 1,
|
package/src/definition.ts
CHANGED
|
@@ -1016,7 +1016,6 @@ const POLICY: Record<string, string> = {
|
|
|
1016
1016
|
vaultUser: 'a Vault user name',
|
|
1017
1017
|
toolchain: '"mise.lock"',
|
|
1018
1018
|
unattendedSudo: 'true',
|
|
1019
|
-
persistentT3: 'true',
|
|
1020
1019
|
neverSleep: 'true',
|
|
1021
1020
|
toolProfiles: 'a list of known tool profiles, each once',
|
|
1022
1021
|
tools: 'a list of tool names from homelab’s mise.toml, each once',
|
package/src/manager-sync.ts
CHANGED
|
@@ -34,6 +34,14 @@ export interface ManagerNode extends NodeReport {
|
|
|
34
34
|
reachability: 'online' | 'offline' | 'missing' | 'conflict' | 'unknown';
|
|
35
35
|
desiredRevision: string | null;
|
|
36
36
|
appliedRevision: string | null;
|
|
37
|
+
/** The release this node runs, when it was recorded. A node whose revision
|
|
38
|
+
* is not the run's has no version: the older commit and its date show it.
|
|
39
|
+
*/
|
|
40
|
+
homelab?: {
|
|
41
|
+
version: string | null;
|
|
42
|
+
revision: string | null;
|
|
43
|
+
committedAt: string | null;
|
|
44
|
+
};
|
|
37
45
|
durationMs: number;
|
|
38
46
|
diagnostics?: Diagnostic[];
|
|
39
47
|
/** Observations superseded by a later measurement during this run. */
|
|
@@ -56,6 +64,12 @@ export interface ManagerReport {
|
|
|
56
64
|
selectedBy?: RevisionSelection;
|
|
57
65
|
/** The approved revision this run's revision replaces, when it is another. */
|
|
58
66
|
replacedRevision?: string;
|
|
67
|
+
/** The homelab release this run is: its version, commit and commit date. */
|
|
68
|
+
homelab?: {
|
|
69
|
+
version: string;
|
|
70
|
+
revision: string | null;
|
|
71
|
+
committedAt: string | null;
|
|
72
|
+
};
|
|
59
73
|
/** The worker that proved a revision new to the fleet first, when one did. */
|
|
60
74
|
canary?: string;
|
|
61
75
|
/** The workers this run enrolled (added to the roster, or bound to their
|
package/src/package-info.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { execFileSync } from 'node:child_process';
|
|
1
2
|
import { existsSync, readFileSync } from 'node:fs';
|
|
2
3
|
import { join } from 'node:path';
|
|
3
4
|
import { fileURLToPath } from 'node:url';
|
|
@@ -30,10 +31,19 @@ export interface PackageInfo {
|
|
|
30
31
|
version: string;
|
|
31
32
|
/** The commit this package was published from; null in a checkout. */
|
|
32
33
|
revision: string | null;
|
|
34
|
+
/** The calendar date of that commit, `YYYY-MM-DD`; null when unknown. */
|
|
35
|
+
committedAt: string | null;
|
|
33
36
|
/** Where a defect or a feature request is raised (`bugs` in the manifest). */
|
|
34
37
|
issues: string | null;
|
|
35
38
|
}
|
|
36
39
|
|
|
40
|
+
/** A real calendar day, `YYYY-MM-DD`: `2026-13-01` is not one. */
|
|
41
|
+
function calendarDate(value: string): boolean {
|
|
42
|
+
if (!/^\d{4}-\d{2}-\d{2}$/.test(value)) return false;
|
|
43
|
+
const date = new Date(`${value}T00:00:00Z`);
|
|
44
|
+
return !Number.isNaN(date.getTime()) && date.toISOString().startsWith(value);
|
|
45
|
+
}
|
|
46
|
+
|
|
37
47
|
function issueTracker(bugs: unknown): string | null {
|
|
38
48
|
const url =
|
|
39
49
|
typeof bugs === 'object' && bugs !== null
|
|
@@ -43,16 +53,23 @@ function issueTracker(bugs: unknown): string | null {
|
|
|
43
53
|
}
|
|
44
54
|
|
|
45
55
|
/** What the running package says about itself. The release workflow stamps
|
|
46
|
-
* the version
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
56
|
+
* the version, the commit (`gitHead`) and that commit's date
|
|
57
|
+
* (`gitCommittedAt`) into the package it publishes, so an installed homelab
|
|
58
|
+
* knows which revision every machine has to run and how old it is. A
|
|
59
|
+
* checkout carries none of them: its revision is its own HEAD. The issue
|
|
60
|
+
* tracker comes from the manifest too, so a fork sends its users to its own.
|
|
50
61
|
*/
|
|
51
62
|
export function packageInfo(root = PACKAGE_ROOT): PackageInfo {
|
|
52
63
|
const manifest = JSON.parse(
|
|
53
64
|
readFileSync(join(root, 'package.json'), 'utf8')
|
|
54
|
-
) as {
|
|
55
|
-
|
|
65
|
+
) as {
|
|
66
|
+
name?: unknown;
|
|
67
|
+
version?: unknown;
|
|
68
|
+
gitHead?: unknown;
|
|
69
|
+
gitCommittedAt?: unknown;
|
|
70
|
+
bugs?: unknown;
|
|
71
|
+
};
|
|
72
|
+
const { gitHead, gitCommittedAt } = manifest;
|
|
56
73
|
return {
|
|
57
74
|
name: String(manifest.name),
|
|
58
75
|
version: String(manifest.version),
|
|
@@ -60,6 +77,87 @@ export function packageInfo(root = PACKAGE_ROOT): PackageInfo {
|
|
|
60
77
|
typeof gitHead === 'string' && /^[a-f0-9]{40}$/.test(gitHead)
|
|
61
78
|
? gitHead
|
|
62
79
|
: null,
|
|
80
|
+
committedAt:
|
|
81
|
+
typeof gitCommittedAt === 'string' && calendarDate(gitCommittedAt)
|
|
82
|
+
? gitCommittedAt
|
|
83
|
+
: null,
|
|
63
84
|
issues: issueTracker(manifest.bugs),
|
|
64
85
|
};
|
|
65
86
|
}
|
|
87
|
+
|
|
88
|
+
/** The release a converge run names: the package's version, the commit it
|
|
89
|
+
* runs from and that commit's date. The process that starts the run tells
|
|
90
|
+
* the checkout it hands off to, because that checkout's own manifest stays
|
|
91
|
+
* at the development version.
|
|
92
|
+
*/
|
|
93
|
+
export interface ReleaseIdentity {
|
|
94
|
+
version: string;
|
|
95
|
+
revision: string | null;
|
|
96
|
+
committedAt: string | null;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** `0.23.14:952dd2ba…:2026-12-01`. An empty commit or date is unknown. */
|
|
100
|
+
export function encodeRelease(release: ReleaseIdentity): string {
|
|
101
|
+
return `${release.version}:${release.revision ?? ''}:${release.committedAt ?? ''}`;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const TOLD_RELEASE = /^([^:]+):([a-f0-9]{40})?:(\d{4}-\d{2}-\d{2})?$/;
|
|
105
|
+
|
|
106
|
+
/** What the process that started this run said it is, or null. */
|
|
107
|
+
export function decodeRelease(
|
|
108
|
+
text: string | undefined
|
|
109
|
+
): ReleaseIdentity | null {
|
|
110
|
+
const told = TOLD_RELEASE.exec(text ?? '');
|
|
111
|
+
if (!told) return null;
|
|
112
|
+
return {
|
|
113
|
+
version: told[1]!,
|
|
114
|
+
revision: told[2] ?? null,
|
|
115
|
+
committedAt: told[3] ?? null,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** How a run tells the checkout it starts which release it is. */
|
|
120
|
+
export const RELEASE_ENV = 'HOMELAB_RELEASE';
|
|
121
|
+
|
|
122
|
+
/** The release this process runs: what it was told, else its own package.
|
|
123
|
+
* A checkout has no stamped commit, so the date is read from Git.
|
|
124
|
+
*/
|
|
125
|
+
export function releaseIdentity(cwd = PACKAGE_ROOT): ReleaseIdentity {
|
|
126
|
+
const told = decodeRelease(process.env[RELEASE_ENV]);
|
|
127
|
+
if (told) return told;
|
|
128
|
+
const info = packageInfo(cwd);
|
|
129
|
+
return {
|
|
130
|
+
version: info.version,
|
|
131
|
+
revision: info.revision,
|
|
132
|
+
committedAt:
|
|
133
|
+
info.committedAt ??
|
|
134
|
+
(info.revision ? commitDate(info.revision, cwd) : null),
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/** `homelab 0.23.14 (952dd2ba7785, 2026-12-01)`. */
|
|
139
|
+
export function releaseLine(release: ReleaseIdentity): string {
|
|
140
|
+
return `homelab ${release.version} (${(release.revision ?? 'unknown').slice(0, 12)}, ${release.committedAt ?? 'unknown'})`;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** The calendar date of a commit this checkout can see, `YYYY-MM-DD`, or
|
|
144
|
+
* null. A published package already carries the date; a checkout asks Git.
|
|
145
|
+
*/
|
|
146
|
+
export function commitDate(
|
|
147
|
+
revision: string,
|
|
148
|
+
cwd = PACKAGE_ROOT
|
|
149
|
+
): string | null {
|
|
150
|
+
if (!/^[a-f0-9]{40}$/.test(revision)) return null;
|
|
151
|
+
try {
|
|
152
|
+
const date = execFileSync('git', ['log', '-1', '--format=%cs', revision], {
|
|
153
|
+
cwd,
|
|
154
|
+
stdio: ['ignore', 'pipe', 'ignore'],
|
|
155
|
+
timeout: 5_000,
|
|
156
|
+
})
|
|
157
|
+
.toString()
|
|
158
|
+
.trim();
|
|
159
|
+
return calendarDate(date) ? date : null;
|
|
160
|
+
} catch {
|
|
161
|
+
return null;
|
|
162
|
+
}
|
|
163
|
+
}
|
package/src/worker-policy.ts
CHANGED
|
@@ -14,7 +14,6 @@ export interface WorkerPolicy {
|
|
|
14
14
|
vaultUser: string;
|
|
15
15
|
toolchain: 'mise.lock';
|
|
16
16
|
unattendedSudo: true;
|
|
17
|
-
persistentT3: true;
|
|
18
17
|
neverSleep: true;
|
|
19
18
|
/** Tool profiles every worker installs on top of the base tools. */
|
|
20
19
|
toolProfiles?: ToolProfile[];
|
|
@@ -52,7 +51,6 @@ const FIELDS: Record<string, (value: unknown) => boolean> = {
|
|
|
52
51
|
typeof value === 'string' && /^[a-zA-Z0-9_.-]{1,64}$/.test(value),
|
|
53
52
|
toolchain: (value) => value === 'mise.lock',
|
|
54
53
|
unattendedSudo: (value) => value === true,
|
|
55
|
-
persistentT3: (value) => value === true,
|
|
56
54
|
neverSleep: (value) => value === true,
|
|
57
55
|
toolProfiles: (value) => value === undefined || toolProfiles(value) !== null,
|
|
58
56
|
tools: (value) => value === undefined || toolNames(value),
|
|
@@ -89,7 +87,7 @@ function toolNames(value: unknown): boolean {
|
|
|
89
87
|
export function parseWorkerPolicy(value: unknown): WorkerPolicy {
|
|
90
88
|
if (!record(value) || policyFault(value) !== null)
|
|
91
89
|
throw new FleetUsageError(
|
|
92
|
-
'Invalid mandatory worker policy. Workers require the locked toolchain, common services, unattended sudo
|
|
90
|
+
'Invalid mandatory worker policy. Workers require the locked toolchain, common services, unattended sudo and no sleep.'
|
|
93
91
|
);
|
|
94
92
|
const exposure =
|
|
95
93
|
value['exposure'] === undefined
|