UNPKG

@code-yeongyu/senpi

Version:

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

119 lines • 8.1 kB
import type { TranscriptRoot } from "./accepted-transcript.ts"; import type { RouteRetirement } from "./route-retire-reasons.ts"; import type { FrozenCheckpoint } from "./compact-recovery-checkpoint-types.ts"; export type { FrozenCheckpoint, RetainedRoot } from "./compact-recovery-checkpoint-types.ts"; import { type CheckpointToken, type RecoveryCaller, type RecoveryCounters, type RecoveryOutcome, type RecoveryAdmission, type RecoveryStreamState, type RecoveryToken } from "./compact-recovery-types.ts"; import type { SessionAcceptanceLane } from "./session-acceptance-lane.ts"; /** An admission's route; its session epoch and generation come from the lane and the stream at the freeze. */ export type RecoveryRoute = Omit<RecoveryAdmission, "sessionEpoch" | "generation">; /** * The checkpoint tokens of one host (S08a/S08b, R3.C1.2-C1.5). A freeze pins one complete accepted root in one * synchronous step and mints a token naming the cut's accepted identities as the next generation of its stream; * nothing is published when the root is incomplete. Issuing a generation invalidates the stream's previous token * at once and reclaims its root as soon as the operations in flight on it unwind, whether or not its holder ever * releases it. Every lookup validates the caller, the token and the cut before I/O and after every await. */ export declare class RecoveryCheckpoints { private readonly checkpoints; /** Every token minted here, with the admission it was minted for; a holder's copy or a forgery is not in it. */ private readonly issued; private readonly streams; private readonly manifests; private readonly refusals; private readonly unavailable; private readonly ended; private minted; private frozen; private reclaimed; get open(): number; tokens(): readonly CheckpointToken[]; /** The stream a caller's admissions share, as a bounded description; undefined once its peer or session ended. */ stream(caller: RecoveryCaller): RecoveryStreamState | undefined; /** Whether any stream of this peer incarnation still routes the admission: one indexed lookup (#5274). */ routesAdmission(socketEpoch: string, admissionId: string): boolean; /** Runs once per token when its lease ends, however it ended (a release, a reclaim, its peer's end). */ onTokenEnd(listener: (tokenId: string) => void): void; status(): RecoveryCounters; /** The next generation of the route's stream: a failed freeze advances nothing and pins nothing. */ freeze(route: RecoveryRoute, lane: SessionAcceptanceLane, join?: boolean): RecoveryOutcome<FrozenCheckpoint>; /** Idempotent, and never another token's: the root goes once this token's last operation unwinds. */ release(token: RecoveryToken): void; /** * A peer incarnation is gone: its streams end and every checkpoint it froze is reclaimed whether or not its * holder ever releases it (RULING-50 (2)); an operation still in flight on one is refused as `peer_gone` and * its root goes once that operation unwinds. */ forgetPeer(socketEpoch: string): void; /** * The routing session ended for good (RULING-56 (2)): its stream records go on every peer, since a sealed handle is * never re-attached. Its tokens keep their lifetime (a queued attach view reads its root to delivery, RULING-51 * Q2 A); live access to one is refused as `session_closed`, read from its retired lane. */ forgetSession(sessionId: string): void; /** * An admission ended (a detach today; S14 extends this): its route leaves the stream, the counter stays, and the * token it minted is reclaimed like a superseded one (RULING-56 (4)), with or without its stream record. Idempotent. * `_retirement` is RULING-119's compile-time proof: a client action, or a `RouteAnnouncement` already emitted. */ retireRoute(caller: RecoveryCaller, admissionId: string, _retirement: RouteRetirement): void; /** * The caller's claim on a token it named by id, before any request state is touched: a token superseded while an * operation still holds it answers `superseded_token` with the newer generation (RULING-70 (3), RULING-50 (2)). */ check(token: RecoveryToken, caller: RecoveryCaller): RecoveryOutcome<RecoveryToken>; /** The pinned transcript root (version, leaf, accepted ids, base identity); its bytes are read by S11's page route. */ transcript(token: RecoveryToken, caller: RecoveryCaller): RecoveryOutcome<TranscriptRoot>; readSettled(token: RecoveryToken, caller: RecoveryCaller): Promise<RecoveryOutcome<{ settledMessages: (Omit<import("./compact-settled-rows.ts").TerminalRow, "call" | "kind" | "payload"> & { terminal: unknown; correlation: unknown; call?: import("./compact-call-model.ts").CallProjection; })[]; owners: import("./compact-settled-rows.ts").OwnerRow[]; }>>; readCurrent(token: RecoveryToken, caller: RecoveryCaller): Promise<RecoveryOutcome<{ sequence: number; messages: import("./compact-text-view.ts").CompactMessageView[]; }>>; readComponents(token: RecoveryToken, caller: RecoveryCaller): Promise<RecoveryOutcome<{ runState: import("./compact-current-components.ts").CompactRunState; lifecycle: unknown; dialogs: import("./compact-current-components.ts").CompactDialog[]; dialogCounts: { readonly broadcast: number; readonly targeted: number; }; }>>; readActive(token: RecoveryToken, caller: RecoveryCaller): Promise<RecoveryOutcome<import("./compact-state-view.ts").ActiveMessageView[]>>; readCalls(token: RecoveryToken, caller: RecoveryCaller): Promise<RecoveryOutcome<import("./compact-call-view.ts").CallsView>>; /** The bounded manifest of the cut (S09, R4.B1): built once per token from its pinned root, never a component list. */ catalog(token: RecoveryToken, caller: RecoveryCaller): Promise<RecoveryOutcome<import("./compact-recovery-manifest-shape.ts").RecoveryManifest>>; /** One catalog node or component under the token, verified against its parent's digest before it is decoded. */ readCatalog(token: RecoveryToken, caller: RecoveryCaller, ref: string): Promise<RecoveryOutcome<import("./compact-recovery-catalog.ts").CatalogRead>>; /** * One bounded page (at most `FRAGMENT_MAX_BYTES` raw bytes) of a catalog component at a raw byte offset, under the * same claim and lease as every read (S11a; the cursor, ordinal and request limits around it are S11b). `signal` is * the request's budget: a first open's verification is charged to it and stops, typed `aborted`, when it aborts. */ readCatalogPage(token: RecoveryToken, caller: RecoveryCaller, ref: string, offset: number, signal?: AbortSignal): Promise<RecoveryOutcome<import("./compact-recovery-bytes.ts").RecoveryPage>>; /** Components verified under the live frozen roots (RULING-69 (2)); a root's entries go with its lease. */ get verifiedComponents(): number; private read; /** * Invalidates a token the owner retires (superseded, replaced, route retired, or its peer gone): the root goes after * its in-flight operations. Counted only when this is what released it, never after its holder's own release. */ private reclaim; /** * Only a token minted here for the asking peer + session is looked at (RULING-56 (1)): anything else is * `unknown_token` with no state. A retired one is then described by the asker's own stream before any I/O. */ private claim; /** Why a once-valid token no longer names a readable cut (`compact-recovery-staleness.ts`). */ private staleness; /** A refused operation names the cut's staleness first; a store that could not serve it is storage_unavailable. */ private refused; /** Every typed failure leaves through here, counted by its reason; a storage refusal also by its detail. */ private refuse; } //# sourceMappingURL=compact-recovery-state.d.ts.map