niceeval 0.16.2-canary.98 → 0.16.2
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/inspection/facts.cjs +86 -31
- package/dist/inspection/facts.cjs.map +1 -1
- package/dist/inspection/facts.d.cts +2 -2
- package/dist/inspection/facts.d.mts +2 -2
- package/dist/inspection/facts.d.ts +2 -2
- package/dist/inspection/overview.cjs +2 -1
- package/dist/inspection/overview.cjs.map +1 -1
- package/dist/inspection/project-source.cjs +28 -19
- package/dist/inspection/project-source.cjs.map +1 -1
- package/dist/inspection/protocol.d.cts +17 -17
- package/dist/inspection/protocol.d.mts +17 -17
- package/dist/inspection/protocol.d.ts +17 -17
- package/dist/inspection/select.cjs +10 -6
- package/dist/inspection/select.cjs.map +1 -1
- package/dist/inspection/source.cjs +4 -2
- package/dist/inspection/source.cjs.map +1 -1
- package/dist/inspection/source.d.cts +1 -0
- package/dist/inspection/source.d.mts +1 -0
- package/dist/inspection/source.d.ts +1 -0
- package/dist/record/sqlite/database.cjs +2 -8
- package/dist/record/sqlite/database.cjs.map +1 -1
- package/dist/record/sqlite/index.cjs +13 -11
- package/dist/record/sqlite/index.cjs.map +1 -1
- package/dist/record/sqlite/index.d.cts +4 -2
- package/dist/record/sqlite/index.d.mts +4 -2
- package/dist/record/sqlite/index.d.ts +4 -2
- package/dist/record/sqlite/storage.cjs +118 -64
- package/dist/record/sqlite/storage.cjs.map +1 -1
- package/dist/record/sqlite/storage.d.cts +12 -5
- package/dist/record/sqlite/storage.d.mts +12 -5
- package/dist/record/sqlite/storage.d.ts +12 -5
- package/dist/record/sqlite/storage.js +48 -44
- package/dist/record/sqlite/types.cjs.map +1 -1
- package/dist/record/sqlite/types.d.cts +1 -1
- package/dist/record/sqlite/types.d.mts +1 -1
- package/dist/record/sqlite/types.d.ts +1 -1
- package/dist/view/cli/contribution.cjs +3 -2
- package/dist/view/cli/contribution.cjs.map +1 -1
- package/dist/view/function-runtime.mjs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AAC/J,CAAC;AACD,SAAgB,qBAAqB,CAAC,iBAAyB,EAAE,KAAa;IAC1E,OAAO,WAAW,CAAC,gCAAgC,CAAC,iBAAiB,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC,CAAC;AAC/H,CAAC;AACD,SAAgB,iBAAiB,CAAC,iBAAyB,EAAE,KAAa;IACtE,OAAO,WAAW,CAAC,gCAAgC,CAAC,iBAAiB,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC;AAC3H,CAAC;AACD,SAAgB,oBAAoB,CAAC,iBAAyB,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, 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 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 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) => 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, validation: \"complete\" | \"host-validated-generation\" = \"complete\"): 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 + Seal 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 if (validation === \"complete\") {\n verifyAllSealedRuns(connection, false, deadlineEpochMs);\n }\n else if (kind !== \"private-generation\") {\n throw sqliteError(\"record-database-invalid\", \"open-read-session\", \"only an admitted private generation may skip repeated validation\");\n }\n assertUsable(\"open-read-session\");\n return Object.freeze({\n kind,\n deadlineEpochMs,\n publicationCutoff: () => publicationCutoff,\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);\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) => readBounded(\"read-sealed-run-core\", () => readSealedRunCoreOnConnection(connection, runId)),\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, \"host-validated-generation\");\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":";;;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,2DAAw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CAAC;AAC/H,CAAC;AACD,SAAgB,iBAAiB,CAAC,iBAAyB,EAAE,KAAa;IACtE,OAAO,WAAW,CAAC,gCAAgC,CAAC,iBAAiB,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC;AAC3H,CAAC;AACD,SAAgB,oBAAoB,CAAC,iBAAyB,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, 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,6 +1,6 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
2
|
import { inspectProjectRecordDatabase, reopenProjectDatabase, recordSqlitePath, type ProjectRecordDatabaseInspection } from "./database.cjs";
|
|
3
|
-
import { type AttemptLocatorCandidates, type CollectionItemPage, type ContentChunkPage, type SealedRunDocument, type SealedRunCore, type SealedRunSummary, type SealedRunSummaryPage } from "./types.cjs";
|
|
3
|
+
import { type AttemptLocatorCandidates, type CollectionItemPage, type ContentChunkPage, type SealedRunDocument, type SealedRunCore, type SealedRunCutoff, type SealedRunSummary, type SealedRunSummaryPage } from "./types.cjs";
|
|
4
4
|
import { listRunResourcesOnConnection } from "../../run/storage/sqlite.cjs";
|
|
5
5
|
import type { PublicationCutoff, ReadableRunResource } from "../../run/storage/types.cjs";
|
|
6
6
|
export { makeStorageWorkerClient, openStorageWorker, type StorageWorkerClient } from "./client.cjs";
|
|
@@ -13,13 +13,15 @@ export interface PinnedRecordReadSession {
|
|
|
13
13
|
readonly kind: "canonical" | "private-generation";
|
|
14
14
|
readonly deadlineEpochMs: number;
|
|
15
15
|
readonly publicationCutoff: () => PublicationCutoff;
|
|
16
|
+
readonly sealedCutoff: () => SealedRunCutoff;
|
|
17
|
+
readonly findExperimentRunIds: (experimentId: string) => readonly string[];
|
|
16
18
|
readonly readRunResource: (runId: string) => ReadableRunResource | undefined;
|
|
17
19
|
readonly listRunResources: (input?: Parameters<typeof listRunResourcesOnConnection>[1]) => ReturnType<typeof listRunResourcesOnConnection>;
|
|
18
20
|
readonly readSealedRunSummary: (runId: string) => SealedRunSummary | undefined;
|
|
19
21
|
readonly readSealedRunSummaryPage: (afterRunId?: string, pageSize?: number, expectedCutoffIdentity?: string) => SealedRunSummaryPage;
|
|
20
22
|
readonly findAttemptLocatorCandidates: (locator: string, maximumCandidateRuns: number) => AttemptLocatorCandidates;
|
|
21
23
|
readonly readSealedRunDocument: (runId: string) => SealedRunDocument | undefined;
|
|
22
|
-
readonly readSealedRunCore: (runId: string) => SealedRunCore | undefined;
|
|
24
|
+
readonly readSealedRunCore: (runId: string, lazyAttachments?: boolean) => SealedRunCore | undefined;
|
|
23
25
|
readonly readContentChunkPage: (contentId: string, afterOrdinal: number, pageSize: number) => ContentChunkPage;
|
|
24
26
|
readonly readCollectionItemPage: (attachmentId: string, afterOrdinal: number, pageSize: number) => CollectionItemPage;
|
|
25
27
|
readonly close: () => void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
2
|
import { inspectProjectRecordDatabase, reopenProjectDatabase, recordSqlitePath, type ProjectRecordDatabaseInspection } from "./database.mjs";
|
|
3
|
-
import { type AttemptLocatorCandidates, type CollectionItemPage, type ContentChunkPage, type SealedRunDocument, type SealedRunCore, type SealedRunSummary, type SealedRunSummaryPage } from "./types.mjs";
|
|
3
|
+
import { type AttemptLocatorCandidates, type CollectionItemPage, type ContentChunkPage, type SealedRunDocument, type SealedRunCore, type SealedRunCutoff, type SealedRunSummary, type SealedRunSummaryPage } from "./types.mjs";
|
|
4
4
|
import { listRunResourcesOnConnection } from "../../run/storage/sqlite.mjs";
|
|
5
5
|
import type { PublicationCutoff, ReadableRunResource } from "../../run/storage/types.mjs";
|
|
6
6
|
export { makeStorageWorkerClient, openStorageWorker, type StorageWorkerClient } from "./client.mjs";
|
|
@@ -13,13 +13,15 @@ export interface PinnedRecordReadSession {
|
|
|
13
13
|
readonly kind: "canonical" | "private-generation";
|
|
14
14
|
readonly deadlineEpochMs: number;
|
|
15
15
|
readonly publicationCutoff: () => PublicationCutoff;
|
|
16
|
+
readonly sealedCutoff: () => SealedRunCutoff;
|
|
17
|
+
readonly findExperimentRunIds: (experimentId: string) => readonly string[];
|
|
16
18
|
readonly readRunResource: (runId: string) => ReadableRunResource | undefined;
|
|
17
19
|
readonly listRunResources: (input?: Parameters<typeof listRunResourcesOnConnection>[1]) => ReturnType<typeof listRunResourcesOnConnection>;
|
|
18
20
|
readonly readSealedRunSummary: (runId: string) => SealedRunSummary | undefined;
|
|
19
21
|
readonly readSealedRunSummaryPage: (afterRunId?: string, pageSize?: number, expectedCutoffIdentity?: string) => SealedRunSummaryPage;
|
|
20
22
|
readonly findAttemptLocatorCandidates: (locator: string, maximumCandidateRuns: number) => AttemptLocatorCandidates;
|
|
21
23
|
readonly readSealedRunDocument: (runId: string) => SealedRunDocument | undefined;
|
|
22
|
-
readonly readSealedRunCore: (runId: string) => SealedRunCore | undefined;
|
|
24
|
+
readonly readSealedRunCore: (runId: string, lazyAttachments?: boolean) => SealedRunCore | undefined;
|
|
23
25
|
readonly readContentChunkPage: (contentId: string, afterOrdinal: number, pageSize: number) => ContentChunkPage;
|
|
24
26
|
readonly readCollectionItemPage: (attachmentId: string, afterOrdinal: number, pageSize: number) => CollectionItemPage;
|
|
25
27
|
readonly close: () => void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
2
|
import { inspectProjectRecordDatabase, reopenProjectDatabase, recordSqlitePath, type ProjectRecordDatabaseInspection } from "./database.js";
|
|
3
|
-
import { type AttemptLocatorCandidates, type CollectionItemPage, type ContentChunkPage, type SealedRunDocument, type SealedRunCore, type SealedRunSummary, type SealedRunSummaryPage } from "./types.js";
|
|
3
|
+
import { type AttemptLocatorCandidates, type CollectionItemPage, type ContentChunkPage, type SealedRunDocument, type SealedRunCore, type SealedRunCutoff, type SealedRunSummary, type SealedRunSummaryPage } from "./types.js";
|
|
4
4
|
import { listRunResourcesOnConnection } from "../../run/storage/sqlite.js";
|
|
5
5
|
import type { PublicationCutoff, ReadableRunResource } from "../../run/storage/types.js";
|
|
6
6
|
export { makeStorageWorkerClient, openStorageWorker, type StorageWorkerClient } from "./client.js";
|
|
@@ -13,13 +13,15 @@ export interface PinnedRecordReadSession {
|
|
|
13
13
|
readonly kind: "canonical" | "private-generation";
|
|
14
14
|
readonly deadlineEpochMs: number;
|
|
15
15
|
readonly publicationCutoff: () => PublicationCutoff;
|
|
16
|
+
readonly sealedCutoff: () => SealedRunCutoff;
|
|
17
|
+
readonly findExperimentRunIds: (experimentId: string) => readonly string[];
|
|
16
18
|
readonly readRunResource: (runId: string) => ReadableRunResource | undefined;
|
|
17
19
|
readonly listRunResources: (input?: Parameters<typeof listRunResourcesOnConnection>[1]) => ReturnType<typeof listRunResourcesOnConnection>;
|
|
18
20
|
readonly readSealedRunSummary: (runId: string) => SealedRunSummary | undefined;
|
|
19
21
|
readonly readSealedRunSummaryPage: (afterRunId?: string, pageSize?: number, expectedCutoffIdentity?: string) => SealedRunSummaryPage;
|
|
20
22
|
readonly findAttemptLocatorCandidates: (locator: string, maximumCandidateRuns: number) => AttemptLocatorCandidates;
|
|
21
23
|
readonly readSealedRunDocument: (runId: string) => SealedRunDocument | undefined;
|
|
22
|
-
readonly readSealedRunCore: (runId: string) => SealedRunCore | undefined;
|
|
24
|
+
readonly readSealedRunCore: (runId: string, lazyAttachments?: boolean) => SealedRunCore | undefined;
|
|
23
25
|
readonly readContentChunkPage: (contentId: string, afterOrdinal: number, pageSize: number) => ContentChunkPage;
|
|
24
26
|
readonly readCollectionItemPage: (attachmentId: string, afterOrdinal: number, pageSize: number) => CollectionItemPage;
|
|
25
27
|
readonly close: () => void;
|
|
@@ -23,6 +23,8 @@ exports.sealRun = sealRun;
|
|
|
23
23
|
exports.publishRunSeal = publishRunSeal;
|
|
24
24
|
exports.verifyAllSealedRuns = verifyAllSealedRuns;
|
|
25
25
|
exports.readSealedRunSummary = readSealedRunSummary;
|
|
26
|
+
exports.readSealedRunCutoff = readSealedRunCutoff;
|
|
27
|
+
exports.findExperimentRunIds = findExperimentRunIds;
|
|
26
28
|
exports.listSealedRunSummaries = listSealedRunSummaries;
|
|
27
29
|
exports.readSealedRunSummaryPage = readSealedRunSummaryPage;
|
|
28
30
|
exports.findAttemptLocatorCandidates = findAttemptLocatorCandidates;
|
|
@@ -1480,12 +1482,62 @@ function verifyRunPayloadClosures(connection, runId, verifyPayloadBytes = true)
|
|
|
1480
1482
|
}
|
|
1481
1483
|
}
|
|
1482
1484
|
}
|
|
1485
|
+
/** Summary metadata never materializes Core, Attachment payload or collection rows. */
|
|
1483
1486
|
function readSealedRunSummary(connection, runId) {
|
|
1484
|
-
const
|
|
1485
|
-
|
|
1487
|
+
const row = (0, database_ts_1.recordStatement)(connection, `SELECT r.run_id,r.writer_generation,r.started_at,
|
|
1488
|
+
coalesce(r.logical_seal_identity,'published:' || (SELECT max(p.published_revision)
|
|
1489
|
+
FROM ne18_attempt_publications p WHERE p.origin_run_id=r.run_id)) logical_seal_identity,
|
|
1490
|
+
(SELECT count(*) FROM ne18_slots WHERE run_id=r.run_id) slot_count,
|
|
1491
|
+
CASE WHEN EXISTS (SELECT 1 FROM ne18_run_resources WHERE run_id=r.run_id) THEN
|
|
1492
|
+
(SELECT count(*) FROM ne18_run_slot_bindings WHERE target_run_id=r.run_id)+
|
|
1493
|
+
(SELECT count(*) FROM ne18_run_slot_absences WHERE run_id=r.run_id)
|
|
1494
|
+
ELSE (SELECT count(*) FROM ne18_members WHERE target_run_id=r.run_id) END member_count,
|
|
1495
|
+
(SELECT count(*) FROM ne18_attempts a WHERE a.origin_run_id=r.run_id AND
|
|
1496
|
+
(NOT EXISTS (SELECT 1 FROM ne18_run_resources WHERE run_id=r.run_id) OR EXISTS
|
|
1497
|
+
(SELECT 1 FROM ne18_attempt_publications p WHERE p.origin_run_id=a.origin_run_id AND p.attempt_id=a.attempt_id))) attempt_count,
|
|
1498
|
+
(SELECT count(*) FROM ne18_attachments a WHERE a.owner_run_id=r.run_id AND a.canonical_payload IS NOT NULL AND
|
|
1499
|
+
(a.owner_kind='run' OR NOT EXISTS (SELECT 1 FROM ne18_run_resources WHERE run_id=r.run_id) OR EXISTS
|
|
1500
|
+
(SELECT 1 FROM ne18_attempt_publications p WHERE p.origin_run_id=a.owner_run_id AND p.attempt_id=a.owner_attempt_id))) attachment_count,
|
|
1501
|
+
(SELECT count(*) FROM ne18_contents c JOIN ne18_attachments a ON a.attachment_id=c.attachment_id
|
|
1502
|
+
WHERE a.owner_run_id=r.run_id AND a.canonical_payload IS NOT NULL AND
|
|
1503
|
+
(a.owner_kind='run' OR NOT EXISTS (SELECT 1 FROM ne18_run_resources WHERE run_id=r.run_id) OR EXISTS
|
|
1504
|
+
(SELECT 1 FROM ne18_attempt_publications p WHERE p.origin_run_id=a.owner_run_id AND p.attempt_id=a.owner_attempt_id))) content_count,
|
|
1505
|
+
(SELECT coalesce(sum(c.byte_length),0) FROM ne18_contents c JOIN ne18_attachments a ON a.attachment_id=c.attachment_id
|
|
1506
|
+
WHERE a.owner_run_id=r.run_id AND a.canonical_payload IS NOT NULL AND
|
|
1507
|
+
(a.owner_kind='run' OR NOT EXISTS (SELECT 1 FROM ne18_run_resources WHERE run_id=r.run_id) OR EXISTS
|
|
1508
|
+
(SELECT 1 FROM ne18_attempt_publications p WHERE p.origin_run_id=a.owner_run_id AND p.attempt_id=a.owner_attempt_id))) content_bytes,
|
|
1509
|
+
(SELECT count(*) FROM ne18_run_seal_entries WHERE run_id=r.run_id) seal_count
|
|
1510
|
+
FROM ne18_runs r WHERE r.run_id=? AND NOT EXISTS
|
|
1511
|
+
(SELECT 1 FROM ne18_run_deletion_tombstones d WHERE d.run_id=r.run_id)
|
|
1512
|
+
AND (r.status='sealed' OR EXISTS (SELECT 1 FROM ne18_attempt_publications p WHERE p.origin_run_id=r.run_id))`).get(runId);
|
|
1513
|
+
if (row === undefined)
|
|
1486
1514
|
return undefined;
|
|
1487
|
-
|
|
1488
|
-
|
|
1515
|
+
return Object.freeze({ runId: text(row, "run_id"), writerGeneration: text(row, "writer_generation"),
|
|
1516
|
+
startedAt: text(row, "started_at"), logicalSealIdentity: text(row, "logical_seal_identity"),
|
|
1517
|
+
slotCount: integer(row, "slot_count"), memberCount: integer(row, "member_count"), attemptCount: integer(row, "attempt_count"),
|
|
1518
|
+
attachmentCount: integer(row, "attachment_count"), contentCount: integer(row, "content_count"),
|
|
1519
|
+
contentByteLength: integer(row, "content_bytes"), sealEntryCount: integer(row, "seal_count") });
|
|
1520
|
+
}
|
|
1521
|
+
/** Pinned publication identity, plus a metadata-only count; no Seal hashing. */
|
|
1522
|
+
function readSealedRunCutoff(connection, identity) {
|
|
1523
|
+
const row = (0, database_ts_1.recordStatement)(connection, `SELECT count(*) count FROM ne18_runs r
|
|
1524
|
+
WHERE NOT EXISTS (SELECT 1 FROM ne18_run_deletion_tombstones d WHERE d.run_id=r.run_id)
|
|
1525
|
+
AND (status='sealed' OR EXISTS (SELECT 1 FROM ne18_attempt_publications p WHERE p.origin_run_id=r.run_id))`).get();
|
|
1526
|
+
return Object.freeze({ identity, runCount: integer(row, "count") });
|
|
1527
|
+
}
|
|
1528
|
+
/** Filter lightweight Run metadata before loading any selected Core or payload. */
|
|
1529
|
+
function findExperimentRunIds(connection, experimentId) {
|
|
1530
|
+
requireIdentity(experimentId, "experimentId");
|
|
1531
|
+
const selected = rows(connection, `SELECT r.run_id FROM ne18_runs r
|
|
1532
|
+
LEFT JOIN ne18_run_resources resource ON resource.run_id=r.run_id
|
|
1533
|
+
WHERE coalesce(resource.experiment_id,json_extract(r.core_payload,'$.experimentId'))=?
|
|
1534
|
+
AND NOT EXISTS (SELECT 1 FROM ne18_run_deletion_tombstones d WHERE d.run_id=r.run_id)
|
|
1535
|
+
AND (r.status='sealed' OR EXISTS (SELECT 1 FROM ne18_attempt_publications p WHERE p.origin_run_id=r.run_id))
|
|
1536
|
+
ORDER BY r.run_id LIMIT ?`, experimentId, types_ts_1.RECORD_SQLITE_MAX_VALIDATION_RUNS + 1);
|
|
1537
|
+
if (selected.length > types_ts_1.RECORD_SQLITE_MAX_VALIDATION_RUNS) {
|
|
1538
|
+
throw (0, errors_ts_1.sqliteError)("record-resource-limit-exceeded", "find-experiment-runs", "Experiment exceeds its Run ceiling");
|
|
1539
|
+
}
|
|
1540
|
+
return Object.freeze(selected.map((row) => text(row, "run_id")));
|
|
1489
1541
|
}
|
|
1490
1542
|
function listSealedRunSummaries(connection, afterRunId = "", pageSize = 100) {
|
|
1491
1543
|
if (!Number.isSafeInteger(pageSize) || pageSize < 1 || pageSize > 256) {
|
|
@@ -1506,35 +1558,39 @@ function listSealedRunSummaries(connection, afterRunId = "", pageSize = 100) {
|
|
|
1506
1558
|
* Computes the stable sealed cutoff without retaining the inventory, then
|
|
1507
1559
|
* returns one bounded page from the same caller-owned read transaction.
|
|
1508
1560
|
*/
|
|
1509
|
-
function readSealedRunSummaryPage(connection, afterRunId = "", pageSize = 100, expectedCutoffIdentity, deadlineEpochMs = Date.now() + types_ts_1.RECORD_SQLITE_VALIDATION_DEADLINE_MS) {
|
|
1561
|
+
function readSealedRunSummaryPage(connection, afterRunId = "", pageSize = 100, expectedCutoffIdentity, deadlineEpochMs = Date.now() + types_ts_1.RECORD_SQLITE_VALIDATION_DEADLINE_MS, pinnedCutoff) {
|
|
1510
1562
|
requireIdentity(afterRunId === "" ? "start" : afterRunId, "afterRunId");
|
|
1511
1563
|
if (!Number.isSafeInteger(pageSize) || pageSize < 1 || pageSize > 256) {
|
|
1512
1564
|
throw (0, errors_ts_1.sqliteError)("record-resource-limit-exceeded", "page-sealed-runs", "page size must be between 1 and 256");
|
|
1513
1565
|
}
|
|
1514
|
-
const
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
(
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1566
|
+
const cutoff = pinnedCutoff ?? (() => {
|
|
1567
|
+
const cutoffHash = (0, node_crypto_1.createHash)("sha256");
|
|
1568
|
+
cutoffHash.update("[");
|
|
1569
|
+
let runCount = 0;
|
|
1570
|
+
const inventory = (0, database_ts_1.recordStatement)(connection, `SELECT run_id,
|
|
1571
|
+
coalesce(logical_seal_identity,'published:' || (SELECT max(p.published_revision) FROM ne18_attempt_publications p
|
|
1572
|
+
WHERE p.origin_run_id=ne18_runs.run_id)) logical_seal_identity
|
|
1573
|
+
FROM ne18_runs WHERE NOT EXISTS (SELECT 1 FROM ne18_run_deletion_tombstones d WHERE d.run_id=ne18_runs.run_id)
|
|
1574
|
+
AND (status='sealed' OR EXISTS
|
|
1575
|
+
(SELECT 1 FROM ne18_attempt_publications p WHERE p.origin_run_id=ne18_runs.run_id))
|
|
1576
|
+
ORDER BY run_id`).iterate();
|
|
1577
|
+
for (const row of inventory) {
|
|
1578
|
+
if (runCount >= types_ts_1.RECORD_SQLITE_MAX_VALIDATION_RUNS) {
|
|
1579
|
+
throw (0, errors_ts_1.sqliteError)("record-resource-limit-exceeded", "page-sealed-runs", "sealed cutoff exceeds its Run ceiling");
|
|
1580
|
+
}
|
|
1581
|
+
if ((runCount & 255) === 0 && Date.now() >= deadlineEpochMs) {
|
|
1582
|
+
throw (0, errors_ts_1.sqliteError)("record-resource-limit-exceeded", "page-sealed-runs", "sealed cutoff exceeded its deadline");
|
|
1583
|
+
}
|
|
1584
|
+
if (runCount > 0)
|
|
1585
|
+
cutoffHash.update(",");
|
|
1586
|
+
cutoffHash.update(JSON.stringify({ runId: text(row, "run_id"), logicalSealIdentity: text(row, "logical_seal_identity") }));
|
|
1587
|
+
runCount += 1;
|
|
1588
|
+
}
|
|
1589
|
+
cutoffHash.update("]");
|
|
1590
|
+
const identity = cutoffHash.digest("hex");
|
|
1591
|
+
return Object.freeze({ identity, runCount });
|
|
1592
|
+
})();
|
|
1593
|
+
const { identity, runCount } = cutoff;
|
|
1538
1594
|
if (expectedCutoffIdentity !== undefined && expectedCutoffIdentity !== identity) {
|
|
1539
1595
|
throw (0, errors_ts_1.sqliteError)("record-command-conflict", "page-sealed-runs", "sealed cutoff changed; restart pagination");
|
|
1540
1596
|
}
|
|
@@ -1648,8 +1704,15 @@ function readCollectionItemPage(connection, attachmentId, afterOrdinal, pageSize
|
|
|
1648
1704
|
const nextOrdinal = hasMore ? cursor : null;
|
|
1649
1705
|
return Object.freeze({ attachmentId, afterOrdinal, items: Object.freeze(items), nextOrdinal });
|
|
1650
1706
|
}
|
|
1651
|
-
|
|
1652
|
-
|
|
1707
|
+
function memoRecordRead(read, defer) {
|
|
1708
|
+
if (defer === undefined) {
|
|
1709
|
+
const value = read();
|
|
1710
|
+
return () => value;
|
|
1711
|
+
}
|
|
1712
|
+
let cached;
|
|
1713
|
+
return () => defer(() => (cached ??= { value: read() }).value);
|
|
1714
|
+
}
|
|
1715
|
+
function readPublishedSealedRun(connection, runId, defer) {
|
|
1653
1716
|
const run = (0, database_ts_1.recordStatement)(connection, `SELECT run_id,writer_generation,started_at,status,
|
|
1654
1717
|
coalesce(logical_seal_identity,'published:' || (SELECT max(p.published_revision) FROM ne18_attempt_publications p
|
|
1655
1718
|
WHERE p.origin_run_id=ne18_runs.run_id)) logical_seal_identity,core_payload,core_digest,
|
|
@@ -1766,59 +1829,50 @@ function readPublishedSealedRun(connection, runId) {
|
|
|
1766
1829
|
coreBytes: transferableBytes(bytes(row, "core_payload")), coreDigest: text(row, "core_digest") });
|
|
1767
1830
|
});
|
|
1768
1831
|
const attachmentRows = rows(connection, `SELECT attachment_id,owner_kind,owner_run_id,owner_attempt_id,family,family_revision,
|
|
1769
|
-
logical_identity,
|
|
1770
|
-
(SELECT count(*) FROM ne18_collection_items i WHERE i.attachment_id=a.attachment_id) item_count,
|
|
1771
|
-
(SELECT coalesce(sum(length(i.canonical_payload)),0) FROM ne18_collection_items i WHERE i.attachment_id=a.attachment_id) item_bytes
|
|
1832
|
+
logical_identity,canonical_digest,inventory_digest
|
|
1772
1833
|
FROM ne18_attachments a WHERE owner_run_id=?${publicationManaged ? ` AND canonical_payload IS NOT NULL AND
|
|
1773
1834
|
(owner_kind='run' OR EXISTS (SELECT 1 FROM ne18_attempt_publications p
|
|
1774
1835
|
WHERE p.origin_run_id=a.owner_run_id AND p.attempt_id=a.owner_attempt_id))` : ""} ORDER BY attachment_id`, runId);
|
|
1775
1836
|
const attachments = attachmentRows.map((row) => {
|
|
1776
1837
|
const attachmentId = text(row, "attachment_id");
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1838
|
+
const payload = memoRecordRead(() => {
|
|
1839
|
+
const stored = (0, database_ts_1.recordStatement)(connection, `SELECT canonical_payload,logical_inventory FROM ne18_attachments WHERE attachment_id=?`)
|
|
1840
|
+
.get(attachmentId);
|
|
1841
|
+
return { canonicalBytes: transferableBytes(bytes(stored, "canonical_payload")),
|
|
1842
|
+
logicalInventoryBytes: transferableBytes(bytes(stored, "logical_inventory")) };
|
|
1843
|
+
}, defer);
|
|
1844
|
+
const references = memoRecordRead(() => Object.freeze(rows(connection, `SELECT ordinal,target_owner_kind,target_family,canonical_payload,reference_digest
|
|
1780
1845
|
FROM ne18_attachment_references WHERE attachment_id=? ORDER BY ordinal`, attachmentId).map((reference) => Object.freeze({
|
|
1781
1846
|
ordinal: integer(reference, "ordinal"), owner: ownerKind(reference, "target_owner_kind"), family: text(reference, "target_family"),
|
|
1782
1847
|
canonicalBytes: transferableBytes(bytes(reference, "canonical_payload")), referenceDigest: text(reference, "reference_digest"),
|
|
1783
|
-
}));
|
|
1784
|
-
const contents = rows(connection, `SELECT content_id,logical_handle,byte_length,overall_digest,chunk_count
|
|
1848
|
+
}))), defer);
|
|
1849
|
+
const contents = memoRecordRead(() => Object.freeze(rows(connection, `SELECT content_id,logical_handle,byte_length,overall_digest,chunk_count
|
|
1785
1850
|
FROM ne18_contents WHERE attachment_id=? ORDER BY content_id`, attachmentId).map((content) => Object.freeze({
|
|
1786
1851
|
contentId: text(content, "content_id"), logicalHandle: text(content, "logical_handle"), byteLength: integer(content, "byte_length"),
|
|
1787
1852
|
digest: text(content, "overall_digest"), chunkCount: integer(content, "chunk_count"),
|
|
1788
|
-
}));
|
|
1853
|
+
}))), defer);
|
|
1854
|
+
const collection = memoRecordRead(() => {
|
|
1855
|
+
const aggregate = (0, database_ts_1.recordStatement)(connection, `SELECT count(*) item_count,coalesce(sum(length(canonical_payload)),0) item_bytes
|
|
1856
|
+
FROM ne18_collection_items WHERE attachment_id=?`).get(attachmentId);
|
|
1857
|
+
return { count: integer(aggregate, "item_count"), byteLength: integer(aggregate, "item_bytes") };
|
|
1858
|
+
}, defer);
|
|
1789
1859
|
return Object.freeze({ attachmentId, ownerKind: ownerKind(row, "owner_kind"), ownerRunId: text(row, "owner_run_id"),
|
|
1790
1860
|
...(optionalText(row, "owner_attempt_id") === undefined ? {} : { ownerAttemptId: optionalText(row, "owner_attempt_id") }),
|
|
1791
1861
|
family: text(row, "family"), familyRevision: integer(row, "family_revision"), logicalIdentity: text(row, "logical_identity"),
|
|
1792
|
-
canonicalBytes
|
|
1793
|
-
logicalInventoryBytes
|
|
1794
|
-
references
|
|
1795
|
-
|
|
1862
|
+
get canonicalBytes() { return payload().canonicalBytes; }, canonicalDigest: text(row, "canonical_digest"),
|
|
1863
|
+
get logicalInventoryBytes() { return payload().logicalInventoryBytes; }, inventoryDigest: text(row, "inventory_digest"),
|
|
1864
|
+
get references() { return references(); }, get contents() { return contents(); },
|
|
1865
|
+
get collectionItemCount() { return collection().count; }, get collectionItemByteLength() { return collection().byteLength; } });
|
|
1796
1866
|
});
|
|
1797
1867
|
const core = Object.freeze({ runId: text(run, "run_id"), writerGeneration: text(run, "writer_generation"), startedAt: text(run, "started_at"),
|
|
1798
1868
|
logicalSealIdentity: text(run, "logical_seal_identity"), ...(publicationManaged ? { publicationManaged: true, createdRevision: integer(publicationResource, "created_revision") } : {}), recordCoreBytes: transferableBytes(bytes(record, "record_payload")),
|
|
1799
1869
|
recordCoreDigest: text(record, "record_digest"), runCoreBytes, runCoreDigest,
|
|
1800
1870
|
slots: Object.freeze(slots), attempts: Object.freeze(attempts), members: Object.freeze(members), attachments: Object.freeze(attachments) });
|
|
1801
|
-
|
|
1802
|
-
const contentByteLength = core.attachments.reduce((count, attachment) => count + attachment.contents.reduce((subtotal, content) => subtotal + content.byteLength, 0), 0);
|
|
1803
|
-
const seal = (0, database_ts_1.recordStatement)(connection, "SELECT count(*) seal_count FROM ne18_run_seal_entries WHERE run_id=?").get(runId);
|
|
1804
|
-
const summary = Object.freeze({
|
|
1805
|
-
runId: core.runId,
|
|
1806
|
-
writerGeneration: core.writerGeneration,
|
|
1807
|
-
startedAt: core.startedAt,
|
|
1808
|
-
logicalSealIdentity: core.logicalSealIdentity,
|
|
1809
|
-
slotCount: core.slots.length,
|
|
1810
|
-
memberCount: core.members.length,
|
|
1811
|
-
attemptCount: core.attempts.length,
|
|
1812
|
-
attachmentCount: core.attachments.length,
|
|
1813
|
-
contentCount,
|
|
1814
|
-
contentByteLength,
|
|
1815
|
-
sealEntryCount: integer(seal, "seal_count"),
|
|
1816
|
-
});
|
|
1817
|
-
return Object.freeze({ core, summary });
|
|
1871
|
+
return Object.freeze({ core, get summary() { return readSealedRunSummary(connection, runId); } });
|
|
1818
1872
|
}
|
|
1819
|
-
/**
|
|
1820
|
-
function readSealedRunCore(connection, runId) {
|
|
1821
|
-
return readPublishedSealedRun(connection, runId)?.core;
|
|
1873
|
+
/** Inspection may defer Attachment reads within its existing pinned session. */
|
|
1874
|
+
function readSealedRunCore(connection, runId, defer) {
|
|
1875
|
+
return readPublishedSealedRun(connection, runId, defer)?.core;
|
|
1822
1876
|
}
|
|
1823
1877
|
/** Fixed, decoded projection sufficient to rebuild sealed Core and attachment metadata. */
|
|
1824
1878
|
function readSealedRunDocument(connection, runId) {
|