@bastani/atomic 0.9.82 → 0.9.83

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"journal-transfer.js","sourceRoot":"","sources":["../../../src/core/storage/journal-transfer.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAC9E,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEtD,OAAO,EAAE,YAAY,EAA4B,MAAM,aAAa,CAAC;AACrE,OAAO,EACN,qBAAqB,EACrB,sBAAsB,EAItB,wBAAwB,EACxB,gBAAgB,GAChB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACN,uBAAuB,EACvB,oBAAoB,EACpB,cAAc,GAGd,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AAE/E,kDAAkD;AAClD,MAAM,CAAC,MAAM,wBAAwB,GAAG,qBAAqB,CAAC;AAC9D,8DAA8D;AAC9D,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC;AAC7C,wGAAwG;AACxG,MAAM,CAAC,MAAM,6BAA6B,GAAG,QAAQ,CAAC;AACtD;;;;GAIG;AACH,MAAM,CAAC,MAAM,iCAAiC,GAAG,OAAO,CAAC;AAoDzD,iGAAiG;AACjG,MAAM,OAAO,wBAAyB,SAAQ,YAAY;I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E,CAAC;oBACP,KAAK;oBACL,MAAM,EAAE,oBAAoB,KAAK,OAAO,QAAQ,EAAE;iBAClD,CAAC,CAAC;YACJ,IAAI,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACtC,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;gBAC5B,IAAI,CAAC;oBACJ,QAAQ,GAAG,MAAM,sBAAsB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;gBACrD,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBAChB,MAAM,eAAe,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,EAAE,KAAc,CAAC,CAAC;gBACxD,CAAC;gBACD,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;YAClC,CAAC;YACD,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,WAAW,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE;gBACtD,MAAM,sBAAsB,CAAC,EAAE,CAAC,CAAC;gBACjC,OAAO,WAAW,CAAC,EAAE,EAAE,CAAC,EAAE,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;YAC5C,CAAC,EAAE,oBAAoB,CAAC,CAAC;YACzB,IAAI,MAAM,KAAK,WAAW;gBAAE,MAAM,OAAO,CAAC,SAAS,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;YACnE,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QACvB,CAAC;IACF,CAAC,EACD,KAAK,IAAI,EAAE;QACV,MAAM,SAAS,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;QACjC,MAAM,OAAO,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC,CACD,CAAC;IACF,OAAO,MAAM,CAAC;AACf,CAAC","sourcesContent":["/**\n * Workflow runs as versioned JSONL files (#4716): `exportWorkflowRuns` writes each run of a local workflow journal to\n * `<dir>/<runId>.jsonl`, and `importWorkflowRuns` restores such files into one. The journal stays the working store;\n * the files are the form runs take at rest, so a host that persists only files can carry them between machines.\n *\n * Line 1 of a file is the run's header: the row of the journal's runs table. Every later line is one row of its\n * events table, in sequence order, with its payload as a JSON value instead of JSON text. Leases, local-worker pool\n * state and worktree snapshot blobs are not exported: they belong to the machine that wrote them.\n */\n\nimport { randomUUID } from \"node:crypto\";\nimport { existsSync } from \"node:fs\";\nimport { mkdir, open, readdir, readFile, rename, rm } from \"node:fs/promises\";\nimport { join, resolve } from \"node:path\";\nimport { closeEach, withCleanup } from \"./cleanup.js\";\nimport type { SqliteDatabase, SqliteExecutor, SqliteRow, SqliteValue } from \"./database.js\";\nimport { StorageError, type StorageFailureCause } from \"./errors.js\";\nimport {\n\tdiscoverLegacyJournal,\n\tensureRunJournalSchema,\n\ttype JournalEventTableRow,\n\ttype JournalLeaseTableRow,\n\ttype JournalRunTableRow,\n\tlegacyDefaultJournalPath,\n\trunJournalTables,\n} from \"./journal-adoption.js\";\nimport {\n\tisFinishedJournalStatus,\n\tJOURNAL_CATALOG_FILE,\n\tJournalCatalog,\n\ttype JournalCatalogRun,\n\ttype JournalShardRecord,\n} from \"./journal-catalog.js\";\nimport { openNodeSqliteDatabase } from \"./node-sqlite.js\";\nimport { RUN_EVENT_TYPES, RUN_JOURNAL_SCHEMA_VERSION } from \"./run-journal.js\";\n\n/** The `type` of an export file's header line. */\nexport const WORKFLOW_RUN_EXPORT_TYPE = \"atomic.workflow-run\";\n/** The export format version this Atomic writes and reads. */\nexport const WORKFLOW_RUN_EXPORT_VERSION = 1;\n/** The file name extension of an exported run; import reads every file with it and ignores the rest. */\nexport const WORKFLOW_RUN_EXPORT_EXTENSION = \".jsonl\";\n/**\n * A lease renewed this recently belongs to a process that may still be running the run on this machine, so an import\n * does not add events to that run. It matches the window in which the workflows runtime treats a running run's owner\n * as live.\n */\nexport const WORKFLOW_RUN_IMPORT_LIVE_LEASE_MS = 120_000;\n\n/** A JSON value as an export file holds it. */\nexport type WorkflowRunExportValue =\n\t| string\n\t| number\n\t| boolean\n\t| null\n\t| readonly WorkflowRunExportValue[]\n\t| { readonly [key: string]: WorkflowRunExportValue };\n\n/** Line 1 of an export file. */\nexport interface WorkflowRunExportHeader {\n\treadonly type: typeof WORKFLOW_RUN_EXPORT_TYPE;\n\treadonly version: typeof WORKFLOW_RUN_EXPORT_VERSION;\n\treadonly runId: string;\n\treadonly name: string;\n\treadonly cwd: string;\n\treadonly createdAt: number;\n\t/** The run's latest status. */\n\treadonly status: string;\n\t/** How many event lines follow. */\n\treadonly events: number;\n\t/** The run header the journal recorded when the run was created. */\n\treadonly header: { readonly [key: string]: WorkflowRunExportValue };\n}\n\n/** One event line of an export file: one journal entry. */\nexport interface WorkflowRunExportEvent {\n\treadonly type: string;\n\treadonly seq: number;\n\treadonly epoch: number;\n\treadonly key: string | null;\n\treadonly at: number;\n\treadonly payload: WorkflowRunExportValue;\n}\n\n/** The local workflow journal storage that runs are exported from and imported into. */\nexport type WorkflowRunTransferStorage =\n\t| { readonly kind: \"store\"; readonly directory: string }\n\t| { readonly kind: \"sqlite\"; readonly path: string; readonly prefix?: string };\n\nexport interface WorkflowRunTransferErrorInit {\n\t/** The file or storage location the error is about. */\n\treadonly path: string;\n\t/** The 1-based line of `path`. */\n\treadonly line?: number;\n\treadonly runId?: string;\n\treadonly reason: string;\n\treadonly cause?: StorageFailureCause;\n}\n\n/** An export or import that could not be done; an import that fails this way changed nothing. */\nexport class WorkflowRunTransferError extends StorageError {\n\toverride readonly name = \"WorkflowRunTransferError\" as const;\n\treadonly path: string;\n\treadonly line: number | undefined;\n\treadonly runId: string | undefined;\n\treadonly reason: string;\n\n\tconstructor(init: WorkflowRunTransferErrorInit) {\n\t\tsuper(`${init.path}${init.line === undefined ? \"\" : `:${init.line}`}: ${init.reason}`, { cause: init.cause });\n\t\tthis.path = init.path;\n\t\tthis.line = init.line;\n\t\tthis.runId = init.runId;\n\t\tthis.reason = init.reason;\n\t}\n}\n\nexport function isWorkflowRunTransferError(value: unknown): value is WorkflowRunTransferError {\n\tif (value instanceof WorkflowRunTransferError) return true;\n\treturn (\n\t\ttypeof value === \"object\" && value !== null && (value as { name?: unknown }).name === \"WorkflowRunTransferError\"\n\t);\n}\n\nexport interface WorkflowRunExportOptions {\n\t/** Only these runs; a run the storage does not hold fails the export before any file is written. */\n\treadonly runs?: readonly string[];\n\t/** Only runs that are not completed, failed or cancelled. */\n\treadonly unfinished?: boolean;\n\t/** At most this many runs, newest first. */\n\treadonly limit?: number;\n}\n\nexport interface WorkflowRunExportReport {\n\t/** Runs whose file was written. */\n\treadonly written: readonly string[];\n\t/** Runs whose file already held exactly this export, left untouched. */\n\treadonly unchanged: readonly string[];\n\t/** Journal files that could not be read, and runs the catalog lists that no readable journal holds. */\n\treadonly skipped: readonly { readonly path: string; readonly runId?: string; readonly reason: string }[];\n}\n\nexport interface WorkflowRunImportReport {\n\t/** Runs the storage did not hold. */\n\treadonly added: readonly string[];\n\t/** Runs the storage held an earlier part of, which now have the file's later events. */\n\treadonly updated: readonly string[];\n\t/** Runs the storage already held every event of. */\n\treadonly unchanged: readonly string[];\n}\n\nconst STORE_NOW = \"CAST(unixepoch('subsec') * 1000 AS INTEGER)\";\nconst TRANSFER_TRANSACTION = { lockWaitMs: 10 * 60_000 } as const;\nconst EVENT_TYPES: ReadonlySet<string> = new Set(Object.values(RUN_EVENT_TYPES));\nconst HEADER_FIELDS = [\"type\", \"version\", \"runId\", \"name\", \"cwd\", \"createdAt\", \"status\", \"events\", \"header\"] as const;\nconst EVENT_FIELDS = [\"type\", \"seq\", \"epoch\", \"key\", \"at\", \"payload\"] as const;\n\ntype JsonObject = { readonly [key: string]: WorkflowRunExportValue };\ntype Tables = ReturnType<typeof runJournalTables>;\n\n/** The file an exported run is written to in `directory`. */\nexport function workflowRunExportFile(directory: string, runId: string): string {\n\treturn join(directory, `${encodeURIComponent(runId)}${WORKFLOW_RUN_EXPORT_EXTENSION}`);\n}\n\nfunction storageLocation(storage: WorkflowRunTransferStorage): string {\n\treturn storage.kind === \"store\" ? storage.directory : storage.path;\n}\n\nfunction parseStored(text: string, path: string, runId: string, what: string): WorkflowRunExportValue {\n\ttry {\n\t\treturn JSON.parse(text) as WorkflowRunExportValue;\n\t} catch (cause) {\n\t\tthrow new WorkflowRunTransferError({\n\t\t\tpath,\n\t\t\trunId,\n\t\t\treason: `run ${runId} has ${what} that is not valid JSON`,\n\t\t\tcause: cause as StorageFailureCause,\n\t\t});\n\t}\n}\n\n/** A run and its events as the lines of its export file, newline-terminated. */\nfunction exportText(run: JournalRunTableRow, events: readonly JournalEventTableRow[], path: string): string {\n\tconst header = parseStored(run.header_json, path, run.run_id, \"a header\");\n\tif (!isObject(header))\n\t\tthrow new WorkflowRunTransferError({\n\t\t\tpath,\n\t\t\trunId: run.run_id,\n\t\t\treason: `run ${run.run_id} has a header that is not an object`,\n\t\t});\n\tconst lines = [\n\t\tJSON.stringify({\n\t\t\ttype: WORKFLOW_RUN_EXPORT_TYPE,\n\t\t\tversion: WORKFLOW_RUN_EXPORT_VERSION,\n\t\t\trunId: run.run_id,\n\t\t\tname: run.name,\n\t\t\tcwd: run.cwd,\n\t\t\tcreatedAt: Number(run.created_at),\n\t\t\tstatus: run.status,\n\t\t\tevents: events.length,\n\t\t\theader,\n\t\t} satisfies WorkflowRunExportHeader),\n\t];\n\tfor (const event of events)\n\t\tlines.push(\n\t\t\tJSON.stringify({\n\t\t\t\ttype: event.type,\n\t\t\t\tseq: Number(event.seq),\n\t\t\t\tepoch: Number(event.epoch),\n\t\t\t\tkey: event.key,\n\t\t\t\tat: Number(event.at),\n\t\t\t\tpayload: parseStored(event.payload, path, run.run_id, `event ${event.seq} with a payload`),\n\t\t\t} satisfies WorkflowRunExportEvent),\n\t\t);\n\treturn `${lines.join(\"\\n\")}\\n`;\n}\n\n/**\n * Writes `content` to `file` through a temporary file in the same directory that is flushed and then renamed over it,\n * so `file` holds either its earlier content or all of `content`. A file that already holds `content` is left alone.\n */\nasync function writeAtomically(file: string, content: string): Promise<\"written\" | \"unchanged\"> {\n\tconst existing = await readFile(file, \"utf8\").catch(() => undefined);\n\tif (existing === content) return \"unchanged\";\n\tconst temporary = join(resolve(file, \"..\"), `.${randomUUID()}.tmp`);\n\ttry {\n\t\tconst handle = await open(temporary, \"wx\");\n\t\tawait withCleanup(\n\t\t\tasync () => {\n\t\t\t\tawait handle.writeFile(content, \"utf8\");\n\t\t\t\tawait handle.sync();\n\t\t\t},\n\t\t\t() => handle.close(),\n\t\t);\n\t\tawait rename(temporary, file);\n\t} catch (error) {\n\t\tawait rm(temporary, { force: true }).catch(() => undefined);\n\t\tthrow new WorkflowRunTransferError({\n\t\t\tpath: file,\n\t\t\treason: `cannot write the export file: ${(error as Error).message}`,\n\t\t\tcause: error as StorageFailureCause,\n\t\t});\n\t}\n\treturn \"written\";\n}\n\nasync function hasTables(executor: SqliteExecutor, t: Tables): Promise<boolean> {\n\tconst rows = await executor.all<SqliteRow & { name: string }>(\n\t\t\"SELECT name FROM sqlite_master WHERE type = 'table' AND name IN (?, ?, ?)\",\n\t\tt.meta,\n\t\tt.runs,\n\t\tt.events,\n\t);\n\treturn rows.length === 3;\n}\n\nasync function schemaVersion(executor: SqliteExecutor, t: Tables): Promise<SqliteValue | undefined> {\n\tconst rows = await executor.all<SqliteRow & { schema_version: SqliteValue }>(`SELECT schema_version FROM ${t.meta}`);\n\treturn rows.length === 1 ? rows[0]!.schema_version : undefined;\n}\n\n/** One journal file an export reads, inside one read transaction, so every run it holds is read as of one moment. */\ninterface ExportSource {\n\treadonly path: string;\n\treadonly shardId?: number;\n\treadonly database: SqliteDatabase;\n\treadonly runs: readonly JournalRunTableRow[];\n}\n\n/** Opens a journal file for an export and begins its read transaction; undefined, with the reason, when it cannot. */\nasync function openExportSource(\n\tpath: string,\n\tt: Tables,\n\tshardId: number | undefined,\n): Promise<ExportSource | { readonly path: string; readonly reason: string }> {\n\tif (!existsSync(path)) return { path, reason: \"the journal file no longer exists\" };\n\tlet database: SqliteDatabase;\n\ttry {\n\t\tdatabase = await openNodeSqliteDatabase(path, { readOnly: true });\n\t} catch (error) {\n\t\treturn { path, reason: `the journal file cannot be opened: ${(error as Error).message}` };\n\t}\n\ttry {\n\t\tawait database.exec(\"BEGIN\");\n\t\tif (!(await hasTables(database, t))) {\n\t\t\tawait database.exec(\"COMMIT\");\n\t\t\tawait database.close();\n\t\t\treturn { path, reason: \"it has no workflow runs in the current journal format\" };\n\t\t}\n\t\tconst version = await schemaVersion(database, t);\n\t\tif (version !== RUN_JOURNAL_SCHEMA_VERSION) {\n\t\t\tawait database.exec(\"COMMIT\");\n\t\t\tawait database.close();\n\t\t\treturn { path, reason: `unsupported journal schema version ${String(version)}` };\n\t\t}\n\t\tconst runs = await database.all<JournalRunTableRow>(`SELECT * FROM ${t.runs} ORDER BY run_id`);\n\t\treturn { path, database, runs, ...(shardId === undefined ? {} : { shardId }) };\n\t} catch (error) {\n\t\tawait database.close().catch(() => undefined);\n\t\treturn { path, reason: `the journal file cannot be read: ${(error as Error).message}` };\n\t}\n}\n\n/**\n * Adopts the default journal of Atomic before the journal store, as opening the store does, so its runs are exported\n * and compared like every other run; whether the store has a catalog.\n */\nasync function adoptLegacyJournal(directory: string): Promise<boolean> {\n\tif (existsSync(legacyDefaultJournalPath(directory))) {\n\t\tconst catalog = await JournalCatalog.open(directory);\n\t\tawait withCleanup(\n\t\t\tasync () => {\n\t\t\t\tawait discoverLegacyJournal(catalog, legacyDefaultJournalPath(directory));\n\t\t\t},\n\t\t\t() => catalog.close(),\n\t\t);\n\t}\n\treturn existsSync(join(directory, JOURNAL_CATALOG_FILE));\n}\n\nfunction newestFirst(left: JournalRunTableRow, right: JournalRunTableRow): number {\n\tconst created = Number(right.created_at) - Number(left.created_at);\n\tif (created !== 0) return created;\n\treturn left.run_id < right.run_id ? -1 : left.run_id > right.run_id ? 1 : 0;\n}\n\n/**\n * Exports runs of a local workflow journal to `<directory>/<runId>.jsonl`, one file per run. Each journal file is read\n * in one read transaction, and each export file is written whole or not at all. The same journal state gives the same\n * bytes, and a file that already holds them is not rewritten.\n */\nexport async function exportWorkflowRuns(\n\tstorage: WorkflowRunTransferStorage,\n\tdirectory: string,\n\toptions: WorkflowRunExportOptions = {},\n): Promise<WorkflowRunExportReport> {\n\tconst t = runJournalTables(storage.kind === \"sqlite\" ? storage.prefix : undefined);\n\tconst skipped: { path: string; runId?: string; reason: string }[] = [];\n\tconst sources: ExportSource[] = [];\n\tlet owners: ReadonlyMap<string, number> | undefined;\n\tlet catalogued: readonly JournalCatalogRun[] = [];\n\tconst add = (opened: Awaited<ReturnType<typeof openExportSource>>) => {\n\t\tif (\"database\" in opened) sources.push(opened);\n\t\telse skipped.push(opened);\n\t};\n\treturn withCleanup(\n\t\tasync () => {\n\t\t\tif (storage.kind === \"sqlite\") {\n\t\t\t\tif (existsSync(storage.path)) add(await openExportSource(storage.path, t, undefined));\n\t\t\t} else if (await adoptLegacyJournal(storage.directory)) {\n\t\t\t\tconst catalog = await JournalCatalog.open(storage.directory);\n\t\t\t\tlet shards: readonly JournalShardRecord[];\n\t\t\t\tawait withCleanup(\n\t\t\t\t\tasync () => {\n\t\t\t\t\t\tshards = await catalog.shards();\n\t\t\t\t\t\tcatalogued = await catalog.runs();\n\t\t\t\t\t\towners = new Map(catalogued.map((run) => [run.runId, run.shard]));\n\t\t\t\t\t},\n\t\t\t\t\t() => catalog.close(),\n\t\t\t\t);\n\t\t\t\tfor (const shard of shards!) add(await openExportSource(shard.path, t, shard.id));\n\t\t\t}\n\t\t\tconst listed = new Map<string, { readonly source: ExportSource; readonly run: JournalRunTableRow }>();\n\t\t\tfor (const source of sources)\n\t\t\t\tfor (const run of source.runs) {\n\t\t\t\t\tconst owner = owners?.get(run.run_id);\n\t\t\t\t\tif (owner === undefined ? listed.has(run.run_id) : owner !== source.shardId) continue;\n\t\t\t\t\tlisted.set(run.run_id, { source, run });\n\t\t\t\t}\n\t\t\t// A consolidation that moved a run between reading the catalog and opening the journal files leaves it only in\n\t\t\t// a file the catalog did not name then: that copy is the run. A run whose named file could not be read is not\n\t\t\t// taken from another file, which may hold an older copy an interrupted consolidation left behind.\n\t\t\tconst readable = new Set(sources.map((source) => source.shardId));\n\t\t\tfor (const source of sources)\n\t\t\t\tfor (const run of source.runs) {\n\t\t\t\t\tconst owner = owners?.get(run.run_id);\n\t\t\t\t\tif (listed.has(run.run_id) || (owner !== undefined && !readable.has(owner))) continue;\n\t\t\t\t\tlisted.set(run.run_id, { source, run });\n\t\t\t\t}\n\t\t\t// A run whose journal file was read but does not hold it in the current tables is in the pre-0.9.38 format;\n\t\t\t// the runs of a journal file that could not be read are covered by that file's own entry, and a root that is\n\t\t\t// only reserved (no status yet) has nothing to export.\n\t\t\tif (options.runs === undefined)\n\t\t\t\tfor (const entry of catalogued) {\n\t\t\t\t\tconst source = sources.find((candidate) => candidate.shardId === entry.shard);\n\t\t\t\t\tif (!listed.has(entry.runId) && source !== undefined && entry.status !== undefined)\n\t\t\t\t\t\tskipped.push({\n\t\t\t\t\t\t\tpath: source.path,\n\t\t\t\t\t\t\trunId: entry.runId,\n\t\t\t\t\t\t\treason: \"it is in the journal format of Atomic before 0.9.38; resume it once to convert it\",\n\t\t\t\t\t\t});\n\t\t\t\t}\n\t\t\tlet selected = [...listed.values()];\n\t\t\tif (options.runs !== undefined) {\n\t\t\t\tconst missing = options.runs.find((runId) => !listed.has(runId));\n\t\t\t\tif (missing !== undefined)\n\t\t\t\t\tthrow new WorkflowRunTransferError({\n\t\t\t\t\t\tpath: storageLocation(storage),\n\t\t\t\t\t\trunId: missing,\n\t\t\t\t\t\treason: `run ${missing} is not in this workflow journal`,\n\t\t\t\t\t});\n\t\t\t\tselected = [...new Set(options.runs)].map((runId) => listed.get(runId)!);\n\t\t\t}\n\t\t\tif (options.unfinished) selected = selected.filter(({ run }) => !isFinishedJournalStatus(run.status));\n\t\t\tselected.sort((left, right) => newestFirst(left.run, right.run));\n\t\t\tif (options.limit !== undefined) selected = selected.slice(0, options.limit);\n\t\t\tawait mkdir(directory, { recursive: true });\n\t\t\tconst written: string[] = [];\n\t\t\tconst unchanged: string[] = [];\n\t\t\tfor (const { source, run } of selected) {\n\t\t\t\tconst events = await source.database.all<JournalEventTableRow>(\n\t\t\t\t\t`SELECT * FROM ${t.events} WHERE run_id = ? ORDER BY seq`,\n\t\t\t\t\trun.run_id,\n\t\t\t\t);\n\t\t\t\tconst file = workflowRunExportFile(directory, run.run_id);\n\t\t\t\tconst outcome = await writeAtomically(file, exportText(run, events, source.path));\n\t\t\t\t(outcome === \"written\" ? written : unchanged).push(run.run_id);\n\t\t\t}\n\t\t\treturn { written, unchanged, skipped };\n\t\t},\n\t\tasync () => {\n\t\t\tawait Promise.allSettled(sources.map((source) => source.database.exec(\"COMMIT\")));\n\t\t\tawait closeEach(sources.map((source) => source.database));\n\t\t},\n\t);\n}\n\n/** A run read from an export file and checked: everything an import writes for it. */\ninterface ParsedRun {\n\treadonly file: string;\n\treadonly header: WorkflowRunExportHeader;\n\treadonly events: readonly WorkflowRunExportEvent[];\n}\n\nfunction isObject(value: WorkflowRunExportValue | undefined): value is JsonObject {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction invalidText(value: string): string | undefined {\n\tif (value.includes(\"\\u0000\")) return \"contains a NUL character\";\n\tif (/\\p{Surrogate}/u.test(value)) return \"is not well-formed Unicode\";\n\treturn undefined;\n}\n\nfunction counter(value: WorkflowRunExportValue | undefined, minimum: number): value is number {\n\treturn typeof value === \"number\" && Number.isSafeInteger(value) && value >= minimum;\n}\n\n/** Checks that a line has exactly `fields`; the reason when it does not. */\nfunction fieldsReason(line: JsonObject, fields: readonly string[]): string | undefined {\n\tfor (const field of fields) if (!(field in line)) return `has no \"${field}\" field`;\n\tfor (const field of Object.keys(line)) if (!fields.includes(field)) return `has an unexpected \"${field}\" field`;\n\treturn undefined;\n}\n\n/** Reads and checks one export file, throwing a `WorkflowRunTransferError` that names the file and line. */\nfunction parseExportFile(file: string, bytes: Buffer): ParsedRun {\n\tconst fail = (line: number | undefined, reason: string, runId?: string): never => {\n\t\tthrow new WorkflowRunTransferError({ path: file, ...(line === undefined ? {} : { line }), runId, reason });\n\t};\n\tlet text: string;\n\ttry {\n\t\ttext = new TextDecoder(\"utf-8\", { fatal: true }).decode(bytes);\n\t} catch {\n\t\treturn fail(undefined, \"is not valid UTF-8 text\");\n\t}\n\tconst lines = text.split(\"\\n\");\n\tif (lines.at(-1) === \"\") lines.pop();\n\tif (lines.length === 0) return fail(1, \"is empty; expected a workflow run header\");\n\tconst parse = (index: number): JsonObject => {\n\t\tconst line = lines[index]!;\n\t\tif (line.trim() === \"\") return fail(index + 1, \"is empty\");\n\t\tlet value: WorkflowRunExportValue;\n\t\ttry {\n\t\t\tvalue = JSON.parse(line) as WorkflowRunExportValue;\n\t\t} catch (error) {\n\t\t\treturn fail(index + 1, `is not valid JSON (${(error as Error).message})`);\n\t\t}\n\t\tif (!isObject(value)) return fail(index + 1, \"is not a JSON object\");\n\t\tif (typeof value.type !== \"string\") return fail(index + 1, 'has no string \"type\"');\n\t\treturn value;\n\t};\n\tconst first = parse(0);\n\tif (first.type !== WORKFLOW_RUN_EXPORT_TYPE)\n\t\tfail(1, `is not an Atomic workflow run export: its type is \"${first.type}\", not \"${WORKFLOW_RUN_EXPORT_TYPE}\"`);\n\tif (first.version !== WORKFLOW_RUN_EXPORT_VERSION)\n\t\tfail(\n\t\t\t1,\n\t\t\t`has unsupported export version ${JSON.stringify(first.version ?? null)}; this Atomic reads version ${WORKFLOW_RUN_EXPORT_VERSION}`,\n\t\t);\n\tconst headerFields = fieldsReason(first, HEADER_FIELDS);\n\tif (headerFields !== undefined) fail(1, headerFields);\n\tfor (const field of [\"runId\", \"name\", \"cwd\", \"status\"] as const) {\n\t\tconst value = first[field];\n\t\tif (typeof value !== \"string\") fail(1, `has a \"${field}\" that is not a string`);\n\t\tconst reason = invalidText(value as string);\n\t\tif (reason !== undefined) fail(1, `has a \"${field}\" that ${reason}`);\n\t}\n\tconst runId = first.runId as string;\n\tif (runId === \"\") fail(1, 'has an empty \"runId\"');\n\tif (!counter(first.createdAt, Number.MIN_SAFE_INTEGER)) fail(1, 'has a \"createdAt\" that is not an integer', runId);\n\tif (!counter(first.events, 0)) fail(1, 'has an \"events\" count that is not a non-negative integer', runId);\n\tif (!isObject(first.header)) fail(1, 'has a \"header\" that is not an object', runId);\n\tif ((first.header as JsonObject).runId !== runId)\n\t\tfail(1, `has a \"header\" whose runId is not the run's ID ${runId}`, runId);\n\tconst events: WorkflowRunExportEvent[] = [];\n\tconst keys = new Map<string, number>();\n\tfor (let index = 1; index < lines.length; index++) {\n\t\tconst line = index + 1;\n\t\tconst event = parse(index);\n\t\tconst reason = fieldsReason(event, EVENT_FIELDS);\n\t\tif (reason !== undefined) fail(line, reason, runId);\n\t\tif (!EVENT_TYPES.has(event.type as string)) fail(line, `has unknown event type \"${event.type}\"`, runId);\n\t\tif (event.seq !== index) fail(line, `has seq ${JSON.stringify(event.seq)}; expected ${index}`, runId);\n\t\tif (!counter(event.epoch, 0)) fail(line, 'has an \"epoch\" that is not a non-negative integer', runId);\n\t\tif (!counter(event.at, Number.MIN_SAFE_INTEGER)) fail(line, 'has an \"at\" that is not an integer', runId);\n\t\tconst key = event.key;\n\t\tif (key !== null) {\n\t\t\tif (typeof key !== \"string\") fail(line, 'has a \"key\" that is neither a string nor null', runId);\n\t\t\tconst keyReason = invalidText(key as string);\n\t\t\tif (keyReason !== undefined) fail(line, `has a \"key\" that ${keyReason}`, runId);\n\t\t\tconst earlier = keys.get(key as string);\n\t\t\tif (earlier !== undefined) fail(line, `repeats the key of line ${earlier}`, runId);\n\t\t\tkeys.set(key as string, line);\n\t\t}\n\t\tif (event.type === RUN_EVENT_TYPES.statusChanged) {\n\t\t\tconst status = isObject(event.payload) ? event.payload.status : undefined;\n\t\t\tif (typeof status !== \"string\")\n\t\t\t\tfail(line, 'is a StatusChanged event whose payload has no string \"status\"', runId);\n\t\t\tconst statusReason = invalidText(status as string);\n\t\t\tif (statusReason !== undefined) fail(line, `has a status that ${statusReason}`, runId);\n\t\t}\n\t\tevents.push({\n\t\t\ttype: event.type as string,\n\t\t\tseq: event.seq as number,\n\t\t\tepoch: event.epoch as number,\n\t\t\tkey: key as string | null,\n\t\t\tat: event.at as number,\n\t\t\tpayload: event.payload!,\n\t\t});\n\t}\n\tif (lines.length - 1 !== first.events)\n\t\tfail(1, `says the run has ${first.events} events, but the file has ${lines.length - 1} event lines`, runId);\n\tconst header: WorkflowRunExportHeader = {\n\t\ttype: WORKFLOW_RUN_EXPORT_TYPE,\n\t\tversion: WORKFLOW_RUN_EXPORT_VERSION,\n\t\trunId,\n\t\tname: first.name as string,\n\t\tcwd: first.cwd as string,\n\t\tcreatedAt: first.createdAt as number,\n\t\tstatus: first.status as string,\n\t\tevents: first.events as number,\n\t\theader: first.header as JsonObject,\n\t};\n\treturn { file, header, events };\n}\n\n/** The fields import checks against a stored run: everything but string content, which a tool may redact. */\nfunction sameEntry(stored: JournalEventTableRow, exported: WorkflowRunExportEvent): boolean {\n\treturn (\n\t\tNumber(stored.seq) === exported.seq &&\n\t\tNumber(stored.epoch) === exported.epoch &&\n\t\tstored.key === exported.key &&\n\t\tstored.type === exported.type &&\n\t\tNumber(stored.at) === exported.at\n\t);\n}\n\ninterface StoredRun {\n\treadonly run: JournalRunTableRow;\n\treadonly events: readonly JournalEventTableRow[];\n\treadonly lease?: JournalLeaseTableRow & { readonly age_ms: number };\n}\n\nasync function readStoredRun(executor: SqliteExecutor, t: Tables, runId: string): Promise<StoredRun | undefined> {\n\tif (!(await hasTables(executor, t))) return undefined;\n\tconst run = await executor.get<JournalRunTableRow>(`SELECT * FROM ${t.runs} WHERE run_id = ?`, runId);\n\tif (run === undefined) return undefined;\n\tconst events = await executor.all<JournalEventTableRow>(\n\t\t`SELECT * FROM ${t.events} WHERE run_id = ? ORDER BY seq`,\n\t\trunId,\n\t);\n\tconst leases = await executor.get(`SELECT name FROM sqlite_master WHERE type = 'table' AND name = ?`, t.leases);\n\tconst lease =\n\t\tleases === undefined\n\t\t\t? undefined\n\t\t\t: await executor.get<JournalLeaseTableRow & { age_ms: number }>(\n\t\t\t\t\t`SELECT *, MAX(0, ${STORE_NOW} - renewed_at) AS age_ms FROM ${t.leases} WHERE run_id = ?`,\n\t\t\t\t\trunId,\n\t\t\t\t);\n\treturn { run, events, ...(lease === undefined ? {} : { lease }) };\n}\n\ntype ImportAction = \"add\" | \"update\" | \"unchanged\";\n\n/**\n * What importing `parsed` does to the run as `stored` holds it: add it, add the file's later events, or nothing when\n * the storage already holds every event of the file. A run whose history differs from the file's, or that a process\n * here may still be running, fails with the file and line.\n */\nfunction importAction(parsed: ParsedRun, stored: StoredRun | undefined, location: string): ImportAction {\n\tif (stored === undefined) return \"add\";\n\tconst { header, events, file } = parsed;\n\tconst fail = (line: number, reason: string): never => {\n\t\tthrow new WorkflowRunTransferError({ path: file, line, runId: header.runId, reason });\n\t};\n\tif (Number(stored.run.created_at) !== header.createdAt)\n\t\tfail(1, `run ${header.runId} in ${location} was created at another time; it is a different run with the same ID`);\n\tconst shared = Math.min(stored.events.length, events.length);\n\tfor (let index = 0; index < shared; index++)\n\t\tif (!sameEntry(stored.events[index]!, events[index]!))\n\t\t\tfail(\n\t\t\t\tindex + 2,\n\t\t\t\t`event ${index + 1} differs from event ${index + 1} of run ${header.runId} in ${location}: the run continued differently there`,\n\t\t\t);\n\tif (events.length <= stored.events.length) return \"unchanged\";\n\tconst lease = stored.lease;\n\tif (lease !== undefined && lease.holder_id !== null && Number(lease.age_ms) < WORKFLOW_RUN_IMPORT_LIVE_LEASE_MS)\n\t\tfail(\n\t\t\t1,\n\t\t\t`run ${header.runId} is held by ${lease.holder_id} in ${location}, which may still be running it; stop it and import again`,\n\t\t);\n\treturn \"update\";\n}\n\n/**\n * Writes the part of `parsed` that `stored` lacks inside the caller's transaction: the run row when it is new, the\n * events after the stored ones, the latest status, and an unheld lease at an epoch above every epoch the run's events\n * and any earlier holder used, so no holder from another machine is imported and a stale one here is fenced.\n */\nasync function applyImport(tx: SqliteExecutor, t: Tables, parsed: ParsedRun, location: string): Promise<ImportAction> {\n\tconst { header, events } = parsed;\n\tconst action = importAction(parsed, await readStoredRun(tx, t, header.runId), location);\n\tif (action === \"unchanged\") return action;\n\tif (action === \"add\")\n\t\tawait tx.run(\n\t\t\t`INSERT INTO ${t.runs}(run_id, name, cwd, created_at, status, header_json) VALUES (?, ?, ?, ?, ?, ?)`,\n\t\t\theader.runId,\n\t\t\theader.name,\n\t\t\theader.cwd,\n\t\t\theader.createdAt,\n\t\t\theader.status,\n\t\t\tJSON.stringify(header.header),\n\t\t);\n\telse await tx.run(`UPDATE ${t.runs} SET status = ? WHERE run_id = ?`, header.status, header.runId);\n\tconst stored =\n\t\taction === \"add\"\n\t\t\t? 0\n\t\t\t: Number(\n\t\t\t\t\t(await tx.get<SqliteRow & { seq: number }>(\n\t\t\t\t\t\t`SELECT COALESCE(MAX(seq), 0) AS seq FROM ${t.events} WHERE run_id = ?`,\n\t\t\t\t\t\theader.runId,\n\t\t\t\t\t))!.seq,\n\t\t\t\t);\n\tfor (const event of events.slice(stored))\n\t\tawait tx.run(\n\t\t\t`INSERT INTO ${t.events}(run_id, seq, epoch, key, type, payload, at) VALUES (?, ?, ?, ?, ?, ?, ?)`,\n\t\t\theader.runId,\n\t\t\tevent.seq,\n\t\t\tevent.epoch,\n\t\t\tevent.key,\n\t\t\tevent.type,\n\t\t\tJSON.stringify(event.payload),\n\t\t\tevent.at,\n\t\t);\n\tconst epoch = events.reduce((highest, event) => Math.max(highest, event.epoch), 0);\n\tawait tx.run(\n\t\t`INSERT INTO ${t.leases}(run_id, holder_id, epoch, renewed_at) VALUES (?, NULL, ?, ${STORE_NOW})\n\t\tON CONFLICT(run_id) DO UPDATE SET holder_id = NULL, renewed_at = excluded.renewed_at,\n\t\t\tepoch = MAX(excluded.epoch, ${t.leases}.epoch + (CASE WHEN ${t.leases}.holder_id IS NULL THEN 0 ELSE 1 END))`,\n\t\theader.runId,\n\t\tepoch,\n\t);\n\treturn action;\n}\n\n/** Reads and checks every export file in `directory`; nothing is written. */\nasync function readExportDirectory(directory: string): Promise<ParsedRun[]> {\n\tlet names: string[];\n\ttry {\n\t\tnames = await readdir(directory);\n\t} catch (error) {\n\t\tthrow new WorkflowRunTransferError({\n\t\t\tpath: directory,\n\t\t\treason: `cannot read the directory: ${(error as Error).message}`,\n\t\t\tcause: error as StorageFailureCause,\n\t\t});\n\t}\n\tconst parsed: ParsedRun[] = [];\n\tconst files = new Map<string, string>();\n\tfor (const name of names.filter((entry) => entry.endsWith(WORKFLOW_RUN_EXPORT_EXTENSION)).sort()) {\n\t\tconst file = join(directory, name);\n\t\tlet bytes: Buffer;\n\t\ttry {\n\t\t\tbytes = await readFile(file);\n\t\t} catch (error) {\n\t\t\tthrow new WorkflowRunTransferError({\n\t\t\t\tpath: file,\n\t\t\t\treason: `cannot read the file: ${(error as Error).message}`,\n\t\t\t\tcause: error as StorageFailureCause,\n\t\t\t});\n\t\t}\n\t\tconst run = parseExportFile(file, bytes);\n\t\tconst earlier = files.get(run.header.runId);\n\t\tif (earlier !== undefined)\n\t\t\tthrow new WorkflowRunTransferError({\n\t\t\t\tpath: file,\n\t\t\t\tline: 1,\n\t\t\t\trunId: run.header.runId,\n\t\t\t\treason: `run ${run.header.runId} is also in ${earlier}; keep one file per run`,\n\t\t\t});\n\t\tfiles.set(run.header.runId, file);\n\t\tparsed.push(run);\n\t}\n\treturn parsed;\n}\n\n/** A journal file an import reads its runs from while it decides what to write: read-only, opened once. */\nclass ReadOnlyFiles {\n\tprivate readonly opened = new Map<string, Promise<SqliteDatabase>>();\n\n\tread(path: string): Promise<SqliteDatabase> {\n\t\tlet database = this.opened.get(path);\n\t\tif (database === undefined) {\n\t\t\tdatabase = openNodeSqliteDatabase(path, { readOnly: true });\n\t\t\tthis.opened.set(path, database);\n\t\t}\n\t\treturn database;\n\t}\n\n\tasync close(): Promise<void> {\n\t\tconst settled = await Promise.allSettled(this.opened.values());\n\t\tawait closeEach(settled.flatMap((result) => (result.status === \"fulfilled\" ? [result.value] : [])));\n\t}\n}\n\nfunction unreadableShard(parsed: ParsedRun, path: string, error: Error): WorkflowRunTransferError {\n\treturn new WorkflowRunTransferError({\n\t\tpath: parsed.file,\n\t\tline: 1,\n\t\trunId: parsed.header.runId,\n\t\treason: `run ${parsed.header.runId} is in the journal file ${path}, which cannot be read: ${error.message}`,\n\t\tcause: error,\n\t});\n}\n\n/** The journal file of a store holding `runId`: the one the catalog names, else an adopted journal that holds it. */\nasync function storedShard(\n\tcatalog: JournalCatalog,\n\tfiles: ReadOnlyFiles,\n\tt: Tables,\n\trunId: string,\n): Promise<JournalShardRecord | undefined> {\n\tconst found = await catalog.locate(runId);\n\tif (found !== undefined) return found.shard;\n\tfor (const shard of await catalog.shards()) {\n\t\tif (shard.kind !== \"adopted\" || !existsSync(shard.path)) continue;\n\t\ttry {\n\t\t\tconst database = await files.read(shard.path);\n\t\t\tif ((await hasTables(database, t)) && (await database.get(`SELECT 1 FROM ${t.runs} WHERE run_id = ?`, runId)))\n\t\t\t\treturn shard;\n\t\t} catch {}\n\t}\n\treturn undefined;\n}\n\n/**\n * Imports every `<name>.jsonl` export file in `directory` into a local workflow journal. Every file is read and checked,\n * and every run compared with the storage's copy, before anything is written: a malformed file, an unsupported version,\n * a run that continued differently here, or a run a process here may still be running fails the import with the file\n * and line, and nothing changes. A run the storage does not hold is added; one whose earlier events it holds gets the\n * file's later ones; one it holds every event of is left as it is, so importing again changes nothing. String values\n * inside the records are not compared, so a file whose strings a tool redacted imports as the run it was exported from.\n */\nexport async function importWorkflowRuns(\n\tstorage: WorkflowRunTransferStorage,\n\tdirectory: string,\n): Promise<WorkflowRunImportReport> {\n\tconst runs = await readExportDirectory(directory);\n\tconst t = runJournalTables(storage.kind === \"sqlite\" ? storage.prefix : undefined);\n\tconst location = storageLocation(storage);\n\tconst files = new ReadOnlyFiles();\n\tconst actions: { readonly run: ParsedRun; readonly action: ImportAction; readonly shard?: JournalShardRecord }[] =\n\t\t[];\n\tawait withCleanup(\n\t\tasync () => {\n\t\t\tconst catalogExists = storage.kind === \"store\" && (await adoptLegacyJournal(storage.directory));\n\t\t\tconst catalog = catalogExists ? await JournalCatalog.open(storage.directory) : undefined;\n\t\t\tawait withCleanup(\n\t\t\t\tasync () => {\n\t\t\t\t\tfor (const run of runs) {\n\t\t\t\t\t\tconst shard =\n\t\t\t\t\t\t\tcatalog === undefined ? undefined : await storedShard(catalog, files, t, run.header.runId);\n\t\t\t\t\t\tlet path = shard?.path;\n\t\t\t\t\t\tif (storage.kind === \"sqlite\") path = existsSync(storage.path) ? storage.path : undefined;\n\t\t\t\t\t\tlet stored: StoredRun | undefined;\n\t\t\t\t\t\tif (path !== undefined) {\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tstored = await readStoredRun(await files.read(path), t, run.header.runId);\n\t\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\t\tthrow unreadableShard(run, path, error as Error);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tactions.push({\n\t\t\t\t\t\t\trun,\n\t\t\t\t\t\t\taction: importAction(run, stored, path ?? location),\n\t\t\t\t\t\t\t...(shard === undefined ? {} : { shard }),\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tasync () => catalog?.close(),\n\t\t\t);\n\t\t},\n\t\t() => files.close(),\n\t);\n\tconst report = { added: [] as string[], updated: [] as string[], unchanged: [] as string[] };\n\tconst record = (runId: string, action: ImportAction) =>\n\t\t(action === \"add\" ? report.added : action === \"update\" ? report.updated : report.unchanged).push(runId);\n\tconst pending = actions.filter(({ action, run }) => {\n\t\tif (action === \"unchanged\") record(run.header.runId, action);\n\t\treturn action !== \"unchanged\";\n\t});\n\tif (pending.length === 0) return report;\n\tif (storage.kind === \"sqlite\") {\n\t\tconst database = await openNodeSqliteDatabase(storage.path);\n\t\tawait withCleanup(\n\t\t\tasync () => {\n\t\t\t\tfor (const { run } of pending)\n\t\t\t\t\trecord(\n\t\t\t\t\t\trun.header.runId,\n\t\t\t\t\t\tawait database.transaction(async (tx) => {\n\t\t\t\t\t\t\tawait ensureRunJournalSchema(tx, storage.prefix);\n\t\t\t\t\t\t\treturn applyImport(tx, t, run, location);\n\t\t\t\t\t\t}, TRANSFER_TRANSACTION),\n\t\t\t\t\t);\n\t\t\t},\n\t\t\t() => database.close(),\n\t\t);\n\t\treturn report;\n\t}\n\tconst catalog = await JournalCatalog.open(storage.directory);\n\tconst shards = new Map<string, SqliteDatabase>();\n\tawait withCleanup(\n\t\tasync () => {\n\t\t\tfor (const { run, shard: stored } of pending) {\n\t\t\t\tconst { runId, name, cwd, status } = run.header;\n\t\t\t\t// A new run goes to the shard its ID hashes to, as a consolidated run does: it writes nothing until it is\n\t\t\t\t// resumed, so it never makes a shard busy for new roots.\n\t\t\t\tconst shard = await catalog.shard(\n\t\t\t\t\tawait catalog.index((stored ?? (await catalog.homeShard(runId))).id, { runId, name, cwd, status }),\n\t\t\t\t);\n\t\t\t\tif (shard === undefined)\n\t\t\t\t\tthrow new WorkflowRunTransferError({\n\t\t\t\t\t\tpath: run.file,\n\t\t\t\t\t\tline: 1,\n\t\t\t\t\t\trunId,\n\t\t\t\t\t\treason: `cannot place run ${runId} in ${location}`,\n\t\t\t\t\t});\n\t\t\t\tlet database = shards.get(shard.path);\n\t\t\t\tif (database === undefined) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tdatabase = await openNodeSqliteDatabase(shard.path);\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tthrow unreadableShard(run, shard.path, error as Error);\n\t\t\t\t\t}\n\t\t\t\t\tshards.set(shard.path, database);\n\t\t\t\t}\n\t\t\t\tconst action = await database.transaction(async (tx) => {\n\t\t\t\t\tawait ensureRunJournalSchema(tx);\n\t\t\t\t\treturn applyImport(tx, t, run, shard.path);\n\t\t\t\t}, TRANSFER_TRANSACTION);\n\t\t\t\tif (action !== \"unchanged\") await catalog.setStatus(runId, status);\n\t\t\t\trecord(runId, action);\n\t\t\t}\n\t\t},\n\t\tasync () => {\n\t\t\tawait closeEach(shards.values());\n\t\t\tawait catalog.close();\n\t\t},\n\t);\n\treturn report;\n}\n"]}
@@ -125,6 +125,8 @@ atomic team status [--json] # Profile i
125
125
  atomic team leave # Remove what team join wrote
