@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
54 lines • 2.89 kB
TypeScript
import { type BoundedId, type ContentDigest } from "./compact-recovery-ids.ts";
/**
* The one frozen-reference codec of the recovery catalog (S09-Q1 A, RULING-57 Q1; shared by S11a/S12a/S13 per
* RULING-46 item 2).
*
* Digest: SHA-256 over `u8 tagLength || tag || u64be byteLength || bytes`, where `tag` is the ASCII
* `senpi-recovery-catalog/<version>/<encoding>/<domain>`: `encoding` names the stored encoding of the hashed bytes
* (`utf16le`, RULING-58 (1): a store that writes another encoding gets its own tag and never collides) and `domain`
* is `leaf` (one component's stored bytes), `node` (a catalog node as a child), `root` (the catalog root named by
* the manifest), `pointer` (a node's private side leaf, `compact-catalog-pointers.ts`) or `fragment` (one recovery
* page of a component's bytes, `compact-recovery-bytes.ts`). Bytes are the EXACT stored bytes of the content store: the UTF-16LE code units of the leaf text,
* a lone surrogate included, never a reconstructed or transcoded value. A format bump changes `CATALOG_VERSION`,
* hence every tag; a retired prefix is never reused.
*
* Node: one JSON text with this fixed field order and no other field, integers in canonical decimal, entries in
* child order; every string is an allow-listed ASCII identifier, so the encoding is deterministic by construction.
*/
export declare const CATALOG_FORMAT = "senpi-recovery-catalog";
export declare const CATALOG_VERSION = 1;
/** A node is one store leaf: 32,768 UTF-16 code units, 64 KiB stored, under D (131,072) and F. */
export declare const CATALOG_NODE_MAX_UNITS = 32768;
type CatalogDomain = "leaf" | "node" | "root" | "pointer" | "fragment";
export interface CatalogEntry {
readonly kind: BoundedId;
readonly id: BoundedId;
readonly length: number;
readonly digest: ContentDigest;
}
export declare const storedBytes: (text: string) => Buffer;
/** A digest over `length` bytes fed in order; `finish` after exactly that many. */
export declare function catalogDigester(domain: CatalogDomain, length: number): {
update(bytes: Buffer): void;
finish(): ContentDigest;
};
export declare function catalogDigest(domain: CatalogDomain, bytes: Buffer): ContentDigest;
/** Packs entries in order; `push` refuses, without retaining, the entry that would exceed either bound. */
export declare class CatalogNodeWriter {
private readonly parts;
private units;
get count(): number;
push(entry: CatalogEntry): boolean;
encode(): string;
}
type CatalogDecode = {
readonly ok: true;
readonly entries: readonly CatalogEntry[];
} | {
readonly ok: false;
readonly reason: "schema";
};
/** Decodes verified node bytes only: the caller checks the digest first (RULING-57 Q1 (3)). */
export declare function decodeCatalogNode(text: string): CatalogDecode;
export {};
//# sourceMappingURL=compact-catalog-codec.d.ts.map