@crvouga/homelab 0.26.0 → 0.27.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.
@@ -204,7 +204,7 @@ async function recoveryChecks(
204
204
  : 'The T3 desktop app runs as an enabled session service with automatic crash recovery.'
205
205
  )
206
206
  );
207
- checks.push(await t3HealthCheck(run, features.session));
207
+ checks.push(await t3HealthCheck(run));
208
208
  checks.push(await wipGuardCheck(run));
209
209
  checks.push(await t3StabilityCheck(run, userInfo().homedir));
210
210
  checks.push(
@@ -269,32 +269,21 @@ export async function serviceRecoveryCheck(run: Runner): Promise<Check> {
269
269
  );
270
270
  }
271
271
 
272
- /** Seconds from this boot until T3's unit became active, or null when the
273
- * clock cannot be read. The unit's monotonic start is measured from boot. */
274
- export async function bootToServingSeconds(
275
- run: Runner,
276
- session: 'desktop' | 'headless' = 'desktop'
277
- ): Promise<number | null> {
278
- const started = await run([
279
- 'systemctl',
280
- '--user',
281
- 'show',
282
- '--property=ActiveEnterTimestampMonotonic',
283
- '--value',
284
- t3Unit(session),
272
+ /** The retained first successful loopback probe, measured from this boot. */
273
+ async function bootToServingSeconds(run: Runner): Promise<number | null> {
274
+ const marker = await run([
275
+ 'cat',
276
+ `/run/user/${userInfo().uid}/personal-t3-boot-readiness-ms`,
285
277
  ]);
286
- const entered = Number(started.stdout.trim());
287
- if (!started.ok || !Number.isSafeInteger(entered) || entered <= 0)
288
- return null;
289
- return entered / 1_000_000;
278
+ const value = marker.stdout.trim();
279
+ const milliseconds = Number(value);
280
+ return marker.ok && /^\d+$/.test(value) && Number.isSafeInteger(milliseconds)
281
+ ? milliseconds / 1000
282
+ : null;
290
283
  }
291
284
 
292
- /** The server answers its local API now, not merely that a process exists,
293
- * with unit activation checked against the boot-serving limit. */
294
- export async function t3HealthCheck(
295
- run: Runner,
296
- session: 'desktop' | 'headless' = 'desktop'
297
- ): Promise<Check> {
285
+ /** Check the current server independently of the boot readiness record. */
286
+ export async function t3HealthCheck(run: Runner): Promise<Check> {
298
287
  const probe = await run(
299
288
  [
300
289
  'curl',
@@ -307,9 +296,7 @@ export async function t3HealthCheck(
307
296
  { timeoutMs: 15_000 }
308
297
  );
309
298
  const answers = probe.ok && hasEnvironmentIdentity(probe.stdout);
310
- const boot = answers
311
- ? await bootServing(run, session)
312
- : { late: false, summary: '' };
299
+ const boot = answers ? await bootServing(run) : { late: false, summary: '' };
313
300
  const ok = answers && !boot.late;
314
301
  return {
315
302
  id: 'worker:t3-health',
@@ -321,7 +308,7 @@ export async function t3HealthCheck(
321
308
  ? {
322
309
  remedy: {
323
310
  action: boot.late
324
- ? 'The T3 unit activated later than t3Service.bootServingSeconds in ansible/ubuntu/policy.json. Read the journal of the T3 unit and of personal-worker-recovery for what delayed the start after boot.'
311
+ ? 'The first successful T3 loopback probe was later than t3Service.bootServingSeconds in ansible/ubuntu/policy.json. Read the journal of the T3 unit and of personal-worker-recovery for what delayed the start after boot.'
325
312
  : 'Apply the approved converge revision over verified SSH, then rerun check --workers. No password prompt or state reset is attempted by health.',
326
313
  },
327
314
  }
@@ -342,22 +329,22 @@ function hasEnvironmentIdentity(response: string): boolean {
342
329
  }
343
330
  }
344
331
 
345
- /** Compare the unit activation time with the boot-serving deadline. */
332
+ /** Compare the first successful loopback probe with the boot-serving deadline. */
346
333
  async function bootServing(
347
- run: Runner,
348
- session: 'desktop' | 'headless'
334
+ run: Runner
349
335
  ): Promise<{ late: boolean; summary: string }> {
350
336
  const limit = policy.t3Service.bootServingSeconds;
351
- const serving = await bootToServingSeconds(run, session);
352
- if (serving === null) return { late: false, summary: '' };
337
+ const serving = await bootToServingSeconds(run);
338
+ if (serving === null)
339
+ return { late: false, summary: ' Boot readiness was not measured.' };
353
340
  if (serving > limit)
354
341
  return {
355
342
  late: true,
356
- summary: `T3_BOOT_SERVING_LATE: The T3 unit activated ${serving} seconds after boot, past the ${limit} seconds a worker is given to serve after a power loss.`,
343
+ summary: `T3_BOOT_SERVING_LATE: The first successful T3 loopback probe was ${serving} seconds after boot, past the ${limit} seconds a worker is given to serve after a power loss.`,
357
344
  };
358
345
  return {
359
346
  late: false,
360
- summary: ` The T3 unit activated ${serving} seconds after boot (at most ${limit}).`,
347
+ summary: ` The first successful T3 loopback probe was ${serving} seconds after boot (at most ${limit}).`,
361
348
  };
362
349
  }
363
350