/** * Schema for persisted Hari Seldon state * * Defines the structure of state that is saved to disk and survives * server restarts. All state is stored in .hari-seldon/state.json. */ /** * Persisted state for a task execution. */ export interface PersistedTaskState { /** Claude Code task ID */ taskId: string; /** Agent role used for execution */ role: string; /** Current execution status */ status: 'pending' | 'running' | 'completed' | 'failed'; /** Associated worktree ID (if using worktree isolation) */ worktreeId?: string; /** Task creation timestamp */ createdAt: number; /** Last update timestamp */ updatedAt: number; /** Error message on failure */ error?: string; } /** * Persisted state for a git worktree. */ export interface PersistedWorktreeState { /** Unique worktree identifier */ id: string; /** Filesystem path to the worktree */ path: string; /** Branch name in the worktree */ branch: string; /** Base branch the worktree was created from */ baseBranch: string; /** Current worktree status */ status: 'available' | 'assigned' | 'active' | 'completing' | 'conflict' | 'stale'; /** Associated task ID (if assigned) */ taskId?: string; /** Agent ID using this worktree */ agentId?: string; /** Worktree creation timestamp */ createdAt: number; /** Last activity timestamp */ lastActivityAt: number; } /** * Persisted state for a merge conflict. */ export interface PersistedConflictState { /** Task ID that encountered the conflict */ taskId: string; /** Worktree ID where conflict occurred */ worktreeId: string; /** List of conflicted file paths */ files: string[]; /** Whether the conflict has been resolved */ resolved: boolean; /** Resolution strategy used (if resolved) */ strategy?: string; /** Conflict detection timestamp */ detectedAt: number; /** Resolution timestamp (if resolved) */ resolvedAt?: number; } /** * Persisted state for a multi-step pipeline. */ export interface PersistedPipelineState { /** Unique pipeline execution ID */ pipelineId: string; /** Pipeline name */ name: string; /** Current pipeline status */ status: 'pending' | 'running' | 'completed' | 'failed'; /** List of completed step names */ completedSteps: string[]; /** Mapping from step name to worktree ID */ stepWorktrees: Record; /** Pipeline creation timestamp */ createdAt: number; /** Last update timestamp */ updatedAt: number; } /** * Persisted health state for a provider. */ export interface PersistedProviderHealth { /** Provider name */ provider: string; /** Current health status */ status: 'healthy' | 'degraded' | 'unhealthy'; /** Number of consecutive failures */ consecutiveFailures: number; /** Cooldown end timestamp (null if not in cooldown) */ cooldownUntil: number | null; /** Rolling average latency in ms */ latencyMs: number; /** Total successful requests */ successCount: number; /** Total failed requests */ failureCount: number; /** Last successful request timestamp */ lastSuccessAt: number | null; /** Last error timestamp */ lastErrorAt: number | null; /** Last error message */ lastErrorMessage: string | null; /** Last error HTTP status code */ lastErrorCode: number | null; } /** * Persisted failover event for diagnostics. */ export interface PersistedFailoverEvent { /** Event timestamp */ timestamp: number; /** Role that triggered the failover */ role: string; /** Provider that failed */ fromProvider: string; /** Provider switched to */ toProvider: string; /** Reason for failover */ reason: string; /** HTTP error code if applicable */ errorCode?: number; /** Error message */ errorMessage?: string; } /** * Root persisted state structure. * This is the complete state saved to .hari-seldon/state.json. */ export interface PersistedState { /** State schema version for migrations */ version: string; /** Timestamp of last save */ lastSavedAt: number; /** SHA-256 checksum (first 16 chars) for corruption detection */ checksum?: string; /** All persisted tasks */ tasks: PersistedTaskState[]; /** All persisted worktrees */ worktrees: PersistedWorktreeState[]; /** All persisted conflicts */ conflicts: PersistedConflictState[]; /** All persisted pipelines */ pipelines: PersistedPipelineState[]; /** Provider health states */ providerHealth?: PersistedProviderHealth[]; /** Recent failover events (last 100) */ failoverEvents?: PersistedFailoverEvent[]; } /** * Current state schema version. * Increment when making breaking changes to the schema. */ export declare const CURRENT_STATE_VERSION = "1.0.0"; /** * Create an empty state object with default values. */ export declare function createEmptyState(): PersistedState; //# sourceMappingURL=state-schema.d.ts.map