/** * Generic-profile delta encoding (SPEC Section 10a). * * Full producer + consumer for keyed-row deltas over the generic profile, * byte-for-byte interoperable with gcf-go and gcf-python. Delta is opt-in and * bilateral; the existing encodeGeneric path is unchanged. */ /** * A keyed record set: the unit generic-profile delta operates on (Section 10a). * Rows are order-agnostic (set semantics); fields carries the declared column * order for the wire form; key names the identity column (the `@id` / `key=`); * name is the tabular section name for a full payload. */ export interface GenericSet { name?: string; key: string; fields: string[]; rows: Array>; } /** A diff between two GenericSets (computed by diffGenericSets or supplied directly). */ export interface GenericDeltaPayload { tool?: string; key: string; fields: string[]; baseRoot: string; newRoot: string; added: Array>; changed: Array>; removed: unknown[]; deltaTokens?: number; fullTokens?: number; } /** * Canonicalize one value for the pack-root record (Section 10a.3). Purpose-built * and deliberately decoupled from the wire cell encoder (formatScalar): it must be * collision-free and record-safe, not round-trippable. * - Typed literals stay bare so they never collide with the strings that spell * them: null is "-" (never a string), booleans are true/false, numbers are * canonical (Section 2.3.1). * - Strings are ALWAYS quoted, so (a) they can't collide with a typed literal * ("-", "true", "123" all become quoted), and (b) a tab or newline inside a * value is escaped and cannot break the tab/newline-delimited record. */ export declare function canonicalCell(v: unknown): string; /** * Compute the canonical pack root for a keyed set using the gcf-pack-root-v1 * algorithm, generic profile (Section 10a.3). Two implementations given the same * logical set MUST produce the same result. */ export declare function genericPackRoot(s: GenericSet): string; /** * Compute the delta from base to next. This is the blessed producer path: it is * the single place that enforces the keyed-diff invariants (identity uniqueness, * added-not-in-base, changed-must-exist, whole-row replacement, unchanged rows * omitted). Added/changed/removed are sorted by identity for reproducible output * (Section 10a.6). Schema change or a missing key throws: the caller must then * send a full payload (Section 10a.7). */ export declare function diffGenericSets(base: GenericSet, next: GenericSet): GenericDeltaPayload; /** * Emit a delta-participating full base payload: `key=` in the header, an * `@`-prefixed identity field in the declaration, pipe-separated rows. */ export declare function encodeGenericFull(s: GenericSet, tool: string): string; /** * Serialize a delta payload (Section 10a.2). Sections are emitted in the * deterministic order added / changed / removed (Section 10a.6). */ export declare function encodeGenericDelta(d: GenericDeltaPayload): string; /** * Apply a delta to a base set and verify the result hashes to expectedNewRoot * (Section 10a.5). Atomic: the whole payload is validated before any state * changes, and a mismatch leaves the base untouched. */ export declare function verifyGenericDelta(base: GenericSet, d: GenericDeltaPayload, expectedNewRoot: string): GenericSet; /** * Parse a delta-participating full base payload into a GenericSet, and return the * declared pack_root (Section 10a). */ export declare function decodeGenericFull(text: string): { set: GenericSet; packRoot: string; }; /** * Parse a delta payload into a GenericDeltaPayload (Section 10a.2). The result can * be applied with verifyGenericDelta. */ export declare function decodeGenericDelta(text: string): GenericDeltaPayload; //# sourceMappingURL=generic_delta.d.ts.map