126
126
  atomic storage adopt <path>... [--no-discover] # Register existing journal files in place
127
127
  atomic storage consolidate # Move finished runs of adopted files into the store
128
+ atomic storage export <dir> [--run <id>]... [--unfinished] [--limit <n>] # Write workflow runs as JSONL files
129
+ atomic storage import <dir> # Restore workflow runs from JSONL files
128
130
  atomic intercom status # This machine's Intercom broker and multi-node state
129
131
  atomic intercom restart # Replace the broker so it reads the current selection
130
132
  atomic intercom upgrade # Replace a broker an older Atomic started, when safe
@@ -138,6 +140,8 @@ atomic intercom upgrade # Replace a
138
140
 
139
141
  `atomic storage adopt` registers journal files in the workflow journal store in place, without copying them, so their runs resolve by ID and resume where they are. Each path is a journal `.sqlite` file or a directory holding `journal.sqlite`; every path is checked before the first is registered. It also adopts the journal files the adopted runs were written to, unless `--no-discover` is given. `atomic storage consolidate` moves finished runs from adopted files into the store's own shards and reports the runs it left in place with the reason, and exits `1`, printing each distinct error's message and hint, when a run was left because of an error (a missing shard file, a different copy in the destination). Both also exit `1` with the error's message and hint when they cannot proceed. See [The workflow journal store](/storage#the-workflow-journal-store).
