IF Commons GitHub

merge/rows

Written to: 2 requirements: 2 proved, 0 partly, 0 failing, 0 with no test recorded. 0007-anyfs-merge-governance FR-007, 0007-anyfs-merge-governance FR-008

The version row as text and as checksum. The canonical text of a row is its fields in a fixed order; its sum is the SHA-256 of that text, so a row whose sum is not the hash of its fields has been changed. A row is made by makeVersion, which sorts and checks what a row must hold, and read back by verifyVersion.

import { versionKey } from "./rows.ts";

Source: commons/anyfs/src/merge/rows.ts

2 of 9 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.

VersionFieldstypeno test imports it
type VersionFields = {
  readonly id: VersionId;
  readonly replica: ReplicaId;
  readonly seq: number;
  readonly path: string;
  readonly parent: VersionId | null;
  readonly merged: readonly VersionId[];
  readonly kind: VersionKind;
  readonly blob: string | null;
};

What a row is made from: everything but its sum.

fieldsTextfunctionno test imports it
function fieldsText(f: VersionFields): string

The canonical text of a row's fields: a list in a fixed order.

sumOffunctionno test imports it
function sumOf(f: VersionFields): Promise<string>

The SHA-256 of a row's fields.

blobShafunctionno test imports it
function blobSha(bytes: Uint8Array<ArrayBufferLike>): Promise<string>

The digest a blob is named by: the SHA-256 of its bytes.

isShaconstno test imports it
const isSha: (text: string) => boolean

Whether a text is the digest of a blob.

makeVersionfunction
function makeVersion(f: VersionFields): Promise<Result<Version, string>>

A row from its fields, or why the fields are not a row: a put names a blob and a tombstone does not, the rows merged with are sorted and each once, and the parent is not among them.

Imported by 20 tests of the run (20 passed, 0 failed): the library's results

verifyVersionfunctionno test imports it
function verifyVersion(v: Version): Promise<string | undefined>

Whether a row is what its sum says: the fields are a row, and the sum is their hash. Why not, as a sentence.

versionKeyconst
const versionKey: (v: Pick<Version, "id" | "sum">) => string

The key of a row: its id and its sum, which is its primary key.

Imported by 11 tests of the run (11 passed, 0 failed): the library's results

compareVersionsfunctionno test imports it
function compareVersions(a: Version, b: Version): number

The order of two rows: by id and then by sum. The winner among the heads of a path is the greatest.

Titles, headings, exports, tables, columns and requirements. Esc closes.