@impz/testing 7.9.0 → 7.10.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 +184 -103
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -18837,7 +18837,8 @@ import { join } from "path";
18837
18837
  var UFFD_RUN_FILES = {
18838
18838
  socket: "uffd.sock",
18839
18839
  pidFile: "uffd.pid",
18840
- statsFile: "uffd.stats"
18840
+ statsFile: "uffd.stats",
18841
+ touchedFile: "uffd.touched"
18841
18842
  };
18842
18843
  var DATA_DIRS = ["db", "system", "images", "imps"];
18843
18844
  function createDataDirs(dataDir) {
@@ -18869,6 +18870,7 @@ function buildImpPaths(dataDir, impId) {
18869
18870
  uffdSocket: join(runDir, UFFD_RUN_FILES.socket),
18870
18871
  uffdPidFile: join(runDir, UFFD_RUN_FILES.pidFile),
18871
18872
  uffdStatsFile: join(runDir, UFFD_RUN_FILES.statsFile),
18873
+ uffdTouchedFile: join(runDir, UFFD_RUN_FILES.touchedFile),
18872
18874
  ...buildSnapshotPaths(join(directory, "snapshot")),
18873
18875
  vmIdentity: join(directory, "vm.json"),
18874
18876
  checkpointsDir: join(directory, "checkpoints"),
@@ -18883,6 +18885,7 @@ function buildSnapshotPaths(snapshotDir) {
18883
18885
  snapshotDir,
18884
18886
  vmstate: join(snapshotDir, "vmstate"),
18885
18887
  memFile: join(snapshotDir, "mem"),
18888
+ memTouched: join(snapshotDir, "mem.touched"),
18886
18889
  snapshotMeta: join(snapshotDir, "meta.json")
18887
18890
  };
18888
18891
  }
@@ -18924,7 +18927,7 @@ var BACKUP_TREE = {
18924
18927
  };
18925
18928
 
18926
18929
  // packages/testing/src/stand-in/start-test-impd.ts
18927
- import { copyFileSync as copyFileSync5, mkdirSync as mkdirSync32, mkdtempSync, writeFileSync as writeFileSync18 } from "fs";
18930
+ import { copyFileSync as copyFileSync6, mkdirSync as mkdirSync32, mkdtempSync, writeFileSync as writeFileSync18 } from "fs";
18928
18931
  import { rm as rm2 } from "fs/promises";
18929
18932
  import { tmpdir } from "os";
18930
18933
 
@@ -22158,7 +22161,7 @@ import { join as join49 } from "path";
22158
22161
  // packages/daemon/package.json
22159
22162
  var package_default = {
22160
22163
  name: "@impz/daemon",
22161
- version: "7.9.0",
22164
+ version: "7.10.0",
22162
22165
  private: true,
22163
22166
  description: "impd: the imp host daemon",
22164
22167
  type: "module",
@@ -45164,31 +45167,56 @@ function splitRun(run) {
45164
45167
  }
45165
45168
 
45166
45169
  // packages/daemon/src/vm/vmm/create-memory-warm.ts
45170
+ import { existsSync as existsSync21 } from "fs";
45167
45171
  import invariant12 from "tiny-invariant";
45168
45172
  import { match as match23 } from "ts-pattern";
45169
45173
  import * as z87 from "zod";
45170
45174
  var BLOCK_MIB2 = 2;
45171
45175
  var WARM_CONCURRENCY = 2;
45176
+ var WHOLE_MODES = { count: "--count-data", warm: "--warm" };
45177
+ var RECORDED_MODES = { count: "--count-blocks", warm: "--warm-blocks" };
45172
45178
  var WarmReportSchema = z87.object({ blocks: z87.int().nonnegative() });
45173
45179
  function createMemoryWarm(deps) {
45174
45180
  const running = new Map;
45175
45181
  const lifetime = { isStopped: false };
45176
45182
  const slots = createSemaphore(WARM_CONCURRENCY);
45177
- const readBlocks = async (mode, memFile, signal) => {
45183
+ const readBlocks = async (mode, target, signal) => {
45178
45184
  signal.throwIfAborted();
45179
- const argv = [deps.handlerBin, mode, memFile];
45185
+ const argv = isBlockListMode(mode) ? [deps.handlerBin, mode, target.blockList, target.memFile] : [deps.handlerBin, mode, target.memFile];
45180
45186
  const stdout = await runChecked(argv, { signal }, deps.run);
45181
45187
  return WarmReportSchema.parse(JSON.parse(stdout)).blocks;
45182
45188
  };
45183
- const runWarm = async (memFile, signal) => {
45189
+ const countBlocks = async (target, signal) => {
45190
+ if (existsSync21(target.blockList)) {
45191
+ try {
45192
+ return {
45193
+ scope: "recorded",
45194
+ blocks: await readBlocks(RECORDED_MODES.count, target, signal)
45195
+ };
45196
+ } catch (error) {
45197
+ signal.throwIfAborted();
45198
+ getImpdLogger("imps").with({ imp: target.name }).warning("the recorded blocks of the memory file cannot be counted, so the whole file is: {error}", {
45199
+ error: getErrorMessage(error)
45200
+ });
45201
+ }
45202
+ }
45203
+ return { scope: "whole", blocks: await readBlocks(WHOLE_MODES.count, target, signal) };
45204
+ };
45205
+ const runWarm = async (target, signal) => {
45184
45206
  const startedMs = performance.now();
45185
45207
  try {
45186
- const blocks = await readBlocks("--count-data", memFile, signal);
45187
- if (blocks * BLOCK_MIB2 > deps.capMib) {
45188
- return { kind: "overCap", blocks };
45208
+ const counted = await countBlocks(target, signal);
45209
+ if (counted.blocks * BLOCK_MIB2 > deps.capMib) {
45210
+ return { kind: "overCap", scope: counted.scope, blocks: counted.blocks };
45189
45211
  }
45190
- const read = await readBlocks("--warm", memFile, signal);
45191
- return { kind: "warmed", blocks: read, warmMs: Math.round(performance.now() - startedMs) };
45212
+ const modes = counted.scope === "recorded" ? RECORDED_MODES : WHOLE_MODES;
45213
+ const read = await readBlocks(modes.warm, target, signal);
45214
+ return {
45215
+ kind: "warmed",
45216
+ scope: counted.scope,
45217
+ blocks: read,
45218
+ warmMs: Math.round(performance.now() - startedMs)
45219
+ };
45192
45220
  } catch (error) {
45193
45221
  return { kind: "failed", error: getErrorMessage(error) };
45194
45222
  }
@@ -45223,7 +45251,7 @@ function createMemoryWarm(deps) {
45223
45251
  return Promise.resolve(null);
45224
45252
  }
45225
45253
  state.phase = "running";
45226
- return runWarm(target.memFile, controller.signal);
45254
+ return runWarm(target, controller.signal);
45227
45255
  };
45228
45256
  const runAndLog = async () => {
45229
45257
  const outcome = await slots.run(runInSlot);
@@ -45246,14 +45274,24 @@ function createMemoryWarm(deps) {
45246
45274
  }
45247
45275
  };
45248
45276
  }
45277
+ function isBlockListMode(mode) {
45278
+ return mode === "--count-blocks" || mode === "--warm-blocks";
45279
+ }
45249
45280
  function logWarm(target, outcome, capMib) {
45250
45281
  const logger = getImpdLogger("imps").with({ imp: target.name });
45251
- match23(outcome).with({ kind: "warmed" }, (warmed) => {
45252
- logger.info("warmed the memory file in {warmMs}ms: {blocks} blocks of 2 MiB", {
45282
+ match23(outcome).with({ kind: "warmed", scope: "recorded" }, (warmed) => {
45283
+ logger.info("warmed {blocks} recorded blocks of the memory file in {warmMs}ms", {
45284
+ warmMs: String(warmed.warmMs),
45285
+ blocks: String(warmed.blocks)
45286
+ });
45287
+ }).with({ kind: "warmed", scope: "whole" }, (warmed) => {
45288
+ logger.info("warmed the whole memory file in {warmMs}ms: {blocks} blocks of 2 MiB", {
45253
45289
  warmMs: String(warmed.warmMs),
45254
45290
  blocks: String(warmed.blocks)
45255
45291
  });
45256
- }).with({ kind: "overCap" }, (over) => {
45292
+ }).with({ kind: "overCap", scope: "recorded" }, (over) => {
45293
+ logger.info("left the memory file cold: its {dataMib} MiB of recorded blocks pass the warm cap of {capMib} MiB", { dataMib: String(over.blocks * BLOCK_MIB2), capMib: String(capMib) });
45294
+ }).with({ kind: "overCap", scope: "whole" }, (over) => {
45257
45295
  logger.info("left the memory file cold: its {dataMib} MiB of data pass the warm cap of {capMib} MiB", { dataMib: String(over.blocks * BLOCK_MIB2), capMib: String(capMib) });
45258
45296
  }).with({ kind: "ended" }, (ended) => {
45259
45297
  logger.info("stopped the memory file's warm after {warmMs}ms: {reason}", {
@@ -45481,12 +45519,12 @@ function buildLogKey(impId, generation) {
45481
45519
  import { createActor as createActor3 } from "xstate";
45482
45520
 
45483
45521
  // packages/daemon/src/imps/imps/session-logs/read-session-log-range.ts
45484
- import { existsSync as existsSync22, mkdirSync as mkdirSync20, readdirSync as readdirSync12, rmSync as rmSync23, rmdirSync as rmdirSync2 } from "fs";
45522
+ import { existsSync as existsSync23, mkdirSync as mkdirSync20, readdirSync as readdirSync12, rmSync as rmSync23, rmdirSync as rmdirSync2 } from "fs";
45485
45523
  import { open as open5 } from "fs/promises";
45486
45524
  import { basename as basename5, dirname as dirname13, join as join36, resolve as resolve2 } from "path";
45487
45525
 
45488
45526
  // packages/daemon/src/imps/imps/session-logs/generation-log.ts
45489
- import { existsSync as existsSync21, readFileSync as readFileSync32, readdirSync as readdirSync11, rmSync as rmSync22 } from "fs";
45527
+ import { existsSync as existsSync22, readFileSync as readFileSync32, readdirSync as readdirSync11, rmSync as rmSync22 } from "fs";
45490
45528
  import { mkdir, open as open4, stat, truncate, unlink } from "fs/promises";
45491
45529
  import { join as join35 } from "path";
45492
45530
  import * as z88 from "zod";
@@ -45554,7 +45592,7 @@ function getSegmentPath(directory, start) {
45554
45592
  }
45555
45593
  function readGenerationMeta(directory) {
45556
45594
  const path = join35(directory, META_FILE);
45557
- if (!existsSync21(path)) {
45595
+ if (!existsSync22(path)) {
45558
45596
  return null;
45559
45597
  }
45560
45598
  try {
@@ -45795,7 +45833,7 @@ function getGenerationDir(sessionLogsDir, generation) {
45795
45833
  return directory;
45796
45834
  }
45797
45835
  function readImpMetas(sessionLogsDir, readLive) {
45798
- if (!existsSync22(sessionLogsDir)) {
45836
+ if (!existsSync23(sessionLogsDir)) {
45799
45837
  return [];
45800
45838
  }
45801
45839
  return readdirSync12(sessionLogsDir).filter((entry) => isGenerationName(entry)).flatMap((generation) => {
@@ -45809,11 +45847,11 @@ function writeTombstone(sessionLogsDir, generation) {
45809
45847
  writeFileDurably(path, "");
45810
45848
  }
45811
45849
  function probeTombstone(sessionLogsDir, generation) {
45812
- return isGenerationName(generation) && existsSync22(getTombstonePath(sessionLogsDir, generation));
45850
+ return isGenerationName(generation) && existsSync23(getTombstonePath(sessionLogsDir, generation));
45813
45851
  }
45814
45852
  function listTombstones(sessionLogsDir) {
45815
45853
  const directory = join36(sessionLogsDir, TOMBSTONES);
45816
- return existsSync22(directory) ? readdirSync12(directory).filter((entry) => isGenerationName(entry)) : [];
45854
+ return existsSync23(directory) ? readdirSync12(directory).filter((entry) => isGenerationName(entry)) : [];
45817
45855
  }
45818
45856
  function removeTombstone(sessionLogsDir, generation) {
45819
45857
  rmSync23(getTombstonePath(sessionLogsDir, generation), { force: true });
@@ -47174,10 +47212,12 @@ function removePartialFiles(paths) {
47174
47212
  for (const path of [
47175
47213
  paths.vmstate,
47176
47214
  paths.memFile,
47215
+ paths.memTouched,
47177
47216
  paths.snapshotMeta,
47178
47217
  paths.vmIdentity,
47179
47218
  slot.vmstate,
47180
47219
  slot.memFile,
47220
+ slot.memTouched,
47181
47221
  slot.snapshotMeta
47182
47222
  ]) {
47183
47223
  rmSync24(`${path}.new`, { force: true });
@@ -47844,7 +47884,7 @@ function buildUffdDeviceError() {
47844
47884
  }
47845
47885
 
47846
47886
  // packages/daemon/src/imps/imps/make-sleep-imp-vm.ts
47847
- import { statSync as statSync13 } from "fs";
47887
+ import { statSync as statSync14 } from "fs";
47848
47888
 
47849
47889
  // packages/daemon/src/vm/agent-client/send-services-list.ts
47850
47890
  var STOP_TIMEOUT_MS = 15000;
@@ -47977,6 +48017,35 @@ async function waitForGuestAge(wait) {
47977
48017
  return wanted ? Math.round(now() - started) : null;
47978
48018
  }
47979
48019
 
48020
+ // packages/daemon/src/vm/vmm/keep-touched-blocks.ts
48021
+ import { copyFileSync as copyFileSync4, renameSync as renameSync7, rmSync as rmSync25, statSync as statSync13 } from "fs";
48022
+ function keepTouchedBlocks(paths) {
48023
+ dropTouchedBlocks(paths);
48024
+ if (!probeMarks(paths.uffdTouchedFile)) {
48025
+ return;
48026
+ }
48027
+ const staged = `${paths.memTouched}.new`;
48028
+ try {
48029
+ copyFileSync4(paths.uffdTouchedFile, staged);
48030
+ renameSync7(staged, paths.memTouched);
48031
+ } catch (error) {
48032
+ rmSync25(staged, { force: true });
48033
+ getImpdLogger("imps").with({ imp: paths.impId }).warning("kept no record of the blocks the wake served: {error}", {
48034
+ error: getErrorMessage(error)
48035
+ });
48036
+ }
48037
+ }
48038
+ function dropTouchedBlocks(paths) {
48039
+ rmSync25(paths.memTouched, { force: true });
48040
+ }
48041
+ function probeMarks(path) {
48042
+ try {
48043
+ return statSync13(path).size > 0;
48044
+ } catch {
48045
+ return false;
48046
+ }
48047
+ }
48048
+
47980
48049
  // packages/daemon/src/imps/imps/format-timings.ts
47981
48050
  function formatTimings(timings) {
47982
48051
  return Object.entries(timings).map(([step, durationMs]) => `${step}=${String(durationMs)}ms`).join(" ");
@@ -48042,10 +48111,12 @@ function makeSleepImpVm(deps) {
48042
48111
  isOnHugePages: false
48043
48112
  };
48044
48113
  removeSnapshotMeta(paths);
48114
+ dropTouchedBlocks(paths);
48045
48115
  const hasOomKill = startOomWatch(context.cgroups, imp.id);
48046
48116
  try {
48047
48117
  const cgroup = context.cgroups.setup(imp.id, imp.cpu, imp.memoryMib);
48048
48118
  const timings = await deps.withSleepSlot(() => context.vms.sleepVm(pid, paths, cgroup, paths));
48119
+ keepTouchedBlocks(paths);
48049
48120
  const booted = readVmIdentity(paths);
48050
48121
  slept.isOnHugePages = booted?.hugePages === "2M";
48051
48122
  writeSnapshotMeta(paths, {
@@ -48108,7 +48179,12 @@ function makeSleepImpVm(deps) {
48108
48179
  sleptAt: new Date
48109
48180
  });
48110
48181
  if (slept.isOnHugePages) {
48111
- context.memoryWarm?.start({ impID: imp.id, name: imp.name, memFile: paths.memFile });
48182
+ context.memoryWarm?.start({
48183
+ impID: imp.id,
48184
+ name: imp.name,
48185
+ memFile: paths.memFile,
48186
+ blockList: paths.memTouched
48187
+ });
48112
48188
  }
48113
48189
  return sleeping;
48114
48190
  };
@@ -48144,7 +48220,7 @@ function setDetached(session) {
48144
48220
  }
48145
48221
  function readDiskMib(path) {
48146
48222
  try {
48147
- return Math.round(statSync13(path).blocks * 512 / 1048576);
48223
+ return Math.round(statSync14(path).blocks * 512 / 1048576);
48148
48224
  } catch {
48149
48225
  return 0;
48150
48226
  }
@@ -48363,11 +48439,11 @@ function logTrustFailure(imp, error) {
48363
48439
 
48364
48440
  // packages/daemon/src/imps/imps/start-cold-vm.ts
48365
48441
  import { randomBytes as randomBytes11 } from "crypto";
48366
- import { statSync as statSync15 } from "fs";
48442
+ import { statSync as statSync16 } from "fs";
48367
48443
  import { resolve as resolve3 } from "path";
48368
48444
 
48369
48445
  // packages/daemon/src/vm/vmm/create-template-vm.ts
48370
- import { mkdirSync as mkdirSync22, rmSync as rmSync27 } from "fs";
48446
+ import { mkdirSync as mkdirSync22, rmSync as rmSync28 } from "fs";
48371
48447
 
48372
48448
  // packages/daemon/src/vm/agent-client/wait-for-agent.ts
48373
48449
  import { systemClock as systemClock4 } from "@zgeoff/std";
@@ -48401,14 +48477,14 @@ async function waitForAgent(vsockPath, options) {
48401
48477
  import {
48402
48478
  chmodSync as chmodSync7,
48403
48479
  closeSync as closeSync9,
48404
- existsSync as existsSync23,
48480
+ existsSync as existsSync24,
48405
48481
  lchownSync as lchownSync2,
48406
48482
  lstatSync as lstatSync3,
48407
48483
  mkdirSync as mkdirSync21,
48408
48484
  openSync as openSync7,
48409
48485
  readdirSync as readdirSync13,
48410
- rmSync as rmSync25,
48411
- statSync as statSync14,
48486
+ rmSync as rmSync26,
48487
+ statSync as statSync15,
48412
48488
  truncateSync as truncateSync3
48413
48489
  } from "fs";
48414
48490
  import { basename as basename6, dirname as dirname14, join as join37 } from "path";
@@ -48467,7 +48543,7 @@ function createJails(deps) {
48467
48543
  const remove = async (impId) => {
48468
48544
  await removeMounts(impId);
48469
48545
  if (listMountsUnder(readMounts2(), getRoot(impId)).length === 0) {
48470
- rmSync25(getJailDir(impId), { recursive: true, force: true });
48546
+ rmSync26(getJailDir(impId), { recursive: true, force: true });
48471
48547
  }
48472
48548
  };
48473
48549
  const setupDirBind = async (source, target) => {
@@ -48488,7 +48564,7 @@ function createJails(deps) {
48488
48564
  throw new Error(`jail ${chroot.id}: ${root} still has mounts`);
48489
48565
  }
48490
48566
  chroot.setupFiles();
48491
- rmSync25(getJailDir(chroot.id), { recursive: true, force: true });
48567
+ rmSync26(getJailDir(chroot.id), { recursive: true, force: true });
48492
48568
  mkdirSync21(root, { recursive: true });
48493
48569
  await runMount(["mount", "--bind", root, root]);
48494
48570
  await runMount(["mount", "--make-private", root]);
@@ -48550,7 +48626,7 @@ function createJails(deps) {
48550
48626
  remove,
48551
48627
  removeOrphans: async (impIds) => {
48552
48628
  const base = join37(deps.chrootBase, execName);
48553
- const ids = existsSync23(base) ? readdirSync13(base) : [];
48629
+ const ids = existsSync24(base) ? readdirSync13(base) : [];
48554
48630
  const orphans = ids.filter((impId) => !impIds.has(impId));
48555
48631
  const removed = [];
48556
48632
  for (const impId of orphans) {
@@ -48576,7 +48652,7 @@ function createJails(deps) {
48576
48652
  `);
48577
48653
  },
48578
48654
  removeUffdDevice: (id) => {
48579
- rmSync25(join37(getRoot(id), "dev", "userfaultfd"), { force: true });
48655
+ rmSync26(join37(getRoot(id), "dev", "userfaultfd"), { force: true });
48580
48656
  }
48581
48657
  };
48582
48658
  }
@@ -48599,7 +48675,7 @@ function readOwnerUid(path) {
48599
48675
  function setupScratchFile(source, target, user) {
48600
48676
  mkdirSync21(dirname14(target), { recursive: true });
48601
48677
  closeSync9(openSync7(target, "wx", 384));
48602
- truncateSync3(target, statSync14(source).size);
48678
+ truncateSync3(target, statSync15(source).size);
48603
48679
  lchownSync2(target, user.uid, user.gid);
48604
48680
  }
48605
48681
  function buildJailerCommand(command) {
@@ -48632,7 +48708,7 @@ function setupOwnership(paths, user, isDiskLate) {
48632
48708
  lchownSync2(paths.runDir, user.uid, user.gid);
48633
48709
  setupImpdDir(paths.snapshotDir);
48634
48710
  for (const file of [paths.vmstate, paths.memFile]) {
48635
- if (existsSync23(file)) {
48711
+ if (existsSync24(file)) {
48636
48712
  requireRegularFile(file);
48637
48713
  }
48638
48714
  }
@@ -48641,7 +48717,7 @@ function setupOwnership(paths, user, isDiskLate) {
48641
48717
  lchownSync2(paths.disk, user.uid, user.gid);
48642
48718
  }
48643
48719
  for (const file of [paths.vmstate, paths.memFile]) {
48644
- if (existsSync23(file)) {
48720
+ if (existsSync24(file)) {
48645
48721
  setupSnapshotFile(file, user.gid);
48646
48722
  }
48647
48723
  }
@@ -48651,7 +48727,7 @@ function setupImpdRunDir(paths) {
48651
48727
  for (const name of readdirSync13(paths.runDir)) {
48652
48728
  const path = join37(paths.runDir, name);
48653
48729
  if (!probeSealedEntry(paths, path)) {
48654
- rmSync25(path, { recursive: true, force: true });
48730
+ rmSync26(path, { recursive: true, force: true });
48655
48731
  }
48656
48732
  }
48657
48733
  }
@@ -48675,7 +48751,7 @@ function setupSnapshotFile(file, gid) {
48675
48751
  function setupRealDir(directory) {
48676
48752
  const found = lstatSync3(directory, { throwIfNoEntry: false });
48677
48753
  if (found !== undefined && !found.isDirectory()) {
48678
- rmSync25(directory, { force: true });
48754
+ rmSync26(directory, { force: true });
48679
48755
  }
48680
48756
  mkdirSync21(directory, { recursive: true });
48681
48757
  }
@@ -48684,10 +48760,11 @@ function probeSealedEntry(paths, path) {
48684
48760
  const uffdSocket = join37(paths.runDir, UFFD_RUN_FILES.socket);
48685
48761
  const uffdPidFile = join37(paths.runDir, UFFD_RUN_FILES.pidFile);
48686
48762
  const uffdStatsFile = join37(paths.runDir, UFFD_RUN_FILES.statsFile);
48763
+ const uffdTouchedFile = join37(paths.runDir, UFFD_RUN_FILES.touchedFile);
48687
48764
  if (path === paths.apiSocket || path === paths.vsockSocket || path === uffdSocket) {
48688
48765
  return entry.isSocket();
48689
48766
  }
48690
- return (path === paths.logFile || path === paths.pidFile || path === uffdPidFile || path === uffdStatsFile) && entry.isFile() && entry.uid === IMPD_USER.uid && entry.nlink === 1;
48767
+ return (path === paths.logFile || path === paths.pidFile || path === uffdPidFile || path === uffdStatsFile || path === uffdTouchedFile) && entry.isFile() && entry.uid === IMPD_USER.uid && entry.nlink === 1;
48691
48768
  }
48692
48769
  function requireRegularFile(file) {
48693
48770
  if (!lstatSync3(file).isFile()) {
@@ -48867,7 +48944,7 @@ function toMib(bytes) {
48867
48944
  }
48868
48945
 
48869
48946
  // packages/daemon/src/vm/vmm/start-uffd-handler.ts
48870
- import { closeSync as closeSync10, existsSync as existsSync24, openSync as openSync8, rmSync as rmSync26 } from "fs";
48947
+ import { closeSync as closeSync10, existsSync as existsSync25, openSync as openSync8, rmSync as rmSync27 } from "fs";
48871
48948
 
48872
48949
  // packages/daemon/src/vm/vmm/uffd-stats-layout.ts
48873
48950
  var UFFD_STATS_LAYOUT = {
@@ -48891,18 +48968,20 @@ async function startUffdHandler(plan) {
48891
48968
  ];
48892
48969
  const memFd = openSync8(plan.memFile, "r");
48893
48970
  const statsFd = createZeroedFile(paths.uffdStatsFile, UFFD_STATS_BYTES);
48971
+ const touchedFd = createZeroedFile(paths.uffdTouchedFile, 0);
48894
48972
  const log = setupLogFile(paths.logFile);
48895
48973
  const child = Bun.spawn(buildSpawnArgv(command, plan.cgroup?.procsPath ?? null, null), {
48896
- stdio: ["ignore", log, log, memFd, statsFd]
48974
+ stdio: ["ignore", log, log, memFd, statsFd, touchedFd]
48897
48975
  });
48898
48976
  closeSync10(memFd);
48899
48977
  closeSync10(statsFd);
48978
+ closeSync10(touchedFd);
48900
48979
  closeSync10(log);
48901
48980
  child.unref();
48902
48981
  writeRegularFile(paths.uffdPidFile, `${String(child.pid)}
48903
48982
  `);
48904
48983
  const deadline = Date.now() + SOCKET_WAIT_MS2;
48905
- while (!existsSync24(paths.uffdSocket)) {
48984
+ while (!existsSync25(paths.uffdSocket)) {
48906
48985
  if (child.exitCode !== null || Date.now() > deadline) {
48907
48986
  stopPid(child.pid);
48908
48987
  throw new Error(`the page handler did not open its socket (exit ${String(child.exitCode)}): ${readLogTail(paths.logFile, 5)}`);
@@ -48912,10 +48991,11 @@ async function startUffdHandler(plan) {
48912
48991
  return child.pid;
48913
48992
  }
48914
48993
  function removeUffdFiles(paths) {
48915
- rmSync26(paths.uffdSocket, { force: true });
48916
- rmSync26(`${paths.uffdSocket}.new`, { force: true });
48917
- rmSync26(paths.uffdPidFile, { force: true });
48918
- rmSync26(paths.uffdStatsFile, { force: true });
48994
+ rmSync27(paths.uffdSocket, { force: true });
48995
+ rmSync27(`${paths.uffdSocket}.new`, { force: true });
48996
+ rmSync27(paths.uffdPidFile, { force: true });
48997
+ rmSync27(paths.uffdStatsFile, { force: true });
48998
+ rmSync27(paths.uffdTouchedFile, { force: true });
48919
48999
  }
48920
49000
  function readUffdStats(paths, readFile) {
48921
49001
  const raw = readFile(paths.uffdStatsFile);
@@ -48926,7 +49006,7 @@ function readUffdStats(paths, readFile) {
48926
49006
  };
48927
49007
  }
48928
49008
  function readHandlerState(paths, procRoot = "/proc") {
48929
- if (!existsSync24(paths.uffdPidFile)) {
49009
+ if (!existsSync25(paths.uffdPidFile)) {
48930
49010
  return { state: "none" };
48931
49011
  }
48932
49012
  const pid = readPidFile(paths.uffdPidFile);
@@ -48961,7 +49041,7 @@ async function createTemplateVm(plan, jails, options = {}) {
48961
49041
  setupTemplateFile(plan.memFile);
48962
49042
  writeToDisk([plan.vmstate, plan.memFile, plan.snapshotDir]);
48963
49043
  } catch (error) {
48964
- rmSync27(plan.snapshotDir, { recursive: true, force: true });
49044
+ rmSync28(plan.snapshotDir, { recursive: true, force: true });
48965
49045
  throw new Error(`template build failed: ${getErrorMessage(error)}
48966
49046
  ${readLogTail(plan.paths.logFile)}`, { cause: error });
48967
49047
  }
@@ -49182,7 +49262,7 @@ async function startColdVm(context, start) {
49182
49262
  disk.isFailed = true;
49183
49263
  throw error;
49184
49264
  }
49185
- return statSync15(paths.disk).size;
49265
+ return statSync16(paths.disk).size;
49186
49266
  };
49187
49267
  const diskBytes = readDiskBytes();
49188
49268
  Promise.allSettled([diskBytes]);
@@ -50493,7 +50573,7 @@ function createMemoryController(deps) {
50493
50573
 
50494
50574
  // packages/daemon/src/vm/vmm/cpu-cgroups.ts
50495
50575
  import {
50496
- existsSync as existsSync25,
50576
+ existsSync as existsSync26,
50497
50577
  mkdirSync as mkdirSync23,
50498
50578
  readFileSync as readFileSync34,
50499
50579
  readdirSync as readdirSync14,
@@ -50601,7 +50681,7 @@ function createCpuCgroups(options) {
50601
50681
  isMemoryEnforced,
50602
50682
  setup,
50603
50683
  apply: (impId, cpu) => {
50604
- if (isEnforced && existsSync25(getDir(impId))) {
50684
+ if (isEnforced && existsSync26(getDir(impId))) {
50605
50685
  tryWrite(impId, "apply the limit", () => {
50606
50686
  writeSettings(impId, cpu, cpu.limit);
50607
50687
  });
@@ -50624,7 +50704,7 @@ function createCpuCgroups(options) {
50624
50704
  },
50625
50705
  setGuestMib: (impId, guestMib) => {
50626
50706
  guestMibs.set(impId, guestMib);
50627
- if (isMemoryEnforced && existsSync25(getDir(impId))) {
50707
+ if (isMemoryEnforced && existsSync26(getDir(impId))) {
50628
50708
  tryWrite(impId, "set the memory limit", () => {
50629
50709
  writeMemory(impId);
50630
50710
  });
@@ -50636,7 +50716,7 @@ function createCpuCgroups(options) {
50636
50716
  if (!isEnforced) {
50637
50717
  return;
50638
50718
  }
50639
- for (let attempt = 1;existsSync25(getDir(impId)); attempt += 1) {
50719
+ for (let attempt = 1;existsSync26(getDir(impId)); attempt += 1) {
50640
50720
  try {
50641
50721
  rmdir(getDir(impId));
50642
50722
  return;
@@ -50665,7 +50745,7 @@ function createCpuCgroups(options) {
50665
50745
  return orphans;
50666
50746
  },
50667
50747
  kill: (impId) => {
50668
- if (isEnforced && existsSync25(getDir(impId))) {
50748
+ if (isEnforced && existsSync26(getDir(impId))) {
50669
50749
  tryWrite(impId, "kill", () => {
50670
50750
  writeFileSync13(join39(getDir(impId), "cgroup.kill"), "1");
50671
50751
  });
@@ -50731,7 +50811,7 @@ function probeUffdDevice(path = "/dev/userfaultfd") {
50731
50811
  }
50732
50812
 
50733
50813
  // packages/daemon/src/vm/vmm/vm-runner.ts
50734
- import { lstatSync as lstatSync4, mkdirSync as mkdirSync24, renameSync as renameSync7, rmSync as rmSync28 } from "fs";
50814
+ import { lstatSync as lstatSync4, mkdirSync as mkdirSync24, renameSync as renameSync8, rmSync as rmSync29 } from "fs";
50735
50815
  import { systemClock as systemClock5 } from "@zgeoff/std";
50736
50816
 
50737
50817
  // packages/daemon/src/vm/vmm/build-boot-args.ts
@@ -50963,9 +51043,9 @@ ${readLogTail(plan.paths.logFile)}`, {
50963
51043
  setMark("pause");
50964
51044
  await api.createSnapshot(files, type);
50965
51045
  } catch (error) {
50966
- rmSync28(files.snapshotPath, { force: true });
50967
- rmSync28(files.memFilePath, { force: true });
50968
- rmSync28(paths.memFile, { force: true });
51046
+ rmSync29(files.snapshotPath, { force: true });
51047
+ rmSync29(files.memFilePath, { force: true });
51048
+ rmSync29(paths.memFile, { force: true });
50969
51049
  try {
50970
51050
  await api.resume();
50971
51051
  cgroup?.applyLimit();
@@ -50982,10 +51062,10 @@ ${readLogTail(plan.paths.logFile)}`, {
50982
51062
  for (const file of [files.snapshotPath, files.memFilePath]) {
50983
51063
  setupSnapshotFile(file, owner.gid);
50984
51064
  }
50985
- renameSync7(files.snapshotPath, target.vmstate);
50986
- renameSync7(files.memFilePath, target.memFile);
50987
- rmSync28(paths.apiSocket, { force: true });
50988
- rmSync28(paths.vsockSocket, { force: true });
51065
+ renameSync8(files.snapshotPath, target.vmstate);
51066
+ renameSync8(files.memFilePath, target.memFile);
51067
+ rmSync29(paths.apiSocket, { force: true });
51068
+ rmSync29(paths.vsockSocket, { force: true });
50989
51069
  const dug = await runCommand(["fallocate", "--dig-holes", target.memFile]);
50990
51070
  const digStep = dug.exitCode === 0 ? "digHoles" : "digHolesFailed";
50991
51071
  setMark(digStep);
@@ -51323,7 +51403,7 @@ function makeStandInVmRam(readRam) {
51323
51403
  }
51324
51404
 
51325
51405
  // packages/daemon/src/imp-ops/moves/move-receiver.ts
51326
- import { existsSync as existsSync27, rmSync as rmSync30 } from "fs";
51406
+ import { existsSync as existsSync28, rmSync as rmSync31 } from "fs";
51327
51407
  import { join as join41 } from "path";
51328
51408
 
51329
51409
  // packages/daemon/src/platform/db/probe-slot-free.ts
@@ -51648,7 +51728,7 @@ class MoveRequestError extends ImpdError {
51648
51728
  }
51649
51729
 
51650
51730
  // packages/daemon/src/imp-ops/moves/read-move-stream.ts
51651
- import { mkdirSync as mkdirSync26, rmSync as rmSync29 } from "fs";
51731
+ import { mkdirSync as mkdirSync26, rmSync as rmSync30 } from "fs";
51652
51732
  import { open as open7 } from "fs/promises";
51653
51733
  import { join as join40 } from "path";
51654
51734
  import invariant13 from "tiny-invariant";
@@ -51664,7 +51744,7 @@ config ${configContentSha256}
51664
51744
 
51665
51745
  // packages/daemon/src/imp-ops/moves/check-warm-move.ts
51666
51746
  import { createHash as createHash7 } from "crypto";
51667
- import { existsSync as existsSync26, mkdirSync as mkdirSync25, renameSync as renameSync8 } from "fs";
51747
+ import { existsSync as existsSync27, mkdirSync as mkdirSync25, renameSync as renameSync9 } from "fs";
51668
51748
  import { dirname as dirname15 } from "path";
51669
51749
 
51670
51750
  // packages/daemon/src/imp-ops/moves/read-warm-host.ts
@@ -51831,9 +51911,9 @@ async function writeSystemDrive(deps, temp, meta) {
51831
51911
  if (!isSameHash(sha256, meta.systemDrive)) {
51832
51912
  throw new MoveRequestError("BAD_REQUEST", "the system drive does not match its sha256");
51833
51913
  }
51834
- if (!existsSync26(path)) {
51914
+ if (!existsSync27(path)) {
51835
51915
  mkdirSync25(dirname15(path), { recursive: true });
51836
- renameSync8(temp, path);
51916
+ renameSync9(temp, path);
51837
51917
  }
51838
51918
  }
51839
51919
  async function readFileSha256(path) {
@@ -52359,7 +52439,7 @@ async function readMoveStream(deps, options) {
52359
52439
  await removeStagedImp(deps, header.imp.name, header.imp.id);
52360
52440
  throw error;
52361
52441
  } finally {
52362
- rmSync29(temp, { force: true });
52442
+ rmSync30(temp, { force: true });
52363
52443
  }
52364
52444
  await createGrants(deps, header);
52365
52445
  const receipt = buildReceipt({ ticketId: row.id, name: header.imp.name, impId: header.imp.id, files }, options.secret);
@@ -52460,8 +52540,8 @@ async function requireImage(deps, options) {
52460
52540
  }));
52461
52541
  return { name, files };
52462
52542
  } finally {
52463
- rmSync29(temps.rootfs, { force: true });
52464
- rmSync29(temps.config, { force: true });
52543
+ rmSync30(temps.rootfs, { force: true });
52544
+ rmSync30(temps.config, { force: true });
52465
52545
  }
52466
52546
  }
52467
52547
  async function createGrants(deps, header) {
@@ -52518,7 +52598,7 @@ function createMoveReceiver(deps) {
52518
52598
  const offer = async (offered) => {
52519
52599
  const digests = buildOfferedDigests(offered.imageDigest, offered.receivedImageDigest);
52520
52600
  const existing = await readImageInUse(deps.db, digests, deps.now());
52521
- const needsSystemDrive = offered.systemDrive !== undefined && !existsSync27(buildSystemDrivePath(deps.dataDir, offered.systemDrive));
52601
+ const needsSystemDrive = offered.systemDrive !== undefined && !existsSync28(buildSystemDrivePath(deps.dataDir, offered.systemDrive));
52522
52602
  return {
52523
52603
  needsImage: existing === undefined,
52524
52604
  needsSystemDrive,
@@ -52720,7 +52800,7 @@ function createMoveReceiver(deps) {
52720
52800
  await removeStagedImp(deps, imp.name, imp.id);
52721
52801
  }
52722
52802
  }
52723
- rmSync30(tempDir, { recursive: true, force: true });
52803
+ rmSync31(tempDir, { recursive: true, force: true });
52724
52804
  }
52725
52805
  };
52726
52806
  }
@@ -53694,7 +53774,7 @@ function createImpdMoves(config, deps, parts, hooks) {
53694
53774
  }
53695
53775
 
53696
53776
  // packages/daemon/src/imps/images/template-service.ts
53697
- import { copyFileSync as copyFileSync4, existsSync as existsSync28, statSync as statSync16, writeFileSync as writeFileSync14 } from "fs";
53777
+ import { copyFileSync as copyFileSync5, existsSync as existsSync29, statSync as statSync17, writeFileSync as writeFileSync14 } from "fs";
53698
53778
  import { join as join42 } from "path";
53699
53779
  import { systemClock as systemClock7 } from "@zgeoff/std";
53700
53780
 
@@ -53752,8 +53832,8 @@ function createTemplateService(deps) {
53752
53832
  const image = await readImageById(deps.db, imageId);
53753
53833
  const target = join42(directory, "config.json");
53754
53834
  const config = image === undefined ? undefined : buildImagePaths(deps.config.dataDir, image.digest).config;
53755
- if (config !== undefined && existsSync28(config)) {
53756
- copyFileSync4(config, target);
53835
+ if (config !== undefined && existsSync29(config)) {
53836
+ copyFileSync5(config, target);
53757
53837
  } else {
53758
53838
  writeFileSync14(target, "{}");
53759
53839
  }
@@ -53786,7 +53866,7 @@ function createTemplateService(deps) {
53786
53866
  digest,
53787
53867
  source: "imp",
53788
53868
  sourceImp: imp.name,
53789
- sizeBytes: statSync16(rootfs).blocks * 512
53869
+ sizeBytes: statSync17(rootfs).blocks * 512
53790
53870
  }, clock.now()).catch(async (error) => {
53791
53871
  await storage.removeImage(digest);
53792
53872
  throw error;
@@ -54154,14 +54234,14 @@ function updateImageAlias(db, alias, imageName, atMs) {
54154
54234
  }
54155
54235
 
54156
54236
  // packages/daemon/src/imps/images/build/create-image-builds.ts
54157
- import { existsSync as existsSync30, mkdirSync as mkdirSync27, rmSync as rmSync31, statSync as statSync17 } from "fs";
54237
+ import { existsSync as existsSync31, mkdirSync as mkdirSync27, rmSync as rmSync32, statSync as statSync18 } from "fs";
54158
54238
  import { join as join44, posix as posix3 } from "path";
54159
54239
 
54160
54240
  // packages/local-tar/src/create-local-extractor.ts
54161
54241
  import tar from "tar-stream";
54162
54242
  import * as z95 from "zod";
54163
54243
  // packages/local-tar/src/list-context-entries.ts
54164
- import { existsSync as existsSync29 } from "fs";
54244
+ import { existsSync as existsSync30 } from "fs";
54165
54245
  import { lstat, readFile as readFile5, readdir } from "fs/promises";
54166
54246
  import { join as join43, posix as posix2 } from "path";
54167
54247
  import ignore from "@balena/dockerignore";
@@ -54447,7 +54527,7 @@ class MissingDockerfileError extends Error {
54447
54527
  name = "MissingDockerfileError";
54448
54528
  }
54449
54529
  function listContextEntries(root, dockerfile) {
54450
- const found = listDockerfileCandidates(posix2.normalize(dockerfile)).find((candidate) => existsSync29(join43(root, candidate)));
54530
+ const found = listDockerfileCandidates(posix2.normalize(dockerfile)).find((candidate) => existsSync30(join43(root, candidate)));
54451
54531
  if (found === undefined) {
54452
54532
  return Promise.reject(new MissingDockerfileError(`there is no ${dockerfile} in ${root}`));
54453
54533
  }
@@ -54459,8 +54539,8 @@ var ENTRY_KINDS = [
54459
54539
  ["file", "isFile"]
54460
54540
  ];
54461
54541
  async function listEntries2(root, dockerfile) {
54462
- const ignoreName = existsSync29(join43(root, `${dockerfile}.dockerignore`)) ? `${dockerfile}.dockerignore` : ".dockerignore";
54463
- const patterns = existsSync29(join43(root, ignoreName)) ? await readFile5(join43(root, ignoreName), "utf8") : "";
54542
+ const ignoreName = existsSync30(join43(root, `${dockerfile}.dockerignore`)) ? `${dockerfile}.dockerignore` : ".dockerignore";
54543
+ const patterns = existsSync30(join43(root, ignoreName)) ? await readFile5(join43(root, ignoreName), "utf8") : "";
54464
54544
  const matcher = ignore().add(patterns);
54465
54545
  const hasExceptions = patterns.split(`
54466
54546
  `).some((line) => line.trim().startsWith("!"));
@@ -55839,7 +55919,7 @@ function createImageBuilds(deps, writer) {
55839
55919
  const imageName = requireClientImageName(name);
55840
55920
  await requireUnaliasedName(deps.db, imageName);
55841
55921
  const tag = `imp/${imageName}:latest`;
55842
- const tarBytes = statSync17(tarPath).size;
55922
+ const tarBytes = statSync18(tarPath).size;
55843
55923
  const dockerfilePath = normalizeDockerfilePath(givenDockerfile);
55844
55924
  const rewrittenPath = `${tarPath}.rewritten`;
55845
55925
  let pins = [];
@@ -55916,7 +55996,7 @@ function createImageBuilds(deps, writer) {
55916
55996
  }
55917
55997
  throw error;
55918
55998
  } finally {
55919
- rmSync31(rewrittenPath, { force: true });
55999
+ rmSync32(rewrittenPath, { force: true });
55920
56000
  }
55921
56001
  };
55922
56002
  const createOnHost = async (contextDir, name, dockerfile, options) => {
@@ -55926,7 +56006,7 @@ function createImageBuilds(deps, writer) {
55926
56006
  message: `build context ${JSON.stringify(contextDir)} is not an absolute path`
55927
56007
  });
55928
56008
  }
55929
- if (!existsSync30(contextDir)) {
56009
+ if (!existsSync31(contextDir)) {
55930
56010
  throw new ImpdError("BAD_REQUEST", {
55931
56011
  message: `build context ${contextDir} does not exist on the impd host; build the image there and use \`impz image add\``
55932
56012
  });
@@ -55953,7 +56033,7 @@ function createImageBuilds(deps, writer) {
55953
56033
  signal: options.signal ?? new AbortController().signal
55954
56034
  });
55955
56035
  } finally {
55956
- rmSync31(tarPath, { force: true });
56036
+ rmSync32(tarPath, { force: true });
55957
56037
  }
55958
56038
  });
55959
56039
  };
@@ -56098,7 +56178,7 @@ function buildImageRuntimeConfig(ociConfig) {
56098
56178
  }
56099
56179
 
56100
56180
  // packages/daemon/src/imps/images/rootfs/create-image-writer.ts
56101
- import { existsSync as existsSync31, mkdirSync as mkdirSync29, rmSync as rmSync33, statSync as statSync18, writeFileSync as writeFileSync15 } from "fs";
56181
+ import { existsSync as existsSync32, mkdirSync as mkdirSync29, rmSync as rmSync34, statSync as statSync19, writeFileSync as writeFileSync15 } from "fs";
56102
56182
  import { join as join46 } from "path";
56103
56183
 
56104
56184
  // packages/daemon/src/imps/images/rootfs/read-oci-config.ts
@@ -56118,7 +56198,7 @@ async function readOciConfig(ref, signal, run) {
56118
56198
  }
56119
56199
 
56120
56200
  // packages/daemon/src/imps/images/rootfs/write-image-config.ts
56121
- import { closeSync as closeSync11, constants as constants6, lstatSync as lstatSync5, mkdirSync as mkdirSync28, openSync as openSync9, rmSync as rmSync32, writeSync as writeSync3 } from "fs";
56201
+ import { closeSync as closeSync11, constants as constants6, lstatSync as lstatSync5, mkdirSync as mkdirSync28, openSync as openSync9, rmSync as rmSync33, writeSync as writeSync3 } from "fs";
56122
56202
  import { join as join45 } from "path";
56123
56203
  function writeImageConfig(root, contents) {
56124
56204
  const etc = join45(root, "etc");
@@ -56126,7 +56206,7 @@ function writeImageConfig(root, contents) {
56126
56206
  createDirectory(etc, "/etc");
56127
56207
  createDirectory(directory, "/etc/imp");
56128
56208
  const file = join45(directory, "image.json");
56129
- rmSync32(file, { recursive: true, force: true });
56209
+ rmSync33(file, { recursive: true, force: true });
56130
56210
  const fd = openSync9(file, constants6.O_WRONLY | constants6.O_CREAT | constants6.O_EXCL | constants6.O_NOFOLLOW, 420);
56131
56211
  try {
56132
56212
  writeSync3(fd, contents);
@@ -56261,7 +56341,7 @@ function createImageWriter(deps) {
56261
56341
  try {
56262
56342
  guest.signal.throwIfAborted();
56263
56343
  const sizeBytes = await createRootfsOnce(digest, () => {
56264
- if (existsSync31(rootfs)) {
56344
+ if (existsSync32(rootfs)) {
56265
56345
  return Promise.resolve(readDiskUsage(rootfs));
56266
56346
  }
56267
56347
  freshRootfs.add(digest);
@@ -56298,7 +56378,7 @@ function createImageWriter(deps) {
56298
56378
  signal
56299
56379
  });
56300
56380
  } finally {
56301
- rmSync33(workDir.work, { recursive: true, force: true });
56381
+ rmSync34(workDir.work, { recursive: true, force: true });
56302
56382
  }
56303
56383
  }));
56304
56384
  };
@@ -56333,7 +56413,7 @@ function createImageWriter(deps) {
56333
56413
  signal: new AbortController().signal
56334
56414
  });
56335
56415
  } finally {
56336
- rmSync33(workDir.work, { recursive: true, force: true });
56416
+ rmSync34(workDir.work, { recursive: true, force: true });
56337
56417
  }
56338
56418
  }));
56339
56419
  };
@@ -56365,7 +56445,7 @@ function parseDuCount(stdout) {
56365
56445
  return count;
56366
56446
  }
56367
56447
  function readDiskUsage(path) {
56368
- return statSync18(path).blocks * 512;
56448
+ return statSync19(path).blocks * 512;
56369
56449
  }
56370
56450
 
56371
56451
  // packages/daemon/src/imps/images/create-image-adds.ts
@@ -57390,7 +57470,7 @@ async function listPublicImpNames(db) {
57390
57470
  }
57391
57471
 
57392
57472
  // packages/daemon/src/network/https/acme/cert-store.ts
57393
- import { existsSync as existsSync32, mkdirSync as mkdirSync30, readFileSync as readFileSync37, rmSync as rmSync34 } from "fs";
57473
+ import { existsSync as existsSync33, mkdirSync as mkdirSync30, readFileSync as readFileSync37, rmSync as rmSync35 } from "fs";
57394
57474
  import { join as join48 } from "path";
57395
57475
  import * as z103 from "zod";
57396
57476
  var AttemptStateSchema = z103.object({
@@ -57450,7 +57530,7 @@ ${certificate.chainPem.trimEnd()}
57450
57530
  },
57451
57531
  readAccount: (directoryUrl) => {
57452
57532
  const account = readStoredAccount(directoryUrl);
57453
- rmSync34(legacyKeyPath, { force: true });
57533
+ rmSync35(legacyKeyPath, { force: true });
57454
57534
  return account?.directoryUrl === directoryUrl ? account : null;
57455
57535
  },
57456
57536
  writeAccount: (account) => {
@@ -57472,7 +57552,7 @@ ${certificate.chainPem.trimEnd()}
57472
57552
  };
57473
57553
  }
57474
57554
  function readIfExists(path) {
57475
- return existsSync32(path) ? readFileSync37(path, "utf8") : null;
57555
+ return existsSync33(path) ? readFileSync37(path, "utf8") : null;
57476
57556
  }
57477
57557
  function parseJson2(text) {
57478
57558
  try {
@@ -60748,7 +60828,7 @@ function startImpdLogCapture(onLine) {
60748
60828
  }
60749
60829
 
60750
60830
  // packages/testing/src/stand-in/vm/build-stub-vmm.ts
60751
- import { existsSync as existsSync33, mkdirSync as mkdirSync31, renameSync as renameSync9, writeFileSync as writeFileSync16 } from "fs";
60831
+ import { existsSync as existsSync34, mkdirSync as mkdirSync31, renameSync as renameSync10, writeFileSync as writeFileSync16 } from "fs";
60752
60832
  var STUB_AGENT_VERSION = "0.1.0";
60753
60833
  var IMPD_OWNER = { uid: process.getuid?.() ?? 0, cgroup: null };
60754
60834
 
@@ -60898,7 +60978,7 @@ log tail`);
60898
60978
  }),
60899
60979
  wakeVm: (plan) => runInGeneration(async () => {
60900
60980
  const files = [plan.paths.disk, plan.paths.vmstate, plan.paths.memFile];
60901
- wakeJails.push({ jail: plan.jail, files: files.filter((file) => existsSync33(file)) });
60981
+ wakeJails.push({ jail: plan.jail, files: files.filter((file) => existsSync34(file)) });
60902
60982
  wakePlans.push(plan);
60903
60983
  const drive = readLoadingMeta(plan.paths)?.systemDrivePath;
60904
60984
  if (plan.jail !== null && drive !== undefined && !plan.readOnlyFiles.includes(drive)) {
@@ -60936,8 +61016,8 @@ log tail`);
60936
61016
  mkdirSync31(target.snapshotDir, { recursive: true });
60937
61017
  writeFileSync16(`${target.vmstate}.new`, "vmstate");
60938
61018
  writeFileSync16(`${target.memFile}.new`, "mem");
60939
- renameSync9(`${target.vmstate}.new`, target.vmstate);
60940
- renameSync9(`${target.memFile}.new`, target.memFile);
61019
+ renameSync10(`${target.vmstate}.new`, target.vmstate);
61020
+ renameSync10(`${target.memFile}.new`, target.memFile);
60941
61021
  usedSnapshots.delete(target.snapshotDir);
60942
61022
  return {};
60943
61023
  }),
@@ -61152,7 +61232,7 @@ log tail`);
61152
61232
  }
61153
61233
 
61154
61234
  // packages/testing/src/stand-in/vm/create-stub-uffd-handler.ts
61155
- import { existsSync as existsSync34, readFileSync as readFileSync40, writeFileSync as writeFileSync17 } from "fs";
61235
+ import { existsSync as existsSync35, readFileSync as readFileSync40, writeFileSync as writeFileSync17 } from "fs";
61156
61236
  import { join as join50 } from "path";
61157
61237
  import * as z105 from "zod";
61158
61238
  var StartSchema = z105.object({
@@ -61164,8 +61244,9 @@ var StartSchema = z105.object({
61164
61244
  served: z105.string()
61165
61245
  });
61166
61246
  var WarmRunSchema = z105.object({
61167
- mode: z105.enum(["--count-data", "--warm"]),
61247
+ mode: z105.enum(["--count-data", "--warm", "--count-blocks", "--warm-blocks"]),
61168
61248
  memFile: z105.string(),
61249
+ blockList: z105.string().optional(),
61169
61250
  pid: z105.int()
61170
61251
  });
61171
61252
  function createStubUffdHandler(directory, mode = "serve") {
@@ -61186,7 +61267,7 @@ exec '${process.execPath}' '${script}' '${mode}' '${recorded}' '${warmAnswer}' "
61186
61267
  };
61187
61268
  }
61188
61269
  function readRecords(path, schema) {
61189
- return existsSync34(path) ? readFileSync40(path, "utf8").trimEnd().split(`
61270
+ return existsSync35(path) ? readFileSync40(path, "utf8").trimEnd().split(`
61190
61271
  `).map((line) => schema.parse(JSON.parse(line))) : [];
61191
61272
  }
61192
61273
 
@@ -61244,7 +61325,7 @@ async function startTestImpd(stack, options = {}) {
61244
61325
  const logs = [];
61245
61326
  const filesystemGrows = [];
61246
61327
  const cloneDisk = options.cloneDisk ?? ((source, target) => {
61247
- copyFileSync5(source, target);
61328
+ copyFileSync6(source, target);
61248
61329
  return Promise.resolve();
61249
61330
  });
61250
61331
  const createStorage = () => options.createStorage?.(dataDir) ?? createXfsBackend({ dataDir, cloneFile: cloneDisk });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@impz/testing",
3
- "version": "7.9.0",
3
+ "version": "7.10.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": {
@@ -47,7 +47,7 @@
47
47
  "ts-pattern": "^5.9.2",
48
48
  "xstate": "^5.33.3",
49
49
  "zod": "^4.6.7",
50
- "@impz/client": "7.9.0"
50
+ "@impz/client": "7.10.0"
51
51
  },
52
52
  "engines": {
53
53
  "bun": ">=1.4.3"