140
142
 
143
+ `atomic storage export` writes workflow runs to `<dir>/<runId>.jsonl`, one versioned JSONL file per run, each written whole through a temporary file; `--run`, `--unfinished` and `--limit` select runs. `atomic storage import` checks every `*.jsonl` file in `<dir>` before it writes anything, then adds new runs and the later events of runs this machine has an earlier part of; importing again changes nothing. Both exit `1` with the file and line when they cannot proceed, and refuse a shared libSQL or Turso selection. See [Exporting and importing workflow runs](/storage#exporting-and-importing-workflow-runs).
144
+
141
145
  `atomic intercom restart` asks the broker to shut down (an older broker gets SIGTERM), waits for it to exit, and then for a reconnecting session to start a new broker, whose state it prints. Without connected sessions, the next session that uses Intercom starts one.
142
146
 
143
147
  `atomic intercom upgrade` replaces a broker that an older Atomic started, when that is safe. With no session connected it stops the broker, and the next session starts this version's. With sessions connected it leaves the broker running, and the next session of this version hands it over without disconnecting them for longer than a reconnect. It does nothing when no broker runs or the broker is already this version's, leaves a broker too old to report its sessions running, and exits `1` only when stopping the broker fails. The installers and `atomic update` run it after a successful install when the installed version has the command, without passing it any input. See [Upgrading Atomic with sessions running](/intercom/operations#upgrading-atomic-with-sessions-running).
package/docs/storage.md CHANGED
@@ -158,6 +158,60 @@ Each entry of `report.discovered` names the journal that referenced it and, when
158
158
 
159
159
  A `skipped` result means consolidation did not finish, not that the run stayed in its original file. When another process resumed the destination during a move, the catalog keeps that destination selected. Check the catalog's current location before comparing copies or retrying consolidation.
160
160
 
161
+ ### Exporting and importing workflow runs
162
+
163
+ `atomic storage export <dir>` writes workflow runs to versioned JSONL files, and `atomic storage import <dir>` restores them. The journal stays the working store; the files are only how runs travel between machines, for example through a cache or a persisted directory that holds only text.
164
+
165
+ ```sh
166
+ atomic storage export <dir> [--run <id>]... [--unfinished] [--limit <n>]
167
+ atomic storage import <dir>
168
+ ```
169
+
170
+ Export writes every run by default, one file per run, named `<dir>/<runId>.jsonl`. `--run` selects runs by ID (repeat it for more), `--unfinished` selects runs that are not completed, failed or cancelled, and `--limit <n>` keeps the newest `n` runs by creation time. An unknown `--run` ID fails the export before any file is written. Each journal file is read in one read transaction, and each export file is written to a temporary file in `<dir>` and renamed into place, so a crash never leaves a partial `.jsonl` file. The same run state always produces the same bytes, and a file that already holds them is not rewritten, so unchanged runs produce no diff. Export never deletes files; prune old ones yourself.
171
+
172
+ Import reads every `*.jsonl` file in `<dir>` and ignores other files, including temporary files left by an interrupted export. It checks every file, and compares every run with the copy this machine already has, before it writes anything. A malformed file, an unknown version, or a run that continued differently here fails the import with the file and line, and nothing changes. A run this machine does not have is added; a run whose earlier events it has gets the file's later events; a run it already has every event of is left unchanged. Importing the same files again therefore adds nothing, and a newer export of a run supersedes an older one. Each run is written in its own transaction: if another process changes a run on this machine after the checks pass, the import stops at that run with an error, the runs written before it stay imported, and running the import again finishes it.
173
+
174
+ After import, runs resolve by ID for status, resume, attach, fork and `history://workflows`. Leases, local-worker pool state and worktree snapshot contents are not exported. An imported run has no owner: a run that was running when it was exported is an interrupted run here, and the resume picker and `/workflow resume` offer it once it has completed at least one step. Import refuses to add events to a run that a process on this machine renewed the lease of in the last two minutes, because that run may still be running here. Stage conversations live in session storage, not in the journal; persist the sessions directory too if you need them. Resume treats a run whose working directory differs from the current one as a run from another project, so restore the checkout at the same path.
175
+
176
+ Export and import work with the journal store and with a journal file selected through `workflows.journal.path`, `ATOMIC_WORKFLOW_JOURNAL_PATH` or a `path` selection. Both respect `ATOMIC_CODING_AGENT_DIR` and the storage selection in effect for the current directory. With a shared libSQL or Turso database, both refuse with a message: every machine joined to it already reads its runs.
177
+
178
+ #### File format (version 1)
179
+
180
+ Each line is one JSON object with a string `type`. Line 1 is the run's header:
181
+
182
+ ```json
183
+ {"type":"atomic.workflow-run","version":1,"runId":"…","name":"deploy","cwd":"/repo","createdAt":1794540399185,"status":"running","events":42,"header":{"runId":"…","inputs":{}}}
184
+ ```
185
+
186
+ `status` is the run's latest status, `events` is the number of lines that follow, and `header` is the run header recorded when the run was created. Every later line is one journal event, in sequence order:
187
+
188
+ ```json
189
+ {"type":"CheckpointRecorded","seq":2,"epoch":1,"key":"[\"CheckpointRecorded\",\"tool\",\"build\"]","at":1794540401653,"payload":{"kind":"tool","output":"…"}}
190
+ ```
191
+
192
+ A tool may change string values inside `payload` and inside the header's `header` object, such as replacing secrets with `***`. Import does not checksum string contents, so a redacted file imports as the run it came from. Keep every line a JSON object, and do not add, remove or reorder lines or fields. Import checks these fields exactly and fails on a mismatch:
193
+
194
+ - Header: `type`, `version`, `runId` (also `header.runId`), `createdAt` and `events`. `name` names the workflow that resume runs, and `cwd` and `status` decide where and whether it resumes, so leave them unchanged too.
195
+ - Events: `type` (a known event type), `seq` (1, 2, 3, … without gaps), `epoch`, `key` (unique within the run) and `at`. Import compares these with the copy this machine already has to tell an older export, a newer export and a run that continued differently apart. A `StatusChanged` event must keep a string `payload.status`.
196
+
197
+ A file of a newer version is refused with the version it has and the version this Atomic reads.
198
+
199
+ #### Persisting workflow runs between machines
200
+
201
+ On a CI runner that restores a directory at the start of a job and saves it at the end:
202
+
203
+ ```sh
204
+ # Start of the job, after restoring $RUNS_DIR
205
+ mkdir -p "$RUNS_DIR" && atomic storage import "$RUNS_DIR"
206
+
207
+ # ... run Atomic ...
208
+
209
+ # End of the job, before saving $RUNS_DIR
210
+ atomic storage export "$RUNS_DIR"
211
+ ```
212
+
213
+ To carry only runs that can still be resumed, export with `--unfinished`. An interrupted run imported this way resumes with `/workflow resume <runId>` in the next job.
214
+
161
215
  ### When to select a journal
162
216
 
163
217
  Select a journal file only to isolate runs, for example in tests or a sandbox: `workflows.journal.path`, `ATOMIC_WORKFLOW_JOURNAL_PATH`, `RunOpts.journal` and `createAgentSession({ journal })` keep working as one file. You do not need separate journals for performance: the store already keeps concurrent roots apart. A shared libSQL or Turso database stays one selection; the adapter scales it.
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@bastani/atomic",
3
- "version": "0.9.82",
3
+ "version": "0.9.83",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@bastani/atomic",
9
- "version": "0.9.82",
9
+ "version": "0.9.83",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
- "@bastani/atomic-natives": "0.9.82",
13
- "@bastani/pi-ai": "0.9.82",
12
+ "@bastani/atomic-natives": "0.9.83",
13
+ "@bastani/pi-ai": "0.9.83",
14
14
  "@earendil-works/pi-agent-core": "1.5.2",
15
15
  "@earendil-works/pi-codemode": "1.5.2",
16
16
  "@earendil-works/pi-tui": "1.5.2",
@@ -427,18 +427,18 @@
427
427
  }
428
428
  },
