/** * The auto-resume supervisor: a tiny parent that runs `farketari implement` * as a child process and restarts it — resuming through the journal — until * the feature genuinely completes or hits a stop only a human can resolve. * * Why a separate process, not an in-process retry loop: the failure this * defends against is the WHOLE run dying — an out-of-memory SIGKILL, the * machine sleeping, the terminal closing. Those kill the process outright; * no in-process handler survives them. A supervisor that does almost nothing * (spawn a child, wait, respawn) stays memory-tiny and outlives them, and * because each restart resumes the persisted plan + checkpoint it makes * monotonic progress instead of restarting from zero. * * The child's exit CODE is the whole protocol: * 0 the run completed the feature → done * 2 RunStopped: a decision only a human can make (a spec/contract gap) * → stop; retrying would loop * other / killed-by-signal (code null) → crash or external kill * → resume, up to a cap */ export type SupervisorAction = "done" | "stop-spec" | "retry" | "give-up"; /** * Decide what to do after a supervised child exited with `code` (null when it * was killed by a signal — SIGKILL/OOM/terminated). Pure, so the protocol is * unit-tested without spawning anything. */ export declare function supervisorDecision(code: number | null, restartsSoFar: number, maxRestarts: number): SupervisorAction; export interface SupervisorOptions { /** The farketari CLI entry to spawn (process.argv[1]). */ cliPath: string; /** The child's argv AFTER the entry — e.g. ["implement", "f.feature", "--tdd"]. * Must NOT include the supervisor's own flags (--until-done / --max-restarts). */ args: string[]; maxRestarts: number; backoffMs: number; log: (message: string) => void; /** Injected in tests; defaults to spawning a real child with inherited stdio. */ runOnce?: (cliPath: string, args: string[]) => Promise; /** Injected in tests; defaults to a real timer. */ wait?: (ms: number) => Promise; } /** * Run the child to completion, resuming on every non-spec, non-clean exit. * Returns the process exit code the supervisor itself should exit with. */ export declare function superviseUntilDone(opts: SupervisorOptions): Promise;