@crvouga/homelab 0.23.13 → 0.24.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/.mise/locks/npm-vercel/{68.0.0 → 68.2.0}/aube-lock.yaml +73 -297
- package/.mise/locks/npm-vercel/{68.0.0 → 68.2.0}/package.json +1 -1
- package/.mise/locks/npm-wrangler/{4.169.0 → 4.170.0}/aube-lock.yaml +42 -42
- package/.mise/locks/npm-wrangler/{4.169.0 → 4.170.0}/package.json +1 -1
- package/README.md +54 -76
- package/ansible/ubuntu/agent-tool.py +106 -1
- package/ansible/ubuntu/heavy.py +142 -0
- package/ansible/ubuntu/idle-reboot.py +125 -0
- package/ansible/ubuntu/policy.json +58 -3
- package/ansible/ubuntu/t3-desktop.yml +7 -0
- package/ansible/ubuntu/t3-hang-snapshot.sh +75 -0
- package/ansible/ubuntu/t3-headless.yml +7 -0
- package/ansible/ubuntu/t3-health.sh +71 -3
- package/ansible/ubuntu/t3-policy.yml +14 -5
- package/ansible/ubuntu/tasks/packages.yml +2 -0
- package/ansible/ubuntu/tasks/recovery.yml +16 -2
- package/ansible/ubuntu/tasks/resources.yml +25 -2
- package/ansible/ubuntu/tasks/unattended-upgrades.yml +24 -6
- package/ansible/ubuntu/tasks/updates.yml +59 -0
- package/ansible/ubuntu/wip-guard.py +141 -14
- package/bootstrap/doctor.ts +0 -4
- package/bootstrap/project-action.sh +4 -5
- package/bootstrap/shell-path.ts +17 -19
- package/cliproxy/README.md +5 -6
- package/cliproxy/config.template.yaml +1 -15
- package/cliproxy/docs/health-workflow.example.yml +6 -6
- package/cliproxy/docs/model-health.md +8 -8
- package/cliproxy/scripts/accounts.py +3 -4
- package/cliproxy/scripts/fleet_sync.py +2 -13
- package/cliproxy/scripts/ops +3 -21
- package/docs/authentication.md +21 -26
- package/docs/convergence.md +28 -32
- package/docs/declared.md +30 -31
- package/docs/durability.md +9 -0
- package/docs/github.md +0 -9
- package/docs/machine-setup.md +16 -17
- package/docs/manager-recovery.md +0 -2
- package/docs/operations.md +12 -11
- package/docs/releasing.md +18 -21
- package/docs/runbooks.md +22 -78
- package/docs/support-matrix.md +1 -1
- package/docs/ubuntu-sync.md +71 -65
- package/docs/worker-contract.md +112 -15
- package/examples/fleet.json +0 -1
- package/llms.txt +0 -2
- package/mise.lock +206 -780
- package/mise.toml +12 -27
- package/package.json +5 -6
- package/schema/check-ids.json +41 -482
- package/schema/fleet.schema.json +6 -57
- package/schema/roster.schema.json +0 -2
- package/src/agent-session-limit.ts +2 -7
- package/src/auth-checks.ts +1 -3
- package/src/check-owners.ts +0 -13
- package/src/check-registry.ts +13 -72
- package/src/cli/agent-guide.ts +3 -16
- package/src/cli/command-index.ts +0 -12
- package/src/cli/fleet-sync-manager.ts +4 -146
- package/src/cli/fleet-sync-output.ts +1 -4
- package/src/cli/fleet-sync-plan.ts +1 -24
- package/src/cli/fleet-sync-remote.ts +2 -1
- package/src/cli/fleet-sync-vault.ts +1 -2
- package/src/cli/fleet-sync.ts +8 -44
- package/src/cli/fleet.ts +1 -2
- package/src/cli/program.ts +3 -14
- package/src/cli/register-fleet.ts +1 -55
- package/src/cli/registry.ts +1 -43
- package/src/config.ts +0 -2
- package/src/definition.ts +8 -83
- package/src/fleet-config.ts +1 -1
- package/src/ide/definition.ts +2 -29
- package/src/ide/super.ts +4 -35
- package/src/ide/t3.ts +9 -38
- package/src/manager-sync.ts +1 -1
- package/src/node-converge-linux.ts +4 -47
- package/src/node-converge-shared.ts +1 -22
- package/src/{agents/toolchain.ts → pinned-path.ts} +0 -17
- package/src/platform/agent-oom-check.ts +104 -0
- package/src/platform/t3-policy.ts +23 -36
- package/src/platform/t3-service.ts +117 -0
- package/src/platform/wip-guard-check.ts +65 -0
- package/src/remote-entry.ts +2 -41
- package/src/repair-catalog.ts +0 -30
- package/src/schedule-check.ts +17 -4
- package/src/service-auth.ts +0 -50
- package/src/state/litestream.ts +1 -1
- package/src/t3/retire-providers.ts +79 -0
- package/src/t3/version.ts +1 -1
- package/src/transport.ts +2 -6
- package/src/types.ts +0 -2
- package/src/version-parity.ts +0 -8
- package/src/worker-access-checks.ts +0 -75
- package/src/worker-host-checks.ts +78 -1
- package/src/worker-policy.ts +0 -2
- package/src/worker-readiness.ts +2 -0
- package/src/worker-sizing.ts +25 -0
- package/.mise/locks/azure-cli/2.93.0~a837e014/pyproject.toml +0 -5
- package/.mise/locks/azure-cli/2.93.0~a837e014/uv.lock +0 -2841
- package/.mise/locks/gemini/0.71.1~84aac8e6/aube-lock.yaml +0 -124
- package/.mise/locks/gemini/0.71.1~84aac8e6/package.json +0 -12
- package/agents/antigravity-proxy.ts +0 -3
- package/agents/audit.md +0 -88
- package/agents/bin/agy +0 -10
- package/agents/bin/antigravity +0 -10
- package/agents/bin/claude +0 -10
- package/agents/bin/codex +0 -10
- package/agents/bin/grok +0 -10
- package/agents/bin/opencode +0 -10
- package/agents/claude-proxy +0 -5
- package/agents/claude-proxy.ts +0 -3
- package/agents/codex-proxy.ts +0 -3
- package/agents/grok-proxy.ts +0 -3
- package/agents/managed-proxy.ts +0 -109
- package/agents/opencode-proxy.ts +0 -3
- package/agents/registry.json +0 -209
- package/agents/registry.schema.json +0 -149
- package/agents/setup.md +0 -158
- package/agents/t3.json +0 -40
- package/ansible/agents/agents.yml +0 -135
- package/ansible/agents/commands.yml +0 -32
- package/ansible/agents/receipts.yml +0 -19
- package/ansible/agents/templates/antigravity.settings.json.j2 +0 -3
- package/ansible/agents/templates/claude.settings.json.j2 +0 -3
- package/ansible/agents/templates/codex.config.toml.j2 +0 -11
- package/ansible/agents/templates/gemini.settings.json.j2 +0 -14
- package/ansible/agents/templates/grok.config.toml.j2 +0 -25
- package/ansible/agents/templates/opencode.json.j2 +0 -24
- package/ansible/agents/templates/receipt.json.j2 +0 -10
- package/ansible/t3/provider-keys.yml +0 -24
- package/docs/accounts.md +0 -256
- package/src/accounts/checks.ts +0 -226
- package/src/accounts/context.ts +0 -77
- package/src/accounts/propagate.ts +0 -62
- package/src/accounts/roster.ts +0 -112
- package/src/accounts/selection.ts +0 -67
- package/src/accounts/sessions.ts +0 -354
- package/src/agents/account-relay.ts +0 -279
- package/src/agents/accounts.ts +0 -94
- package/src/agents/admission.ts +0 -65
- package/src/agents/audit.ts +0 -77
- package/src/agents/cli.ts +0 -13
- package/src/agents/command.ts +0 -257
- package/src/agents/commands.ts +0 -127
- package/src/agents/converge.ts +0 -339
- package/src/agents/doctor.ts +0 -107
- package/src/agents/errors.ts +0 -2
- package/src/agents/files.ts +0 -43
- package/src/agents/fleet-verify.ts +0 -195
- package/src/agents/launch.ts +0 -361
- package/src/agents/native-verify.ts +0 -738
- package/src/agents/provider-errors.ts +0 -57
- package/src/agents/registry.ts +0 -61
- package/src/agents/render.ts +0 -121
- package/src/agents/round-trip.ts +0 -192
- package/src/agents/secrets.ts +0 -48
- package/src/agents/verify-cache.ts +0 -164
- package/src/agents/verify.ts +0 -129
- package/src/cli/fleet-accounts.ts +0 -294
- package/src/cli/fleet-sync-accounts.ts +0 -62
- package/src/cli/node-deployment.ts +0 -34
- package/src/cli/node-sync.ts +0 -121
- package/src/cli/node-t3.ts +0 -35
- package/src/cli/t3/command.ts +0 -91
- package/src/cli/t3/register.ts +0 -56
- package/src/configure.ts +0 -271
- package/src/github/copilot.ts +0 -54
- package/src/t3/accounts.ts +0 -90
- package/src/t3/antigravity.ts +0 -93
- package/src/t3/desired.ts +0 -174
- package/src/t3/diagnostics.ts +0 -42
- package/src/t3/models.ts +0 -354
- package/src/t3/names-check.ts +0 -53
- package/src/t3/names.ts +0 -155
- package/src/t3/plan.ts +0 -106
- package/src/t3/provider-keys.ts +0 -49
- package/src/t3/providers.ts +0 -102
- package/src/t3/reconcile.ts +0 -133
package/src/remote-entry.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { configureWorkspace, validConfiguration } from './configure';
|
|
2
1
|
import { parseConfig, record } from './config';
|
|
3
2
|
import { probe } from './probe';
|
|
4
3
|
import { runCommand } from './runner';
|
|
@@ -6,9 +5,6 @@ import { syncWorkspace } from './sync';
|
|
|
6
5
|
import { repairWorkspace, validRepairs } from './repair-runner';
|
|
7
6
|
import { validSnapshot } from './protocol';
|
|
8
7
|
import type { Fingerprint } from './types';
|
|
9
|
-
import { machineProviders } from './t3/providers';
|
|
10
|
-
import { accountModels } from './t3/models';
|
|
11
|
-
import { accountContext, nodeAccountChecks } from './accounts/context';
|
|
12
8
|
|
|
13
9
|
async function main(): Promise<void> {
|
|
14
10
|
const raw: unknown = JSON.parse(
|
|
@@ -16,9 +12,7 @@ async function main(): Promise<void> {
|
|
|
16
12
|
);
|
|
17
13
|
if (!validRequest(raw)) throw new Error('Invalid request.');
|
|
18
14
|
const node = parseConfig({ version: 1, nodes: [raw['node']] }).nodes[0]!;
|
|
19
|
-
if (raw['action'] === '
|
|
20
|
-
await configureRequest(raw, node);
|
|
21
|
-
} else if (raw['action'] === 'repair') {
|
|
15
|
+
if (raw['action'] === 'repair') {
|
|
22
16
|
if (
|
|
23
17
|
raw['apply'] !== true ||
|
|
24
18
|
!validRepairs(raw['repairs']) ||
|
|
@@ -39,18 +33,6 @@ async function main(): Promise<void> {
|
|
|
39
33
|
raw['expected'] as Fingerprint
|
|
40
34
|
);
|
|
41
35
|
process.stdout.write(JSON.stringify({ version: 1, checks }));
|
|
42
|
-
} else if (raw['action'] === 'accounts') {
|
|
43
|
-
// The fast account path: only the account-derived T3 instances and the
|
|
44
|
-
// models each shows. T3 watches its settings, so no restart and no
|
|
45
|
-
// running turn ends.
|
|
46
|
-
if (raw['apply'] !== true)
|
|
47
|
-
throw new Error('Account propagation requires explicit authorization.');
|
|
48
|
-
const checks = [
|
|
49
|
-
await machineProviders(node.id, node.workspace, true),
|
|
50
|
-
await accountModels(),
|
|
51
|
-
...(await nodeAccountChecks(await accountContext())),
|
|
52
|
-
];
|
|
53
|
-
process.stdout.write(JSON.stringify({ version: 1, checks }));
|
|
54
36
|
} else if (raw['action'] === 'sync') {
|
|
55
37
|
if (raw['apply'] !== true)
|
|
56
38
|
throw new Error('Sync requires explicit authorization.');
|
|
@@ -78,29 +60,8 @@ await main().catch(() => {
|
|
|
78
60
|
process.exitCode = 1;
|
|
79
61
|
});
|
|
80
62
|
|
|
81
|
-
async function configureRequest(
|
|
82
|
-
raw: Record<string, unknown>,
|
|
83
|
-
node: { id: string; workspace: string }
|
|
84
|
-
): Promise<void> {
|
|
85
|
-
if (
|
|
86
|
-
raw['apply'] !== true ||
|
|
87
|
-
!validConfiguration(raw['configuration']) ||
|
|
88
|
-
raw['configuration'].node !== node.id
|
|
89
|
-
)
|
|
90
|
-
throw new Error('Invalid configuration request.');
|
|
91
|
-
const checks = await configureWorkspace(
|
|
92
|
-
node.workspace,
|
|
93
|
-
raw['configuration'],
|
|
94
|
-
runCommand
|
|
95
|
-
);
|
|
96
|
-
process.stdout.write(JSON.stringify({ version: 1, checks }));
|
|
97
|
-
}
|
|
98
|
-
|
|
99
63
|
function validRequest(raw: unknown): raw is Record<string, unknown> {
|
|
100
64
|
return (
|
|
101
|
-
record(raw) &&
|
|
102
|
-
['probe', 'sync', 'repair', 'configure', 'accounts'].includes(
|
|
103
|
-
String(raw['action'])
|
|
104
|
-
)
|
|
65
|
+
record(raw) && ['probe', 'sync', 'repair'].includes(String(raw['action']))
|
|
105
66
|
);
|
|
106
67
|
}
|
package/src/repair-catalog.ts
CHANGED
|
@@ -82,18 +82,6 @@ export const REPAIR_RECIPES: RepairRecipe[] = [
|
|
|
82
82
|
"Renews this machine's own secrets-provider session and the service logins derived from it. No credentials are copied from another computer.",
|
|
83
83
|
commands: [['bun', 'bootstrap/worker-auth.ts']],
|
|
84
84
|
},
|
|
85
|
-
login(
|
|
86
|
-
'codex',
|
|
87
|
-
'Sign in to Codex on this machine',
|
|
88
|
-
[['codex', 'login', '--device-auth']],
|
|
89
|
-
'Approve the device flow in your browser. Run codex login status afterward; retain this machine’s own credential store.'
|
|
90
|
-
),
|
|
91
|
-
login(
|
|
92
|
-
'claude',
|
|
93
|
-
'Sign in to Claude Code on this machine',
|
|
94
|
-
[['claude', 'auth', 'login']],
|
|
95
|
-
'Complete the native browser login, then run claude auth status --json. API-key and subscription contexts can differ.'
|
|
96
|
-
),
|
|
97
85
|
login(
|
|
98
86
|
'github',
|
|
99
87
|
'Sign in to GitHub and configure Git',
|
|
@@ -155,24 +143,6 @@ export const REPAIR_RECIPES: RepairRecipe[] = [
|
|
|
155
143
|
],
|
|
156
144
|
'Complete the specific CLI approval and run npm whoami. Prefer the existing trusted-publisher CI workflow for releases.'
|
|
157
145
|
),
|
|
158
|
-
login(
|
|
159
|
-
'opencode',
|
|
160
|
-
'Authorize an OpenCode provider',
|
|
161
|
-
[['opencode', 'auth', 'login']],
|
|
162
|
-
'Prefer the existing Vault-backed providers repair for managed API keys. Native auth login handles an operator-owned OAuth provider. Credential listing alone does not prove live provider access.'
|
|
163
|
-
),
|
|
164
|
-
login(
|
|
165
|
-
'copilot',
|
|
166
|
-
'Sign in to Copilot',
|
|
167
|
-
[],
|
|
168
|
-
'Copilot CLI uses the node’s GitHub sign-in, which converge brings from the stored credential (github-token). Run converge; store a fine-grained token with the Copilot Requests permission if auth:copilot says the token kind is refused. No per-node copilot login.'
|
|
169
|
-
),
|
|
170
|
-
login(
|
|
171
|
-
'gemini',
|
|
172
|
-
'Sign in to Gemini',
|
|
173
|
-
[],
|
|
174
|
-
'Open Gemini interactively and choose its supported sign-in flow. Provider authorization remains unverified without a supported read-only status adapter.'
|
|
175
|
-
),
|
|
176
146
|
{
|
|
177
147
|
id: 't3',
|
|
178
148
|
title: 'Enable and authorize T3 Connect',
|
package/src/schedule-check.ts
CHANGED
|
@@ -23,12 +23,25 @@ export function scheduleIntervals(
|
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
/** `manager:schedule`:
|
|
27
|
-
*
|
|
26
|
+
/** `manager:schedule`: the fleet is kept converged by the manager's schedule,
|
|
27
|
+
* so one that is off, paused or never turned on fails, and one that is on
|
|
28
|
+
* must have succeeded within two of its intervals.
|
|
28
29
|
*/
|
|
29
|
-
export function scheduleCheck(history: History, now: Date): Check
|
|
30
|
+
export function scheduleCheck(history: History, now: Date): Check {
|
|
30
31
|
const { schedule } = history;
|
|
31
|
-
if (!schedule?.enabled)
|
|
32
|
+
if (!schedule?.enabled)
|
|
33
|
+
return {
|
|
34
|
+
id: 'manager:schedule',
|
|
35
|
+
status: 'fail',
|
|
36
|
+
summary: schedule
|
|
37
|
+
? 'MANAGER_SCHEDULE_OFF: the manager’s schedule is off, so nothing keeps the fleet converged.'
|
|
38
|
+
: 'MANAGER_SCHEDULE_OFF: the manager’s schedule was never turned on, so nothing keeps the fleet converged.',
|
|
39
|
+
remedy: {
|
|
40
|
+
action:
|
|
41
|
+
'Turn the schedule on from the project that pins homelab, on the manager.',
|
|
42
|
+
command: 'homelab converge --schedule enable --apply --yes',
|
|
43
|
+
},
|
|
44
|
+
};
|
|
32
45
|
const window = 2 * schedule.intervalSeconds * 1000;
|
|
33
46
|
const lastSuccess = history.runs
|
|
34
47
|
.filter((run) => run.trigger === 'schedule' && run.ok)
|
package/src/service-auth.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { record } from './config';
|
|
2
|
-
import { copilotCheck } from './github/copilot';
|
|
3
2
|
import type { Check, CommandResult, Runner } from './types';
|
|
4
3
|
|
|
5
4
|
interface Service {
|
|
@@ -16,47 +15,6 @@ function json(result: CommandResult): Record<string, unknown> | null {
|
|
|
16
15
|
return null;
|
|
17
16
|
}
|
|
18
17
|
}
|
|
19
|
-
export async function codingAuth(
|
|
20
|
-
id: 'codex' | 'claude',
|
|
21
|
-
run: Runner
|
|
22
|
-
): Promise<Check[]> {
|
|
23
|
-
return [
|
|
24
|
-
await serviceCheck(
|
|
25
|
-
id === 'codex'
|
|
26
|
-
? {
|
|
27
|
-
id,
|
|
28
|
-
command: ['codex', 'login', 'status'],
|
|
29
|
-
action: 'Run codex login on this computer as its operator.',
|
|
30
|
-
valid: (result) =>
|
|
31
|
-
/^Logged in using (ChatGPT|an API key|API key)\b/im.test(
|
|
32
|
-
`${result.stdout}\n${result.stderr}`
|
|
33
|
-
),
|
|
34
|
-
}
|
|
35
|
-
: {
|
|
36
|
-
id,
|
|
37
|
-
command: ['claude', 'auth', 'status', '--json'],
|
|
38
|
-
action: 'Run claude auth login on this computer as its operator.',
|
|
39
|
-
valid: (result) => json(result)?.['loggedIn'] === true,
|
|
40
|
-
},
|
|
41
|
-
run
|
|
42
|
-
),
|
|
43
|
-
];
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/** Registered agent CLIs with no sign-in of their own to check, and why.
|
|
47
|
-
* Each is `not-applicable` on the proxy route and says where its access is
|
|
48
|
-
* proven instead; none is a silent skip.
|
|
49
|
-
*/
|
|
50
|
-
export const PROXY_ROUTED: Record<string, string> = {
|
|
51
|
-
gemini:
|
|
52
|
-
'gemini signs in through the CLI proxy and has no T3 launcher; provider:gemini:inference proves its route from this node.',
|
|
53
|
-
opencode:
|
|
54
|
-
'opencode signs in through the CLI proxy; agent:muse:session and the per-account agent:opencode sessions prove it from this node.',
|
|
55
|
-
grok: 'grok reads the proxy key from its environment and has no grok login; agent:grok:session proves it from this node.',
|
|
56
|
-
antigravity:
|
|
57
|
-
'antigravity signs in through the CLI proxy; agent:antigravity:session proves it from this node.',
|
|
58
|
-
};
|
|
59
|
-
|
|
60
18
|
/** The services a computer signs in to, each checked as `auth:<id>`. */
|
|
61
19
|
const SERVICES: Service[] = [
|
|
62
20
|
{
|
|
@@ -107,14 +65,6 @@ export const SERVICE_IDS = SERVICES.map((service) => service.id);
|
|
|
107
65
|
export async function serviceAuth(run: Runner): Promise<Check[]> {
|
|
108
66
|
const checks: Check[] = [];
|
|
109
67
|
for (const service of SERVICES) checks.push(await serviceCheck(service, run));
|
|
110
|
-
checks.push(await copilotCheck(run));
|
|
111
|
-
for (const [id, reason] of Object.entries(PROXY_ROUTED))
|
|
112
|
-
checks.push({
|
|
113
|
-
id: `auth:${id}`,
|
|
114
|
-
status: 'not-applicable',
|
|
115
|
-
required: false,
|
|
116
|
-
summary: `AUTH_NOT_SUPPORTED_ON_ROUTE: ${reason}`,
|
|
117
|
-
});
|
|
118
68
|
return checks;
|
|
119
69
|
}
|
|
120
70
|
|
package/src/state/litestream.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { existsSync, mkdirSync, writeFileSync } from 'node:fs';
|
|
2
2
|
import { basename, dirname, join } from 'node:path';
|
|
3
3
|
import { stringify } from 'yaml';
|
|
4
|
-
import { pinnedPath } from '../
|
|
4
|
+
import { pinnedPath } from '../pinned-path';
|
|
5
5
|
import { PACKAGE_ROOT } from '../package-info';
|
|
6
6
|
import type { Runner } from '../types';
|
|
7
7
|
import type { Bucket } from './bucket';
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { rm } from 'node:fs/promises';
|
|
2
|
+
import { object, read, write } from './files';
|
|
3
|
+
import type { Check } from '../types';
|
|
4
|
+
|
|
5
|
+
/** Earlier releases wrote provider instances into T3's settings that ran a
|
|
6
|
+
* launcher of the fleet, and recorded their ids in `personal-managed.json`.
|
|
7
|
+
* The launchers are gone and T3 manages its own providers, so those
|
|
8
|
+
* instances are removed once, and the record with them. An instance the
|
|
9
|
+
* record does not name is never touched.
|
|
10
|
+
*/
|
|
11
|
+
export async function retireManagedProviders(
|
|
12
|
+
home: string,
|
|
13
|
+
apply: boolean
|
|
14
|
+
): Promise<Check> {
|
|
15
|
+
const settingsPath = `${home}/userdata/settings.json`;
|
|
16
|
+
const recordPath = `${home}/userdata/personal-managed.json`;
|
|
17
|
+
try {
|
|
18
|
+
const record = await read(recordPath);
|
|
19
|
+
if (record === null) return pass();
|
|
20
|
+
const owned = object(record)['instances'];
|
|
21
|
+
const ids = Array.isArray(owned)
|
|
22
|
+
? owned.filter((id): id is string => typeof id === 'string')
|
|
23
|
+
: [];
|
|
24
|
+
if (!apply) return pending();
|
|
25
|
+
const raw = await read(settingsPath);
|
|
26
|
+
const settings = object(raw);
|
|
27
|
+
const kept = (value: unknown): Record<string, unknown> | undefined =>
|
|
28
|
+
value && typeof value === 'object' && !Array.isArray(value)
|
|
29
|
+
? Object.fromEntries(
|
|
30
|
+
Object.entries(value).filter(([id]) => !ids.includes(id))
|
|
31
|
+
)
|
|
32
|
+
: undefined;
|
|
33
|
+
const instances = kept(settings['providerInstances']);
|
|
34
|
+
const preferences = kept(settings['providerModelPreferences']);
|
|
35
|
+
if (raw !== null)
|
|
36
|
+
await write(
|
|
37
|
+
settingsPath,
|
|
38
|
+
JSON.stringify(
|
|
39
|
+
{
|
|
40
|
+
...settings,
|
|
41
|
+
...(instances ? { providerInstances: instances } : {}),
|
|
42
|
+
...(preferences ? { providerModelPreferences: preferences } : {}),
|
|
43
|
+
},
|
|
44
|
+
null,
|
|
45
|
+
2
|
|
46
|
+
) + '\n'
|
|
47
|
+
);
|
|
48
|
+
await rm(recordPath, { force: true });
|
|
49
|
+
await rm(`${recordPath}.backup`, { force: true });
|
|
50
|
+
return pass();
|
|
51
|
+
} catch {
|
|
52
|
+
return {
|
|
53
|
+
id: 't3:legacy-providers',
|
|
54
|
+
status: 'fail',
|
|
55
|
+
summary: 'T3_LEGACY_PROVIDERS_UNREADABLE',
|
|
56
|
+
remedy: {
|
|
57
|
+
action:
|
|
58
|
+
'Remove the provider instances the fleet once added from ~/.t3/userdata/settings.json by hand, then delete ~/.t3/userdata/personal-managed.json. Do not share the file.',
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const pass = (): Check => ({
|
|
65
|
+
id: 't3:legacy-providers',
|
|
66
|
+
status: 'pass',
|
|
67
|
+
summary:
|
|
68
|
+
'T3 holds no provider instance an earlier release of the fleet added.',
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
const pending = (): Check => ({
|
|
72
|
+
id: 't3:legacy-providers',
|
|
73
|
+
status: 'warn',
|
|
74
|
+
summary: 'T3_LEGACY_PROVIDERS_PENDING',
|
|
75
|
+
remedy: {
|
|
76
|
+
action:
|
|
77
|
+
'Run homelab converge: it removes the provider instances an earlier release added, which run launchers that no longer exist.',
|
|
78
|
+
},
|
|
79
|
+
});
|
package/src/t3/version.ts
CHANGED
|
@@ -89,7 +89,7 @@ export async function updatesCheck(
|
|
|
89
89
|
}
|
|
90
90
|
: {
|
|
91
91
|
id: 't3:updates',
|
|
92
|
-
status: '
|
|
92
|
+
status: 'fail',
|
|
93
93
|
summary: 'T3_UPDATES_UNMANAGED',
|
|
94
94
|
remedy: {
|
|
95
95
|
action: `T3 on this machine may update itself away from the pinned release. Stage the fleet's policy once, as an administrator: ${stage}`,
|
package/src/transport.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { managedProbeTarget } from './managed-source';
|
|
2
|
-
import type { ConfigurationRequest } from './configure';
|
|
3
2
|
import { remoteCommand, sshFailure, sshArgs } from './ssh';
|
|
4
3
|
import { cleanCheck, decodeSnapshot, validCheck } from './protocol';
|
|
5
4
|
import { record } from './config';
|
|
@@ -21,8 +20,7 @@ export async function bundleProbe(): Promise<string> {
|
|
|
21
20
|
export interface RemoteOptions {
|
|
22
21
|
source: string;
|
|
23
22
|
timeoutMs: number;
|
|
24
|
-
action: 'probe' | 'sync' | 'repair'
|
|
25
|
-
configuration?: ConfigurationRequest;
|
|
23
|
+
action: 'probe' | 'sync' | 'repair';
|
|
26
24
|
repairs?: AutomatedRepair[];
|
|
27
25
|
expected?: Fingerprint;
|
|
28
26
|
pull?: boolean;
|
|
@@ -41,13 +39,11 @@ export async function inspectRemote(
|
|
|
41
39
|
return { node: node.id, checks: [sshFailure(preflight)] };
|
|
42
40
|
}
|
|
43
41
|
const target =
|
|
44
|
-
|
|
45
|
-
options.expected
|
|
42
|
+
options.action === 'probe' && options.expected
|
|
46
43
|
? await managedProbeTarget(node, options.expected.head, run)
|
|
47
44
|
: { node, checks: [] };
|
|
48
45
|
const command = remoteCommand(target.node, {
|
|
49
46
|
action: options.action,
|
|
50
|
-
configuration: options.configuration,
|
|
51
47
|
node: target.node,
|
|
52
48
|
apply: options.action !== 'probe',
|
|
53
49
|
repairs: options.repairs,
|
package/src/types.ts
CHANGED
package/src/version-parity.ts
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ADDITIONAL_PROVIDER_CLIS,
|
|
3
|
-
NATIVE_AGENTS,
|
|
4
|
-
} from './agents/native-verify';
|
|
5
1
|
import type { FleetDefinition } from './definition';
|
|
6
2
|
import { idesOf } from './ide/definition';
|
|
7
3
|
import type { ManagerNode, ManagerReport } from './manager-sync';
|
|
@@ -42,10 +38,6 @@ export function pendingVersions(
|
|
|
42
38
|
'beszel:connection',
|
|
43
39
|
'beszel:freshness',
|
|
44
40
|
'beszel:agent-version',
|
|
45
|
-
...[
|
|
46
|
-
...NATIVE_AGENTS.map((agent) => agent.name),
|
|
47
|
-
...ADDITIONAL_PROVIDER_CLIS,
|
|
48
|
-
].map((name) => 'agent:' + name + ':version'),
|
|
49
41
|
...(idesOf(definition).includes('t3')
|
|
50
42
|
? [
|
|
51
43
|
't3:version',
|
|
@@ -2,7 +2,6 @@ import type { Check, Runner } from './types';
|
|
|
2
2
|
import { fleet } from './fleet-config';
|
|
3
3
|
import { secretsProvider, vaultStatus, vaultTokenLookup } from './secrets';
|
|
4
4
|
import { WORKER_SECRETS_LOGIN, unreadSecret } from './secrets-blocked';
|
|
5
|
-
import { registry } from './agents/registry';
|
|
6
5
|
import { resolveVaultConfig, usesVault } from './vault-config';
|
|
7
6
|
import { record } from './config';
|
|
8
7
|
import { githubCredential } from './github/credential';
|
|
@@ -17,7 +16,6 @@ export async function workerAccessChecks(
|
|
|
17
16
|
): Promise<Check[]> {
|
|
18
17
|
return [
|
|
19
18
|
await githubSync(run, nodeId),
|
|
20
|
-
await proxyAuthentication(run),
|
|
21
19
|
...(usesVault() ? [await vaultRenewalCheck(run)] : []),
|
|
22
20
|
];
|
|
23
21
|
}
|
|
@@ -83,79 +81,6 @@ const secrets = (run: Runner) =>
|
|
|
83
81
|
},
|
|
84
82
|
});
|
|
85
83
|
|
|
86
|
-
/** Vault refuses a read the token's policy does not allow with a 403. */
|
|
87
|
-
const PERMISSION_DENIED = /permission denied|Code: 403/i;
|
|
88
|
-
|
|
89
|
-
async function proxyAuthentication(run: Runner): Promise<Check> {
|
|
90
|
-
// Read through the declared provider, remembering only whether Vault said
|
|
91
|
-
// the policy forbids it: never what it printed.
|
|
92
|
-
let denied = false;
|
|
93
|
-
const secret = secretsProvider(fleet.secrets, {
|
|
94
|
-
run: async (argv) => {
|
|
95
|
-
const result = await run(argv, { timeoutMs: 20_000 });
|
|
96
|
-
if (!result.ok && PERMISSION_DENIED.test(result.stderr)) denied = true;
|
|
97
|
-
return result.ok ? result.stdout : null;
|
|
98
|
-
},
|
|
99
|
-
});
|
|
100
|
-
const forbidden = {
|
|
101
|
-
id: 'worker:proxy-authentication',
|
|
102
|
-
status: 'fail' as const,
|
|
103
|
-
summary: 'VAULT_POLICY_PERMISSION_REQUIRED',
|
|
104
|
-
remedy: {
|
|
105
|
-
action:
|
|
106
|
-
'This worker’s Vault identity was refused the proxy client key by its policy. Grant that identity read access to the declared location in the Vault policy you manage. converge seeds no secret, writes no policy and adds no secret store.',
|
|
107
|
-
},
|
|
108
|
-
};
|
|
109
|
-
const unavailable = {
|
|
110
|
-
id: 'worker:proxy-authentication',
|
|
111
|
-
status: 'fail' as const,
|
|
112
|
-
summary: 'UNATTENDED_PROXY_AUTHENTICATION_REQUIRED',
|
|
113
|
-
remedy: {
|
|
114
|
-
action:
|
|
115
|
-
'Restore this worker’s own Vault authorization and renewal; no other node’s login or gateway identity is copied.',
|
|
116
|
-
},
|
|
117
|
-
};
|
|
118
|
-
try {
|
|
119
|
-
const key = (await secret('proxy-client-key')) ?? '';
|
|
120
|
-
// A policy refuses a session that answers. Vault says the same 403 to a
|
|
121
|
-
// session that lapsed, and nothing at all when it is out of reach: both
|
|
122
|
-
// are this worker's login, not its policy and not a missing key.
|
|
123
|
-
if (denied) return unreadSecret(secret, forbidden, WORKER_SECRETS_LOGIN);
|
|
124
|
-
if (!/^[\x21-\x7e]{16,4096}$/.test(key))
|
|
125
|
-
return unreadSecret(secret, unavailable, WORKER_SECRETS_LOGIN);
|
|
126
|
-
const result = await run(
|
|
127
|
-
[
|
|
128
|
-
'curl',
|
|
129
|
-
'--fail',
|
|
130
|
-
'--silent',
|
|
131
|
-
'--show-error',
|
|
132
|
-
'--max-time',
|
|
133
|
-
'10',
|
|
134
|
-
'--header',
|
|
135
|
-
'@-',
|
|
136
|
-
`${registry.proxy.endpoint}/v1/models`,
|
|
137
|
-
],
|
|
138
|
-
{ input: `Authorization: Bearer ${key}\n`, timeoutMs: 15_000 }
|
|
139
|
-
);
|
|
140
|
-
const data: unknown = JSON.parse(result.stdout);
|
|
141
|
-
if (
|
|
142
|
-
!result.ok ||
|
|
143
|
-
!record(data) ||
|
|
144
|
-
!Array.isArray(data['data']) ||
|
|
145
|
-
!data['data'].length
|
|
146
|
-
)
|
|
147
|
-
return unavailable;
|
|
148
|
-
return {
|
|
149
|
-
...unavailable,
|
|
150
|
-
status: 'pass',
|
|
151
|
-
summary:
|
|
152
|
-
'Worker credential authenticates to the declared singleton gateway model catalog.',
|
|
153
|
-
};
|
|
154
|
-
} catch {
|
|
155
|
-
return unavailable;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
84
|
/** The check that owns this worker's login (`WORKER_SECRETS_LOGIN`): every
|
|
160
85
|
* check here that needed a secret the worker could not read names it. A
|
|
161
86
|
* session that does not answer is a lapsed one only when Vault itself
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { powerRecoveryCheck } from './power-recovery';
|
|
2
2
|
import { auditUbuntu } from './platform/ubuntu-audit';
|
|
3
3
|
import { verifyUbuntuBoot } from './platform/ubuntu-verify';
|
|
4
|
+
import { wipGuardCheck } from './platform/wip-guard-check';
|
|
4
5
|
import { verifyResourceSafety } from './platform/resource-verify';
|
|
5
6
|
import policy from '../ansible/ubuntu/policy.json';
|
|
6
7
|
import { userInfo } from 'node:os';
|
|
7
8
|
import {
|
|
8
9
|
T3_HEALTH_SCRIPT,
|
|
9
10
|
deadlineRestartsCheck,
|
|
11
|
+
hangEvidence,
|
|
12
|
+
t3StabilityCheck,
|
|
10
13
|
runningVersionCheck,
|
|
11
14
|
t3Unit,
|
|
12
15
|
} from './platform/t3-service';
|
|
@@ -162,6 +165,7 @@ export async function workerHostChecks(
|
|
|
162
165
|
);
|
|
163
166
|
}
|
|
164
167
|
checks.push(await rebootPendingCheck(audit.rebootPending, run));
|
|
168
|
+
checks.push(await updatesPendingCheck(run));
|
|
165
169
|
checks.push(featuresCheck(features, await presentParts(run, user, features)));
|
|
166
170
|
checks.push(
|
|
167
171
|
...(await recoveryChecks(run, features, {
|
|
@@ -201,6 +205,8 @@ async function recoveryChecks(
|
|
|
201
205
|
)
|
|
202
206
|
);
|
|
203
207
|
checks.push(await t3HealthCheck(run));
|
|
208
|
+
checks.push(await wipGuardCheck(run));
|
|
209
|
+
checks.push(await t3StabilityCheck(run, userInfo().homedir));
|
|
204
210
|
checks.push(
|
|
205
211
|
await runningVersionCheck(run, userInfo().uid, Date.now(), features.session)
|
|
206
212
|
);
|
|
@@ -289,7 +295,7 @@ async function t3HealthCheck(run: Runner): Promise<Check> {
|
|
|
289
295
|
return check(
|
|
290
296
|
'worker:t3-health',
|
|
291
297
|
probe.ok && identified,
|
|
292
|
-
|
|
298
|
+
`T3 local API answers with its environment identity within 10 seconds.${await hangEvidence(run, userInfo().homedir)}`
|
|
293
299
|
);
|
|
294
300
|
}
|
|
295
301
|
|
|
@@ -323,3 +329,74 @@ export async function rebootPendingCheck(
|
|
|
323
329
|
},
|
|
324
330
|
};
|
|
325
331
|
}
|
|
332
|
+
|
|
333
|
+
/** The updates Ubuntu's own archives offer, which unattended-upgrades installs
|
|
334
|
+
* by itself (`updates` in `policy.json`). Third-party archives are left out:
|
|
335
|
+
* Docker and Tailscale stay at their pins. A pending update is normal for a
|
|
336
|
+
* day; one that is still pending when unattended-upgrades has not run for
|
|
337
|
+
* `updates.pendingFailDays` means the worker no longer keeps itself up to date.
|
|
338
|
+
*/
|
|
339
|
+
export async function updatesPendingCheck(
|
|
340
|
+
run: Runner,
|
|
341
|
+
now = Date.now()
|
|
342
|
+
): Promise<Check> {
|
|
343
|
+
const id = 'worker:updates-pending';
|
|
344
|
+
const origins = policy.updates.origins.join('|');
|
|
345
|
+
const esm = policy.updates.esm ? '|UbuntuESM\\w*' : '';
|
|
346
|
+
const offered = new RegExp(
|
|
347
|
+
`^Inst \\S+ .*\\(\\S+ (?:Ubuntu${esm}):[^/\\s]+/\\S*-(?:${origins}|apps-security|infra-security)\\b`
|
|
348
|
+
);
|
|
349
|
+
const simulation = await run([
|
|
350
|
+
'apt-get',
|
|
351
|
+
'-s',
|
|
352
|
+
'-o',
|
|
353
|
+
'Debug::NoLocking=1',
|
|
354
|
+
'dist-upgrade',
|
|
355
|
+
]);
|
|
356
|
+
if (!simulation.ok)
|
|
357
|
+
return {
|
|
358
|
+
id,
|
|
359
|
+
status: 'warn',
|
|
360
|
+
summary: 'UPDATES_UNMEASURED: the pending updates could not be listed.',
|
|
361
|
+
remedy: {
|
|
362
|
+
action:
|
|
363
|
+
'Run apt-get -s dist-upgrade on the worker; a package manager that does not answer needs repair before anything updates.',
|
|
364
|
+
},
|
|
365
|
+
};
|
|
366
|
+
const pending = simulation.stdout
|
|
367
|
+
.split('\n')
|
|
368
|
+
.filter((line) => offered.test(line)).length;
|
|
369
|
+
if (pending === 0)
|
|
370
|
+
return {
|
|
371
|
+
id,
|
|
372
|
+
status: 'pass',
|
|
373
|
+
summary: 'Every update Ubuntu offers is installed.',
|
|
374
|
+
};
|
|
375
|
+
const stamp = await run([
|
|
376
|
+
'stat',
|
|
377
|
+
'-c',
|
|
378
|
+
'%Y',
|
|
379
|
+
'/var/lib/apt/periodic/unattended-upgrades-stamp',
|
|
380
|
+
]);
|
|
381
|
+
const seconds = Number(stamp.stdout.trim());
|
|
382
|
+
const days =
|
|
383
|
+
stamp.ok && /^\d+$/.test(stamp.stdout.trim())
|
|
384
|
+
? Math.max(0, Math.floor((now / 1000 - seconds) / DAY_SECONDS))
|
|
385
|
+
: null;
|
|
386
|
+
if (days !== null && days <= policy.updates.pendingFailDays)
|
|
387
|
+
return {
|
|
388
|
+
id,
|
|
389
|
+
status: 'pass',
|
|
390
|
+
summary: `${pending} updates will install at the next unattended run, which last ran ${days} days ago.`,
|
|
391
|
+
};
|
|
392
|
+
return {
|
|
393
|
+
id,
|
|
394
|
+
status: 'fail',
|
|
395
|
+
summary: `UPDATES_NOT_INSTALLING: ${pending} updates are pending and unattended-upgrades ${days === null ? 'has never run' : `last ran ${days} days ago`}.`,
|
|
396
|
+
remedy: {
|
|
397
|
+
action:
|
|
398
|
+
'Run converge for the worker: it declares the unattended-upgrades policy and the timers that run it. Then read journalctl -u apt-daily-upgrade on the worker if updates stay pending.',
|
|
399
|
+
command: 'homelab converge --node <worker>',
|
|
400
|
+
},
|
|
401
|
+
};
|
|
402
|
+
}
|
package/src/worker-policy.ts
CHANGED
|
@@ -13,7 +13,6 @@ export interface WorkerPolicy {
|
|
|
13
13
|
/** Vault userpass login each node uses for its own periodic token. */
|
|
14
14
|
vaultUser: string;
|
|
15
15
|
toolchain: 'mise.lock';
|
|
16
|
-
agentProfile: 'proxy';
|
|
17
16
|
unattendedSudo: true;
|
|
18
17
|
persistentT3: true;
|
|
19
18
|
neverSleep: true;
|
|
@@ -52,7 +51,6 @@ const FIELDS: Record<string, (value: unknown) => boolean> = {
|
|
|
52
51
|
vaultUser: (value) =>
|
|
53
52
|
typeof value === 'string' && /^[a-zA-Z0-9_.-]{1,64}$/.test(value),
|
|
54
53
|
toolchain: (value) => value === 'mise.lock',
|
|
55
|
-
agentProfile: (value) => value === 'proxy',
|
|
56
54
|
unattendedSudo: (value) => value === true,
|
|
57
55
|
persistentT3: (value) => value === true,
|
|
58
56
|
neverSleep: (value) => value === true,
|
package/src/worker-readiness.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { desktopChecks } from './screen-sharing';
|
|
2
|
+
import { agentOomCheck } from './platform/agent-oom-check';
|
|
2
3
|
import {
|
|
3
4
|
pressureEvents,
|
|
4
5
|
rendererCheck,
|
|
@@ -42,6 +43,7 @@ export async function workerReadiness(
|
|
|
42
43
|
sharing ? desktopChecks(sharing.port, run) : [],
|
|
43
44
|
gitChecks(fleet.git, run),
|
|
44
45
|
pressureEvents(run),
|
|
46
|
+
agentOomCheck(run, userInfo().homedir),
|
|
45
47
|
features.session === 'desktop' ? rendererCheck(run) : [],
|
|
46
48
|
t3Protection(exposure.t3Port, run),
|
|
47
49
|
workerCapacity(root, nodeId, run),
|
package/src/worker-sizing.ts
CHANGED
|
@@ -87,3 +87,28 @@ export function supportedSessions(
|
|
|
87
87
|
): number {
|
|
88
88
|
return Math.floor(agentMemoryMiB(memoryMiB) / eachMiB);
|
|
89
89
|
}
|
|
90
|
+
|
|
91
|
+
/** The CPU the policy lets agents use, from the cores of a worker
|
|
92
|
+
* (`resourceSafety.agentCpu` and `heavyTools`), in percent of one CPU.
|
|
93
|
+
* `tasks/resources.yml` writes the same numbers into the agent slice and
|
|
94
|
+
* scopes: every agent together leaves `reservedCpus` cores to T3 and the
|
|
95
|
+
* system, one agent scope takes at most `scopePercentOfCores` of the cores
|
|
96
|
+
* and never less than `minScopeCpus`, and a heavy tool queue has one slot
|
|
97
|
+
* per `coresPerSlot` cores. A worker is never limited below one CPU or one
|
|
98
|
+
* slot.
|
|
99
|
+
*/
|
|
100
|
+
export function agentCpuLimits(cpus: number): {
|
|
101
|
+
slicePercent: number;
|
|
102
|
+
scopePercent: number;
|
|
103
|
+
heavySlots: number;
|
|
104
|
+
} {
|
|
105
|
+
const { agentCpu, heavyTools } = policy.resourceSafety;
|
|
106
|
+
return {
|
|
107
|
+
slicePercent: Math.max((cpus - agentCpu.reservedCpus) * 100, 100),
|
|
108
|
+
scopePercent: Math.max(
|
|
109
|
+
cpus * agentCpu.scopePercentOfCores,
|
|
110
|
+
agentCpu.minScopeCpus * 100
|
|
111
|
+
),
|
|
112
|
+
heavySlots: Math.max(1, Math.floor(cpus / heavyTools.coresPerSlot)),
|
|
113
|
+
};
|
|
114
|
+
}
|