logical.GENESISconstno test imports itconst GENESIS: stringThe previous of the first entry.
The ledger and the manifest of evidence (0006-grc-evidence): an append-only, hash-chained list of what was kept, and the manifest of a bundle that lists its items by digest and the head of the ledger. Pure apart from hashing, which is the same on every runtime.
import { appendEntry, verifyLedger } from "./ledger.ts";
const e1 = await appendEntry(undefined, { at: "2026-01-01T00:00:00Z", type: "observation", subject: "host-1", evidence: "ab".repeat(32) });
(await verifyLedger([e1])).kind; // "ok"logical.GENESISconstno test imports itconst GENESIS: stringThe previous of the first entry.
logical.appendEntryfunctionno test imports itfunction appendEntry(previous: (Document & { readonly seq: number; readonly previous: string; readonly type: string; rea… (503 characters)function appendEntry(previous: (Document & { readonly seq: number; readonly previous: string; readonly type: string; readonly subject: string; readonly evidence: string; readonly digest: string; } & {}) | undefined, item: { readonly at: string; readonly type: string; readonly subject: string; readonly evidence: string; }): Promise<Document & { readonly seq: number; readonly previous: string; readonly type: string; readonly subject: string; readonly evidence: string; readonly digest: string; } & {}>The entry after previous (none for the first): its sequence number, the digest of the one before, and its own digest.
logical.LedgerFaulttypeno test imports ittype LedgerFault = { readonly seq: number; readonly reason: string };The first entry that was changed, removed, inserted or reordered.
logical.verifyLedgerfunctionno test imports itfunction verifyLedger(entries: readonly (Document & { readonly seq: number; readonly previous: string; readonly type: string; readonly subject: string; readonly evidence: string; readonly digest: string; } & {})[], head?: string | undefined): Promise<Result<void, LedgerFault>>Verifies the chain; with head (the digest a signature covers) it also finds entries cut off the end.
logical.makeManifestfunctionno test imports itfunction makeManifest(items: readonly { readonly digest: string; readonly size: number; readonly mediaType: string; }[], ledgerHead: string, at: string): Document & { readonly items: readonly ObjectOf<{ digest: Decoder<string>; size: Decoder<number>; mediaType: Decoder<string>; }, Record<never, never>>[]; readonly ledgerHead: string; } & {}The manifest of a bundle: the items in the byte order of their digests, and the head of the ledger.
logical.ManifestFaultstypeno test imports ittype ManifestFaults = { readonly missing: readonly string[]; readonly extra: readonly string[]; readonly different: readonly string[] };What a set of items has that its manifest does not say.
logical.verifyManifestfunctionno test imports itfunction verifyManifest(manifest: Document & { readonly items: readonly ObjectOf<{ digest: Decoder<string>; size: Decoder<number>; mediaType: Decoder<string>; }, Record<never, never>>[]; readonly ledgerHead: string; } & {}, present: readonly { readonly digest: string; readonly size: number; }[]): ManifestFaultsEach item the manifest lists that is missing, each present that it does not list, and each whose size differs.
logical.manifestBytesfunctionno test imports itfunction manifestBytes(manifest: Document & { readonly items: readonly ObjectOf<{ digest: Decoder<string>; size: Decoder<number>; mediaType: Decoder<string>; }, Record<never, never>>[]; readonly ledgerHead: string; } & {}): Uint8Array<ArrayBufferLike>The canonical bytes a manifest is signed over.
GENESISconstconst GENESIS: stringThe previous of the first entry.
appendEntryfunctionfunction appendEntry(previous: (Document & { readonly seq: number; readonly previous: string; readonly type: string; rea… (503 characters)function appendEntry(previous: (Document & { readonly seq: number; readonly previous: string; readonly type: string; readonly subject: string; readonly evidence: string; readonly digest: string; } & {}) | undefined, item: { readonly at: string; readonly type: string; readonly subject: string; readonly evidence: string; }): Promise<Document & { readonly seq: number; readonly previous: string; readonly type: string; readonly subject: string; readonly evidence: string; readonly digest: string; } & {}>The entry after previous (none for the first): its sequence number, the digest of the one before, and its own digest.
LedgerFaulttypeno test imports ittype LedgerFault = { readonly seq: number; readonly reason: string };The first entry that was changed, removed, inserted or reordered.
verifyLedgerfunctionfunction verifyLedger(entries: readonly (Document & { readonly seq: number; readonly previous: string; readonly type: string; readonly subject: string; readonly evidence: string; readonly digest: string; } & {})[], head?: string | undefined): Promise<Result<void, LedgerFault>>Verifies the chain; with head (the digest a signature covers) it also finds entries cut off the end.
makeManifestfunctionfunction makeManifest(items: readonly { readonly digest: string; readonly size: number; readonly mediaType: string; }[], ledgerHead: string, at: string): Document & { readonly items: readonly ObjectOf<{ digest: Decoder<string>; size: Decoder<number>; mediaType: Decoder<string>; }, Record<never, never>>[]; readonly ledgerHead: string; } & {}The manifest of a bundle: the items in the byte order of their digests, and the head of the ledger.
ManifestFaultstypeno test imports ittype ManifestFaults = { readonly missing: readonly string[]; readonly extra: readonly string[]; readonly different: readonly string[] };What a set of items has that its manifest does not say.
verifyManifestfunctionfunction verifyManifest(manifest: Document & { readonly items: readonly ObjectOf<{ digest: Decoder<string>; size: Decoder<number>; mediaType: Decoder<string>; }, Record<never, never>>[]; readonly ledgerHead: string; } & {}, present: readonly { readonly digest: string; readonly size: number; }[]): ManifestFaultsEach item the manifest lists that is missing, each present that it does not list, and each whose size differs.
manifestBytesfunctionno test imports itfunction manifestBytes(manifest: Document & { readonly items: readonly ObjectOf<{ digest: Decoder<string>; size: Decoder<number>; mediaType: Decoder<string>; }, Record<never, never>>[]; readonly ledgerHead: string; } & {}): Uint8Array<ArrayBufferLike>The canonical bytes a manifest is signed over.