UNPKG

@code-yeongyu/senpi

Version:

Coding agent CLI with read, bash, edit, write tools and session management

70 lines • 4.87 kB
import type { MoveRecord } from "./move-record.ts"; /** * How old a commit stamp with no landed file must be before it is settled as failed (senpi#6417). A commit holds its * record's lock from its stamp to its rename, so a stamp with no file, read under that lock, was left by a commit that * failed, died, or stalled until its lock went stale and was taken over. Only a stalled one can still rename, when it * runs again; this gives it three stale bounds to land its file or to learn that its lock is gone. */ export declare const COMMIT_SETTLE_AFTER_MS: number; /** The clocks a record is stamped and aged with. Tests replace them; nothing else does. */ export interface StampClockOptions { /** The wall clock, in ms. It can be stepped, in either direction. */ readonly now?: () => number; /** Ms since this machine started: one clock for every process on it, which a wall-clock step does not move. */ readonly uptime?: () => number; /** The machine `uptime` belongs to. */ readonly host?: string; } export type StampClock = Required<StampClockOptions>; export declare function stampClock(options?: StampClockOptions): StampClock; /** What a record carries beside its `at`, so a reader on the same machine can age it without the wall clock. */ export declare function stampFields(clock: StampClock): { readonly up: number; readonly host: string; }; /** * The age a commit stamp is settled by. The wall clock alone misjudges it after a step: stepped forward, a healthy * commit's stamp reads old at once and is settled failed while that commit can still land its file. So a stamp is old * only when both clocks say so: while the machine's uptime calls it young that age is the answer, and otherwise the * wall clock's is (negative after a step back, which `settledLanding` counts as old). Erring young only delays the * settling of a commit that died, and by at most the bound of whichever clock is wrong. */ export declare function stampAge(value: unknown, clock: StampClock): number | undefined; /** Whether a stored record is still the commit stamp that was written at `stamp`. */ export declare function isCommitStamp(value: unknown, stamp: string): boolean; /** What the session file at a move's landing target records for the move. */ export type LandingOutcome = "absent" | "moved_in" | "revoked"; /** The hidden part of a move record: where the move lands, and whether its commit began. Never part of an answer. */ export interface Landing { readonly target?: string; /** * The folder this move was readied for and lands in, resolved as the import resolves its `cwd` (senpi#6435). * Whoever readies the move writes it: the target's `prepare` once it checked that folder's repository, or an * import that readies the move itself, with its own folder. From then on the move lands only there. */ readonly cwd?: string; readonly committing?: true; } export declare function parseLanding(value: unknown): Landing; /** What a write keeps of a landing: where the move lands and the folder it was readied for, never the commit stamp. */ export declare function settledAt(landing: Landing, target: string): Landing; /** * The one spelling a move's folder is kept and compared in (senpi#6435): resolved as the import resolves its `cwd`, * so a trailing slash, a `.` or `..` segment or a doubled slash still names the same folder at every step. */ export declare function moveFolder(cwd: string | undefined): string | undefined; /** Why a move readied for one folder refuses another: it lands only where its repository was checked (senpi#6435). */ export declare function heldElsewhere(landing: Landing): string; /** * What a record becomes once the file at its target settles a step a crash interrupted: a committing record is * accepted (revoked if the file is) when its file landed and failed when it did not, and an accepted record whose file * is sealed gains its revoke mark. `undefined` when the record already agrees with the file, and while a commit stamp * with no file is younger than `COMMIT_SETTLE_AFTER_MS` (`stampAge`). A stamp with no known age counts as old, and so * does one dated after now: the clock stepped back since it was written, and its age would stay negative, and the * move unsettled, for as long as the step. */ export declare function settledLanding(record: MoveRecord | undefined, committing: boolean, outcome: LandingOutcome, stampAge?: number): MoveRecord | undefined; /** Whether an import into `target` may proceed: only a receiving move whose commit has not begun, into its target. */ export declare function landsAt(record: MoveRecord | undefined, landing: Landing, target: string): boolean; export declare function landedElsewhere(record: MoveRecord | undefined, landing: Landing): string | undefined; //# sourceMappingURL=move-landing.d.ts.map