IF Commons GitHub

protocol

Written to: 2 requirements: 2 proved, 0 partly, 0 failing, 0 with no test recorded. 0002-anyfs-ssh-helper FR-003, 0002-anyfs-ssh-helper FR-004

The protocol between the store and the helper, as pure functions: the argument vector of a call (the helper is carried in the call or kept on the host), the answer of the helper as a closed union (its exit status and its standard output, read once), and the lines the helper writes for each command. Nothing here runs a program.

import { callOf, replyOf } from "./protocol.ts";
import { helperOf, POSIX } from "./dialect.ts";
callOf(helperOf(POSIX), { kind: "installed", path: "/home/a/.local/state/anyfs/helper-x.sh" }, "stat", "/srv/fleet", ["a.json"]).slice(2); // ["stat", "/srv/fleet", "a.json"]

Source: commons/anyfs-ssh/src/protocol.ts

1 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.

callOffunction
function callOf(helper: Helper, transport: Transport, command: Command, root: string, args: readonly string[]): readonly string[]

The argument vector of a call: every word is one word, quoted by the executor, never joined here.

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

Commandtypeno test imports it
type Command = "probe" | "install" | "read" | "stat" | "statmany" | "list" | "write" | "delete" | "rename";

The commands of the helper.

Factstypeno test imports it
type Facts = { readonly size: number; readonly rev: Revision; readonly modified?: string };

What the helper says of an object.

HostFactstypeno test imports it
type HostFacts = {
  readonly dialect: "posix";
  readonly hash: "sha256sum" | "shasum" | "openssl" | "sha256" | "none";
  readonly stat: "gnu" | "bsd" | "none";
  readonly caseSensitive: boolean | undefined;
};

What a host is: what the probe of the helper said, as a closed record.

Replytypeno test imports it
type Reply = | { readonly kind: "done"; readonly stdout: Uint8Array } | { readonly kind: "missing" } | { readonly … (549 characters)
type Reply =
  | { readonly kind: "done"; readonly stdout: Uint8Array }
  | { readonly kind: "missing" }
  | { readonly kind: "conflict"; readonly found: Found; readonly at: "path" | "to" }
  | { readonly kind: "refused"; readonly reason: string }
  | { readonly kind: "locked" }
  | { readonly kind: "too-large" }
  | { readonly kind: "no-root" }
  | { readonly kind: "no-hash" }
  | { readonly kind: "bad-hash"; readonly got: string }
  | { readonly kind: "failed"; readonly detail: string }
  | { readonly kind: "lost"; readonly detail: string };

What the helper answered: a closed union.

Transporttypeno test imports it
type Transport = { readonly kind: "installed"; readonly path: string } | { readonly kind: "carried" };

How the helper reaches the host: kept there at a path (verified once by its hash), or carried in each call as the argument of sh -c.

Writtentypeno test imports it
type Written = { readonly rev: Revision; readonly created: boolean };

What a write told: whether it made the object, and the revision.

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