429
429
  "node_modules/@bastani/atomic-natives": {
430
- "version": "0.9.82",
431
- "resolved": "https://registry.npmjs.org/@bastani/atomic-natives/-/atomic-natives-0.9.82.tgz",
430
+ "version": "0.9.83",
431
+ "resolved": "https://registry.npmjs.org/@bastani/atomic-natives/-/atomic-natives-0.9.83.tgz",
432
432
  "license": "MIT",
433
433
  "optionalDependencies": {
434
- "@bastani/atomic-natives-darwin-arm64": "0.9.82",
435
- "@bastani/atomic-natives-darwin-x64": "0.9.82",
436
- "@bastani/atomic-natives-linux-arm64-gnu": "0.9.82",
437
- "@bastani/atomic-natives-linux-arm64-musl": "0.9.82",
438
- "@bastani/atomic-natives-linux-x64-gnu": "0.9.82",
439
- "@bastani/atomic-natives-linux-x64-musl": "0.9.82",
440
- "@bastani/atomic-natives-win32-arm64-msvc": "0.9.82",
441
- "@bastani/atomic-natives-win32-x64-msvc": "0.9.82"
434
+ "@bastani/atomic-natives-darwin-arm64": "0.9.83",
435
+ "@bastani/atomic-natives-darwin-x64": "0.9.83",
436
+ "@bastani/atomic-natives-linux-arm64-gnu": "0.9.83",
437
+ "@bastani/atomic-natives-linux-arm64-musl": "0.9.83",
438
+ "@bastani/atomic-natives-linux-x64-gnu": "0.9.83",
439
+ "@bastani/atomic-natives-linux-x64-musl": "0.9.83",
440
+ "@bastani/atomic-natives-win32-arm64-msvc": "0.9.83",
441
+ "@bastani/atomic-natives-win32-x64-msvc": "0.9.83"
442
442
  },
443
443
  "engines": {
444
444
  "bun": ">=1.4.2",
@@ -446,8 +446,8 @@
446
446
  }
447
447
  },
