import type { DispatchTask, TaskEventState } from "../types.ts"; export type { SerializedDispatchTask } from "./task-serialization.ts"; /** * File-based persistence for DispatchManager task state. * * Writes are asynchronous (fs.promises.writeFile) with a serialization lock * to prevent concurrent writes from corrupting the state file. Uses atomic * write pattern (.tmp + renameSync) to prevent file corruption from partial writes. * * Multi-instance isolation: each workspace directory gets its own state file * keyed by a 12-character sha256 hash of the directory path. */ export declare class TaskStateStore { private directory; private dirHash; private _saveLock; private _lockState?; private _readOnly; constructor(directory: string); tryLock(): boolean; /** Release lock if held. */ unlock(): void; /** Is this store in read-only degraded mode? */ get readOnly(): boolean; /** * Persist the current task map to disk asynchronously. * Uses atomic write: write to .tmp, unlink existing, rename. * Never throws — logs a warning on failure and degrades gracefully. * * Serialization lock ensures only one write is in-flight at a time; * concurrent callers queue up behind the previous save. */ save(tasks: Map, outbox?: Set, eventState?: Map): Promise; private _doSave; /** * Load task state from disk. * * Returns null (clean start) in these cases: * - File does not exist (ENOENT) — first run * - File is corrupt JSON — logged as warning * - File has unexpected schema version — logged as warning * * On success, returns tasks map with ISO strings deserialized to Dates, * plus the outbox string array (empty for v1-v3 or when absent). */ load(): { tasks: Map; outbox: string[]; eventState: Map; } | null; /** * Delete the state file from disk. * No-op if the file does not exist. Never throws. */ clear(): void; /** * Synchronous version of save() for crash-safe persistence. * Mirrors the atomic write pattern from _doSave but fully synchronous. * * On process exit, this is last-writer-wins versus any in-flight async save(), * which is the desired behavior (exit state is authoritative). * Never throws — wraps errors in try/catch and logs a warning. */ saveSync(tasks: Map, outbox?: Set, eventState?: Map): void; private getStatePath; /** Convert a live task map to a JSON string. */ private serialize; /** * Check whether the persisted state file contains eventState data. * Returns true when the on-disk file has a non-empty `eventState` key. * Safe to call even when no file exists (returns false). */ hasEventState(): boolean; /** Parse a JSON string back into a DispatchStateFile. Returns null on parse error. */ private deserialize; } //# sourceMappingURL=task-store.d.ts.map