@impz/testing 6.9.0 → 6.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 +25 -9
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -20188,7 +20188,8 @@ var SystemFeaturesSchema = z33.object({
20188
20188
  execDropSysAdmin: z33.boolean().optional(),
20189
20189
  guestScratch: z33.boolean().optional(),
20190
20190
  imagePins: z33.boolean().optional(),
20191
- buildContextUpload: z33.boolean().optional()
20191
+ buildContextUpload: z33.boolean().optional(),
20192
+ destroyIdCheck: z33.boolean().optional()
20192
20193
  });
20193
20194
  var GuestInfoSchema = z33.object({
20194
20195
  scratchDir: z33.string(),
@@ -20210,6 +20211,7 @@ var SystemInfoSchema = z33.object({
20210
20211
  ramCommittedMib: z33.int().nonnegative(),
20211
20212
  ramPriorityKeptMib: z33.int().nonnegative().optional(),
20212
20213
  ramSleepingMib: z33.int().nonnegative().optional(),
20214
+ ramPrioritySleepingMib: z33.int().nonnegative().optional(),
20213
20215
  awakeCount: z33.int().nonnegative(),
20214
20216
  impCount: z33.int().nonnegative(),
20215
20217
  sessionCount: z33.int().nonnegative(),
@@ -20305,7 +20307,7 @@ var ResourceKindSchema = z34.enum([
20305
20307
  var ResourceDataSchema = z34.object({
20306
20308
  kind: ResourceKindSchema,
20307
20309
  name: z34.string(),
20308
- reason: z34.enum(["binding_changed"]).optional()
20310
+ reason: z34.enum(["binding_changed", "id_changed"]).optional()
20309
20311
  });
20310
20312
  var ForbiddenReasonSchema = z34.enum(["imp_out_of_scope", "not_grantable", "scope"]);
20311
20313
  var ForbiddenDataSchema = z34.object({ reason: ForbiddenReasonSchema });
@@ -20424,7 +20426,7 @@ var impsContract = {
20424
20426
  create: contractBase.meta(ACCESS.manageImp).input(ImpCreateInputSchema).output(ImpSchema),
20425
20427
  list: contractBase.meta(ACCESS.readAny).input(z40.object({ builders: z40.boolean().optional() }).optional()).output(z40.array(ImpSchema)),
20426
20428
  get: contractBase.meta(ACCESS.readImp).input(NameInputSchema).output(ImpSchema),
20427
- destroy: contractBase.meta(ACCESS.manageImp).input(NameInputSchema).output(EmptySchema),
20429
+ destroy: contractBase.meta(ACCESS.manageImp).input(z40.object({ name: NameSchema, id: z40.string().optional() })).output(EmptySchema),
20428
20430
  start: contractBase.meta(ACCESS.execImp).input(NameInputSchema).output(ImpSchema),
20429
20431
  stop: contractBase.meta(ACCESS.execImp).input(ForceInputSchema).output(ImpSchema),
20430
20432
  sleep: contractBase.meta(ACCESS.execImp).input(ForceInputSchema).output(ImpSchema),
@@ -21992,7 +21994,7 @@ import { join as join48 } from "path";
21992
21994
  // packages/daemon/package.json
21993
21995
  var package_default = {
21994
21996
  name: "@impz/daemon",
21995
- version: "6.9.0",
21997
+ version: "6.10.0",
21996
21998
  private: true,
21997
21999
  description: "impd: the imp host daemon",
21998
22000
  type: "module",
@@ -22246,6 +22248,12 @@ function buildConflictError(kind, name, message) {
22246
22248
  data: { kind, name }
22247
22249
  });
22248
22250
  }
22251
+ function buildIdChangedError(name, id) {
22252
+ return new ImpdError("CONFLICT", {
22253
+ message: `imp ${name} is no longer the imp with id ${id}`,
22254
+ data: { kind: "imp", name, reason: "id_changed" }
22255
+ });
22256
+ }
22249
22257
  var NOT_BACKED_UP_REASON = "created with backup off";
22250
22258
  function buildNotBackedUpError(name, refusal) {
22251
22259
  return new ImpdError("PRECONDITION_FAILED", {
@@ -30103,7 +30111,7 @@ function createImpRoutes(os, deps, views) {
30103
30111
  }),
30104
30112
  get: os.imps.get.handler((context) => views.readCallerImp(context.context.caller, deps.imps.readImp(context.input.name))),
30105
30113
  destroy: os.imps.destroy.handler(async (context) => {
30106
- await deps.imps.destroyImp(context.input.name);
30114
+ await deps.imps.destroyImp(context.input.name, { id: context.input.id });
30107
30115
  return {};
30108
30116
  }),
30109
30117
  start: os.imps.start.handler((context) => views.readCallerImp(context.context.caller, deps.imps.startImp(context.input.name))),
@@ -30559,7 +30567,7 @@ async function readSystemInfo(deps) {
30559
30567
  deps.images.findDefaultImage()
30560
30568
  ]);
30561
30569
  const running = imps.filter((imp) => imp.state === "running");
30562
- const sleeping = imps.filter((imp) => imp.state === "sleeping");
30570
+ const sleeping = imps.filter((imp) => imp.state === "sleeping" && !deps.governor.isAdmitted(imp.id));
30563
30571
  return {
30564
30572
  version: package_default.version,
30565
30573
  ramBudgetMib: deps.config.ramBudgetMib,
@@ -30568,6 +30576,7 @@ async function readSystemInfo(deps) {
30568
30576
  ramCommittedMib: running.reduce((sum, imp) => sum + imp.maxMemoryMib, 0),
30569
30577
  ramPriorityKeptMib: usage.priorityKeptMib,
30570
30578
  ramSleepingMib: sleeping.reduce((sum, imp) => sum + imp.memoryMib, 0),
30579
+ ramPrioritySleepingMib: sleeping.filter((imp) => deps.governor.isPriority(imp.name)).reduce((sum, imp) => sum + imp.memoryMib, 0),
30571
30580
  awakeCount: running.length,
30572
30581
  impCount: imps.length,
30573
30582
  sessionCount: imps.reduce((sum, imp) => sum + (deps.imps.countSessions(imp) ?? 0), 0),
@@ -37946,7 +37955,7 @@ function createRamGovernor(deps) {
37946
37955
  }
37947
37956
  emitAdmission(request, "admitted", usedMib);
37948
37957
  };
37949
- const readReservation = (id) => {
37958
+ const getReservationMib = (id) => {
37950
37959
  const reservation = reservations.get(id);
37951
37960
  if (reservation === undefined) {
37952
37961
  return 0;
@@ -37978,7 +37987,7 @@ function createRamGovernor(deps) {
37978
37987
  const readings = await Promise.all(awake.map((imp) => readVm(imp.pid, imp.apiSocket)));
37979
37988
  const live = [...reservations.keys()].filter((id) => id !== excludeId).map((id) => ({
37980
37989
  id,
37981
- mib: readReservation(id),
37990
+ mib: getReservationMib(id),
37982
37991
  isPriority: admittedPriority.has(id),
37983
37992
  isOnPool: pendingHugePages.has(id)
37984
37993
  }));
@@ -38206,6 +38215,8 @@ function createRamGovernor(deps) {
38206
38215
  reservations.set(id, reservation.beforeGrow);
38207
38216
  }
38208
38217
  },
38218
+ isPriority,
38219
+ isAdmitted: (id) => getReservationMib(id) > 0,
38209
38220
  readUsage: async () => {
38210
38221
  const usage = await readEffectiveUsage(null);
38211
38222
  return {
@@ -38796,7 +38807,12 @@ function createImpCommands(parts) {
38796
38807
  return presenter.readApi(after);
38797
38808
  }),
38798
38809
  destroyImp: async (name, options = {}) => {
38799
- await lock.withImp(name, removeLockedImp, options);
38810
+ await lock.withImp(name, async (imp) => {
38811
+ if (options.id !== undefined && imp.id !== options.id) {
38812
+ throw buildIdChangedError(name, options.id);
38813
+ }
38814
+ await removeLockedImp(imp);
38815
+ }, options);
38800
38816
  },
38801
38817
  destroyImpId: async (id, kind) => {
38802
38818
  await lock.withImpId(id, async (imp) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@impz/testing",
3
- "version": "6.9.0",
3
+ "version": "6.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": {
@@ -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.9.0"
46
+ "@impz/client": "6.10.0"
47
47
  },
48
48
  "engines": {
49
49
  "bun": ">=1.4.3"