/** * Todo-level lead-dev plan persistence — spawn gate survives beyond 4h mtime * while outstanding todos remain. SSOT for plan todo status sync. */ import type { LeadDevPlan, LeadDevTodo } from './autonomy-kernel.js'; export interface PersistedLeadDevPlan extends LeadDevPlan { persistedAt?: string; sessionId?: string; planGeneration?: number; } export interface SpawnTodoValidation { valid: boolean; reason?: string; gate?: string; hint?: Record; expectedTodoId?: string | null; } export declare const DEFAULT_PLAN_STALE_MS: number; export declare const DEFAULT_PLAN_ARCHIVE_MARKER_MS: number; export declare function leadDevPlanStatePath(projectRoot?: string): string; export declare function loadLeadDevPlanStaleMs(projectRoot?: string): number; export declare function loadLeadDevPlanArchiveMarkerMs(projectRoot?: string): number; /** * Mandatory synthesis consults (s.1–s.3) must stay spawnable until complete — * never treat an active realignment plan as stale while consult todos remain. */ export declare function isProtectedSynthesisRealignmentPlan(plan: PersistedLeadDevPlan): boolean; /** * Stale when every outstanding todo is still pending and plan age exceeds TTL. * In-progress or completed todos imply active work — plan stays valid. */ export declare function isLeadDevPlanStale(plan: PersistedLeadDevPlan, projectRoot?: string): boolean; export declare function archiveStaleLeadDevPlan(projectRoot?: string): { archived: boolean; archivePath?: string; reason?: string; }; /** Recent stale archival — keeps spawn-plan-stale gate after session-start cleanup. */ export declare function findRecentStalePlanArchive(projectRoot?: string, maxAgeMs?: number): { archivePath: string; archivedAt: string; } | null; export declare function loadPersistedLeadDevPlan(projectRoot?: string): PersistedLeadDevPlan | null; export declare function savePersistedLeadDevPlan(plan: PersistedLeadDevPlan, projectRoot?: string): string; export declare function allPlanTodos(plan: PersistedLeadDevPlan): LeadDevTodo[]; export declare function getOutstandingTodos(plan: PersistedLeadDevPlan): LeadDevTodo[]; /** First outstanding todo in phase order */ export declare function getNextRequiredTodo(plan: PersistedLeadDevPlan): LeadDevTodo | null; /** * Plan valid for spawn when active and either: * - outstanding todos remain (ignores 4h mtime), or * - all todos complete and persistedAt within TTL */ export declare function hasValidLeadDevPlanForSpawn(projectRoot?: string, _sessionId?: string | null): boolean; export declare function isSynthesisRealignmentPlan(plan: PersistedLeadDevPlan): boolean; export declare function getSynthesisConsultTodos(plan: PersistedLeadDevPlan): LeadDevTodo[]; export declare function areSynthesisConsultTodosComplete(plan: PersistedLeadDevPlan): boolean; export declare function updatePlanTodoStatus(todoId: string, status: LeadDevTodo['status'], projectRoot?: string, sessionId?: string | null): boolean; export declare function bindPlanToSession(sessionId: string, projectRoot?: string): PersistedLeadDevPlan | null; export interface SpawnToolInput { prompt?: string; description?: string; task?: string; subagent_type?: string; agent?: string; delegationId?: string; planTodoId?: string; } export declare function validateSpawnMatchesTodo(toolInput: SpawnToolInput, projectRoot?: string, expectedTodo?: LeadDevTodo | null, sessionId?: string | null): SpawnTodoValidation; export declare function markTodoInProgressOnSpawn(toolInput: SpawnToolInput, projectRoot?: string, sessionId?: string | null): string | null;