@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
42 lines • 3.02 kB
TypeScript
/**
* The registry's path claims: the in-process reservation set and the cross-generation claim
* (`host-reservations.ts`) follow whatever file each entry's runtime is actually writing.
*/
import { type SessionPathReservations } from "./host-reservations.ts";
import { type RpcSessionEntry } from "./session-registry-types.ts";
/** Opens between their in-process reservation and their entry, by path: their cross-generation claim is in flight. */
export type PendingClaims = Map<string, Promise<void>>;
/**
* Marks `sessionPath` as mid-claim. The returned settle is called once the open has either recorded
* its entry or given the reservation back, so a waiter that wakes always finds one or the other.
*/
export declare function beginPendingClaim(pending: PendingClaims, sessionPath: string): () => void;
/**
* Takes the cross-generation claim for an open that already holds the in-process reservation, and
* returns the settle `beginPendingClaim` handed out: the caller settles it once its entry is recorded.
* A live claim another generation holds gives the reservation back and refuses with the owner.
*/
export declare function takeCrossGenerationClaim(reservations: Set<string>, pending: PendingClaims, pathReservations: SessionPathReservations, sessionPath: string): Promise<() => void>;
/**
* Waits out another open of this path that is still taking its claim (senpi#3485). Without the wait
* the path looked reserved by no session at all and a reopen was refused for a session about to be
* served. Bounded by the close grace window: a claim that never settles (a wedged daemon directory)
* ends this open with a retryable `session_path_in_use { reason: "claim_in_progress" }`.
*/
export declare function settlePendingClaim(pending: ReadonlyMap<string, Promise<void>>, sessionPath: string, graceMs: number): Promise<void>;
/** Reconcile path and durable identity after runtime replacement. */
export declare function syncRuntimeMetadata(entries: Iterable<RpcSessionEntry>, reservations: Set<string>, pathReservations: SessionPathReservations | undefined): void;
/**
* Waits out a teardown already in flight for this path before the open decides.
*
* A close FREES the path, but the entry keeps its reservation until its runtime is
* disposed, so an open landing inside that window used to be refused with
* `session_path_in_use` for a session that no longer exists - making "reopen the
* path I just closed" a race against disposal latency, which no client can time.
* The open now waits for the teardown it would have been refused by and then opens
* the file fresh. Bounded by the same grace window that bounds the teardown itself
* (`closeMarkedSession` force-releases at that deadline), so a wedged disposal
* still ends in the ordinary refusal instead of an open that never answers.
*/
export declare function settleClosingReservation(entries: Iterable<RpcSessionEntry>, sessionPath: string, closeGraceMs: number): Promise<void>;
//# sourceMappingURL=session-registry-claims.d.ts.map