@impz/testing 6.2.1 → 6.3.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.
Files changed (2) hide show
  1. package/dist/index.js +56 -7
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -20107,7 +20107,8 @@ var ImpEventDetailSchema = z17.object({
20107
20107
  trigger: z17.string().optional(),
20108
20108
  coldBootReason: z17.string().optional(),
20109
20109
  steps: z17.record(z17.string(), z17.int()).readonly().optional(),
20110
- released: z17.int().positive().optional()
20110
+ released: z17.int().positive().optional(),
20111
+ memFileMib: z17.int().nonnegative().optional()
20111
20112
  }).readonly();
20112
20113
  var envelope = { v: z17.literal(EVENT_VERSION), at: z17.date() };
20113
20114
  var ImpEventSchema = z17.discriminatedUnion("ev", [
@@ -20623,6 +20624,14 @@ var GuestInfoSchema = z33.object({
20623
20624
  scratchDir: z33.string(),
20624
20625
  isClearedOnBoot: z33.boolean()
20625
20626
  });
20627
+ var HostInfoSchema = z33.object({
20628
+ kernel: z33.string(),
20629
+ cpuModel: z33.string(),
20630
+ isNested: z33.boolean(),
20631
+ hugePages: z33.enum(["off", "2M"]),
20632
+ hugePool: z33.object({ totalMib: CountSchema, freeMib: CountSchema }).nullable(),
20633
+ bootTemplates: CountSchema.nullable()
20634
+ });
20626
20635
  var SystemInfoSchema = z33.object({
20627
20636
  version: z33.string(),
20628
20637
  ramBudgetMib: z33.int().nonnegative(),
@@ -20668,7 +20677,8 @@ var SystemInfoSchema = z33.object({
20668
20677
  egress: z33.object({ isEnforced: z33.boolean() }).optional(),
20669
20678
  public: PublicInfoSchema.nullable().optional(),
20670
20679
  https: HttpsInfoSchema.nullable().optional(),
20671
- features: SystemFeaturesSchema.optional()
20680
+ features: SystemFeaturesSchema.optional(),
20681
+ host: HostInfoSchema.optional()
20672
20682
  });
20673
20683
  var SystemFeaturesInfoSchema = z33.object({
20674
20684
  version: z33.string(),
@@ -21950,17 +21960,19 @@ function parseKsmConfig(parsed) {
21950
21960
  }
21951
21961
 
21952
21962
  // packages/daemon/src/create-impd.ts
21963
+ import { readFileSync as readFileSync36 } from "fs";
21953
21964
  import { release as release2 } from "os";
21954
21965
  import { join as join47 } from "path";
21955
21966
  // packages/daemon/package.json
21956
21967
  var package_default = {
21957
21968
  name: "@impz/daemon",
21958
- version: "6.2.1",
21969
+ version: "6.3.0",
21959
21970
  private: true,
21960
21971
  description: "impd: the imp host daemon",
21961
21972
  type: "module",
21962
21973
  exports: {
21963
21974
  ".": "./src/index.ts",
21975
+ "./real-clock": "./src/platform/process/real-clock.ts",
21964
21976
  "./testing": "./testing/index.ts",
21965
21977
  "./testing/build-stub-clock": "./testing/platform/build-stub-clock.ts",
21966
21978
  "./testing/data-layout": "./src/vm/storage/data-layout.ts",
@@ -30519,7 +30531,8 @@ async function readSystemInfo(deps) {
30519
30531
  ksm: readKsmInfo(deps, running, usage.headroomMib),
30520
30532
  public: readPublicInfo(deps.config, imps, deps.publicRecords.readStatus()),
30521
30533
  https: await readHttpsInfo(deps),
30522
- features: SYSTEM_FEATURES
30534
+ features: SYSTEM_FEATURES,
30535
+ host: deps.readHostInfo()
30523
30536
  };
30524
30537
  }
30525
30538
  function readKsmInfo(deps, running, headroomMib) {
@@ -32912,6 +32925,29 @@ function readLimit(request, maxBytes) {
32912
32925
  return declared;
32913
32926
  }
32914
32927
 
32928
+ // packages/daemon/src/surface/read-host-info.ts
32929
+ function readHostInfo(sources) {
32930
+ const cpuInfo = readCpuInfoIfPresent(sources);
32931
+ return {
32932
+ kernel: sources.readKernel(),
32933
+ cpuModel: cpuInfo === null ? UNKNOWN_CPU : parseCpuInfo(cpuInfo).cpuModel,
32934
+ isNested: cpuInfo !== null && isNestedCpu(cpuInfo),
32935
+ hugePages: sources.isHugePages ? "2M" : "off",
32936
+ hugePool: sources.readHugePagePool(),
32937
+ bootTemplates: sources.readBootTemplateCount?.() ?? null
32938
+ };
32939
+ }
32940
+ function readCpuInfoIfPresent(sources) {
32941
+ try {
32942
+ return sources.readCpuInfo();
32943
+ } catch {
32944
+ return null;
32945
+ }
32946
+ }
32947
+ function isNestedCpu(cpuInfo) {
32948
+ return /^flags\s*:.*\bhypervisor\b/mu.test(cpuInfo);
32949
+ }
32950
+
32915
32951
  // packages/daemon/src/create-impd-app.ts
32916
32952
  function createImpdApp(config, deps, parts) {
32917
32953
  const now = deps.now ?? Date.now;
@@ -32968,7 +33004,12 @@ function createImpdApp(config, deps, parts) {
32968
33004
  }),
32969
33005
  imageKeepaliveMs: keepaliveMs,
32970
33006
  ...deps.keepaliveRepeat !== undefined && { imageKeepaliveRepeat: deps.keepaliveRepeat },
32971
- moves: parts.moves
33007
+ moves: parts.moves,
33008
+ readHostInfo: () => readHostInfo({
33009
+ isHugePages: config.hugePages !== null,
33010
+ ...parts.hostReaders,
33011
+ readBootTemplateCount: parts.imps.bootTemplates?.readReadyCount ?? null
33012
+ })
32972
33013
  });
32973
33014
  }
32974
33015
 
@@ -39440,6 +39481,7 @@ function createBootTemplates(deps) {
39440
39481
  }
39441
39482
  },
39442
39483
  readLockedMib: templateLocks.readLockedMib,
39484
+ readReadyCount: () => listTemplateKeys().filter((key) => readReady(key) !== null).length,
39443
39485
  stop: async () => {
39444
39486
  await Promise.all([templateLocks.stop(), building.waitForAll()]);
39445
39487
  }
@@ -42397,11 +42439,13 @@ function makeSleepImpVm(deps) {
42397
42439
  }
42398
42440
  const sleepMs = Math.round(context.sleepTiming.now() - started);
42399
42441
  const waited = waitedMs > 0 ? `, waited ${String(waitedMs)}ms for a young guest` : "";
42442
+ const memFileMib = readDiskMib(paths.memFile);
42400
42443
  slept.detail = {
42401
42444
  trigger: reason,
42402
42445
  durationMs: sleepMs,
42403
42446
  prepareMs: Math.round(started - options.requestedAt),
42404
- steps: timings
42447
+ steps: timings,
42448
+ memFileMib
42405
42449
  };
42406
42450
  const plugged = pluggedMib === null ? "" : `, ${String(pluggedMib)} MiB plugged`;
42407
42451
  getImpdLogger("imps").with({ imp: imp.name }).info("asleep in {sleepMs}ms ({reason}){waited}, ram {ramMib} MiB{plugged}, mem file {memFile} MiB on disk, {timings}", {
@@ -42410,7 +42454,7 @@ function makeSleepImpVm(deps) {
42410
42454
  waited,
42411
42455
  ramMib: String(ramMib),
42412
42456
  plugged,
42413
- memFile: String(readDiskMib(paths.memFile)),
42457
+ memFile: String(memFileMib),
42414
42458
  timings: formatTimings(timings)
42415
42459
  });
42416
42460
  } catch (error) {
@@ -58233,6 +58277,11 @@ async function startImpdParts(config, boundaries, plan) {
58233
58277
  checkDnsToken: dnsToken?.check ?? null,
58234
58278
  readTailscale,
58235
58279
  readTailnetNames: tailnetNames === null ? null : tailnetNames.readStatus,
58280
+ hostReaders: {
58281
+ readKernel: () => deps.hostKernelRelease ?? release2(),
58282
+ readCpuInfo: deps.readCpuInfo ?? (() => readFileSync36("/proc/cpuinfo", "utf8")),
58283
+ readHugePagePool: deps.imps?.readHugePagePool ?? (() => readHugePagePool())
58284
+ },
58236
58285
  isReady: () => state.ready,
58237
58286
  readKsmHostStats: readKsmStats,
58238
58287
  ...deps.keepaliveMs !== undefined && { keepaliveMs: deps.keepaliveMs }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@impz/testing",
3
- "version": "6.2.1",
3
+ "version": "6.3.0",
4
4
  "description": "A real impd on stand-ins, for Bun tests of code that drives impd through @impz/client",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -43,7 +43,7 @@
43
43
  "ts-pattern": "^5.9.2",
44
44
  "xstate": "^5.33.3",
45
45
  "zod": "^4.6.7",
46
- "@impz/client": "6.2.1"
46
+ "@impz/client": "6.3.0"
47
47
  },
48
48
  "engines": {
49
49
  "bun": ">=1.4.3"