@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
106 lines • 5.34 kB
TypeScript
import type { FileEntry } from "../../core/session-manager.ts";
import { type PersistedBase, type PersistedBaseError, type TranscriptTransition, type TranscriptUnavailableReason } from "../../core/session-transcript-journal.ts";
import { type TailReadFailure, TranscriptTail } from "./accepted-transcript-tail.ts";
import { type StagedContent, type TransferStaging } from "./compact-transfer-staging.ts";
/**
* What an epoch keeps of every accepted entry after persistence released its text: its id, kind and parent link
* (RULING-61 Q1 = C). Each record is charged no less than the heap it holds, so this budget bounds the retained heap
* itself, and the record count to at most 8 MiB / 40 B = 209,715 (records of empty strings).
*/
export declare const DEFAULT_TRANSCRIPT_ANCESTRY_BYTES: number;
/** One accepted entry of the epoch, at its accepted index, as a frozen root names it. */
export interface AcceptedEntry {
readonly index: number;
readonly id: string;
readonly kind: string;
readonly parentId: string | null;
}
/**
* The first `count` entries of an epoch's columns. The lane only appends to its columns (a `replace` starts new ones),
* so this prefix never changes: a root freezes in O(1) without a copy and never sees an entry accepted after it.
*/
declare class AcceptedEntries implements Iterable<AcceptedEntry> {
private readonly ids;
private readonly kinds;
private readonly parents;
readonly count: number;
constructor(ids: readonly string[], kinds: readonly string[], parents: readonly (string | null)[], count: number);
/** The ids of the first `end` entries, as the base reader takes them. */
idsBefore(end: number): string[];
[Symbol.iterator](): Generator<AcceptedEntry>;
}
/**
* A cut names its base and accepted ids. Its shared tail releases content only once the captured file covers it;
* persistence may change the source of those exact entries, never the accepted count.
*/
export interface TranscriptRoot {
readonly historyVersion: number;
readonly leafId: string | null;
readonly base: PersistedBase | null;
/** Exactly the `count` entries accepted when the root froze: id, engine kind and parent link. */
readonly accepted: AcceptedEntries;
readonly ancestryBytes: number;
readonly tail: TranscriptTail;
readonly count: number;
readonly unavailable: TranscriptUnavailableReason | null;
}
export type TranscriptRead = {
readonly ok: true;
readonly entries: readonly FileEntry[];
} | {
readonly ok: false;
readonly error: PersistedBaseError | TranscriptUnavailableReason | TailReadFailure;
};
/** The transcript component of one epoch, changed only by accepted transitions (R3.C1.1). */
export declare class AcceptedTranscript {
private version;
private leafId;
private base;
private entryIds;
private kinds;
private parents;
/** Each distinct kind once per epoch, so every record of a kind shares one string whatever the producer sent. */
private kindNames;
private ancestryBytes;
private readonly staging;
/** One bound for this epoch's tails, a superseded tail a live cut still holds included (carry 65a). */
private readonly budget;
private tail;
private unavailable;
/**
* The first entry whose text the tail bound refused, while that is the only reason the version is unavailable
* (RULING-80 (4)): later entries still record their identity, no text is kept outside the budget, and the version
* reads whole again once every entry from here on is durable.
*/
private missingFrom;
/** Entry texts are staged into, and spill through, the owning lane's staging store (S12a). */
constructor(staging: TransferStaging);
get historyVersion(): number;
get available(): boolean;
/**
* Applies a bootstrap whose entry texts the internal bootstrap reader staged first: a bootstrap refused at a bound
* leaves the epoch's transcript typed unavailable with nothing kept, never partial.
*/
bootstrap(transitions: readonly TranscriptTransition[]): void;
/** `staged`: the append's entry text, already staged by the bootstrap reader; this transcript adopts it if kept. */
apply(transition: TranscriptTransition, staged?: StagedContent): void;
/**
* Charges what the record really holds: its slots, its id, a kind the epoch has not seen, and a parent link unless it
* shares the previous entry's own id string (the common chain).
*/
private retainAncestry;
/** `missingFrom` marks a tail-bound refusal recoverable; any other reason, or a second one, stays for the version. */
private markUnavailable;
freeze(): TranscriptRoot;
private persisted;
/** Releases the epoch's tail content once no root of it can be read any longer. */
release(): void;
}
/**
* The root's entries: its base read only through the captured identity, then its own accepted values from its own
* segments, held for the whole read so a persistence report during it cannot drop what it reads. A segment read by
* identity that is gone or holds other bytes is typed, never other content (RULING-78 (2)).
*/
export declare function readTranscriptRoot(root: TranscriptRoot): Promise<TranscriptRead>;
export {};
//# sourceMappingURL=accepted-transcript.d.ts.map