@impz/testing 7.3.0 → 7.5.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 +96 -70
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -21758,6 +21758,69 @@ function parseTailnetNamesConfig(env, dataDir, isOnTailnet) {
21758
21758
  };
21759
21759
  }
21760
21760
 
21761
+ // packages/daemon/src/platform/errors/impd-error.ts
21762
+ class ImpdError extends Error {
21763
+ name = "ImpdError";
21764
+ code;
21765
+ status;
21766
+ data;
21767
+ constructor(code, options) {
21768
+ super(options.message, buildErrorOptions(options.cause));
21769
+ this.code = code;
21770
+ this.status = options.status;
21771
+ this.data = options.data;
21772
+ }
21773
+ }
21774
+ function isImpdError(error, code) {
21775
+ return error instanceof ImpdError && error.code === code;
21776
+ }
21777
+ function buildErrorOptions(cause) {
21778
+ return cause === undefined ? undefined : { cause };
21779
+ }
21780
+
21781
+ // packages/daemon/src/vm/vmm/elastic-memory.ts
21782
+ var MAX_GROWTH_FACTOR = 4;
21783
+ var SLOT_MIB = 128;
21784
+ var BLOCK_MIB = 2;
21785
+ var ONLINE_MOVABLE_ARG = "memhp_default_state=online_movable";
21786
+ var GROW_STEP_MIB = 256;
21787
+ var LOW_FLOOR_MIB = 128;
21788
+ var LOW_FRACTION = 0.15;
21789
+ var STRUCT_PAGE_MIB_PER_GIB = 16;
21790
+ function getRegionMib(memoryMib, maxMemoryMib) {
21791
+ const growth = maxMemoryMib - memoryMib;
21792
+ return growth <= 0 ? 0 : Math.ceil(growth / SLOT_MIB) * SLOT_MIB;
21793
+ }
21794
+ function getLowMib(totalMib) {
21795
+ return Math.max(LOW_FLOOR_MIB, totalMib * LOW_FRACTION);
21796
+ }
21797
+ function getSpareTotalMib(usedMib) {
21798
+ return Math.max(usedMib + LOW_FLOOR_MIB + GROW_STEP_MIB, Math.ceil((usedMib + GROW_STEP_MIB) / (1 - LOW_FRACTION)));
21799
+ }
21800
+ function getStructPageMib(mib) {
21801
+ return Math.ceil(mib * STRUCT_PAGE_MIB_PER_GIB / 1024);
21802
+ }
21803
+ function resolveMaxMemoryMib(memoryMib, requested) {
21804
+ if (requested === undefined) {
21805
+ return memoryMib;
21806
+ }
21807
+ if (requested < memoryMib) {
21808
+ throw new ImpdError("BAD_REQUEST", {
21809
+ message: `the max memory (${String(requested)} MiB) is less than the memory (${String(memoryMib)} MiB)`
21810
+ });
21811
+ }
21812
+ const ceiling = memoryMib * MAX_GROWTH_FACTOR;
21813
+ if (requested > ceiling) {
21814
+ throw new ImpdError("BAD_REQUEST", {
21815
+ message: `the max memory (${String(requested)} MiB) is more than ${String(MAX_GROWTH_FACTOR)} \xD7 the memory (${String(ceiling)} MiB): memory the guest grows into cannot hold its kernel's own allocations, so raise the memory too`
21816
+ });
21817
+ }
21818
+ return requested;
21819
+ }
21820
+ function toWholeBlocks(mib) {
21821
+ return Math.ceil(mib / BLOCK_MIB) * BLOCK_MIB;
21822
+ }
21823
+
21761
21824
  // packages/daemon/src/config.ts
21762
21825
  var PortSchema3 = z54.coerce.number().pipe(z54.int().min(1).max(65535));
21763
21826
  var CountSchema3 = z54.coerce.number().pipe(z54.int().positive());
