@impz/testing 6.11.2 → 6.11.4
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.
- package/dist/index.js +149 -103
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -21756,7 +21756,7 @@ var EnvSchema = z53.object({
|
|
|
21756
21756
|
IMP_KSM_HEADROOM_PERCENT: z53.string().default("100"),
|
|
21757
21757
|
IMP_HUGE_PAGES: z53.enum(["off", "2M"]).default("off"),
|
|
21758
21758
|
IMP_UFFD_HANDLER: z53.string().default("uffd-handler"),
|
|
21759
|
-
IMP_WARM_CAP_MIB: CountSchema3.default(
|
|
21759
|
+
IMP_WARM_CAP_MIB: CountSchema3.default(2048),
|
|
21760
21760
|
IMP_DNS: z53.string().default("1.1.1.1,8.8.8.8").transform(splitList).pipe(DnsServersSchema),
|
|
21761
21761
|
IMP_SUBNET: z53.cidrv4().default("10.66.0.0/16"),
|
|
21762
21762
|
IMP_SUBNET6: z53.string().default("auto"),
|
|
@@ -22009,7 +22009,7 @@ import { join as join48 } from "path";
|
|
|
22009
22009
|
// packages/daemon/package.json
|
|
22010
22010
|
var package_default = {
|
|
22011
22011
|
name: "@impz/daemon",
|
|
22012
|
-
version: "6.11.
|
|
22012
|
+
version: "6.11.4",
|
|
22013
22013
|
private: true,
|
|
22014
22014
|
description: "impd: the imp host daemon",
|
|
22015
22015
|
type: "module",
|
|
@@ -22199,7 +22199,7 @@ function runOnInterval(durationMs, tick) {
|
|
|
22199
22199
|
}
|
|
22200
22200
|
|
|
22201
22201
|
// packages/daemon/src/platform/db/imps.ts
|
|
22202
|
-
import { sql as
|
|
22202
|
+
import { sql as sql3 } from "kysely";
|
|
22203
22203
|
|
|
22204
22204
|
// packages/daemon/src/platform/db/list-taken-slots.ts
|
|
22205
22205
|
async function listTakenSlots(db, now) {
|
|
@@ -22312,25 +22312,57 @@ async function readEventHead(db) {
|
|
|
22312
22312
|
return Math.max(row.last ?? 0, row.pruned_through);
|
|
22313
22313
|
}
|
|
22314
22314
|
// packages/durable/src/events/read-log-id.ts
|
|
22315
|
-
async function
|
|
22315
|
+
async function readLogID(db) {
|
|
22316
22316
|
const row = await db.selectFrom("event_log").select("log_id").where("id", "=", 1).executeTakeFirstOrThrow();
|
|
22317
22317
|
return row.log_id;
|
|
22318
22318
|
}
|
|
22319
22319
|
// packages/durable/src/events/remove-log-id.ts
|
|
22320
|
-
async function
|
|
22320
|
+
async function removeLogID(db) {
|
|
22321
22321
|
await db.updateTable("event_log").set({ log_id: "" }).where("id", "=", 1).execute();
|
|
22322
22322
|
}
|
|
22323
|
+
// packages/durable/src/events/create-outside-write-triggers.ts
|
|
22324
|
+
import { sql } from "kysely";
|
|
22325
|
+
var WRITES = ["INSERT", "UPDATE", "DELETE"];
|
|
22326
|
+
async function createOutsideWriteTriggers(db, tables) {
|
|
22327
|
+
await sql`
|
|
22328
|
+
CREATE TABLE IF NOT EXISTS event_log_outside_writes (id INTEGER PRIMARY KEY CHECK (id = 1))
|
|
22329
|
+
`.execute(db);
|
|
22330
|
+
for (const table of tables) {
|
|
22331
|
+
for (const write of WRITES) {
|
|
22332
|
+
const name = sql.id(`durable_outside_${write.toLowerCase()}_${table}`);
|
|
22333
|
+
await sql`DROP TRIGGER IF EXISTS ${name}`.execute(db);
|
|
22334
|
+
await sql`
|
|
22335
|
+
CREATE TRIGGER ${name} AFTER ${sql.raw(write)} ON ${sql.table(table)}
|
|
22336
|
+
BEGIN
|
|
22337
|
+
INSERT OR IGNORE INTO event_log_outside_writes (id) VALUES (1);
|
|
22338
|
+
END
|
|
22339
|
+
`.execute(db);
|
|
22340
|
+
}
|
|
22341
|
+
}
|
|
22342
|
+
await sql`
|
|
22343
|
+
CREATE TEMP TRIGGER IF NOT EXISTS durable_skip_own_writes
|
|
22344
|
+
BEFORE INSERT ON main.event_log_outside_writes
|
|
22345
|
+
BEGIN
|
|
22346
|
+
SELECT RAISE(IGNORE);
|
|
22347
|
+
END
|
|
22348
|
+
`.execute(db);
|
|
22349
|
+
}
|
|
22350
|
+
// packages/durable/src/events/remove-log-id-after-outside-writes.ts
|
|
22351
|
+
async function removeLogIDAfterOutsideWrites(db) {
|
|
22352
|
+
await db.updateTable("event_log").set({ log_id: "" }).where("id", "=", 1).where((eb) => eb.exists(eb.selectFrom("event_log_outside_writes").select("id"))).execute();
|
|
22353
|
+
await db.deleteFrom("event_log_outside_writes").execute();
|
|
22354
|
+
}
|
|
22323
22355
|
// packages/durable/src/events/write-new-log-id.ts
|
|
22324
|
-
async function
|
|
22356
|
+
async function writeNewLogID(db) {
|
|
22325
22357
|
await db.updateTable("event_log").set({ log_id: crypto.randomUUID() }).where("id", "=", 1).where("log_id", "=", "").execute();
|
|
22326
22358
|
}
|
|
22327
22359
|
// packages/durable/src/migrations/durable-migration-001-create-event-log.ts
|
|
22328
|
-
import { sql } from "kysely";
|
|
22360
|
+
import { sql as sql2 } from "kysely";
|
|
22329
22361
|
var DURABLE_MIGRATION_001_CREATE_EVENT_LOG = {
|
|
22330
22362
|
async up(db) {
|
|
22331
22363
|
await db.schema.createTable("events").addColumn("seq", "integer", (column) => column.primaryKey().autoIncrement()).addColumn("at", "integer", (column) => column.notNull()).addColumn("kind", "text", (column) => column.notNull()).addColumn("target_id", "text").addColumn("operation_id", "text").addColumn("payload", "text", (column) => column.notNull()).execute();
|
|
22332
|
-
await db.schema.createTable("event_log").addColumn("id", "integer", (column) => column.primaryKey().check(
|
|
22333
|
-
await
|
|
22364
|
+
await db.schema.createTable("event_log").addColumn("id", "integer", (column) => column.primaryKey().check(sql2`id = 1`)).addColumn("log_id", "text", (column) => column.notNull()).addColumn("pruned_through", "integer", (column) => column.notNull()).execute();
|
|
22365
|
+
await sql2`
|
|
22334
22366
|
INSERT INTO event_log (id, log_id, pruned_through) VALUES (1, ${crypto.randomUUID()}, 0)
|
|
22335
22367
|
`.execute(db);
|
|
22336
22368
|
}
|
|
@@ -23735,8 +23767,8 @@ async function updateImpActivity(db, id, at) {
|
|
|
23735
23767
|
async function updateImpRequest(db, id, at) {
|
|
23736
23768
|
const atMs = at.getTime();
|
|
23737
23769
|
await db.updateTable("imps").set({
|
|
23738
|
-
last_active_at:
|
|
23739
|
-
last_request_at:
|
|
23770
|
+
last_active_at: sql3`MAX(last_active_at, ${atMs})`,
|
|
23771
|
+
last_request_at: sql3`MAX(COALESCE(last_request_at, 0), ${atMs})`
|
|
23740
23772
|
}).where("id", "=", id).execute();
|
|
23741
23773
|
}
|
|
23742
23774
|
function updateImpDisk(db, id, disk) {
|
|
@@ -23753,7 +23785,7 @@ function updateImpDisk(db, id, disk) {
|
|
|
23753
23785
|
var NO_END_MS = 8640000000000000;
|
|
23754
23786
|
async function updateImpHold(db, id) {
|
|
23755
23787
|
const row = await db.updateTable("imps").set((eb) => ({
|
|
23756
|
-
hold_until: eb.selectFrom("imp_leases").select((inner) => inner.fn.max(inner.fn.coalesce("until",
|
|
23788
|
+
hold_until: eb.selectFrom("imp_leases").select((inner) => inner.fn.max(inner.fn.coalesce("until", sql3.lit(NO_END_MS))).as("end")).where("imp_id", "=", id)
|
|
23757
23789
|
})).where("id", "=", id).returningAll().executeTakeFirstOrThrow();
|
|
23758
23790
|
return toImpRecord(row);
|
|
23759
23791
|
}
|
|
@@ -23948,28 +23980,28 @@ import { Database } from "bun:sqlite";
|
|
|
23948
23980
|
import { chmodSync, closeSync, mkdirSync as mkdirSync3, openSync, rmSync, statSync } from "fs";
|
|
23949
23981
|
import { join as join5 } from "path";
|
|
23950
23982
|
import { buildSQLiteDialect } from "@zgeoff/kysely-bun-sqlite";
|
|
23951
|
-
import { Kysely, sql as
|
|
23983
|
+
import { Kysely, sql as sql4 } from "kysely";
|
|
23952
23984
|
import * as z55 from "zod";
|
|
23953
23985
|
var MigrationRowSchema = z55.object({ name: z55.string() });
|
|
23954
23986
|
var IntegrityRowSchema = z55.object({ integrity_check: z55.string() });
|
|
23955
23987
|
var SizeRowSchema = z55.object({ bytes: z55.int().nonnegative() });
|
|
23956
23988
|
async function writeConsistentCopy(db, path) {
|
|
23957
|
-
await
|
|
23958
|
-
await
|
|
23989
|
+
await sql4`VACUUM INTO ${path}`.execute(db);
|
|
23990
|
+
await removeCopyLogID(path);
|
|
23959
23991
|
}
|
|
23960
|
-
async function
|
|
23992
|
+
async function removeCopyLogID(path) {
|
|
23961
23993
|
const copy = new Kysely({ dialect: buildSQLiteDialect(new Database(path)) });
|
|
23962
23994
|
try {
|
|
23963
23995
|
const hasEventLog = await probeEventLogTable(copy);
|
|
23964
23996
|
if (hasEventLog) {
|
|
23965
|
-
await
|
|
23997
|
+
await removeLogID(copy);
|
|
23966
23998
|
}
|
|
23967
23999
|
} finally {
|
|
23968
24000
|
await copy.destroy();
|
|
23969
24001
|
}
|
|
23970
24002
|
}
|
|
23971
24003
|
async function probeEventLogTable(copy) {
|
|
23972
|
-
const tables = await
|
|
24004
|
+
const tables = await sql4`
|
|
23973
24005
|
SELECT name FROM sqlite_master WHERE type = 'table' AND name = 'event_log'
|
|
23974
24006
|
`.execute(copy);
|
|
23975
24007
|
return tables.rows.length > 0;
|
|
@@ -24009,7 +24041,7 @@ async function writeDatabaseCopy(db, options) {
|
|
|
24009
24041
|
});
|
|
24010
24042
|
}
|
|
24011
24043
|
async function readDatabaseBytes(db) {
|
|
24012
|
-
const result = await
|
|
24044
|
+
const result = await sql4`SELECT page_count * page_size AS bytes FROM pragma_page_count(), pragma_page_size()`.execute(db);
|
|
24013
24045
|
return SizeRowSchema.parse(result.rows[0]).bytes;
|
|
24014
24046
|
}
|
|
24015
24047
|
function readCopyFacts(path) {
|
|
@@ -28377,7 +28409,7 @@ function withImpLogContext(imp, run) {
|
|
|
28377
28409
|
}
|
|
28378
28410
|
|
|
28379
28411
|
// packages/daemon/src/platform/db/update-imp-state.ts
|
|
28380
|
-
import { sql as
|
|
28412
|
+
import { sql as sql5 } from "kysely";
|
|
28381
28413
|
async function updateImpState(db, id, change, expected) {
|
|
28382
28414
|
const values = { state: change.state };
|
|
28383
28415
|
if (change.error !== undefined) {
|
|
@@ -28425,13 +28457,13 @@ function buildAwakeValues(change) {
|
|
|
28425
28457
|
if (change.state === "running") {
|
|
28426
28458
|
const isWake = change.reason === "woke" || change.countsWake === true;
|
|
28427
28459
|
return {
|
|
28428
|
-
awake_since:
|
|
28429
|
-
...isWake && { wake_count:
|
|
28460
|
+
awake_since: sql5`coalesce(awake_since, ${now})`,
|
|
28461
|
+
...isWake && { wake_count: sql5`wake_count + 1` }
|
|
28430
28462
|
};
|
|
28431
28463
|
}
|
|
28432
28464
|
const until = change.awakeUntil?.getTime() ?? now;
|
|
28433
28465
|
return {
|
|
28434
|
-
awake_ms:
|
|
28466
|
+
awake_ms: sql5`awake_ms + coalesce(max(0, ${until} - awake_since), 0)`,
|
|
28435
28467
|
awake_since: null
|
|
28436
28468
|
};
|
|
28437
28469
|
}
|
|
@@ -29606,7 +29638,7 @@ function createImpEventLog(db, now) {
|
|
|
29606
29638
|
}
|
|
29607
29639
|
},
|
|
29608
29640
|
readHead: () => readEventHead(db),
|
|
29609
|
-
|
|
29641
|
+
readLogID: () => readLogID(db),
|
|
29610
29642
|
readAfter: (after, limit) => readImpEventsAfter(db, { after, limit }),
|
|
29611
29643
|
start: async () => {
|
|
29612
29644
|
const head = await readEventHead(db);
|
|
@@ -29651,7 +29683,7 @@ async function runFollower(db, parts, head) {
|
|
|
29651
29683
|
}
|
|
29652
29684
|
|
|
29653
29685
|
// packages/daemon/src/platform/db/run-migrations.ts
|
|
29654
|
-
import { sql as
|
|
29686
|
+
import { sql as sql15 } from "kysely";
|
|
29655
29687
|
import { Migrator } from "kysely/migration";
|
|
29656
29688
|
|
|
29657
29689
|
// packages/daemon/src/platform/db/migrations/migration-001-create-initial-schema.ts
|
|
@@ -29829,14 +29861,14 @@ var MIGRATION_019_ADD_IMP_MAX_MEMORY = {
|
|
|
29829
29861
|
};
|
|
29830
29862
|
|
|
29831
29863
|
// packages/daemon/src/platform/db/migrations/migration-020-add-grantable-secrets.ts
|
|
29832
|
-
import { sql as
|
|
29864
|
+
import { sql as sql6 } from "kysely";
|
|
29833
29865
|
var MIGRATION_020_ADD_GRANTABLE_SECRETS = {
|
|
29834
29866
|
async up(db) {
|
|
29835
29867
|
await db.schema.alterTable("tokens").addColumn("grantable", "text", (column) => column.notNull().defaultTo("[]")).execute();
|
|
29836
29868
|
await db.schema.alterTable("secrets").addColumn("generation", "text", (column) => column.notNull().defaultTo("")).execute();
|
|
29837
29869
|
await db.schema.alterTable("secrets").addColumn("value_file", "text", (column) => column.notNull().defaultTo("")).execute();
|
|
29838
29870
|
await db.schema.alterTable("grants").addColumn("secret_generation", "text", (column) => column.notNull().defaultTo("")).execute();
|
|
29839
|
-
await db.updateTable("secrets").set({ generation:
|
|
29871
|
+
await db.updateTable("secrets").set({ generation: sql6`lower(hex(randomblob(16)))`, value_file: sql6.ref("name") }).execute();
|
|
29840
29872
|
await db.updateTable("grants").set({
|
|
29841
29873
|
secret_generation: (eb) => eb.selectFrom("secrets").select("secrets.generation").whereRef("secrets.name", "=", "grants.secret_name")
|
|
29842
29874
|
}).execute();
|
|
@@ -29899,12 +29931,12 @@ var MIGRATION_027_ADD_IMP_BACKUP = {
|
|
|
29899
29931
|
};
|
|
29900
29932
|
|
|
29901
29933
|
// packages/daemon/src/platform/db/migrations/migration-028-cascade-oauth-tokens.ts
|
|
29902
|
-
import { sql as
|
|
29934
|
+
import { sql as sql7 } from "kysely";
|
|
29903
29935
|
var MIGRATION_028_CASCADE_OAUTH_TOKENS = {
|
|
29904
29936
|
async up(db) {
|
|
29905
29937
|
await db.transaction().execute(async (trx) => {
|
|
29906
29938
|
await trx.schema.createTable("oauth_tokens_cascade").addColumn("id", "text", (column) => column.primaryKey()).addColumn("grant_id", "text", (column) => column.notNull().references("oauth_grants.id").onDelete("cascade")).addColumn("kind", "text", (column) => column.notNull()).addColumn("secret_hash", "text", (column) => column.notNull()).addColumn("created_at", "integer", (column) => column.notNull()).addColumn("expires_at", "integer", (column) => column.notNull()).addColumn("spent_at", "integer").execute();
|
|
29907
|
-
await
|
|
29939
|
+
await sql7`
|
|
29908
29940
|
INSERT INTO oauth_tokens_cascade
|
|
29909
29941
|
(id, grant_id, kind, secret_hash, created_at, expires_at, spent_at)
|
|
29910
29942
|
SELECT id, grant_id, kind, secret_hash, created_at, expires_at, spent_at
|
|
@@ -29926,12 +29958,12 @@ var MIGRATION_029_ADD_TOKEN_IMAGE_REF_PREFIX = {
|
|
|
29926
29958
|
};
|
|
29927
29959
|
|
|
29928
29960
|
// packages/daemon/src/platform/db/migrations/migration-030-add-broker-audit-refusals.ts
|
|
29929
|
-
import { sql as
|
|
29961
|
+
import { sql as sql8 } from "kysely";
|
|
29930
29962
|
var MIGRATION_030_ADD_BROKER_AUDIT_REFUSALS = {
|
|
29931
29963
|
async up(db) {
|
|
29932
29964
|
await db.transaction().execute(async (trx) => {
|
|
29933
29965
|
await trx.schema.createTable("broker_audit_refusals").addColumn("id", "integer", (column) => column.primaryKey().autoIncrement()).addColumn("imp_id", "text", (column) => column.notNull().references("imps.id").onDelete("cascade")).addColumn("secret_name", "text").addColumn("at", "integer", (column) => column.notNull()).addColumn("method", "text").addColumn("host", "text").addColumn("path", "text").addColumn("status", "integer", (column) => column.notNull()).addColumn("request_bytes", "integer", (column) => column.notNull()).addColumn("response_bytes", "integer", (column) => column.notNull()).addColumn("duration_ms", "integer", (column) => column.notNull()).addColumn("reason", "text").execute();
|
|
29934
|
-
await
|
|
29966
|
+
await sql8`
|
|
29935
29967
|
INSERT INTO broker_audit_refusals
|
|
29936
29968
|
(id, imp_id, secret_name, at, method, host, path, status, request_bytes,
|
|
29937
29969
|
response_bytes, duration_ms)
|
|
@@ -29961,12 +29993,12 @@ var MIGRATION_032_ADD_IMP_OOPS_BOOT_ID = {
|
|
|
29961
29993
|
};
|
|
29962
29994
|
|
|
29963
29995
|
// packages/daemon/src/platform/db/migrations/migration-033-add-imp-oops-hold.ts
|
|
29964
|
-
import { sql as
|
|
29996
|
+
import { sql as sql9 } from "kysely";
|
|
29965
29997
|
var MIGRATION_033_ADD_IMP_OOPS_HOLD = {
|
|
29966
29998
|
async up(db) {
|
|
29967
29999
|
await db.transaction().execute(async (trx) => {
|
|
29968
30000
|
await trx.schema.alterTable("imps").addColumn("oops_hold", "integer", (column) => column.notNull().defaultTo(0)).execute();
|
|
29969
|
-
await
|
|
30001
|
+
await sql9`
|
|
29970
30002
|
UPDATE imps SET oops_hold = 1 WHERE error = 'a kernel oops killed firecracker'
|
|
29971
30003
|
`.execute(trx);
|
|
29972
30004
|
});
|
|
@@ -29974,11 +30006,11 @@ var MIGRATION_033_ADD_IMP_OOPS_HOLD = {
|
|
|
29974
30006
|
};
|
|
29975
30007
|
|
|
29976
30008
|
// packages/daemon/src/platform/db/migrations/migration-034-add-better-auth.ts
|
|
29977
|
-
import { sql as
|
|
30009
|
+
import { sql as sql10 } from "kysely";
|
|
29978
30010
|
var MIGRATION_034_ADD_BETTER_AUTH = {
|
|
29979
30011
|
async up(db) {
|
|
29980
30012
|
await db.transaction().execute(async (trx) => {
|
|
29981
|
-
await
|
|
30013
|
+
await sql10`
|
|
29982
30014
|
CREATE TABLE "user" (
|
|
29983
30015
|
"id" text NOT NULL PRIMARY KEY,
|
|
29984
30016
|
"name" text NOT NULL,
|
|
@@ -29992,7 +30024,7 @@ var MIGRATION_034_ADD_BETTER_AUTH = {
|
|
|
29992
30024
|
"lastUsedAt" date
|
|
29993
30025
|
)
|
|
29994
30026
|
`.execute(trx);
|
|
29995
|
-
await
|
|
30027
|
+
await sql10`
|
|
29996
30028
|
CREATE TABLE "session" (
|
|
29997
30029
|
"id" text NOT NULL PRIMARY KEY,
|
|
29998
30030
|
"expiresAt" date NOT NULL,
|
|
@@ -30004,7 +30036,7 @@ var MIGRATION_034_ADD_BETTER_AUTH = {
|
|
|
30004
30036
|
"userId" text NOT NULL REFERENCES "user" ("id") ON DELETE CASCADE
|
|
30005
30037
|
)
|
|
30006
30038
|
`.execute(trx);
|
|
30007
|
-
await
|
|
30039
|
+
await sql10`
|
|
30008
30040
|
CREATE TABLE "account" (
|
|
30009
30041
|
"id" text NOT NULL PRIMARY KEY,
|
|
30010
30042
|
"accountId" text NOT NULL,
|
|
@@ -30021,7 +30053,7 @@ var MIGRATION_034_ADD_BETTER_AUTH = {
|
|
|
30021
30053
|
"updatedAt" date NOT NULL
|
|
30022
30054
|
)
|
|
30023
30055
|
`.execute(trx);
|
|
30024
|
-
await
|
|
30056
|
+
await sql10`
|
|
30025
30057
|
CREATE TABLE "verification" (
|
|
30026
30058
|
"id" text NOT NULL PRIMARY KEY,
|
|
30027
30059
|
"identifier" text NOT NULL,
|
|
@@ -30031,7 +30063,7 @@ var MIGRATION_034_ADD_BETTER_AUTH = {
|
|
|
30031
30063
|
"updatedAt" date NOT NULL
|
|
30032
30064
|
)
|
|
30033
30065
|
`.execute(trx);
|
|
30034
|
-
await
|
|
30066
|
+
await sql10`
|
|
30035
30067
|
CREATE TABLE "oauthClient" (
|
|
30036
30068
|
"id" text NOT NULL PRIMARY KEY,
|
|
30037
30069
|
"clientId" text NOT NULL UNIQUE,
|
|
@@ -30071,7 +30103,7 @@ var MIGRATION_034_ADD_BETTER_AUTH = {
|
|
|
30071
30103
|
"metadata" text
|
|
30072
30104
|
)
|
|
30073
30105
|
`.execute(trx);
|
|
30074
|
-
await
|
|
30106
|
+
await sql10`
|
|
30075
30107
|
CREATE TABLE "oauthResource" (
|
|
30076
30108
|
"id" text NOT NULL PRIMARY KEY,
|
|
30077
30109
|
"identifier" text NOT NULL UNIQUE,
|
|
@@ -30090,7 +30122,7 @@ var MIGRATION_034_ADD_BETTER_AUTH = {
|
|
|
30090
30122
|
"metadata" text
|
|
30091
30123
|
)
|
|
30092
30124
|
`.execute(trx);
|
|
30093
|
-
await
|
|
30125
|
+
await sql10`
|
|
30094
30126
|
CREATE TABLE "oauthClientResource" (
|
|
30095
30127
|
"id" text NOT NULL PRIMARY KEY,
|
|
30096
30128
|
"clientId" text NOT NULL REFERENCES "oauthClient" ("clientId") ON DELETE CASCADE,
|
|
@@ -30099,7 +30131,7 @@ var MIGRATION_034_ADD_BETTER_AUTH = {
|
|
|
30099
30131
|
"createdAt" date
|
|
30100
30132
|
)
|
|
30101
30133
|
`.execute(trx);
|
|
30102
|
-
await
|
|
30134
|
+
await sql10`
|
|
30103
30135
|
CREATE TABLE "oauthRefreshToken" (
|
|
30104
30136
|
"id" text NOT NULL PRIMARY KEY,
|
|
30105
30137
|
"token" text NOT NULL UNIQUE,
|
|
@@ -30121,7 +30153,7 @@ var MIGRATION_034_ADD_BETTER_AUTH = {
|
|
|
30121
30153
|
"scopes" text NOT NULL
|
|
30122
30154
|
)
|
|
30123
30155
|
`.execute(trx);
|
|
30124
|
-
await
|
|
30156
|
+
await sql10`
|
|
30125
30157
|
CREATE TABLE "oauthAccessToken" (
|
|
30126
30158
|
"id" text NOT NULL PRIMARY KEY,
|
|
30127
30159
|
"token" text NOT NULL UNIQUE,
|
|
@@ -30140,7 +30172,7 @@ var MIGRATION_034_ADD_BETTER_AUTH = {
|
|
|
30140
30172
|
"scopes" text NOT NULL
|
|
30141
30173
|
)
|
|
30142
30174
|
`.execute(trx);
|
|
30143
|
-
await
|
|
30175
|
+
await sql10`
|
|
30144
30176
|
CREATE TABLE "oauthConsent" (
|
|
30145
30177
|
"id" text NOT NULL PRIMARY KEY,
|
|
30146
30178
|
"clientId" text NOT NULL REFERENCES "oauthClient" ("clientId") ON DELETE CASCADE,
|
|
@@ -30153,43 +30185,43 @@ var MIGRATION_034_ADD_BETTER_AUTH = {
|
|
|
30153
30185
|
"updatedAt" date NOT NULL
|
|
30154
30186
|
)
|
|
30155
30187
|
`.execute(trx);
|
|
30156
|
-
await
|
|
30188
|
+
await sql10`
|
|
30157
30189
|
CREATE TABLE "oauthClientAssertion" (
|
|
30158
30190
|
"id" text NOT NULL PRIMARY KEY,
|
|
30159
30191
|
"expiresAt" date NOT NULL
|
|
30160
30192
|
)
|
|
30161
30193
|
`.execute(trx);
|
|
30162
|
-
await
|
|
30163
|
-
await
|
|
30164
|
-
await
|
|
30194
|
+
await sql10`CREATE INDEX "session_userId_idx" ON "session" ("userId")`.execute(trx);
|
|
30195
|
+
await sql10`CREATE INDEX "account_userId_idx" ON "account" ("userId")`.execute(trx);
|
|
30196
|
+
await sql10`
|
|
30165
30197
|
CREATE INDEX "verification_identifier_idx" ON "verification" ("identifier")
|
|
30166
30198
|
`.execute(trx);
|
|
30167
|
-
await
|
|
30168
|
-
await
|
|
30199
|
+
await sql10`CREATE INDEX "oauthClient_userId_idx" ON "oauthClient" ("userId")`.execute(trx);
|
|
30200
|
+
await sql10`
|
|
30169
30201
|
CREATE UNIQUE INDEX "oauthClient_name_uidx" ON "oauthClient" ("name")
|
|
30170
30202
|
`.execute(trx);
|
|
30171
|
-
await
|
|
30203
|
+
await sql10`
|
|
30172
30204
|
CREATE INDEX "oauthClientResource_clientId_idx" ON "oauthClientResource" ("clientId")
|
|
30173
30205
|
`.execute(trx);
|
|
30174
|
-
await
|
|
30206
|
+
await sql10`
|
|
30175
30207
|
CREATE INDEX "oauthClientResource_resourceId_idx" ON "oauthClientResource" ("resourceId")
|
|
30176
30208
|
`.execute(trx);
|
|
30177
|
-
await
|
|
30209
|
+
await sql10`
|
|
30178
30210
|
CREATE UNIQUE INDEX "oauthClientResource_clientId_resourceId_uidx"
|
|
30179
30211
|
ON "oauthClientResource" ("clientId", "resourceId")
|
|
30180
30212
|
`.execute(trx);
|
|
30181
30213
|
for (const table of ["oauthRefreshToken", "oauthAccessToken"]) {
|
|
30182
30214
|
for (const column of ["clientId", "sessionId", "userId", "authorizationCodeId"]) {
|
|
30183
|
-
await
|
|
30184
|
-
CREATE INDEX ${
|
|
30215
|
+
await sql10`
|
|
30216
|
+
CREATE INDEX ${sql10.id(`${table}_${column}_idx`)} ON ${sql10.table(table)} (${sql10.ref(column)})
|
|
30185
30217
|
`.execute(trx);
|
|
30186
30218
|
}
|
|
30187
30219
|
}
|
|
30188
|
-
await
|
|
30220
|
+
await sql10`
|
|
30189
30221
|
CREATE INDEX "oauthAccessToken_refreshId_idx" ON "oauthAccessToken" ("refreshId")
|
|
30190
30222
|
`.execute(trx);
|
|
30191
|
-
await
|
|
30192
|
-
await
|
|
30223
|
+
await sql10`CREATE INDEX "oauthConsent_clientId_idx" ON "oauthConsent" ("clientId")`.execute(trx);
|
|
30224
|
+
await sql10`CREATE INDEX "oauthConsent_userId_idx" ON "oauthConsent" ("userId")`.execute(trx);
|
|
30193
30225
|
});
|
|
30194
30226
|
}
|
|
30195
30227
|
};
|
|
@@ -30206,12 +30238,12 @@ var MIGRATION_035_DROP_OLD_OAUTH = {
|
|
|
30206
30238
|
};
|
|
30207
30239
|
|
|
30208
30240
|
// packages/daemon/src/platform/db/migrations/migration-036-keep-broker-audit-of-destroyed-imps.ts
|
|
30209
|
-
import { sql as
|
|
30241
|
+
import { sql as sql11 } from "kysely";
|
|
30210
30242
|
var MIGRATION_036_KEEP_BROKER_AUDIT_OF_DESTROYED_IMPS = {
|
|
30211
30243
|
async up(db) {
|
|
30212
30244
|
await db.transaction().execute(async (trx) => {
|
|
30213
30245
|
await trx.schema.createTable("broker_audit_kept").addColumn("id", "integer", (column) => column.primaryKey().autoIncrement()).addColumn("imp_id", "text", (column) => column.notNull()).addColumn("imp_name", "text", (column) => column.notNull()).addColumn("secret_name", "text").addColumn("at", "integer", (column) => column.notNull()).addColumn("method", "text").addColumn("host", "text").addColumn("path", "text").addColumn("status", "integer", (column) => column.notNull()).addColumn("request_bytes", "integer", (column) => column.notNull()).addColumn("response_bytes", "integer", (column) => column.notNull()).addColumn("duration_ms", "integer", (column) => column.notNull()).addColumn("reason", "text").execute();
|
|
30214
|
-
await
|
|
30246
|
+
await sql11`
|
|
30215
30247
|
INSERT INTO broker_audit_kept
|
|
30216
30248
|
(id, imp_id, imp_name, secret_name, at, method, host, path, status, request_bytes,
|
|
30217
30249
|
response_bytes, duration_ms, reason)
|
|
@@ -30229,12 +30261,12 @@ var MIGRATION_036_KEEP_BROKER_AUDIT_OF_DESTROYED_IMPS = {
|
|
|
30229
30261
|
};
|
|
30230
30262
|
|
|
30231
30263
|
// packages/daemon/src/platform/db/migrations/migration-037-add-image-last-used.ts
|
|
30232
|
-
import { sql as
|
|
30264
|
+
import { sql as sql12 } from "kysely";
|
|
30233
30265
|
var MIGRATION_037_ADD_IMAGE_LAST_USED = {
|
|
30234
30266
|
async up(db) {
|
|
30235
30267
|
await db.transaction().execute(async (trx) => {
|
|
30236
30268
|
await trx.schema.alterTable("images").addColumn("last_used_at", "integer", (column) => column.notNull().defaultTo(0)).execute();
|
|
30237
|
-
await
|
|
30269
|
+
await sql12`
|
|
30238
30270
|
UPDATE images SET last_used_at = MAX(
|
|
30239
30271
|
created_at,
|
|
30240
30272
|
COALESCE((SELECT MAX(imps.created_at) FROM imps WHERE imps.image_id = images.id), 0)
|
|
@@ -30266,12 +30298,12 @@ var MIGRATION_040_ADD_IMAGE_RECEIVED_DIGESTS = {
|
|
|
30266
30298
|
};
|
|
30267
30299
|
|
|
30268
30300
|
// packages/daemon/src/platform/db/migrations/migration-041-add-move-send-steps.ts
|
|
30269
|
-
import { sql as
|
|
30301
|
+
import { sql as sql13 } from "kysely";
|
|
30270
30302
|
var MIGRATION_041_ADD_MOVE_SEND_STEPS = {
|
|
30271
30303
|
async up(db) {
|
|
30272
30304
|
await db.schema.alterTable("move_sends").addColumn("step", "text", (column) => column.notNull().defaultTo("prepared")).execute();
|
|
30273
30305
|
await db.schema.alterTable("move_sends").addColumn("halted", "integer", (column) => column.notNull().defaultTo(0)).execute();
|
|
30274
|
-
await
|
|
30306
|
+
await sql13`
|
|
30275
30307
|
UPDATE move_sends SET step = CASE
|
|
30276
30308
|
WHEN (SELECT move_state FROM imps WHERE imps.id = move_sends.imp_id) = 'moved' THEN 'sent'
|
|
30277
30309
|
WHEN peer_url IS NOT NULL THEN 'streaming'
|
|
@@ -30304,11 +30336,11 @@ var MIGRATION_043_MERGE_SECRET_KINDS = {
|
|
|
30304
30336
|
};
|
|
30305
30337
|
|
|
30306
30338
|
// packages/daemon/src/platform/db/migrations/migration-044-add-imp-image-digests.ts
|
|
30307
|
-
import { sql as
|
|
30339
|
+
import { sql as sql14 } from "kysely";
|
|
30308
30340
|
var MIGRATION_044_ADD_IMP_IMAGE_DIGESTS = {
|
|
30309
30341
|
async up(db) {
|
|
30310
30342
|
await db.schema.alterTable("imps").addColumn("image_digest", "text", (column) => column.notNull().defaultTo("")).execute();
|
|
30311
|
-
await
|
|
30343
|
+
await sql14`UPDATE imps SET image_digest = (
|
|
30312
30344
|
SELECT images.digest FROM images WHERE images.id = imps.image_id
|
|
30313
30345
|
)`.execute(db);
|
|
30314
30346
|
}
|
|
@@ -30386,13 +30418,13 @@ async function runMigrations(db) {
|
|
|
30386
30418
|
requireMigrated(durableResult);
|
|
30387
30419
|
}
|
|
30388
30420
|
async function requireKnownMigrations(db, table, migrations) {
|
|
30389
|
-
const found = await
|
|
30421
|
+
const found = await sql15`
|
|
30390
30422
|
SELECT name FROM sqlite_master WHERE type = 'table' AND name = ${table}
|
|
30391
30423
|
`.execute(db);
|
|
30392
30424
|
if (found.rows.length === 0) {
|
|
30393
30425
|
return;
|
|
30394
30426
|
}
|
|
30395
|
-
const executed = await
|
|
30427
|
+
const executed = await sql15`SELECT name FROM ${sql15.table(table)}`.execute(db);
|
|
30396
30428
|
const unknown = executed.rows.map((row) => row.name).filter((name) => !Object.hasOwn(migrations, name));
|
|
30397
30429
|
if (unknown.length === 0) {
|
|
30398
30430
|
return;
|
|
@@ -30415,6 +30447,7 @@ function requireMigrated(result) {
|
|
|
30415
30447
|
}
|
|
30416
30448
|
|
|
30417
30449
|
// packages/daemon/src/platform/db/open-database.ts
|
|
30450
|
+
var LOGGED_TABLES = ["imps", "checkpoints"];
|
|
30418
30451
|
async function openDatabase(source, now = Date.now) {
|
|
30419
30452
|
const sqlite = typeof source === "string" ? new Database3(source, { create: true }) : source;
|
|
30420
30453
|
sqlite.run("PRAGMA journal_mode = WAL;");
|
|
@@ -30432,7 +30465,9 @@ async function openDatabase(source, now = Date.now) {
|
|
|
30432
30465
|
});
|
|
30433
30466
|
try {
|
|
30434
30467
|
await runMigrations(db);
|
|
30435
|
-
await
|
|
30468
|
+
await createOutsideWriteTriggers(db, LOGGED_TABLES);
|
|
30469
|
+
await removeLogIDAfterOutsideWrites(db);
|
|
30470
|
+
await writeNewLogID(db);
|
|
30436
30471
|
await log.start();
|
|
30437
30472
|
} catch (error) {
|
|
30438
30473
|
sqlite.close();
|
|
@@ -31089,7 +31124,7 @@ function buildCursorEvent(ev, position) {
|
|
|
31089
31124
|
v: EVENT_VERSION,
|
|
31090
31125
|
at: new Date(position.at),
|
|
31091
31126
|
seq: position.seq,
|
|
31092
|
-
logId: position.
|
|
31127
|
+
logId: position.logID,
|
|
31093
31128
|
ev
|
|
31094
31129
|
};
|
|
31095
31130
|
}
|
|
@@ -31099,7 +31134,7 @@ function pickStreamStart(cursor, log) {
|
|
|
31099
31134
|
if (cursor.after === undefined) {
|
|
31100
31135
|
return { kind: "snapshot" };
|
|
31101
31136
|
}
|
|
31102
|
-
const isOtherLog = cursor.logId !== undefined && cursor.logId !== log.
|
|
31137
|
+
const isOtherLog = cursor.logId !== undefined && cursor.logId !== log.logID;
|
|
31103
31138
|
return isOtherLog || cursor.after > log.head ? { kind: "reset" } : { kind: "resume", after: cursor.after };
|
|
31104
31139
|
}
|
|
31105
31140
|
|
|
@@ -31116,20 +31151,20 @@ async function* openEventStream(options) {
|
|
|
31116
31151
|
...options.startTimer !== undefined && { startTimer: options.startTimer }
|
|
31117
31152
|
});
|
|
31118
31153
|
try {
|
|
31119
|
-
const
|
|
31154
|
+
const logID = await options.readLogID();
|
|
31120
31155
|
const head = await options.readHead();
|
|
31121
|
-
const start = pickStreamStart(options.cursor, { head,
|
|
31156
|
+
const start = pickStreamStart(options.cursor, { head, logID });
|
|
31122
31157
|
const opening = match8(start).with({ kind: "snapshot" }, () => ({ isReset: false, hasSnapshot: true, after: head })).with({ kind: "reset" }, () => ({ isReset: true, hasSnapshot: true, after: head })).with({ kind: "resume" }, (resume) => ({
|
|
31123
31158
|
isReset: false,
|
|
31124
31159
|
hasSnapshot: false,
|
|
31125
31160
|
after: resume.after
|
|
31126
31161
|
})).exhaustive();
|
|
31127
31162
|
if (opening.isReset) {
|
|
31128
|
-
yield buildCursorEvent("Reset", { seq: head,
|
|
31163
|
+
yield buildCursorEvent("Reset", { seq: head, logID, at: options.now() });
|
|
31129
31164
|
}
|
|
31130
31165
|
const knowsCursorEvents = options.cursor.after !== undefined;
|
|
31131
31166
|
if (opening.hasSnapshot) {
|
|
31132
|
-
yield* readSnapshotAt(options, { head,
|
|
31167
|
+
yield* readSnapshotAt(options, { head, logID, knowsCursorEvents });
|
|
31133
31168
|
}
|
|
31134
31169
|
let after = opening.after;
|
|
31135
31170
|
while (!stop.signal.aborted) {
|
|
@@ -31140,7 +31175,7 @@ async function* openEventStream(options) {
|
|
|
31140
31175
|
signal: stop.signal
|
|
31141
31176
|
});
|
|
31142
31177
|
const reset = yield* presentPages(pages, options, {
|
|
31143
|
-
|
|
31178
|
+
logID,
|
|
31144
31179
|
knowsCursorEvents,
|
|
31145
31180
|
signal: stop.signal
|
|
31146
31181
|
});
|
|
@@ -31148,8 +31183,8 @@ async function* openEventStream(options) {
|
|
|
31148
31183
|
return;
|
|
31149
31184
|
}
|
|
31150
31185
|
after = await options.readHead();
|
|
31151
|
-
yield buildCursorEvent("Reset", { seq: after,
|
|
31152
|
-
yield* readSnapshotAt(options, { head: after,
|
|
31186
|
+
yield buildCursorEvent("Reset", { seq: after, logID, at: options.now() });
|
|
31187
|
+
yield* readSnapshotAt(options, { head: after, logID, knowsCursorEvents });
|
|
31153
31188
|
}
|
|
31154
31189
|
} finally {
|
|
31155
31190
|
options.signal?.removeEventListener("abort", stopStream);
|
|
@@ -31158,20 +31193,20 @@ async function* openEventStream(options) {
|
|
|
31158
31193
|
}
|
|
31159
31194
|
}
|
|
31160
31195
|
async function* readSnapshotAt(reads, place) {
|
|
31161
|
-
yield* await reads.readSnapshot(place.head, place.
|
|
31196
|
+
yield* await reads.readSnapshot(place.head, place.logID);
|
|
31162
31197
|
if (place.knowsCursorEvents) {
|
|
31163
|
-
yield buildCursorEvent("Position", { seq: place.head,
|
|
31198
|
+
yield buildCursorEvent("Position", { seq: place.head, logID: place.logID, at: reads.now() });
|
|
31164
31199
|
}
|
|
31165
31200
|
}
|
|
31166
31201
|
async function* presentPages(pages, reads, place) {
|
|
31167
|
-
const
|
|
31202
|
+
const logID = place.logID;
|
|
31168
31203
|
const signal = place.signal;
|
|
31169
31204
|
try {
|
|
31170
31205
|
let step = await pages.next();
|
|
31171
31206
|
while (step.done !== true) {
|
|
31172
31207
|
let sentSeq = null;
|
|
31173
31208
|
for (const logged of step.value) {
|
|
31174
|
-
const event = await reads.present(logged,
|
|
31209
|
+
const event = await reads.present(logged, logID);
|
|
31175
31210
|
if (signal.aborted) {
|
|
31176
31211
|
return null;
|
|
31177
31212
|
}
|
|
@@ -31182,7 +31217,7 @@ async function* presentPages(pages, reads, place) {
|
|
|
31182
31217
|
}
|
|
31183
31218
|
const readSeq = step.value.at(-1)?.seq ?? null;
|
|
31184
31219
|
if (place.knowsCursorEvents && readSeq !== null && readSeq !== sentSeq) {
|
|
31185
|
-
yield buildCursorEvent("Position", { seq: readSeq,
|
|
31220
|
+
yield buildCursorEvent("Position", { seq: readSeq, logID, at: reads.now() });
|
|
31186
31221
|
}
|
|
31187
31222
|
step = await pages.next();
|
|
31188
31223
|
}
|
|
@@ -31195,17 +31230,17 @@ async function* presentPages(pages, reads, place) {
|
|
|
31195
31230
|
// packages/daemon/src/platform/events/read-event-page.ts
|
|
31196
31231
|
import { match as match9 } from "ts-pattern";
|
|
31197
31232
|
async function readEventPage(reads, cursor, limit) {
|
|
31198
|
-
const
|
|
31233
|
+
const logID = await reads.readLogID();
|
|
31199
31234
|
const head = await reads.readHead();
|
|
31200
|
-
return match9(pickStreamStart(cursor, { head,
|
|
31235
|
+
return match9(pickStreamStart(cursor, { head, logID })).with({ kind: "snapshot" }, () => readSnapshotPage(reads, { head, logID, isReset: false })).with({ kind: "reset" }, () => readSnapshotPage(reads, { head, logID, isReset: true })).with({ kind: "resume" }, (resume) => readResumedPage(reads, { head, logID, isReset: false }, resume.after, limit)).exhaustive();
|
|
31201
31236
|
}
|
|
31202
31237
|
async function readSnapshotPage(reads, position) {
|
|
31203
|
-
const snapshot = await reads.readSnapshot(position.head, position.
|
|
31204
|
-
const reset = position.isReset ? [buildCursorEvent("Reset", { seq: position.head,
|
|
31238
|
+
const snapshot = await reads.readSnapshot(position.head, position.logID);
|
|
31239
|
+
const reset = position.isReset ? [buildCursorEvent("Reset", { seq: position.head, logID: position.logID, at: reads.now() })] : [];
|
|
31205
31240
|
return {
|
|
31206
31241
|
events: [...reset, ...snapshot],
|
|
31207
31242
|
after: position.head,
|
|
31208
|
-
logId: position.
|
|
31243
|
+
logId: position.logID,
|
|
31209
31244
|
hasMore: false
|
|
31210
31245
|
};
|
|
31211
31246
|
}
|
|
@@ -31216,12 +31251,12 @@ async function readResumedPage(reads, position, after, limit) {
|
|
|
31216
31251
|
}
|
|
31217
31252
|
const events = [];
|
|
31218
31253
|
for (const logged of read.events) {
|
|
31219
|
-
const event = await reads.present(logged, position.
|
|
31254
|
+
const event = await reads.present(logged, position.logID);
|
|
31220
31255
|
if (event !== null && (reads.accepts?.(event) ?? true)) {
|
|
31221
31256
|
events.push(event);
|
|
31222
31257
|
}
|
|
31223
31258
|
}
|
|
31224
|
-
return { events, after: read.throughSeq, logId: position.
|
|
31259
|
+
return { events, after: read.throughSeq, logId: position.logID, hasMore: read.hasMore };
|
|
31225
31260
|
}
|
|
31226
31261
|
|
|
31227
31262
|
// packages/daemon/src/platform/process/merge-signals.ts
|
|
@@ -31265,16 +31300,24 @@ function createEventRoutes(os, deps, views) {
|
|
|
31265
31300
|
const isEventValid = createEventCheck({ now: deps.now });
|
|
31266
31301
|
const buildCallerReads = (caller) => ({
|
|
31267
31302
|
readHead: deps.imps.events.readHead,
|
|
31268
|
-
|
|
31303
|
+
readLogID: deps.imps.events.readLogID,
|
|
31269
31304
|
readAfter: deps.imps.events.readAfter,
|
|
31270
|
-
readSnapshot: async (head,
|
|
31305
|
+
readSnapshot: async (head, logID) => {
|
|
31271
31306
|
const imps = await views.listCallerImps(caller);
|
|
31272
31307
|
const at = new Date(deps.now());
|
|
31273
|
-
return imps.map((imp) => ({
|
|
31274
|
-
|
|
31275
|
-
|
|
31308
|
+
return imps.map((imp) => ({
|
|
31309
|
+
v: EVENT_VERSION,
|
|
31310
|
+
at,
|
|
31311
|
+
seq: head,
|
|
31312
|
+
logId: logID,
|
|
31313
|
+
ev: "ImpAdded",
|
|
31314
|
+
reason: "snapshot",
|
|
31315
|
+
imp
|
|
31316
|
+
})).filter((event) => isEventValid(event));
|
|
31317
|
+
},
|
|
31318
|
+
present: async (event, logID) => {
|
|
31276
31319
|
try {
|
|
31277
|
-
return await readApiEvent(event, deps.imps.toApi,
|
|
31320
|
+
return await readApiEvent(event, deps.imps.toApi, logID);
|
|
31278
31321
|
} catch (error) {
|
|
31279
31322
|
getImpdLogger("events").warning("left out event {seq}: {error}", {
|
|
31280
31323
|
seq: event.seq,
|
|
@@ -39350,6 +39393,9 @@ function createPrioritySemaphore(limit) {
|
|
|
39350
39393
|
};
|
|
39351
39394
|
}
|
|
39352
39395
|
|
|
39396
|
+
// packages/daemon/src/platform/process/vm-deadlines.ts
|
|
39397
|
+
var VM_DEADLINES = { agentMs: 15000, killMs: 3000 };
|
|
39398
|
+
|
|
39353
39399
|
// packages/daemon/src/imp-ops/governor/build-budgets.ts
|
|
39354
39400
|
function buildBudgets(budgetMib, pool) {
|
|
39355
39401
|
return {
|
|
@@ -39547,7 +39593,7 @@ function createPriorityAdmissions(priority) {
|
|
|
39547
39593
|
}
|
|
39548
39594
|
|
|
39549
39595
|
// packages/daemon/src/imp-ops/governor/ram-governor.ts
|
|
39550
|
-
var RESERVATION_TTL_MS =
|
|
39596
|
+
var RESERVATION_TTL_MS = VM_DEADLINES.agentMs + 1e4;
|
|
39551
39597
|
var ENFORCE_INTERVAL_MS = 5000;
|
|
39552
39598
|
var ENFORCE_TRIGGER = "RAM over budget";
|
|
39553
39599
|
var ORDINARY_TRIGGER = "RAM outside the huge page pool";
|
|
@@ -44606,9 +44652,6 @@ import { resolve as resolve3 } from "path";
|
|
|
44606
44652
|
// packages/daemon/src/vm/vmm/template-vm.ts
|
|
44607
44653
|
import { mkdirSync as mkdirSync15, rmSync as rmSync21 } from "fs";
|
|
44608
44654
|
|
|
44609
|
-
// packages/daemon/src/platform/process/vm-deadlines.ts
|
|
44610
|
-
var VM_DEADLINES = { agentMs: 15000, killMs: 3000 };
|
|
44611
|
-
|
|
44612
44655
|
// packages/daemon/src/vm/agent-client/wait-for-agent.ts
|
|
44613
44656
|
async function waitForAgent(vsockPath, options) {
|
|
44614
44657
|
const clock = options.clock ?? REAL_CLOCK;
|
|
@@ -47036,7 +47079,7 @@ async function copyBase(base, memFile) {
|
|
|
47036
47079
|
// packages/daemon/src/vm/vmm/vm-runner.ts
|
|
47037
47080
|
var SHUTDOWN_TIMEOUT_MS = 1e4;
|
|
47038
47081
|
var UFFD_WATCH_INTERVAL_MS = 100;
|
|
47039
|
-
var WAKE_AGENT_DEADLINE_MS =
|
|
47082
|
+
var WAKE_AGENT_DEADLINE_MS = VM_DEADLINES.agentMs;
|
|
47040
47083
|
var GUEST_MEMORY_TIMEOUTS = { requestMs: 1000, snapshotMs: 1000 };
|
|
47041
47084
|
var UPTIME_PING_TIMEOUT_MS = 250;
|
|
47042
47085
|
function createVmRunner(jails, options) {
|
|
@@ -47046,6 +47089,7 @@ function createVmRunner(jails, options) {
|
|
|
47046
47089
|
const createClient = options.createClient ?? createFirecrackerClient;
|
|
47047
47090
|
const readFile = options.readFile;
|
|
47048
47091
|
const uffdHandlerBin = options.uffdHandlerBin ?? null;
|
|
47092
|
+
const clock = options.clock ?? REAL_CLOCK;
|
|
47049
47093
|
const uffdWatch = createUffdWatch({
|
|
47050
47094
|
probeVmAlive: (pid, paths) => probeProcessAlive(pid, paths.apiSocket, procRoot),
|
|
47051
47095
|
readHandlerState: (paths) => readHandlerState(paths, procRoot),
|
|
@@ -47263,7 +47307,8 @@ ${readLogTail(plan.paths.logFile)}`, {
|
|
|
47263
47307
|
setMark("load");
|
|
47264
47308
|
const ping = await waitForAgent(plan.paths.vsockSocket, {
|
|
47265
47309
|
deadlineMs: WAKE_AGENT_DEADLINE_MS,
|
|
47266
|
-
attemptMs: 200
|
|
47310
|
+
attemptMs: 200,
|
|
47311
|
+
clock
|
|
47267
47312
|
});
|
|
47268
47313
|
setMark("agent");
|
|
47269
47314
|
await sendResumed(plan.paths.vsockSocket, Date.now());
|
|
@@ -47345,7 +47390,8 @@ ${readLogTail(plan.paths.logFile, 5)}`, {
|
|
|
47345
47390
|
finishWake: async (paths) => {
|
|
47346
47391
|
const ping = await waitForAgent(paths.vsockSocket, {
|
|
47347
47392
|
deadlineMs: WAKE_AGENT_DEADLINE_MS,
|
|
47348
|
-
attemptMs: 200
|
|
47393
|
+
attemptMs: 200,
|
|
47394
|
+
clock
|
|
47349
47395
|
});
|
|
47350
47396
|
await sendResumed(paths.vsockSocket, Date.now());
|
|
47351
47397
|
const firecrackerVersion = await createClient(paths.apiSocket).readVersion();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@impz/testing",
|
|
3
|
-
"version": "6.11.
|
|
3
|
+
"version": "6.11.4",
|
|
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": {
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@balena/dockerignore": "^1.0.2",
|
|
20
|
-
"@better-auth/mcp": "^1.7.
|
|
21
|
-
"@better-auth/oauth-provider": "^1.7.
|
|
20
|
+
"@better-auth/mcp": "^1.7.15",
|
|
21
|
+
"@better-auth/oauth-provider": "^1.7.15",
|
|
22
22
|
"@bufbuild/protobuf": "^2.16.0",
|
|
23
23
|
"@logtape/logtape": "^2.4.2",
|
|
24
24
|
"@modelcontextprotocol/server": "^2.4.0",
|
|
@@ -30,11 +30,11 @@
|
|
|
30
30
|
"@orpc/server": "^1.16.1",
|
|
31
31
|
"@peculiar/x509": "^2.2.0",
|
|
32
32
|
"@zgeoff/kysely-bun-sqlite": "^0.3.2",
|
|
33
|
-
"better-auth": "^1.7.
|
|
33
|
+
"better-auth": "^1.7.15",
|
|
34
34
|
"dns-packet": "^5.6.1",
|
|
35
35
|
"elysia": "^1.4.30",
|
|
36
36
|
"ipaddr.js": "^2.5.0",
|
|
37
|
-
"kysely": "^0.29.
|
|
37
|
+
"kysely": "^0.29.8",
|
|
38
38
|
"lru-cache": "^11.5.3",
|
|
39
39
|
"nanoid": "^6.0.2",
|
|
40
40
|
"reflect-metadata": "^0.2.2",
|
|
@@ -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.11.
|
|
46
|
+
"@impz/client": "6.11.4"
|
|
47
47
|
},
|
|
48
48
|
"engines": {
|
|
49
49
|
"bun": ">=1.4.3"
|