export interface RuntimeRecord { runId: string; revision: number; } export interface RuntimeStore { readonly queryScope?: string; readProjection?(runId: string): Promise; prepareCompareAndSwap?(runId: string, expectedRevision: number | null, next: T): () => Promise; read(runId: string): Promise; compareAndSwap(runId: string, expectedRevision: number | null, next: T): Promise; /** * 调用者先验证 checkpoint、owner、workspace 和 application,再导入已确认的恢复基线。 * 仅接受缺失 Run,或除 revision 外 JSON 内容完全相同的 revision-1 初始导入。 * 不覆盖活跃或更新的 Run,不伪造丢失历史;普通 compareAndSwap 仍只能增加一个 revision。 */ restoreCheckpoint?(runId: string, expectedRevision: null | 1, checkpoint: T): Promise; } /** 一个 Run 的存储位置(格式标记、当前目录、历史目录);新修订与归档都会改动其中之一,供只读缓存判断是否过期。 */ export declare function fileRuntimeStoreRunPaths(rootDir: string, runId: string): string[]; /** 只读核对当前 Run 的写锁,不加载工作流或执行存储恢复。 */ export declare function inspectFileRuntimeStoreLock(options: Pick, runId: string): Promise<{ file: string; path: string; status: "missing" | "active" | "stale" | "unknown" | "malformed"; owner: import("../../platform/fs/recoverable-file-lock.js").RecoverableFileLockOwner | null; token: string | null; coordinator?: Array<{ file: string; status: "active" | "unknown" | "malformed"; owner: import("../../platform/fs/recoverable-file-lock.js").RecoverableFileLockOwner | null; token: string; }>; }>; export declare function repairFileRuntimeStoreLock(options: Pick, runId: string, token: string, confirmedOwnerStopped?: boolean): Promise<"changed" | "removed" | "missing" | "blocked">; export declare function createMemoryRuntimeStore(): RuntimeStore; export type FileRuntimeStoreDisposition = 'active' | 'closing' | 'closed' | 'reopening' | 'missing'; /** 文件存储的显式历史生命周期;业务终态与资源清理由调用方先验证。 */ export interface FileRuntimeStore extends RuntimeStore { /** * 将固定 expectedRevision 的 checkpoint 封存到历史分区,不改变记录内容或 revision。 * 调用方须先确认业务已结束、所有执行及子任务已停止,且必要清理已完成。 * 此操作只管理存储布局,不取消进程、不执行业务清理;版本失配返回 false。 */ closeRun(runId: string, expectedRevision: number): Promise; /** * 将固定 expectedRevision 的历史 checkpoint 恢复到可写分区,版本失配返回 false。 * 此操作不启动执行或批准业务重试;调用方仍须完成 owner、恢复资格和 Runtime 校验。 */ reopenRun(runId: string, expectedRevision: number): Promise; readDisposition(runId: string): Promise; /** 仅校验布局/小型事务标记,不校验历史正文;未知和冲突抛错。 */ readPartitionMetadata(runId: string): Promise; /** 仅完成持久化的布局事务,不增加 revision 或执行业务。 */ settleRun(runId: string): Promise; } export interface FileRuntimeStoreOptions { rootDir: string; writerProtocol?: 'application-holder-v1'; /** 调用方保证同一工作区由一个 controller 串行提交;保留 revision 校验和原子发布,不获取写锁。 */ singleWriter?: true; /** 与顶层 revision 镜像的嵌套字段,例如固定应用记录的 run.revision。读取和写入都必须一致。 */ mirroredRevisionPaths?: readonly 'run.revision'[]; } /** * 默认使用跨进程锁串行 CAS;singleWriter 调用方自行串行提交。完整 checkpoint 始终原子发布。 * 旧版本历史只在写入时迁移:先验证、发布新 authority 和格式标记,再清理已覆盖文件。 * 不使用增量日志;checkpoint 内的业务历史仍由调用者维护。 */ export declare function createFileRuntimeStore(options: FileRuntimeStoreOptions): FileRuntimeStore; //# sourceMappingURL=runtime-store.d.ts.map