@@ -21779,6 +21842,7 @@ var EnvSchema = z54.object({
21779
21842
  IMP_HOST_ADDRESSES: z54.string().default(""),
21780
21843
  IMP_RAM_BUDGET_MIB: CountSchema3.default(16384),
21781
21844
  IMP_PRIORITY_RAM_MIB: CountSchema3.optional(),
21845
+ IMP_PRIORITY_ORDINARY_RAM_MIB: z54.coerce.number().pipe(z54.int().nonnegative()).optional(),
21782
21846
  IMP_PRIORITY_IMPS: z54.string().transform(splitList).pipe(z54.array(ImpPatternSchema)).optional(),
21783
21847
  IMP_IDLE_TIMEOUT_S: CountSchema3.default(60),
21784
21848
  IMP_IDLE_CPU_PERCENT: z54.coerce.number().nonnegative().default(10),
@@ -21795,6 +21859,7 @@ var EnvSchema = z54.object({
21795
21859
  IMP_DISK_RESERVE_GIB: CountSchema3.optional(),
21796
21860
  IMP_BUILD_CONTEXT_MAX_MIB: CountSchema3.default(1024),
21797
21861
  IMP_BUILD_MEMORY_MIB: CountSchema3.default(2048),
21862
+ IMP_BUILD_MAX_MEMORY_MIB: CountSchema3.optional(),
21798
21863
  IMP_BUILD_DISK_GIB: CountSchema3.default(20),
21799
21864
  IMP_BUILD_IMAGE_MAX_MIB: CountSchema3.default(8192),
21800
21865
  IMP_BUILD_IMAGE_MAX_FILES: CountSchema3.default(1e6),
@@ -21963,6 +22028,7 @@ function loadConfig(env) {
21963
22028
  buildContextMaxBytes: parsed.IMP_BUILD_CONTEXT_MAX_MIB * 1024 ** 2,
21964
22029
  build: {
21965
22030
  memoryMib: parsed.IMP_BUILD_MEMORY_MIB,
22031
+ maxMemoryMib: parseBuildMaxMemoryMib(parsed),
21966
22032
  diskBytes: parsed.IMP_BUILD_DISK_GIB * 1024 ** 3,
21967
22033
  imageMaxBytes: parsed.IMP_BUILD_IMAGE_MAX_MIB * 1024 ** 2,
21968
22034
  imageMaxFiles: parsed.IMP_BUILD_IMAGE_MAX_FILES,
@@ -22006,7 +22072,11 @@ function loadConfig(env) {
22006
22072
  function parsePriorityRam(parsed) {
22007
22073
  const mib = parsed.IMP_PRIORITY_RAM_MIB;
22008
22074
  const patterns = parsed.IMP_PRIORITY_IMPS;
22075
+ const ordinaryMib = parsed.IMP_PRIORITY_ORDINARY_RAM_MIB;
22009
22076
  if (mib === undefined && patterns === undefined) {
22077
+ if (ordinaryMib !== undefined) {
22078
+ throw new Error("IMP_PRIORITY_ORDINARY_RAM_MIB needs IMP_PRIORITY_RAM_MIB and IMP_PRIORITY_IMPS");
22079
+ }
22010
22080
  return null;
22011
22081
  }
22012
22082
  if (mib === undefined || patterns === undefined) {
@@ -22015,7 +22085,24 @@ function parsePriorityRam(parsed) {
22015
22085
  if (mib >= parsed.IMP_RAM_BUDGET_MIB) {
22016
22086
  throw new Error(`IMP_PRIORITY_RAM_MIB ${String(mib)} leaves no room for other imps in the ${String(parsed.IMP_RAM_BUDGET_MIB)} MiB IMP_RAM_BUDGET_MIB`);
22017
22087
  }
22018
- return { mib, patterns };
22088
+ if (ordinaryMib !== undefined && ordinaryMib > mib) {
22089
+ throw new Error(`IMP_PRIORITY_ORDINARY_RAM_MIB ${String(ordinaryMib)} is more than the ${String(mib)} MiB IMP_PRIORITY_RAM_MIB`);
22090
+ }
22091
+ return { mib, patterns, ...ordinaryMib !== undefined && { ordinaryMib } };
22092
+ }
22093
+ function parseBuildMaxMemoryMib(parsed) {
22094
+ const memoryMib = parsed.IMP_BUILD_MEMORY_MIB;
22095
+ const maxMemoryMib = parsed.IMP_BUILD_MAX_MEMORY_MIB;
22096
+ if (maxMemoryMib === undefined) {
22097
+ return null;
22098
+ }
22099
+ if (maxMemoryMib <= memoryMib) {
22100
+ throw new Error(`IMP_BUILD_MAX_MEMORY_MIB ${String(maxMemoryMib)} is not above the ${String(memoryMib)} MiB IMP_BUILD_MEMORY_MIB`);
22101
+ }
22102
+ if (maxMemoryMib > memoryMib * MAX_GROWTH_FACTOR) {
22103
+ throw new Error(`IMP_BUILD_MAX_MEMORY_MIB ${String(maxMemoryMib)} is more than ${String(MAX_GROWTH_FACTOR)} \xD7 the ${String(memoryMib)} MiB IMP_BUILD_MEMORY_MIB`);
22104
+ }
22105
+ return maxMemoryMib;
22019
22106
  }
22020
22107
  function parseTestRegistry(parsed) {
22021
22108
  const registry = parsed.IMP_BUILD_TEST_REGISTRY;
@@ -22066,7 +22153,7 @@ import { join as join49 } from "path";
22066
22153
  // packages/daemon/package.json
22067
22154
  var package_default = {
22068
22155
  name: "@impz/daemon",
22069
- version: "7.3.0",
22156
+ version: "7.5.0",
22070
22157
  private: true,
22071
22158
  description: "impd: the imp host daemon",
22072
22159
  type: "module",
@@ -23489,26 +23576,6 @@ class ImpClashError extends Error {
23489
23576
  }
23490
23577
  }
23491
23578
 
23492
- // packages/daemon/src/platform/errors/impd-error.ts
23493
- class ImpdError extends Error {
23494
- name = "ImpdError";
23495
- code;
23496
- status;
23497
- data;
23498
- constructor(code, options) {
23499
- super(options.message, buildErrorOptions(options.cause));
23500
- this.code = code;
23501
- this.status = options.status;
23502
- this.data = options.data;
23503
- }
23504
- }
23505
- function isImpdError(error, code) {
23506
- return error instanceof ImpdError && error.code === code;
23507
- }
23508
- function buildErrorOptions(cause) {
23509
- return cause === undefined ? undefined : { cause };
23510
- }
23511
-
23512
23579
  // packages/daemon/src/platform/errors/impd-errors.ts
23513
23580
  function buildNotFoundError(kind, name) {
23514
23581
  return new ImpdError("NOT_FOUND", {
@@ -33481,7 +33548,7 @@ var EVENT_TOOL = defineTool({
33481
33548
  input: z72.strictObject({
33482
33549
  after: EventCursorSchema.shape.after.describe("The after of the last call; omit it at first"),
33483
33550
  logId: EventCursorSchema.shape.logId.describe("The logId of the last call"),
33484
- limit: z72.int().min(1).max(1000).optional().describe("The most events to return, 100 when omitted")
33551
+ limit: z72.int().min(1).max(1000).optional().describe("The most events to return after a valid cursor, 100 when omitted. A call with no after, and a Reset, return every imp whatever the limit")
33485
33552
  }),
33486
33553
  annotations: { title: "List imp events", readOnlyHint: true, openWorldHint: false },
33487
33554
  run: async (input, context) => {
@@ -39961,7 +40028,7 @@ function buildUsageTotals(input) {
39961
40028
  ordinaryEffectiveMib,
39962
40029
  kept: {
39963
40030
  ramMib: Math.max(0, input.priorityMib - priority.ramMib),
39964
- ordinaryMib: Math.max(0, input.priorityMib - priority.ordinaryMib),
40031
+ ordinaryMib: Math.max(0, input.priorityOrdinaryMib - priority.ordinaryMib),
39965
40032
  poolMib: Math.max(0, input.priorityMib - priority.poolMib)
39966
40033
  }
39967
40034
  };
@@ -40189,7 +40256,8 @@ function createRamGovernor(deps) {
40189
40256
  pendingPool,
40190
40257
  lockedMib,
40191
40258
  headroomMib,
40192
- priorityMib: priority?.mib ?? 0
40259
+ priorityMib: priority?.mib ?? 0,
40260
+ priorityOrdinaryMib: priority?.ordinaryMib ?? priority?.mib ?? 0
40193
40261
  });
40194
40262
  return { awake, headroomMib, ...totals };
40195
40263
  };
@@ -40671,49 +40739,6 @@ function toApiError(error) {
40671
40739
  // packages/daemon/src/imps/imps/imp-commands.ts
40672
40740
  import { mkdirSync as mkdirSync12, rmSync as rmSync15 } from "fs";
40673
40741
 
40674
- // packages/daemon/src/vm/vmm/elastic-memory.ts
40675
- var MAX_GROWTH_FACTOR = 4;
40676
- var SLOT_MIB = 128;
40677
- var BLOCK_MIB = 2;
40678
- var ONLINE_MOVABLE_ARG = "memhp_default_state=online_movable";
40679
- var GROW_STEP_MIB = 256;
40680
- var LOW_FLOOR_MIB = 128;
40681
- var LOW_FRACTION = 0.15;
40682
- var STRUCT_PAGE_MIB_PER_GIB = 16;
40683
- function getRegionMib(memoryMib, maxMemoryMib) {
40684
- const growth = maxMemoryMib - memoryMib;
40685
- return growth <= 0 ? 0 : Math.ceil(growth / SLOT_MIB) * SLOT_MIB;
40686
- }
40687
- function getLowMib(totalMib) {
40688
- return Math.max(LOW_FLOOR_MIB, totalMib * LOW_FRACTION);
40689
- }
40690
- function getSpareTotalMib(usedMib) {
40691
- return Math.max(usedMib + LOW_FLOOR_MIB + GROW_STEP_MIB, Math.ceil((usedMib + GROW_STEP_MIB) / (1 - LOW_FRACTION)));
40692
- }
40693
- function getStructPageMib(mib) {
40694
- return Math.ceil(mib * STRUCT_PAGE_MIB_PER_GIB / 1024);
40695
- }
40696
- function resolveMaxMemoryMib(memoryMib, requested) {
40697
- if (requested === undefined) {
40698
- return memoryMib;
40699
- }
40700
- if (requested < memoryMib) {
40701
- throw new ImpdError("BAD_REQUEST", {
40702
- message: `the max memory (${String(requested)} MiB) is less than the memory (${String(memoryMib)} MiB)`
40703
- });
40704
- }
40705
- const ceiling = memoryMib * MAX_GROWTH_FACTOR;
40706
- if (requested > ceiling) {
40707
- throw new ImpdError("BAD_REQUEST", {
40708
- message: `the max memory (${String(requested)} MiB) is more than ${String(MAX_GROWTH_FACTOR)} \xD7 the memory (${String(ceiling)} MiB): memory the guest grows into cannot hold its kernel's own allocations, so raise the memory too`
40709
- });
40710
- }
40711
- return requested;
40712
- }
40713
- function toWholeBlocks(mib) {
40714
- return Math.ceil(mib / BLOCK_MIB) * BLOCK_MIB;
40715
- }
40716
-
40717
40742
  // packages/daemon/src/imps/imps/cpu-limit.ts
40718
40743
  var MIN_CPU_LIMIT = 0.1;
40719
40744
  var DEFAULT_CPU_WEIGHT = 100;
@@ -50750,6 +50775,7 @@ function createBuilders(deps) {
50750
50775
  name,
50751
50776
  image: BUILDER_IMAGE,
50752
50777
  memoryMib: deps.config.build.memoryMib,
50778
+ maxMemoryMib: deps.config.build.maxMemoryMib ?? undefined,
50753
50779
  diskMib: Math.ceil(deps.config.build.diskBytes / 1024 ** 2),
50754
50780
  policy: { mode: "public", allow: [] },
50755
50781
  kind: "builder",
@@ -53547,7 +53573,7 @@ function createImageAdds(deps, writer) {
53547
53573
  signal: options?.signal ?? new AbortController().signal
53548
53574
  }),
53549
53575
  ensureBuilderImage: loadBuilderImage,
53550
- seedDefaultImage: async () => {
53576
+ addDefaultImage: async () => {
53551
53577
  const images = await listImages(deps.db);
53552
53578
  const seedRef = deps.seedRef === undefined ? SEED_REF : deps.seedRef;
53553
53579
  if (seedRef !== null && images.every((image) => image.name === BUILDER_IMAGE)) {
@@ -60323,7 +60349,7 @@ async function startImpdParts(config, boundaries, plan) {
60323
60349
  }
60324
60350
  async function setupDefaultImage(config, images) {
60325
60351
  try {
60326
- await images.seedDefaultImage();
60352
+ await images.addDefaultImage();
60327
60353
  const existing = await images.listImages();
60328
60354
  if (!existing.some((image) => image.name === config.defaultImage)) {
60329
60355
  getImpdLogger("image").warning("no image named {defaultImage} (IMP_DEFAULT_IMAGE); impz new uses ubuntu until `impz image add <ref> --name {defaultImage}` adds it", { defaultImage: config.defaultImage });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@impz/testing",
3
- "version": "7.3.0",
3
+ "version": "7.5.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": {
@@ -42,7 +42,7 @@
42
42
  "ts-pattern": "^5.9.2",
43
43
  "xstate": "^5.33.3",
44
44
  "zod": "^4.6.7",
45
- "@impz/client": "7.3.0"
45
+ "@impz/client": "7.5.0"
46
46
  },
47
47
  "engines": {
48
48
  "bun": ">=1.4.3"