IF Commons GitHub

governance/problem

Written to: 1 requirement: 1 proved, 0 partly, 0 failing, 0 with no test recorded. 0002-anyfs-governance FR-008

What a store reports when it does not do what it was asked: five kinds of problem, a closed union, each a value with one sentence. A conflict is not an error of the store: it is the answer to a write whose expectation did not hold, and says what was expected and what was found.

import { describeProblem, missing } from "./problem.ts";
import { parsePath } from "./path.ts";
const p = parsePath("a");
p.kind === "ok" && describeProblem(missing(p.value)); // "a is not in the store"

Source: commons/anyfs/src/governance/problem.ts

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

REFUSALSconst
const REFUSALS: readonly ["read-only", "outside-scope", "unsupported-expectation", "capability-absent", "too-large", "unportable-path", "consent"]

Why a store refused an operation: a closed list.

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

Refusaltypeno test imports it
type Refusal = (typeof REFUSALS)[number];

One reason for a refusal.

Foundtypeno test imports it
type Found = { readonly kind: "absent" } | { readonly kind: "rev"; readonly rev: Revision };

What a conflict found at the path: no object, or one at a revision.

Problemtype
type Problem = | { readonly kind: "missing"; readonly path: Path } | { readonly kind: "conflict"; readonly path: Pat… (473 characters)
type Problem =
  | { readonly kind: "missing"; readonly path: Path }
  | { readonly kind: "conflict"; readonly path: Path; readonly expected: Expect; readonly found: Found }
  | { readonly kind: "refused"; readonly reason: Refusal; readonly detail: string; readonly path?: Path }
  | { readonly kind: "unavailable"; readonly detail: string; readonly retryable: boolean; readonly path?: Path }
  | { readonly kind: "tampered"; readonly path: Path; readonly detail: string };

What a store reports: a closed union of five kinds.

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

missingconst
const missing: (path: Path) => Problem

There is no object at the path.

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

conflictconst
const conflict: (path: Path, expected: Expect, found: Found) => Problem

The object was not as the write expected.

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

refusedconst
const refused: (reason: "capability-absent" | "consent" | "outside-scope" | "read-only" | "too-large" | "unportable-path" | "unsupported-expectation", detail: string, path?: Path | undefined) => Problem

The store will not do it, and says why.

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

unavailableconst
const unavailable: (detail: string, retryable: boolean, path?: Path | undefined) => Problem

The store could not do it now; a retry may succeed where retryable.

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

tamperedconst
const tampered: (path: Path, detail: string) => Problem

The bytes are not what their revision says they are.

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

describeProblemfunction
function describeProblem(problem: Problem): string

A problem as one sentence.

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

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