UNPKG

@code-yeongyu/senpi

Version:

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

144 lines • 7.46 kB
import type { RecoveryCarrier } from "../../core/session-recovery-identity.ts"; import type { TranscriptTransition } from "../../core/session-transcript-journal.ts"; import { type TranscriptRoot } from "./accepted-transcript.ts"; import type { CanonicalUnit } from "./compact-lane-transitions.ts"; import { MessageIdentities } from "./compact-message-identity.ts"; import { type SettledDiagnostic, type SettledRoot } from "./compact-settled-messages.ts"; import type { FrozenCompactState } from "./compact-state-view.ts"; import { type CompactContentStoreOptions } from "./compact-content-store.ts"; import { TransferStaging } from "./compact-transfer-staging.ts"; import { type AcceptedCorrelation } from "./session-acceptance-admission.ts"; import { AcceptedRootReads } from "./session-acceptance-reads.ts"; import { SessionGenerations } from "./compact-session-generations.ts"; /** Where one accepted recovery record sits in its runtime incarnation (R3.C1.1). */ interface AcceptedRef { readonly sessionEpoch: string; readonly sequence: number; readonly historyVersion: number; readonly messageId: string | null; readonly turnId: string | null; } export interface FrozenAcceptedRoot { readonly sessionEpoch: string; readonly sequence: number; readonly activeMessageId: string | null; readonly turnId: string | null; readonly correlation: AcceptedCorrelation | null; /** * Client correlations this epoch refused at the protocol depth limit (RULING-67 (4)): the record took its sequence * but its correlation never became the standing one, so a reader knows one is missing. */ readonly refusedCorrelations: number; readonly transcript: TranscriptRoot; readonly settled: SettledRoot; /** The compact current state at this root's sequence; absent once that component became unavailable. */ readonly current: FrozenCompactState | undefined; } /** The incarnation's transcript as its manager journaled it up to bootstrap: base, unpersisted entries, leaf. */ export interface SessionBootstrap { readonly transcript: readonly TranscriptTransition[]; /** Replacement handshake: the host fills this nonce before returning the worker's output credit. */ readonly epochSignal?: SharedArrayBuffer; } /** * The ordered acceptance lane of one routing session. Every record reaches it synchronously, before * `SessionEventWriter.enqueue`, in the order the session produced it; a worker's records arrive here before * the worker's credit returns. Each bootstrap starts a new `sessionEpoch` whose sequences are never compared * with another epoch's. */ export declare class SessionAcceptanceLane extends AcceptedRootReads { readonly generations: SessionGenerations; private epoch; private sequence; /** * The lane's one staging store: accepted transcript tails of every epoch, spilled like any payload leaf (S12a), and * its worker's fragments before their message is whole (S12b); retiring the lane aborts what is still staged. */ readonly staging: TransferStaging; private transcript; private activeMessageId; private turnId; private correlation; private refusedCorrelations; /** RULING-120 (#5331): the settled ids of the record being delivered, read at `acceptedSequence`. */ readonly identities: MessageIdentities; private retiredAs; private storageRetired; private nonce; private settled; private cleanup; private readonly storage; private readonly diagnose; constructor(storage?: CompactContentStoreOptions, diagnose?: (reason: SettledDiagnostic) => void, agentDir?: string); get recoveryEpoch(): string; /** The sequence of the last record this epoch accepted: what a record leased right after its acceptance names (S13). */ get acceptedSequence(): number; /** The public epoch of this incarnation (S08-Q1): distinct from the producer nonce, which is never serialized. */ get sessionEpoch(): string; get retired(): boolean; get retirement(): "close" | "worker_failed" | undefined; /** Open broadcast questions now (a hot count for status); undefined when the compact state is unavailable. */ get openBroadcastDialogs(): number | undefined; bootstrap(input: SessionBootstrap, nonce?: string): void; /** Transcript transitions committed before the record they arrive with; each takes its own sequence (C1.1). */ applyTranscript(transitions: readonly TranscriptTransition[]): void; /** * A legacy record and, when the structured lane projected one, its canonical record: one unit, one sequence. * `canonicalRefused`: the pairing refused this event's canonical record at the protocol depth limit and that refusal * was already counted; like a record the depth check refuses here, the unit then takes its place but changes no * compact state, and the event is never counted twice (RULING-59 C). */ accept(record: object, carrier: RecoveryCarrier | undefined, canonical?: CanonicalUnit, canonicalRefused?: boolean, callKey?: string): AcceptedRef | undefined; /** A block control has no legacy record; it is a unit of its own at the next sequence. */ acceptControl(unit: CanonicalUnit | undefined): number | undefined; /** * A canonical record of this epoch was lost before folding, so its compact state can no longer be complete; one refused * at the protocol depth limit is counted instead, live state or not, and a live state stays (RULING-59 C). */ compactUnavailable(cause: unknown): void; freeze(): FrozenAcceptedRoot; release(root: FrozenAcceptedRoot): void; storageStatus(): { structuredBytes: { readonly resident: number; readonly spilled: number; readonly pinned: number; }; residentPayloadBytes: number; pendingIoCopyBytes: number; pinnedOnlyBytes: number; spilledLiveBytes: number; spillBytesWritten: number; reclaimDebtBytes: number; spillFailureRetainedBytes: number; spillHalted: boolean; failures: readonly import("./compact-storage-io.ts").CompactStorageFailure[]; overrideSlots: number; deletionMasks: number; deletionMaskBytes: number; basePages: number; baseRows: number; residentIndexNodes: number; allocatedIndexNodes: number; residentPages: number; peakResidentPages: number; ownerJoinsEvicted: number; ownerJoinsOverflowed: number; residentSettledKeys: number; refusedRecords: number; transcript: import("./compact-transfer-staging.ts").StagingStatus; }; private compact; idle(): Promise<void>; private retireSettled; /** * No record is accepted after retirement, and every root this lane published is released except those in `keep`: * a legacy view still queued at a seal reads its root to the end (RULING-51 Q2=A), and the lane's storage retires * with the last such release. A root never published by this lane is not kept. The epoch's retained transcript * (ids, kinds, parents, tail) goes with the lane; a kept root holds its own reference until released. */ retire(reason: "close" | "worker_failed", keep?: ReadonlySet<FrozenAcceptedRoot>): void; private retireStorage; } export {}; //# sourceMappingURL=session-acceptance-lane.d.ts.map