{"draft":null,"from":116,"to":318,"files":[{"path":"server/test/disk-first-runtime.test.ts","added":499,"removed":0,"diff":"--- /dev/null\n+++ b/server/test/disk-first-runtime.test.ts\n@@ -0,0 +1,499 @@\n+import assert from \"node:assert/strict\";\n+import { createHash } from \"node:crypto\";\n+import { mkdtempSync, rmdirSync, unlinkSync } from \"node:fs\";\n+import { tmpdir } from \"node:os\";\n+import { join } from \"node:path\";\n+import { test } from \"node:test\";\n+import { answer } from \"../../worker/project/http.ts\";\n+import { MemoryStore, Project } from \"../../worker/project/project.ts\";\n+import { where } from \"../../worker/project/where.ts\";\n+import { DiskFirstRuntime } from \"../src/disk-first-runtime.ts\";\n+import { type EngineProject, SqliteLog } from \"../src/engine-project.ts\";\n+import { SqliteProjectionStore } from \"../src/projection-store.ts\";\n+import { SqliteWriterHost, SqliteWriterState } from \"../src/writer-host.ts\";\n+import { memoryStorage } from \"./helpers.ts\";\n+\n+test(\"runtime defers a large later frame and adopts it on its own page\", (t) => {\n+\tconst storage = memoryStorage();\n+\tt.after(() => storage.db.close());\n+\tconst memory = new MemoryStore();\n+\tconst project = new Project(memory);\n+\tproject.init({ \"a.txt\": \"small\\n\" }, 0);\n+\tproject.record(\"alice\", { \"a.txt\": `${\"x\".repeat(1_100_000)}\\n` }, 1);\n+\tproject.publish(\"alice\", \"Large entry\", 2);\n+\tconst log = new SqliteLog(storage);\n+\tlog.append(memory.entries);\n+\tconst large = memory.entries.findIndex((entry) => Buffer.byteLength(JSON.stringify(entry)) > 1_048_576);\n+\tassert.ok(large > 0);\n+\tconst before = storage.db.prepare(\"SELECT * FROM log ORDER BY seq,part\").all();\n+\tt.mock.method(Project, \"load\", () => {\n+\t\tthrow Error(\"full-history replay forbidden\");\n+\t});\n+\tconst runtime = () => new DiskFirstRuntime(storage, \"large-later\", \"large-later\");\n+\tconst first = runtime().preparePage(() => {});\n+\tassert.equal(first.phase, \"writer\");\n+\tassert.equal(first.next, large);\n+\tlet pages = 0;\n+\twhile (!runtime().preparePage(() => {}).ready) assert.ok(++pages < 100);\n+\tassert.equal(\n+\t\truntime().read(\n+\t\t\t(calls) => calls.statusAt(log.seq()).version,\n+\t\t\t() => {},\n+\t\t),\n+\t\t1,\n+\t);\n+\tassert.equal(\n+\t\truntime().read(\n+\t\t\t(calls) => calls.shared().files[\"a.txt\"]?.length,\n+\t\t\t() => {},\n+\t\t),\n+\t\t1_100_001,\n+\t);\n+\tassert.deepEqual(storage.db.prepare(\"SELECT * FROM log ORDER BY seq,part\").all(), before);\n+});\n+\n+test(\"historical runtime preserves named draft bases and intermediate states after landing\", (t) => {\n+\tconst storage = memoryStorage();\n+\tt.after(() => storage.db.close());\n+\tconst memory = new MemoryStore();\n+\tconst project = new Project(memory);\n+\tproject.init({ \"a.txt\": \"one\\ntwo\\n\", \"b.txt\": \"other\\n\" }, 0);\n+\tproject.switchTo(\"alice\", \"rewrite\", 1);\n+\tproject.record(\"alice\", { \"a.txt\": \"ONE\\ntwo\\n\" }, 2);\n+\tproject.publish(\"alice\", \"First draft version\", 3);\n+\tproject.switchTo(\"bob\", \"rewrite\", 4);\n+\tproject.record(\"bob\", { \"b.txt\": \"OTHER\\n\" }, 5);\n+\tproject.publish(\"bob\", \"Second draft version\", 6);\n+\tassert.equal(project.land(\"bob\", \"Land rewrite\", 7).ok, true);\n+\tconst expected = memory.entries.map((_, i) => {\n+\t\tconst prefix = Project.load(memory.entries.slice(0, i + 1), new MemoryStore());\n+\t\treturn { status: prefix.status(), where: where(prefix) };\n+\t});\n+\tnew SqliteLog(storage).append(memory.entries);\n+\tt.mock.method(Project, \"load\", () => {\n+\t\tthrow Error(\"full-history replay forbidden\");\n+\t});\n+\tconst runtime = () => new DiskFirstRuntime(storage, \"named-history\", \"named-history\");\n+\twhile (!runtime().preparePage(() => {}).ready) {}\n+\tfor (let at = 1; at <= expected.length; at++) {\n+\t\tassert.deepEqual(\n+\t\t\truntime().read(\n+\t\t\t\t(calls) => calls.statusAt(at),\n+\t\t\t\t() => {},\n+\t\t\t),\n+\t\t\t{ at, ...expected[at - 1]!.status },\n+\t\t\t`status at ${at}`,\n+\t\t);\n+\t\tassert.deepEqual(\n+\t\t\truntime().read(\n+\t\t\t\t(calls) => calls.whereAt(at),\n+\t\t\t\t() => {},\n+\t\t\t),\n+\t\t\t{ at, ...expected[at - 1]!.where },\n+\t\t\t`where at ${at}`,\n+\t\t);\n+\t}\n+});\n+\n+test(\"runtime resumes from disk and detaches reads, with exact authorized retries\", (t) => {\n+\tconst directory = mkdtempSync(join(tmpdir(), \"abso-runtime-\"));\n+\tconst filename = join(directory, \"state.sqlite\");\n+\tlet storage = memoryStorage(filename);\n+\tt.after(() => {\n+\t\tstorage.db.close();\n+\t\tunlinkSync(filename);\n+\t\trmdirSync(directory);\n+\t});\n+\tconst runtime = () => new DiskFirstRuntime(storage, \"project-1\", \"disk-v1\");\n+\tconst validate = () => {};\n+\tt.mock.method(Project, \"load\", () => {\n+\t\tthrow Error(\"full-history load forbidden\");\n+\t});\n+\tassert.equal(runtime().preparePage(validate).phase, \"empty\");\n+\tassert.equal(\n+\t\tstorage.db.prepare(\"SELECT COUNT(*) AS n FROM sqlite_master WHERE name = 'writer_state'\").get()!.n,\n+\t\t0,\n+\t\t\"an empty lookup must not install the legacy-write fence\",\n+\t);\n+\tassert.equal(\n+\t\truntime().initialize((calls) => answer(calls, \"init\", undefined, { files: { \"a.txt\": \"one\\ntwo\\n\" } }), validate)\n+\t\t\t.status,\n+\t\t200,\n+\t);\n+\tassert.throws(() => runtime().write(() => undefined, validate), /not complete/);\n+\tlet pages = 0;\n+\twhile (!runtime().preparePage(validate).ready) {\n+\t\tassert.ok(++pages < 100);\n+\t\tstorage.db.close();\n+\t\tstorage = memoryStorage(filename);\n+\t}\n+\tassert.ok(pages > 0);\n+\tconst initialLength = new SqliteLog(storage).seq();\n+\tconst initialStatus = runtime().read((calls) => calls.statusAt(initialLength), validate);\n+\tconst initialWhere = runtime().read((calls) => calls.whereAt(initialLength), validate);\n+\t// Reproduce the published runtime's ready state before historical indexing existed.\n+\tnew SqliteWriterState(storage, \"disk-v1\").remove(\"runtime\", \"history-ready\");\n+\tstorage.db.exec(\n+\t\t\"DELETE FROM writer_state WHERE namespace LIKE 'disk-v1:history%'; DROP TABLE writer_history_keys; DROP TABLE writer_history_heads;\",\n+\t);\n+\tassert.throws(() => runtime().read((calls) => calls.status(), validate), /not complete/);\n+\tassert.throws(() => runtime().write(() => undefined, validate), /not complete/);\n+\twhile (!runtime().preparePage(validate).ready) {}\n+\tassert.deepEqual(\n+\t\truntime().read((calls) => calls.statusAt(initialLength), validate),\n+\t\tinitialStatus,\n+\t);\n+\tconst req = { id: \"record-1\", identity: { agent: \"alice\", operation: \"record\", files: { \"a.txt\": \"changed\\n\" } } };\n+\tconst operation = (calls: Parameters<Parameters<DiskFirstRuntime[\"write\"]>[0]>[0]) =>\n+\t\tanswer(calls, \"record\", \"alice\", { files: req.identity.files });\n+\tconst first = runtime().write(operation, validate, req);\n+\tassert.equal(first.status, 200);\n+\tconst length = new SqliteLog(storage).seq();\n+\tconst draftStatus = runtime().read((calls) => calls.statusAt(length), validate);\n+\tconst draftWhere = runtime().read((calls) => calls.whereAt(length), validate);\n+\tstorage.db.close();\n+\tstorage = memoryStorage(filename);\n+\tassert.deepEqual(\n+\t\truntime().write(\n+\t\t\t() => {\n+\t\t\t\tthrow Error(\"retry executed\");\n+\t\t\t},\n+\t\t\tvalidate,\n+\t\t\treq,\n+\t\t),\n+\t\tfirst,\n+\t);\n+\tassert.equal(new SqliteLog(storage).seq(), length);\n+\tassert.throws(() => runtime().write(operation, validate, { ...req, identity: { agent: \"bob\" } }), /reused/);\n+\tassert.throws(\n+\t\t() =>\n+\t\t\truntime().write(\n+\t\t\t\toperation,\n+\t\t\t\t() => {\n+\t\t\t\t\tthrow Error(\"revoked\");\n+\t\t\t\t},\n+\t\t\t\treq,\n+\t\t\t),\n+\t\t/revoked/,\n+\t);\n+\tassert.equal(\n+\t\truntime().write((calls) => answer(calls, \"publish\", \"alice\", { message: \"Publish\" }), validate).status,\n+\t\t200,\n+\t);\n+\tconst shared = runtime().read((calls) => calls.shared(), validate);\n+\tassert.equal(Object.getOwnPropertyDescriptor(shared, \"files\")?.get, undefined);\n+\tassert.equal(shared.files[\"a.txt\"], \"changed\\n\");\n+\tstorage.db.close();\n+\tstorage = memoryStorage(filename);\n+\tassert.equal(runtime().preparePage(validate).ready, true);\n+\tassert.deepEqual(\n+\t\truntime().read((calls) => calls.statusAt(initialLength), validate),\n+\t\tinitialStatus,\n+\t);\n+\tassert.deepEqual(\n+\t\truntime().read((calls) => calls.whereAt(initialLength), validate),\n+\t\tinitialWhere,\n+\t);\n+\tconst end = new SqliteLog(storage).seq();\n+\tassert.deepEqual(\n+\t\truntime().read((calls) => calls.statusAt(length), validate),\n+\t\tdraftStatus,\n+\t);\n+\tassert.deepEqual(\n+\t\truntime().read((calls) => calls.whereAt(length), validate),\n+\t\tdraftWhere,\n+\t);\n+\tassert.equal(\n+\t\truntime().read((calls) => calls.statusAt(end).version, validate),\n+\t\t1,\n+\t);\n+\tassert.equal(\n+\t\truntime().read((calls) => calls.whereAt(end).version, validate),\n+\t\t1,\n+\t);\n+\tassert.equal(\n+\t\truntime().read((calls) => calls.shared().files[\"a.txt\"], validate),\n+\t\t\"changed\\n\",\n+\t);\n+});\n+\n+test(\"runtime page and write authority failures leave no partial state\", (t) => {\n+\tconst storage = memoryStorage();\n+\tt.after(() => storage.db.close());\n+\tconst runtime = new DiskFirstRuntime(storage, \"project\", \"disk-v1\");\n+\truntime.initialize(\n+\t\t(calls) => answer(calls, \"init\", undefined, { files: { \"a.txt\": \"one\\n\" } }),\n+\t\t() => {},\n+\t);\n+\tconst rows = () => {\n+\t\tconst tables = storage.db.prepare(\"SELECT name FROM sqlite_master WHERE type = 'table' ORDER BY name\").all();\n+\t\treturn tables.map((row) => [\n+\t\t\trow.name,\n+\t\t\tstorage.db.prepare(`SELECT * FROM \"${String(row.name).replaceAll('\"', '\"\"')}\" ORDER BY rowid`).all(),\n+\t\t]);\n+\t};\n+\tconst before = rows();\n+\tlet checks = 0;\n+\tassert.throws(\n+\t\t() =>\n+\t\t\truntime.preparePage(() => {\n+\t\t\t\tif (++checks === 3) throw Error(\"authority changed\");\n+\t\t\t}),\n+\t\t/authority changed/,\n+\t);\n+\tassert.deepEqual(rows(), before);\n+\twhile (!runtime.preparePage(() => {}).ready) {}\n+\tconst adopted = rows();\n+\tchecks = 0;\n+\tassert.throws(\n+\t\t() =>\n+\t\t\truntime.write(\n+\t\t\t\t(calls) => answer(calls, \"record\", \"alice\", { files: { \"a.txt\": \"two\\n\" } }),\n+\t\t\t\t() => {\n+\t\t\t\t\tif (++checks === 3) throw Error(\"authority changed\");\n+\t\t\t\t},\n+\t\t\t\t{ id: \"failed\", identity: \"record\" },\n+\t\t\t),\n+\t\t/authority changed/,\n+\t);\n+\tassert.deepEqual(rows(), adopted);\n+\tconst originalWrite = SqliteWriterState.prototype.write;\n+\tconst failure = t.mock.method(\n+\t\tSqliteWriterState.prototype,\n+\t\t\"write\",\n+\t\tfunction (this: SqliteWriterState, collection: string, key: string, value: unknown) {\n+\t\t\tif (collection === \"runtime:receipts\") throw Error(\"receipt persistence failed\");\n+\t\t\treturn originalWrite.call(this, collection, key, value);\n+\t\t},\n+\t);\n+\tassert.throws(\n+\t\t() =>\n+\t\t\truntime.write(\n+\t\t\t\t(calls) => answer(calls, \"record\", \"alice\", { files: { \"a.txt\": \"two\\n\" } }),\n+\t\t\t\t() => {},\n+\t\t\t\t{ id: \"receipt-failed\", identity: \"record\" },\n+\t\t\t),\n+\t\t/receipt persistence failed/,\n+\t);\n+\tassert.deepEqual(rows(), adopted, \"receipt failure must roll back canonical state, history and its cursor\");\n+\tfailure.mock.restore();\n+});\n+\n+test(\"runtime recovers after a writer without historical support commits\", (t) => {\n+\tconst storage = memoryStorage();\n+\tt.after(() => storage.db.close());\n+\tconst namespace = \"old-writer\";\n+\tconst runtime = () => new DiskFirstRuntime(storage, \"recovery\", namespace);\n+\truntime().initialize(\n+\t\t(calls) => answer(calls, \"init\", undefined, { files: { \"a.txt\": \"one\\n\" } }),\n+\t\t() => {},\n+\t);\n+\twhile (!runtime().preparePage(() => {}).ready) {}\n+\tconst historical = runtime().read(\n+\t\t(calls) => calls.statusAt(1),\n+\t\t() => {},\n+\t);\n+\tconst projection = new SqliteProjectionStore(\n+\t\t{\n+\t\t\tdatabase: \"recovery\",\n+\t\t\tnamespace: `${namespace}:views`,\n+\t\t\tregistry: `${namespace}:roots`,\n+\t\t\tdefaultFile: \"__abso_projection_default__\",\n+\t\t},\n+\t\t1,\n+\t\t{ indexedAtoms: true },\n+\t);\n+\tconst oldWriter = () => new SqliteWriterHost(storage, namespace, projection, { indexProjectionAtoms: true });\n+\tfor (const [op, body] of [\n+\t\t[\"record\", { files: { \"a.txt\": \"two\\n\" } }],\n+\t\t[\"publish\", { message: \"Old writer\" }],\n+\t] as const) {\n+\t\tassert.equal(\n+\t\t\toldWriter().runCalls({\n+\t\t\t\texpected: oldWriter().source(),\n+\t\t\t\tvalidateAuthority: () => {},\n+\t\t\t\tcheckerReady: false,\n+\t\t\t\tcommitReceipt: () => {},\n+\t\t\t\toperation: (calls) => answer(calls, op, \"alice\", body),\n+\t\t\t}).status,\n+\t\t\t200,\n+\t\t);\n+\t}\n+\tt.mock.method(Project, \"load\", () => {\n+\t\tthrow Error(\"full-history load forbidden\");\n+\t});\n+\tlet ready = false;\n+\tfor (let page = 0; page < 100 && !ready; page++) ready = runtime().preparePage(() => {}).ready;\n+\tassert.equal(ready, true);\n+\tassert.deepEqual(\n+\t\truntime().read(\n+\t\t\t(calls) => calls.statusAt(1),\n+\t\t\t() => {},\n+\t\t),\n+\t\thistorical,\n+\t);\n+\tassert.equal(\n+\t\truntime().read(\n+\t\t\t(calls) => calls.shared().files[\"a.txt\"],\n+\t\t\t() => {},\n+\t\t),\n+\t\t\"two\\n\",\n+\t);\n+\tassert.equal(\n+\t\truntime().write(\n+\t\t\t(calls) => answer(calls, \"record\", \"alice\", { files: { \"a.txt\": \"three\\n\" } }),\n+\t\t\t() => {},\n+\t\t).status,\n+\t\t200,\n+\t);\n+});\n+\n+test(\"a large retry response must not roll back an otherwise successful write\", (t) => {\n+\tconst storage = memoryStorage();\n+\tt.after(() => storage.db.close());\n+\tconst runtime = () => new DiskFirstRuntime(storage, \"large-receipt\", \"large-receipt\");\n+\truntime().initialize(\n+\t\t(calls) => answer(calls, \"init\", undefined, { files: { \"a.txt\": \"one\\n\" } }),\n+\t\t() => {},\n+\t);\n+\twhile (!runtime().preparePage(() => {}).ready) {}\n+\tconst large = \"x\".repeat(65503) + \"🚀\" + '\\u0000\\n\"\\\\é中\\ud800'.repeat(1_000_000);\n+\tconst request = { id: \"large-response\", identity: { agent: \"alice\", operation: \"large-fixture\" } };\n+\tconst result = runtime().write(\n+\t\t(calls) => {\n+\t\t\tconst recorded = answer(calls, \"record\", \"alice\", { files: { \"a.txt\": \"two\\n\" } });\n+\t\t\tassert.equal(recorded.status, 200);\n+\t\t\treturn { status: 200, body: large };\n+\t\t},\n+\t\t() => {},\n+\t\trequest,\n+\t);\n+\tassert.equal(result.body.length, large.length);\n+\tconst state = new SqliteWriterState(storage, \"large-receipt\");\n+\tconst header = state.read(\"runtime:receipts\", request.id) as { parts: number; characters: number; digest: string };\n+\tconst expected = JSON.stringify({ result });\n+\tassert.equal(header.characters, expected.length);\n+\tassert.equal(header.digest, createHash(\"sha256\").update(expected).digest(\"hex\"));\n+\tfor (let part = 0; part < header.parts; part++)\n+\t\tassert.equal(\n+\t\t\tstate.read(`runtime:receipt:${request.id}`, String(part)),\n+\t\t\texpected.slice(part * 65536, (part + 1) * 65536),\n+\t\t);\n+\tconst before = storage.db.prepare(\"SELECT * FROM log ORDER BY seq,part\").all();\n+\tconst replay = runtime().write(\n+\t\t() => {\n+\t\t\tthrow Error(\"receipt replay must not execute twice\");\n+\t\t},\n+\t\t() => {},\n+\t\trequest,\n+\t) as typeof result;\n+\tassert.deepEqual(replay, result);\n+\tassert.deepEqual(storage.db.prepare(\"SELECT * FROM log ORDER BY seq,part\").all(), before);\n+});\n+\n+test(\"chunked receipts roll back failures and reject damaged replay\", (t) => {\n+\tconst storage = memoryStorage();\n+\tt.after(() => storage.db.close());\n+\tconst runtime = () => new DiskFirstRuntime(storage, \"receipt-failure\", \"receipt-failure\");\n+\truntime().initialize(\n+\t\t(calls) => answer(calls, \"init\", undefined, { files: { \"a.txt\": \"one\\n\" } }),\n+\t\t() => {},\n+\t);\n+\twhile (!runtime().preparePage(() => {}).ready) {}\n+\tconst rows = () => ({\n+\t\tlog: storage.db.prepare(\"SELECT * FROM log ORDER BY seq,part\").all(),\n+\t\tstate: storage.db.prepare(\"SELECT * FROM writer_state ORDER BY namespace,collection,key,part\").all(),\n+\t\thistory: storage.db.prepare(\"SELECT * FROM writer_history_keys ORDER BY namespace,collection,key,revision\").all(),\n+\t\theads: storage.db.prepare(\"SELECT * FROM writer_history_heads ORDER BY namespace\").all(),\n+\t});\n+\tconst before = rows();\n+\tconst original = SqliteWriterState.prototype.write;\n+\tconst failure = t.mock.method(\n+\t\tSqliteWriterState.prototype,\n+\t\t\"write\",\n+\t\tfunction (this: SqliteWriterState, collection: string, key: string, value: unknown) {\n+\t\t\toriginal.call(this, collection, key, value);\n+\t\t\tif (collection === \"runtime:receipt:chunk-failure\" && key === \"1\") throw Error(\"injected receipt chunk failure\");\n+\t\t},\n+\t);\n+\tconst request = { id: \"chunk-failure\", identity: { operation: \"fixture\" } };\n+\tconst operation = (calls: EngineProject) => {\n+\t\tassert.equal(answer(calls, \"record\", \"alice\", { files: { \"a.txt\": \"two\\n\" } }).status, 200);\n+\t\treturn { body: \"x\".repeat(140000) };\n+\t};\n+\tassert.throws(() => runtime().write(operation, () => {}, request), /injected receipt chunk failure/);\n+\tassert.deepEqual(rows(), before);\n+\tfailure.mock.restore();\n+\tconst result = runtime().write(operation, () => {}, request);\n+\tconst committed = rows();\n+\tassert.deepEqual(\n+\t\truntime().write(\n+\t\t\t() => {\n+\t\t\t\tthrow Error(\"must not execute\");\n+\t\t\t},\n+\t\t\t() => {},\n+\t\t\trequest,\n+\t\t),\n+\t\tresult,\n+\t);\n+\tassert.deepEqual(rows(), committed);\n+\tconst state = new SqliteWriterState(storage, \"receipt-failure\");\n+\tconst chunk = state.read(\"runtime:receipt:chunk-failure\", \"1\") as string;\n+\tstate.write(\"runtime:receipt:chunk-failure\", \"1\", \"y\" + chunk.slice(1));\n+\tassert.throws(\n+\t\t() =>\n+\t\t\truntime().write(\n+\t\t\t\t() => {\n+\t\t\t\t\tthrow Error(\"must not execute\");\n+\t\t\t\t},\n+\t\t\t\t() => {},\n+\t\t\t\trequest,\n+\t\t\t),\n+\t\t/digest mismatch/,\n+\t);\n+\tstate.remove(\"runtime:receipt:chunk-failure\", \"1\");\n+\tassert.throws(\n+\t\t() =>\n+\t\t\truntime().write(\n+\t\t\t\t() => {\n+\t\t\t\t\tthrow Error(\"must not execute\");\n+\t\t\t\t},\n+\t\t\t\t() => {},\n+\t\t\t\trequest,\n+\t\t\t),\n+\t\t/incomplete receipt/,\n+\t);\n+\tassert.deepEqual(rows().log, committed.log);\n+});\n+\n+test(\"runtime format upgrade is authorized, atomic, and rejects unknown formats\", (t) => {\n+\tconst storage = memoryStorage();\n+\tt.after(() => storage.db.close());\n+\tconst runtime = () => new DiskFirstRuntime(storage, \"format-test\", \"format-test\");\n+\truntime().initialize(\n+\t\t(calls) => answer(calls, \"init\", undefined, { files: { \"a.txt\": \"one\\n\" } }),\n+\t\t() => {},\n+\t);\n+\twhile (!runtime().preparePage(() => {}).ready) {}\n+\tconst state = new SqliteWriterState(storage, \"format-test\");\n+\tassert.equal(state.read(\"runtime\", \"format\"), 5);\n+\tstate.write(\"runtime\", \"format\", 3);\n+\tconst before = storage.db.prepare(\"SELECT * FROM writer_state ORDER BY namespace,collection,key,part\").all();\n+\tlet validations = 0;\n+\tassert.throws(\n+\t\t() =>\n+\t\t\truntime().preparePage(() => {\n+\t\t\t\tif (++validations === 2) throw Error(\"revoked during upgrade\");\n+\t\t\t}),\n+\t\t/revoked/,\n+\t);\n+\tassert.deepEqual(\n+\t\tstorage.db.prepare(\"SELECT * FROM writer_state ORDER BY namespace,collection,key,part\").all(),\n+\t\tbefore,\n+\t);\n+\tassert.equal(runtime().preparePage(() => {}).ready, true);\n+\tassert.equal(state.read(\"runtime\", \"format\"), 5);\n+\tstate.write(\"runtime\", \"format\", 999);\n+\tassert.throws(() => runtime().preparePage(() => {}), /unsupported disk-first runtime format/);\n+\tassert.equal(state.read(\"runtime\", \"format\"), 999);\n+});"}],"unmatched":[]}