hiveagents-runtime 0.0.0-stage → 0.1.0-beta.3
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/LICENSE +202 -0
- package/README.md +89 -2
- package/dist/adapter-kit.d.ts +37 -0
- package/dist/adapter-kit.js +34 -0
- package/dist/adapter-kit.js.map +1 -0
- package/dist/agent-Bj5YPrO7.d.ts +169 -0
- package/dist/agent-D6OXR7UF.js +24 -0
- package/dist/agent-D6OXR7UF.js.map +1 -0
- package/dist/agent-readiness-KSGNKTGK.js +19 -0
- package/dist/agent-readiness-KSGNKTGK.js.map +1 -0
- package/dist/capture-runtime-GP6NZ2ee.d.ts +54 -0
- package/dist/chunk-2RK74GCA.js +2397 -0
- package/dist/chunk-2RK74GCA.js.map +1 -0
- package/dist/chunk-3TIYA3K5.js +55 -0
- package/dist/chunk-3TIYA3K5.js.map +1 -0
- package/dist/chunk-6FIXXWNM.js +1 -0
- package/dist/chunk-6FIXXWNM.js.map +1 -0
- package/dist/chunk-6XIJW65Q.js +52 -0
- package/dist/chunk-6XIJW65Q.js.map +1 -0
- package/dist/chunk-7LDQKJKI.js +248 -0
- package/dist/chunk-7LDQKJKI.js.map +1 -0
- package/dist/chunk-CPN4DOXH.js +115 -0
- package/dist/chunk-CPN4DOXH.js.map +1 -0
- package/dist/chunk-DAXPAV2L.js +810 -0
- package/dist/chunk-DAXPAV2L.js.map +1 -0
- package/dist/chunk-DQEMIGKC.js +291 -0
- package/dist/chunk-DQEMIGKC.js.map +1 -0
- package/dist/chunk-DZFFGUIA.js +81 -0
- package/dist/chunk-DZFFGUIA.js.map +1 -0
- package/dist/chunk-EEUYQFCP.js +106 -0
- package/dist/chunk-EEUYQFCP.js.map +1 -0
- package/dist/chunk-G6JV7WV6.js +521 -0
- package/dist/chunk-G6JV7WV6.js.map +1 -0
- package/dist/chunk-GFVYNPLS.js +118 -0
- package/dist/chunk-GFVYNPLS.js.map +1 -0
- package/dist/chunk-GS5U3KUN.js +201 -0
- package/dist/chunk-GS5U3KUN.js.map +1 -0
- package/dist/chunk-HB7FBSH2.js +960 -0
- package/dist/chunk-HB7FBSH2.js.map +1 -0
- package/dist/chunk-HZFZX5A3.js +21 -0
- package/dist/chunk-HZFZX5A3.js.map +1 -0
- package/dist/chunk-J7VAYJKM.js +595 -0
- package/dist/chunk-J7VAYJKM.js.map +1 -0
- package/dist/chunk-NCNSHOF7.js +52 -0
- package/dist/chunk-NCNSHOF7.js.map +1 -0
- package/dist/chunk-RH5A5U7G.js +202 -0
- package/dist/chunk-RH5A5U7G.js.map +1 -0
- package/dist/chunk-RX3XZENU.js +385 -0
- package/dist/chunk-RX3XZENU.js.map +1 -0
- package/dist/chunk-RXU2Q2HF.js +49 -0
- package/dist/chunk-RXU2Q2HF.js.map +1 -0
- package/dist/chunk-TG7NTMTR.js +208 -0
- package/dist/chunk-TG7NTMTR.js.map +1 -0
- package/dist/chunk-TWGEYWMO.js +1217 -0
- package/dist/chunk-TWGEYWMO.js.map +1 -0
- package/dist/chunk-UZPDDQVJ.js +2910 -0
- package/dist/chunk-UZPDDQVJ.js.map +1 -0
- package/dist/chunk-WMKO5XOE.js +601 -0
- package/dist/chunk-WMKO5XOE.js.map +1 -0
- package/dist/chunk-WOQBVJH5.js +175 -0
- package/dist/chunk-WOQBVJH5.js.map +1 -0
- package/dist/chunk-WVT5SEKC.js +581 -0
- package/dist/chunk-WVT5SEKC.js.map +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +26 -0
- package/dist/cli.js.map +1 -0
- package/dist/errors-BNHvvjn9.d.ts +98 -0
- package/dist/execution-halt-B8G0fOKS.d.ts +12 -0
- package/dist/execution-types-ClYYqPQP.d.ts +239 -0
- package/dist/host-ledger-VPRWVVOS.js +25 -0
- package/dist/host-ledger-VPRWVVOS.js.map +1 -0
- package/dist/hosted-runtime.d.ts +168 -0
- package/dist/hosted-runtime.js +858 -0
- package/dist/hosted-runtime.js.map +1 -0
- package/dist/index-B86C6VAD.d.ts +41 -0
- package/dist/index.d.ts +344 -0
- package/dist/index.js +8825 -0
- package/dist/index.js.map +1 -0
- package/dist/memory-items-BSTC0_R0.d.ts +28 -0
- package/dist/memory-tools.d.ts +222 -0
- package/dist/memory-tools.js +923 -0
- package/dist/memory-tools.js.map +1 -0
- package/dist/orchestration/dynamic.d.ts +854 -0
- package/dist/orchestration/dynamic.js +3150 -0
- package/dist/orchestration/dynamic.js.map +1 -0
- package/dist/orchestration/graph.d.ts +11 -0
- package/dist/orchestration/graph.js +9 -0
- package/dist/orchestration/graph.js.map +1 -0
- package/dist/orchestration/index.d.ts +2385 -0
- package/dist/orchestration/index.js +6409 -0
- package/dist/orchestration/index.js.map +1 -0
- package/dist/orchestration/log.d.ts +301 -0
- package/dist/orchestration/log.js +3058 -0
- package/dist/orchestration/log.js.map +1 -0
- package/dist/orchestration/memory.d.ts +711 -0
- package/dist/orchestration/memory.js +27 -0
- package/dist/orchestration/memory.js.map +1 -0
- package/dist/provider-DX5Mf0uq.d.ts +151 -0
- package/dist/routing/index.d.ts +29 -0
- package/dist/routing/index.js +386 -0
- package/dist/routing/index.js.map +1 -0
- package/dist/routing/learning/index.d.ts +433 -0
- package/dist/routing/learning/index.js +2502 -0
- package/dist/routing/learning/index.js.map +1 -0
- package/dist/runtime-BSjrnxeF.d.ts +283 -0
- package/dist/runtime-OISPXS4I.js +19 -0
- package/dist/runtime-OISPXS4I.js.map +1 -0
- package/dist/store-types-2YdceOMy.d.ts +78 -0
- package/dist/types-BB7KqceP.d.ts +52 -0
- package/dist/types-CIqkKXix.d.ts +86 -0
- package/dist/types-DTFc1qO6.d.ts +1065 -0
- package/dist/types-DYex3p7_.d.ts +88 -0
- package/docs/licenses/ruflo-memory-MIT.txt +21 -0
- package/docs/releases/0.1.0-beta.3.md +13 -0
- package/package.json +114 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/orchestration/log/sqlite-store.ts","../../src/orchestration/log/configuration.ts","../../src/orchestration/log/sqlite-storage.ts","../../src/orchestration/log/sqlite-schema.ts","../../src/orchestration/log/records.ts","../../src/orchestration/log/paging.ts","../../src/orchestration/log/reconstruction.ts","../../src/orchestration/log/sqlite-binding.ts","../../src/orchestration/log/artifacts-validation.ts","../../src/orchestration/log/artifacts-types.ts","../../src/orchestration/log/artifacts-files.ts","../../src/orchestration/log/artifacts.ts","../../src/orchestration/log/execution-database.ts","../../src/orchestration/log/execution-storage.ts","../../src/orchestration/log/execution-types.ts","../../src/orchestration/log/execution-schema.ts","../../src/orchestration/log/execution-validation.ts","../../src/orchestration/log/leases.ts","../../src/orchestration/log/record-codec.ts","../../src/orchestration/log/record-json.ts","../../src/orchestration/log/execution-capture.ts","../../src/orchestration/log/run-history-codec.ts","../../src/orchestration/log/run-history-storage.ts","../../src/orchestration/log/run-history.ts","../../src/orchestration/log/materialized.ts","../../src/orchestration/log/state-history.ts","../../src/orchestration/log/execution-metadata.ts","../../src/orchestration/log/effects.ts","../../src/orchestration/log/decision-reconciliation.ts","../../src/orchestration/log/decision-store.ts","../../src/orchestration/log/workflow-store.ts","../../src/orchestration/log/projection.ts","../../src/orchestration/log/projection-reconciliation.ts","../../src/orchestration/log/projection-codecs.ts","../../src/orchestration/log/projection-data.ts","../../src/orchestration/log/trace-projector.ts","../../src/orchestration/log/audit-projector.ts"],"sourcesContent":["import { DatabaseSync } from 'node:sqlite';\nimport { configuration, verifyCommit } from './configuration.js';\nimport type { Configuration } from './configuration.js';\nimport { capture } from './encoding.js';\nimport { captureQuery, pageRecords } from './paging.js';\nimport { appendRecords, lookupReceipt, readHead, requestIdentifier } from './records.js';\nimport { captureIdentity, reconstruct } from './reconstruction.js';\nimport { LogConnection, publishLog } from './sqlite-storage.js';\nimport { LogStoreError, logError, safeFailure } from './store-types.js';\nimport type { LogPage, LogQuery, LogSourceDescriptor, LogStoreOptions, RunReconstruction } from './store-types.js';\nimport type { LogCommit, LogReceipt, RunIdentity } from './types.js';\n\n/** Exclusive standalone connection. SQLite locking and transactions own durability, not this queue. */\nexport class SqliteRunLogStore {\n readonly descriptor: LogSourceDescriptor; readonly sourceId: string;\n readonly #connection: LogConnection; readonly #config: Configuration; readonly #abort = new AbortController();\n #tail: Promise<unknown> = Promise.resolve(); #pending = 0; #closed = false;\n constructor(options: LogStoreOptions) {\n this.#config = configuration(options); let db: DatabaseSync | undefined;\n try {\n publishLog(this.#config.databasePath, this.#config.systemId);\n db = new DatabaseSync(this.#config.databasePath);\n db.exec(`PRAGMA busy_timeout=${this.#config.busyTimeoutMs}; PRAGMA foreign_keys=ON; PRAGMA synchronous=FULL`);\n this.#connection = new LogConnection(db, this.#config.databasePath, this.#config.systemId, true);\n this.descriptor = this.#connection.source; this.sourceId = this.descriptor.sourceId;\n this.#connection.transaction(() => readHead(db!, this.descriptor));\n for (const key of ['descriptor', 'sourceId']) Object.defineProperty(this, key, { writable: false, configurable: false });\n } catch (error) { db?.close(); safeFailure(error); }\n }\n #enqueue<T>(captureInput: () => () => T | Promise<T>): Promise<T> {\n if (this.#closed) return Promise.reject(new LogStoreError('CLOSED'));\n if (this.#pending >= this.#config.maxPending) return Promise.reject(new LogStoreError('BUSY'));\n let body: () => T | Promise<T>; try { body = captureInput(); } catch (error) { return Promise.reject(error); }\n this.#pending++;\n const operation = this.#tail.then(async () => { if (this.#closed) logError('CLOSED'); return body(); });\n this.#tail = operation.catch(() => {});\n return operation.catch(safeFailure).finally(() => { this.#pending--; });\n }\n append(input: LogCommit): Promise<LogReceipt> {\n return this.#enqueue(() => {\n const commit = capture(input, this.descriptor);\n return async () => {\n this.#connection.assert();\n // Replay is content-bound, but need not re-read already pinned payload bytes.\n const existing = this.#connection.transaction(() => lookupReceipt(this.#connection.db, commit.requestId, this.descriptor));\n if (!existing) await verifyCommit(commit, this.#config, this.descriptor, this.#abort.signal);\n this.#connection.assert();\n return this.#connection.transaction(() => appendRecords(this.#connection.db, commit, this.descriptor), true);\n };\n });\n }\n lookupRequest(requestId: string): Promise<LogReceipt | undefined> {\n return this.#enqueue(() => { requestIdentifier(requestId); return () => this.#connection.transaction(() => {\n readHead(this.#connection.db, this.descriptor); return lookupReceipt(this.#connection.db, requestId, this.descriptor)?.receipt;\n }); });\n }\n readPage(query: LogQuery = {}): Promise<LogPage> {\n return this.#enqueue(() => { const captured = captureQuery(query); return () => this.#page(captured); });\n }\n #page(query: LogQuery): LogPage {\n return this.#connection.transaction(() => pageRecords(this.#connection.db, this.descriptor, this.#connection.storageDigest, query));\n }\n inspectRun(input: RunIdentity): Promise<RunReconstruction> {\n return this.#enqueue(() => {\n const identity = captureIdentity(input);\n return async () => {\n const result = await reconstruct(identity, this.descriptor, this.#config, query => this.#page(query), ref => this.#connection.transaction(() =>\n this.#connection.db.prepare('SELECT digest FROM main.oar_log_events WHERE sequence=?').get(ref.sequence)?.digest === ref.digest), this.#abort.signal);\n this.#connection.assert(); return result;\n };\n });\n }\n close(): void { if (!this.#closed) { this.#closed = true; this.#abort.abort(); this.#connection.close(); } }\n}\n","import { canonical, identifier, method, object, ownObject } from '../../shared/json.js';\nimport { types } from 'node:util';\nimport { validPath } from './sqlite-storage.js';\nimport { logError } from './store-types.js';\nimport type { LogPayloadVerifier, LogStoreOptions } from './store-types.js';\nimport type { LogCommit, PayloadReference } from './types.js';\nimport { capture } from './encoding.js';\nimport type { LogSourceDescriptor } from './store-types.js';\n\nexport interface Configuration {\n readonly databasePath: string; readonly systemId: string; readonly busyTimeoutMs: number;\n readonly maxPending: number; readonly schemas: ReadonlySet<string>;\n readonly verify: LogPayloadVerifier['verify'] | undefined;\n}\nexport function configuration(input: LogStoreOptions): Configuration {\n try {\n input = ownObject(input, ['databasePath', 'systemId', 'busyTimeoutMs', 'maxPending', 'supportedSchemas', 'payloadVerifier']);\n validPath(input.databasePath); identifier(input.systemId);\n const busyTimeoutMs = input.busyTimeoutMs ?? 5000, maxPending = input.maxPending ?? 2;\n if (!Number.isSafeInteger(busyTimeoutMs) || busyTimeoutMs < 0 || busyTimeoutMs > 60000\n || !Number.isSafeInteger(maxPending) || maxPending < 1 || maxPending > 64) logError('INVALID_INPUT');\n const schemas = new Set<string>(), supported = input.supportedSchemas ?? [];\n if (types.isProxy(supported) || !Array.isArray(supported) || Object.getPrototypeOf(supported) !== Array.prototype\n || supported.length > 256 || Object.getOwnPropertySymbols(supported).length\n || Object.keys(supported).length !== supported.length) logError('INVALID_INPUT');\n for (let index = 0; index < supported.length; index++) {\n const descriptor = Object.getOwnPropertyDescriptor(supported, String(index));\n if (!descriptor || !Object.hasOwn(descriptor, 'value')) logError('INVALID_INPUT');\n const schema = ownObject(descriptor.value, ['id', 'version']); object(schema); identifier(schema.id);\n if (Object.keys(schema).length !== 2 || !Number.isSafeInteger(schema.version) || Number(schema.version) < 1) logError('INVALID_INPUT');\n schemas.add(canonical(schema));\n }\n const verify = input.payloadVerifier === undefined ? undefined : method<LogPayloadVerifier['verify']>(input.payloadVerifier, 'verify');\n return Object.freeze({ databasePath: input.databasePath, systemId: input.systemId, busyTimeoutMs, maxPending, schemas, verify });\n } catch { return logError('INVALID_INPUT'); }\n}\nexport async function verifyReference(verify: Configuration['verify'], ref: PayloadReference, source: LogSourceDescriptor, signal?: AbortSignal): Promise<'verified' | 'missing' | 'corrupt' | 'unverified'> {\n if (!verify) return 'unverified';\n try {\n const result = await verify(ref, signal ? { signal } : {}); object(result, ['kind', 'reference']);\n if (Object.keys(result).length !== 2 || !['verified', 'missing', 'corrupt'].includes(result.kind as string)) return 'corrupt';\n const checked = capture({ requestId: 'verify', records: [{ identity: { systemId: ref.systemId, generation: ref.generation, runId: 'verify', agentId: 'verify', harness: { id: 'verify', version: '1', digest: '0'.repeat(64) } }, schema: { id: 'verify', version: 1 }, type: 'verify', causal: [], payload: { artifact: result.reference } }] }, source);\n if (canonical(checked.records[0]!.payload) !== canonical({ artifact: ref })) return 'corrupt';\n return result.kind as 'verified' | 'missing' | 'corrupt';\n } catch { return 'unverified'; }\n}\nexport async function verifyCommit(commit: LogCommit, config: Configuration, source: LogSourceDescriptor, signal?: AbortSignal): Promise<void> {\n for (const record of commit.records) if ('artifact' in record.payload) {\n if (await verifyReference(config.verify, record.payload.artifact, source, signal) !== 'verified') logError('PAYLOAD_UNAVAILABLE');\n }\n}\n","import { randomUUID } from 'node:crypto';\nimport { closeSync, fsyncSync, linkSync, lstatSync, openSync, realpathSync, unlinkSync } from 'node:fs';\nimport { dirname, isAbsolute, resolve } from 'node:path';\nimport { DatabaseSync } from 'node:sqlite';\nimport { types } from 'node:util';\nimport { digest } from './encoding.js';\nimport { LOG_APPLICATION_ID, LOG_SCHEMA_VERSION, installLogSchema, validateLogSchema } from './sqlite-schema.js';\nimport { logError, safeFailure } from './store-types.js';\nimport type { LogSourceDescriptor } from './store-types.js';\n\nexport function validPath(path: unknown): asserts path is string {\n if (typeof path !== 'string' || !isAbsolute(path) || path.includes('\\0') || resolve(path) !== path) logError('INVALID_INPUT');\n}\nfunction stat(path: string) {\n const value = lstatSync(path, { bigint: true }); if (!value.isFile() || value.isSymbolicLink()) logError('INTEGRITY'); return value;\n}\nlet checkedRuntime = false, nativeTransactionGetter: ((this: DatabaseSync) => boolean) | undefined;\nfunction transactionGetter(db: DatabaseSync, required: boolean): (() => boolean) | undefined {\n if (!checkedRuntime) {\n const sample = new DatabaseSync(':memory:');\n try { nativeTransactionGetter = Object.getOwnPropertyDescriptor(sample, 'isTransaction')?.get; checkedRuntime = true; }\n finally { sample.close(); }\n }\n if (!nativeTransactionGetter) { if (required) logError('UNSUPPORTED_RUNTIME'); return undefined; }\n const getter = nativeTransactionGetter.bind(db); getter(); return getter;\n}\nexport function publishLog(path: string, systemId: string): void {\n try { lstatSync(path); return; } catch (error) { if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error; }\n const temporary = `${path}.${randomUUID()}.initializing`; closeSync(openSync(temporary, 'wx', 0o600));\n let db: DatabaseSync | undefined;\n try {\n db = new DatabaseSync(temporary); db.exec('PRAGMA foreign_keys=ON; PRAGMA synchronous=FULL; BEGIN IMMEDIATE');\n installLogSchema(db, systemId); db.exec(`PRAGMA application_id=${LOG_APPLICATION_ID}; PRAGMA user_version=${LOG_SCHEMA_VERSION}; COMMIT`); db.close(); db = undefined;\n const fd = openSync(temporary, 'r'); try { fsyncSync(fd); } finally { closeSync(fd); }\n try { linkSync(temporary, path); } catch (error) { if ((error as NodeJS.ErrnoException).code !== 'EEXIST') throw error; }\n const parent = openSync(dirname(path), 'r'); try { fsyncSync(parent); } finally { closeSync(parent); }\n } finally { db?.close(); unlinkSync(temporary); }\n}\n/** Pins data storage, not an OS sandbox or authorization identity. */\n// Connections the SDK opened itself and never hands to application code (for\n// example LogExecutionDatabase's own connection, which it enrolls through a\n// binding internally). Only these may skip the per-assert full check.\nconst sdkOwnedConnections = new WeakSet<DatabaseSync>();\n/** Internal: mark a connection the SDK created and keeps private. */\nexport function markSdkOwnedConnection(db: DatabaseSync): void { sdkOwnedConnections.add(db); }\nexport class LogConnection {\n readonly source: LogSourceDescriptor; readonly storageDigest: string;\n readonly #dev: bigint; readonly #ino: bigint; readonly #canonicalPath: string; readonly #transactionGetter: (() => boolean) | undefined;\n #closed = false; #dataVersion: number; #ownedTransaction = false;\n // Enrolled (caller-owned) connections run application SQL on this same\n // connection, and data_version never reports same-connection commits: a caller\n // can disable foreign keys, commit an orphan and re-enable them unseen. Those\n // connections keep the full check on every assert.\n readonly #alwaysFull: boolean;\n constructor(readonly db: DatabaseSync, readonly path: string, readonly systemId: string, readonly standalone: boolean, enroll = false) {\n this.#alwaysFull = enroll && !sdkOwnedConnections.has(db);\n try {\n validPath(path); if (types.isProxy(db) || !(db instanceof DatabaseSync)) logError('INVALID_INPUT');\n this.#transactionGetter = transactionGetter(db, !standalone);\n if (enroll && !this.inTransaction()) logError('TRANSACTION_REQUIRED');\n const info = stat(path); this.#dev = info.dev; this.#ino = info.ino; this.#canonicalPath = realpathSync(path);\n const actual = db.prepare('PRAGMA database_list').all().find(row => row.name === 'main');\n if (!actual || realpathSync(String(actual.file)) !== this.#canonicalPath) logError('INTEGRITY');\n // Sample before validation so an intervening external commit is never marked as checked.\n const dataVersion = Number(db.prepare('PRAGMA main.data_version').get()!.data_version);\n if (enroll) {\n let began = false;\n try {\n db.exec('SAVEPOINT oar_log_enroll'); began = true; installLogSchema(db, systemId);\n this.source = validateLogSchema(db, systemId, standalone); db.exec('RELEASE oar_log_enroll'); began = false;\n } catch (error) {\n if (began) { try { db.exec('ROLLBACK TO oar_log_enroll; RELEASE oar_log_enroll'); } catch {} } throw error;\n }\n } else this.source = validateLogSchema(db, systemId, standalone);\n this.#dataVersion = dataVersion;\n this.storageDigest = digest(`oar-log-storage-v1\\n${this.#canonicalPath}\\n${info.dev}\\n${info.ino}`);\n } catch (error) { safeFailure(error); }\n }\n inTransaction(): boolean { return this.#ownedTransaction || (this.#transactionGetter?.() ?? false); }\n assert(insideTransaction = false): void {\n if (this.#closed) logError('CLOSED');\n try {\n const info = stat(this.path); if (info.dev !== this.#dev || info.ino !== this.#ino || realpathSync(this.path) !== this.#canonicalPath) logError('INTEGRITY');\n // Own commits do not change data_version. Catalog/descriptor/file guards still run every time;\n // on SDK-owned connections page and foreign-key corruption introduced by this connection is\n // checked again on reopen. Enrolled connections always run the full check (see #alwaysFull).\n const dataVersion = Number(this.db.prepare('PRAGMA main.data_version').get()!.data_version);\n const source = validateLogSchema(this.db, this.systemId, this.standalone, this.#alwaysFull || dataVersion !== this.#dataVersion);\n if (source.sourceId !== this.source.sourceId) logError('INTEGRITY');\n // Only cache checks outside both SDK-owned and caller-owned transactions.\n if (!insideTransaction && !this.inTransaction()) this.#dataVersion = dataVersion;\n } catch (error) { safeFailure(error); }\n }\n close(): void { if (!this.#closed) { this.#closed = true; if (this.standalone) this.db.close(); } }\n /** Only rolls back a transaction that this invocation successfully began. */\n transaction<T>(body: () => T, write = false): T {\n this.assert(); if (this.inTransaction()) { const result = body(); this.assert(); return result; }\n let began = false;\n try { this.db.exec(write ? 'BEGIN IMMEDIATE' : 'BEGIN'); began = true; this.#ownedTransaction = true; const result = body(); this.assert(); this.db.exec('COMMIT'); return result; }\n catch (error) { if (began) { try { if (!this.#transactionGetter || this.inTransaction()) this.db.exec('ROLLBACK'); } catch {} } return safeFailure(error); }\n finally { if (began) this.#ownedTransaction = false; }\n }\n}\n","import { randomUUID } from 'node:crypto';\nimport type { DatabaseSync } from 'node:sqlite';\nimport { canonical } from '../../shared/json.js';\nimport { digest, genesis } from './encoding.js';\nimport { logError } from './store-types.js';\nimport type { LogSourceDescriptor } from './store-types.js';\n\nexport const LOG_APPLICATION_ID = 0x4f41524c;\nexport const LOG_SCHEMA_VERSION = 1;\nconst integer = 'BETWEEN 1 AND 9007199254740991';\nexport const LOG_DDL: readonly string[] = Object.freeze([\n `CREATE TABLE oar_log_meta (id INTEGER PRIMARY KEY CHECK(id=1), descriptor_json TEXT NOT NULL,\n descriptor_digest TEXT NOT NULL, head_sequence INTEGER NOT NULL CHECK(head_sequence BETWEEN 0 AND 9007199254740991),\n head_digest TEXT NOT NULL) STRICT`,\n `CREATE TABLE oar_log_requests (request_id TEXT PRIMARY KEY NOT NULL, commit_digest TEXT NOT NULL,\n first_sequence INTEGER NOT NULL CHECK(first_sequence ${integer}), last_sequence INTEGER NOT NULL CHECK(last_sequence ${integer}),\n count INTEGER NOT NULL CHECK(count BETWEEN 1 AND 256 AND last_sequence=first_sequence+count-1),\n receipt_json TEXT NOT NULL, receipt_digest TEXT NOT NULL) STRICT`,\n `CREATE TABLE oar_log_events (sequence INTEGER PRIMARY KEY CHECK(sequence ${integer}),\n request_id TEXT NOT NULL REFERENCES oar_log_requests(request_id), ordinal INTEGER NOT NULL CHECK(ordinal BETWEEN 1 AND 256),\n source_id TEXT NOT NULL, system_id TEXT NOT NULL, generation INTEGER NOT NULL CHECK(generation ${integer}),\n run_id TEXT NOT NULL, agent_id TEXT NOT NULL, schema_id TEXT NOT NULL, schema_version INTEGER NOT NULL,\n previous_digest TEXT NOT NULL, digest TEXT NOT NULL, body_json TEXT NOT NULL CHECK(json_valid(body_json)\n AND source_id IS json_extract(body_json,'$.sourceId') AND sequence IS json_extract(body_json,'$.sequence')\n AND request_id IS json_extract(body_json,'$.requestId') AND ordinal IS json_extract(body_json,'$.ordinal')\n AND previous_digest IS json_extract(body_json,'$.previousDigest')\n AND system_id IS json_extract(body_json,'$.record.identity.systemId')\n AND generation IS json_extract(body_json,'$.record.identity.generation')\n AND run_id IS json_extract(body_json,'$.record.identity.runId') AND agent_id IS json_extract(body_json,'$.record.identity.agentId')\n AND schema_id IS json_extract(body_json,'$.record.schema.id') AND schema_version IS json_extract(body_json,'$.record.schema.version')),\n UNIQUE(request_id,ordinal)) STRICT`,\n `CREATE TABLE oar_log_payloads (sequence INTEGER PRIMARY KEY REFERENCES oar_log_events(sequence),\n reference_json TEXT NOT NULL, reference_digest TEXT NOT NULL) STRICT`,\n ...['events', 'requests', 'payloads'].flatMap(table => ['UPDATE', 'DELETE'].map(operation =>\n `CREATE TRIGGER oar_log_${table}_${operation.toLowerCase()} BEFORE ${operation} ON oar_log_${table} BEGIN SELECT RAISE(ABORT,'immutable execution log'); END`)),\n `CREATE TRIGGER oar_log_meta_delete BEFORE DELETE ON oar_log_meta BEGIN SELECT RAISE(ABORT,'immutable execution log'); END`,\n `CREATE TRIGGER oar_log_meta_descriptor BEFORE UPDATE OF descriptor_json,descriptor_digest,id ON oar_log_meta BEGIN SELECT RAISE(ABORT,'immutable execution log'); END`,\n]);\nconst expected = new Map(LOG_DDL.map(sql => [sql.match(/^CREATE (?:TABLE|TRIGGER) (\\w+)/)![1]!, sql]));\nexpected.set('sqlite_autoindex_oar_log_requests_1', ''); expected.set('sqlite_autoindex_oar_log_events_1', '');\nexport function installLogSchema(db: DatabaseSync, systemId: string): LogSourceDescriptor {\n const existing = db.prepare(\"SELECT name FROM main.sqlite_schema WHERE name GLOB 'oar_log_*'\").all();\n if (existing.length) return validateLogSchema(db, systemId);\n // A caller-owned transaction is the only enrollment boundary; partial namespace is never reset.\n for (const sql of LOG_DDL) db.exec(sql);\n const source = Object.freeze({ format: 1 as const, sourceId: randomUUID(), systemId });\n const encoded = canonical(source);\n db.prepare('INSERT INTO main.oar_log_meta VALUES(1,?,?,0,?)').run(encoded, digest(encoded), genesis(source));\n return source;\n}\nexport function validateLogSchema(db: DatabaseSync, systemId: string, standalone = false, full = true): LogSourceDescriptor {\n const rows = db.prepare(`SELECT name,tbl_name,sql FROM main.sqlite_schema ${standalone ? '' : \"WHERE name GLOB 'oar_log_*' OR tbl_name GLOB 'oar_log_*'\"}`).all();\n if (rows.length !== expected.size || rows.some(row => !expected.has(String(row.name)) || (row.sql ?? '') !== expected.get(String(row.name)))) logError('INTEGRITY');\n if (standalone && (db.prepare('PRAGMA main.application_id').get()!.application_id !== LOG_APPLICATION_ID\n || db.prepare('PRAGMA main.user_version').get()!.user_version !== LOG_SCHEMA_VERSION)) logError('INTEGRITY');\n if (full && (db.prepare('PRAGMA main.quick_check').all().some(row => row.quick_check !== 'ok')\n || db.prepare('PRAGMA main.foreign_key_check(oar_log_events)').all().length\n || db.prepare('PRAGMA main.foreign_key_check(oar_log_payloads)').all().length)) logError('INTEGRITY');\n const meta = db.prepare('SELECT descriptor_json,descriptor_digest FROM main.oar_log_meta WHERE id=1').get();\n if (!meta || typeof meta.descriptor_json !== 'string' || meta.descriptor_json.length > 2048 || digest(meta.descriptor_json) !== meta.descriptor_digest) logError('INTEGRITY');\n try {\n const source = JSON.parse(meta.descriptor_json) as LogSourceDescriptor;\n if (!source || canonical(source) !== meta.descriptor_json || Object.keys(source).sort().join(',') !== 'format,sourceId,systemId'\n || source.format !== 1 || typeof source.sourceId !== 'string' || !/^[\\da-f-]{36}$/.test(source.sourceId) || source.systemId !== systemId) logError('INTEGRITY');\n return Object.freeze(source);\n } catch { return logError('INTEGRITY'); }\n}\n","import type { DatabaseSync } from 'node:sqlite';\nimport { canonical, freeze, hash, identifier } from '../../shared/json.js';\nimport { capture, decodeEntry, digest, entryBody, genesis, MAX_EVENT_BYTES } from './encoding.js';\nimport { logError } from './store-types.js';\nimport type { LogEntry, LogSourceDescriptor } from './store-types.js';\nimport type { LogCommit, LogPosition, LogReceipt } from './types.js';\n\nexport function readHead(db: DatabaseSync, source: LogSourceDescriptor): LogPosition {\n const meta = db.prepare('SELECT head_sequence,head_digest FROM main.oar_log_meta WHERE id=1').get();\n const rows = db.prepare('SELECT COUNT(*) AS count,MIN(sequence) AS first,MAX(sequence) AS last FROM main.oar_log_events').get()!;\n if (!meta || !Number.isSafeInteger(meta.head_sequence) || Number(meta.head_sequence) < 0 || rows.count !== meta.head_sequence\n || (Number(rows.count) > 0 && (rows.first !== 1 || rows.last !== meta.head_sequence))) logError('INTEGRITY');\n try { hash(meta.head_digest); } catch { return logError('INTEGRITY'); }\n const expected = meta.head_sequence === 0 ? genesis(source)\n : db.prepare('SELECT digest FROM main.oar_log_events WHERE sequence=?').get(Number(meta.head_sequence))?.digest;\n if (meta.head_digest !== expected) logError('INTEGRITY');\n // SQL integrity work is global. Only record *decoding* has a per-page bound.\n if (db.prepare(`SELECT 1 FROM main.oar_log_requests r WHERE r.count !=\n (SELECT COUNT(*) FROM main.oar_log_events e WHERE e.request_id=r.request_id)\n OR r.first_sequence != (SELECT MIN(sequence) FROM main.oar_log_events e WHERE e.request_id=r.request_id)\n OR r.last_sequence != (SELECT MAX(sequence) FROM main.oar_log_events e WHERE e.request_id=r.request_id) LIMIT 1`).get()) logError('INTEGRITY');\n return Object.freeze({ sourceId: source.sourceId, sequence: Number(meta.head_sequence), digest: meta.head_digest as string });\n}\nfunction readRequestMetadata(db: DatabaseSync, requestId: string, source: LogSourceDescriptor) {\n const row = db.prepare(`SELECT commit_digest,first_sequence,last_sequence,count,receipt_digest,\n CASE WHEN length(receipt_json)<4096 THEN receipt_json END AS receipt_json FROM main.oar_log_requests WHERE request_id=?`).get(requestId);\n if (!row) return undefined;\n try {\n if (typeof row.receipt_json !== 'string' || digest(row.receipt_json) !== row.receipt_digest || !Number.isSafeInteger(row.count)\n || Number(row.count) < 1 || Number(row.count) > 256 || !Number.isSafeInteger(row.first_sequence) || Number(row.first_sequence) < 1\n || row.last_sequence !== Number(row.first_sequence) + Number(row.count) - 1) logError('INTEGRITY');\n hash(row.commit_digest);\n const first = db.prepare('SELECT digest FROM main.oar_log_events WHERE sequence=?').get(Number(row.first_sequence));\n const last = db.prepare('SELECT digest FROM main.oar_log_events WHERE sequence=?').get(Number(row.last_sequence));\n if (!first || !last) logError('INTEGRITY');\n const receipt: LogReceipt = { first: { sourceId: source.sourceId, sequence: Number(row.first_sequence), digest: first.digest as string },\n head: { sourceId: source.sourceId, sequence: Number(row.last_sequence), digest: last.digest as string }, count: Number(row.count) };\n if (canonical(receipt) !== row.receipt_json) logError('INTEGRITY');\n return { first_sequence: Number(row.first_sequence), last_sequence: Number(row.last_sequence), count: Number(row.count),\n commit_digest: row.commit_digest as string, receipt_json: row.receipt_json, receipt: freeze(receipt) };\n } catch { return logError('INTEGRITY'); }\n}\nexport function readEntry(db: DatabaseSync, sequence: number, source: LogSourceDescriptor): LogEntry {\n const row = db.prepare(`SELECT sequence,request_id,ordinal,source_id,system_id,generation,run_id,agent_id,schema_id,schema_version,\n previous_digest,digest,CASE WHEN length(CAST(body_json AS BLOB))<=? THEN body_json END AS body_json\n FROM main.oar_log_events WHERE sequence=?`).get(MAX_EVENT_BYTES, sequence);\n if (!row || typeof row.body_json !== 'string') logError('INTEGRITY');\n const entry = decodeEntry(row.body_json, row.digest, source), identity = entry.record.identity;\n if (row.sequence !== entry.sequence || row.request_id !== entry.requestId || row.ordinal !== entry.ordinal || row.source_id !== entry.sourceId\n || row.previous_digest !== entry.previousDigest || row.system_id !== identity.systemId || row.generation !== identity.generation\n || row.run_id !== identity.runId || row.agent_id !== identity.agentId || row.schema_id !== entry.record.schema.id || row.schema_version !== entry.record.schema.version) logError('INTEGRITY');\n const request = readRequestMetadata(db, entry.requestId, source);\n if (!request || entry.sequence !== Number(request.first_sequence) + entry.ordinal - 1 || entry.ordinal > Number(request.count)) logError('INTEGRITY');\n const pin = db.prepare(`SELECT CASE WHEN length(reference_json)<2048 THEN reference_json END AS reference_json,reference_digest\n FROM main.oar_log_payloads WHERE sequence=?`).get(sequence);\n if ('artifact' in entry.record.payload) {\n const encoded = canonical(entry.record.payload.artifact);\n if (!pin || pin.reference_json !== encoded || pin.reference_digest !== digest(encoded)) logError('INTEGRITY');\n } else if (pin) logError('INTEGRITY');\n return entry;\n}\nfunction position(entry: LogEntry): LogPosition { return { sourceId: entry.sourceId, sequence: entry.sequence, digest: entry.digest }; }\nexport function lookupReceipt(db: DatabaseSync, requestId: string, source: LogSourceDescriptor): { receipt: LogReceipt; commitDigest: string } | undefined {\n const row = readRequestMetadata(db, requestId, source);\n if (!row) return undefined;\n const entries: LogEntry[] = [];\n const before = Number(row.first_sequence) - 1;\n let previous = before === 0 ? genesis(source) : db.prepare('SELECT digest FROM main.oar_log_events WHERE sequence=?').get(before)?.digest;\n for (let i = 0; i < Number(row.count); i++) {\n const entry = readEntry(db, Number(row.first_sequence) + i, source);\n if (entry.requestId !== requestId || entry.ordinal !== i + 1 || entry.previousDigest !== previous) logError('INTEGRITY');\n entries.push(entry); previous = entry.digest;\n }\n const receipt = freeze({ first: position(entries[0]!), head: position(entries.at(-1)!), count: entries.length });\n const input = capture({ requestId, records: entries.map(entry => entry.record) }, source);\n if (canonical(receipt) !== row.receipt_json || digest(canonical(input)) !== row.commit_digest) logError('INTEGRITY');\n return { receipt, commitDigest: row.commit_digest as string };\n}\nexport function appendRecords(db: DatabaseSync, commit: LogCommit, source: LogSourceDescriptor): LogReceipt {\n const head = readHead(db, source), existing = lookupReceipt(db, commit.requestId, source), commitDigest = digest(canonical(commit));\n if (existing) { if (existing.commitDigest !== commitDigest) logError('REQUEST_CONFLICT'); return existing.receipt; }\n if (!Number.isSafeInteger(head.sequence + commit.records.length)) logError('INTEGRITY');\n const entries: LogEntry[] = []; let previous = head.digest;\n for (let index = 0; index < commit.records.length; index++) {\n const record = commit.records[index]!;\n for (const causal of record.causal) if (causal.sourceId === source.sourceId) {\n const known = entries.find(entry => entry.sequence === causal.sequence)\n ?? db.prepare('SELECT digest FROM main.oar_log_events WHERE sequence=?').get(causal.sequence);\n if (!known || known.digest !== causal.digest) logError('INVALID_INPUT');\n }\n const body = entryBody(source, head.sequence + index + 1, commit.requestId, index + 1, previous, record);\n const entry = { ...body, digest: digest(canonical(body)) }; entries.push(entry); previous = entry.digest;\n }\n const receipt = freeze({ first: position(entries[0]!), head: position(entries.at(-1)!), count: entries.length }), encodedReceipt = canonical(receipt);\n db.prepare('INSERT INTO main.oar_log_requests VALUES(?,?,?,?,?,?,?)').run(commit.requestId, commitDigest, receipt.first.sequence, receipt.head.sequence, receipt.count, encodedReceipt, digest(encodedReceipt));\n const insert = db.prepare('INSERT INTO main.oar_log_events VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?)');\n for (const entry of entries) {\n const identity = entry.record.identity, { digest: _, ...body } = entry;\n insert.run(entry.sequence, entry.requestId, entry.ordinal, entry.sourceId, identity.systemId, identity.generation,\n identity.runId, identity.agentId, entry.record.schema.id, entry.record.schema.version, entry.previousDigest, entry.digest, canonical(body));\n if ('artifact' in entry.record.payload) {\n const ref = canonical(entry.record.payload.artifact);\n db.prepare('INSERT INTO main.oar_log_payloads VALUES(?,?,?)').run(entry.sequence, ref, digest(ref));\n }\n }\n const update = db.prepare('UPDATE main.oar_log_meta SET head_sequence=?,head_digest=? WHERE id=1 AND head_sequence=? AND head_digest=?')\n .run(receipt.head.sequence, receipt.head.digest, head.sequence, head.digest);\n if (update.changes !== 1) logError('INTEGRITY');\n return receipt;\n}\nexport function requestIdentifier(value: unknown): asserts value is string { try { identifier(value); } catch { logError('INVALID_INPUT'); } }\n","import type { DatabaseSync } from 'node:sqlite';\nimport { canonical, freeze, hash, identifier, object, ownObject } from '../../shared/json.js';\nimport { digest, genesis } from './encoding.js';\nimport { readEntry, readHead } from './records.js';\nimport { logError } from './store-types.js';\nimport type { LogCursor, LogPage, LogQuery, LogSourceDescriptor } from './store-types.js';\nimport type { LogPosition } from './types.js';\n\nexport function captureQuery(input: LogQuery = {}): LogQuery {\n try {\n input = ownObject(input, ['generation', 'runId', 'agentId', 'limit', 'cursor']);\n const output: Record<string, unknown> = {};\n for (const key of ['runId', 'agentId'] as const) if (input[key] !== undefined) { identifier(input[key]); output[key] = input[key]; }\n if (input.generation !== undefined) { if (!Number.isSafeInteger(input.generation) || Number(input.generation) < 1) logError('INVALID_INPUT'); output.generation = input.generation; }\n const limit = input.limit ?? 64;\n if (!Number.isSafeInteger(limit) || Number(limit) < 1 || Number(limit) > 256) logError('INVALID_INPUT'); output.limit = limit;\n if (input.cursor !== undefined) {\n const cursor = input.cursor; object(cursor, ['format', 'filterDigest', 'after', 'through']);\n if (Object.keys(cursor).length !== 4 || cursor.format !== 1) logError('INVALID_INPUT'); hash(cursor.filterDigest);\n const positions = [cursor.after, cursor.through].map(value => {\n object(value, ['sourceId', 'sequence', 'digest']); identifier(value.sourceId); hash(value.digest);\n if (Object.keys(value).length !== 3 || !Number.isSafeInteger(value.sequence) || Number(value.sequence) < 0) logError('INVALID_INPUT');\n return { sourceId: value.sourceId, sequence: value.sequence, digest: value.digest };\n });\n output.cursor = { format: 1, filterDigest: cursor.filterDigest, after: positions[0], through: positions[1] };\n }\n return freeze(output) as LogQuery;\n } catch { return logError('INVALID_INPUT'); }\n}\nexport function pageRecords(db: DatabaseSync, source: LogSourceDescriptor, storageDigest: string, query: LogQuery): LogPage {\n const { cursor, limit = 64, ...filter } = query;\n const filterDigest = digest(canonical({ purpose: 'oar-log-page-v1', source, storageDigest, filter }));\n const head = readHead(db, source), through = cursor?.through ?? head;\n const after: LogPosition = cursor?.after ?? { sourceId: source.sourceId, sequence: 0, digest: genesis(source) };\n if (cursor && cursor.filterDigest !== filterDigest || through.sourceId !== source.sourceId || after.sourceId !== source.sourceId\n || after.sequence > through.sequence || through.sequence > head.sequence) logError('INVALID_INPUT');\n for (const position of [after, through]) {\n const known = position.sequence === 0 ? genesis(source) : db.prepare('SELECT digest FROM main.oar_log_events WHERE sequence=?').get(position.sequence)?.digest;\n if (known !== position.digest) logError('INTEGRITY');\n }\n const ids = db.prepare('SELECT sequence FROM main.oar_log_events WHERE sequence>? AND sequence<=? ORDER BY sequence LIMIT ?').all(after.sequence, through.sequence, limit + 1);\n const items = []; let previous = after.digest, last = after;\n const scanned = Math.min(ids.length, limit);\n for (let index = 0; index < scanned; index++) {\n const entry = readEntry(db, Number(ids[index]!.sequence), source);\n if (entry.sequence !== after.sequence + index + 1 || entry.previousDigest !== previous) logError('INTEGRITY');\n previous = entry.digest; last = { sourceId: source.sourceId, sequence: entry.sequence, digest: entry.digest };\n // Decode/hash/index validation always precedes filtering, including nonmatching rows.\n const identity = entry.record.identity;\n if ((filter.generation === undefined || identity.generation === filter.generation)\n && (filter.runId === undefined || identity.runId === filter.runId) && (filter.agentId === undefined || identity.agentId === filter.agentId)) items.push(entry);\n }\n const nextCursor: LogCursor | undefined = ids.length > limit ? { format: 1, filterDigest, after: last, through } : undefined;\n return freeze({ source, through, items, scanned, ...(nextCursor ? { nextCursor } : {}) });\n}\n","import { setImmediate } from 'node:timers/promises';\nimport { canonical, freeze } from '../../shared/json.js';\nimport { captureLogCommit } from './validation.js';\nimport { verifyReference } from './configuration.js';\nimport type { Configuration } from './configuration.js';\nimport { isLogStoreError, logError } from './store-types.js';\nimport type { LogCursor, LogPage, LogQuery, LogSourceDescriptor, ReconstructionIssue, RunReconstruction } from './store-types.js';\nimport type { LogPosition, RunIdentity } from './types.js';\n\nexport function captureIdentity(input: RunIdentity): RunIdentity {\n try { return captureLogCommit({ requestId: 'inspect', records: [{ identity: input, schema: { id: 'inspect', version: 1 }, type: 'inspect', causal: [], payload: { inline: null } }] }).records[0]!.identity; }\n catch { return logError('INVALID_INPUT'); }\n}\n/** No reducer or effect dispatcher: this reports captured-history coverage at one source head. */\nexport async function reconstruct(identity: RunIdentity, source: LogSourceDescriptor, config: Configuration,\n page: (query: LogQuery) => LogPage, causal: (position: LogPosition) => boolean, signal?: AbortSignal): Promise<RunReconstruction> {\n const issues = new Set<ReconstructionIssue>(); let count = 0, through: LogPosition | undefined, cursor: LogCursor | undefined;\n try {\n do {\n const batch = page(cursor ? { cursor } : {}); through = batch.through; cursor = batch.nextCursor;\n for (const entry of batch.items) {\n if (canonical(entry.record.identity) !== canonical(identity)) continue;\n count++;\n if (!config.schemas.has(canonical(entry.record.schema))) issues.add('UNKNOWN_SCHEMA');\n for (const ref of entry.record.causal) if (ref.sourceId !== source.sourceId || ref.sequence >= entry.sequence || !causal(ref)) issues.add('UNRESOLVED_CAUSAL_REFERENCE');\n if ('artifact' in entry.record.payload) {\n const result = await verifyReference(config.verify, entry.record.payload.artifact, source, signal);\n if (result !== 'verified') issues.add(result === 'missing' ? 'PAYLOAD_MISSING' : result === 'corrupt' ? 'PAYLOAD_CORRUPT' : 'PAYLOAD_UNVERIFIED');\n }\n }\n if (cursor) await setImmediate();\n } while (cursor);\n if (!count) issues.add('RUN_NOT_FOUND');\n return freeze({ scope: 'captured-history', kind: issues.size ? 'incomplete' : 'complete', identity, ...(through ? { through } : {}), eventCount: count, issues: [...issues].sort() });\n } catch (error) {\n if (!isLogStoreError(error) || error.code !== 'INTEGRITY') throw error;\n return freeze({ scope: 'captured-history', kind: 'corrupt', identity, ...(through ? { through } : {}), eventCount: count, issues: ['LOG_CORRUPT'] });\n }\n}\n","import type { DatabaseSync } from 'node:sqlite';\nimport { configuration, verifyCommit } from './configuration.js';\nimport type { Configuration } from './configuration.js';\nimport { capture } from './encoding.js';\nimport { captureQuery, pageRecords } from './paging.js';\nimport { appendRecords, lookupReceipt, readHead, requestIdentifier } from './records.js';\nimport { LogConnection } from './sqlite-storage.js';\nimport { logError, safeFailure } from './store-types.js';\nimport type { LogPage, LogQuery, LogSourceDescriptor, LogStoreOptions, PreparedLogCommit } from './store-types.js';\nimport type { LogCommit, LogReceipt } from './types.js';\n\nconst prepared = new WeakMap<object, { binding: SqliteLogBinding; commit: LogCommit }>();\n/** Explicit app-database enrollment; needs native DatabaseSync.isTransaction (Node >=22.16).\n * All append writes stay inside the caller transaction. This is a data binding, not a host capability. */\nexport class SqliteLogBinding {\n readonly descriptor: LogSourceDescriptor; readonly sourceId: string;\n readonly #connection: LogConnection; readonly #config: Configuration; readonly #abort = new AbortController();\n #pending = 0;\n constructor(db: DatabaseSync, options: LogStoreOptions) {\n this.#config = configuration(options);\n try {\n this.#connection = new LogConnection(db, this.#config.databasePath, this.#config.systemId, false, true);\n this.descriptor = this.#connection.source; this.sourceId = this.descriptor.sourceId;\n readHead(db, this.descriptor);\n for (const key of ['descriptor', 'sourceId']) Object.defineProperty(this, key, { writable: false, configurable: false });\n } catch (error) { safeFailure(error); }\n }\n async prepare(input: LogCommit): Promise<PreparedLogCommit> {\n this.#connection.assert(); if (this.#connection.inTransaction()) logError('TRANSACTION_REQUIRED');\n if (this.#pending >= this.#config.maxPending) logError('BUSY');\n const commit = capture(input, this.descriptor); this.#pending++;\n try {\n await verifyCommit(commit, this.#config, this.descriptor, this.#abort.signal);\n this.#connection.assert(); if (this.#connection.inTransaction()) logError('TRANSACTION_REQUIRED');\n const handle = Object.freeze({}) as PreparedLogCommit; prepared.set(handle, { binding: this, commit }); return handle;\n } catch (error) { return safeFailure(error); } finally { this.#pending--; }\n }\n appendInTransaction(input: LogCommit | PreparedLogCommit): LogReceipt {\n this.#connection.assert(); if (!this.#connection.inTransaction()) logError('TRANSACTION_REQUIRED');\n const saved = input && typeof input === 'object' ? prepared.get(input) : undefined;\n if (saved && saved.binding !== this) logError('INVALID_INPUT');\n const commit = saved?.commit ?? capture(input, this.descriptor);\n if (!saved && commit.records.some(record => 'artifact' in record.payload)) logError('PAYLOAD_UNAVAILABLE');\n const db = this.#connection.db; let began = false;\n try {\n db.exec('SAVEPOINT oar_log_append'); began = true;\n const receipt = appendRecords(db, commit, this.descriptor); this.#connection.assert();\n db.exec('RELEASE oar_log_append'); began = false; return receipt;\n } catch (error) {\n if (began) { try { db.exec('ROLLBACK TO oar_log_append; RELEASE oar_log_append'); } catch {} }\n return safeFailure(error);\n }\n }\n lookupRequest(requestId: string): LogReceipt | undefined {\n requestIdentifier(requestId); return this.#connection.transaction(() => {\n readHead(this.#connection.db, this.descriptor); return lookupReceipt(this.#connection.db, requestId, this.descriptor)?.receipt;\n });\n }\n readPage(query: LogQuery = {}): LogPage {\n const captured = captureQuery(query);\n return this.#connection.transaction(() => pageRecords(this.#connection.db, this.descriptor, this.#connection.storageDigest, captured));\n }\n close(): void { this.#abort.abort(); this.#connection.close(); }\n}\n","import { isAbsolute, resolve } from 'node:path';\nimport { types } from 'node:util';\nimport { hash, identifier, object } from '../../shared/json.js';\nimport type { PayloadReference } from './types.js';\nimport { LOG_ARTIFACT_LIMITS, LogArtifactError, type LogArtifactBinding, type LogArtifactOptions, type LogArtifactReadOptions, type LogArtifactWriteOptions } from './artifacts-types.js';\n\nconst lengthGetter = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Uint8Array.prototype), 'byteLength')!.get!;\nconst bufferGetter = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Uint8Array.prototype), 'buffer')!.get!;\nconst abortedGetter = Object.getOwnPropertyDescriptor(AbortSignal.prototype, 'aborted')!.get!;\nconst reasonGetter = Object.getOwnPropertyDescriptor(AbortSignal.prototype, 'reason')!.get!;\nfunction exact(input: unknown, keys: readonly string[], optional: readonly string[] = []): Record<string, unknown> {\n object(input, keys); if (keys.some(key => !optional.includes(key) && !Object.hasOwn(input, key))) throw new LogArtifactError('INVALID');\n return Object.fromEntries(Object.entries(Object.getOwnPropertyDescriptors(input)).map(([key, value]) => [key, value.value]));\n}\nconst text = (input: unknown) => { identifier(input); if (Buffer.from(input).toString('utf8') !== input) throw new LogArtifactError('INVALID'); return input; };\nfunction integer(input: unknown, minimum: number, maximum = Number.MAX_SAFE_INTEGER): number {\n if (typeof input !== 'number' || !Number.isSafeInteger(input) || input < minimum || input > maximum) throw new LogArtifactError('INVALID'); return input;\n}\nexport function artifactOptions(input: LogArtifactOptions) {\n try {\n const r = exact(input, ['directory', 'binding', 'maxBytes', 'maxPending'], ['maxBytes', 'maxPending']), b = exact(r.binding, ['sourceId', 'systemId', 'generation']);\n if (typeof r.directory !== 'string' || !isAbsolute(r.directory) || resolve(r.directory) !== r.directory || r.directory.includes('\\0') || Buffer.byteLength(r.directory) > 4096) throw Error();\n return Object.freeze({ directory: r.directory, binding: Object.freeze({ sourceId: text(b.sourceId), systemId: text(b.systemId), generation: integer(b.generation, 1) }),\n maxBytes: integer(r.maxBytes === undefined ? LOG_ARTIFACT_LIMITS.maxBytes : r.maxBytes, 1, LOG_ARTIFACT_LIMITS.maxBytes),\n maxPending: integer(r.maxPending === undefined ? 2 : r.maxPending, 1, 2) });\n } catch { throw new LogArtifactError('INVALID'); }\n}\nexport function artifactIoOptions(input: LogArtifactReadOptions | LogArtifactWriteOptions, write = false) {\n try {\n const r = exact(input, write ? ['signal', 'mediaType'] : ['signal'], ['signal']), signal = r.signal;\n if (signal !== undefined) { if (!signal || typeof signal !== 'object' || types.isProxy(signal)) throw Error(); Reflect.apply(abortedGetter, signal, []); }\n if (write && r.mediaType !== 'application/json' && r.mediaType !== 'application/octet-stream') throw Error();\n return Object.freeze({ signal: signal as AbortSignal | undefined, mediaType: r.mediaType as PayloadReference['mediaType'] | undefined });\n } catch { throw new LogArtifactError('INVALID'); }\n}\nexport function artifactReference(input: unknown, binding: LogArtifactBinding, maximum: number): PayloadReference {\n try {\n const r = exact(input, ['sourceId', 'systemId', 'generation', 'digest', 'bytes', 'mediaType']);\n if (r.sourceId !== binding.sourceId || r.systemId !== binding.systemId || r.generation !== binding.generation\n || r.mediaType !== 'application/json' && r.mediaType !== 'application/octet-stream') throw Error(); hash(r.digest);\n return Object.freeze({ ...binding, digest: r.digest, bytes: integer(r.bytes, 0, maximum), mediaType: r.mediaType });\n } catch { throw new LogArtifactError('INVALID'); }\n}\nexport function artifactInputSize(input: unknown, maximum: number): number {\n if (typeof input === 'string') { const size = Buffer.byteLength(input); if (size > maximum) throw new LogArtifactError('LIMIT'); return size; }\n if (!input || typeof input !== 'object' || types.isProxy(input) || !types.isUint8Array(input)) throw new LogArtifactError('INVALID');\n const size = Reflect.apply(lengthGetter, input, []) as number, backing = Reflect.apply(bufferGetter, input, []) as unknown;\n if (types.isSharedArrayBuffer(backing)) throw new LogArtifactError('INVALID'); if (size > maximum) throw new LogArtifactError('LIMIT'); return size;\n}\nexport function captureArtifactInput(input: string | Uint8Array, length: number): string | Buffer {\n if (typeof input === 'string') return input;\n try { const bytes = Buffer.allocUnsafe(length); Uint8Array.prototype.set.call(bytes, input); return bytes; }\n catch { throw new LogArtifactError('INVALID'); }\n}\nexport function checkArtifactAbort(signal?: AbortSignal): void {\n if (signal && Reflect.apply(abortedGetter, signal, [])) throw new LogArtifactError('ABORTED', Reflect.apply(reasonGetter, signal, []));\n}\nexport function* artifactChunks(input: string | Buffer): Generator<Buffer> {\n if (typeof input !== 'string') { for (let offset = 0; offset < input.length; offset += LOG_ARTIFACT_LIMITS.chunkBytes) yield input.subarray(offset, offset + LOG_ARTIFACT_LIMITS.chunkBytes); return; }\n for (let offset = 0; offset < input.length;) {\n let end = Math.min(input.length, offset + 16384); const tail = input.charCodeAt(end - 1);\n if (end < input.length && tail >= 0xd800 && tail <= 0xdbff) end--;\n if (end === offset) end++;\n const slice = input.slice(offset, end), bytes = Buffer.from(slice); if (bytes.toString('utf8') !== slice) throw new LogArtifactError('INVALID');\n yield bytes; offset = end;\n }\n}\nexport const artifactFailure = (cause: unknown) => cause instanceof LogArtifactError ? cause : new LogArtifactError('IO', cause);\nexport const artifactYield = () => new Promise<void>(resolve => setImmediate(resolve));\n","import type { PayloadReference } from './types.js';\nexport interface LogArtifactBinding { readonly sourceId: string; readonly systemId: string; readonly generation: number }\nexport interface LogArtifactOptions { readonly directory: string; readonly binding: LogArtifactBinding; readonly maxBytes?: number; readonly maxPending?: number }\nexport interface LogArtifactReadOptions { readonly signal?: AbortSignal }\nexport interface LogArtifactWriteOptions extends LogArtifactReadOptions { readonly mediaType: PayloadReference['mediaType'] }\n/** Byte integrity/durability data only, never execution, recovery or release permission. */\nexport interface LogArtifactVerification { readonly kind: 'verified' | 'missing' | 'corrupt'; readonly reference: PayloadReference }\nexport type LogArtifactErrorCode = 'INVALID' | 'LIMIT' | 'BUSY' | 'ABORTED' | 'MISSING' | 'CORRUPT' | 'IO';\nexport class LogArtifactError extends Error {\n constructor(readonly code: LogArtifactErrorCode, cause?: unknown) {\n super('Execution log artifact operation failed', cause === undefined ? undefined : { cause }); this.name = 'LogArtifactError';\n }\n}\nexport const LOG_ARTIFACT_LIMITS = Object.freeze({ chunkBytes: 65536, maxBytes: 128 * 1024 * 1024, maxPending: 2 });\n","import fs from 'node:fs';\nimport { createHash, randomBytes } from 'node:crypto';\nimport { dirname, join } from 'node:path';\nimport { canonical } from '../../shared/json.js';\nimport type { PayloadReference } from './types.js';\nimport { LOG_ARTIFACT_LIMITS, LogArtifactError, type LogArtifactBinding } from './artifacts-types.js';\nimport { artifactChunks, artifactYield, checkArtifactAbort } from './artifacts-validation.js';\ninterface Identity { dev: bigint; ino: bigint }\nconst same = (a: Identity, b: Identity) => a.dev === b.dev && a.ino === b.ino;\nconst uid = () => { if (!process.getuid) throw new LogArtifactError('IO'); return BigInt(process.getuid()); };\nconst directory = (path: string, expected?: Identity) => {\n const s = fs.lstatSync(path, { bigint: true });\n if (!s.isDirectory() || s.isSymbolicLink() || s.uid !== uid() || (s.mode & 0o777n) !== 0o700n || fs.realpathSync(path) !== path || expected && !same(s, expected)) throw new LogArtifactError('CORRUPT'); return s;\n};\nconst file = (path: string, length: number) => {\n const s = fs.lstatSync(path, { bigint: true });\n if (!s.isFile() || s.isSymbolicLink() || s.uid !== uid() || (s.mode & 0o777n) !== 0o600n || s.nlink !== 1n || s.size !== BigInt(length) || fs.realpathSync(path) !== path) throw new LogArtifactError('CORRUPT'); return s;\n};\nconst fsync = (fd: number) => new Promise<void>((resolve, reject) => fs.fsync(fd, error => error ? reject(error) : resolve()));\nconst rename = (from: string, to: string) => new Promise<void>((resolve, reject) => fs.rename(from, to, error => error ? reject(error) : resolve()));\nconst link = (from: string, to: string) => new Promise<void>((resolve, reject) => fs.link(from, to, error => error ? reject(error) : resolve()));\nconst unlink = (path: string) => new Promise<void>((resolve, reject) => fs.unlink(path, error => error ? reject(error) : resolve()));\nconst write = (fd: number, bytes: Buffer, offset: number) => new Promise<number>((resolve, reject) => fs.write(fd, bytes, offset, bytes.length - offset, null, (error, count) => error ? reject(error) : resolve(count)));\nconst read = (fd: number, bytes: Buffer, count: number, position: number) => new Promise<number>((resolve, reject) => fs.read(fd, bytes, 0, count, position, (error, used) => error ? reject(error) : resolve(used)));\nexport interface ArtifactFiles {\n readonly scope: string;\n check(): void; quarantine(fd: number): void;\n snapshot(): { faulted: boolean; quarantined: number };\n}\nasync function syncDirectory(context: ArtifactFiles | undefined, path: string, expected?: Identity) {\n context?.check(); const before = directory(path, expected), fd = fs.openSync(path, fs.constants.O_RDONLY | fs.constants.O_DIRECTORY | fs.constants.O_NOFOLLOW); let owned = true;\n try { if (!same(before, fs.fstatSync(fd, { bigint: true }))) { if (context) { owned = false; context.quarantine(fd); } throw new LogArtifactError('CORRUPT'); } await fsync(fd); context?.check(); directory(path, before); }\n finally { if (owned) fs.closeSync(fd); }\n}\nexport async function createArtifactFiles(root: string, binding: LogArtifactBinding): Promise<ArtifactFiles> {\n try { fs.lstatSync(root); } catch (error) { if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error; directory(dirname(root)); try { fs.mkdirSync(root, { mode: 0o700 }); } catch (cause) { if ((cause as NodeJS.ErrnoException).code !== 'EEXIST') throw cause; } }\n await syncDirectory(undefined, dirname(root));\n const rootIdentity = directory(root), scope = join(root, createHash('sha256').update(canonical(binding)).digest('hex'));\n try { fs.mkdirSync(scope, { mode: 0o700 }); } catch (error) { if ((error as NodeJS.ErrnoException).code !== 'EEXIST') throw error; }\n const scopeIdentity = directory(scope); let faulted = false, quarantined: number | undefined;\n const context: ArtifactFiles = Object.freeze({ scope,\n check() { if (faulted) throw new LogArtifactError('CORRUPT'); directory(root, rootIdentity); directory(scope, scopeIdentity); },\n quarantine(fd: number) { faulted = true; if (quarantined === undefined) quarantined = fd; /* Deliberate bounded retention. No GC/finalizer may close a possible SQLite alias. */ },\n snapshot: () => ({ faulted, quarantined: Number(quarantined !== undefined) }),\n });\n await syncDirectory(context, root, rootIdentity); await syncDirectory(context, scope, scopeIdentity); return context;\n}\n/** One pinned descriptor, one capped pass; read never verifies then reopens a named file. */\nexport async function scanArtifact(context: ArtifactFiles, reference: PayloadReference, signal?: AbortSignal, retain = false): Promise<Buffer | undefined> {\n context.check(); checkArtifactAbort(signal); const path = join(context.scope, `${reference.digest}.blob`);\n let before: fs.BigIntStats;\n try { before = file(path, reference.bytes); } catch (error) { if ((error as NodeJS.ErrnoException).code === 'ENOENT') throw new LogArtifactError('MISSING'); throw error; }\n const fd = fs.openSync(path, fs.constants.O_RDONLY | fs.constants.O_NOFOLLOW); let owned = true;\n const chunks: Buffer[] = [], buffer = Buffer.allocUnsafe(LOG_ARTIFACT_LIMITS.chunkBytes), hash = createHash('sha256'); let used = 0;\n try {\n let pinned: fs.BigIntStats;\n try { pinned = fs.fstatSync(fd, { bigint: true }); } catch (cause) { owned = false; context.quarantine(fd); throw new LogArtifactError('CORRUPT', cause); }\n if (!same(before, pinned) || !pinned.isFile() || pinned.size !== before.size || pinned.nlink !== 1n || pinned.uid !== uid() || (pinned.mode & 0o777n) !== 0o600n) { owned = false; context.quarantine(fd); throw new LogArtifactError('CORRUPT'); }\n while (used < reference.bytes) {\n context.check(); checkArtifactAbort(signal); const count = await read(fd, buffer, Math.min(buffer.length, reference.bytes - used), used);\n if (count < 1) throw new LogArtifactError('CORRUPT'); hash.update(buffer.subarray(0, count)); if (retain) chunks.push(Buffer.from(buffer.subarray(0, count))); used += count;\n await artifactYield();\n }\n checkArtifactAbort(signal); const after = file(path, reference.bytes), current = fs.fstatSync(fd, { bigint: true });\n if (!same(before, after) || !same(before, current) || before.mtimeNs !== after.mtimeNs || before.ctimeNs !== after.ctimeNs || current.size !== before.size || hash.digest('hex') !== reference.digest) throw new LogArtifactError('CORRUPT');\n // Establish durability even for a caller-built data ref to a concurrently completed final file.\n await fsync(fd); await syncDirectory(context, context.scope); checkArtifactAbort(signal); const last = file(path, reference.bytes);\n if (!same(before, last) || before.mtimeNs !== last.mtimeNs || before.ctimeNs !== last.ctimeNs) throw new LogArtifactError('CORRUPT');\n return retain ? Buffer.concat(chunks, used) : undefined;\n } finally { buffer.fill(0); for (const chunk of chunks) chunk.fill(0); if (owned) fs.closeSync(fd); }\n}\nasync function verifyPublishedDescriptor(context: ArtifactFiles, fd: number, reference: PayloadReference, path: string, signal?: AbortSignal) {\n context.check(); const before = fs.fstatSync(fd, { bigint: true }), named = file(path, reference.bytes), hash = createHash('sha256'), buffer = Buffer.allocUnsafe(LOG_ARTIFACT_LIMITS.chunkBytes); let used = 0;\n if (!same(before, named) || before.size !== BigInt(reference.bytes)) throw new LogArtifactError('CORRUPT');\n try {\n while (used < reference.bytes) { context.check(); checkArtifactAbort(signal); const count = await read(fd, buffer, Math.min(buffer.length, reference.bytes - used), used);\n if (count < 1) throw new LogArtifactError('CORRUPT'); hash.update(buffer.subarray(0, count)); used += count; await artifactYield(); }\n const after = file(path, reference.bytes), pinned = fs.fstatSync(fd, { bigint: true });\n if (!same(before, after) || !same(before, pinned) || before.mtimeNs !== after.mtimeNs || before.ctimeNs !== after.ctimeNs\n || pinned.size !== before.size || hash.digest('hex') !== reference.digest) throw new LogArtifactError('CORRUPT');\n return after;\n } finally { buffer.fill(0); }\n}\nasync function removeOwned(path: string, identity: Identity) {\n let s: fs.BigIntStats; try { s = fs.lstatSync(path, { bigint: true }); } catch (error) { if ((error as NodeJS.ErrnoException).code === 'ENOENT') return; throw error; }\n if (!s.isFile() || s.isSymbolicLink() || !same(s, identity)) throw new LogArtifactError('CORRUPT'); await unlink(path);\n}\n/** Private staging rename followed by atomic no-replace publication. No final artifact is overwritten. */\nexport async function publishArtifact(context: ArtifactFiles, binding: LogArtifactBinding, input: string | Buffer, length: number, mediaType: PayloadReference['mediaType'], signal?: AbortSignal): Promise<PayloadReference> {\n context.check(); checkArtifactAbort(signal); const temporary = join(context.scope, `.${randomBytes(32).toString('hex')}.tmp`), ready = join(context.scope, `.${randomBytes(32).toString('hex')}.ready`);\n const fd = fs.openSync(temporary, fs.constants.O_RDWR | fs.constants.O_CREAT | fs.constants.O_EXCL | fs.constants.O_NOFOLLOW, 0o600);\n let identity: fs.BigIntStats | undefined;\n let renamed = false, failure: unknown; const hash = createHash('sha256'); let bytes = 0;\n try {\n identity = fs.fstatSync(fd, { bigint: true }); fs.fchmodSync(fd, 0o600);\n for (const chunk of artifactChunks(input)) {\n context.check(); checkArtifactAbort(signal); let offset = 0;\n while (offset < chunk.length) { const count = await write(fd, chunk, offset); if (count < 1) throw new LogArtifactError('IO'); offset += count; }\n hash.update(chunk); bytes += chunk.length; if (bytes > length) throw new LogArtifactError('LIMIT'); await artifactYield();\n }\n if (bytes !== length) throw new LogArtifactError('CORRUPT'); await fsync(fd); checkArtifactAbort(signal); context.check();\n try { fs.lstatSync(ready); throw new LogArtifactError('CORRUPT'); } catch (error) { if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error; }\n await rename(temporary, ready); renamed = true; const staged = fs.lstatSync(ready, { bigint: true });\n if (!same(identity, staged) || !staged.isFile() || staged.isSymbolicLink()) throw new LogArtifactError('CORRUPT');\n const reference: PayloadReference = Object.freeze({ ...binding, digest: hash.digest('hex'), bytes, mediaType }), final = join(context.scope, `${reference.digest}.blob`);\n let created = false, duplicate: fs.BigIntStats | undefined;\n try { await link(ready, final); created = true; } catch (error) { if ((error as NodeJS.ErrnoException).code !== 'EEXIST') throw error; duplicate = file(final, reference.bytes); await scanArtifact(context, reference, signal); }\n await removeOwned(ready, identity); renamed = false; context.check(); const published = file(final, reference.bytes);\n if (created && !same(published, identity) || duplicate && (!same(published, duplicate) || duplicate.mtimeNs !== published.mtimeNs || duplicate.ctimeNs !== published.ctimeNs)) throw new LogArtifactError('CORRUPT');\n const verified = created ? await verifyPublishedDescriptor(context, fd, reference, final, signal) : published;\n await syncDirectory(context, context.scope); checkArtifactAbort(signal); const last = file(final, reference.bytes);\n if (!same(verified, last) || verified.mtimeNs !== last.mtimeNs || verified.ctimeNs !== last.ctimeNs) throw new LogArtifactError('CORRUPT'); return reference;\n } catch (error) { failure = error; throw error; }\n finally { fs.closeSync(fd); if (identity) try { await removeOwned(renamed ? ready : temporary, identity); } catch (error) { if (failure === undefined) throw error; } }\n}\n","import type { PayloadReference } from './types.js';\nimport { artifactFailure, artifactInputSize, artifactIoOptions, artifactOptions, artifactReference, captureArtifactInput, checkArtifactAbort } from './artifacts-validation.js';\nimport { createArtifactFiles, publishArtifact, scanArtifact } from './artifacts-files.js';\nimport { LogArtifactError, type LogArtifactOptions, type LogArtifactReadOptions, type LogArtifactWriteOptions, type LogArtifactVerification } from './artifacts-types.js';\nexport type { LogArtifactOptions, LogArtifactReadOptions, LogArtifactWriteOptions, LogArtifactVerification, LogArtifactBinding } from './artifacts-types.js';\nexport { LogArtifactError } from './artifacts-types.js';\nconst observed = <T>(promise: Promise<T>) => { void promise.catch(() => {}); return promise; };\n/** Optional private artifact storage. Refs/pins are DATA; the execution log owns its transactional reference records. No GC or permission API. */\nexport async function createLogArtifactStore(input: LogArtifactOptions) {\n const options = artifactOptions(input); let files: Awaited<ReturnType<typeof createArtifactFiles>>;\n try { files = await createArtifactFiles(options.directory, options.binding); } catch (cause) { throw artifactFailure(cause); }\n let pending = 0;\n const reserve = () => { files.check(); if (pending >= options.maxPending) throw new LogArtifactError('BUSY'); pending++; };\n const run = <T>(work: () => Promise<T>): Promise<T> => observed((async () => {\n try { return await work(); } catch (cause) { throw artifactFailure(cause); } finally { pending--; }\n })());\n return Object.freeze({\n write(input: string | Uint8Array, operation: LogArtifactWriteOptions): Promise<PayloadReference> {\n let owned: string | Buffer;\n try { const io = artifactIoOptions(operation, true), length = artifactInputSize(input, options.maxBytes); checkArtifactAbort(io.signal); reserve();\n try { owned = captureArtifactInput(input, length); } catch (error) { pending--; throw error; }\n return run(async () => { try { return await publishArtifact(files, options.binding, owned, length, io.mediaType!, io.signal); } finally { if (typeof owned !== 'string') owned.fill(0); } });\n } catch (cause) { return observed(Promise.reject(artifactFailure(cause))); }\n },\n verify(input: PayloadReference, operation: LogArtifactReadOptions = {}): Promise<LogArtifactVerification> {\n let reference: PayloadReference;\n try { reference = artifactReference(input, options.binding, options.maxBytes); const io = artifactIoOptions(operation); checkArtifactAbort(io.signal);\n try { reserve(); } catch (cause) { if (cause instanceof LogArtifactError && cause.code === 'CORRUPT') return Promise.resolve(Object.freeze({ kind: 'corrupt', reference })); throw cause; }\n return run(async () => { try { await scanArtifact(files, reference, io.signal); return Object.freeze({ kind: 'verified', reference }); }\n catch (cause) { if (cause instanceof LogArtifactError && (cause.code === 'MISSING' || cause.code === 'CORRUPT')) return Object.freeze({ kind: cause.code === 'MISSING' ? 'missing' : 'corrupt', reference }); throw cause; } });\n } catch (cause) { return observed(Promise.reject(artifactFailure(cause))); }\n },\n read(input: PayloadReference, operation: LogArtifactReadOptions = {}): Promise<Uint8Array> {\n try { const reference = artifactReference(input, options.binding, options.maxBytes), io = artifactIoOptions(operation); checkArtifactAbort(io.signal); reserve();\n return run(async () => (await scanArtifact(files, reference, io.signal, true))!);\n } catch (cause) { return observed(Promise.reject(artifactFailure(cause))); }\n },\n snapshot: () => Object.freeze({ pending, maxPending: options.maxPending, maxBytes: options.maxBytes, ...files.snapshot() }),\n });\n}\n","import { DatabaseSync } from 'node:sqlite';\nimport { ownObject } from '../../shared/json.js';\nimport { configuration } from './configuration.js';\nimport { SqliteLogBinding } from './sqlite-binding.js';\nimport { LogConnection, markSdkOwnedConnection } from './sqlite-storage.js';\nimport { publishExecutionDatabase } from './execution-storage.js';\nimport { validateExecutionSchema } from './execution-schema.js';\nimport { captureIdentity } from './reconstruction.js';\nimport { captureQuery, pageRecords } from './paging.js';\nimport { captureExecutionValue, runKey } from './execution-validation.js';\nimport { inspectOwner, recoverOwner } from './leases.js';\nimport { executionFailure, safeExecutionFailure } from './execution-types.js';\nimport type { ExecutionOwnership, LogExecutionDatabaseOptions, StandaloneStoppedAcknowledgement } from './execution-types.js';\nimport type { LogPage, LogQuery, LogSourceDescriptor } from './store-types.js';\nimport type { RunIdentity } from './types.js';\nimport { RecordCodec } from './record-codec.js';\nimport { executionCaptureStore } from './execution-capture.js';\nimport type { LogCommit, LogReceipt } from './types.js';\n\n/** Private data-store plumbing, not a Host capability or a public arbitrary-SQL port. */\nexport interface ExecutionDatabaseContext {\n readonly db: DatabaseSync; readonly binding: SqliteLogBinding; readonly source: LogSourceDescriptor; readonly storageDigest: string; readonly codec: RecordCodec;\n assert(): void; transaction<T>(body: () => T, write?: boolean): T;\n}\nconst contexts = new WeakMap<LogExecutionDatabase, ExecutionDatabaseContext>();\nexport function executionContext(database: LogExecutionDatabase): ExecutionDatabaseContext {\n const context = contexts.get(database); if (!context) executionFailure('INVALID_STATE'); context.assert(); return context;\n}\n/** Dedicated SQLite data database. All callbacks stay outside transactions; no execution issuer. */\nexport class LogExecutionDatabase {\n readonly sourceId: string; readonly descriptor: LogSourceDescriptor;\n readonly captureStore: Readonly<{ append(commit: LogCommit): Promise<LogReceipt> }>;\n readonly #db: DatabaseSync; readonly #binding: SqliteLogBinding; readonly #pin: LogConnection;\n readonly #codec: RecordCodec;\n #closed = false; #dataVersion: number; #ownedTransaction = false;\n constructor(options: LogExecutionDatabaseOptions) {\n let db: DatabaseSync | undefined;\n try {\n options = ownObject(options, ['databasePath', 'systemId', 'busyTimeoutMs', 'artifactStore', 'maxRecordBytes']);\n const config = configuration({ databasePath: options.databasePath, systemId: options.systemId, ...(options.busyTimeoutMs !== undefined ? { busyTimeoutMs: options.busyTimeoutMs } : {}) });\n this.#codec = new RecordCodec(options.artifactStore, options.maxRecordBytes); publishExecutionDatabase(config.databasePath, config.systemId, config.busyTimeoutMs);\n db = new DatabaseSync(config.databasePath); markSdkOwnedConnection(db);\n db.exec(`PRAGMA busy_timeout=${config.busyTimeoutMs}; PRAGMA foreign_keys=ON; PRAGMA synchronous=FULL`);\n const dataVersion = Number(db.prepare('PRAGMA main.data_version').get()!.data_version);\n validateExecutionSchema(db); this.#dataVersion = dataVersion; db.exec('BEGIN IMMEDIATE');\n this.#binding = new SqliteLogBinding(db, { databasePath: config.databasePath, systemId: config.systemId,\n ...(this.#codec.port ? { payloadVerifier: { verify: this.#codec.verify.bind(this.#codec) } } : {}) }); db.exec('COMMIT');\n this.#db = db; this.#pin = new LogConnection(db, config.databasePath, config.systemId, false);\n this.descriptor = this.#binding.descriptor; this.sourceId = this.descriptor.sourceId;\n for (const key of ['descriptor', 'sourceId']) Object.defineProperty(this, key, { writable: false, configurable: false });\n const context: ExecutionDatabaseContext = { db, binding: this.#binding, source: this.descriptor, storageDigest: this.#pin.storageDigest, codec: this.#codec,\n assert: () => this.#assert(), transaction: (body, write) => this.#transaction(body, write) };\n contexts.set(this, context); this.captureStore = executionCaptureStore(context);\n Object.defineProperty(this, 'captureStore', { writable: false, configurable: false }); this.#assert();\n } catch (error) { db?.close(); safeExecutionFailure(error); }\n }\n #assert(): void {\n if (this.#closed) executionFailure('CLOSED');\n try {\n this.#pin.assert(this.#ownedTransaction);\n // Keep a separate watermark: the log pin does not validate execution-table foreign keys.\n const dataVersion = Number(this.#db.prepare('PRAGMA main.data_version').get()!.data_version);\n validateExecutionSchema(this.#db, dataVersion !== this.#dataVersion);\n if (!this.#ownedTransaction && !this.#pin.inTransaction()) this.#dataVersion = dataVersion;\n } catch (error) { safeExecutionFailure(error); }\n }\n #transaction<T>(body: () => T, write = false): T {\n this.#assert(); let began = false;\n try {\n this.#db.exec(write ? 'BEGIN IMMEDIATE' : 'BEGIN'); began = true; this.#ownedTransaction = true;\n const result = body(); this.#assert(); this.#db.exec('COMMIT'); return result;\n } catch (error) {\n if (began) { try { if (this.#db.isTransaction) this.#db.exec('ROLLBACK'); } catch {} }\n return safeExecutionFailure(error);\n } finally { if (began) this.#ownedTransaction = false; }\n }\n async readPage(query: LogQuery = {}): Promise<LogPage> {\n const captured = captureQuery(query); return this.#transaction(() => pageRecords(this.#db, this.descriptor, this.#pin.storageDigest, captured));\n }\n inspectOwnership(kind: 'decision' | 'workflow', input: RunIdentity): ExecutionOwnership | undefined {\n const identity = captureIdentity(input); if (identity.systemId !== this.descriptor.systemId || !['decision', 'workflow'].includes(kind)) executionFailure('INVALID_STATE');\n return this.#transaction(() => inspectOwner(executionContext(this), kind, runKey(this.sourceId, identity)));\n }\n /** Trusted standalone operator acknowledgement. No PID/age inference and no Host stopped-work proof. */\n recoverAbandoned(expected: ExecutionOwnership, acknowledgement: StandaloneStoppedAcknowledgement): void {\n const captured = captureExecutionValue(expected), ack = captureExecutionValue(acknowledgement);\n if (!ack || typeof ack !== 'object' || Array.isArray(ack) || Object.keys(ack).length !== 1 || (ack as Record<string, unknown>).ownerStopped !== true) executionFailure('INVALID_STATE');\n this.#transaction(() => recoverOwner(executionContext(this), captured), true);\n }\n close(): void { if (!this.#closed) { this.#closed = true; this.#codec.close(); this.#binding.close(); this.#pin.close(); this.#db.close(); } }\n}\n","import { randomUUID } from 'node:crypto';\nimport { closeSync, fsyncSync, linkSync, lstatSync, openSync, unlinkSync } from 'node:fs';\nimport { dirname } from 'node:path';\nimport { DatabaseSync } from 'node:sqlite';\nimport { publishLog } from './sqlite-storage.js';\nimport { installExecutionSchema } from './execution-schema.js';\nexport function publishExecutionDatabase(path: string, systemId: string, busyTimeoutMs: number): void {\n try { lstatSync(path); return; } catch (error) { if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error; }\n const temporary = `${path}.${randomUUID()}.initializing`; let db: DatabaseSync | undefined;\n try {\n publishLog(temporary, systemId); db = new DatabaseSync(temporary);\n db.exec(`PRAGMA foreign_keys=ON; PRAGMA synchronous=FULL; PRAGMA busy_timeout=${busyTimeoutMs}; BEGIN IMMEDIATE`);\n installExecutionSchema(db); db.exec('COMMIT'); db.close(); db = undefined;\n const file = openSync(temporary, 'r'); try { fsyncSync(file); } finally { closeSync(file); }\n try { linkSync(temporary, path); } catch (error) { if ((error as NodeJS.ErrnoException).code !== 'EEXIST') throw error; }\n const parent = openSync(dirname(path), 'r'); try { fsyncSync(parent); } finally { closeSync(parent); }\n } finally { db?.close(); try { unlinkSync(temporary); } catch (error) { if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error; } }\n}\n","import { ExecutionHaltedError, rethrowExecutionHalt } from '../../public/execution-halt.js';\nimport type { RunIdentity } from './types.js';\nimport type { createLogArtifactStore } from './artifacts.js';\nexport type ExecutionArtifactStore = Pick<Awaited<ReturnType<typeof createLogArtifactStore>>, 'write' | 'read' | 'verify'>;\nexport interface LogExecutionDatabaseOptions {\n readonly databasePath: string; readonly systemId: string; readonly busyTimeoutMs?: number;\n readonly artifactStore?: ExecutionArtifactStore; readonly maxRecordBytes?: number;\n}\nexport interface ManagedEffectAssociation {\n readonly identity: RunIdentity; readonly stepId: string; readonly effectKey: string;\n readonly operation: Readonly<{ id: string; version: string; targetDigest: string; contentDigest: string; provider?: string; model?: string }>;\n readonly parentEffectKey?: string;\n}\nexport interface CapturedEffectAssociation extends ManagedEffectAssociation { readonly sourceId: string }\nexport interface ExecutionOwnership {\n readonly format: 1; readonly sourceId: string; readonly kind: 'decision' | 'workflow'; readonly runKey: string;\n readonly identity: RunIdentity; readonly ownerId: string;\n}\nexport interface StandaloneStoppedAcknowledgement { readonly ownerStopped: true }\nexport type LogExecutionFailure = 'INVALID_STATE' | 'STORAGE_UNCERTAIN' | 'INTEGRITY' | 'RUN_OWNED'\n | 'EFFECT_BINDING_CONFLICT' | 'OUTCOME_UNKNOWN' | 'CLOSED' | 'PAYLOAD_CODEC_REQUIRED' | 'PAYLOAD_UNAVAILABLE' | 'CODEC_LIMIT' | 'CODEC_BUSY';\nconst failures: readonly string[] = ['INVALID_STATE', 'STORAGE_UNCERTAIN', 'INTEGRITY', 'RUN_OWNED', 'EFFECT_BINDING_CONFLICT', 'OUTCOME_UNKNOWN', 'CLOSED', 'PAYLOAD_CODEC_REQUIRED', 'PAYLOAD_UNAVAILABLE', 'CODEC_LIMIT', 'CODEC_BUSY'];\nconst genuine = new WeakSet<object>();\n/** Nominal SDK halt: infrastructure/effect uncertainty is not negative model-quality evidence. */\nexport class LogExecutionError extends ExecutionHaltedError {\n readonly reason: LogExecutionFailure;\n constructor(reason: LogExecutionFailure) {\n const safe = failures.includes(reason) ? reason : 'INVALID_STATE';\n super({ sanitizedDiagnostics: Object.freeze({ reason: safe }) }); this.reason = safe; genuine.add(this); Object.freeze(this);\n }\n}\nexport function executionFailure(reason: LogExecutionFailure): never { throw new LogExecutionError(reason); }\nexport function safeExecutionFailure(error: unknown): never {\n rethrowExecutionHalt(error);\n if (error && typeof error === 'object' && genuine.has(error)) throw error;\n return executionFailure('STORAGE_UNCERTAIN');\n}\n","import type { DatabaseSync } from 'node:sqlite';\nimport { LOG_DDL } from './sqlite-schema.js';\nimport { executionFailure } from './execution-types.js';\nexport const EXECUTION_APPLICATION_ID = 0x4f415245;\nexport const EXECUTION_DDL: readonly string[] = Object.freeze([\n `CREATE TABLE oar_execution_leases (kind TEXT NOT NULL CHECK(kind IN ('decision','workflow')),run_key TEXT NOT NULL,\n owner_json TEXT NOT NULL CHECK(json_valid(owner_json) AND kind IS json_extract(owner_json,'$.kind') AND run_key IS json_extract(owner_json,'$.runKey')),\n owner_digest TEXT NOT NULL,PRIMARY KEY(kind,run_key)) STRICT`,\n `CREATE TABLE oar_execution_effects (effect_id TEXT PRIMARY KEY NOT NULL,run_key TEXT NOT NULL,step_id TEXT NOT NULL,\n generation INTEGER NOT NULL,decision_id TEXT NOT NULL,association_json TEXT NOT NULL CHECK(json_valid(association_json)\n AND step_id IS json_extract(association_json,'$.stepId') AND generation IS json_extract(association_json,'$.identity.generation')),\n association_digest TEXT NOT NULL,UNIQUE(generation,decision_id)) STRICT`,\n `CREATE TABLE oar_execution_states (kind TEXT NOT NULL CHECK(kind IN ('decision','workflow')),state_key TEXT NOT NULL,\n identity_json TEXT NOT NULL CHECK(json_valid(identity_json)),identity_digest TEXT NOT NULL,\n revision INTEGER NOT NULL CHECK(revision BETWEEN 1 AND 9007199254740991),record_json TEXT NOT NULL CHECK(json_valid(record_json)),record_digest TEXT NOT NULL,\n sequence INTEGER NOT NULL REFERENCES oar_log_events(sequence),event_digest TEXT NOT NULL,request_id TEXT NOT NULL REFERENCES oar_log_requests(request_id),\n PRIMARY KEY(kind,state_key)) STRICT`,\n `CREATE TRIGGER oar_execution_effects_update BEFORE UPDATE ON oar_execution_effects BEGIN SELECT RAISE(ABORT,'immutable managed association'); END`,\n `CREATE TRIGGER oar_execution_effects_delete BEFORE DELETE ON oar_execution_effects BEGIN SELECT RAISE(ABORT,'immutable managed association'); END`,\n `CREATE TRIGGER oar_execution_states_delete BEFORE DELETE ON oar_execution_states BEGIN SELECT RAISE(ABORT,'immutable managed state'); END`,\n `CREATE TRIGGER oar_execution_states_key BEFORE UPDATE OF kind,state_key,identity_json,identity_digest ON oar_execution_states BEGIN SELECT RAISE(ABORT,'immutable managed state'); END`,\n]);\nconst expected = new Map([...LOG_DDL, ...EXECUTION_DDL].map(sql => [sql.match(/^CREATE (?:TABLE|TRIGGER) (\\w+)/)![1]!, sql]));\nfor (const table of ['oar_log_requests', 'oar_log_events', 'oar_execution_leases', 'oar_execution_effects', 'oar_execution_states']) expected.set(`sqlite_autoindex_${table}_1`, '');\nexpected.set('sqlite_autoindex_oar_execution_effects_2', '');\nexport function installExecutionSchema(db: DatabaseSync): void { for (const sql of EXECUTION_DDL) db.exec(sql); db.exec(`PRAGMA application_id=${EXECUTION_APPLICATION_ID}; PRAGMA user_version=1`); }\nexport function validateExecutionSchema(db: DatabaseSync, full = true): void {\n if (db.prepare('PRAGMA main.application_id').get()?.application_id !== EXECUTION_APPLICATION_ID\n || db.prepare('PRAGMA main.user_version').get()?.user_version !== 1) executionFailure('INTEGRITY');\n const objects = db.prepare('SELECT name,sql FROM main.sqlite_schema').all();\n if (objects.length !== expected.size || objects.some(row => !expected.has(String(row.name)) || (row.sql ?? '') !== expected.get(String(row.name)))) executionFailure('INTEGRITY');\n if (full && db.prepare('PRAGMA main.foreign_key_check').all().length) executionFailure('INTEGRITY');\n}\n","import { canonical, freeze, hash, identifier, object } from '../../shared/json.js';\nimport { captureLogCommit } from './validation.js';\nimport { captureIdentity } from './reconstruction.js';\nimport { digest } from './encoding.js';\nimport { executionFailure } from './execution-types.js';\nimport type { CapturedEffectAssociation, ManagedEffectAssociation } from './execution-types.js';\nimport type { LogJsonValue, RunIdentity } from './types.js';\nconst neutral: RunIdentity = { systemId: 'validation', generation: 1, runId: 'validation', agentId: 'validation', harness: { id: 'sdk', version: '1', digest: '0'.repeat(64) } };\n/** Bounded private data capture; preserves object insertion order for legacy decision hashes. */\nexport function captureExecutionValue(input: unknown): LogJsonValue {\n try { return (captureLogCommit({ requestId: 'capture', records: [{ identity: neutral, schema: { id: 'capture', version: 1 }, type: 'capture', causal: [], payload: { inline: input } }] }).records[0]!.payload as { inline: LogJsonValue }).inline; }\n catch { return executionFailure('PAYLOAD_CODEC_REQUIRED'); }\n}\nexport function runKey(sourceId: string, identity: RunIdentity): string { return digest(canonical({ sourceId, identity })); }\nexport function effectId(association: CapturedEffectAssociation): string {\n return digest(canonical({ sourceId: association.sourceId, systemId: association.identity.systemId, generation: association.identity.generation, effectKey: association.effectKey }));\n}\nexport function captureAssociation(input: ManagedEffectAssociation, sourceId: string, systemId: string): CapturedEffectAssociation {\n try {\n const next = captureExecutionValue(input); object(next, ['identity', 'stepId', 'effectKey', 'operation', 'parentEffectKey']);\n const identity = captureIdentity(next.identity as unknown as RunIdentity); if (identity.systemId !== systemId) executionFailure('INVALID_STATE');\n identifier(next.stepId); identifier(next.effectKey); if (next.parentEffectKey !== undefined) identifier(next.parentEffectKey);\n const operation = next.operation; object(operation, ['id', 'version', 'targetDigest', 'contentDigest', 'provider', 'model']);\n identifier(operation.id); identifier(operation.version); hash(operation.targetDigest); hash(operation.contentDigest);\n if (operation.provider !== undefined) identifier(operation.provider); if (operation.model !== undefined) identifier(operation.model);\n if (Object.keys(next).length < 4 || Object.keys(operation).length < 4 || next.parentEffectKey === next.effectKey) executionFailure('INVALID_STATE');\n return freeze({ ...next, sourceId, identity }) as unknown as CapturedEffectAssociation;\n } catch { return executionFailure('INVALID_STATE'); }\n}\nexport function encodeExecutionValue(input: unknown): string {\n const encoded = JSON.stringify(captureExecutionValue(input));\n if (Buffer.byteLength(encoded) > 60000) executionFailure('PAYLOAD_CODEC_REQUIRED');\n return encoded;\n}\nexport function decodeExecutionValue(text: unknown, expectedDigest: unknown): LogJsonValue {\n try {\n if (typeof text !== 'string' || Buffer.byteLength(text) > 60000 || digest(text) !== expectedDigest) executionFailure('INTEGRITY');\n const value = captureExecutionValue(JSON.parse(text)); if (JSON.stringify(value) !== text) executionFailure('INTEGRITY'); return value;\n } catch { return executionFailure('INTEGRITY'); }\n}\n","import { randomUUID } from 'node:crypto';\nimport { canonical, freeze, object } from '../../shared/json.js';\nimport { digest } from './encoding.js';\nimport { captureIdentity } from './reconstruction.js';\nimport { runKey } from './execution-validation.js';\nimport { executionFailure } from './execution-types.js';\nimport type { ExecutionOwnership } from './execution-types.js';\nimport type { ExecutionDatabaseContext } from './execution-database.js';\nimport type { LogJsonValue, RunIdentity } from './types.js';\nconst active = new Set<string>();\nfunction activeKey(context: ExecutionDatabaseContext, ownerId: string): string { return `${context.storageDigest}:${ownerId}`; }\nexport function inspectOwner(context: ExecutionDatabaseContext, kind: 'decision' | 'workflow', key: string): ExecutionOwnership | undefined {\n const row = context.db.prepare('SELECT owner_json,owner_digest FROM main.oar_execution_leases WHERE kind=? AND run_key=?').get(kind, key);\n if (!row) return undefined;\n try {\n if (typeof row.owner_json !== 'string' || row.owner_json.length > 4096 || digest(row.owner_json) !== row.owner_digest) executionFailure('INTEGRITY');\n const owner = JSON.parse(row.owner_json); object(owner, ['format', 'sourceId', 'kind', 'runKey', 'identity', 'ownerId']);\n if (Object.keys(owner).length !== 6 || canonical(owner) !== row.owner_json || owner.format !== 1 || owner.sourceId !== context.source.sourceId\n || owner.kind !== kind || owner.runKey !== key || typeof owner.ownerId !== 'string' || !/^[\\da-f-]{36}$/.test(owner.ownerId)) executionFailure('INTEGRITY');\n const identity = captureIdentity(owner.identity as RunIdentity);\n if (identity.systemId !== context.source.systemId || runKey(context.source.sourceId, identity) !== key) executionFailure('INTEGRITY');\n return freeze(owner) as unknown as ExecutionOwnership;\n } catch { return executionFailure('INTEGRITY'); }\n}\nfunction ownerEvent(context: ExecutionDatabaseContext, owner: ExecutionOwnership, type: string): void {\n context.binding.appendInTransaction({ requestId: `owner:${type}:${owner.ownerId}`, records: [{ identity: owner.identity, schema: { id: 'oar.execution.ownership', version: 1 }, type: `ownership.${type}`, causal: [], payload: { inline: owner as unknown as LogJsonValue } }] });\n}\nexport function acquireOwner(context: ExecutionDatabaseContext, kind: 'decision' | 'workflow', identity: RunIdentity): ExecutionOwnership {\n const key = runKey(context.source.sourceId, identity); if (inspectOwner(context, kind, key)) executionFailure('RUN_OWNED');\n const owner: ExecutionOwnership = freeze({ format: 1, sourceId: context.source.sourceId, kind, runKey: key, identity, ownerId: randomUUID() });\n const encoded = canonical(owner); context.db.prepare('INSERT INTO main.oar_execution_leases VALUES(?,?,?,?)').run(kind, key, encoded, digest(encoded));\n ownerEvent(context, owner, 'acquired'); return owner;\n}\nexport function markOwnerActive(context: ExecutionDatabaseContext, owner: ExecutionOwnership): void { active.add(activeKey(context, owner.ownerId)); }\nexport function markOwnerDrained(context: ExecutionDatabaseContext, owner: ExecutionOwnership): void { active.delete(activeKey(context, owner.ownerId)); }\nexport function assertOwner(context: ExecutionDatabaseContext, owner: ExecutionOwnership): void {\n context.assert();\n const actual = inspectOwner(context, owner.kind, owner.runKey); if (!actual || canonical(actual) !== canonical(owner)) executionFailure('RUN_OWNED');\n}\nexport function releaseOwner(context: ExecutionDatabaseContext, owner: ExecutionOwnership): void {\n assertOwner(context, owner); ownerEvent(context, owner, 'released');\n if (context.db.prepare('DELETE FROM main.oar_execution_leases WHERE kind=? AND run_key=? AND owner_digest=?').run(owner.kind, owner.runKey, digest(canonical(owner))).changes !== 1) executionFailure('RUN_OWNED');\n}\nexport function recoverOwner(context: ExecutionDatabaseContext, expected: LogJsonValue): void {\n try {\n object(expected, ['format', 'sourceId', 'kind', 'runKey', 'identity', 'ownerId']);\n if (!['decision', 'workflow'].includes(expected.kind as string) || typeof expected.runKey !== 'string') executionFailure('INVALID_STATE');\n const owner = inspectOwner(context, expected.kind as 'decision' | 'workflow', expected.runKey);\n if (!owner || canonical(owner) !== canonical(expected) || active.has(activeKey(context, owner.ownerId))) executionFailure('RUN_OWNED');\n ownerEvent(context, owner, 'operator-recovered'); context.db.prepare('DELETE FROM main.oar_execution_leases WHERE kind=? AND run_key=? AND owner_digest=?').run(owner.kind, owner.runKey, digest(canonical(owner)));\n } catch { return executionFailure('RUN_OWNED'); }\n}\n","import { types } from 'node:util';\nimport { hash, method, object } from '../../shared/json.js';\nimport { isExecutionHalted } from '../../public/execution-halt.js';\nimport { captureLogCommit } from './validation.js';\nimport { captureRecordJson, decodeRecordJson, encodeRecordJson } from './record-json.js';\nimport { executionFailure } from './execution-types.js';\nimport type { ExecutionArtifactStore } from './execution-types.js';\nimport type { LogJsonValue, PayloadReference, RunIdentity } from './types.js';\nexport interface RecordBody { readonly codec: 'oar.execution.record-json'; readonly version: 1; readonly reference: PayloadReference }\nexport function captureRecordBody(input: unknown, sourceId: string, identity: RunIdentity, maxBytes: number): RecordBody {\n try {\n object(input, ['codec', 'version', 'reference']); if (Object.keys(input).length !== 3 || input.codec !== 'oar.execution.record-json' || input.version !== 1) executionFailure('PAYLOAD_UNAVAILABLE');\n const checked = captureLogCommit({ requestId: 'reference', records: [{ identity, schema: { id: 'reference', version: 1 }, type: 'reference', causal: [], payload: { artifact: input.reference } }] });\n const reference = (checked.records[0]!.payload as { artifact: PayloadReference }).artifact;\n if (reference.sourceId !== sourceId || reference.bytes > maxBytes || reference.mediaType !== 'application/json') executionFailure('PAYLOAD_UNAVAILABLE');\n return Object.freeze({ codec: 'oar.execution.record-json', version: 1, reference });\n } catch { return executionFailure('PAYLOAD_UNAVAILABLE'); }\n}\n/** Captured trusted content port only; no execution, recovery, GC or permission callback. */\nexport class RecordCodec {\n readonly maxBytes: number; readonly port: ExecutionArtifactStore | undefined;\n readonly #controller = new AbortController(); #pending = 0;\n constructor(input: ExecutionArtifactStore | undefined, maxBytes = 128 * 1024 * 1024) {\n if (!Number.isSafeInteger(maxBytes) || maxBytes < 65536 || maxBytes > 128 * 1024 * 1024) executionFailure('INVALID_STATE');\n this.maxBytes = maxBytes;\n try { this.port = input ? Object.freeze({ write: method(input, 'write'), read: method(input, 'read'), verify: method(input, 'verify') }) as ExecutionArtifactStore : undefined; }\n catch { return executionFailure('INVALID_STATE'); }\n }\n close(): void { this.#controller.abort(); }\n async operation<T>(body: () => Promise<T>): Promise<T> {\n if (this.#controller.signal.aborted) executionFailure('CLOSED'); if (this.#pending >= 2) executionFailure('CODEC_BUSY'); this.#pending++;\n try { return await body(); } finally { this.#pending--; }\n }\n capture(input: unknown, check: () => void): Promise<LogJsonValue> { return captureRecordJson(input, { maxBytes: this.maxBytes }, check); }\n encode(input: LogJsonValue, check: () => void) { return encodeRecordJson(input, { maxBytes: this.maxBytes }, check); }\n async stage(bytes: Buffer, digest: string, sourceId: string, identity: RunIdentity, check: () => void): Promise<RecordBody> {\n if (!this.port) executionFailure('PAYLOAD_CODEC_REQUIRED');\n try {\n const reference = await this.port.write(bytes, { mediaType: 'application/json', signal: this.#controller.signal }); check();\n const body = captureRecordBody({ codec: 'oar.execution.record-json', version: 1, reference }, sourceId, identity, this.maxBytes);\n if (body.reference.bytes !== bytes.length || body.reference.digest !== digest) executionFailure('PAYLOAD_UNAVAILABLE');\n return body;\n } catch (error) { return this.#failure(error, check); }\n }\n async hydrate(body: RecordBody, digest: string, check: () => void): Promise<LogJsonValue> {\n if (!this.port) executionFailure('PAYLOAD_CODEC_REQUIRED'); hash(digest); if (body.reference.digest !== digest) executionFailure('PAYLOAD_UNAVAILABLE');\n let owned: Buffer | undefined;\n try {\n const bytes = await this.port.read(body.reference, { signal: this.#controller.signal }); check();\n if (types.isProxy(bytes) || !types.isUint8Array(bytes)) executionFailure('PAYLOAD_UNAVAILABLE');\n const length = Reflect.apply(Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Uint8Array.prototype), 'byteLength')!.get!, bytes, []) as number;\n if (length !== body.reference.bytes || length > this.maxBytes) executionFailure('CODEC_LIMIT');\n owned = Buffer.allocUnsafe(length); Reflect.apply(Uint8Array.prototype.set, owned, [bytes]);\n const record = await decodeRecordJson(owned, digest, { maxBytes: this.maxBytes }, check); check(); return record;\n } catch (error) { return this.#failure(error, check); }\n finally { owned?.fill(0); }\n }\n async verify(reference: PayloadReference, options?: { signal?: AbortSignal }) {\n if (!this.port) executionFailure('PAYLOAD_CODEC_REQUIRED'); return this.port.verify(reference, options);\n }\n #failure(error: unknown, check: () => void): never {\n try { check(); } catch (secondary) {\n if (isExecutionHalted(error)) throw new AggregateError([error, secondary], 'Execution halted during body validation', { cause: error });\n throw secondary;\n }\n if (isExecutionHalted(error)) throw error; return executionFailure('PAYLOAD_UNAVAILABLE');\n }\n}\n","import { createHash } from 'node:crypto';\nimport { types } from 'node:util';\nimport { setImmediate } from 'node:timers/promises';\nimport { executionFailure } from './execution-types.js';\nimport type { LogJsonValue } from './types.js';\nexport interface RecordJsonLimits { readonly maxBytes: number }\nconst MAX_NODES = 65536, MAX_DEPTH = 64, CHUNK = 65536;\nasync function pause(check: () => void): Promise<void> { await setImmediate(); check(); }\n/** Data capture only; immutable original property order preserves legacy JSON.stringify hashes. */\nexport async function captureRecordJson(input: unknown, limits: RecordJsonLimits, check: () => void): Promise<LogJsonValue> {\n let nodes = 0, bytes = 0; const ancestors = new Set<object>();\n async function visit(value: unknown, depth: number): Promise<LogJsonValue> {\n if (++nodes > MAX_NODES || depth > MAX_DEPTH) executionFailure('CODEC_LIMIT');\n if (nodes % 256 === 0) await pause(check);\n if (typeof value === 'string') { if (/[\\ud800-\\udfff]/u.test(value)) executionFailure('INVALID_STATE'); bytes += Buffer.byteLength(value); if (bytes > limits.maxBytes) executionFailure('CODEC_LIMIT'); return value; }\n if (value === null || typeof value === 'boolean' || typeof value === 'number' && Number.isFinite(value)) return value;\n if (!value || typeof value !== 'object' || types.isProxy(value) || ancestors.has(value) || Object.getOwnPropertySymbols(value).length) executionFailure('INVALID_STATE');\n const array = Array.isArray(value), prototype = Object.getPrototypeOf(value);\n if (array ? prototype !== Array.prototype : prototype !== Object.prototype && prototype !== null) executionFailure('INVALID_STATE');\n const names = Object.getOwnPropertyNames(value); if (names.length > MAX_NODES + 1 || array && names.length !== value.length + 1) executionFailure('CODEC_LIMIT');\n const captured: Record<string, LogJsonValue> | LogJsonValue[] = array ? [] : Object.create(null); ancestors.add(value); let index = 0;\n try {\n for (const key of names) {\n if (array && key === 'length') continue;\n const descriptor = Object.getOwnPropertyDescriptor(value, key)!;\n if (array && key !== String(index++) || !Object.hasOwn(descriptor, 'value') || !descriptor.enumerable) executionFailure('INVALID_STATE');\n if (/[\\ud800-\\udfff]/u.test(key)) executionFailure('INVALID_STATE'); bytes += Buffer.byteLength(key); if (bytes > limits.maxBytes) executionFailure('CODEC_LIMIT');\n const child = await visit(descriptor.value, depth + 1); check(); Object.defineProperty(captured, key, { value: child, enumerable: true });\n }\n return Object.freeze(captured);\n } finally { ancestors.delete(value); }\n }\n check(); const captured = await visit(input, 1); check(); return captured;\n}\nfunction* quoted(value: string): Generator<string> {\n if (/[\\ud800-\\udfff]/u.test(value)) executionFailure('INVALID_STATE');\n yield '\"';\n for (let start = 0; start < value.length;) {\n let end = Math.min(value.length, start + 4096);\n if (end < value.length && value.charCodeAt(end - 1) >= 0xd800 && value.charCodeAt(end - 1) <= 0xdbff && value.charCodeAt(end) >= 0xdc00 && value.charCodeAt(end) <= 0xdfff) end--;\n yield JSON.stringify(value.slice(start, end)).slice(1, -1); start = end;\n }\n yield '\"';\n}\nfunction* fragments(value: LogJsonValue): Generator<string> {\n if (typeof value === 'string') { yield* quoted(value); return; }\n if (value === null || typeof value !== 'object') { yield JSON.stringify(value); return; }\n const array = Array.isArray(value); yield array ? '[' : '{'; let first = true;\n for (const key of Object.keys(value)) {\n if (!first) yield ','; first = false;\n if (!array) { yield* quoted(key); yield ':'; }\n yield* fragments((value as Record<string, LogJsonValue>)[key]!);\n }\n yield array ? ']' : '}';\n}\nasync function encode(value: LogJsonValue, limits: RecordJsonLimits, check: () => void, retain: boolean) {\n const chunks: Buffer[] = [], hash = createHash('sha256'); let total = 0, buffer = Buffer.allocUnsafe(CHUNK), used = 0;\n for (const text of fragments(value)) {\n const bytes = Buffer.from(text); total += bytes.length; if (total > limits.maxBytes) executionFailure('CODEC_LIMIT');\n for (let offset = 0; offset < bytes.length;) {\n const copied = Math.min(bytes.length - offset, CHUNK - used); bytes.copy(buffer, used, offset, offset + copied); used += copied; offset += copied;\n if (used === CHUNK) { hash.update(buffer); if (retain) chunks.push(buffer); await pause(check); buffer = Buffer.allocUnsafe(CHUNK); used = 0; }\n }\n }\n if (used) { hash.update(buffer.subarray(0, used)); if (retain) chunks.push(buffer.subarray(0, used)); await pause(check); }\n return { digest: hash.digest('hex'), bytes: retain ? Buffer.concat(chunks, total) : undefined, length: total };\n}\nexport async function encodeRecordJson(value: LogJsonValue, limits: RecordJsonLimits, check: () => void): Promise<{ digest: string; bytes: Buffer }> {\n const encoded = await encode(value, limits, check, true); return { digest: encoded.digest, bytes: encoded.bytes! };\n}\n/** Fuse JSON nesting/tokens before JSON.parse allocates the materialized checkpoint. */\nasync function preflight(text: string, check: () => void): Promise<void> {\n let depth = 0, tokens = 0, string = false, escaped = false, literal = false;\n for (let index = 0; index < text.length; index++) {\n const char = text[index]!;\n if (string) { if (escaped) escaped = false; else if (char === '\\\\') escaped = true; else if (char === '\"') string = false; }\n else if (char === '\"') { string = true; literal = false; tokens++; }\n else if (char === '{' || char === '[') { if (++depth > MAX_DEPTH) executionFailure('CODEC_LIMIT'); tokens++; literal = false; }\n else if (char === '}' || char === ']') { if (--depth < 0) executionFailure('INVALID_STATE'); literal = false; }\n else if (char === ',' || char === ':' || char === ' ' || char === '\\r' || char === '\\n' || char === '\\t') literal = false;\n else if (!literal) { tokens++; literal = true; }\n if (tokens > MAX_NODES * 2) executionFailure('CODEC_LIMIT');\n if (index && index % CHUNK === 0) await pause(check);\n }\n if (depth || string || escaped) executionFailure('INVALID_STATE');\n}\nexport async function decodeRecordJson(bytes: Uint8Array, expectedDigest: string, limits: RecordJsonLimits, check: () => void): Promise<LogJsonValue> {\n if (types.isProxy(bytes) || !types.isUint8Array(bytes)) executionFailure('PAYLOAD_UNAVAILABLE');\n const length = Reflect.apply(Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Uint8Array.prototype), 'byteLength')!.get!, bytes, []) as number;\n if (length > limits.maxBytes) executionFailure('CODEC_LIMIT');\n let text: string; try { text = new TextDecoder('utf-8', { fatal: true, ignoreBOM: true }).decode(bytes); } catch { return executionFailure('PAYLOAD_UNAVAILABLE'); }\n await preflight(text, check); check();\n let parsed: unknown; try { parsed = JSON.parse(text); } catch { return executionFailure('PAYLOAD_UNAVAILABLE'); }\n const captured = await captureRecordJson(parsed, limits, check), encoded = await encode(captured, limits, check, false);\n // Detect duplicate keys/whitespace/unknown representation, preserving original insertion-order bytes.\n if (encoded.digest !== expectedDigest || encoded.length !== length) executionFailure('PAYLOAD_UNAVAILABLE');\n return captured;\n}\n","import { capture } from './encoding.js';\nimport { AGENT_METADATA_SCHEMA, CAPTURE_OPERATION_SCHEMA, decodeCaptureMetadata } from './capture-codec.js';\nimport { executionFailure, safeExecutionFailure } from './execution-types.js';\nimport type { ExecutionDatabaseContext } from './execution-database.js';\nimport type { LogCommit, LogReceipt } from './types.js';\n\n/** Bounded metadata DATA port for Runtime.capture. Reserved lifecycle/effect records cannot be injected. */\nexport function executionCaptureStore(context: ExecutionDatabaseContext): Readonly<{ append(commit: LogCommit): Promise<LogReceipt> }> {\n let pending = 0;\n return Object.freeze({ async append(input: LogCommit): Promise<LogReceipt> {\n context.assert(); if (pending >= 2) executionFailure('CODEC_BUSY');\n let commit: LogCommit;\n try {\n commit = capture(input, context.source);\n for (const record of commit.records) {\n if (record.schema.version !== 1 || ![AGENT_METADATA_SCHEMA, CAPTURE_OPERATION_SCHEMA].includes(record.schema.id) || !('inline' in record.payload)) executionFailure('INVALID_STATE');\n decodeCaptureMetadata(record.schema.id, record.type, record.payload.inline);\n }\n } catch { return executionFailure('INVALID_STATE'); }\n pending++;\n try {\n const prepared = await context.binding.prepare(commit);\n return context.transaction(() => context.binding.appendInTransaction(prepared), true);\n } catch (error) { return safeExecutionFailure(error); } finally { pending--; }\n } });\n}\n","import { freeze, hash, object } from '../../shared/json.js';\nimport type { RunInterruptionReason } from './run-history-types.js';\n\nexport const RUN_HISTORY_SCHEMA = 'oar.system.run';\nexport interface RunMarker { readonly inputDigest: string; readonly outputDigest?: string; readonly reason?: RunInterruptionReason }\n/** Closed metadata grammar; no outputs, exception prose or native diagnostics. */\nexport function decodeRunMarker(type: string, input: unknown): RunMarker {\n object(input, ['inputDigest', 'outputDigest', 'reason']); hash(input.inputDigest);\n if (type === 'run.started') { if (Object.keys(input).length !== 1) throw Error(); }\n else if (type === 'run.completed') {\n if (input.reason !== undefined || Object.hasOwn(input, 'reason')) throw Error();\n if (Object.hasOwn(input, 'outputDigest')) hash(input.outputDigest);\n } else if (type === 'run.interrupted') {\n if (Object.keys(input).length !== 2 || typeof input.reason !== 'string' || !['aborted', 'failed', 'stopped', 'halted'].includes(input.reason)) throw Error();\n } else throw Error();\n return freeze({ inputDigest: input.inputDigest, ...(input.outputDigest === undefined ? {} : { outputDigest: input.outputDigest as string }),\n ...(input.reason === undefined ? {} : { reason: input.reason as RunInterruptionReason }) });\n}\nexport function capturePublicRunMarker(input: unknown): Readonly<Record<string, unknown>> {\n object(input, ['stage', 'inputDigest', 'outputDigest', 'reason']);\n if (typeof input.stage !== 'string') throw Error();\n const { stage, ...body } = input;\n return freeze({ stage, ...decodeRunMarker(`run.${stage}`, body) });\n}\n","import { canonical, freeze } from '../../shared/json.js';\nimport type { ExecutionDatabaseContext } from './execution-database.js';\nimport { executionFailure } from './execution-types.js';\nimport { pageRecords } from './paging.js';\nimport { RUN_HISTORY_SCHEMA, decodeRunMarker } from './run-history-codec.js';\nimport type { RunHistoryRecord } from './run-history-types.js';\nimport type { LogCursor } from './store-types.js';\nimport type { RunIdentity } from './types.js';\n\n/** Whole-source chain/index validation, bounded per invocation and under one SQLite snapshot. */\nexport function scanRuns(context: ExecutionDatabaseContext, maxEntries: number): { runs: Map<string, RunHistoryRecord>; scanned: number } {\n const runs = new Map<string, RunHistoryRecord>(); let cursor: LogCursor | undefined, scanned = 0;\n do {\n const page = pageRecords(context.db, context.source, context.storageDigest, { limit: Math.min(256, maxEntries - scanned + 1), ...(cursor ? { cursor } : {}) });\n scanned += page.scanned; if (scanned > maxEntries) executionFailure('CODEC_LIMIT'); cursor = page.nextCursor;\n for (const entry of page.items) {\n if (entry.record.schema.id !== RUN_HISTORY_SCHEMA) continue;\n try {\n if (entry.record.schema.version !== 1 || !('inline' in entry.record.payload)) executionFailure('INTEGRITY');\n const metadata = decodeRunMarker(entry.record.type, entry.record.payload.inline), identity = entry.record.identity;\n const position = { sourceId: entry.sourceId, sequence: entry.sequence, digest: entry.digest }, prior = runs.get(identity.runId);\n if (entry.record.type === 'run.started') {\n if (prior || entry.record.causal.length) executionFailure('INTEGRITY');\n runs.set(identity.runId, freeze({ schemaVersion: 1, sourceId: entry.sourceId, identity, inputDigest: metadata.inputDigest, status: 'unknown', started: position }));\n } else {\n if (!prior || prior.status !== 'unknown' || canonical(prior.identity) !== canonical(identity) || prior.inputDigest !== metadata.inputDigest\n || canonical(entry.record.causal) !== canonical([prior.started])) executionFailure('INTEGRITY');\n runs.set(identity.runId, freeze({ ...prior, status: entry.record.type === 'run.completed' ? 'completed' : 'interrupted', terminal: position,\n ...(metadata.outputDigest === undefined ? {} : { outputDigest: metadata.outputDigest }), ...(metadata.reason === undefined ? {} : { reason: metadata.reason }) }));\n }\n } catch { executionFailure('INTEGRITY'); }\n }\n } while (cursor);\n return { runs, scanned };\n}\nexport function matchingRun(runs: Map<string, RunHistoryRecord>, identity: RunIdentity): RunHistoryRecord | undefined {\n const record = runs.get(identity.runId);\n if (record && canonical(record.identity) !== canonical(identity)) executionFailure('INVALID_STATE');\n return record;\n}\n","import { canonical, freeze, hash, identifier, ownObject } from '../../shared/json.js';\nimport { executionContext } from './execution-database.js';\nimport { executionFailure } from './execution-types.js';\nimport { captureIdentity } from './reconstruction.js';\nimport { RUN_HISTORY_SCHEMA } from './run-history-codec.js';\nimport { matchingRun, scanRuns } from './run-history-storage.js';\nimport type { RunHistory, RunHistoryComplete, RunHistoryHandle, RunHistoryInterrupt, RunHistoryOptions, RunHistoryRecord } from './run-history-types.js';\nimport type { RunIdentity } from './types.js';\n\nfunction input<T>(value: T, keys: readonly string[]): T {\n try { return ownObject(value, keys); } catch { return executionFailure('INVALID_STATE'); }\n}\nfunction id(value: unknown): void { try { identifier(value); } catch { executionFailure('INVALID_STATE'); } }\nfunction sha(value: unknown): void { try { hash(value); } catch { executionFailure('INVALID_STATE'); } }\n/** Lifecycle and deduplication DATA in the existing log. Does not execute work or prove its postconditions. */\nexport function createRunHistory(options: RunHistoryOptions): RunHistory {\n options = input(options, ['database', 'maxEntries']);\n const context = executionContext(options.database), maxEntries = options.maxEntries ?? 4096;\n if (!Number.isSafeInteger(maxEntries) || maxEntries < 1 || maxEntries > 65536) executionFailure('INVALID_STATE');\n const handles = new WeakMap<object, RunHistoryRecord>();\n const identity = (value: RunIdentity) => {\n let captured: RunIdentity; try { captured = captureIdentity(value); } catch { return executionFailure('INVALID_STATE'); }\n if (captured.systemId !== context.source.systemId) executionFailure('INVALID_STATE'); return captured;\n };\n const finish = async (handle: RunHistoryHandle, raw: RunHistoryComplete | RunHistoryInterrupt, status: 'completed' | 'interrupted'): Promise<RunHistoryRecord> => {\n const saved = handle && typeof handle === 'object' ? handles.get(handle) : undefined; if (!saved) executionFailure('INVALID_STATE');\n const command = input(raw, status === 'completed' ? ['requestId', 'outputDigest'] : ['requestId', 'reason']); id(command.requestId);\n const outputDigest = 'outputDigest' in command ? command.outputDigest : undefined, reason = 'reason' in command ? command.reason : undefined;\n if (outputDigest !== undefined) sha(outputDigest);\n if (status === 'interrupted' && (typeof reason !== 'string' || !['aborted', 'failed', 'stopped', 'halted'].includes(reason))) executionFailure('INVALID_STATE');\n return context.transaction(() => {\n const { runs, scanned } = scanRuns(context, maxEntries);\n const prior = matchingRun(runs, saved.identity);\n if (!prior || canonical(prior.started) !== canonical(saved.started) || prior.inputDigest !== saved.inputDigest) executionFailure('INTEGRITY');\n if (prior.status !== 'unknown') {\n if (prior.status !== status || prior.outputDigest !== outputDigest || prior.reason !== reason) executionFailure('INVALID_STATE'); return prior;\n }\n if (scanned >= maxEntries) executionFailure('CODEC_LIMIT');\n const receipt = context.binding.appendInTransaction({ requestId: command.requestId, records: [{ identity: saved.identity, schema: { id: RUN_HISTORY_SCHEMA, version: 1 },\n type: `run.${status}`, causal: [prior.started], payload: { inline: { inputDigest: prior.inputDigest, ...(outputDigest === undefined ? {} : { outputDigest }), ...(reason === undefined ? {} : { reason }) } } }] });\n return freeze({ ...prior, status, terminal: receipt.first, ...(outputDigest === undefined ? {} : { outputDigest }), ...(reason === undefined ? {} : { reason }) });\n }, true);\n };\n return Object.freeze({\n async begin(raw) {\n const command = input(raw, ['identity', 'requestId', 'inputDigest']), captured = identity(command.identity); id(command.requestId); sha(command.inputDigest);\n const result = context.transaction(() => {\n const { runs, scanned } = scanRuns(context, maxEntries);\n const prior = matchingRun(runs, captured);\n if (prior) { if (prior.inputDigest !== command.inputDigest) executionFailure('INVALID_STATE'); return { kind: 'existing' as const, record: prior }; }\n let reserved = 2; // The new start and its terminal record.\n for (const run of runs.values()) if (run.status === 'unknown') reserved++;\n if (scanned + reserved > maxEntries) executionFailure('CODEC_LIMIT');\n const receipt = context.binding.appendInTransaction({ requestId: command.requestId, records: [{ identity: captured, schema: { id: RUN_HISTORY_SCHEMA, version: 1 }, type: 'run.started', causal: [], payload: { inline: { inputDigest: command.inputDigest } } }] });\n return { kind: 'started' as const, record: freeze({ schemaVersion: 1 as const, sourceId: context.source.sourceId, identity: captured, inputDigest: command.inputDigest, status: 'unknown' as const, started: receipt.first }) };\n }, true);\n // Never mint an execution handle before actual COMMIT acknowledgement.\n if (result.kind === 'existing') return Object.freeze(result);\n const run = Object.freeze({}) as RunHistoryHandle; handles.set(run, result.record); return Object.freeze({ ...result, run });\n },\n complete: (handle, command) => finish(handle, command, 'completed'),\n interrupt: (handle, command) => finish(handle, command, 'interrupted'),\n async recover(raw) { const captured = identity(raw); return context.transaction(() => matchingRun(scanRuns(context, maxEntries).runs, captured)); },\n async list(raw = {}) {\n const command = input(raw, ['generation', 'limit']), limit = command.limit ?? 64;\n if (!Number.isSafeInteger(limit) || limit < 1 || limit > 256 || command.generation !== undefined && (!Number.isSafeInteger(command.generation) || command.generation < 1)) executionFailure('INVALID_STATE');\n return context.transaction(() => freeze([...scanRuns(context, maxEntries).runs.values()].filter(record => command.generation === undefined || record.identity.generation === command.generation).sort((a, b) => b.started.sequence - a.started.sequence).slice(0, limit)));\n },\n } satisfies RunHistory);\n}\n","import { randomUUID } from 'node:crypto';\nimport { canonical, freeze } from '../../shared/json.js';\nimport { digest } from './encoding.js';\nimport { readEntry } from './records.js';\nimport { latestStatePosition } from './state-history.js';\nimport { decodeExecutionValue } from './execution-validation.js';\nimport { executionFailure } from './execution-types.js';\nimport { captureExecutionMetadata, executionMetadata } from './execution-metadata.js';\nimport type { DecisionLogMetadata, WorkflowLogMetadata } from './execution-metadata.js';\nimport { captureRecordBody } from './record-codec.js';\nimport type { RecordBody } from './record-codec.js';\nimport { captureLogCommit } from './validation.js';\nimport type { ExecutionDatabaseContext } from './execution-database.js';\nimport type { LogJsonValue, RunIdentity } from './types.js';\nimport type { LogCommit } from './types.js';\nimport type { PreparedLogCommit } from './store-types.js';\nexport interface MaterializedState {\n readonly revision: number; readonly record?: LogJsonValue; readonly recordJson: string; readonly recordDigest: string;\n readonly metadata: DecisionLogMetadata | WorkflowLogMetadata; readonly body?: RecordBody;\n}\nexport interface PreparedState {\n readonly revision: number; readonly record: LogJsonValue; readonly recordJson: string; readonly recordDigest: string;\n readonly metadata: DecisionLogMetadata | WorkflowLogMetadata; readonly commit: LogCommit | PreparedLogCommit;\n}\n/** v1 keeps original JSON inline; v2 binds a private body descriptor to an adjacent pinned body event. */\nexport function readState(context: ExecutionDatabaseContext, kind: 'decision' | 'workflow', key: string, identity: RunIdentity): MaterializedState | undefined {\n const latest = latestStatePosition(context, kind, key);\n const row = context.db.prepare(`SELECT identity_json,identity_digest,revision,record_digest,sequence,event_digest,request_id,\n CASE WHEN length(CAST(record_json AS BLOB))<=60000 THEN record_json END AS record_json FROM main.oar_execution_states WHERE kind=? AND state_key=?`).get(kind, key);\n if (!row) {\n if (latest) executionFailure('INTEGRITY');\n return undefined;\n }\n if (!latest || latest.sequence !== row.sequence || latest.digest !== row.event_digest\n || row.identity_json !== canonical(identity) || row.identity_digest !== digest(canonical(identity)) || !Number.isSafeInteger(row.revision) || Number(row.revision) < 1) executionFailure('INTEGRITY');\n const event = readEntry(context.db, Number(row.sequence), context.source);\n if (event.digest !== row.event_digest || event.requestId !== row.request_id || canonical(event.record.identity) !== canonical(identity)\n || event.record.schema.id !== `oar.execution.${kind}`) executionFailure('INTEGRITY');\n let record: LogJsonValue | undefined, body: RecordBody | undefined, metadata: DecisionLogMetadata | WorkflowLogMetadata, expected;\n if (event.record.schema.version === 1) {\n record = decodeExecutionValue(row.record_json, row.record_digest); metadata = executionMetadata(kind, record);\n expected = { kind, key, revision: row.revision, recordJson: row.record_json, recordDigest: row.record_digest, metadata };\n } else if (event.record.schema.version === 2) {\n if (typeof row.record_json !== 'string') executionFailure('INTEGRITY');\n let raw: unknown; try { raw = JSON.parse(row.record_json); } catch { return executionFailure('INTEGRITY'); }\n body = captureRecordBody(raw, context.source.sourceId, identity, context.codec.maxBytes);\n if (canonical(body) !== row.record_json || body.reference.digest !== row.record_digest || !('inline' in event.record.payload)) executionFailure('INTEGRITY');\n metadata = captureExecutionMetadata(kind, (event.record.payload.inline as Record<string, unknown>).metadata);\n expected = { kind, key, revision: row.revision, recordDigest: row.record_digest, body, metadata };\n const original = readEntry(context.db, event.sequence - 1, context.source);\n const range = context.db.prepare('SELECT count,first_sequence,last_sequence FROM main.oar_log_requests WHERE request_id=?').get(event.requestId);\n if (event.ordinal !== 2 || original.ordinal !== 1 || original.requestId !== event.requestId || original.record.schema.id !== 'oar.execution.body'\n || original.record.schema.version !== 1 || original.record.type !== `${kind}.body` || canonical(original.record.identity) !== canonical(identity)\n || canonical(original.record.payload) !== canonical({ artifact: body.reference }) || range?.count !== 2\n || range.first_sequence !== original.sequence || range.last_sequence !== event.sequence) executionFailure('INTEGRITY');\n } else return executionFailure('PAYLOAD_UNAVAILABLE');\n if (event.record.type !== `${kind}.${metadata.status}` || canonical(event.record.payload) !== canonical({ inline: expected })) executionFailure('INTEGRITY');\n return freeze({ revision: Number(row.revision), ...(record !== undefined ? { record } : {}), recordJson: row.record_json as string,\n recordDigest: row.record_digest as string, metadata, ...(body ? { body } : {}) });\n}\nexport async function hydrateState(context: ExecutionDatabaseContext, kind: 'decision' | 'workflow', state: MaterializedState, check: () => void): Promise<LogJsonValue> {\n if (!state.body) { if (state.record === undefined) executionFailure('INTEGRITY'); return state.record; }\n const record = await context.codec.hydrate(state.body, state.recordDigest, check); check();\n if (canonical(executionMetadata(kind, record)) !== canonical(state.metadata)) executionFailure('INTEGRITY'); return record;\n}\nexport async function prepareState(context: ExecutionDatabaseContext, kind: 'decision' | 'workflow', key: string, identity: RunIdentity,\n record: LogJsonValue, expectedRevision: number, type: string, check: () => void): Promise<PreparedState> {\n const revision = expectedRevision + 1; if (!Number.isSafeInteger(revision)) executionFailure('INTEGRITY');\n const metadata = executionMetadata(kind, record), requestId = `state:${randomUUID()}`;\n return (async () => {\n const encoded = await context.codec.encode(record, check); check();\n try {\n const recordDigest = encoded.digest;\n if (encoded.bytes.length <= 60000) {\n const recordJson = encoded.bytes.toString('utf8');\n try {\n const commit = captureLogCommit({ requestId, records: [{ identity, schema: { id: `oar.execution.${kind}`, version: 1 }, type,\n causal: [], payload: { inline: { kind, key, revision, recordJson, recordDigest, metadata } } }] });\n return { revision, record, recordJson, recordDigest, metadata, commit };\n } catch { /* Escaped inline bytes may require the artifact codec even for a small record. */ }\n }\n const body = await context.codec.stage(encoded.bytes, recordDigest, context.source.sourceId, identity, check); check();\n const commit = await context.binding.prepare({ requestId, records: [\n { identity, schema: { id: 'oar.execution.body', version: 1 }, type: `${kind}.body`, causal: [], payload: { artifact: body.reference } },\n { identity, schema: { id: `oar.execution.${kind}`, version: 2 }, type, causal: [], payload: { inline: { kind, key, revision, recordDigest, body: body as unknown as LogJsonValue, metadata: metadata as unknown as LogJsonValue } } },\n ] }); check();\n return { revision, record, recordJson: canonical(body), recordDigest, metadata, commit };\n } finally { encoded.bytes.fill(0); }\n })();\n}\nexport function commitState(context: ExecutionDatabaseContext, kind: 'decision' | 'workflow', key: string, identity: RunIdentity, prepared: PreparedState): MaterializedState {\n const current = readState(context, kind, key, identity), { revision, recordJson, recordDigest, metadata } = prepared;\n if ((current?.revision ?? 0) !== revision - 1) executionFailure('OUTCOME_UNKNOWN');\n if (current?.recordDigest === recordDigest && current.recordJson === recordJson) return current;\n const receipt = context.binding.appendInTransaction(prepared.commit);\n context.db.prepare(`INSERT INTO main.oar_execution_states VALUES(?,?,?,?,?,?,?,?,?,?) ON CONFLICT(kind,state_key)\n DO UPDATE SET revision=excluded.revision,record_json=excluded.record_json,record_digest=excluded.record_digest,sequence=excluded.sequence,event_digest=excluded.event_digest,request_id=excluded.request_id`)\n .run(kind, key, canonical(identity), digest(canonical(identity)), revision, recordJson, recordDigest, receipt.head.sequence, receipt.head.digest,\n readEntry(context.db, receipt.head.sequence, context.source).requestId);\n return freeze({ revision, record: prepared.record, recordJson, recordDigest, metadata });\n}\n","import { pageRecords } from './paging.js';\nimport { executionFailure } from './execution-types.js';\nimport type { ExecutionDatabaseContext } from './execution-database.js';\nimport type { LogCursor } from './store-types.js';\nimport type { LogPosition } from './types.js';\n/** A materialized row is only a view of the LAST matching transition in the verified chain.\n * Global 64-record pages validate before key exclusion. Total scan/SQL work grows with history. */\nexport function latestStatePosition(context: ExecutionDatabaseContext, kind: 'decision' | 'workflow', key: string): LogPosition | undefined {\n let cursor: LogCursor | undefined, latest: LogPosition | undefined;\n do {\n const page = pageRecords(context.db, context.source, context.storageDigest, cursor ? { cursor, limit: 64 } : { limit: 64 }); cursor = page.nextCursor;\n for (const entry of page.items) {\n if (entry.record.schema.id !== `oar.execution.${kind}`) continue;\n if (entry.record.schema.version !== 1 && entry.record.schema.version !== 2) executionFailure('INTEGRITY');\n const payload = 'inline' in entry.record.payload ? entry.record.payload.inline : undefined;\n if (!payload || typeof payload !== 'object' || Array.isArray(payload)) executionFailure('INTEGRITY');\n if ((payload as Record<string, unknown>).kind === kind && (payload as Record<string, unknown>).key === key) latest = { sourceId: entry.sourceId, sequence: entry.sequence, digest: entry.digest };\n }\n } while (cursor);\n return latest;\n}\n","import { freeze, hash, object } from '../../shared/json.js';\nimport { digest } from './encoding.js';\nimport { validateDecisionRecord } from '../decisions/runner.js';\nimport type { DecisionRecord } from '../decisions/types.js';\nimport type { WorkflowCheckpoint } from '../workflow/types.js';\nimport type { LogJsonValue } from './types.js';\nimport { executionFailure } from './execution-types.js';\nimport { captureExecutionValue } from './execution-validation.js';\nexport interface DecisionLogMetadata {\n readonly kind: 'decision'; readonly decisionIdDigest: string; readonly status: DecisionRecord['status']; readonly attempts: number;\n readonly intentIdDigest?: string; readonly inputHash: string; readonly authorityHash: string;\n readonly inputVersionDigest: string; readonly authorityVersionDigest: string; readonly resultHash?: string;\n}\nexport interface WorkflowLogMetadata {\n readonly kind: 'workflow'; readonly workflowIdDigest: string; readonly workflowVersionDigest: string;\n readonly fingerprint: string; readonly status: WorkflowCheckpoint['status'];\n readonly steps: readonly Readonly<{ stepIdDigest: string; status: WorkflowCheckpoint['steps'][string]['status']; attempts: number }>[];\n}\n/** Closed DATA descriptor for v2 bodies; never constructs a DecisionRecord from metadata. */\nexport function captureExecutionMetadata(kind: 'decision' | 'workflow', input: unknown): DecisionLogMetadata | WorkflowLogMetadata {\n try {\n const next = captureExecutionValue(input);\n if (kind === 'decision') {\n object(next, ['kind', 'decisionIdDigest', 'status', 'attempts', 'intentIdDigest', 'inputHash', 'authorityHash', 'inputVersionDigest', 'authorityVersionDigest', 'resultHash']);\n if (next.kind !== kind || !['waiting', 'denied', 'intent', 'dispatched', 'verified', 'needs-owner'].includes(next.status as string)\n || !Number.isSafeInteger(next.attempts) || Number(next.attempts) < 0) executionFailure('INTEGRITY');\n for (const key of ['decisionIdDigest', 'inputHash', 'authorityHash', 'inputVersionDigest', 'authorityVersionDigest']) hash(next[key]);\n for (const key of ['intentIdDigest', 'resultHash']) if (next[key] !== undefined) hash(next[key]);\n if (['intent', 'dispatched', 'verified'].includes(next.status as string) && (!next.intentIdDigest || Number(next.attempts) < 1)\n || next.status === 'verified' && !next.resultHash) executionFailure('INTEGRITY');\n } else {\n object(next, ['kind', 'workflowIdDigest', 'workflowVersionDigest', 'fingerprint', 'status', 'steps']);\n if (next.kind !== kind || Object.keys(next).length !== 6 || !['running', 'completed', 'failed', 'cancelled', 'halted'].includes(next.status as string)\n || !Array.isArray(next.steps) || next.steps.length > 1024) executionFailure('INTEGRITY');\n for (const key of ['workflowIdDigest', 'workflowVersionDigest', 'fingerprint']) hash(next[key]);\n const ids = new Set<string>();\n for (const step of next.steps) {\n object(step, ['stepIdDigest', 'status', 'attempts']); hash(step.stepIdDigest);\n if (Object.keys(step).length !== 3 || ids.has(step.stepIdDigest) || !['pending', 'running', 'completed', 'failed', 'interrupted', 'blocked'].includes(step.status as string)\n || !Number.isSafeInteger(step.attempts) || Number(step.attempts) < 0) executionFailure('INTEGRITY'); ids.add(step.stepIdDigest);\n }\n }\n return next as unknown as DecisionLogMetadata | WorkflowLogMetadata;\n } catch { return executionFailure('INTEGRITY'); }\n}\n/** Projection allowlist. Never parse recordJson in a public trace/audit projector. Metadata is DATA only. */\nexport function executionMetadata(kind: 'decision' | 'workflow', input: LogJsonValue): DecisionLogMetadata | WorkflowLogMetadata {\n if (kind === 'decision') {\n const raw = input as unknown as DecisionRecord, record = validateDecisionRecord(input, raw.id);\n return freeze({ kind, decisionIdDigest: digest(record.id), status: record.status, attempts: record.attempts,\n ...(record.intentId ? { intentIdDigest: digest(record.intentId) } : {}), inputHash: record.binding.inputHash, authorityHash: record.binding.authorityHash,\n inputVersionDigest: digest(record.binding.inputVersion), authorityVersionDigest: digest(record.binding.authorityVersion),\n ...(record.receipt ? { resultHash: record.receipt.resultHash } : {}) });\n }\n const record = input as unknown as WorkflowCheckpoint;\n if (!record || !record.workflow || !record.steps) executionFailure('INTEGRITY');\n return freeze({ kind, workflowIdDigest: digest(record.workflow.id), workflowVersionDigest: digest(record.workflow.version), fingerprint: record.workflow.fingerprint,\n status: record.status, steps: Object.entries(record.steps).map(([stepId, step]) => ({ stepIdDigest: digest(stepId), status: step.status, attempts: step.attempts })) });\n}\n","import { canonical, freeze, identifier } from '../../shared/json.js';\nimport { digest } from './encoding.js';\nimport { lookupReceipt, readEntry } from './records.js';\nimport { captureAssociation, effectId, runKey } from './execution-validation.js';\nimport { readState } from './materialized.js';\nimport { executionFailure } from './execution-types.js';\nimport { validateDecisionRecord } from '../decisions/runner.js';\nimport type { CapturedEffectAssociation, ManagedEffectAssociation } from './execution-types.js';\nimport type { ExecutionDatabaseContext, LogExecutionDatabase } from './execution-database.js';\nimport { executionContext } from './execution-database.js';\nimport type { DecisionRecord } from '../decisions/types.js';\nimport type { RunIdentity } from './types.js';\nimport type { DecisionLogMetadata } from './execution-metadata.js';\nexport interface ManagedEffectView {\n readonly association: CapturedEffectAssociation; readonly decisionId: string; readonly record?: DecisionRecord;\n readonly metadata?: DecisionLogMetadata; readonly bodyState?: 'inline' | 'requires-body';\n}\nexport function readEffect(context: ExecutionDatabaseContext, id: string): ManagedEffectView | undefined {\n const row = context.db.prepare(`SELECT run_key,step_id,generation,decision_id,association_digest,\n CASE WHEN length(CAST(association_json AS BLOB))<8192 THEN association_json END AS association_json FROM main.oar_execution_effects WHERE effect_id=?`).get(id);\n if (!row) { if (lookupReceipt(context.db, `effect:${id}`, context.source)) executionFailure('INTEGRITY'); return undefined; }\n try {\n if (typeof row.association_json !== 'string' || digest(row.association_json) !== row.association_digest) executionFailure('INTEGRITY');\n const raw = JSON.parse(row.association_json), { sourceId, ...input } = raw;\n const association = captureAssociation(input as ManagedEffectAssociation, context.source.sourceId, context.source.systemId);\n if (sourceId !== context.source.sourceId || canonical(association) !== row.association_json || effectId(association) !== id\n || runKey(context.source.sourceId, association.identity) !== row.run_key || row.step_id !== association.stepId || row.generation !== association.identity.generation) executionFailure('INTEGRITY');\n const origin = lookupReceipt(context.db, `effect:${id}`, context.source);\n if (!origin || origin.receipt.count !== 1) executionFailure('INTEGRITY');\n const event = readEntry(context.db, origin.receipt.first.sequence, context.source);\n if (event.record.schema.id !== 'oar.execution.association' || event.record.schema.version !== 1 || event.record.type !== 'effect.associated'\n || canonical(event.record.identity) !== canonical(association.identity)\n || canonical(event.record.payload) !== canonical({ inline: { effectId: id, decisionId: row.decision_id, association } })) executionFailure('INTEGRITY');\n identifier(row.decision_id); const state = readState(context, 'decision', id, association.identity);\n const record = state && !state.body ? validateDecisionRecord(state.record, row.decision_id) : undefined;\n if (state && (state.metadata.kind !== 'decision' || state.metadata.decisionIdDigest !== digest(row.decision_id))) executionFailure('INTEGRITY');\n return freeze({ association, decisionId: row.decision_id, ...(record ? { record } : {}),\n ...(state ? { metadata: state.metadata as DecisionLogMetadata, bodyState: state.body ? 'requires-body' : 'inline' } : {}) }) as ManagedEffectView;\n } catch { return executionFailure('INTEGRITY'); }\n}\nexport function associateEffect(context: ExecutionDatabaseContext, association: CapturedEffectAssociation, decisionId: string): void {\n identifier(decisionId); const id = effectId(association), existing = readEffect(context, id);\n if (existing) {\n if (existing.decisionId !== decisionId || canonical(existing.association) !== canonical(association)) executionFailure('EFFECT_BINDING_CONFLICT'); return;\n }\n if (readState(context, 'decision', id, association.identity)) executionFailure('INTEGRITY');\n const encoded = canonical(association);\n context.db.prepare('INSERT INTO main.oar_execution_effects VALUES(?,?,?,?,?,?,?)').run(id, runKey(context.source.sourceId, association.identity), association.stepId,\n association.identity.generation, decisionId, encoded, digest(encoded));\n context.binding.appendInTransaction({ requestId: `effect:${id}`, records: [{ identity: association.identity, schema: { id: 'oar.execution.association', version: 1 },\n type: 'effect.associated', causal: [], payload: { inline: { effectId: id, decisionId, association: association as any } } }] });\n}\n/** Global fixed-key batches validate immutable data BEFORE scope exclusion. Total guard work is not constant. */\nexport function visitEffects(context: ExecutionDatabaseContext, visit: (id: string, effect: ManagedEffectView) => void): void {\n let after: string | null = null;\n for (;;) {\n const ids: Record<string, unknown>[] = context.db.prepare('SELECT effect_id FROM main.oar_execution_effects WHERE (? IS NULL OR effect_id>?) ORDER BY effect_id LIMIT 256').all(after, after);\n for (const row of ids) { if (typeof row.effect_id !== 'string') executionFailure('INTEGRITY'); const effect = readEffect(context, row.effect_id); if (!effect) executionFailure('INTEGRITY'); visit(row.effect_id, effect); }\n if (ids.length < 256) return; after = String(ids.at(-1)!.effect_id);\n }\n}\nexport function unresolved(record?: Pick<DecisionRecord, 'status'>): boolean { return !!record && ['intent', 'dispatched', 'needs-owner'].includes(record.status); }\nexport function assertResolvedRun(context: ExecutionDatabaseContext, identity: RunIdentity, except?: string): void {\n const key = runKey(context.source.sourceId, identity);\n visitEffects(context, (id, effect) => {\n if (id !== except && runKey(context.source.sourceId, effect.association.identity) === key && unresolved(effect.metadata)) executionFailure('OUTCOME_UNKNOWN');\n });\n}\n/** Data inspection never acquires or recovers an execution lease. */\nexport function inspectManagedEffect(database: LogExecutionDatabase, input: ManagedEffectAssociation): ManagedEffectView | undefined {\n const context = executionContext(database), association = captureAssociation(input, context.source.sourceId, context.source.systemId);\n return context.transaction(() => { const effect = readEffect(context, effectId(association)); if (effect && canonical(effect.association) !== canonical(association)) executionFailure('EFFECT_BINDING_CONFLICT'); return effect; });\n}\n","import { randomUUID } from 'node:crypto';\nimport { canonical, freeze, identifier, method, object, ownObject } from '../../shared/json.js';\nimport { isExecutionHalted, ExecutionHaltedError } from '../../public/execution-halt.js';\nimport { decisionHash, sameDecisionBinding, snapshotBinding } from '../decisions/binding.js';\nimport { validateDecisionRecord } from '../decisions/runner.js';\nimport type { DecisionRecord } from '../decisions/types.js';\nimport type { JsonValue } from '../workflow/types.js';\nimport { digest } from './encoding.js';\nimport { executionContext } from './execution-database.js';\nimport type { LogExecutionDatabase } from './execution-database.js';\nimport { executionFailure } from './execution-types.js';\nimport type { CapturedEffectAssociation } from './execution-types.js';\nimport { effectId } from './execution-validation.js';\nimport { acquireOwner, assertOwner, markOwnerActive, markOwnerDrained, releaseOwner } from './leases.js';\nimport { commitState, hydrateState, prepareState, readState } from './materialized.js';\nimport { readEffect } from './effects.js';\nimport type { LogJsonValue, LogPosition } from './types.js';\nimport type { DecisionReconciliationOptions } from './decision-reconciliation-types.js';\n\nfunction halted(error: unknown): unknown {\n return isExecutionHalted(error) ? error : new ExecutionHaltedError({ sanitizedDiagnostics: { reason: 'ORIGINAL_EFFECT_UNVERIFIED' } }, { cause: error });\n}\n/** Only this original-association method may make an owner-required record verified, without dispatch. */\nexport async function reconcileOriginalDecision(database: LogExecutionDatabase, association: CapturedEffectAssociation, input: DecisionReconciliationOptions): Promise<DecisionRecord> {\n const options = ownObject(input, ['id', 'intentId', 'binding', 'verifyApplied']); identifier(options.id); identifier(options.intentId);\n const verifyApplied = method<DecisionReconciliationOptions['verifyApplied']>(options, 'verifyApplied');\n const context = executionContext(database), key = effectId(association);\n const initial = context.transaction(() => {\n const effect = readEffect(context, key), state = readState(context, 'decision', key, association.identity);\n if (!effect || effect.decisionId !== options.id || canonical(effect.association) !== canonical(association) || !state\n || state.metadata.kind !== 'decision' || !['intent', 'dispatched', 'needs-owner', 'verified'].includes(state.metadata.status)) executionFailure('OUTCOME_UNKNOWN');\n // Verification is not a new dispatch. Other unresolved effects remain untouched and cannot deadlock reconciliation.\n return { state, owner: acquireOwner(context, 'decision', association.identity) };\n }, true);\n markOwnerActive(context, initial.owner); let failed = false, failure: unknown, uncertainCommit = false;\n const checkBody = () => {\n assertOwner(context, initial.owner); const effect = readEffect(context, key), state = readState(context, 'decision', key, association.identity);\n if (!effect || effect.decisionId !== options.id || canonical(effect.association) !== canonical(association) || !state\n || state.revision !== initial.state.revision || state.recordDigest !== initial.state.recordDigest || state.recordJson !== initial.state.recordJson) executionFailure('OUTCOME_UNKNOWN');\n };\n const check = () => context.transaction(checkBody);\n const position = (): LogPosition => {\n const row = context.db.prepare(\"SELECT sequence,event_digest FROM main.oar_execution_states WHERE kind='decision' AND state_key=?\").get(key);\n if (!row || !Number.isSafeInteger(row.sequence) || typeof row.event_digest !== 'string') executionFailure('INTEGRITY');\n return Object.freeze({ sourceId: context.source.sourceId, sequence: Number(row.sequence), digest: row.event_digest });\n };\n try {\n return await context.codec.operation(async () => {\n const capturedBinding = await context.codec.capture(options.binding, check); check(); const binding = snapshotBinding(capturedBinding as unknown as DecisionReconciliationOptions['binding']);\n const original = validateDecisionRecord(await hydrateState(context, 'decision', initial.state, check), options.id); check();\n if (original.intentId !== options.intentId || !sameDecisionBinding(original.binding, binding)) executionFailure('EFFECT_BINDING_CONFLICT');\n if (original.status === 'verified') return original;\n if (!original.authorization || original.authorization.decision !== 'allow' || original.attempts < 1) executionFailure('OUTCOME_UNKNOWN');\n const originalPosition = context.transaction(() => { checkBody(); return position(); });\n const verdict = await verifyApplied(freeze({ association, record: freeze(original) })); check(); object(verdict, ['verified', 'result', 'evidence']);\n if (typeof verdict.verified !== 'boolean') executionFailure('OUTCOME_UNKNOWN');\n if (!verdict.verified) return original;\n if (!Object.hasOwn(verdict, 'result') || !Array.isArray(verdict.evidence) || verdict.evidence.length < 1 || verdict.evidence.length > 64) executionFailure('OUTCOME_UNKNOWN');\n const captured = await context.codec.capture({ result: verdict.result, evidence: verdict.evidence }, check); check(); object(captured, ['result', 'evidence']);\n const evidence = captured.evidence as unknown[];\n if (evidence.some(value => typeof value !== 'string' || !value.trim() || value.length > 1024)) executionFailure('OUTCOME_UNKNOWN');\n const result = captured.result as JsonValue, resultHash = decisionHash(result), now = Date.now(); if (!Number.isSafeInteger(now) || now < 0) executionFailure('OUTCOME_UNKNOWN');\n const next: DecisionRecord = { ...original, status: 'verified', result, reason: 'Original-target postcondition reconciled by owner', receipt: {\n intentId: original.intentId, inputHash: original.binding.inputHash, authorityHash: original.binding.authorityHash,\n inputVersion: original.binding.inputVersion, authorityVersion: original.binding.authorityVersion, approval: original.authorization,\n resultHash, evidence: evidence as string[], verifiedAt: now,\n } };\n validateDecisionRecord(next, options.id);\n const prepared = await prepareState(context, 'decision', key, association.identity, next as unknown as LogJsonValue, initial.state.revision, 'decision.verified', check); check();\n uncertainCommit = true;\n context.transaction(() => {\n checkBody(); commitState(context, 'decision', key, association.identity, prepared); const verifiedPosition = position();\n const metadata = { kind: 'decision-reconciliation', status: 'verified', decisionIdDigest: digest(options.id), intentIdDigest: digest(options.intentId),\n associationDigest: digest(canonical(association)), inputHash: original.binding.inputHash, authorityHash: original.binding.authorityHash,\n inputVersionDigest: digest(original.binding.inputVersion), authorityVersionDigest: digest(original.binding.authorityVersion), resultHash,\n evidenceDigests: (evidence as string[]).map(digest), original: { ...originalPosition }, verified: { ...verifiedPosition } };\n context.binding.appendInTransaction({ requestId: `reconciliation:${randomUUID()}`, records: [{ identity: association.identity,\n schema: { id: 'oar.execution.reconciliation', version: 1 }, type: 'decision.reconciled', causal: [originalPosition, verifiedPosition], payload: { inline: metadata } }] });\n }, true);\n uncertainCommit = false; return next;\n });\n } catch (error) { failed = true; failure = halted(error); throw failure; }\n finally {\n try {\n if (uncertainCommit) executionFailure('OUTCOME_UNKNOWN');\n context.transaction(() => releaseOwner(context, initial.owner), true);\n } catch (secondary) { throw failed ? new AggregateError([failure, secondary], 'Original effect reconciliation is uncertain', { cause: failure }) : halted(secondary); }\n finally { markOwnerDrained(context, initial.owner); }\n }\n}\n","import { canonical, object } from '../../shared/json.js';\nimport { sameDecisionBinding } from '../decisions/binding.js';\nimport { validateDecisionRecord } from '../decisions/runner.js';\nimport type { DecisionLease, DecisionRecord, DecisionStore } from '../decisions/types.js';\nimport type { CapturedEffectAssociation, ManagedEffectAssociation } from './execution-types.js';\nimport { executionFailure, safeExecutionFailure } from './execution-types.js';\nimport { executionContext } from './execution-database.js';\nimport type { LogExecutionDatabase } from './execution-database.js';\nimport { captureAssociation, effectId } from './execution-validation.js';\nimport { acquireOwner, assertOwner, markOwnerActive, markOwnerDrained, releaseOwner } from './leases.js';\nimport { commitState, hydrateState, prepareState, readState } from './materialized.js';\nimport { assertResolvedRun, associateEffect, readEffect } from './effects.js';\nimport type { LogJsonValue } from './types.js';\nimport { reconcileOriginalDecision } from './decision-reconciliation.js';\nimport type { DecisionReconciliationOptions } from './decision-reconciliation-types.js';\nfunction validateTransition(previous: DecisionRecord | undefined, next: DecisionRecord): void {\n if (!previous) { if (!['waiting', 'denied', 'intent'].includes(next.status) || next.attempts !== (next.status === 'intent' ? 1 : 0)) executionFailure('INVALID_STATE'); return; }\n if (!sameDecisionBinding(previous.binding, next.binding)) executionFailure('EFFECT_BINDING_CONFLICT');\n if (canonical(previous) === canonical(next)) return;\n const allowed: Record<DecisionRecord['status'], readonly DecisionRecord['status'][]> = { waiting: ['waiting', 'denied', 'intent', 'needs-owner'], denied: [], intent: ['dispatched', 'needs-owner'], dispatched: ['dispatched', 'verified', 'needs-owner'], verified: [], 'needs-owner': [] };\n if (!allowed[previous.status].includes(next.status) || next.attempts !== previous.attempts + (next.status === 'intent' ? 1 : 0)\n || previous.intentId && next.intentId !== previous.intentId) executionFailure('INVALID_STATE');\n}\n/** One managed immutable effect association. Run-level ownership conservatively serializes callbacks. */\nexport class LogDecisionStore implements DecisionStore {\n readonly #database!: LogExecutionDatabase; readonly #association!: CapturedEffectAssociation;\n constructor(options: { database: LogExecutionDatabase; association: ManagedEffectAssociation; requireResolvedRun?: true }) {\n try {\n object(options, ['database', 'association', 'requireResolvedRun']); if (options.requireResolvedRun !== undefined && options.requireResolvedRun !== true) executionFailure('INVALID_STATE');\n const context = executionContext(options.database); this.#database = options.database;\n this.#association = captureAssociation(options.association, context.source.sourceId, context.source.systemId);\n } catch { return executionFailure('INVALID_STATE'); }\n }\n reconcile(options: DecisionReconciliationOptions): Promise<DecisionRecord> { return reconcileOriginalDecision(this.#database, this.#association, options); }\n async acquire(id: string): Promise<DecisionLease> {\n const context = executionContext(this.#database), association = this.#association, key = effectId(association);\n const acquired = context.transaction(() => {\n associateEffect(context, association, id); assertResolvedRun(context, association.identity, key);\n const owner = acquireOwner(context, 'decision', association.identity), state = readState(context, 'decision', key, association.identity);\n return { owner, revision: state?.revision ?? 0 };\n }, true);\n const owner = acquired.owner; markOwnerActive(context, owner); let revision = acquired.revision, released = false, poisoned = false, busy = false;\n const assert = () => { if (released || poisoned) executionFailure('OUTCOME_UNKNOWN'); assertOwner(context, owner); };\n const captureSnapshot = () => context.transaction(() => { assert(); return readState(context, 'decision', key, association.identity); });\n const checkSnapshot = (snapshot: ReturnType<typeof readState>) => context.transaction(() => {\n assert(); const effect = readEffect(context, key), current = readState(context, 'decision', key, association.identity);\n if (!effect || canonical(effect.association) !== canonical(association) || (current?.revision ?? 0) !== revision\n || current?.recordDigest !== snapshot?.recordDigest || current?.recordJson !== snapshot?.recordJson) executionFailure('OUTCOME_UNKNOWN');\n });\n return {\n async load() {\n if (busy) executionFailure('CODEC_BUSY'); busy = true;\n try { return await context.codec.operation(async () => {\n const snapshot = captureSnapshot(); if (!snapshot) return undefined;\n const record = await hydrateState(context, 'decision', snapshot, () => checkSnapshot(snapshot)); checkSnapshot(snapshot);\n return validateDecisionRecord(record, id);\n }); } catch (error) { poisoned = true; return safeExecutionFailure(error); } finally { busy = false; }\n },\n async save(input) {\n if (busy) executionFailure('CODEC_BUSY'); busy = true;\n try {\n await context.codec.operation(async () => {\n const snapshot = captureSnapshot(), check = () => checkSnapshot(snapshot);\n const captured = await context.codec.capture(input, check); check(); const next = validateDecisionRecord(captured, id);\n const previous = snapshot ? await hydrateState(context, 'decision', snapshot, check) : undefined; check();\n validateTransition(previous ? validateDecisionRecord(previous, id) : undefined, next);\n const prepared = await prepareState(context, 'decision', key, association.identity, next as unknown as LogJsonValue, revision, `decision.${next.status}`, check); check();\n const saved = context.transaction(() => { assert(); assertResolvedRun(context, association.identity, key); return commitState(context, 'decision', key, association.identity, prepared); }, true);\n revision = saved.revision;\n });\n } catch (error) { poisoned = true; safeExecutionFailure(error); } finally { busy = false; }\n },\n async release() {\n if (released) return;\n if (busy) executionFailure('OUTCOME_UNKNOWN');\n try { if (poisoned) executionFailure('OUTCOME_UNKNOWN'); context.transaction(() => releaseOwner(context, owner), true); released = true; }\n finally { markOwnerDrained(context, owner); }\n },\n };\n }\n}\n","import { types } from 'node:util';\nimport { identifier, object, ownObject } from '../../shared/json.js';\nimport { cloneSteps, identity as workflowIdentity, validateCheckpoint } from '../workflow/checkpoint.js';\nimport { dependencyWaves } from '../workflow/graph.js';\nimport type { WorkflowCheckpoint, WorkflowDefinition, WorkflowLease, WorkflowStep, WorkflowStore } from '../workflow/types.js';\nimport type { RunIdentity } from './types.js';\nimport { captureIdentity } from './reconstruction.js';\nimport { executionContext } from './execution-database.js';\nimport type { ExecutionDatabaseContext, LogExecutionDatabase } from './execution-database.js';\nimport { captureExecutionValue, runKey } from './execution-validation.js';\nimport { executionFailure, safeExecutionFailure } from './execution-types.js';\nimport { acquireOwner, assertOwner, markOwnerActive, markOwnerDrained, releaseOwner } from './leases.js';\nimport { commitState, hydrateState, prepareState, readState } from './materialized.js';\nimport { unresolved, visitEffects } from './effects.js';\n\nfunction captureDefinition(input: WorkflowDefinition): WorkflowDefinition {\n try {\n input = ownObject(input, ['id', 'version', 'steps']); identifier(input.id); identifier(input.version);\n if (types.isProxy(input.steps) || !Array.isArray(input.steps) || input.steps.length > 1024) executionFailure('INVALID_STATE');\n const steps: WorkflowStep[] = [];\n for (let index = 0; index < input.steps.length; index++) {\n const descriptor = Object.getOwnPropertyDescriptor(input.steps, String(index));\n if (!descriptor || !Object.hasOwn(descriptor, 'value')) executionFailure('INVALID_STATE');\n const step = ownObject(descriptor.value, ['id', 'execute', 'dependencies', 'maxAttempts', 'replaySafe']); object(step); identifier(step.id);\n if (types.isProxy(step.execute) || typeof step.execute !== 'function') executionFailure('INVALID_STATE');\n const dependencies = captureExecutionValue(step.dependencies ?? []); if (!Array.isArray(dependencies)) executionFailure('INVALID_STATE');\n for (const dependency of dependencies) identifier(dependency);\n const maxAttempts = step.maxAttempts ?? 1, replaySafe = step.replaySafe ?? false;\n if (!Number.isSafeInteger(maxAttempts) || Number(maxAttempts) < 1 || typeof replaySafe !== 'boolean') executionFailure('INVALID_STATE');\n steps.push({ id: step.id, execute: step.execute as WorkflowStep['execute'], dependencies: dependencies as string[], maxAttempts: Number(maxAttempts), replaySafe });\n }\n const definition = { id: input.id, version: input.version, steps: cloneSteps(steps) }; workflowIdentity(definition); dependencyWaves(definition.steps); return definition;\n } catch { return executionFailure('INVALID_STATE'); }\n}\nfunction guardCheckpoint(context: ExecutionDatabaseContext, identity: RunIdentity, next: WorkflowCheckpoint, previous?: WorkflowCheckpoint): void {\n const key = runKey(context.source.sourceId, identity);\n visitEffects(context, (_id, effect) => {\n if (!unresolved(effect.metadata) || runKey(context.source.sourceId, effect.association.identity) !== key) return;\n const step = next.steps[effect.association.stepId], before = previous?.steps[effect.association.stepId];\n if (!step || ['pending', 'completed'].includes(step.status)\n || step.status === 'running' && (before?.status !== 'running' || before.attempts !== step.attempts)) executionFailure('OUTCOME_UNKNOWN');\n });\n}\n/** Log and materialized checkpoint share one transaction; app callbacks remain WorkflowRunner-owned. */\nexport class LogWorkflowStore implements WorkflowStore {\n readonly #database!: LogExecutionDatabase; readonly #identity!: RunIdentity; readonly #definition!: WorkflowDefinition;\n constructor(options: { database: LogExecutionDatabase; identity: RunIdentity; definition: WorkflowDefinition }) {\n try {\n options = ownObject(options, ['database', 'identity', 'definition']); const context = executionContext(options.database);\n this.#identity = captureIdentity(options.identity); if (this.#identity.systemId !== context.source.systemId) executionFailure('INVALID_STATE');\n this.#database = options.database; this.#definition = captureDefinition(options.definition);\n } catch { return executionFailure('INVALID_STATE'); }\n }\n async acquire(runId: string): Promise<WorkflowLease> {\n if (runId !== this.#identity.runId) executionFailure('INVALID_STATE');\n const context = executionContext(this.#database), identity = this.#identity, key = runKey(context.source.sourceId, identity), definition = this.#definition;\n const acquired = context.transaction(() => ({ owner: acquireOwner(context, 'workflow', identity), revision: readState(context, 'workflow', key, identity)?.revision ?? 0 }), true);\n const owner = acquired.owner; markOwnerActive(context, owner); let revision = acquired.revision, poisoned = false, released = false, busy = false;\n const assert = () => { if (released || poisoned) executionFailure('OUTCOME_UNKNOWN'); assertOwner(context, owner); };\n const captureSnapshot = () => context.transaction(() => { assert(); return readState(context, 'workflow', key, identity); });\n const checkSnapshot = (snapshot: ReturnType<typeof readState>) => context.transaction(() => {\n assert(); const current = readState(context, 'workflow', key, identity);\n if ((current?.revision ?? 0) !== revision || current?.recordDigest !== snapshot?.recordDigest || current?.recordJson !== snapshot?.recordJson) executionFailure('OUTCOME_UNKNOWN');\n });\n return {\n async load() {\n if (busy) executionFailure('CODEC_BUSY'); busy = true;\n try { return await context.codec.operation(async () => {\n const snapshot = captureSnapshot(); if (!snapshot) return undefined;\n const record = await hydrateState(context, 'workflow', snapshot, () => checkSnapshot(snapshot)); checkSnapshot(snapshot);\n const checkpoint = validateCheckpoint(record, definition, runId);\n context.transaction(() => { assert(); guardCheckpoint(context, identity, checkpoint, checkpoint); }); return checkpoint;\n }); } catch (error) { poisoned = true; return safeExecutionFailure(error); } finally { busy = false; }\n },\n async save(input) {\n if (busy) executionFailure('CODEC_BUSY'); busy = true;\n try {\n await context.codec.operation(async () => {\n const snapshot = captureSnapshot(), check = () => checkSnapshot(snapshot);\n const captured = await context.codec.capture(input, check); check(); const next = validateCheckpoint(captured, definition, runId);\n const original = snapshot ? await hydrateState(context, 'workflow', snapshot, check) : undefined; check();\n const previous = original ? validateCheckpoint(original, definition, runId) : undefined;\n const prepared = await prepareState(context, 'workflow', key, identity, next as unknown as import('./types.js').LogJsonValue, revision, `workflow.${next.status}`, check); check();\n const result = context.transaction(() => { assert(); guardCheckpoint(context, identity, next, previous); return commitState(context, 'workflow', key, identity, prepared); }, true);\n revision = result.revision;\n });\n } catch (error) { poisoned = true; safeExecutionFailure(error); } finally { busy = false; }\n },\n async release() {\n if (released) return;\n if (busy) executionFailure('OUTCOME_UNKNOWN');\n try { if (poisoned) executionFailure('OUTCOME_UNKNOWN'); context.transaction(() => releaseOwner(context, owner), true); released = true; }\n finally { markOwnerDrained(context, owner); }\n },\n };\n }\n}\n","import { types } from 'node:util';\nimport { canonical, freeze, hash, method, object } from '../../shared/json.js';\nimport { captureIdentity, boundedInteger, invalidCapture } from './capture-codec.js';\nimport { capture, decodeEntry, digest, entryBody, genesis } from './encoding.js';\nimport type { LogEntry, LogPage, LogQuery, LogSourceDescriptor } from './store-types.js';\nimport type { LogPosition } from './types.js';\nimport type { LogProjection, LogProjectionOptions, LogProjectionPage, ProjectionCursor, ProjectionIssue, ProjectionItem, ProjectionPurpose } from './projection-types.js';\nimport { projectCommittedEntry } from './projection-codecs.js';\nimport { captureProjectionPage, dataArray, projectionCursor as cursor, projectionPosition as position, projectionSource as descriptor, sameProjectionData as same } from './projection-data.js';\nimport { coherentReconciliation } from './projection-reconciliation.js';\n\nconst MAX_LINKS = 32768, MAX_BYTES = 4 * 1024 * 1024;\nfunction checkedEntry(input: unknown, source: LogSourceDescriptor): LogEntry {\n object(input, ['format', 'sourceId', 'sequence', 'digest', 'requestId', 'ordinal', 'previousDigest', 'record']);\n const commit = capture({ requestId: input.requestId, records: [input.record] }, source); hash(input.digest); hash(input.previousDigest);\n if (input.format !== 1 || input.sourceId !== source.sourceId) invalidCapture();\n boundedInteger(input.sequence, 1, Number.MAX_SAFE_INTEGER); boundedInteger(input.ordinal, 1, 256);\n return decodeEntry(canonical(entryBody(source, input.sequence as number, commit.requestId, input.ordinal as number, input.previousDigest, commit.records[0]!)), input.digest, source);\n}\n/** Source reader is a trusted committed-store DATA port. Structural pages alone never grant execution permission. */\nexport function createLogProjector(purpose: ProjectionPurpose, options: LogProjectionOptions) {\n object(options, ['reader', 'identity', 'maxPages', 'maxEntries']);\n const identity = captureIdentity(options.identity), identityDigest = digest(canonical(identity));\n if (!options.reader || typeof options.reader !== 'object' || types.isProxy(options.reader)) invalidCapture();\n const sourceDescriptor = Object.getOwnPropertyDescriptor(options.reader, 'descriptor');\n if (!sourceDescriptor || !Object.hasOwn(sourceDescriptor, 'value')) invalidCapture(); const source = descriptor(sourceDescriptor.value);\n if (source.systemId !== identity.systemId) invalidCapture();\n const readPage = method<(query: LogQuery) => Promise<LogPage>>(options.reader, 'readPage');\n const maxPages = boundedInteger(options.maxPages ?? 128, 1, 128), maxEntries = boundedInteger(options.maxEntries ?? 10000, 1, 10000);\n async function read(input: { cursor?: ProjectionCursor; limit?: number } = {}): Promise<LogProjectionPage> {\n object(input, ['cursor', 'limit']); const limit = Math.min(boundedInteger(input.limit ?? 32, 1, 256), 32);\n const saved = input.cursor === undefined ? undefined : cursor(input.cursor, purpose, identityDigest, source);\n const from = saved?.underlying.after ?? { sourceId: source.sourceId, sequence: 0, digest: genesis(source) };\n let through = saved?.underlying.through ?? from;\n const links: LogProjectionPage['links'][number][] = [], items: LogProjectionPage['items'][number][] = [], issues: ProjectionIssue[] = [];\n let nextCursor: ProjectionCursor | undefined;\n try {\n const page = await readPage({ limit, ...(saved ? { cursor: saved.underlying } : {}) });\n object(page, ['source', 'through', 'items', 'scanned', 'nextCursor']);\n if (!same(descriptor(page.source), source)) invalidCapture(); through = position(page.through, source);\n if (saved && !same(through, saved.underlying.through) || through.sequence < from.sequence) invalidCapture();\n const entries = dataArray(page.items, limit); if (page.scanned !== entries.length) invalidCapture();\n let previous = from;\n for (const raw of entries) {\n const entry = checkedEntry(raw, source);\n if (entry.sequence !== previous.sequence + 1 || entry.previousDigest !== previous.digest || entry.sequence > through.sequence) invalidCapture();\n const at = { sourceId: entry.sourceId, sequence: entry.sequence, digest: entry.digest }; links.push({ position: at, previousDigest: entry.previousDigest }); previous = at;\n if (same(entry.record.identity, identity)) items.push(projectCommittedEntry(entry));\n }\n if (page.nextCursor !== undefined) {\n nextCursor = cursor({ format: 1, purpose, identityDigest, source, underlying: page.nextCursor }, purpose, identityDigest, source);\n if (!same(nextCursor.underlying.after, previous) || !same(nextCursor.underlying.through, through) || previous.sequence >= through.sequence || !links.length) invalidCapture();\n } else if (!same(previous, through)) invalidCapture();\n } catch (error) {\n const code = error && typeof error === 'object' && !types.isProxy(error) ? Object.getOwnPropertyDescriptor(error, 'code') : undefined;\n issues.push(code && Object.hasOwn(code, 'value') && ['STORAGE', 'CLOSED', 'BUSY'].includes(code.value) ? 'SOURCE_UNAVAILABLE' : 'LOG_CORRUPT');\n nextCursor = undefined;\n }\n return freeze({ format: 1, purpose, identityDigest, source, from, through, links, items, issues, ...(nextCursor ? { nextCursor } : {}) });\n }\n async function rebuild(input: { limit?: number } = {}): Promise<LogProjection> {\n object(input, ['limit']); const requestedLimit = boundedInteger(input.limit ?? 32, 1, 256);\n const pages: LogProjectionPage[] = []; let next: ProjectionCursor | undefined, bytes = 0, entries = 0;\n for (let count = 0; count < maxPages; count++) {\n const page = await read({ limit: Math.min(requestedLimit, maxEntries - entries), ...(next ? { cursor: next } : {}) });\n const pageBytes = Buffer.byteLength(canonical(page));\n if (pages.length && bytes + pageBytes > MAX_BYTES) break;\n pages.push(page); next = page.nextCursor; bytes += pageBytes; entries += page.items.length;\n if (!next || entries >= maxEntries || bytes >= MAX_BYTES) break;\n }\n const result = mergeLogProjectionPages(pages);\n if (!next) return result;\n return freeze({ ...result, kind: result.kind === 'corrupt' ? 'corrupt' : 'incomplete', issues: [...new Set([...result.issues, 'PROJECTION_LIMIT' as const])] });\n }\n return Object.freeze({ read, rebuild });\n}\n/** Pure deterministic DATA merge. Replayed pages deduplicate by exact source position, not time. */\nexport function mergeLogProjectionPages(pages: readonly LogProjectionPage[]): LogProjection {\n const captured: LogProjectionPage[] = []; let bytes = 0;\n for (const input of dataArray(pages, 256)) { const page = captureProjectionPage(input); bytes += Buffer.byteLength(canonical(page)); if (bytes > MAX_BYTES) invalidCapture(); captured.push(page); }\n pages = captured; if (!pages.length) invalidCapture();\n const first = pages[0]!, links = new Map<number, LogProjectionPage['links'][number]>(), items = new Map<number, LogProjectionPage['items'][number]>(), issues = new Set<ProjectionIssue>();\n for (const page of pages) {\n if (page.purpose !== first.purpose || page.identityDigest !== first.identityDigest || !same(page.source, first.source) || !same(page.through, first.through)) invalidCapture();\n for (const issue of page.issues) issues.add(issue);\n for (const link of page.links) { const old = links.get(link.position.sequence); if (old && !same(old, link)) issues.add('LOG_CORRUPT'); else links.set(link.position.sequence, link); }\n for (const item of page.items) { const old = items.get(item.position.sequence); if (old && !same(old, item)) issues.add('LOG_CORRUPT'); else items.set(item.position.sequence, item); for (const issue of item.issues) issues.add(issue); }\n if (links.size > MAX_LINKS || items.size > 10000) invalidCapture();\n }\n let coveredThrough: LogPosition = { sourceId: first.source.sourceId, sequence: 0, digest: genesis(first.source) };\n for (const link of [...links.values()].sort((a, b) => a.position.sequence - b.position.sequence)) {\n if (link.position.sequence !== coveredThrough.sequence + 1 || link.previousDigest !== coveredThrough.digest) { issues.add('HISTORY_GAP'); break; } coveredThrough = link.position;\n }\n if (!same(coveredThrough, first.through)) issues.add('HISTORY_GAP');\n const sorted = [...items.values()].sort((a, b) => a.position.sequence - b.position.sequence);\n if (!sorted.length) issues.add('RUN_NOT_FOUND');\n const invocation = new Map<string, { stage: string; actual: unknown }>(), decisions = new Map<string, string>(), workflows = new Map<string, string>();\n let runStart: ProjectionItem | undefined, runStage: string | undefined;\n for (const item of sorted) {\n if (item.category === 'reconciliation' && !coherentReconciliation(item, items, first.source.sourceId)) issues.add('INCOMPLETE_ORIGIN');\n for (const causal of item.causal) if (causal.sourceIdDigest !== digest(first.source.sourceId) || links.get(causal.sequence)?.position.digest !== causal.digest) issues.add('UNRESOLVED_CAUSAL_REFERENCE');\n const m = item.metadata as Record<string, unknown> | undefined; if (!m) continue;\n if (item.category === 'run') {\n if (m.stage === 'started') {\n if (runStart || item.causal.length) issues.add('INCOMPLETE_ORIGIN'); runStart = item; runStage = 'started';\n } else {\n if (!runStart || runStage !== 'started' || (runStart.metadata as Record<string, unknown>).inputDigest !== m.inputDigest\n || item.causal.length !== 1 || item.causal[0]!.sequence !== runStart.position.sequence || item.causal[0]!.digest !== runStart.position.digest) issues.add('INCOMPLETE_ORIGIN');\n runStage = m.stage as string;\n }\n }\n if (item.category === 'capture-operation' || item.category === 'agent-event') {\n const known = invocation.get(m.invocationDigest as string);\n if (item.category === 'capture-operation' && m.stage === 'started') {\n if (known) issues.add('INCOMPLETE_ORIGIN'); invocation.set(m.invocationDigest as string, { stage: 'started', actual: m.actual });\n } else if (!known || known.stage !== 'started' || !same(known.actual, m.actual)) issues.add('INCOMPLETE_ORIGIN');\n else if (item.category === 'capture-operation') invocation.set(m.invocationDigest as string, { ...known, stage: m.stage as string });\n }\n if (item.category === 'decision') decisions.set(m.decisionIdDigest as string, m.status as string);\n if (item.category === 'workflow') workflows.set(m.workflowIdDigest as string, m.status as string);\n }\n if ([...invocation.values()].some(value => value.stage !== 'settled')) issues.add('INVOCATION_UNSETTLED');\n if (runStage && runStage !== 'completed') issues.add('INVOCATION_UNSETTLED');\n const awaiting = [...decisions.values()].some(status => ['intent', 'dispatched', 'needs-owner', 'waiting'].includes(status)) || [...workflows.values()].some(status => status === 'halted');\n return freeze({ format: 1, purpose: first.purpose, identityDigest: first.identityDigest, scope: 'captured-metadata', textReconstruction: 'unavailable', qualityAssessment: 'not-derived', source: first.source, through: first.through, coveredThrough,\n kind: issues.has('LOG_CORRUPT') ? 'corrupt' : issues.size ? 'incomplete' : awaiting ? 'awaiting-owner' : 'observed', items: sorted, issues: [...issues].sort() });\n}\n","import { canonical, freeze, hash, object } from '../../shared/json.js';\nimport { boundedDataArray, boundedInteger } from './capture-codec.js';\nimport { digest } from './encoding.js';\nimport type { LogEntry } from './store-types.js';\nimport type { ProjectionItem } from './projection-types.js';\nconst digests = ['decisionIdDigest', 'intentIdDigest', 'associationDigest', 'inputHash', 'authorityHash', 'inputVersionDigest', 'authorityVersionDigest', 'resultHash'];\nconst fields = ['kind', 'status', ...digests, 'evidenceDigests', 'original', 'verified'];\nfunction reference(input: unknown) {\n object(input, ['sourceIdDigest', 'sequence', 'digest']); if (Object.keys(input).length !== 3) throw Error();\n hash(input.sourceIdDigest); hash(input.digest); boundedInteger(input.sequence, 1, Number.MAX_SAFE_INTEGER);\n return { sourceIdDigest: input.sourceIdDigest, sequence: input.sequence as number, digest: input.digest };\n}\n/** Closed finite metadata only. Neither reconciliation status nor these hashes grant effects/release. */\nexport function capturePublicReconciliation(input: unknown): Readonly<Record<string, unknown>> {\n object(input, fields); if (Object.keys(input).length !== fields.length || input.kind !== 'decision-reconciliation' || input.status !== 'verified') throw Error();\n for (const key of digests) hash(input[key]); const evidenceDigests = boundedDataArray(input.evidenceDigests, 64); for (const value of evidenceDigests) hash(value);\n const original = reference(input.original), verified = reference(input.verified);\n if (original.sequence >= verified.sequence) throw Error();\n return freeze({ ...input, evidenceDigests: [...evidenceDigests], original, verified });\n}\nexport function projectReconciliation(entry: LogEntry, input: unknown): Readonly<Record<string, unknown>> {\n object(input, fields); if (entry.record.type !== 'decision.reconciled') throw Error();\n const transform = (raw: unknown) => {\n object(raw, ['sourceId', 'sequence', 'digest']); if (raw.sourceId !== entry.sourceId || Object.keys(raw).length !== 3) throw Error();\n hash(raw.digest); boundedInteger(raw.sequence, 1, entry.sequence - 1);\n return { sourceIdDigest: digest(entry.sourceId), sequence: raw.sequence, digest: raw.digest };\n };\n if (canonical(entry.record.causal) !== canonical([input.original, input.verified])) throw Error();\n return capturePublicReconciliation({ ...input, original: transform(input.original), verified: transform(input.verified) });\n}\nexport function coherentReconciliation(item: ProjectionItem, items: ReadonlyMap<number, ProjectionItem>, sourceId: string): boolean {\n const m = item.metadata! as Record<string, unknown>, original = reference(m.original), verified = reference(m.verified);\n if (original.sourceIdDigest !== digest(sourceId) || verified.sourceIdDigest !== digest(sourceId) || verified.sequence >= item.position.sequence\n || canonical(item.causal) !== canonical([original, verified])) return false;\n const before = items.get(original.sequence), after = items.get(verified.sequence);\n if (before?.position.digest !== original.digest || after?.position.digest !== verified.digest || before.category !== 'decision' || after.category !== 'decision') return false;\n const b = before.metadata as Record<string, unknown>, a = after.metadata as Record<string, unknown>;\n return ['intent', 'dispatched', 'needs-owner'].includes(b.status as string) && a.status === 'verified' && a.resultHash === m.resultHash\n && ['decisionIdDigest', 'intentIdDigest', 'inputHash', 'authorityHash', 'inputVersionDigest', 'authorityVersionDigest'].every(key => b[key] === m[key] && a[key] === m[key]);\n}\n","import { freeze, hash, object } from '../../shared/json.js';\nimport { AGENT_METADATA_SCHEMA, CAPTURE_OPERATION_SCHEMA, boundedDataArray, boundedInteger, decodeCaptureMetadata } from './capture-codec.js';\nimport type { LogEntry } from './store-types.js';\nimport type { ProjectionIssue, ProjectionItem } from './projection-types.js';\nimport { digest } from './encoding.js';\nimport { captureExecutionMetadata } from './execution-metadata.js';\nimport { captureRecordBody } from './record-codec.js';\nimport { projectReconciliation } from './projection-reconciliation.js';\nimport { RUN_HISTORY_SCHEMA, decodeRunMarker } from './run-history-codec.js';\n/** Closed public allowlist. Deliberately never parses the adjacent private recordJson. */\nfunction executionMetadata(entry: LogEntry, input: unknown): Readonly<Record<string, unknown>> {\n object(input, entry.record.schema.version === 1 ? ['kind', 'key', 'revision', 'recordJson', 'recordDigest', 'metadata'] : ['kind', 'key', 'revision', 'recordDigest', 'body', 'metadata']);\n if (entry.record.schema.version === 1) { if (typeof input.recordJson !== 'string') throw Error(); }\n else { const body = captureRecordBody(input.body, entry.sourceId, entry.record.identity, 128 * 1024 * 1024); if (body.reference.digest !== input.recordDigest) throw Error(); }\n hash(input.key); hash(input.recordDigest); boundedInteger(input.revision, 1, Number.MAX_SAFE_INTEGER);\n const kind = entry.record.schema.id === 'oar.execution.decision' ? 'decision' : 'workflow';\n if (input.kind !== kind) throw Error();\n const metadata = decodeExecutionMetadata(kind, input.metadata);\n if (entry.record.type !== `${kind}.${metadata.status}`) throw Error();\n return metadata;\n}\nexport function decodeExecutionMetadata(kind: 'decision' | 'workflow', metadata: unknown): Readonly<Record<string, unknown>> {\n if (kind === 'workflow') { object(metadata); boundedDataArray(metadata.steps, 256); }\n return captureExecutionMetadata(kind, metadata) as unknown as Readonly<Record<string, unknown>>;\n}\nexport function projectCommittedEntry(entry: LogEntry): ProjectionItem {\n const position = { sourceId: entry.sourceId, sequence: entry.sequence, digest: entry.digest }, issues: ProjectionIssue[] = [];\n const base = { id: `${entry.sourceId}:${entry.sequence}:${entry.digest}`, position, causal: entry.record.causal.map(ref => ({ sourceIdDigest: digest(ref.sourceId), sequence: ref.sequence, digest: ref.digest })) };\n if ('artifact' in entry.record.payload) return freeze({ ...base, category: 'unprojected', issues: ['PRIVATE_PAYLOAD'] });\n const schema = entry.record.schema;\n try {\n if (schema.id === RUN_HISTORY_SCHEMA && schema.version === 1) return freeze({ ...base, category: 'run', metadata: { stage: entry.record.type.slice(4), ...decodeRunMarker(entry.record.type, entry.record.payload.inline) }, issues });\n else if (schema.id === 'oar.execution.reconciliation' && schema.version === 1) return freeze({ ...base, category: 'reconciliation', metadata: projectReconciliation(entry, entry.record.payload.inline), issues });\n else if (['oar.execution.decision', 'oar.execution.workflow'].includes(schema.id) && [1, 2].includes(schema.version)) {\n if (schema.version === 2) issues.push('PRIVATE_PAYLOAD');\n return freeze({ ...base, category: schema.id === 'oar.execution.decision' ? 'decision' : 'workflow', metadata: executionMetadata(entry, entry.record.payload.inline), issues });\n } else if (schema.version !== 1) issues.push('UNKNOWN_SCHEMA');\n else if ([AGENT_METADATA_SCHEMA, CAPTURE_OPERATION_SCHEMA].includes(schema.id)) return freeze({ ...base, category: schema.id === AGENT_METADATA_SCHEMA ? 'agent-event' : 'capture-operation', metadata: decodeCaptureMetadata(schema.id, entry.record.type, entry.record.payload.inline), issues });\n else issues.push(['oar.execution.association', 'oar.execution.ownership'].includes(schema.id) ? 'PRIVATE_PAYLOAD' : 'UNKNOWN_SCHEMA');\n } catch { issues.push('INVALID_METADATA'); }\n return freeze({ ...base, category: 'unprojected', issues });\n}\n","import { canonical, freeze, hash, object } from '../../shared/json.js';\nimport { AGENT_METADATA_SCHEMA, CAPTURE_OPERATION_SCHEMA, boundedDataArray, boundedInteger, decodeCaptureMetadata, invalidCapture } from './capture-codec.js';\nimport { genesis } from './encoding.js';\nimport { decodeExecutionMetadata } from './projection-codecs.js';\nimport { capturePublicReconciliation } from './projection-reconciliation.js';\nimport { capturePublicRunMarker } from './run-history-codec.js';\nimport type { LogSourceDescriptor } from './store-types.js';\nimport type { LogPosition } from './types.js';\nimport type { LogProjectionPage, ProjectionCursor, ProjectionIssue, ProjectionItem, ProjectionPurpose } from './projection-types.js';\nexport const sameProjectionData = (a: unknown, b: unknown) => canonical(a) === canonical(b);\nconst issueCodes = ['UNKNOWN_SCHEMA', 'PRIVATE_PAYLOAD', 'INVALID_METADATA', 'UNRESOLVED_CAUSAL_REFERENCE', 'LOG_CORRUPT', 'SOURCE_UNAVAILABLE', 'PROJECTION_LIMIT', 'HISTORY_GAP', 'RUN_NOT_FOUND', 'INVOCATION_UNSETTLED', 'INCOMPLETE_ORIGIN'];\nexport const dataArray = boundedDataArray;\nexport function projectionPosition(input: unknown, source: LogSourceDescriptor): LogPosition {\n object(input, ['sourceId', 'sequence', 'digest']); if (input.sourceId !== source.sourceId) invalidCapture();\n boundedInteger(input.sequence, 0, Number.MAX_SAFE_INTEGER); hash(input.digest);\n if (input.sequence === 0 && input.digest !== genesis(source)) invalidCapture();\n return freeze({ sourceId: input.sourceId, sequence: input.sequence as number, digest: input.digest });\n}\nexport function projectionSource(input: unknown): LogSourceDescriptor {\n object(input, ['format', 'sourceId', 'systemId']);\n if (input.format !== 1 || typeof input.sourceId !== 'string' || !input.sourceId || input.sourceId.length > 128 || typeof input.systemId !== 'string' || !input.systemId || input.systemId.length > 128) invalidCapture();\n return freeze({ format: 1, sourceId: input.sourceId, systemId: input.systemId });\n}\nexport function projectionCursor(input: unknown, purpose: ProjectionPurpose, identityDigest: string, source: LogSourceDescriptor): ProjectionCursor {\n object(input, ['format', 'purpose', 'identityDigest', 'source', 'underlying']);\n if (input.format !== 1 || input.purpose !== purpose || input.identityDigest !== identityDigest || !sameProjectionData(projectionSource(input.source), source)) invalidCapture();\n object(input.underlying, ['format', 'filterDigest', 'after', 'through']); const raw = input.underlying;\n if (raw.format !== 1) invalidCapture(); hash(raw.filterDigest);\n const after = projectionPosition(raw.after, source), through = projectionPosition(raw.through, source); if (after.sequence > through.sequence) invalidCapture();\n return freeze({ format: 1, purpose, identityDigest, source, underlying: { format: 1, filterDigest: raw.filterDigest, after, through } });\n}\nfunction issues(input: unknown): readonly ProjectionIssue[] {\n const result = dataArray(input, issueCodes.length); if (new Set(result).size !== result.length || result.some(code => !issueCodes.includes(code as string))) invalidCapture(); return [...result] as ProjectionIssue[];\n}\nfunction item(input: unknown, source: LogSourceDescriptor): ProjectionItem {\n object(input, ['id', 'position', 'causal', 'category', 'metadata', 'issues']); const position = projectionPosition(input.position, source);\n if (!position.sequence || input.id !== `${source.sourceId}:${position.sequence}:${position.digest}`) invalidCapture();\n const causal = dataArray(input.causal, 64).map(ref => { object(ref, ['sourceIdDigest', 'sequence', 'digest']); hash(ref.sourceIdDigest); hash(ref.digest); boundedInteger(ref.sequence, 1, Number.MAX_SAFE_INTEGER); return { sourceIdDigest: ref.sourceIdDigest, sequence: ref.sequence as number, digest: ref.digest }; });\n const category = input.category as ProjectionItem['category']; let metadata: ProjectionItem['metadata'];\n if (category === 'agent-event') {\n object(input.metadata); object(input.metadata.event); const type = input.metadata.event.type; if (typeof type !== 'string') invalidCapture();\n metadata = decodeCaptureMetadata(AGENT_METADATA_SCHEMA, type, input.metadata);\n } else if (category === 'capture-operation') {\n object(input.metadata); metadata = decodeCaptureMetadata(CAPTURE_OPERATION_SCHEMA, `capture.${input.metadata.stage}`, input.metadata);\n } else if (category === 'decision' || category === 'workflow') metadata = decodeExecutionMetadata(category, input.metadata);\n else if (category === 'reconciliation') metadata = capturePublicReconciliation(input.metadata);\n else if (category === 'run') metadata = capturePublicRunMarker(input.metadata);\n else if (category !== 'unprojected' || input.metadata !== undefined) invalidCapture();\n return freeze({ id: input.id as string, position, causal, category, ...(metadata ? { metadata } : {}), issues: issues(input.issues) });\n}\n/** Restore only the closed public projection grammar. Restoration is DATA validation, not origin authentication. */\nexport function captureProjectionPage(input: unknown): LogProjectionPage {\n object(input, ['format', 'purpose', 'identityDigest', 'source', 'from', 'through', 'links', 'items', 'issues', 'nextCursor']);\n if (input.format !== 1 || !['trace', 'audit'].includes(input.purpose as string)) invalidCapture(); hash(input.identityDigest);\n const purpose = input.purpose as ProjectionPurpose, source = projectionSource(input.source), from = projectionPosition(input.from, source), through = projectionPosition(input.through, source);\n if (from.sequence > through.sequence) invalidCapture();\n const links = dataArray(input.links, 256).map(raw => { object(raw, ['position', 'previousDigest']); hash(raw.previousDigest); return { position: projectionPosition(raw.position, source), previousDigest: raw.previousDigest }; });\n let previous = from; for (const link of links) { if (link.position.sequence !== previous.sequence + 1 || link.previousDigest !== previous.digest || link.position.sequence > through.sequence) invalidCapture(); previous = link.position; }\n const items = dataArray(input.items, 256).map(raw => item(raw, source));\n const seen = new Set<number>(); for (const entry of items) { if (seen.has(entry.position.sequence) || !links.some(link => sameProjectionData(link.position, entry.position))) invalidCapture(); seen.add(entry.position.sequence); }\n const nextCursor = input.nextCursor === undefined ? undefined : projectionCursor(input.nextCursor, purpose, input.identityDigest, source);\n if (nextCursor && (!sameProjectionData(nextCursor.underlying.after, previous) || !sameProjectionData(nextCursor.underlying.through, through))) invalidCapture();\n const result = freeze({ format: 1 as const, purpose, identityDigest: input.identityDigest, source, from, through, links, items, issues: issues(input.issues), ...(nextCursor ? { nextCursor } : {}) });\n if (Buffer.byteLength(canonical(result)) > 4 * 1024 * 1024) invalidCapture(); return result;\n}\n","import type { LogProjectionOptions } from './projection-types.js';\nimport { createLogProjector } from './projection.js';\nexport function createLogTraceProjector(options: LogProjectionOptions) { return createLogProjector('trace', options); }\n","import type { LogProjectionOptions } from './projection-types.js';\nimport { createLogProjector } from './projection.js';\nexport function createLogAuditProjector(options: LogProjectionOptions) { return createLogProjector('audit', options); }\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,gBAAAA,qBAAoB;;;ACC7B,SAAS,SAAAC,cAAa;;;ACDtB,SAAS,cAAAC,mBAAkB;AAC3B,SAAS,WAAW,WAAW,UAAU,WAAW,UAAU,cAAc,kBAAkB;AAC9F,SAAS,SAAS,YAAY,eAAe;AAC7C,SAAS,oBAAoB;AAC7B,SAAS,aAAa;;;ACJtB,SAAS,kBAAkB;AAOpB,IAAM,qBAAqB;AAC3B,IAAM,qBAAqB;AAClC,IAAM,UAAU;AACT,IAAM,UAA6B,OAAO,OAAO;AAAA,EACtD;AAAA;AAAA;AAAA,EAGA;AAAA,2DACyD,OAAO,yDAAyD,OAAO;AAAA;AAAA;AAAA,EAGhI,4EAA4E,OAAO;AAAA;AAAA,qGAEgB,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAA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AA,EAAE,CAAC;AACpK;;;AI5HO,SAAS,wBAAwB,SAA+B;AAAE,SAAO,mBAAmB,SAAS,OAAO;AAAG;;;ACA/G,SAAS,wBAAwB,SAA+B;AAAE,SAAO,mBAAmB,SAAS,OAAO;AAAG;","names":["DatabaseSync","types","randomUUID","randomUUID","write","input","types","expected","identity","input","entry","input","position","identity","setImmediate","captureIdentity","input","identity","issues","setImmediate","DatabaseSync","input","identity","captureIdentity","input","isAbsolute","resolve","types","input","integer","isAbsolute","resolve","write","types","size","dirname","expected","resolve","position","dirname","reference","hash","identity","input","input","reference","DatabaseSync","randomUUID","closeSync","fsyncSync","linkSync","lstatSync","openSync","unlinkSync","dirname","DatabaseSync","expected","lstatSync","randomUUID","DatabaseSync","file","openSync","fsyncSync","closeSync","linkSync","dirname","unlinkSync","input","identity","captureIdentity","text","randomUUID","identity","captureIdentity","randomUUID","expected","types","createHash","types","setImmediate","setImmediate","input","types","captured","hash","createHash","text","input","identity","reference","digest","types","input","prepared","DatabaseSync","write","input","identity","captureIdentity","expected","input","identity","position","identity","captureIdentity","run","randomUUID","input","record","identity","expected","randomUUID","commit","prepared","id","input","identity","randomUUID","input","position","prepared","randomUUID","id","owner","input","prepared","types","input","types","identity","captureIdentity","prepared","types","input","item","executionMetadata","input","position","issues","input","position","link","input","identity","types","read","issues","link","item"]}
|