@runuai/host 0.9.91 → 0.9.92
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/lib/machine-provider-aws.ts +15 -0
- package/lib/vnode-pressure.ts +50 -13
- package/package.json +1 -1
|
@@ -136,6 +136,21 @@ export function awsUserData(authorizedPublicKey: string): string {
|
|
|
136
136
|
' chmod 700 "$home/.ssh"',
|
|
137
137
|
' chmod 600 "$home/.ssh/authorized_keys"',
|
|
138
138
|
"done",
|
|
139
|
+
// Swap BEFORE any workload: an Opus agent + a bundler + Chromium on a
|
|
140
|
+
// swapless machine hits the memory wall as a thrash (load 14, RAM 100%,
|
|
141
|
+
// sshd/code-server accept loops starved — live 2026-08-31 on the first
|
|
142
|
+
// real machine task; the HOSTS got their swapfile in 0.9.85, the
|
|
143
|
+
// machines never did). Best-effort: a machine without fallocate still
|
|
144
|
+
// boots.
|
|
145
|
+
"(fallocate -l 4G /swapfile && chmod 600 /swapfile && mkswap /swapfile && swapon /swapfile && echo '/swapfile none swap sw 0 0' >> /etc/fstab) || true",
|
|
146
|
+
// The task OWNS its machine (ADR-121 — per-customer kernel isolation is
|
|
147
|
+
// the whole point); denying sudo just breaks project setups that
|
|
148
|
+
// container tasks handle fine (live 2026-08-31: a Hightop machine task
|
|
149
|
+
// could not install the Infisical CLI its repo's config expects).
|
|
150
|
+
"echo 'node ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/node && chmod 440 /etc/sudoers.d/node",
|
|
151
|
+
// Infisical CLI: baseline parity with the standard container image —
|
|
152
|
+
// pnpm-secrets-style project setups expect it on PATH. Best-effort.
|
|
153
|
+
"(V=0.43.110; case \$(uname -m) in aarch64|arm64) T=arm64;; *) T=amd64;; esac; curl -fsSL -o /tmp/inf.tgz https://github.com/Infisical/cli/releases/download/v\${V}/cli_\${V}_linux_\${T}.tar.gz && tar -xzf /tmp/inf.tgz -C /tmp infisical && install -m 0755 /tmp/infisical /usr/local/bin/infisical) || true",
|
|
139
154
|
"",
|
|
140
155
|
].join("\n");
|
|
141
156
|
// RAW script, not base64: AWS CLI v2 base64-encodes --user-data ITSELF.
|
package/lib/vnode-pressure.ts
CHANGED
|
@@ -30,12 +30,25 @@ const exec = promisify(execFile);
|
|
|
30
30
|
const ADMISSION_THRESHOLD = 0.9;
|
|
31
31
|
/** Warn-log above this fraction. */
|
|
32
32
|
const WARN_THRESHOLD = 0.8;
|
|
33
|
+
/**
|
|
34
|
+
* The vnode counter ALONE cannot refuse: `kern.num_vnodes` includes the
|
|
35
|
+
* reclaimable vnode cache, and a healthy long-uptime Mac converges to
|
|
36
|
+
* num_vnodes == maxvnodes forever (live false-positive, 2026-08-31: the
|
|
37
|
+
* Studio refused every task at "100%" with ZERO VMs running and the file
|
|
38
|
+
* table at 1.2%). Real virtiofs pinning holds OPEN FILES — the Aug-24
|
|
39
|
+
* incident read 96% of `kern.num_files/kern.maxfiles`. So refusal
|
|
40
|
+
* requires the vnode ratio AND genuine file-table pressure together.
|
|
41
|
+
*/
|
|
42
|
+
const FILE_TABLE_CORROBORATION_THRESHOLD = 0.5;
|
|
33
43
|
const CACHE_MS = 15_000;
|
|
34
44
|
|
|
35
45
|
export interface VnodePressure {
|
|
36
46
|
current: number;
|
|
37
47
|
max: number;
|
|
38
48
|
ratio: number;
|
|
49
|
+
filesCurrent: number;
|
|
50
|
+
filesMax: number;
|
|
51
|
+
filesRatio: number;
|
|
39
52
|
}
|
|
40
53
|
|
|
41
54
|
let cached: { at: number; value: VnodePressure | null } | null = null;
|
|
@@ -47,14 +60,30 @@ export async function readVnodePressure(): Promise<VnodePressure | null> {
|
|
|
47
60
|
try {
|
|
48
61
|
const { stdout } = await exec(
|
|
49
62
|
"/usr/sbin/sysctl",
|
|
50
|
-
["-n", "kern.num_vnodes", "kern.maxvnodes"],
|
|
63
|
+
["-n", "kern.num_vnodes", "kern.maxvnodes", "kern.num_files", "kern.maxfiles"],
|
|
51
64
|
{ timeout: 5_000 },
|
|
52
65
|
);
|
|
53
66
|
const parts = stdout.trim().split(/\s+/).map(Number);
|
|
54
67
|
const current = parts[0] ?? Number.NaN;
|
|
55
68
|
const max = parts[1] ?? Number.NaN;
|
|
56
|
-
|
|
57
|
-
|
|
69
|
+
const filesCurrent = parts[2] ?? Number.NaN;
|
|
70
|
+
const filesMax = parts[3] ?? Number.NaN;
|
|
71
|
+
if (
|
|
72
|
+
Number.isFinite(current) &&
|
|
73
|
+
Number.isFinite(max) &&
|
|
74
|
+
max > 0 &&
|
|
75
|
+
Number.isFinite(filesCurrent) &&
|
|
76
|
+
Number.isFinite(filesMax) &&
|
|
77
|
+
filesMax > 0
|
|
78
|
+
) {
|
|
79
|
+
value = {
|
|
80
|
+
current,
|
|
81
|
+
max,
|
|
82
|
+
ratio: current / max,
|
|
83
|
+
filesCurrent,
|
|
84
|
+
filesMax,
|
|
85
|
+
filesRatio: filesCurrent / filesMax,
|
|
86
|
+
};
|
|
58
87
|
}
|
|
59
88
|
} catch {
|
|
60
89
|
// Sensor failure is never a task failure; admission simply has no data.
|
|
@@ -67,11 +96,15 @@ export async function readVnodePressure(): Promise<VnodePressure | null> {
|
|
|
67
96
|
export async function vnodeAdmissionProblem(): Promise<string | null> {
|
|
68
97
|
const pressure = await readVnodePressure();
|
|
69
98
|
if (!pressure || pressure.ratio < ADMISSION_THRESHOLD) return null;
|
|
99
|
+
// A full vnode table with an idle file table is a warm cache, not danger.
|
|
100
|
+
if (pressure.filesRatio < FILE_TABLE_CORROBORATION_THRESHOLD) return null;
|
|
70
101
|
return (
|
|
71
102
|
`the macOS vnode table is at ${Math.round(pressure.ratio * 100)}% ` +
|
|
72
|
-
`(${pressure.current}/${pressure.max})
|
|
73
|
-
|
|
74
|
-
|
|
103
|
+
`(${pressure.current}/${pressure.max}) with the file table at ` +
|
|
104
|
+
`${Math.round(pressure.filesRatio * 100)}% ` +
|
|
105
|
+
`(${pressure.filesCurrent}/${pressure.filesMax}); starting another task ` +
|
|
106
|
+
"VM risks system-wide file-table exhaustion. Close a running task, or " +
|
|
107
|
+
"raise the ceiling once with: sudo uai-host tune"
|
|
75
108
|
);
|
|
76
109
|
}
|
|
77
110
|
|
|
@@ -82,15 +115,19 @@ let lastLoggedBand: "ok" | "warn" | "critical" = "ok";
|
|
|
82
115
|
export async function logVnodePressure(): Promise<void> {
|
|
83
116
|
const pressure = await readVnodePressure();
|
|
84
117
|
if (!pressure) return;
|
|
85
|
-
const
|
|
86
|
-
pressure.ratio >= ADMISSION_THRESHOLD
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
118
|
+
const refusing =
|
|
119
|
+
pressure.ratio >= ADMISSION_THRESHOLD &&
|
|
120
|
+
pressure.filesRatio >= FILE_TABLE_CORROBORATION_THRESHOLD;
|
|
121
|
+
const band = refusing
|
|
122
|
+
? "critical"
|
|
123
|
+
: pressure.filesRatio >= WARN_THRESHOLD || pressure.ratio >= WARN_THRESHOLD
|
|
124
|
+
? "warn"
|
|
125
|
+
: "ok";
|
|
91
126
|
if (band === lastLoggedBand) return;
|
|
92
127
|
lastLoggedBand = band;
|
|
93
|
-
const detail =
|
|
128
|
+
const detail =
|
|
129
|
+
`vnodes ${pressure.current}/${pressure.max} (${Math.round(pressure.ratio * 100)}%), ` +
|
|
130
|
+
`files ${pressure.filesCurrent}/${pressure.filesMax} (${Math.round(pressure.filesRatio * 100)}%)`;
|
|
94
131
|
if (band === "critical") {
|
|
95
132
|
console.warn(
|
|
96
133
|
`[vnode] table at ${detail} — new apple task VMs will be refused; run: sudo uai-host tune`,
|