niceeval 0.16.3-canary.99 → 0.17.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.
- package/dist/cli/bootstrap.cjs +7 -1
- package/dist/cli/bootstrap.cjs.map +1 -1
- package/dist/cli/project-configuration.cjs +8 -11
- package/dist/cli/project-configuration.cjs.map +1 -1
- package/dist/expect/index.cjs.map +1 -1
- package/dist/expect/index.d.cts +1 -0
- package/dist/expect/index.d.mts +1 -0
- package/dist/expect/index.d.ts +1 -0
- package/dist/experiment/host/cli/contribution.cjs +6 -11
- package/dist/experiment/host/cli/contribution.cjs.map +1 -1
- package/dist/experiment/host/cli/contribution.d.cts +0 -16
- package/dist/experiment/host/cli/contribution.d.mts +0 -16
- package/dist/experiment/host/cli/contribution.d.ts +0 -16
- package/dist/experiment/host/operations.cjs +3 -3
- package/dist/experiment/host/operations.cjs.map +1 -1
- package/dist/experiment/host/types.cjs.map +1 -1
- package/dist/experiment/host/types.d.cts +0 -4
- package/dist/experiment/host/types.d.mts +0 -4
- package/dist/experiment/host/types.d.ts +0 -4
- package/dist/fresh-import.cjs +2 -2
- package/dist/fresh-import.cjs.map +1 -1
- package/dist/fresh-import.d.cts +3 -3
- package/dist/fresh-import.d.mts +3 -3
- package/dist/fresh-import.d.ts +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/inspection/codec.cjs.map +1 -1
- package/dist/inspection/codec.d.cts +1 -1
- package/dist/inspection/codec.d.mts +1 -1
- package/dist/inspection/codec.d.ts +1 -1
- package/dist/inspection/facts.cjs +66 -9
- package/dist/inspection/facts.cjs.map +1 -1
- package/dist/inspection/facts.d.cts +4 -0
- package/dist/inspection/facts.d.mts +4 -0
- package/dist/inspection/facts.d.ts +4 -0
- package/dist/inspection/facts.js +4 -2
- package/dist/inspection/index.cjs +1 -3
- package/dist/inspection/index.cjs.map +1 -1
- package/dist/inspection/index.d.cts +1 -1
- package/dist/inspection/index.d.mts +1 -1
- package/dist/inspection/index.d.ts +1 -1
- package/dist/inspection/index.js +44 -48
- package/dist/inspection/limits.cjs +3 -1
- package/dist/inspection/limits.cjs.map +1 -1
- package/dist/inspection/limits.d.cts +2 -0
- package/dist/inspection/limits.d.mts +2 -0
- package/dist/inspection/limits.d.ts +2 -0
- package/dist/inspection/limits.js +6 -4
- package/dist/inspection/project-source.cjs +4 -1
- package/dist/inspection/project-source.cjs.map +1 -1
- package/dist/inspection/protocol.cjs +10 -18
- package/dist/inspection/protocol.cjs.map +1 -1
- package/dist/inspection/protocol.d.cts +111 -173
- package/dist/inspection/protocol.d.mts +111 -173
- package/dist/inspection/protocol.d.ts +111 -173
- package/dist/inspection/public.mjs +73 -109
- package/dist/inspection/results.cjs +12 -48
- package/dist/inspection/results.cjs.map +1 -1
- package/dist/inspection/results.d.cts +124 -122
- package/dist/inspection/results.d.mts +124 -122
- package/dist/inspection/results.d.ts +124 -122
- package/dist/inspection/results.js +16 -20
- package/dist/inspection/select.cjs +80 -117
- package/dist/inspection/select.cjs.map +1 -1
- package/dist/inspection/source.cjs +14 -15
- package/dist/inspection/source.cjs.map +1 -1
- package/dist/inspection/source.d.cts +6 -3
- package/dist/inspection/source.d.mts +6 -3
- package/dist/inspection/source.d.ts +6 -3
- package/dist/inspection/trace.cjs +1 -1
- package/dist/inspection/trace.cjs.map +1 -1
- package/dist/load-config.cjs +17 -11
- package/dist/load-config.cjs.map +1 -1
- package/dist/load-config.d.cts +3 -2
- package/dist/load-config.d.mts +3 -2
- package/dist/load-config.d.ts +3 -2
- package/dist/o11y/adapter-usage-projection.cjs +5 -1
- package/dist/o11y/adapter-usage-projection.cjs.map +1 -1
- package/dist/o11y/adapter-usage-projection.d.cts +109 -1
- package/dist/o11y/adapter-usage-projection.d.mts +109 -1
- package/dist/o11y/adapter-usage-projection.d.ts +109 -1
- package/dist/o11y/cache-read.cjs +113 -0
- package/dist/o11y/cache-read.cjs.map +1 -0
- package/dist/o11y/cache-read.d.cts +80 -0
- package/dist/o11y/cache-read.d.mts +80 -0
- package/dist/o11y/cache-read.d.ts +80 -0
- package/dist/o11y/cache-read.js +8 -0
- package/dist/o11y/cache-read.js.map +1 -0
- package/dist/o11y/eval-usage.cjs +4 -1
- package/dist/o11y/eval-usage.cjs.map +1 -1
- package/dist/o11y/eval-usage.d.cts +4 -1
- package/dist/o11y/eval-usage.d.mts +4 -1
- package/dist/o11y/eval-usage.d.ts +4 -1
- package/dist/record/host/sqlite-host.cjs +188 -53
- package/dist/record/host/sqlite-host.cjs.map +1 -1
- package/dist/record/host/sqlite-host.d.cts +37 -1
- package/dist/record/host/sqlite-host.d.mts +37 -1
- package/dist/record/host/sqlite-host.d.ts +37 -1
- package/dist/record/host/sqlite-host.js +16 -8
- package/dist/record/maintenance/runtime.cjs +3 -3
- package/dist/record/maintenance/runtime.cjs.map +1 -1
- package/dist/record/sqlite/admission-repository.cjs +18 -18
- package/dist/record/sqlite/admission-repository.cjs.map +1 -1
- package/dist/record/sqlite/case-repository.cjs +6 -6
- package/dist/record/sqlite/case-repository.cjs.map +1 -1
- package/dist/record/sqlite/coordination-repository.cjs +25 -25
- package/dist/record/sqlite/coordination-repository.cjs.map +1 -1
- package/dist/record/sqlite/current-schema.cjs +115 -111
- package/dist/record/sqlite/current-schema.cjs.map +1 -1
- package/dist/record/sqlite/current-schema.d.cts +3 -3
- package/dist/record/sqlite/current-schema.d.mts +3 -3
- package/dist/record/sqlite/current-schema.d.ts +3 -3
- package/dist/record/sqlite/database.cjs +56 -53
- package/dist/record/sqlite/database.cjs.map +1 -1
- package/dist/record/sqlite/index.cjs +3 -1
- package/dist/record/sqlite/index.cjs.map +1 -1
- package/dist/record/sqlite/index.d.cts +5 -2
- package/dist/record/sqlite/index.d.mts +5 -2
- package/dist/record/sqlite/index.d.ts +5 -2
- package/dist/record/sqlite/legacy-schema-018.cjs +443 -0
- package/dist/record/sqlite/legacy-schema-018.cjs.map +1 -0
- package/dist/record/sqlite/legacy-schema-018.d.cts +6 -0
- package/dist/record/sqlite/legacy-schema-018.d.mts +6 -0
- package/dist/record/sqlite/legacy-schema-018.d.ts +6 -0
- package/dist/record/sqlite/legacy-schema-018.js +6 -0
- package/dist/record/sqlite/legacy-schema-018.js.map +1 -0
- package/dist/record/sqlite/migration.cjs +105 -46
- package/dist/record/sqlite/migration.cjs.map +1 -1
- package/dist/record/sqlite/migration.d.cts +2 -1
- package/dist/record/sqlite/migration.d.mts +2 -1
- package/dist/record/sqlite/migration.d.ts +2 -1
- package/dist/record/sqlite/portable-capture.cjs +13 -13
- package/dist/record/sqlite/portable-capture.cjs.map +1 -1
- package/dist/record/sqlite/registry-repository.cjs +22 -22
- package/dist/record/sqlite/registry-repository.cjs.map +1 -1
- package/dist/record/sqlite/schema.cjs +10 -2
- package/dist/record/sqlite/schema.cjs.map +1 -1
- package/dist/record/sqlite/schema.d.cts +4 -1
- package/dist/record/sqlite/schema.d.mts +4 -1
- package/dist/record/sqlite/schema.d.ts +4 -1
- package/dist/record/sqlite/schema.js +20 -14
- package/dist/record/sqlite/storage-worker.cjs +1 -1
- package/dist/record/sqlite/storage-worker.cjs.map +1 -1
- package/dist/record/sqlite/storage.cjs +316 -232
- package/dist/record/sqlite/storage.cjs.map +1 -1
- package/dist/record/sqlite/storage.d.cts +10 -2
- package/dist/record/sqlite/storage.d.mts +10 -2
- package/dist/record/sqlite/storage.d.ts +10 -2
- package/dist/record/sqlite/storage.js +54 -50
- package/dist/record/sqlite/types.cjs +1 -1
- package/dist/record/sqlite/types.cjs.map +1 -1
- package/dist/record/sqlite/types.d.cts +13 -1
- package/dist/record/sqlite/types.d.mts +13 -1
- package/dist/record/sqlite/types.d.ts +13 -1
- package/dist/run/cli/contribution.cjs +17 -12
- package/dist/run/cli/contribution.cjs.map +1 -1
- package/dist/run/host/lifecycle-adapter.cjs +1 -1
- package/dist/run/host/lifecycle-adapter.cjs.map +1 -1
- package/dist/run/storage/owner-identity.cjs +78 -16
- package/dist/run/storage/owner-identity.cjs.map +1 -1
- package/dist/run/storage/owner-identity.d.cts +2 -1
- package/dist/run/storage/owner-identity.d.mts +2 -1
- package/dist/run/storage/owner-identity.d.ts +2 -1
- package/dist/run/storage/sqlite.cjs +55 -55
- package/dist/run/storage/sqlite.cjs.map +1 -1
- package/dist/runner/accept.cjs +12 -42
- package/dist/runner/accept.cjs.map +1 -1
- package/dist/runner/accept.d.cts +2 -3
- package/dist/runner/accept.d.mts +2 -3
- package/dist/runner/accept.d.ts +2 -3
- package/dist/runner/adapter-usage.cjs +2 -2
- package/dist/runner/adapter-usage.cjs.map +1 -1
- package/dist/runner/adoption.cjs +14 -26
- package/dist/runner/adoption.cjs.map +1 -1
- package/dist/runner/adoption.d.cts +5 -13
- package/dist/runner/adoption.d.mts +5 -13
- package/dist/runner/adoption.d.ts +5 -13
- package/dist/runner/adoption.js +2 -4
- package/dist/runner/record.cjs +24 -18
- package/dist/runner/record.cjs.map +1 -1
- package/dist/runner/rename-experiment.cjs +5 -7
- package/dist/runner/rename-experiment.cjs.map +1 -1
- package/dist/runner/reuse-plan.cjs +37 -18
- package/dist/runner/reuse-plan.cjs.map +1 -1
- package/dist/runner/reuse-plan.d.cts +4 -1
- package/dist/runner/reuse-plan.d.mts +4 -1
- package/dist/runner/reuse-plan.d.ts +4 -1
- package/dist/runner/setup-prefix-plan.cjs +17 -12
- package/dist/runner/setup-prefix-plan.cjs.map +1 -1
- package/dist/runner/setup-prefix-plan.d.cts +0 -2
- package/dist/runner/setup-prefix-plan.d.mts +0 -2
- package/dist/runner/setup-prefix-plan.d.ts +0 -2
- package/dist/runner/setup-prefix-plan.js +8 -12
- package/dist/sandbox/backend.cjs +10 -1
- package/dist/sandbox/backend.cjs.map +1 -1
- package/dist/sandbox/backend.d.cts +16 -8
- package/dist/sandbox/backend.d.mts +16 -8
- package/dist/sandbox/backend.d.ts +16 -8
- package/dist/sandbox/backend.js +28 -26
- package/dist/sandbox/docker.cjs +7 -1
- package/dist/sandbox/docker.cjs.map +1 -1
- package/dist/sandbox/e2b-cache-repository.cjs +13 -3
- package/dist/sandbox/e2b-cache-repository.cjs.map +1 -1
- package/dist/sandbox/e2b-cache-repository.d.cts +3 -0
- package/dist/sandbox/e2b-cache-repository.d.mts +3 -0
- package/dist/sandbox/e2b-cache-repository.d.ts +3 -0
- package/dist/sandbox/e2b-cache-repository.js +16 -12
- package/dist/sandbox/e2b.cjs +2 -2
- package/dist/sandbox/e2b.cjs.map +1 -1
- package/dist/sandbox/incus/materialize.cjs +1 -1
- package/dist/sandbox/incus/materialize.cjs.map +1 -1
- package/dist/show/contribution.cjs +3 -3
- package/dist/show/contribution.cjs.map +1 -1
- package/dist/show/model.cjs +14 -13
- package/dist/show/model.cjs.map +1 -1
- package/dist/show/model.d.cts +7 -7
- package/dist/show/model.d.mts +7 -7
- package/dist/show/model.d.ts +7 -7
- package/dist/show/render.cjs +14 -0
- package/dist/show/render.cjs.map +1 -1
- package/dist/user-database/storage-worker.cjs +13 -3
- package/dist/user-database/storage-worker.cjs.map +1 -1
- package/dist/view/app-dist/.vite/manifest.json +2 -2
- package/dist/view/app-dist/assets/{index-CmVoXbwG.js → index-B3ijZRph.js} +17 -17
- package/dist/view/app-dist/assets/{quality-cost-scatter-BuLISaH4.js → quality-cost-scatter-B--DfJ9s.js} +1 -1
- package/dist/view/app-dist/index.html +1 -1
- package/dist/view/application-runtime.cjs +8 -0
- package/dist/view/application-runtime.cjs.map +1 -0
- package/dist/view/application-runtime.d.cts +9 -0
- package/dist/view/application-runtime.d.mts +9 -0
- package/dist/view/application-runtime.d.ts +9 -0
- package/dist/view/application-runtime.js +6 -0
- package/dist/view/application-runtime.js.map +1 -0
- package/dist/view/cli/contribution.cjs +5 -2
- package/dist/view/cli/contribution.cjs.map +1 -1
- package/dist/view/cli/contribution.d.cts +2 -1
- package/dist/view/cli/contribution.d.mts +2 -1
- package/dist/view/cli/contribution.d.ts +2 -1
- package/dist/view/function-runtime.mjs +1019 -456
- package/dist/view/http-protocol.d.cts +1 -9
- package/dist/view/http-protocol.d.mts +1 -9
- package/dist/view/http-protocol.d.ts +1 -9
- package/dist/view/inspection-host.cjs +39 -30
- package/dist/view/inspection-host.cjs.map +1 -1
- package/dist/view/inspection-host.d.cts +7545 -2
- package/dist/view/inspection-host.d.mts +7545 -2
- package/dist/view/inspection-host.d.ts +7545 -2
- package/dist/view/server.cjs +8 -5
- package/dist/view/server.cjs.map +1 -1
- package/dist/view/server.d.cts +4 -2
- package/dist/view/server.d.mts +4 -2
- package/dist/view/server.d.ts +4 -2
- package/docs-site/zh/reference/cli.mdx +1 -2
- package/docs-site/zh/tutorials/control-run-cost.mdx +22 -0
- package/docs-site/zh/tutorials/niceeval-taste-application.mdx +21 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"database.js","sourceRoot":"","sources":["database.ts"],"names":[],"mappings":";;;AA4CA,0CAOC;AAsBD,8DAEC;AAQD,4CAOC;AA6DD,oEAkEC;AAmKD,kDAGC;AACD,4CAoFC;AAED,8DAOC;AACD,4CAGC;AACD,8DAGC;AAuCD,sDA2BC;AACD,kDAMC;AACD,4DAKC;AAED,sDA0BC;AAMD,kEA8KC;AApwBD,6CAAyC;AACzC,qCAA4D;AAC5D,yCAA6D;AAC7D,6CAA+F;AAC/F,2CAAoI;AACpI,2CAA0C;AAC1C,yCAAkF;AAClF,mGAAsH;AACtH,MAAM,YAAY,GAAG,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAU,CAAC;AAC1C,MAAM,6BAA6B,GAAG,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAU,CAAC;AAC3D,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC;IACxB,uBAAS,CAAC,aAAa;IACvB,uBAAS,CAAC,aAAa;IACvB,uBAAS,CAAC,aAAa;IACvB,uBAAS,CAAC,aAAa;IACvB,uBAAS,CAAC,aAAa;IACvB,uBAAS,CAAC,mBAAmB;IA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CAAC;YACjE,YAAY,KAAK,SAAS,IAAI,YAAY,CAAC,gBAAgB,KAAK,IAAI,IAAI,YAAY,CAAC,UAAU,KAAK,IAAI,EAAE,CAAC;YAC3G,MAAM,IAAA,uBAAW,EAAC,yBAAyB,EAAE,eAAe,EAAE,yDAAyD,CAAC,CAAC;QAC7H,CAAC;IACL,CAAC;YACO,CAAC;QACL,mBAAmB,CAAC,UAAU,CAAC,CAAC;IACpC,CAAC;IACD,OAAO,IAAI,CAAC;AAChB,CAAC;AACD,2FAA2F;AAC9E,QAAA,0BAA0B,GAAG,2BAA2B,CAAC","sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport { lstatSync, mkdirSync, readdirSync } from \"node:fs\";\nimport { basename, dirname, join, resolve } from \"node:path\";\nimport { constants, DatabaseSync, type SQLOutputValue, type StatementSync } from \"node:sqlite\";\nimport { RECORD_SQLITE_BASELINE_FINGERPRINT, RECORD_SQLITE_BASELINE_SQL, RECORD_SQLITE_PREPARED_SEAL_TEMP_SQL, } from \"./schema.ts\";\nimport { sqliteError } from \"./errors.ts\";\nimport { RECORD_SQLITE_FORMAT, RECORD_SQLITE_STORAGE_REVISION } from \"./types.ts\";\nimport { currentProcessOwnerIdentity, exactProcessState } from \"../../coordination/platform/node-process-identity.ts\";\nconst MINIMUM_NODE = [24, 15, 0] as const;\nconst MINIMUM_IMMUTABLE_READER_NODE = [24, 10, 0] as const;\nconst READ_DENIED = new Set([\n constants.SQLITE_ATTACH,\n constants.SQLITE_DETACH,\n constants.SQLITE_INSERT,\n constants.SQLITE_UPDATE,\n constants.SQLITE_DELETE,\n constants.SQLITE_CREATE_INDEX,\n constants.SQLITE_CREATE_TABLE,\n constants.SQLITE_CREATE_TEMP_INDEX,\n constants.SQLITE_CREATE_TEMP_TABLE,\n constants.SQLITE_CREATE_TEMP_TRIGGER,\n constants.SQLITE_CREATE_TEMP_VIEW,\n constants.SQLITE_CREATE_TRIGGER,\n constants.SQLITE_CREATE_VIEW,\n constants.SQLITE_DROP_INDEX,\n constants.SQLITE_DROP_TABLE,\n constants.SQLITE_DROP_TEMP_INDEX,\n constants.SQLITE_DROP_TEMP_TABLE,\n constants.SQLITE_DROP_TEMP_TRIGGER,\n constants.SQLITE_DROP_TEMP_VIEW,\n constants.SQLITE_DROP_TRIGGER,\n constants.SQLITE_DROP_VIEW,\n constants.SQLITE_ALTER_TABLE,\n constants.SQLITE_REINDEX,\n constants.SQLITE_ANALYZE,\n constants.SQLITE_CREATE_VTABLE,\n constants.SQLITE_DROP_VTABLE,\n]);\nexport interface RecordDatabase {\n readonly db: DatabaseSync;\n readonly path: string;\n readonly mode: \"writer\" | \"reader\" | \"maintenance\";\n readonly statements: Map<string, StatementSync>;\n}\nexport function recordStatement(connection: RecordDatabase, sql: string): StatementSync {\n const existing = connection.statements.get(sql);\n if (existing !== undefined)\n return existing;\n const prepared = connection.db.prepare(sql);\n connection.statements.set(sql, prepared);\n return prepared;\n}\nfunction currentStatement(db: DatabaseSync, sql: string): StatementSync {\n return db.prepare(sql);\n}\nfunction currentExec(db: DatabaseSync, sql: string): void {\n db.exec(sql);\n}\nfunction nodeVersionTuple(): readonly number[] {\n return process.versions.node.split(\".\").map((part) => Number(part));\n}\nfunction assertMinimumNode(minimum: readonly number[], capability: string): void {\n const actual = nodeVersionTuple();\n for (let index = 0; index < minimum.length; index += 1) {\n const value = actual[index] ?? 0;\n const required = minimum[index];\n if (value > required)\n return;\n if (value < required) {\n throw sqliteError(\"record-runtime-unsupported\", \"open\", `${capability} requires Node ${minimum.join(\".\")} or newer; received ${process.versions.node}`);\n }\n }\n}\nexport function assertRecordSqliteRuntime(): void {\n assertMinimumNode(MINIMUM_NODE, \"Project Record SQLite\");\n}\nfunction assertImmutableRecordReaderRuntime(): void {\n // The 24.15 floor protects mutable WAL ownership. An already-admitted,\n // immutable generation only needs the defensive read APIs introduced in\n // 24.10 and never opens a writer or checkpoints WAL.\n assertMinimumNode(MINIMUM_IMMUTABLE_READER_NODE, \"Immutable Project Record reader\");\n}\n/** Resolves the one ProjectDatabase while preserving custom non-project roots. */\nexport function recordSqlitePath(recordStorageRoot: string): string {\n if (recordStorageRoot.length === 0)\n throw sqliteError(\"record-database-invalid\", \"locate\", \"Record storage root is empty\");\n const resolvedRoot = resolve(recordStorageRoot);\n return basename(resolvedRoot) === \"record\" && basename(dirname(resolvedRoot)) === \".niceeval\"\n ? join(dirname(resolvedRoot), \"record.sqlite\")\n : join(resolvedRoot, \"record.sqlite\");\n}\nfunction legacyRecordSqlitePath(path: string): string | undefined {\n const parent = dirname(path);\n return basename(path) === \"record.sqlite\" && basename(parent) === \".niceeval\"\n ? join(parent, \"record\", \"record.sqlite\")\n : undefined;\n}\nfunction pathExists(path: string): boolean {\n try {\n lstatSync(path);\n return true;\n }\n catch (cause) {\n if (typeof cause === \"object\" && cause !== null && Reflect.get(cause, \"code\") === \"ENOENT\")\n return false;\n throw sqliteError(\"record-database-invalid\", \"locate\", \"Record path could not be inspected safely\", cause);\n }\n}\nfunction legacyRecordRecovery(): string {\n return \"No automatic migration is available. Keep the original project and its .niceeval directory \" +\n \"for inspection with the original NiceEval version. Stop any old NiceEval processes before \" +\n \"copying project files. To run with this version, use a separate project copy without .niceeval \" +\n \"and rerun the experiment there. Do not delete individual legacy locks or records.\";\n}\n/** Record/0.13 is never opened or silently migrated into ProjectDatabase. */\nfunction assertLegacyRecordAbsent(path: string): void {\n const legacyPath = legacyRecordSqlitePath(path);\n if (legacyPath === undefined)\n return;\n if (!pathExists(legacyPath))\n return;\n throw sqliteError(\"record-schema-unsupported\", \"locate\", `legacy Record/0.13 database is unsupported and blocks ProjectDatabase: ${legacyPath}. ${legacyRecordRecovery()}`);\n}\nfunction assertLegacyCoordinationEntriesAbsent(path: string): void {\n const parent = dirname(path);\n if (basename(path) !== \"record.sqlite\" || basename(parent) !== \".niceeval\")\n return;\n for (const name of [\"locks\", \"sessions\", \"teardowns\", \"shared-state-leases\", \"sandboxes\"] as const) {\n const legacy = join(parent, name);\n if (!pathExists(legacy))\n continue;\n const metadata = lstatSync(legacy);\n if (!metadata.isDirectory() || metadata.isSymbolicLink() || readdirSync(legacy).length > 0) {\n throw sqliteError(\"record-schema-unsupported\", \"locate\", `legacy ${name}/ entries block ProjectDatabase mutation: ${legacy}. ${legacyRecordRecovery()}`);\n }\n }\n}\nexport type ProjectRecordDatabaseInspection = {\n readonly state: \"current\";\n readonly exists: boolean;\n} | {\n readonly state: \"unsupported\";\n readonly format: string;\n} | {\n readonly state: \"foreign\";\n};\n/**\n * Bounded identity probe used only by explicit maintenance. It never creates a\n * database and never treats the pre-ProjectDatabase directory as a migration\n * source.\n */\nexport function inspectProjectRecordDatabase(path: string): ProjectRecordDatabaseInspection {\n assertRecordSqliteRuntime();\n const legacyPath = legacyRecordSqlitePath(path);\n if (legacyPath !== undefined && pathExists(legacyPath)) {\n return Object.freeze({ state: \"unsupported\", format: \"niceeval.record/0.13.x\" });\n }\n if (!pathExists(path))\n return Object.freeze({ state: \"current\", exists: false });\n const metadata = lstatSync(path);\n if (!metadata.isFile() || metadata.isSymbolicLink())\n return Object.freeze({ state: \"foreign\" });\n let connection: RecordDatabase | undefined;\n try {\n connection = openRecordMaintenance(path);\n const currentTable = connection.db.prepare(`SELECT count(*) AS count FROM sqlite_schema\n WHERE type='table' AND name='ne18_record_metadata'`).get() as Record<string, SQLOutputValue>;\n const legacy017Table = connection.db.prepare(`SELECT count(*) AS count FROM sqlite_schema\n WHERE type='table' AND name='ne_record_metadata'`).get() as Record<string, SQLOutputValue>;\n const legacyTable = connection.db.prepare(`SELECT count(*) AS count FROM sqlite_schema\n WHERE type='table' AND name='record_metadata'`).get() as Record<string, SQLOutputValue>;\n const hasCurrent = decodeInteger(currentTable.count, \"sqlite_schema.record_metadata\") === 1;\n const hasLegacy017 = decodeInteger(legacy017Table.count, \"sqlite_schema.record_metadata\") === 1;\n const hasLegacy = decodeInteger(legacyTable.count, \"sqlite_schema.record_metadata\") === 1;\n if (Number(hasCurrent) + Number(hasLegacy017) + Number(hasLegacy) !== 1) {\n return Object.freeze({ state: \"foreign\" });\n }\n const metadataTable = hasCurrent ? \"ne18_record_metadata\" : hasLegacy017 ? \"ne_record_metadata\" : \"record_metadata\";\n let row: Record<string, SQLOutputValue> | undefined;\n try {\n row = connection.db.prepare(`SELECT format,storage_revision\n FROM ${metadataTable} WHERE singleton=1`).get() as Record<string, SQLOutputValue> | undefined;\n }\n catch {\n return Object.freeze({ state: \"foreign\" });\n }\n if (row === undefined || typeof row.format !== \"string\")\n return Object.freeze({ state: \"foreign\" });\n if (row.format !== RECORD_SQLITE_FORMAT) {\n return Object.freeze({ state: \"unsupported\", format: row.format });\n }\n let revision: number;\n try {\n revision = decodeInteger(row.storage_revision, \"record_metadata.storage_revision\");\n }\n catch {\n return Object.freeze({ state: \"foreign\" });\n }\n if (revision !== RECORD_SQLITE_STORAGE_REVISION) {\n return Object.freeze({ state: \"unsupported\", format: row.format });\n }\n try {\n validateExactSchema(connection);\n requireMigrationReady(connection);\n return Object.freeze({ state: \"current\", exists: true });\n }\n catch {\n return Object.freeze({ state: \"unsupported\", format: row.format });\n }\n }\n catch {\n return Object.freeze({ state: \"foreign\" });\n }\n finally {\n if (connection !== undefined)\n closeRecordDatabase(connection);\n }\n}\nfunction configureCommon(db: DatabaseSync): void {\n db.enableLoadExtension(false);\n db.enableDefensive(true);\n db.exec(\"PRAGMA secure_delete=ON; PRAGMA foreign_keys=ON; PRAGMA trusted_schema=OFF; PRAGMA mmap_size=0; PRAGMA cache_size=-8192; PRAGMA temp_store=FILE; PRAGMA recursive_triggers=ON;\");\n}\nfunction requireSecureDelete(db: DatabaseSync): void {\n const row = currentStatement(db, \"PRAGMA secure_delete\").get() as Record<string, SQLOutputValue> | undefined;\n if (row === undefined || decodeInteger(row.secure_delete, \"secure_delete\") !== 1) {\n throw sqliteError(\"record-database-invalid\", \"open\", \"ProjectDatabase requires PRAGMA secure_delete=ON\");\n }\n}\nfunction writableAuthorizer() {\n return (action: number, arg1: string | null, arg2: string | null): number => {\n if (action === constants.SQLITE_ATTACH)\n return constants.SQLITE_DENY;\n if (action === constants.SQLITE_DETACH)\n return constants.SQLITE_DENY;\n if (action === constants.SQLITE_FUNCTION && arg2?.toLowerCase() === \"load_extension\")\n return constants.SQLITE_DENY;\n if (action === constants.SQLITE_PRAGMA) {\n const permitted = arg1 === \"busy_timeout\" || arg1 === \"quick_check\" || arg1 === \"foreign_key_check\" || arg1 === \"wal_checkpoint\" || arg1 === \"secure_delete\";\n if (!permitted)\n return constants.SQLITE_DENY;\n }\n return constants.SQLITE_OK;\n };\n}\nfunction readerAuthorizer(action: number, arg1: string | null, arg2: string | null, dbName: string | null): number {\n if (dbName === \"temp\") {\n const preparedTable = arg1 === \"niceeval_prepared_seal_raw\" || arg1 === \"niceeval_prepared_seal_ordered\";\n return preparedTable && (action === constants.SQLITE_READ || action === constants.SQLITE_INSERT || action === constants.SQLITE_DELETE)\n ? constants.SQLITE_OK\n : constants.SQLITE_DENY;\n }\n if (dbName !== null && dbName !== \"main\")\n return constants.SQLITE_DENY;\n if (READ_DENIED.has(action))\n return constants.SQLITE_DENY;\n if (action === constants.SQLITE_PRAGMA && arg1 !== \"quick_check\" && arg1 !== \"foreign_key_check\" && arg1 !== \"secure_delete\")\n return constants.SQLITE_DENY;\n if (action === constants.SQLITE_FUNCTION && arg2?.toLowerCase() === \"load_extension\")\n return constants.SQLITE_DENY;\n return constants.SQLITE_OK;\n}\nfunction schemaRows(db: DatabaseSync): readonly string[] {\n const rows = currentStatement(db, `SELECT type, name, tbl_name, sql FROM sqlite_schema\n WHERE name NOT LIKE 'sqlite_stat%' ORDER BY type, name LIMIT 257`).all() as unknown as readonly Record<string, SQLOutputValue>[];\n if (rows.length > 256)\n throw sqliteError(\"record-database-invalid\", \"validate-schema\", \"database schema exceeds the bounded object allowlist\");\n return rows.map((row) => JSON.stringify([\n decodeText(row.type, \"sqlite_schema.type\"),\n decodeText(row.name, \"sqlite_schema.name\"),\n decodeText(row.tbl_name, \"sqlite_schema.tbl_name\"),\n row.sql === null ? null : normalizeSql(decodeText(row.sql, \"sqlite_schema.sql\")),\n ]));\n}\nfunction normalizeSql(sql: string): string {\n return sql.replace(/\\s+/gu, \" \").replace(/\\s*([(),])\\s*/gu, \"$1\").trim().replace(/;$/u, \"\");\n}\nconst canonicalSchemaRows = new Map<string, readonly string[]>();\nfunction expectedSchemaRows(sql?: string): readonly string[] {\n const key = sql ?? \"bootstrap\";\n const cached = canonicalSchemaRows.get(key);\n if (cached !== undefined)\n return cached;\n const db = new DatabaseSync(\":memory:\", { allowExtension: false, defensive: true, readBigInts: true });\n try {\n db.exec(sql ?? RECORD_SQLITE_BASELINE_SQL);\n const rows = Object.freeze(schemaRows(db));\n canonicalSchemaRows.set(key, rows);\n return rows;\n }\n finally {\n db.close();\n }\n}\nfunction validateSchemaObjects(connection: RecordDatabase, sql?: string): void {\n const actual = schemaRows(connection.db);\n const expected = expectedSchemaRows(sql);\n if (actual.length !== expected.length || actual.some((row, index) => row !== expected[index])) {\n throw sqliteError(\"record-schema-unsupported\", \"validate-schema\", \"database objects do not match the exact Project Record schema allowlist\");\n }\n}\nfunction storageRevision(connection: RecordDatabase): number {\n const row = currentStatement(connection.db, \"SELECT storage_revision FROM ne18_record_metadata WHERE singleton=1\").get() as Record<string, SQLOutputValue> | undefined;\n if (row === undefined)\n throw sqliteError(\"record-schema-unsupported\", \"validate-schema\", \"ProjectDatabase identity is missing\");\n return decodeInteger(row.storage_revision, \"record_metadata.storage_revision\");\n}\nfunction validateExistingOperationalSchemaForWriter(connection: RecordDatabase): void {\n const revision = storageRevision(connection);\n if (revision === RECORD_SQLITE_STORAGE_REVISION) {\n validateExactSchema(connection);\n requireMigrationReady(connection);\n return;\n }\n throw sqliteError(\"record-schema-unsupported\", \"validate-schema\", `record storage revision ${revision} cannot be opened by revision ${RECORD_SQLITE_STORAGE_REVISION}`);\n}\nfunction decodeText(value: SQLOutputValue | undefined, field: string): string {\n if (typeof value !== \"string\")\n throw sqliteError(\"record-database-invalid\", \"decode\", `${field} is not text`);\n return value;\n}\nfunction decodeInteger(value: SQLOutputValue | undefined, field: string): number {\n const numeric = typeof value === \"bigint\" ? Number(value) : value;\n if (typeof numeric !== \"number\" || !Number.isSafeInteger(numeric)) {\n throw sqliteError(\"record-database-invalid\", \"decode\", `${field} is not a safe integer`);\n }\n return numeric;\n}\nfunction validateCurrentRecordDomain(connection: RecordDatabase): void {\n let metadata: Record<string, SQLOutputValue> | undefined;\n try {\n metadata = currentStatement(connection.db, `SELECT format,storage_revision,storage_generation,schema_fingerprint,barrier_state\n FROM ne18_record_metadata WHERE singleton=1`).get() as Record<string, SQLOutputValue> | undefined;\n }\n catch (cause) {\n throw sqliteError(\"record-schema-unsupported\", \"validate-schema\", \"database does not expose the ProjectDatabase identity\", cause);\n }\n if (metadata === undefined) {\n throw sqliteError(\"record-schema-unsupported\", \"validate-schema\", \"ProjectDatabase identity is missing\");\n }\n if (decodeText(metadata.format, \"record_metadata.format\") !== RECORD_SQLITE_FORMAT) {\n throw sqliteError(\"record-schema-unsupported\", \"validate-schema\", \"record format is unsupported\");\n }\n const revision = decodeInteger(metadata.storage_revision, \"record_metadata.storage_revision\");\n if (revision !== RECORD_SQLITE_STORAGE_REVISION) {\n throw sqliteError(\"record-schema-unsupported\", \"validate-schema\", `record storage revision ${revision} is not ${RECORD_SQLITE_STORAGE_REVISION}`);\n }\n if (decodeText(metadata.schema_fingerprint, \"record_metadata.schema_fingerprint\") !== RECORD_SQLITE_BASELINE_FINGERPRINT) {\n throw sqliteError(\"record-schema-unsupported\", \"validate-schema\", \"ProjectDatabase baseline fingerprint is unsupported\");\n }\n const barrierState = decodeText(metadata.barrier_state, \"record_metadata.barrier_state\");\n if (barrierState !== \"open\" && barrierState !== \"draining\" && barrierState !== \"portable\") {\n throw sqliteError(\"record-database-invalid\", \"validate-schema\", \"ProjectDatabase barrier state is invalid\");\n }\n validateSchemaObjects(connection);\n const coordination = currentStatement(connection.db, `SELECT revision,operational_generation,next_writer_sequence,\n writer_ticket_id,barrier_id FROM ne18_coordination_state WHERE singleton=1`).get() as Record<string, SQLOutputValue> | undefined;\n if (coordination === undefined) {\n throw sqliteError(\"record-database-invalid\", \"validate-schema\", \"host coordination generation is missing\");\n }\n const operationalGeneration = decodeText(coordination.operational_generation, \"coordination_state.operational_generation\");\n const storageGeneration = decodeText(metadata.storage_generation, \"record_metadata.storage_generation\");\n if (operationalGeneration !== storageGeneration) {\n throw sqliteError(\"record-database-invalid\", \"validate-schema\", \"operational coordination generation does not match ProjectDatabase\");\n }\n const migration = currentStatement(connection.db, \"SELECT state FROM ne18_migration_state WHERE singleton=1\").get() as Record<string, SQLOutputValue> | undefined;\n if (migration === undefined) {\n throw sqliteError(\"record-database-invalid\", \"validate-schema\", \"ProjectDatabase migration state is missing\");\n }\n const migrationState = decodeText(migration.state, \"migration_state.state\");\n if (migrationState !== \"committed\" && migrationState !== \"ready\") {\n throw sqliteError(\"record-database-invalid\", \"validate-schema\", \"ProjectDatabase migration state is invalid\");\n }\n}\nfunction requireMigrationReady(connection: RecordDatabase): void {\n const row = currentStatement(connection.db, \"SELECT state FROM ne18_migration_state WHERE singleton=1\").get() as Record<string, SQLOutputValue> | undefined;\n if (row === undefined || decodeText(row.state, \"migration_state.state\") !== \"ready\") {\n throw sqliteError(\"record-schema-migration-required\", \"open\", \"ProjectDatabase migration committed but requires Host verification\");\n }\n}\nexport function validateExactSchema(connection: RecordDatabase): void {\n requireSecureDelete(connection.db);\n validateCurrentRecordDomain(connection);\n}\nexport function openRecordWriter(path: string, busyTimeoutMs = 5000): RecordDatabase {\n assertRecordSqliteRuntime();\n assertLegacyRecordAbsent(path);\n assertLegacyCoordinationEntriesAbsent(path);\n const existed = pathExists(path);\n if (existed) {\n const metadata = lstatSync(path);\n if (!metadata.isFile() || metadata.isSymbolicLink()) {\n throw sqliteError(\"record-schema-unsupported\", \"open\", \"ProjectDatabase path is not a regular Host-owned file\");\n }\n }\n mkdirSync(dirname(path), { recursive: true, mode: 0o700 });\n const db = new DatabaseSync(path, {\n allowExtension: false,\n defensive: true,\n enableForeignKeyConstraints: true,\n readBigInts: true,\n timeout: Math.max(0, Math.min(30000, Math.trunc(busyTimeoutMs))),\n });\n const connection: RecordDatabase = { db, path, mode: \"writer\", statements: new Map() };\n try {\n configureCommon(db);\n const objectCount = currentStatement(db, \"SELECT count(*) AS count FROM sqlite_schema\").get() as Record<string, SQLOutputValue>;\n const isEmpty = decodeInteger(objectCount.count, \"sqlite_schema.count\") === 0;\n if (isEmpty && existed) {\n throw sqliteError(\"record-schema-unsupported\", \"open\", \"existing empty SQLite is not a ProjectDatabase\");\n }\n // Never persist WAL mode or acquire a write transaction until an existing\n // file has proved that it is the exact Host-owned ProjectDatabase format.\n if (!isEmpty) {\n validateExistingOperationalSchemaForWriter(connection);\n requireSecureDelete(db);\n }\n else {\n db.exec(\"PRAGMA secure_delete=ON\");\n requireSecureDelete(db);\n }\n db.exec(\"PRAGMA journal_mode=WAL; PRAGMA synchronous=FULL;\");\n let created = false;\n try {\n if (isEmpty) {\n const appliedAt = new Date().toISOString();\n const generation = randomUUID();\n db.exec(\"BEGIN IMMEDIATE\");\n try {\n db.exec(RECORD_SQLITE_BASELINE_SQL);\n currentStatement(db, `INSERT INTO ne18_record_metadata(singleton,format,storage_revision,storage_generation,schema_fingerprint,\n created_at,barrier_state,portable_generation,portable_revision,portable_gate_id,record_payload,record_digest)\n VALUES (1,?,?,?,?,?,'open',NULL,NULL,NULL,NULL,NULL)`).run(RECORD_SQLITE_FORMAT, RECORD_SQLITE_STORAGE_REVISION, generation, RECORD_SQLITE_BASELINE_FINGERPRINT, appliedAt);\n currentStatement(db, `INSERT INTO ne18_coordination_state(singleton,revision,operational_generation,next_writer_sequence)\n VALUES (1,0,?,1)`).run(generation);\n currentStatement(db, `INSERT INTO ne18_migration_state(singleton,state,source_format,source_digest)\n VALUES (1,'ready',NULL,NULL)`).run();\n db.exec(\"COMMIT\");\n created = true;\n }\n catch (cause) {\n if (db.isTransaction)\n db.exec(\"ROLLBACK\");\n throw cause;\n }\n }\n else {\n // Revalidate under the write lock so a concurrent schema change cannot\n // cross the admission boundary between the read probe and this writer.\n validateExistingOperationalSchemaForWriter(connection);\n }\n }\n catch (cause) {\n throw cause;\n }\n // Both the creator and every concurrent loser validate the exact committed\n // bootstrap identity before the connection becomes a writer.\n validateExactSchema(connection);\n requireMigrationReady(connection);\n if (created)\n db.exec(\"PRAGMA wal_checkpoint(PASSIVE)\");\n db.setAuthorizer(writableAuthorizer());\n return connection;\n }\n catch (cause) {\n db.close();\n throw cause;\n }\n}\n/** Host admission path: reject legacy coordination before any in-place migration mutation. */\nexport async function openHostOwnedRecordWriter(path: string, busyTimeoutMs = 5000): Promise<RecordDatabase> {\n assertRecordSqliteRuntime();\n assertLegacyRecordAbsent(path);\n assertLegacyCoordinationEntriesAbsent(path);\n const { migrateHostOwnedProjectDatabase } = await __niceevalDynamicImport(\"./migration.cjs\");\n await migrateHostOwnedProjectDatabase(path, busyTimeoutMs);\n return openRecordWriter(path, busyTimeoutMs);\n}\nexport function openRecordReader(path: string): RecordDatabase {\n assertRecordSqliteRuntime();\n return openRecordReaderAfterRuntimeAdmission(path);\n}\nexport function openImmutableRecordReader(path: string): RecordDatabase {\n assertImmutableRecordReaderRuntime();\n return openRecordReaderAfterRuntimeAdmission(path);\n}\nfunction openRecordReaderAfterRuntimeAdmission(path: string): RecordDatabase {\n assertLegacyRecordAbsent(path);\n const db = new DatabaseSync(path, {\n allowExtension: false,\n defensive: true,\n enableForeignKeyConstraints: true,\n readBigInts: true,\n readOnly: true,\n timeout: 0,\n });\n const connection: RecordDatabase = { db, path, mode: \"reader\", statements: new Map() };\n try {\n configureCommon(db);\n requireSecureDelete(db);\n const legacyTable = db.prepare(`SELECT count(*) AS count FROM sqlite_schema\n WHERE type='table' AND name='record_metadata'`).get() as Record<string, SQLOutputValue>;\n if (decodeInteger(legacyTable.count, \"sqlite_schema.record_metadata\") === 1) {\n const legacy = db.prepare(\"SELECT format FROM record_metadata WHERE singleton=1\").get() as Record<string, SQLOutputValue> | undefined;\n const format = legacy?.format;\n if (format === \"niceeval.project-database/0.15\" || format === \"niceeval.project-database/0.16\") {\n throw sqliteError(\"record-schema-unsupported\", \"open\", `${format} cannot be opened through the current-format operational reader. Finish the old writer and provide a portable Record for read-time migration, or upgrade through the Host-owned project writer`);\n }\n }\n // The main database is opened read-only. These two private TEMP tables are\n // the only writable reader state and are required for bounded Seal sort.\n db.exec(RECORD_SQLITE_PREPARED_SEAL_TEMP_SQL);\n db.setAuthorizer(readerAuthorizer);\n validateExactSchema(connection);\n requireMigrationReady(connection);\n // Full structure and closure validation belongs to import, publication and\n // maintenance. Opening a Host-owned reader must not scan historical payload.\n return connection;\n }\n catch (cause) {\n db.close();\n throw cause;\n }\n}\nexport function openRecordMaintenance(path: string): RecordDatabase {\n assertRecordSqliteRuntime();\n assertLegacyRecordAbsent(path);\n if (!pathExists(path)) {\n throw sqliteError(\"record-database-invalid\", \"open-maintenance\", \"ProjectDatabase does not exist\");\n }\n const metadata = lstatSync(path);\n if (!metadata.isFile() || metadata.isSymbolicLink()) {\n throw sqliteError(\"record-schema-unsupported\", \"open-maintenance\", \"ProjectDatabase path is not a regular Host-owned file\");\n }\n const db = new DatabaseSync(path, {\n allowExtension: false,\n defensive: true,\n enableForeignKeyConstraints: true,\n readBigInts: true,\n timeout: 5000,\n });\n const connection: RecordDatabase = { db, path, mode: \"maintenance\", statements: new Map() };\n try {\n configureCommon(db);\n db.setAuthorizer(writableAuthorizer());\n return connection;\n }\n catch (cause) {\n db.close();\n throw cause;\n }\n}\nexport function closeRecordDatabase(connection: RecordDatabase): void {\n // node:sqlite finalizes every cached statement when its owning connection is\n // closed; StatementSync intentionally exposes no independent finalize API.\n connection.statements.clear();\n if (connection.db.isOpen)\n connection.db.close();\n}\nexport function checkpointRecordDatabase(connection: RecordDatabase): void {\n if (connection.mode !== \"writer\" || !connection.db.isOpen) {\n throw sqliteError(\"record-database-invalid\", \"checkpoint\", \"Record checkpoint requires an open writer\");\n }\n connection.db.exec(\"PRAGMA wal_checkpoint(TRUNCATE)\");\n}\n/** Starts a new operational generation before coordination services acquire it. */\nexport function reopenProjectDatabase(path: string): void {\n const connection = openRecordWriter(path);\n try {\n connection.db.exec(\"BEGIN IMMEDIATE\");\n const row = currentStatement(connection.db, \"SELECT barrier_state FROM ne18_record_metadata WHERE singleton=1\")\n .get() as Record<string, SQLOutputValue> | undefined;\n if (row === undefined || decodeText(row.barrier_state, \"barrier_state\") === \"draining\") {\n throw sqliteError(\"record-command-conflict\", \"reopen\", \"ProjectDatabase portable gate is draining\");\n }\n if (decodeText(row.barrier_state, \"barrier_state\") === \"portable\") {\n const generation = randomUUID();\n currentStatement(connection.db, `UPDATE ne18_record_metadata SET barrier_state='open',storage_generation=?,portable_generation=NULL,\n portable_revision=NULL,portable_gate_id=NULL WHERE singleton=1 AND barrier_state='portable'`).run(generation);\n currentStatement(connection.db, \"UPDATE ne18_coordination_state SET operational_generation=?,revision=revision+1 WHERE singleton=1\")\n .run(generation);\n }\n connection.db.exec(\"COMMIT\");\n }\n catch (cause) {\n if (connection.db.isTransaction)\n connection.db.exec(\"ROLLBACK\");\n throw cause;\n }\n finally {\n closeRecordDatabase(connection);\n }\n}\n/**\n * Closes the project-wide writer admission and proves that the canonical file\n * itself is portable. The first transaction deliberately persists draining;\n * any later failure therefore remains fail-closed for explicit recovery.\n */\nexport function makeProjectDatabasePortable(path: string): boolean {\n const gateId = randomUUID();\n const gateNonce = randomUUID();\n const gateOwner = currentProcessOwnerIdentity(gateId);\n const admissionDrainDeadline = Date.now() + 5000;\n const waitCell = new Int32Array(new SharedArrayBuffer(4));\n let connection = openRecordWriter(path);\n try {\n connection.db.exec(\"BEGIN IMMEDIATE\");\n const metadata = currentStatement(connection.db, \"SELECT barrier_state,portable_gate_id FROM ne18_record_metadata WHERE singleton=1\")\n .get() as Record<string, SQLOutputValue> | undefined;\n if (metadata === undefined) {\n throw sqliteError(\"record-database-invalid\", \"portable-gate\", \"ProjectDatabase barrier is missing\");\n }\n const barrierState = decodeText(metadata.barrier_state, \"barrier_state\");\n if (barrierState === \"portable\") {\n connection.db.exec(\"COMMIT\");\n return true;\n }\n if (barrierState === \"draining\") {\n const previous = currentStatement(connection.db, `SELECT barrier_id,barrier_nonce,barrier_host,barrier_pid,\n barrier_boot_id,barrier_process_start FROM ne18_coordination_state WHERE singleton=1`).get() as Record<string, SQLOutputValue> | undefined;\n if (previous === undefined || previous.barrier_id === null || previous.barrier_nonce === null) {\n throw sqliteError(\"record-database-invalid\", \"portable-gate\", \"draining portable gate has no fenced owner\");\n }\n const previousOwner = {\n ownerId: decodeText(previous.barrier_id, \"barrier_id\"),\n host: decodeText(previous.barrier_host, \"barrier_host\"),\n pid: decodeInteger(previous.barrier_pid, \"barrier_pid\"),\n bootId: decodeText(previous.barrier_boot_id, \"barrier_boot_id\"),\n processStart: decodeText(previous.barrier_process_start, \"barrier_process_start\"),\n };\n const sameProcess = previousOwner.host === gateOwner.host && previousOwner.pid === gateOwner.pid &&\n previousOwner.bootId === gateOwner.bootId && previousOwner.processStart === gateOwner.processStart;\n if (!sameProcess && exactProcessState(previousOwner) !== \"dead\") {\n throw sqliteError(\"record-command-conflict\", \"portable-gate\", \"draining portable gate owner is not proven dead\");\n }\n const fenced = currentStatement(connection.db, `UPDATE ne18_coordination_state SET barrier_id=?,barrier_nonce=?,barrier_host=?,\n barrier_pid=?,barrier_boot_id=?,barrier_process_start=?,barrier_deadline=?,barrier_requested_at=?,\n barrier_lease_expires_at=?,barrier_status='active',barrier_active_at=?,revision=revision+1\n WHERE singleton=1 AND barrier_id=? AND barrier_nonce=?`).run(gateId, gateNonce, gateOwner.host, gateOwner.pid, gateOwner.bootId, gateOwner.processStart, admissionDrainDeadline, Date.now(), admissionDrainDeadline, Date.now(), previous.barrier_id, previous.barrier_nonce);\n const metadataFenced = currentStatement(connection.db, `UPDATE ne18_record_metadata SET portable_gate_id=?\n WHERE singleton=1 AND barrier_state='draining' AND portable_gate_id=?`).run(gateId, metadata.portable_gate_id);\n if (Number(fenced.changes) !== 1 || Number(metadataFenced.changes) !== 1) {\n throw sqliteError(\"record-command-conflict\", \"portable-gate\", \"draining portable gate changed during recovery\");\n }\n }\n else if (barrierState === \"open\") {\n const entered = recordStatement(connection, `UPDATE ne18_record_metadata SET barrier_state='draining',portable_gate_id=?\n WHERE singleton=1 AND barrier_state='open' AND portable_gate_id IS NULL`).run(gateId);\n const established = currentStatement(connection.db, `UPDATE ne18_coordination_state SET barrier_id=?,barrier_nonce=?,barrier_host=?,\n barrier_pid=?,barrier_boot_id=?,barrier_process_start=?,barrier_deadline=?,barrier_requested_at=?,\n barrier_lease_expires_at=?,barrier_status='active',barrier_active_at=?,revision=revision+1\n WHERE singleton=1 AND barrier_id IS NULL`).run(gateId, gateNonce, gateOwner.host, gateOwner.pid, gateOwner.bootId, gateOwner.processStart, admissionDrainDeadline, Date.now(), admissionDrainDeadline, Date.now());\n if (Number(entered.changes) !== 1 || Number(established.changes) !== 1) {\n throw sqliteError(\"record-command-conflict\", \"portable-gate\", \"ProjectDatabase barrier is not open\");\n }\n }\n else {\n throw sqliteError(\"record-database-invalid\", \"portable-gate\", \"ProjectDatabase barrier state is invalid\");\n }\n const admittedActive = currentStatement(connection.db, `SELECT\n (SELECT count(*) FROM ne18_run_resources WHERE terminal_state IS NULL)+\n (SELECT count(*) FROM ne18_invocation_sessions WHERE state IN ('active','recovering'))+\n (SELECT count(*) FROM ne18_case_locks)+\n (SELECT count(*) FROM ne18_teardown_obligations)+\n (SELECT count(*) FROM ne18_shared_state_generations s WHERE state_kind!='free' AND generation=(SELECT max(generation) FROM ne18_shared_state_generations WHERE state_key=s.state_key))+\n (SELECT count(*) FROM ne18_kept_sandbox_operation_leases) AS count`)\n .get() as Record<string, SQLOutputValue>;\n if (decodeInteger(admittedActive.count, \"active_runs\") !== 0) {\n currentStatement(connection.db, `UPDATE ne18_record_metadata SET barrier_state='open',portable_gate_id=NULL\n WHERE singleton=1 AND barrier_state='draining' AND portable_gate_id=?`).run(gateId);\n currentStatement(connection.db, `UPDATE ne18_coordination_state SET barrier_id=NULL,barrier_nonce=NULL,barrier_host=NULL,\n barrier_pid=NULL,barrier_boot_id=NULL,barrier_process_start=NULL,barrier_deadline=NULL,\n barrier_requested_at=NULL,barrier_lease_expires_at=NULL,barrier_status=NULL,barrier_active_at=NULL,\n revision=revision+1 WHERE singleton=1 AND barrier_id=? AND barrier_nonce=?`).run(gateId, gateNonce);\n connection.db.exec(\"COMMIT\");\n return false;\n }\n // The draining barrier rejects new tickets. Queued-but-not-admitted work\n // has no writer authority and is canceled; an already admitted writer or\n // barrier must release its exact identity before the gate continues.\n currentStatement(connection.db, \"DELETE FROM ne18_coordination_tickets\").run();\n connection.db.exec(\"COMMIT\");\n while (true) {\n const coordination = currentStatement(connection.db, `SELECT\n (writer_ticket_id IS NOT NULL OR (barrier_id IS NOT NULL AND barrier_id!=?)) AS active\n FROM ne18_coordination_state WHERE singleton=1`).get(gateId) as Record<string, SQLOutputValue> | undefined;\n if (coordination === undefined) {\n throw sqliteError(\"record-database-invalid\", \"portable-gate\", \"coordination singleton is missing\");\n }\n if (decodeInteger(coordination.active, \"portable_admission\") === 0)\n break;\n if (Date.now() >= admissionDrainDeadline) {\n throw sqliteError(\"record-write-busy\", \"portable-gate\", \"admitted writer did not drain before the portable deadline\");\n }\n Atomics.wait(waitCell, 0, 0, 15);\n }\n connection.db.exec(\"BEGIN IMMEDIATE\");\n const active = currentStatement(connection.db, \"SELECT count(*) AS count FROM ne18_run_resources WHERE terminal_state IS NULL\")\n .get() as Record<string, SQLOutputValue>;\n if (decodeInteger(active.count, \"active_runs\") !== 0) {\n throw sqliteError(\"record-command-conflict\", \"portable-gate\", \"active Run owners prevent portable close\");\n }\n const invocationWork = currentStatement(connection.db, `SELECT\n (SELECT count(*) FROM ne18_invocation_sessions WHERE state IN ('active','recovering'))+\n (SELECT count(*) FROM ne18_invocation_session_queued_attempts)+\n (SELECT count(*) FROM ne18_case_locks) AS count`).get() as Record<string, SQLOutputValue>;\n if (decodeInteger(invocationWork.count, \"invocation_work\") !== 0) {\n throw sqliteError(\"record-command-conflict\", \"portable-gate\", \"invocation coordination work prevents portable close\");\n }\n currentExec(connection.db, `DELETE FROM ne18_runs WHERE status!='sealed' AND NOT EXISTS\n (SELECT 1 FROM ne18_attempt_publications WHERE origin_run_id=ne18_runs.run_id); DELETE FROM ne18_coordination_tickets;`);\n currentStatement(connection.db, `UPDATE ne18_coordination_state SET revision=revision+1,next_writer_sequence=1,\n writer_ticket_id=NULL,writer_sequence=NULL,writer_host=NULL,writer_pid=NULL,writer_deadline=NULL,\n writer_boot_id=NULL,writer_process_start=NULL,\n writer_enqueued_at=NULL,writer_nonce=NULL,writer_admitted_at=NULL,writer_lease_expires_at=NULL,\n barrier_id=NULL,barrier_nonce=NULL,barrier_host=NULL,barrier_pid=NULL,barrier_deadline=NULL,\n barrier_boot_id=NULL,barrier_process_start=NULL,\n barrier_requested_at=NULL,barrier_lease_expires_at=NULL,barrier_status=NULL,barrier_active_at=NULL\n WHERE singleton=1`).run();\n const clock = currentStatement(connection.db, \"SELECT revision FROM ne18_run_publication_clock WHERE singleton=1\")\n .get() as Record<string, SQLOutputValue>;\n const generation = currentStatement(connection.db, \"SELECT storage_generation FROM ne18_record_metadata WHERE singleton=1\")\n .get() as Record<string, SQLOutputValue>;\n currentStatement(connection.db, `UPDATE ne18_record_metadata SET barrier_state='portable',portable_generation=?,portable_revision=?\n WHERE singleton=1 AND barrier_state='draining' AND portable_gate_id=?`).run(decodeText(generation.storage_generation, \"storage_generation\"), decodeInteger(clock.revision, \"publication_revision\"), gateId);\n connection.db.exec(\"COMMIT\");\n checkpointRecordDatabase(connection);\n }\n catch (cause) {\n if (connection.db.isTransaction)\n connection.db.exec(\"ROLLBACK\");\n throw cause;\n }\n finally {\n closeRecordDatabase(connection);\n }\n connection = openRecordReader(path);\n try {\n const state = currentStatement(connection.db, `SELECT barrier_state,portable_generation,portable_revision,storage_generation\n FROM ne18_record_metadata WHERE singleton=1`).get() as Record<string, SQLOutputValue> | undefined;\n const active = currentStatement(connection.db, `SELECT\n (SELECT count(*) FROM ne18_run_resources WHERE terminal_state IS NULL)+\n (SELECT count(*) FROM ne18_runs r WHERE status!='sealed' AND\n (EXISTS (SELECT 1 FROM ne18_attempts a WHERE a.origin_run_id=r.run_id AND a.publication_state!='published') OR\n EXISTS (SELECT 1 FROM ne18_run_resources rr WHERE rr.run_id=r.run_id AND rr.terminal_state IS NULL)))+\n (SELECT count(*) FROM ne18_coordination_tickets) AS count`).get() as Record<string, SQLOutputValue>;\n const invocationWork = currentStatement(connection.db, `SELECT\n (SELECT count(*) FROM ne18_invocation_sessions WHERE state IN ('active','recovering'))+\n (SELECT count(*) FROM ne18_invocation_session_queued_attempts)+\n (SELECT count(*) FROM ne18_case_locks) AS count`).get() as Record<string, SQLOutputValue>;\n const registryWork = currentStatement(connection.db, `SELECT\n (SELECT count(*) FROM ne18_teardown_obligations)+\n (SELECT count(*) FROM ne18_shared_state_generations s WHERE state_kind!='free' AND generation=(SELECT max(generation) FROM ne18_shared_state_generations WHERE state_key=s.state_key))+\n (SELECT count(*) FROM ne18_kept_sandbox_operation_leases) AS count`).get() as Record<string, SQLOutputValue>;\n const coordination = currentStatement(connection.db, `SELECT writer_ticket_id,barrier_id FROM ne18_coordination_state WHERE singleton=1`)\n .get() as Record<string, SQLOutputValue> | undefined;\n const clock = currentStatement(connection.db, \"SELECT revision FROM ne18_run_publication_clock WHERE singleton=1\")\n .get() as Record<string, SQLOutputValue> | undefined;\n if (state === undefined || decodeText(state.barrier_state, \"barrier_state\") !== \"portable\" ||\n decodeText(state.portable_generation, \"portable_generation\") !== decodeText(state.storage_generation, \"storage_generation\") ||\n clock === undefined || decodeInteger(state.portable_revision, \"portable_revision\") !== decodeInteger(clock.revision, \"publication_revision\") ||\n decodeInteger(active.count, \"portable_work\") !== 0 ||\n decodeInteger(invocationWork.count, \"portable_invocation_work\") !== 0 ||\n decodeInteger(registryWork.count, \"portable_registry_work\") !== 0 ||\n coordination === undefined || coordination.writer_ticket_id !== null || coordination.barrier_id !== null) {\n throw sqliteError(\"record-database-invalid\", \"portable-gate\", \"hostile reopen did not prove a portable ProjectDatabase\");\n }\n }\n finally {\n closeRecordDatabase(connection);\n }\n return true;\n}\n/** Invocation-boundary portable operation; terminal session projections remain durable. */\nexport const finalizeInvocationPortable = makeProjectDatabasePortable;\n"]}
|
|
1
|
+
{"version":3,"file":"database.js","sourceRoot":"","sources":["database.ts"],"names":[],"mappings":";;;AA4CA,0CAOC;AAsBD,8DAEC;AAQD,4CAOC;AA6DD,oEAqEC;AAmKD,kDAGC;AACD,4CAoFC;AAED,8DAOC;AACD,4CAGC;AACD,8DAGC;AAuCD,sDA2BC;AACD,kDAMC;AACD,4DAKC;AAED,sDA0BC;AAMD,kEA8KC;AAvwBD,6CAAyC;AACzC,qCAA4D;AAC5D,yCAA6D;AAC7D,6CAA+F;AAC/F,2CAAoI;AACpI,2CAA0C;AAC1C,yCAAkF;AAClF,mGAAsH;AACtH,MAAM,YAAY,GAAG,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAU,CAAC;AAC1C,MAAM,6BAA6B,GAAG,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAU,CAAC;AAC3D,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC;IACxB,uBAAS,CAAC,aAAa;IACvB,uBAAS,CAAC,aAAa;IACvB,uBAAS,CAAC,aAAa;IACvB,uBAAS,CAAC,aAAa;IACvB,uBAAS,CAAC,aAAa;IACvB,uBAAS,CAAC,mBAAmB;IAC7B,uBAAS,CAAC,mBAAmB;IAC7B,uBAAS,CAAC,wBAAwB;IAClC,uBAAS,CAAC,wBAAwB;IAClC,uBAAS,CAAC,0BAA0B;IACpC,uBAAS,CAAC,uBAAuB;IACjC,uBAAS,CAAC,qBAAqB;IAC/B,uBAAS,CAAC,kBAAkB;IAC5B,uBAAS,CAAC,iBAAiB;IA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AC,YAAY,CAAC,KAAK,EAAE,wBAAwB,CAAC,KAAK,CAAC;YACjE,YAAY,KAAK,SAAS,IAAI,YAAY,CAAC,gBAAgB,KAAK,IAAI,IAAI,YAAY,CAAC,UAAU,KAAK,IAAI,EAAE,CAAC;YAC3G,MAAM,IAAA,uBAAW,EAAC,yBAAyB,EAAE,eAAe,EAAE,yDAAyD,CAAC,CAAC;QAC7H,CAAC;IACL,CAAC;YACO,CAAC;QACL,mBAAmB,CAAC,UAAU,CAAC,CAAC;IACpC,CAAC;IACD,OAAO,IAAI,CAAC;AAChB,CAAC;AACD,2FAA2F;AAC9E,QAAA,0BAA0B,GAAG,2BAA2B,CAAC","sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport { lstatSync, mkdirSync, readdirSync } from \"node:fs\";\nimport { basename, dirname, join, resolve } from \"node:path\";\nimport { constants, DatabaseSync, type SQLOutputValue, type StatementSync } from \"node:sqlite\";\nimport { RECORD_SQLITE_BASELINE_FINGERPRINT, RECORD_SQLITE_BASELINE_SQL, RECORD_SQLITE_PREPARED_SEAL_TEMP_SQL, } from \"./schema.ts\";\nimport { sqliteError } from \"./errors.ts\";\nimport { RECORD_SQLITE_FORMAT, RECORD_SQLITE_STORAGE_REVISION } from \"./types.ts\";\nimport { currentProcessOwnerIdentity, exactProcessState } from \"../../coordination/platform/node-process-identity.ts\";\nconst MINIMUM_NODE = [24, 15, 0] as const;\nconst MINIMUM_IMMUTABLE_READER_NODE = [24, 10, 0] as const;\nconst READ_DENIED = new Set([\n constants.SQLITE_ATTACH,\n constants.SQLITE_DETACH,\n constants.SQLITE_INSERT,\n constants.SQLITE_UPDATE,\n constants.SQLITE_DELETE,\n constants.SQLITE_CREATE_INDEX,\n constants.SQLITE_CREATE_TABLE,\n constants.SQLITE_CREATE_TEMP_INDEX,\n constants.SQLITE_CREATE_TEMP_TABLE,\n constants.SQLITE_CREATE_TEMP_TRIGGER,\n constants.SQLITE_CREATE_TEMP_VIEW,\n constants.SQLITE_CREATE_TRIGGER,\n constants.SQLITE_CREATE_VIEW,\n constants.SQLITE_DROP_INDEX,\n constants.SQLITE_DROP_TABLE,\n constants.SQLITE_DROP_TEMP_INDEX,\n constants.SQLITE_DROP_TEMP_TABLE,\n constants.SQLITE_DROP_TEMP_TRIGGER,\n constants.SQLITE_DROP_TEMP_VIEW,\n constants.SQLITE_DROP_TRIGGER,\n constants.SQLITE_DROP_VIEW,\n constants.SQLITE_ALTER_TABLE,\n constants.SQLITE_REINDEX,\n constants.SQLITE_ANALYZE,\n constants.SQLITE_CREATE_VTABLE,\n constants.SQLITE_DROP_VTABLE,\n]);\nexport interface RecordDatabase {\n readonly db: DatabaseSync;\n readonly path: string;\n readonly mode: \"writer\" | \"reader\" | \"maintenance\";\n readonly statements: Map<string, StatementSync>;\n}\nexport function recordStatement(connection: RecordDatabase, sql: string): StatementSync {\n const existing = connection.statements.get(sql);\n if (existing !== undefined)\n return existing;\n const prepared = connection.db.prepare(sql);\n connection.statements.set(sql, prepared);\n return prepared;\n}\nfunction currentStatement(db: DatabaseSync, sql: string): StatementSync {\n return db.prepare(sql);\n}\nfunction currentExec(db: DatabaseSync, sql: string): void {\n db.exec(sql);\n}\nfunction nodeVersionTuple(): readonly number[] {\n return process.versions.node.split(\".\").map((part) => Number(part));\n}\nfunction assertMinimumNode(minimum: readonly number[], capability: string): void {\n const actual = nodeVersionTuple();\n for (let index = 0; index < minimum.length; index += 1) {\n const value = actual[index] ?? 0;\n const required = minimum[index];\n if (value > required)\n return;\n if (value < required) {\n throw sqliteError(\"record-runtime-unsupported\", \"open\", `${capability} requires Node ${minimum.join(\".\")} or newer; received ${process.versions.node}`);\n }\n }\n}\nexport function assertRecordSqliteRuntime(): void {\n assertMinimumNode(MINIMUM_NODE, \"Project Record SQLite\");\n}\nfunction assertImmutableRecordReaderRuntime(): void {\n // The 24.15 floor protects mutable WAL ownership. An already-admitted,\n // immutable generation only needs the defensive read APIs introduced in\n // 24.10 and never opens a writer or checkpoints WAL.\n assertMinimumNode(MINIMUM_IMMUTABLE_READER_NODE, \"Immutable Project Record reader\");\n}\n/** Resolves the one ProjectDatabase while preserving custom non-project roots. */\nexport function recordSqlitePath(recordStorageRoot: string): string {\n if (recordStorageRoot.length === 0)\n throw sqliteError(\"record-database-invalid\", \"locate\", \"Record storage root is empty\");\n const resolvedRoot = resolve(recordStorageRoot);\n return basename(resolvedRoot) === \"record\" && basename(dirname(resolvedRoot)) === \".niceeval\"\n ? join(dirname(resolvedRoot), \"record.sqlite\")\n : join(resolvedRoot, \"record.sqlite\");\n}\nfunction legacyRecordSqlitePath(path: string): string | undefined {\n const parent = dirname(path);\n return basename(path) === \"record.sqlite\" && basename(parent) === \".niceeval\"\n ? join(parent, \"record\", \"record.sqlite\")\n : undefined;\n}\nfunction pathExists(path: string): boolean {\n try {\n lstatSync(path);\n return true;\n }\n catch (cause) {\n if (typeof cause === \"object\" && cause !== null && Reflect.get(cause, \"code\") === \"ENOENT\")\n return false;\n throw sqliteError(\"record-database-invalid\", \"locate\", \"Record path could not be inspected safely\", cause);\n }\n}\nfunction legacyRecordRecovery(): string {\n return \"No automatic migration is available. Keep the original project and its .niceeval directory \" +\n \"for inspection with the original NiceEval version. Stop any old NiceEval processes before \" +\n \"copying project files. To run with this version, use a separate project copy without .niceeval \" +\n \"and rerun the experiment there. Do not delete individual legacy locks or records.\";\n}\n/** Record/0.13 is never opened or silently migrated into ProjectDatabase. */\nfunction assertLegacyRecordAbsent(path: string): void {\n const legacyPath = legacyRecordSqlitePath(path);\n if (legacyPath === undefined)\n return;\n if (!pathExists(legacyPath))\n return;\n throw sqliteError(\"record-schema-unsupported\", \"locate\", `legacy Record/0.13 database is unsupported and blocks ProjectDatabase: ${legacyPath}. ${legacyRecordRecovery()}`);\n}\nfunction assertLegacyCoordinationEntriesAbsent(path: string): void {\n const parent = dirname(path);\n if (basename(path) !== \"record.sqlite\" || basename(parent) !== \".niceeval\")\n return;\n for (const name of [\"locks\", \"sessions\", \"teardowns\", \"shared-state-leases\", \"sandboxes\"] as const) {\n const legacy = join(parent, name);\n if (!pathExists(legacy))\n continue;\n const metadata = lstatSync(legacy);\n if (!metadata.isDirectory() || metadata.isSymbolicLink() || readdirSync(legacy).length > 0) {\n throw sqliteError(\"record-schema-unsupported\", \"locate\", `legacy ${name}/ entries block ProjectDatabase mutation: ${legacy}. ${legacyRecordRecovery()}`);\n }\n }\n}\nexport type ProjectRecordDatabaseInspection = {\n readonly state: \"current\";\n readonly exists: boolean;\n} | {\n readonly state: \"unsupported\";\n readonly format: string;\n} | {\n readonly state: \"foreign\";\n};\n/**\n * Bounded identity probe used only by explicit maintenance. It never creates a\n * database and never treats the pre-ProjectDatabase directory as a migration\n * source.\n */\nexport function inspectProjectRecordDatabase(path: string): ProjectRecordDatabaseInspection {\n assertRecordSqliteRuntime();\n const legacyPath = legacyRecordSqlitePath(path);\n if (legacyPath !== undefined && pathExists(legacyPath)) {\n return Object.freeze({ state: \"unsupported\", format: \"niceeval.record/0.13.x\" });\n }\n if (!pathExists(path))\n return Object.freeze({ state: \"current\", exists: false });\n const metadata = lstatSync(path);\n if (!metadata.isFile() || metadata.isSymbolicLink())\n return Object.freeze({ state: \"foreign\" });\n let connection: RecordDatabase | undefined;\n try {\n connection = openRecordMaintenance(path);\n const currentTable = connection.db.prepare(`SELECT count(*) AS count FROM sqlite_schema\n WHERE type='table' AND name='ne19_record_metadata'`).get() as Record<string, SQLOutputValue>;\n const legacy018Table = connection.db.prepare(`SELECT count(*) AS count FROM sqlite_schema\n WHERE type='table' AND name='ne18_record_metadata'`).get() as Record<string, SQLOutputValue>;\n const legacy017Table = connection.db.prepare(`SELECT count(*) AS count FROM sqlite_schema\n WHERE type='table' AND name='ne_record_metadata'`).get() as Record<string, SQLOutputValue>;\n const legacyTable = connection.db.prepare(`SELECT count(*) AS count FROM sqlite_schema\n WHERE type='table' AND name='record_metadata'`).get() as Record<string, SQLOutputValue>;\n const hasCurrent = decodeInteger(currentTable.count, \"sqlite_schema.record_metadata\") === 1;\n const hasLegacy018 = decodeInteger(legacy018Table.count, \"sqlite_schema.record_metadata\") === 1;\n const hasLegacy017 = decodeInteger(legacy017Table.count, \"sqlite_schema.record_metadata\") === 1;\n const hasLegacy = decodeInteger(legacyTable.count, \"sqlite_schema.record_metadata\") === 1;\n if (Number(hasCurrent) + Number(hasLegacy018) + Number(hasLegacy017) + Number(hasLegacy) !== 1) {\n return Object.freeze({ state: \"foreign\" });\n }\n const metadataTable = hasCurrent ? \"ne19_record_metadata\" : hasLegacy018 ? \"ne18_record_metadata\" : hasLegacy017 ? \"ne_record_metadata\" : \"record_metadata\";\n let row: Record<string, SQLOutputValue> | undefined;\n try {\n row = connection.db.prepare(`SELECT format,storage_revision\n FROM ${metadataTable} WHERE singleton=1`).get() as Record<string, SQLOutputValue> | undefined;\n }\n catch {\n return Object.freeze({ state: \"foreign\" });\n }\n if (row === undefined || typeof row.format !== \"string\")\n return Object.freeze({ state: \"foreign\" });\n if (row.format !== RECORD_SQLITE_FORMAT) {\n return Object.freeze({ state: \"unsupported\", format: row.format });\n }\n let revision: number;\n try {\n revision = decodeInteger(row.storage_revision, \"record_metadata.storage_revision\");\n }\n catch {\n return Object.freeze({ state: \"foreign\" });\n }\n if (revision !== RECORD_SQLITE_STORAGE_REVISION) {\n return Object.freeze({ state: \"unsupported\", format: row.format });\n }\n try {\n validateExactSchema(connection);\n requireMigrationReady(connection);\n return Object.freeze({ state: \"current\", exists: true });\n }\n catch {\n return Object.freeze({ state: \"unsupported\", format: row.format });\n }\n }\n catch {\n return Object.freeze({ state: \"foreign\" });\n }\n finally {\n if (connection !== undefined)\n closeRecordDatabase(connection);\n }\n}\nfunction configureCommon(db: DatabaseSync): void {\n db.enableLoadExtension(false);\n db.enableDefensive(true);\n db.exec(\"PRAGMA secure_delete=ON; PRAGMA foreign_keys=ON; PRAGMA trusted_schema=OFF; PRAGMA mmap_size=0; PRAGMA cache_size=-8192; PRAGMA temp_store=FILE; PRAGMA recursive_triggers=ON;\");\n}\nfunction requireSecureDelete(db: DatabaseSync): void {\n const row = currentStatement(db, \"PRAGMA secure_delete\").get() as Record<string, SQLOutputValue> | undefined;\n if (row === undefined || decodeInteger(row.secure_delete, \"secure_delete\") !== 1) {\n throw sqliteError(\"record-database-invalid\", \"open\", \"ProjectDatabase requires PRAGMA secure_delete=ON\");\n }\n}\nfunction writableAuthorizer() {\n return (action: number, arg1: string | null, arg2: string | null): number => {\n if (action === constants.SQLITE_ATTACH)\n return constants.SQLITE_DENY;\n if (action === constants.SQLITE_DETACH)\n return constants.SQLITE_DENY;\n if (action === constants.SQLITE_FUNCTION && arg2?.toLowerCase() === \"load_extension\")\n return constants.SQLITE_DENY;\n if (action === constants.SQLITE_PRAGMA) {\n const permitted = arg1 === \"busy_timeout\" || arg1 === \"quick_check\" || arg1 === \"foreign_key_check\" || arg1 === \"wal_checkpoint\" || arg1 === \"secure_delete\";\n if (!permitted)\n return constants.SQLITE_DENY;\n }\n return constants.SQLITE_OK;\n };\n}\nfunction readerAuthorizer(action: number, arg1: string | null, arg2: string | null, dbName: string | null): number {\n if (dbName === \"temp\") {\n const preparedTable = arg1 === \"niceeval_prepared_seal_raw\" || arg1 === \"niceeval_prepared_seal_ordered\";\n return preparedTable && (action === constants.SQLITE_READ || action === constants.SQLITE_INSERT || action === constants.SQLITE_DELETE)\n ? constants.SQLITE_OK\n : constants.SQLITE_DENY;\n }\n if (dbName !== null && dbName !== \"main\")\n return constants.SQLITE_DENY;\n if (READ_DENIED.has(action))\n return constants.SQLITE_DENY;\n if (action === constants.SQLITE_PRAGMA && arg1 !== \"quick_check\" && arg1 !== \"foreign_key_check\" && arg1 !== \"secure_delete\")\n return constants.SQLITE_DENY;\n if (action === constants.SQLITE_FUNCTION && arg2?.toLowerCase() === \"load_extension\")\n return constants.SQLITE_DENY;\n return constants.SQLITE_OK;\n}\nfunction schemaRows(db: DatabaseSync): readonly string[] {\n const rows = currentStatement(db, `SELECT type, name, tbl_name, sql FROM sqlite_schema\n WHERE name NOT LIKE 'sqlite_stat%' ORDER BY type, name LIMIT 257`).all() as unknown as readonly Record<string, SQLOutputValue>[];\n if (rows.length > 256)\n throw sqliteError(\"record-database-invalid\", \"validate-schema\", \"database schema exceeds the bounded object allowlist\");\n return rows.map((row) => JSON.stringify([\n decodeText(row.type, \"sqlite_schema.type\"),\n decodeText(row.name, \"sqlite_schema.name\"),\n decodeText(row.tbl_name, \"sqlite_schema.tbl_name\"),\n row.sql === null ? null : normalizeSql(decodeText(row.sql, \"sqlite_schema.sql\")),\n ]));\n}\nfunction normalizeSql(sql: string): string {\n return sql.replace(/\\s+/gu, \" \").replace(/\\s*([(),])\\s*/gu, \"$1\").trim().replace(/;$/u, \"\");\n}\nconst canonicalSchemaRows = new Map<string, readonly string[]>();\nfunction expectedSchemaRows(sql?: string): readonly string[] {\n const key = sql ?? \"bootstrap\";\n const cached = canonicalSchemaRows.get(key);\n if (cached !== undefined)\n return cached;\n const db = new DatabaseSync(\":memory:\", { allowExtension: false, defensive: true, readBigInts: true });\n try {\n db.exec(sql ?? RECORD_SQLITE_BASELINE_SQL);\n const rows = Object.freeze(schemaRows(db));\n canonicalSchemaRows.set(key, rows);\n return rows;\n }\n finally {\n db.close();\n }\n}\nfunction validateSchemaObjects(connection: RecordDatabase, sql?: string): void {\n const actual = schemaRows(connection.db);\n const expected = expectedSchemaRows(sql);\n if (actual.length !== expected.length || actual.some((row, index) => row !== expected[index])) {\n throw sqliteError(\"record-schema-unsupported\", \"validate-schema\", \"database objects do not match the exact Project Record schema allowlist\");\n }\n}\nfunction storageRevision(connection: RecordDatabase): number {\n const row = currentStatement(connection.db, \"SELECT storage_revision FROM ne19_record_metadata WHERE singleton=1\").get() as Record<string, SQLOutputValue> | undefined;\n if (row === undefined)\n throw sqliteError(\"record-schema-unsupported\", \"validate-schema\", \"ProjectDatabase identity is missing\");\n return decodeInteger(row.storage_revision, \"record_metadata.storage_revision\");\n}\nfunction validateExistingOperationalSchemaForWriter(connection: RecordDatabase): void {\n const revision = storageRevision(connection);\n if (revision === RECORD_SQLITE_STORAGE_REVISION) {\n validateExactSchema(connection);\n requireMigrationReady(connection);\n return;\n }\n throw sqliteError(\"record-schema-unsupported\", \"validate-schema\", `record storage revision ${revision} cannot be opened by revision ${RECORD_SQLITE_STORAGE_REVISION}`);\n}\nfunction decodeText(value: SQLOutputValue | undefined, field: string): string {\n if (typeof value !== \"string\")\n throw sqliteError(\"record-database-invalid\", \"decode\", `${field} is not text`);\n return value;\n}\nfunction decodeInteger(value: SQLOutputValue | undefined, field: string): number {\n const numeric = typeof value === \"bigint\" ? Number(value) : value;\n if (typeof numeric !== \"number\" || !Number.isSafeInteger(numeric)) {\n throw sqliteError(\"record-database-invalid\", \"decode\", `${field} is not a safe integer`);\n }\n return numeric;\n}\nfunction validateCurrentRecordDomain(connection: RecordDatabase): void {\n let metadata: Record<string, SQLOutputValue> | undefined;\n try {\n metadata = currentStatement(connection.db, `SELECT format,storage_revision,storage_generation,schema_fingerprint,barrier_state\n FROM ne19_record_metadata WHERE singleton=1`).get() as Record<string, SQLOutputValue> | undefined;\n }\n catch (cause) {\n throw sqliteError(\"record-schema-unsupported\", \"validate-schema\", \"database does not expose the ProjectDatabase identity\", cause);\n }\n if (metadata === undefined) {\n throw sqliteError(\"record-schema-unsupported\", \"validate-schema\", \"ProjectDatabase identity is missing\");\n }\n if (decodeText(metadata.format, \"record_metadata.format\") !== RECORD_SQLITE_FORMAT) {\n throw sqliteError(\"record-schema-unsupported\", \"validate-schema\", \"record format is unsupported\");\n }\n const revision = decodeInteger(metadata.storage_revision, \"record_metadata.storage_revision\");\n if (revision !== RECORD_SQLITE_STORAGE_REVISION) {\n throw sqliteError(\"record-schema-unsupported\", \"validate-schema\", `record storage revision ${revision} is not ${RECORD_SQLITE_STORAGE_REVISION}`);\n }\n if (decodeText(metadata.schema_fingerprint, \"record_metadata.schema_fingerprint\") !== RECORD_SQLITE_BASELINE_FINGERPRINT) {\n throw sqliteError(\"record-schema-unsupported\", \"validate-schema\", \"ProjectDatabase baseline fingerprint is unsupported\");\n }\n const barrierState = decodeText(metadata.barrier_state, \"record_metadata.barrier_state\");\n if (barrierState !== \"open\" && barrierState !== \"draining\" && barrierState !== \"portable\") {\n throw sqliteError(\"record-database-invalid\", \"validate-schema\", \"ProjectDatabase barrier state is invalid\");\n }\n validateSchemaObjects(connection);\n const coordination = currentStatement(connection.db, `SELECT revision,operational_generation,next_writer_sequence,\n writer_ticket_id,barrier_id FROM ne19_coordination_state WHERE singleton=1`).get() as Record<string, SQLOutputValue> | undefined;\n if (coordination === undefined) {\n throw sqliteError(\"record-database-invalid\", \"validate-schema\", \"host coordination generation is missing\");\n }\n const operationalGeneration = decodeText(coordination.operational_generation, \"coordination_state.operational_generation\");\n const storageGeneration = decodeText(metadata.storage_generation, \"record_metadata.storage_generation\");\n if (operationalGeneration !== storageGeneration) {\n throw sqliteError(\"record-database-invalid\", \"validate-schema\", \"operational coordination generation does not match ProjectDatabase\");\n }\n const migration = currentStatement(connection.db, \"SELECT state FROM ne19_migration_state WHERE singleton=1\").get() as Record<string, SQLOutputValue> | undefined;\n if (migration === undefined) {\n throw sqliteError(\"record-database-invalid\", \"validate-schema\", \"ProjectDatabase migration state is missing\");\n }\n const migrationState = decodeText(migration.state, \"migration_state.state\");\n if (migrationState !== \"committed\" && migrationState !== \"ready\") {\n throw sqliteError(\"record-database-invalid\", \"validate-schema\", \"ProjectDatabase migration state is invalid\");\n }\n}\nfunction requireMigrationReady(connection: RecordDatabase): void {\n const row = currentStatement(connection.db, \"SELECT state FROM ne19_migration_state WHERE singleton=1\").get() as Record<string, SQLOutputValue> | undefined;\n if (row === undefined || decodeText(row.state, \"migration_state.state\") !== \"ready\") {\n throw sqliteError(\"record-schema-migration-required\", \"open\", \"ProjectDatabase migration committed but requires Host verification\");\n }\n}\nexport function validateExactSchema(connection: RecordDatabase): void {\n requireSecureDelete(connection.db);\n validateCurrentRecordDomain(connection);\n}\nexport function openRecordWriter(path: string, busyTimeoutMs = 5000): RecordDatabase {\n assertRecordSqliteRuntime();\n assertLegacyRecordAbsent(path);\n assertLegacyCoordinationEntriesAbsent(path);\n const existed = pathExists(path);\n if (existed) {\n const metadata = lstatSync(path);\n if (!metadata.isFile() || metadata.isSymbolicLink()) {\n throw sqliteError(\"record-schema-unsupported\", \"open\", \"ProjectDatabase path is not a regular Host-owned file\");\n }\n }\n mkdirSync(dirname(path), { recursive: true, mode: 0o700 });\n const db = new DatabaseSync(path, {\n allowExtension: false,\n defensive: true,\n enableForeignKeyConstraints: true,\n readBigInts: true,\n timeout: Math.max(0, Math.min(30000, Math.trunc(busyTimeoutMs))),\n });\n const connection: RecordDatabase = { db, path, mode: \"writer\", statements: new Map() };\n try {\n configureCommon(db);\n const objectCount = currentStatement(db, \"SELECT count(*) AS count FROM sqlite_schema\").get() as Record<string, SQLOutputValue>;\n const isEmpty = decodeInteger(objectCount.count, \"sqlite_schema.count\") === 0;\n if (isEmpty && existed) {\n throw sqliteError(\"record-schema-unsupported\", \"open\", \"existing empty SQLite is not a ProjectDatabase\");\n }\n // Never persist WAL mode or acquire a write transaction until an existing\n // file has proved that it is the exact Host-owned ProjectDatabase format.\n if (!isEmpty) {\n validateExistingOperationalSchemaForWriter(connection);\n requireSecureDelete(db);\n }\n else {\n db.exec(\"PRAGMA secure_delete=ON\");\n requireSecureDelete(db);\n }\n db.exec(\"PRAGMA journal_mode=WAL; PRAGMA synchronous=FULL;\");\n let created = false;\n try {\n if (isEmpty) {\n const appliedAt = new Date().toISOString();\n const generation = randomUUID();\n db.exec(\"BEGIN IMMEDIATE\");\n try {\n db.exec(RECORD_SQLITE_BASELINE_SQL);\n currentStatement(db, `INSERT INTO ne19_record_metadata(singleton,format,storage_revision,storage_generation,schema_fingerprint,\n created_at,barrier_state,portable_generation,portable_revision,portable_gate_id,record_payload,record_digest)\n VALUES (1,?,?,?,?,?,'open',NULL,NULL,NULL,NULL,NULL)`).run(RECORD_SQLITE_FORMAT, RECORD_SQLITE_STORAGE_REVISION, generation, RECORD_SQLITE_BASELINE_FINGERPRINT, appliedAt);\n currentStatement(db, `INSERT INTO ne19_coordination_state(singleton,revision,operational_generation,next_writer_sequence)\n VALUES (1,0,?,1)`).run(generation);\n currentStatement(db, `INSERT INTO ne19_migration_state(singleton,state,source_format,source_digest)\n VALUES (1,'ready',NULL,NULL)`).run();\n db.exec(\"COMMIT\");\n created = true;\n }\n catch (cause) {\n if (db.isTransaction)\n db.exec(\"ROLLBACK\");\n throw cause;\n }\n }\n else {\n // Revalidate under the write lock so a concurrent schema change cannot\n // cross the admission boundary between the read probe and this writer.\n validateExistingOperationalSchemaForWriter(connection);\n }\n }\n catch (cause) {\n throw cause;\n }\n // Both the creator and every concurrent loser validate the exact committed\n // bootstrap identity before the connection becomes a writer.\n validateExactSchema(connection);\n requireMigrationReady(connection);\n if (created)\n db.exec(\"PRAGMA wal_checkpoint(PASSIVE)\");\n db.setAuthorizer(writableAuthorizer());\n return connection;\n }\n catch (cause) {\n db.close();\n throw cause;\n }\n}\n/** Host admission path: reject legacy coordination before any in-place migration mutation. */\nexport async function openHostOwnedRecordWriter(path: string, busyTimeoutMs = 5000): Promise<RecordDatabase> {\n assertRecordSqliteRuntime();\n assertLegacyRecordAbsent(path);\n assertLegacyCoordinationEntriesAbsent(path);\n const { migrateHostOwnedProjectDatabase } = await __niceevalDynamicImport(\"./migration.cjs\");\n await migrateHostOwnedProjectDatabase(path, busyTimeoutMs);\n return openRecordWriter(path, busyTimeoutMs);\n}\nexport function openRecordReader(path: string): RecordDatabase {\n assertRecordSqliteRuntime();\n return openRecordReaderAfterRuntimeAdmission(path);\n}\nexport function openImmutableRecordReader(path: string): RecordDatabase {\n assertImmutableRecordReaderRuntime();\n return openRecordReaderAfterRuntimeAdmission(path);\n}\nfunction openRecordReaderAfterRuntimeAdmission(path: string): RecordDatabase {\n assertLegacyRecordAbsent(path);\n const db = new DatabaseSync(path, {\n allowExtension: false,\n defensive: true,\n enableForeignKeyConstraints: true,\n readBigInts: true,\n readOnly: true,\n timeout: 0,\n });\n const connection: RecordDatabase = { db, path, mode: \"reader\", statements: new Map() };\n try {\n configureCommon(db);\n requireSecureDelete(db);\n const legacyTable = db.prepare(`SELECT count(*) AS count FROM sqlite_schema\n WHERE type='table' AND name='record_metadata'`).get() as Record<string, SQLOutputValue>;\n if (decodeInteger(legacyTable.count, \"sqlite_schema.record_metadata\") === 1) {\n const legacy = db.prepare(\"SELECT format FROM record_metadata WHERE singleton=1\").get() as Record<string, SQLOutputValue> | undefined;\n const format = legacy?.format;\n if (format === \"niceeval.project-database/0.15\" || format === \"niceeval.project-database/0.16\") {\n throw sqliteError(\"record-schema-unsupported\", \"open\", `${format} cannot be opened through the current-format operational reader. Finish the old writer and provide a portable Record for read-time migration, or upgrade through the Host-owned project writer`);\n }\n }\n // The main database is opened read-only. These two private TEMP tables are\n // the only writable reader state and are required for bounded Seal sort.\n db.exec(RECORD_SQLITE_PREPARED_SEAL_TEMP_SQL);\n db.setAuthorizer(readerAuthorizer);\n validateExactSchema(connection);\n requireMigrationReady(connection);\n // Full structure and closure validation belongs to import, publication and\n // maintenance. Opening a Host-owned reader must not scan historical payload.\n return connection;\n }\n catch (cause) {\n db.close();\n throw cause;\n }\n}\nexport function openRecordMaintenance(path: string): RecordDatabase {\n assertRecordSqliteRuntime();\n assertLegacyRecordAbsent(path);\n if (!pathExists(path)) {\n throw sqliteError(\"record-database-invalid\", \"open-maintenance\", \"ProjectDatabase does not exist\");\n }\n const metadata = lstatSync(path);\n if (!metadata.isFile() || metadata.isSymbolicLink()) {\n throw sqliteError(\"record-schema-unsupported\", \"open-maintenance\", \"ProjectDatabase path is not a regular Host-owned file\");\n }\n const db = new DatabaseSync(path, {\n allowExtension: false,\n defensive: true,\n enableForeignKeyConstraints: true,\n readBigInts: true,\n timeout: 5000,\n });\n const connection: RecordDatabase = { db, path, mode: \"maintenance\", statements: new Map() };\n try {\n configureCommon(db);\n db.setAuthorizer(writableAuthorizer());\n return connection;\n }\n catch (cause) {\n db.close();\n throw cause;\n }\n}\nexport function closeRecordDatabase(connection: RecordDatabase): void {\n // node:sqlite finalizes every cached statement when its owning connection is\n // closed; StatementSync intentionally exposes no independent finalize API.\n connection.statements.clear();\n if (connection.db.isOpen)\n connection.db.close();\n}\nexport function checkpointRecordDatabase(connection: RecordDatabase): void {\n if (connection.mode !== \"writer\" || !connection.db.isOpen) {\n throw sqliteError(\"record-database-invalid\", \"checkpoint\", \"Record checkpoint requires an open writer\");\n }\n connection.db.exec(\"PRAGMA wal_checkpoint(TRUNCATE)\");\n}\n/** Starts a new operational generation before coordination services acquire it. */\nexport function reopenProjectDatabase(path: string): void {\n const connection = openRecordWriter(path);\n try {\n connection.db.exec(\"BEGIN IMMEDIATE\");\n const row = currentStatement(connection.db, \"SELECT barrier_state FROM ne19_record_metadata WHERE singleton=1\")\n .get() as Record<string, SQLOutputValue> | undefined;\n if (row === undefined || decodeText(row.barrier_state, \"barrier_state\") === \"draining\") {\n throw sqliteError(\"record-command-conflict\", \"reopen\", \"ProjectDatabase portable gate is draining\");\n }\n if (decodeText(row.barrier_state, \"barrier_state\") === \"portable\") {\n const generation = randomUUID();\n currentStatement(connection.db, `UPDATE ne19_record_metadata SET barrier_state='open',storage_generation=?,portable_generation=NULL,\n portable_revision=NULL,portable_gate_id=NULL WHERE singleton=1 AND barrier_state='portable'`).run(generation);\n currentStatement(connection.db, \"UPDATE ne19_coordination_state SET operational_generation=?,revision=revision+1 WHERE singleton=1\")\n .run(generation);\n }\n connection.db.exec(\"COMMIT\");\n }\n catch (cause) {\n if (connection.db.isTransaction)\n connection.db.exec(\"ROLLBACK\");\n throw cause;\n }\n finally {\n closeRecordDatabase(connection);\n }\n}\n/**\n * Closes the project-wide writer admission and proves that the canonical file\n * itself is portable. The first transaction deliberately persists draining;\n * any later failure therefore remains fail-closed for explicit recovery.\n */\nexport function makeProjectDatabasePortable(path: string): boolean {\n const gateId = randomUUID();\n const gateNonce = randomUUID();\n const gateOwner = currentProcessOwnerIdentity(gateId);\n const admissionDrainDeadline = Date.now() + 5000;\n const waitCell = new Int32Array(new SharedArrayBuffer(4));\n let connection = openRecordWriter(path);\n try {\n connection.db.exec(\"BEGIN IMMEDIATE\");\n const metadata = currentStatement(connection.db, \"SELECT barrier_state,portable_gate_id FROM ne19_record_metadata WHERE singleton=1\")\n .get() as Record<string, SQLOutputValue> | undefined;\n if (metadata === undefined) {\n throw sqliteError(\"record-database-invalid\", \"portable-gate\", \"ProjectDatabase barrier is missing\");\n }\n const barrierState = decodeText(metadata.barrier_state, \"barrier_state\");\n if (barrierState === \"portable\") {\n connection.db.exec(\"COMMIT\");\n return true;\n }\n if (barrierState === \"draining\") {\n const previous = currentStatement(connection.db, `SELECT barrier_id,barrier_nonce,barrier_host,barrier_pid,\n barrier_boot_id,barrier_process_start FROM ne19_coordination_state WHERE singleton=1`).get() as Record<string, SQLOutputValue> | undefined;\n if (previous === undefined || previous.barrier_id === null || previous.barrier_nonce === null) {\n throw sqliteError(\"record-database-invalid\", \"portable-gate\", \"draining portable gate has no fenced owner\");\n }\n const previousOwner = {\n ownerId: decodeText(previous.barrier_id, \"barrier_id\"),\n host: decodeText(previous.barrier_host, \"barrier_host\"),\n pid: decodeInteger(previous.barrier_pid, \"barrier_pid\"),\n bootId: decodeText(previous.barrier_boot_id, \"barrier_boot_id\"),\n processStart: decodeText(previous.barrier_process_start, \"barrier_process_start\"),\n };\n const sameProcess = previousOwner.host === gateOwner.host && previousOwner.pid === gateOwner.pid &&\n previousOwner.bootId === gateOwner.bootId && previousOwner.processStart === gateOwner.processStart;\n if (!sameProcess && exactProcessState(previousOwner) !== \"dead\") {\n throw sqliteError(\"record-command-conflict\", \"portable-gate\", \"draining portable gate owner is not proven dead\");\n }\n const fenced = currentStatement(connection.db, `UPDATE ne19_coordination_state SET barrier_id=?,barrier_nonce=?,barrier_host=?,\n barrier_pid=?,barrier_boot_id=?,barrier_process_start=?,barrier_deadline=?,barrier_requested_at=?,\n barrier_lease_expires_at=?,barrier_status='active',barrier_active_at=?,revision=revision+1\n WHERE singleton=1 AND barrier_id=? AND barrier_nonce=?`).run(gateId, gateNonce, gateOwner.host, gateOwner.pid, gateOwner.bootId, gateOwner.processStart, admissionDrainDeadline, Date.now(), admissionDrainDeadline, Date.now(), previous.barrier_id, previous.barrier_nonce);\n const metadataFenced = currentStatement(connection.db, `UPDATE ne19_record_metadata SET portable_gate_id=?\n WHERE singleton=1 AND barrier_state='draining' AND portable_gate_id=?`).run(gateId, metadata.portable_gate_id);\n if (Number(fenced.changes) !== 1 || Number(metadataFenced.changes) !== 1) {\n throw sqliteError(\"record-command-conflict\", \"portable-gate\", \"draining portable gate changed during recovery\");\n }\n }\n else if (barrierState === \"open\") {\n const entered = recordStatement(connection, `UPDATE ne19_record_metadata SET barrier_state='draining',portable_gate_id=?\n WHERE singleton=1 AND barrier_state='open' AND portable_gate_id IS NULL`).run(gateId);\n const established = currentStatement(connection.db, `UPDATE ne19_coordination_state SET barrier_id=?,barrier_nonce=?,barrier_host=?,\n barrier_pid=?,barrier_boot_id=?,barrier_process_start=?,barrier_deadline=?,barrier_requested_at=?,\n barrier_lease_expires_at=?,barrier_status='active',barrier_active_at=?,revision=revision+1\n WHERE singleton=1 AND barrier_id IS NULL`).run(gateId, gateNonce, gateOwner.host, gateOwner.pid, gateOwner.bootId, gateOwner.processStart, admissionDrainDeadline, Date.now(), admissionDrainDeadline, Date.now());\n if (Number(entered.changes) !== 1 || Number(established.changes) !== 1) {\n throw sqliteError(\"record-command-conflict\", \"portable-gate\", \"ProjectDatabase barrier is not open\");\n }\n }\n else {\n throw sqliteError(\"record-database-invalid\", \"portable-gate\", \"ProjectDatabase barrier state is invalid\");\n }\n const admittedActive = currentStatement(connection.db, `SELECT\n (SELECT count(*) FROM ne19_run_resources WHERE terminal_state IS NULL)+\n (SELECT count(*) FROM ne19_invocation_sessions WHERE state IN ('active','recovering'))+\n (SELECT count(*) FROM ne19_case_locks)+\n (SELECT count(*) FROM ne19_teardown_obligations)+\n (SELECT count(*) FROM ne19_shared_state_generations s WHERE state_kind!='free' AND generation=(SELECT max(generation) FROM ne19_shared_state_generations WHERE state_key=s.state_key))+\n (SELECT count(*) FROM ne19_kept_sandbox_operation_leases) AS count`)\n .get() as Record<string, SQLOutputValue>;\n if (decodeInteger(admittedActive.count, \"active_runs\") !== 0) {\n currentStatement(connection.db, `UPDATE ne19_record_metadata SET barrier_state='open',portable_gate_id=NULL\n WHERE singleton=1 AND barrier_state='draining' AND portable_gate_id=?`).run(gateId);\n currentStatement(connection.db, `UPDATE ne19_coordination_state SET barrier_id=NULL,barrier_nonce=NULL,barrier_host=NULL,\n barrier_pid=NULL,barrier_boot_id=NULL,barrier_process_start=NULL,barrier_deadline=NULL,\n barrier_requested_at=NULL,barrier_lease_expires_at=NULL,barrier_status=NULL,barrier_active_at=NULL,\n revision=revision+1 WHERE singleton=1 AND barrier_id=? AND barrier_nonce=?`).run(gateId, gateNonce);\n connection.db.exec(\"COMMIT\");\n return false;\n }\n // The draining barrier rejects new tickets. Queued-but-not-admitted work\n // has no writer authority and is canceled; an already admitted writer or\n // barrier must release its exact identity before the gate continues.\n currentStatement(connection.db, \"DELETE FROM ne19_coordination_tickets\").run();\n connection.db.exec(\"COMMIT\");\n while (true) {\n const coordination = currentStatement(connection.db, `SELECT\n (writer_ticket_id IS NOT NULL OR (barrier_id IS NOT NULL AND barrier_id!=?)) AS active\n FROM ne19_coordination_state WHERE singleton=1`).get(gateId) as Record<string, SQLOutputValue> | undefined;\n if (coordination === undefined) {\n throw sqliteError(\"record-database-invalid\", \"portable-gate\", \"coordination singleton is missing\");\n }\n if (decodeInteger(coordination.active, \"portable_admission\") === 0)\n break;\n if (Date.now() >= admissionDrainDeadline) {\n throw sqliteError(\"record-write-busy\", \"portable-gate\", \"admitted writer did not drain before the portable deadline\");\n }\n Atomics.wait(waitCell, 0, 0, 15);\n }\n connection.db.exec(\"BEGIN IMMEDIATE\");\n const active = currentStatement(connection.db, \"SELECT count(*) AS count FROM ne19_run_resources WHERE terminal_state IS NULL\")\n .get() as Record<string, SQLOutputValue>;\n if (decodeInteger(active.count, \"active_runs\") !== 0) {\n throw sqliteError(\"record-command-conflict\", \"portable-gate\", \"active Run owners prevent portable close\");\n }\n const invocationWork = currentStatement(connection.db, `SELECT\n (SELECT count(*) FROM ne19_invocation_sessions WHERE state IN ('active','recovering'))+\n (SELECT count(*) FROM ne19_invocation_session_queued_attempts)+\n (SELECT count(*) FROM ne19_case_locks) AS count`).get() as Record<string, SQLOutputValue>;\n if (decodeInteger(invocationWork.count, \"invocation_work\") !== 0) {\n throw sqliteError(\"record-command-conflict\", \"portable-gate\", \"invocation coordination work prevents portable close\");\n }\n currentExec(connection.db, `DELETE FROM ne19_runs WHERE status!='sealed' AND NOT EXISTS\n (SELECT 1 FROM ne19_attempt_publications WHERE origin_run_id=ne19_runs.run_id); DELETE FROM ne19_coordination_tickets;`);\n currentStatement(connection.db, `UPDATE ne19_coordination_state SET revision=revision+1,next_writer_sequence=1,\n writer_ticket_id=NULL,writer_sequence=NULL,writer_host=NULL,writer_pid=NULL,writer_deadline=NULL,\n writer_boot_id=NULL,writer_process_start=NULL,\n writer_enqueued_at=NULL,writer_nonce=NULL,writer_admitted_at=NULL,writer_lease_expires_at=NULL,\n barrier_id=NULL,barrier_nonce=NULL,barrier_host=NULL,barrier_pid=NULL,barrier_deadline=NULL,\n barrier_boot_id=NULL,barrier_process_start=NULL,\n barrier_requested_at=NULL,barrier_lease_expires_at=NULL,barrier_status=NULL,barrier_active_at=NULL\n WHERE singleton=1`).run();\n const clock = currentStatement(connection.db, \"SELECT revision FROM ne19_run_publication_clock WHERE singleton=1\")\n .get() as Record<string, SQLOutputValue>;\n const generation = currentStatement(connection.db, \"SELECT storage_generation FROM ne19_record_metadata WHERE singleton=1\")\n .get() as Record<string, SQLOutputValue>;\n currentStatement(connection.db, `UPDATE ne19_record_metadata SET barrier_state='portable',portable_generation=?,portable_revision=?\n WHERE singleton=1 AND barrier_state='draining' AND portable_gate_id=?`).run(decodeText(generation.storage_generation, \"storage_generation\"), decodeInteger(clock.revision, \"publication_revision\"), gateId);\n connection.db.exec(\"COMMIT\");\n checkpointRecordDatabase(connection);\n }\n catch (cause) {\n if (connection.db.isTransaction)\n connection.db.exec(\"ROLLBACK\");\n throw cause;\n }\n finally {\n closeRecordDatabase(connection);\n }\n connection = openRecordReader(path);\n try {\n const state = currentStatement(connection.db, `SELECT barrier_state,portable_generation,portable_revision,storage_generation\n FROM ne19_record_metadata WHERE singleton=1`).get() as Record<string, SQLOutputValue> | undefined;\n const active = currentStatement(connection.db, `SELECT\n (SELECT count(*) FROM ne19_run_resources WHERE terminal_state IS NULL)+\n (SELECT count(*) FROM ne19_runs r WHERE status!='sealed' AND\n (EXISTS (SELECT 1 FROM ne19_attempts a WHERE a.origin_run_id=r.run_id AND a.publication_state!='published') OR\n EXISTS (SELECT 1 FROM ne19_run_resources rr WHERE rr.run_id=r.run_id AND rr.terminal_state IS NULL)))+\n (SELECT count(*) FROM ne19_coordination_tickets) AS count`).get() as Record<string, SQLOutputValue>;\n const invocationWork = currentStatement(connection.db, `SELECT\n (SELECT count(*) FROM ne19_invocation_sessions WHERE state IN ('active','recovering'))+\n (SELECT count(*) FROM ne19_invocation_session_queued_attempts)+\n (SELECT count(*) FROM ne19_case_locks) AS count`).get() as Record<string, SQLOutputValue>;\n const registryWork = currentStatement(connection.db, `SELECT\n (SELECT count(*) FROM ne19_teardown_obligations)+\n (SELECT count(*) FROM ne19_shared_state_generations s WHERE state_kind!='free' AND generation=(SELECT max(generation) FROM ne19_shared_state_generations WHERE state_key=s.state_key))+\n (SELECT count(*) FROM ne19_kept_sandbox_operation_leases) AS count`).get() as Record<string, SQLOutputValue>;\n const coordination = currentStatement(connection.db, `SELECT writer_ticket_id,barrier_id FROM ne19_coordination_state WHERE singleton=1`)\n .get() as Record<string, SQLOutputValue> | undefined;\n const clock = currentStatement(connection.db, \"SELECT revision FROM ne19_run_publication_clock WHERE singleton=1\")\n .get() as Record<string, SQLOutputValue> | undefined;\n if (state === undefined || decodeText(state.barrier_state, \"barrier_state\") !== \"portable\" ||\n decodeText(state.portable_generation, \"portable_generation\") !== decodeText(state.storage_generation, \"storage_generation\") ||\n clock === undefined || decodeInteger(state.portable_revision, \"portable_revision\") !== decodeInteger(clock.revision, \"publication_revision\") ||\n decodeInteger(active.count, \"portable_work\") !== 0 ||\n decodeInteger(invocationWork.count, \"portable_invocation_work\") !== 0 ||\n decodeInteger(registryWork.count, \"portable_registry_work\") !== 0 ||\n coordination === undefined || coordination.writer_ticket_id !== null || coordination.barrier_id !== null) {\n throw sqliteError(\"record-database-invalid\", \"portable-gate\", \"hostile reopen did not prove a portable ProjectDatabase\");\n }\n }\n finally {\n closeRecordDatabase(connection);\n }\n return true;\n}\n/** Invocation-boundary portable operation; terminal session projections remain durable. */\nexport const finalizeInvocationPortable = makeProjectDatabasePortable;\n"]}
|
|
@@ -108,7 +108,9 @@ function openPinnedRecordReadSession(path, kind, deadlineEpochMs) {
|
|
|
108
108
|
cutoff: Object.freeze({ ...page.cutoff, identity: cutoffIdentity }),
|
|
109
109
|
});
|
|
110
110
|
}),
|
|
111
|
-
|
|
111
|
+
findSourceBarrierCandidate: (request) => readBounded("find-source-barrier", () => (0, storage_ts_1.findSourceBarrierCandidate)(connection, request, publicationCutoff.revision)),
|
|
112
|
+
findAcceptedAttemptRunIds: (request) => readBounded("find-accepted-attempt-runs", () => (0, storage_ts_1.findAcceptedAttemptRunIds)(connection, request, publicationCutoff.revision)),
|
|
113
|
+
findAttemptLocatorCandidates: (locator, maximumCandidateRuns, includeTargets = true) => readBounded("find-attempt-locator", () => (0, storage_ts_1.findAttemptLocatorCandidates)(connection, locator, maximumCandidateRuns, includeTargets)),
|
|
112
114
|
readSealedRunDocument: (runId) => readBounded("read-sealed-run-document", () => (0, storage_ts_1.readSealedRunDocument)(connection, runId)),
|
|
113
115
|
readSealedRunCore: (runId, lazyAttachments = false) => readBounded("read-sealed-run-core", () => (0, storage_ts_1.readSealedRunCore)(connection, runId, lazyAttachments
|
|
114
116
|
? (read) => readBounded("read-sealed-attachment", read)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;AAgHA,4EAEC;AAgBD,wEAEC;AASD,oDAEC;AACD,wDAEC;AACD,4DAEC;AACD,oEAEC;AACD,wDAEC;AACD,sDAEC;AACD,8CAEC;AACD,oDAEC;AACD,wDASC;AA9KD,mCAAgC;AAChC,2EAA+F;AAC/F,+CAAkN;AAWzM,6GAXqB,0CAA4B,OAWrB;AAAoB,sGAX8B,mCAAqB,OAW9B;AAAvC,iGAXuE,8BAAgB,OAWvE;AAVvD,2CAA0C;AAC1C,6CAAolB;AACplB,yCAAsQ;AACtQ,2DAA+I;AAC/I,2DAAwE;AAExE,yCAAmG;AAA1F,oHAAA,uBAAuB,OAAA;AAAE,8GAAA,iBAAiB,OAAA;AACnD,yEAAyJ;AAAhJ,iIAAA,oBAAoB,OAAA;AAAE,qIAAA,wBAAwB,OAAA;AACvD,yCAA4E;AAAnE,8GAAA,iBAAiB,OAAA;AAC1B,uCAAi8C;AAAx7C,qHAAA,yBAAyB,OAAA;AAAE,gHAAA,oBAAoB,OAAA;AAAE,2HAAA,+BAA+B,OAAA;AAAE,0HAAA,8BAA8B,OAAA;AAAE,uHAAA,2BAA2B,OAAA;AAAE,uHAAA,2BAA2B,OAAA;AAAE,wHAAA,4BAA4B,OAAA;AAAE,6HAAA,iCAAiC,OAAA;AAAE,6HAAA,iCAAiC,OAAA;AAAE,gIAAA,oCAAoC,OAAA;AAAE,0HAAA,8BAA8B,OAAA;AAoB7V,SAAS,2BAA2B,CAAC,IAAY,EAAE,IAAwC,EAAE,eAAuB;IAChH,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,eAAe,CAAC,IAAI,eAAe,IAAI,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;QAC1E,MAAM,IAAA,uBAAW,EAAC,gCAAgC,EAAE,mBAAmB,EAAE,oD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ACvD,CAAC;YACO,CAAC;QACL,IAAA,iCAAmB,EAAC,UAAU,CAAC,CAAC;IACpC,CAAC;AACL,CAAC","sourcesContent":["import { Effect } from \"effect\";\nimport { projectRecordReadMode, startExternalRecordImport } from \"./external-record-import.ts\";\nimport { closeRecordDatabase, inspectProjectRecordDatabase, openImmutableRecordReader, reopenProjectDatabase, recordSqlitePath, validateExactSchema, type ProjectRecordDatabaseInspection, } from \"./database.ts\";\nimport { sqliteError } from \"./errors.ts\";\nimport { findAttemptLocatorCandidates as findAttemptLocatorCandidatesOnConnection, findExperimentRunIds as findExperimentRunIdsOnConnection, readSealedRunCutoff as readSealedRunCutoffOnConnection, readSealedRunSummaryPage as readSealedRunSummaryPageOnConnection, readCollectionItemPage as readCollectionItemPageOnConnection, readContentChunkPage as readContentChunkPageOnConnection, readSealedRunDocument as readSealedRunDocumentOnConnection, readSealedRunCore as readSealedRunCoreOnConnection, readSealedRunSummary as readSealedRunSummaryOnConnection, verifyAllSealedRuns, } from \"./storage.ts\";\nimport { RECORD_SQLITE_VALIDATION_DEADLINE_MS, type AttemptLocatorCandidates, type CollectionItemPage, type ContentChunkPage, type SealedRunDocument, type SealedRunCore, type SealedRunCutoff, type SealedRunSummary, type SealedRunSummaryPage, } from \"./types.ts\";\nimport { currentPublicationCutoffOnConnection, readRunResourceOnConnection, listRunResourcesOnConnection, } from \"../../run/storage/sqlite.ts\";\nimport { publicationCutoffIdentity } from \"../../run/storage/cutoff.ts\";\nimport type { PublicationCutoff, ReadableRunResource, } from \"../../run/storage/types.ts\";\nexport { makeStorageWorkerClient, openStorageWorker, type StorageWorkerClient } from \"./client.ts\";\nexport { ProjectStateDatabase, ProjectStateDatabaseLive, type ProjectStateDatabaseService, type ProjectStateFacets, } from \"./project-state-database.ts\";\nexport { SqliteRecordError, type SqliteRecordErrorCode } from \"./errors.ts\";\nexport { RECORD_SQLITE_CHUNK_BYTES, RECORD_SQLITE_FORMAT, RECORD_SQLITE_MAX_PUBLISH_BYTES, RECORD_SQLITE_MAX_PUBLISH_ROWS, RECORD_SQLITE_MAX_ROW_BYTES, RECORD_SQLITE_MAX_PAGE_ROWS, RECORD_SQLITE_MAX_PAGE_BYTES, RECORD_SQLITE_MAX_VALIDATION_ROWS, RECORD_SQLITE_MAX_VALIDATION_RUNS, RECORD_SQLITE_VALIDATION_DEADLINE_MS, RECORD_SQLITE_STORAGE_REVISION, type AdmitAttachmentInput, type AdmitAttemptInput, type AdmitContentInput, type AppendContentChunksInput, type BeginRunInput, type AttemptLocatorCandidateRun, type AttemptLocatorCandidates, type CollectionItemPage, type ContentChunkPage, type FinalizeRunInput, type FinalizedAttachmentMetadata, type FinalizedAttachmentClosure, type FenceRunFinalizationInput, type PersistedAttachment, type PersistedAttachmentReference, type PersistedCollectionItem, type PersistedContent, type PersistedContentMetadata, type PersistedContentChunk, type PersistedMember, type PersistedSlot, type PersistedAttempt, type PersistSealedRunInput, type PrepareRunFinalizationInput, type PreparedRunFinalization, type RunFinalization, type SealEntry, type SealedAttachmentDocument, type SealedAttachmentMetadata, type SealedRunCore, type SealedRunDocument, type SealedRunSummary, type SealedRunCutoff, type SealedRunSummaryPage, type SealRunInput, type StageAttachmentInput, type StageAttachmentReferencesInput, type StageCollectionItemsInput, type StageSealEntriesInput, type StageSealEntriesResult, type StageRunCoreInput, } from \"./types.ts\";\nexport { inspectProjectRecordDatabase, recordSqlitePath, reopenProjectDatabase, type ProjectRecordDatabaseInspection };\n/** Fixed Host-private read surface. The SQLite connection and SQL stay encapsulated. */\nexport interface PinnedRecordReadSession {\n readonly kind: \"canonical\" | \"private-generation\";\n readonly deadlineEpochMs: number;\n readonly publicationCutoff: () => PublicationCutoff;\n readonly sealedCutoff: () => SealedRunCutoff;\n readonly findExperimentRunIds: (experimentId: string) => readonly string[];\n readonly readRunResource: (runId: string) => ReadableRunResource | undefined;\n readonly listRunResources: (input?: Parameters<typeof listRunResourcesOnConnection>[1]) => ReturnType<typeof listRunResourcesOnConnection>;\n readonly readSealedRunSummary: (runId: string) => SealedRunSummary | undefined;\n readonly readSealedRunSummaryPage: (afterRunId?: string, pageSize?: number, expectedCutoffIdentity?: string) => SealedRunSummaryPage;\n readonly findAttemptLocatorCandidates: (locator: string, maximumCandidateRuns: number) => AttemptLocatorCandidates;\n readonly readSealedRunDocument: (runId: string) => SealedRunDocument | undefined;\n readonly readSealedRunCore: (runId: string, lazyAttachments?: boolean) => SealedRunCore | undefined;\n readonly readContentChunkPage: (contentId: string, afterOrdinal: number, pageSize: number) => ContentChunkPage;\n readonly readCollectionItemPage: (attachmentId: string, afterOrdinal: number, pageSize: number) => CollectionItemPage;\n readonly close: () => void;\n}\nfunction openPinnedRecordReadSession(path: string, kind: \"canonical\" | \"private-generation\", deadlineEpochMs: number): PinnedRecordReadSession {\n if (!Number.isSafeInteger(deadlineEpochMs) || deadlineEpochMs <= Date.now()) {\n throw sqliteError(\"record-resource-limit-exceeded\", \"open-read-session\", \"pinned read deadline must be a future safe integer\");\n }\n const connection = openImmutableRecordReader(path);\n let closed = false;\n const close = (): void => {\n if (closed)\n return;\n closed = true;\n try {\n if (connection.db.isTransaction)\n connection.db.exec(\"ROLLBACK\");\n }\n finally {\n closeRecordDatabase(connection);\n }\n };\n const assertUsable = (operation: string): void => {\n if (closed)\n throw sqliteError(\"record-database-invalid\", operation, \"pinned read session is closed\");\n if (Date.now() >= deadlineEpochMs) {\n close();\n throw sqliteError(\"record-resource-limit-exceeded\", operation, \"pinned read session exceeded its deadline and was closed\");\n }\n };\n const readBounded = <A>(operation: string, read: () => A): A => {\n assertUsable(operation);\n const result = read();\n // Synchronous SQLite work may only observe the deadline at its boundary;\n // never release a result if that work crossed the session deadline.\n assertUsable(operation);\n return result;\n };\n try {\n // BEGIN occurs before the authoritative schema pass. Every later\n // read observes this same WAL/file generation until close rolls it back.\n connection.db.exec(\"BEGIN\");\n const publicationCutoff = currentPublicationCutoffOnConnection(connection);\n const cutoffIdentity = publicationCutoffIdentity(publicationCutoff);\n validateExactSchema(connection);\n // Both sources have an admission owner: the project writer or the hostile\n // importer. Re-check selected facts, not every historical Seal, on reads.\n let sealedCutoff: SealedRunCutoff | undefined;\n const readCutoff = () => sealedCutoff ??= readBounded(\"read-sealed-cutoff\", () => readSealedRunCutoffOnConnection(connection, cutoffIdentity));\n assertUsable(\"open-read-session\");\n return Object.freeze({\n kind,\n deadlineEpochMs,\n publicationCutoff: () => publicationCutoff,\n sealedCutoff: readCutoff,\n findExperimentRunIds: (experimentId: string) => readBounded(\"find-experiment-runs\", () => findExperimentRunIdsOnConnection(connection, experimentId)),\n readRunResource: (runId: string) => readBounded(\"read-run-resource\", () => readRunResourceOnConnection(connection, runId, publicationCutoff)),\n listRunResources: (input: Parameters<typeof listRunResourcesOnConnection>[1]) => readBounded(\"list-run-resources\", () => listRunResourcesOnConnection(connection, { ...input, cutoff: input?.cutoff ?? publicationCutoff })),\n readSealedRunSummary: (runId: string) => readBounded(\"read-sealed-run-summary\", () => readSealedRunSummaryOnConnection(connection, runId)),\n readSealedRunSummaryPage: (afterRunId = \"\", pageSize = 100, expectedCutoffIdentity?: string) => readBounded(\"page-sealed-runs\", () => {\n if (expectedCutoffIdentity !== undefined && expectedCutoffIdentity !== cutoffIdentity) {\n throw sqliteError(\"record-command-conflict\", \"page-sealed-runs\", \"publication cutoff changed; restart pagination\");\n }\n const page = readSealedRunSummaryPageOnConnection(connection, afterRunId, pageSize, undefined, deadlineEpochMs, readCutoff());\n return Object.freeze({\n ...page,\n cutoff: Object.freeze({ ...page.cutoff, identity: cutoffIdentity }),\n });\n }),\n findAttemptLocatorCandidates: (locator: string, maximumCandidateRuns: number) => readBounded(\"find-attempt-locator\", () => findAttemptLocatorCandidatesOnConnection(connection, locator, maximumCandidateRuns)),\n readSealedRunDocument: (runId: string) => readBounded(\"read-sealed-run-document\", () => readSealedRunDocumentOnConnection(connection, runId)),\n readSealedRunCore: (runId: string, lazyAttachments = false) => readBounded(\"read-sealed-run-core\", () => readSealedRunCoreOnConnection(connection, runId, lazyAttachments\n ? (read) => readBounded(\"read-sealed-attachment\", read)\n : undefined)),\n readContentChunkPage: (contentId: string, afterOrdinal: number, pageSize: number) => readBounded(\"read-content-page\", () => readContentChunkPageOnConnection(connection, contentId, afterOrdinal, pageSize)),\n readCollectionItemPage: (attachmentId: string, afterOrdinal: number, pageSize: number) => readBounded(\"read-collection-page\", () => readCollectionItemPageOnConnection(connection, attachmentId, afterOrdinal, pageSize)),\n close,\n });\n }\n catch (cause) {\n close();\n throw cause;\n }\n}\nexport function openOperationalRecordReadSession(recordStorageRoot: string, deadlineEpochMs = Date.now() + RECORD_SQLITE_VALIDATION_DEADLINE_MS): PinnedRecordReadSession {\n return openPinnedRecordReadSession(recordSqlitePath(recordStorageRoot), \"canonical\", deadlineEpochMs);\n}\n/** Read admission never binds a project writer or mutates historical input. */\nexport const acquireProjectRecordReadSession = Effect.fn(\"acquireProjectRecordReadSession\")(function* (recordStorageRoot: string) {\n const path = recordSqlitePath(recordStorageRoot);\n const mode = yield* Effect.try({ try: () => projectRecordReadMode(path), catch: (cause) => cause });\n if (mode === \"operational\") {\n return yield* Effect.acquireRelease(Effect.try({ try: () => openOperationalRecordReadSession(recordStorageRoot), catch: (cause) => cause }), (session) => Effect.sync(() => session.close()));\n }\n const importer = yield* Effect.acquireRelease(Effect.try({\n try: () => startExternalRecordImport(path, Date.now() + RECORD_SQLITE_VALIDATION_DEADLINE_MS, \"captured-project-record\"),\n catch: (cause) => cause,\n }), (handle) => Effect.promise(() => handle.close()));\n const generation = yield* Effect.tryPromise({ try: (_signal) => importer.result, catch: (cause) => cause });\n return yield* Effect.acquireRelease(Effect.try({ try: () => openHostOwnedRecordReadSession(generation.path), catch: (cause) => cause }), (session) => Effect.sync(() => session.close()));\n});\n/** Opens only a private generation already admitted by the hostile importer. */\nexport function openHostOwnedRecordReadSession(generationPath: string, deadlineEpochMs = Date.now() + RECORD_SQLITE_VALIDATION_DEADLINE_MS): PinnedRecordReadSession {\n return openPinnedRecordReadSession(generationPath, \"private-generation\", deadlineEpochMs);\n}\nfunction withSession<A>(session: PinnedRecordReadSession, use: (session: PinnedRecordReadSession) => A): A {\n try {\n return use(session);\n }\n finally {\n session.close();\n }\n}\nexport function readSealedRunSummary(recordStorageRoot: string, runId: string): SealedRunSummary | undefined {\n return withSession(openOperationalRecordReadSession(recordStorageRoot), (session) => session.readSealedRunSummary(runId));\n}\nexport function listSealedRunSummaries(recordStorageRoot: string, afterRunId = \"\", pageSize = 100): readonly SealedRunSummary[] {\n return withSession(openOperationalRecordReadSession(recordStorageRoot), (session) => session.readSealedRunSummaryPage(afterRunId, pageSize).summaries);\n}\nexport function readSealedRunSummaryPage(recordStorageRoot: string, afterRunId = \"\", pageSize = 100, expectedCutoffIdentity?: string): SealedRunSummaryPage {\n return withSession(openOperationalRecordReadSession(recordStorageRoot), (session) => session.readSealedRunSummaryPage(afterRunId, pageSize, expectedCutoffIdentity));\n}\nexport function findAttemptLocatorCandidates(recordStorageRoot: string, locator: string, maximumCandidateRuns: number): AttemptLocatorCandidates {\n return withSession(openOperationalRecordReadSession(recordStorageRoot), (session) => session.findAttemptLocatorCandidates(locator, maximumCandidateRuns));\n}\nexport function readCollectionItemPage(recordStorageRoot: string, attachmentId: string, afterOrdinal: number, pageSize: number): CollectionItemPage {\n return withSession(openOperationalRecordReadSession(recordStorageRoot), (session) => session.readCollectionItemPage(attachmentId, afterOrdinal, pageSize));\n}\nexport function readSealedRunDocument(recordStorageRoot: string, runId: string): SealedRunDocument | undefined {\n return withSession(openOperationalRecordReadSession(recordStorageRoot), (session) => session.readSealedRunDocument(runId));\n}\nexport function readSealedRunCore(recordStorageRoot: string, runId: string): SealedRunCore | undefined {\n return withSession(openOperationalRecordReadSession(recordStorageRoot), (session) => session.readSealedRunCore(runId));\n}\nexport function readContentChunkPage(recordStorageRoot: string, contentId: string, afterOrdinal: number, pageSize: number): ContentChunkPage {\n return withSession(openOperationalRecordReadSession(recordStorageRoot), (session) => session.readContentChunkPage(contentId, afterOrdinal, pageSize));\n}\nexport function validateRecordDatabase(recordStorageRoot: string, sealedOnly = false): number {\n const connection = openImmutableRecordReader(recordSqlitePath(recordStorageRoot));\n try {\n validateExactSchema(connection);\n return verifyAllSealedRuns(connection, sealedOnly);\n }\n finally {\n closeRecordDatabase(connection);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;AAoHA,4EAEC;AAgBD,wEAEC;AASD,oDAEC;AACD,wDAEC;AACD,4DAEC;AACD,oEAEC;AACD,wDAEC;AACD,sDAEC;AACD,8CAEC;AACD,oDAEC;AACD,wDASC;AAlLD,mCAAgC;AAChC,2EAA+F;AAC/F,+CAAkN;AAWzM,6GAXqB,0CAA4B,OAWrB;AAAoB,sGAX8B,mCAAqB,OAW9B;AAAvC,iGAXuE,8BAAgB,OAWvE;AAVvD,2CAA0C;AAC1C,6CAA8tB;AAC9tB,yCAA8T;AAC9T,2DAA+I;AAC/I,2DAAwE;AAExE,yCAAmG;AAA1F,oHAAA,uBAAuB,OAAA;AAAE,8GAAA,iBAAiB,OAAA;AACnD,yEAAyJ;AAAhJ,iIAAA,oBAAoB,OAAA;AAAE,qIAAA,wBAAwB,OAAA;AACvD,yCAA4E;AAAnE,8GAAA,iBAAiB,OAAA;AAC1B,uCAAi8C;AAAx7C,qHAAA,yBAAyB,OAAA;AAAE,gHAAA,oBAAoB,OAAA;AAAE,2HAAA,+BAA+B,OAAA;AAAE,0HAAA,8BAA8B,OAAA;AAAE,uHAAA,2BAA2B,OAAA;AAAE,uHAAA,2BAA2B,OAAA;AAAE,wHAAA,4BAA4B,OAAA;AAAE,6HAAA,iCAAiC,OAAA;AAAE,6HAAA,iCAAiC,OAAA;AAAE,gIAAA,oCAAoC,OAAA;AAAE,0HAAA,8BAA8B,OAAA;AAsB7V,SAAS,2BAA2B,CAAC,IAAY,EAAE,IAAwC,EAAE,eAAuB;IAChH,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,eAAe,CAAC,IAA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AAyB,EAAE,SAAiB,EAAE,YAAoB,EAAE,QAAgB;IACrH,OAAO,WAAW,CAAC,gCAAgC,CAAC,iBAAiB,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,oBAAoB,CAAC,SAAS,EAAE,YAAY,EAAE,QAAQ,CAAC,CAAC,CAAC;AAC1J,CAAC;AACD,SAAgB,sBAAsB,CAAC,iBAAyB,EAAE,UAAU,GAAG,KAAK;IAChF,MAAM,UAAU,GAAG,IAAA,uCAAyB,EAAC,IAAA,8BAAgB,EAAC,iBAAiB,CAAC,CAAC,CAAC;IAClF,IAAI,CAAC;QACD,IAAA,iCAAmB,EAAC,UAAU,CAAC,CAAC;QAChC,OAAO,IAAA,gCAAmB,EAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IACvD,CAAC;YACO,CAAC;QACL,IAAA,iCAAmB,EAAC,UAAU,CAAC,CAAC;IACpC,CAAC;AACL,CAAC","sourcesContent":["import { Effect } from \"effect\";\nimport { projectRecordReadMode, startExternalRecordImport } from \"./external-record-import.ts\";\nimport { closeRecordDatabase, inspectProjectRecordDatabase, openImmutableRecordReader, reopenProjectDatabase, recordSqlitePath, validateExactSchema, type ProjectRecordDatabaseInspection, } from \"./database.ts\";\nimport { sqliteError } from \"./errors.ts\";\nimport { findAttemptLocatorCandidates as findAttemptLocatorCandidatesOnConnection, findExperimentRunIds as findExperimentRunIdsOnConnection, findSourceBarrierCandidate as findSourceBarrierCandidateOnConnection, findAcceptedAttemptRunIds as findAcceptedAttemptRunIdsOnConnection, readSealedRunCutoff as readSealedRunCutoffOnConnection, readSealedRunSummaryPage as readSealedRunSummaryPageOnConnection, readCollectionItemPage as readCollectionItemPageOnConnection, readContentChunkPage as readContentChunkPageOnConnection, readSealedRunDocument as readSealedRunDocumentOnConnection, readSealedRunCore as readSealedRunCoreOnConnection, readSealedRunSummary as readSealedRunSummaryOnConnection, verifyAllSealedRuns, } from \"./storage.ts\";\nimport { RECORD_SQLITE_VALIDATION_DEADLINE_MS, type AttemptLocatorCandidates, type SourceBarrierRequest, type SourceBarrierCandidate, type CollectionItemPage, type ContentChunkPage, type SealedRunDocument, type SealedRunCore, type SealedRunCutoff, type SealedRunSummary, type SealedRunSummaryPage, } from \"./types.ts\";\nimport { currentPublicationCutoffOnConnection, readRunResourceOnConnection, listRunResourcesOnConnection, } from \"../../run/storage/sqlite.ts\";\nimport { publicationCutoffIdentity } from \"../../run/storage/cutoff.ts\";\nimport type { PublicationCutoff, ReadableRunResource, } from \"../../run/storage/types.ts\";\nexport { makeStorageWorkerClient, openStorageWorker, type StorageWorkerClient } from \"./client.ts\";\nexport { ProjectStateDatabase, ProjectStateDatabaseLive, type ProjectStateDatabaseService, type ProjectStateFacets, } from \"./project-state-database.ts\";\nexport { SqliteRecordError, type SqliteRecordErrorCode } from \"./errors.ts\";\nexport { RECORD_SQLITE_CHUNK_BYTES, RECORD_SQLITE_FORMAT, RECORD_SQLITE_MAX_PUBLISH_BYTES, RECORD_SQLITE_MAX_PUBLISH_ROWS, RECORD_SQLITE_MAX_ROW_BYTES, RECORD_SQLITE_MAX_PAGE_ROWS, RECORD_SQLITE_MAX_PAGE_BYTES, RECORD_SQLITE_MAX_VALIDATION_ROWS, RECORD_SQLITE_MAX_VALIDATION_RUNS, RECORD_SQLITE_VALIDATION_DEADLINE_MS, RECORD_SQLITE_STORAGE_REVISION, type AdmitAttachmentInput, type AdmitAttemptInput, type AdmitContentInput, type AppendContentChunksInput, type BeginRunInput, type AttemptLocatorCandidateRun, type AttemptLocatorCandidates, type CollectionItemPage, type ContentChunkPage, type FinalizeRunInput, type FinalizedAttachmentMetadata, type FinalizedAttachmentClosure, type FenceRunFinalizationInput, type PersistedAttachment, type PersistedAttachmentReference, type PersistedCollectionItem, type PersistedContent, type PersistedContentMetadata, type PersistedContentChunk, type PersistedMember, type PersistedSlot, type PersistedAttempt, type PersistSealedRunInput, type PrepareRunFinalizationInput, type PreparedRunFinalization, type RunFinalization, type SealEntry, type SealedAttachmentDocument, type SealedAttachmentMetadata, type SealedRunCore, type SealedRunDocument, type SealedRunSummary, type SealedRunCutoff, type SealedRunSummaryPage, type SealRunInput, type StageAttachmentInput, type StageAttachmentReferencesInput, type StageCollectionItemsInput, type StageSealEntriesInput, type StageSealEntriesResult, type StageRunCoreInput, } from \"./types.ts\";\nexport { inspectProjectRecordDatabase, recordSqlitePath, reopenProjectDatabase, type ProjectRecordDatabaseInspection };\n/** Fixed Host-private read surface. The SQLite connection and SQL stay encapsulated. */\nexport interface PinnedRecordReadSession {\n readonly kind: \"canonical\" | \"private-generation\";\n readonly deadlineEpochMs: number;\n readonly publicationCutoff: () => PublicationCutoff;\n readonly sealedCutoff: () => SealedRunCutoff;\n readonly findExperimentRunIds: (experimentId: string) => readonly string[];\n readonly findSourceBarrierCandidate: (request: SourceBarrierRequest) => SourceBarrierCandidate | undefined;\n readonly findAcceptedAttemptRunIds: (request: Parameters<typeof findAcceptedAttemptRunIdsOnConnection>[1]) => readonly string[];\n readonly readRunResource: (runId: string) => ReadableRunResource | undefined;\n readonly listRunResources: (input?: Parameters<typeof listRunResourcesOnConnection>[1]) => ReturnType<typeof listRunResourcesOnConnection>;\n readonly readSealedRunSummary: (runId: string) => SealedRunSummary | undefined;\n readonly readSealedRunSummaryPage: (afterRunId?: string, pageSize?: number, expectedCutoffIdentity?: string) => SealedRunSummaryPage;\n readonly findAttemptLocatorCandidates: (locator: string, maximumCandidateRuns: number, includeTargets?: boolean) => AttemptLocatorCandidates;\n readonly readSealedRunDocument: (runId: string) => SealedRunDocument | undefined;\n readonly readSealedRunCore: (runId: string, lazyAttachments?: boolean) => SealedRunCore | undefined;\n readonly readContentChunkPage: (contentId: string, afterOrdinal: number, pageSize: number) => ContentChunkPage;\n readonly readCollectionItemPage: (attachmentId: string, afterOrdinal: number, pageSize: number) => CollectionItemPage;\n readonly close: () => void;\n}\nfunction openPinnedRecordReadSession(path: string, kind: \"canonical\" | \"private-generation\", deadlineEpochMs: number): PinnedRecordReadSession {\n if (!Number.isSafeInteger(deadlineEpochMs) || deadlineEpochMs <= Date.now()) {\n throw sqliteError(\"record-resource-limit-exceeded\", \"open-read-session\", \"pinned read deadline must be a future safe integer\");\n }\n const connection = openImmutableRecordReader(path);\n let closed = false;\n const close = (): void => {\n if (closed)\n return;\n closed = true;\n try {\n if (connection.db.isTransaction)\n connection.db.exec(\"ROLLBACK\");\n }\n finally {\n closeRecordDatabase(connection);\n }\n };\n const assertUsable = (operation: string): void => {\n if (closed)\n throw sqliteError(\"record-database-invalid\", operation, \"pinned read session is closed\");\n if (Date.now() >= deadlineEpochMs) {\n close();\n throw sqliteError(\"record-resource-limit-exceeded\", operation, \"pinned read session exceeded its deadline and was closed\");\n }\n };\n const readBounded = <A>(operation: string, read: () => A): A => {\n assertUsable(operation);\n const result = read();\n // Synchronous SQLite work may only observe the deadline at its boundary;\n // never release a result if that work crossed the session deadline.\n assertUsable(operation);\n return result;\n };\n try {\n // BEGIN occurs before the authoritative schema pass. Every later\n // read observes this same WAL/file generation until close rolls it back.\n connection.db.exec(\"BEGIN\");\n const publicationCutoff = currentPublicationCutoffOnConnection(connection);\n const cutoffIdentity = publicationCutoffIdentity(publicationCutoff);\n validateExactSchema(connection);\n // Both sources have an admission owner: the project writer or the hostile\n // importer. Re-check selected facts, not every historical Seal, on reads.\n let sealedCutoff: SealedRunCutoff | undefined;\n const readCutoff = () => sealedCutoff ??= readBounded(\"read-sealed-cutoff\", () => readSealedRunCutoffOnConnection(connection, cutoffIdentity));\n assertUsable(\"open-read-session\");\n return Object.freeze({\n kind,\n deadlineEpochMs,\n publicationCutoff: () => publicationCutoff,\n sealedCutoff: readCutoff,\n findExperimentRunIds: (experimentId: string) => readBounded(\"find-experiment-runs\", () => findExperimentRunIdsOnConnection(connection, experimentId)),\n readRunResource: (runId: string) => readBounded(\"read-run-resource\", () => readRunResourceOnConnection(connection, runId, publicationCutoff)),\n listRunResources: (input: Parameters<typeof listRunResourcesOnConnection>[1]) => readBounded(\"list-run-resources\", () => listRunResourcesOnConnection(connection, { ...input, cutoff: input?.cutoff ?? publicationCutoff })),\n readSealedRunSummary: (runId: string) => readBounded(\"read-sealed-run-summary\", () => readSealedRunSummaryOnConnection(connection, runId)),\n readSealedRunSummaryPage: (afterRunId = \"\", pageSize = 100, expectedCutoffIdentity?: string) => readBounded(\"page-sealed-runs\", () => {\n if (expectedCutoffIdentity !== undefined && expectedCutoffIdentity !== cutoffIdentity) {\n throw sqliteError(\"record-command-conflict\", \"page-sealed-runs\", \"publication cutoff changed; restart pagination\");\n }\n const page = readSealedRunSummaryPageOnConnection(connection, afterRunId, pageSize, undefined, deadlineEpochMs, readCutoff());\n return Object.freeze({\n ...page,\n cutoff: Object.freeze({ ...page.cutoff, identity: cutoffIdentity }),\n });\n }),\n findSourceBarrierCandidate: (request: SourceBarrierRequest) => readBounded(\"find-source-barrier\", () => findSourceBarrierCandidateOnConnection(connection, request, publicationCutoff.revision)),\n findAcceptedAttemptRunIds: (request: Parameters<typeof findAcceptedAttemptRunIdsOnConnection>[1]) => readBounded(\"find-accepted-attempt-runs\", () => findAcceptedAttemptRunIdsOnConnection(connection, request, publicationCutoff.revision)),\n findAttemptLocatorCandidates: (locator: string, maximumCandidateRuns: number, includeTargets = true) => readBounded(\"find-attempt-locator\", () => findAttemptLocatorCandidatesOnConnection(connection, locator, maximumCandidateRuns, includeTargets)),\n readSealedRunDocument: (runId: string) => readBounded(\"read-sealed-run-document\", () => readSealedRunDocumentOnConnection(connection, runId)),\n readSealedRunCore: (runId: string, lazyAttachments = false) => readBounded(\"read-sealed-run-core\", () => readSealedRunCoreOnConnection(connection, runId, lazyAttachments\n ? (read) => readBounded(\"read-sealed-attachment\", read)\n : undefined)),\n readContentChunkPage: (contentId: string, afterOrdinal: number, pageSize: number) => readBounded(\"read-content-page\", () => readContentChunkPageOnConnection(connection, contentId, afterOrdinal, pageSize)),\n readCollectionItemPage: (attachmentId: string, afterOrdinal: number, pageSize: number) => readBounded(\"read-collection-page\", () => readCollectionItemPageOnConnection(connection, attachmentId, afterOrdinal, pageSize)),\n close,\n });\n }\n catch (cause) {\n close();\n throw cause;\n }\n}\nexport function openOperationalRecordReadSession(recordStorageRoot: string, deadlineEpochMs = Date.now() + RECORD_SQLITE_VALIDATION_DEADLINE_MS): PinnedRecordReadSession {\n return openPinnedRecordReadSession(recordSqlitePath(recordStorageRoot), \"canonical\", deadlineEpochMs);\n}\n/** Read admission never binds a project writer or mutates historical input. */\nexport const acquireProjectRecordReadSession = Effect.fn(\"acquireProjectRecordReadSession\")(function* (recordStorageRoot: string) {\n const path = recordSqlitePath(recordStorageRoot);\n const mode = yield* Effect.try({ try: () => projectRecordReadMode(path), catch: (cause) => cause });\n if (mode === \"operational\") {\n return yield* Effect.acquireRelease(Effect.try({ try: () => openOperationalRecordReadSession(recordStorageRoot), catch: (cause) => cause }), (session) => Effect.sync(() => session.close()));\n }\n const importer = yield* Effect.acquireRelease(Effect.try({\n try: () => startExternalRecordImport(path, Date.now() + RECORD_SQLITE_VALIDATION_DEADLINE_MS, \"captured-project-record\"),\n catch: (cause) => cause,\n }), (handle) => Effect.promise(() => handle.close()));\n const generation = yield* Effect.tryPromise({ try: (_signal) => importer.result, catch: (cause) => cause });\n return yield* Effect.acquireRelease(Effect.try({ try: () => openHostOwnedRecordReadSession(generation.path), catch: (cause) => cause }), (session) => Effect.sync(() => session.close()));\n});\n/** Opens only a private generation already admitted by the hostile importer. */\nexport function openHostOwnedRecordReadSession(generationPath: string, deadlineEpochMs = Date.now() + RECORD_SQLITE_VALIDATION_DEADLINE_MS): PinnedRecordReadSession {\n return openPinnedRecordReadSession(generationPath, \"private-generation\", deadlineEpochMs);\n}\nfunction withSession<A>(session: PinnedRecordReadSession, use: (session: PinnedRecordReadSession) => A): A {\n try {\n return use(session);\n }\n finally {\n session.close();\n }\n}\nexport function readSealedRunSummary(recordStorageRoot: string, runId: string): SealedRunSummary | undefined {\n return withSession(openOperationalRecordReadSession(recordStorageRoot), (session) => session.readSealedRunSummary(runId));\n}\nexport function listSealedRunSummaries(recordStorageRoot: string, afterRunId = \"\", pageSize = 100): readonly SealedRunSummary[] {\n return withSession(openOperationalRecordReadSession(recordStorageRoot), (session) => session.readSealedRunSummaryPage(afterRunId, pageSize).summaries);\n}\nexport function readSealedRunSummaryPage(recordStorageRoot: string, afterRunId = \"\", pageSize = 100, expectedCutoffIdentity?: string): SealedRunSummaryPage {\n return withSession(openOperationalRecordReadSession(recordStorageRoot), (session) => session.readSealedRunSummaryPage(afterRunId, pageSize, expectedCutoffIdentity));\n}\nexport function findAttemptLocatorCandidates(recordStorageRoot: string, locator: string, maximumCandidateRuns: number): AttemptLocatorCandidates {\n return withSession(openOperationalRecordReadSession(recordStorageRoot), (session) => session.findAttemptLocatorCandidates(locator, maximumCandidateRuns));\n}\nexport function readCollectionItemPage(recordStorageRoot: string, attachmentId: string, afterOrdinal: number, pageSize: number): CollectionItemPage {\n return withSession(openOperationalRecordReadSession(recordStorageRoot), (session) => session.readCollectionItemPage(attachmentId, afterOrdinal, pageSize));\n}\nexport function readSealedRunDocument(recordStorageRoot: string, runId: string): SealedRunDocument | undefined {\n return withSession(openOperationalRecordReadSession(recordStorageRoot), (session) => session.readSealedRunDocument(runId));\n}\nexport function readSealedRunCore(recordStorageRoot: string, runId: string): SealedRunCore | undefined {\n return withSession(openOperationalRecordReadSession(recordStorageRoot), (session) => session.readSealedRunCore(runId));\n}\nexport function readContentChunkPage(recordStorageRoot: string, contentId: string, afterOrdinal: number, pageSize: number): ContentChunkPage {\n return withSession(openOperationalRecordReadSession(recordStorageRoot), (session) => session.readContentChunkPage(contentId, afterOrdinal, pageSize));\n}\nexport function validateRecordDatabase(recordStorageRoot: string, sealedOnly = false): number {\n const connection = openImmutableRecordReader(recordSqlitePath(recordStorageRoot));\n try {\n validateExactSchema(connection);\n return verifyAllSealedRuns(connection, sealedOnly);\n }\n finally {\n closeRecordDatabase(connection);\n }\n}\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
2
|
import { inspectProjectRecordDatabase, reopenProjectDatabase, recordSqlitePath, type ProjectRecordDatabaseInspection } from "./database.cjs";
|
|
3
|
-
import {
|
|
3
|
+
import { findAcceptedAttemptRunIds as findAcceptedAttemptRunIdsOnConnection } from "./storage.cjs";
|
|
4
|
+
import { type AttemptLocatorCandidates, type SourceBarrierRequest, type SourceBarrierCandidate, type CollectionItemPage, type ContentChunkPage, type SealedRunDocument, type SealedRunCore, type SealedRunCutoff, type SealedRunSummary, type SealedRunSummaryPage } from "./types.cjs";
|
|
4
5
|
import { listRunResourcesOnConnection } from "../../run/storage/sqlite.cjs";
|
|
5
6
|
import type { PublicationCutoff, ReadableRunResource } from "../../run/storage/types.cjs";
|
|
6
7
|
export { makeStorageWorkerClient, openStorageWorker, type StorageWorkerClient } from "./client.cjs";
|
|
@@ -15,11 +16,13 @@ export interface PinnedRecordReadSession {
|
|
|
15
16
|
readonly publicationCutoff: () => PublicationCutoff;
|
|
16
17
|
readonly sealedCutoff: () => SealedRunCutoff;
|
|
17
18
|
readonly findExperimentRunIds: (experimentId: string) => readonly string[];
|
|
19
|
+
readonly findSourceBarrierCandidate: (request: SourceBarrierRequest) => SourceBarrierCandidate | undefined;
|
|
20
|
+
readonly findAcceptedAttemptRunIds: (request: Parameters<typeof findAcceptedAttemptRunIdsOnConnection>[1]) => readonly string[];
|
|
18
21
|
readonly readRunResource: (runId: string) => ReadableRunResource | undefined;
|
|
19
22
|
readonly listRunResources: (input?: Parameters<typeof listRunResourcesOnConnection>[1]) => ReturnType<typeof listRunResourcesOnConnection>;
|
|
20
23
|
readonly readSealedRunSummary: (runId: string) => SealedRunSummary | undefined;
|
|
21
24
|
readonly readSealedRunSummaryPage: (afterRunId?: string, pageSize?: number, expectedCutoffIdentity?: string) => SealedRunSummaryPage;
|
|
22
|
-
readonly findAttemptLocatorCandidates: (locator: string, maximumCandidateRuns: number) => AttemptLocatorCandidates;
|
|
25
|
+
readonly findAttemptLocatorCandidates: (locator: string, maximumCandidateRuns: number, includeTargets?: boolean) => AttemptLocatorCandidates;
|
|
23
26
|
readonly readSealedRunDocument: (runId: string) => SealedRunDocument | undefined;
|
|
24
27
|
readonly readSealedRunCore: (runId: string, lazyAttachments?: boolean) => SealedRunCore | undefined;
|
|
25
28
|
readonly readContentChunkPage: (contentId: string, afterOrdinal: number, pageSize: number) => ContentChunkPage;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
2
|
import { inspectProjectRecordDatabase, reopenProjectDatabase, recordSqlitePath, type ProjectRecordDatabaseInspection } from "./database.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { findAcceptedAttemptRunIds as findAcceptedAttemptRunIdsOnConnection } from "./storage.mjs";
|
|
4
|
+
import { type AttemptLocatorCandidates, type SourceBarrierRequest, type SourceBarrierCandidate, type CollectionItemPage, type ContentChunkPage, type SealedRunDocument, type SealedRunCore, type SealedRunCutoff, type SealedRunSummary, type SealedRunSummaryPage } from "./types.mjs";
|
|
4
5
|
import { listRunResourcesOnConnection } from "../../run/storage/sqlite.mjs";
|
|
5
6
|
import type { PublicationCutoff, ReadableRunResource } from "../../run/storage/types.mjs";
|
|
6
7
|
export { makeStorageWorkerClient, openStorageWorker, type StorageWorkerClient } from "./client.mjs";
|
|
@@ -15,11 +16,13 @@ export interface PinnedRecordReadSession {
|
|
|
15
16
|
readonly publicationCutoff: () => PublicationCutoff;
|
|
16
17
|
readonly sealedCutoff: () => SealedRunCutoff;
|
|
17
18
|
readonly findExperimentRunIds: (experimentId: string) => readonly string[];
|
|
19
|
+
readonly findSourceBarrierCandidate: (request: SourceBarrierRequest) => SourceBarrierCandidate | undefined;
|
|
20
|
+
readonly findAcceptedAttemptRunIds: (request: Parameters<typeof findAcceptedAttemptRunIdsOnConnection>[1]) => readonly string[];
|
|
18
21
|
readonly readRunResource: (runId: string) => ReadableRunResource | undefined;
|
|
19
22
|
readonly listRunResources: (input?: Parameters<typeof listRunResourcesOnConnection>[1]) => ReturnType<typeof listRunResourcesOnConnection>;
|
|
20
23
|
readonly readSealedRunSummary: (runId: string) => SealedRunSummary | undefined;
|
|
21
24
|
readonly readSealedRunSummaryPage: (afterRunId?: string, pageSize?: number, expectedCutoffIdentity?: string) => SealedRunSummaryPage;
|
|
22
|
-
readonly findAttemptLocatorCandidates: (locator: string, maximumCandidateRuns: number) => AttemptLocatorCandidates;
|
|
25
|
+
readonly findAttemptLocatorCandidates: (locator: string, maximumCandidateRuns: number, includeTargets?: boolean) => AttemptLocatorCandidates;
|
|
23
26
|
readonly readSealedRunDocument: (runId: string) => SealedRunDocument | undefined;
|
|
24
27
|
readonly readSealedRunCore: (runId: string, lazyAttachments?: boolean) => SealedRunCore | undefined;
|
|
25
28
|
readonly readContentChunkPage: (contentId: string, afterOrdinal: number, pageSize: number) => ContentChunkPage;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
2
|
import { inspectProjectRecordDatabase, reopenProjectDatabase, recordSqlitePath, type ProjectRecordDatabaseInspection } from "./database.js";
|
|
3
|
-
import {
|
|
3
|
+
import { findAcceptedAttemptRunIds as findAcceptedAttemptRunIdsOnConnection } from "./storage.js";
|
|
4
|
+
import { type AttemptLocatorCandidates, type SourceBarrierRequest, type SourceBarrierCandidate, type CollectionItemPage, type ContentChunkPage, type SealedRunDocument, type SealedRunCore, type SealedRunCutoff, type SealedRunSummary, type SealedRunSummaryPage } from "./types.js";
|
|
4
5
|
import { listRunResourcesOnConnection } from "../../run/storage/sqlite.js";
|
|
5
6
|
import type { PublicationCutoff, ReadableRunResource } from "../../run/storage/types.js";
|
|
6
7
|
export { makeStorageWorkerClient, openStorageWorker, type StorageWorkerClient } from "./client.js";
|
|
@@ -15,11 +16,13 @@ export interface PinnedRecordReadSession {
|
|
|
15
16
|
readonly publicationCutoff: () => PublicationCutoff;
|
|
16
17
|
readonly sealedCutoff: () => SealedRunCutoff;
|
|
17
18
|
readonly findExperimentRunIds: (experimentId: string) => readonly string[];
|
|
19
|
+
readonly findSourceBarrierCandidate: (request: SourceBarrierRequest) => SourceBarrierCandidate | undefined;
|
|
20
|
+
readonly findAcceptedAttemptRunIds: (request: Parameters<typeof findAcceptedAttemptRunIdsOnConnection>[1]) => readonly string[];
|
|
18
21
|
readonly readRunResource: (runId: string) => ReadableRunResource | undefined;
|
|
19
22
|
readonly listRunResources: (input?: Parameters<typeof listRunResourcesOnConnection>[1]) => ReturnType<typeof listRunResourcesOnConnection>;
|
|
20
23
|
readonly readSealedRunSummary: (runId: string) => SealedRunSummary | undefined;
|
|
21
24
|
readonly readSealedRunSummaryPage: (afterRunId?: string, pageSize?: number, expectedCutoffIdentity?: string) => SealedRunSummaryPage;
|
|
22
|
-
readonly findAttemptLocatorCandidates: (locator: string, maximumCandidateRuns: number) => AttemptLocatorCandidates;
|
|
25
|
+
readonly findAttemptLocatorCandidates: (locator: string, maximumCandidateRuns: number, includeTargets?: boolean) => AttemptLocatorCandidates;
|
|
23
26
|
readonly readSealedRunDocument: (runId: string) => SealedRunDocument | undefined;
|
|
24
27
|
readonly readSealedRunCore: (runId: string, lazyAttachments?: boolean) => SealedRunCore | undefined;
|
|
25
28
|
readonly readContentChunkPage: (contentId: string, afterOrdinal: number, pageSize: number) => ContentChunkPage;
|