@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
102 lines • 5.73 kB
TypeScript
import type { RecoveryCarrier } from "../../core/session-recovery-identity.ts";
import type { TranscriptTransition } from "../../core/session-transcript-journal.ts";
import type { CallProjection } from "./compact-call-model.ts";
import type { SettledEnd } from "./compact-message-identity.ts";
import { type FrozenIndex } from "./compact-content-index.ts";
import { type CompactContentStoreOptions } from "./compact-content-store.ts";
import { type OwnerRow, type SettledReader, type TerminalRow } from "./compact-settled-rows.ts";
export type SettledDiagnostic = "unknown_message" | "duplicate_end" | "retired_owner" | "conflicting_owner" | "unsupported_role";
export type SettledRoot = FrozenIndex;
/** One spillable collection owns payloads, end markers and both directions of the durable join. */
export declare class CompactSettledMessages {
private readonly store;
private readonly rows;
/**
* Resident membership: one state key per message (`end:` ended but unjoined, `owner:` -> entry id joined before its
* end, `settled:` -> entry id both), `terminal:` per pending terminal row and `entry:` per joined entry. Settling a
* message folds its end marker into its join and drops its terminal row, so what a settled message keeps resident is
* exactly the two id-sized facts the duplicate-end and conflicting-owner checks need (carried item 9, senpi#4460):
* residency is O(settled messages) per epoch, two id keys per message, payloads zero. Bounding it independently of
* message count needs a paged synchronous membership filter, carried to S08/S11 (RULING-48 item 9).
*/
private readonly keys;
private joins;
private readonly epoch;
private readonly diagnose;
constructor(epoch: string, options: CompactContentStoreOptions, diagnose: (reason: SettledDiagnostic) => void);
/** The catalog's reader of one cut: rows a page at a time, payload leaves, paged values and entry joins. */
reader(root: SettledRoot): SettledReader;
valid(carrier: RecoveryCarrier | undefined): carrier is RecoveryCarrier;
/**
* Returns the accepted end (undefined when refused): whether it joined the message to its durable entry, the only end
* that settles persistence, and the message's settled ids (RULING-120): its `messageId` and the end's accepted sequence as
* `terminalSequence`, which a pending or failed terminal pages as `message-<terminalSequence>` and a joined message
* pages only through its `join-<n>` member's `messageId` (an already-joined end writes no terminal row). `call`:
* the projection of the outstanding call this toolResult settles, stored with the terminal (Q2). The terminal is
* serialized from `record`, so a record over the protocol depth limit is refused typed before anything changes
* (RULING-59 C); the lane runs that check, and counts the refusal, before it calls this.
*/
end(record: object, carrier: RecoveryCarrier | undefined, sequence: number, turnId: string | null, call?: CallProjection): SettledEnd | undefined;
private reject;
/** Marks the message's pending terminal failed; returns the `messageId` that row carries, undefined for none. */
fail(carrier: RecoveryCarrier | undefined, errorMessage: string): {
readonly messageId: string;
} | undefined;
/** Joins an owned append to its message; returns that message's id, the `messageId` of the join member it made. */
append(transition: Extract<TranscriptTransition, {
kind: "append";
}>): string | undefined;
private join;
/** Ended and joined: its rows stay paged; its end marker folds into its join, its entry stays claimed. */
private settle;
private put;
/** The message each entry joined in this epoch, read in order from one cut of the paged rows; undefined for none. */
messagesOf(entryIds: readonly string[]): Promise<(string | undefined)[]>;
freeze(): SettledRoot;
release(root: SettledRoot): void;
read(root: SettledRoot): Promise<{
settledMessages: (Omit<TerminalRow, "call" | "kind" | "payload"> & {
terminal: unknown;
correlation: unknown;
call?: CallProjection;
})[];
owners: OwnerRow[];
}>;
/**
* The rows of one cut, a descriptor page (at most 128) at a time (S10b): each terminal row with its patched status
* and the ref of its paged call, each `owner:` join once (its `entry:` twin is the same row). A reader of a terminal's
* payload or call pages through `readLeaf` and `values.walk` under the same cut.
*/
private members;
/** The message an entry joined in this cut, if any (the `source` family's join). */
private messageOf;
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;
residentSettledKeys: number;
};
idle(): Promise<void>;
retire(): Promise<void>;
}
//# sourceMappingURL=compact-settled-messages.d.ts.map