448
448
  "node_modules/@bastani/atomic-natives-darwin-arm64": {
449
- "version": "0.9.82",
450
- "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-darwin-arm64/-/atomic-natives-darwin-arm64-0.9.82.tgz",
449
+ "version": "0.9.83",
450
+ "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-darwin-arm64/-/atomic-natives-darwin-arm64-0.9.83.tgz",
451
451
  "license": "MIT",
452
452
  "os": [
453
453
  "darwin"
@@ -458,8 +458,8 @@
458
458
  "optional": true
459
459
  },
460
460
  "node_modules/@bastani/atomic-natives-darwin-x64": {
461
- "version": "0.9.82",
462
- "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-darwin-x64/-/atomic-natives-darwin-x64-0.9.82.tgz",
461
+ "version": "0.9.83",
462
+ "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-darwin-x64/-/atomic-natives-darwin-x64-0.9.83.tgz",
463
463
  "license": "MIT",
464
464
  "os": [
465
465
  "darwin"
@@ -470,8 +470,8 @@
470
470
  "optional": true
471
471
  },
472
472
  "node_modules/@bastani/atomic-natives-linux-arm64-gnu": {
473
- "version": "0.9.82",
474
- "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-linux-arm64-gnu/-/atomic-natives-linux-arm64-gnu-0.9.82.tgz",
473
+ "version": "0.9.83",
474
+ "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-linux-arm64-gnu/-/atomic-natives-linux-arm64-gnu-0.9.83.tgz",
475
475
  "license": "MIT",
476
476
  "os": [
477
477
  "linux"
@@ -485,8 +485,8 @@
485
485
  "optional": true
486
486
  },
487
487
  "node_modules/@bastani/atomic-natives-linux-arm64-musl": {
488
- "version": "0.9.82",
489
- "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-linux-arm64-musl/-/atomic-natives-linux-arm64-musl-0.9.82.tgz",
488
+ "version": "0.9.83",
489
+ "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-linux-arm64-musl/-/atomic-natives-linux-arm64-musl-0.9.83.tgz",
490
490
  "license": "MIT",
491
491
  "os": [
492
492
  "linux"
@@ -500,8 +500,8 @@
500
500
  "optional": true
501
501
  },
502
502
  "node_modules/@bastani/atomic-natives-linux-x64-gnu": {
503
- "version": "0.9.82",
504
- "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-linux-x64-gnu/-/atomic-natives-linux-x64-gnu-0.9.82.tgz",
503
+ "version": "0.9.83",
504
+ "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-linux-x64-gnu/-/atomic-natives-linux-x64-gnu-0.9.83.tgz",
505
505
  "license": "MIT",
506
506
  "os": [
507
507
  "linux"
@@ -515,8 +515,8 @@
515
515
  "optional": true
516
516
  },
517
517
  "node_modules/@bastani/atomic-natives-linux-x64-musl": {
518
- "version": "0.9.82",
519
- "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-linux-x64-musl/-/atomic-natives-linux-x64-musl-0.9.82.tgz",
518
+ "version": "0.9.83",
519
+ "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-linux-x64-musl/-/atomic-natives-linux-x64-musl-0.9.83.tgz",
520
520
  "license": "MIT",
521
521
  "os": [
522
522
  "linux"
@@ -530,8 +530,8 @@
530
530
  "optional": true
531
531
  },
532
532
  "node_modules/@bastani/atomic-natives-win32-arm64-msvc": {
533
- "version": "0.9.82",
534
- "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-win32-arm64-msvc/-/atomic-natives-win32-arm64-msvc-0.9.82.tgz",
533
+ "version": "0.9.83",
534
+ "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-win32-arm64-msvc/-/atomic-natives-win32-arm64-msvc-0.9.83.tgz",
535
535
  "license": "MIT",
536
536
  "os": [
537
537
  "win32"
@@ -542,8 +542,8 @@
542
542
  "optional": true
543
543
  },
544
544
  "node_modules/@bastani/atomic-natives-win32-x64-msvc": {
545
- "version": "0.9.82",
546
- "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-win32-x64-msvc/-/atomic-natives-win32-x64-msvc-0.9.82.tgz",
545
+ "version": "0.9.83",
546
+ "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-win32-x64-msvc/-/atomic-natives-win32-x64-msvc-0.9.83.tgz",
547
547
  "license": "MIT",
548
548
  "os": [
549
549
  "win32"
@@ -554,8 +554,8 @@
554
554
  "optional": true
555
555
  },
556
556
  "node_modules/@bastani/pi-ai": {
557
- "version": "0.9.82",
558
- "resolved": "https://registry.npmjs.org/@bastani/pi-ai/-/pi-ai-0.9.82.tgz",
557
+ "version": "0.9.83",
558
+ "resolved": "https://registry.npmjs.org/@bastani/pi-ai/-/pi-ai-0.9.83.tgz",
559
559
  "license": "MIT",
560
560
  "dependencies": {
561
561
  "@anthropic-ai/sdk": "0.129.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bastani/atomic",
3
- "version": "0.9.82",
3
+ "version": "0.9.83",
4
4
  "description": "Atomic coding agent CLI with read, bash, edit, write tools and session management",
5
5
  "type": "module",
6
6
  "atomicConfig": {
@@ -89,8 +89,8 @@
89
89
  "prepublishOnly": "bun run clean && bun run build && bun run shrinkwrap"
90
90
  },
91
91
  "dependencies": {
92
- "@bastani/atomic-natives": "0.9.82",
93
- "@bastani/pi-ai": "0.9.82",
92
+ "@bastani/atomic-natives": "0.9.83",
93
+ "@bastani/pi-ai": "0.9.83",
94
94
  "@earendil-works/pi-agent-core": "1.5.2",
95
95
  "@earendil-works/pi-codemode": "1.5.2",
96
96
  "@earendil-works/pi-tui": "1.5.2",