IF Commons GitHub

bundle

Written to: 4 requirements: 4 proved, 0 partly, 0 failing, 0 with no test recorded. 0002-kanon-content-checks FR-008, 0002-kanon-content-checks FR-009, 0002-kanon-content-checks FR-010, 0002-kanon-content-checks FR-011

The published bundle of a Logical model (commons 0033-kanon FR-026): the model as five files and a manifest of the SHA-256 and size of each, made the same way every time, and a loader that checks the whole bundle before it returns any of it. makeBundle writes the files as text; verifyBundle takes the manifest's text and the bytes of every file found, reads no file, no clock and no network, evaluates nothing, and either returns every fault (a file changed, missing or extra, a manifest that is not valid, a verified file that is not of the form) and none of the files, or the verified files and the model decoded from them.

The design is that of grc's verification of an evidence bundle (0011-grc-bundles), made again on core and crypto: grc is in the same layer as Kanon and cannot be imported (commons 0032-libraries-by-concern FR-003). There is no ledger and no signature here: the manifest holds digests, and a signature of it is another requirement.

import { makeBundle, verifyBundle, type LayeredModel } from "@intellectual-frontiers/kanon";
declare const model: LayeredModel;
const bundle = await makeBundle(model);
bundle.files.size; // 5

Source: commons/kanon/src/bundle.ts

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

Bundletypeno test imports it
type Bundle = { readonly files: ReadonlyMap<string, string>; readonly manifest: string };

The files of a bundle as text, and the text of its manifest.

BundleFaulttypeno test imports it
type BundleFault = | { readonly kind: "changed"; readonly path: string; readonly message: string } | { readonly kind… (425 characters)
type BundleFault =
  | { readonly kind: "changed"; readonly path: string; readonly message: string }
  | { readonly kind: "missing"; readonly path: string; readonly message: string }
  | { readonly kind: "extra"; readonly path: string; readonly message: string }
  | { readonly kind: "manifest"; readonly path: string; readonly message: string }
  | { readonly kind: "form"; readonly path: string; readonly message: string };

One thing wrong with a bundle: a closed union, each case with the path it concerns and one sentence.

BUNDLE_FILESconstno test imports it
const BUNDLE_FILES: readonly ["dispositions.json", "elements.json", "model.json", "relations.json", "trace.json"]

The files of a bundle besides its manifest, in the order of their paths.

BUNDLE_MANIFESTconst
const BUNDLE_MANIFEST: "manifest.json"

The name of the manifest in a bundle.

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

makeBundlefunction
function makeBundle(model: LayeredModel): Promise<Bundle>

The bundle of a model: the same model gives the same bytes, with the ids and the trace edges as the model has them.

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

VerifiedBundletypeno test imports it
type VerifiedBundle = { readonly files: ReadonlyMap<string, Uint8Array>; readonly model: LayeredModel };

What a verified bundle gives: its files as bytes and the model decoded from them.

verifyBundlefunction
function verifyBundle(input: { readonly manifest: string; readonly files: ReadonlyMap<string, Uint8Array<ArrayBufferLike>>; }): Promise<Result<VerifiedBundle, readonly BundleFault[]>>

Verifies a whole bundle, from the text of its manifest and the bytes of each file found in it (not the manifest). It returns every fault, in the order of the paths, and none of the files where there is one; where there is none, the verified files and the model decoded from them. It evaluates nothing of the bundle.

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

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