IF Commons GitHub

governance/policy

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

What a program decides about the view before it opens it: whether an empty directory is kept (and as which marker object), who the objects belong to and with which mode, whether the ancestors of a new object are checked, how much a read cache may hold and how many times an append tries again. The policy is a value, made by smart constructors and held by the view, so that two views of one store can differ and nothing is read from the process.

import { defaultPolicy, keepMarkers } from "./policy.ts";
defaultPolicy().markers.kind; // "none": an empty directory is not kept
const m = keepMarkers(".keep");
m.kind === "ok" && m.value.kind; // "keep"

Source: commons/anyfs-posix/src/governance/policy.ts

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

governance.MarkerNametypeno test imports it
type MarkerName = Brand<string, "anyfs posix marker name">;

The name of the marker object that keeps a directory: one segment of a path. Made only by parseMarkerName.

governance.parseMarkerNamefunctionno test imports it
function parseMarkerName(text: string): Result<MarkerName, string>

The name of a marker, or why the text is not one: one segment, which a path can hold.

governance.Markerstypeno test imports it
type Markers = { readonly kind: "none" } | { readonly kind: "keep"; readonly name: MarkerName };

Whether an empty directory is kept: not at all, or as an empty object of this name below it.

governance.keepMarkersfunctionno test imports it
function keepMarkers(name: string): Result<Markers, string>

Keeping empty directories as marker objects of a name.

governance.Ownershiptypeno test imports it
type Ownership = { readonly uid: number; readonly gid: number; readonly fileMode: number; readonly dirMode: number };

Whom an object belongs to and with which mode, for a view that has no such thing in its store: a number each.

governance.DEFAULT_OWNERSHIPconstno test imports it
const DEFAULT_OWNERSHIP: Ownership

The owner of everything, root, and the modes of a file system's usual defaults.

governance.parseOwnershipfunctionno test imports it
function parseOwnership(uid: number, gid: number, fileMode: number, dirMode: number): Result<Ownership, string>

An ownership from numbers, or why they are not one: whole numbers from 0, and modes of at most four octal digits.

governance.AncestorCheckstypeno test imports it
type AncestorChecks = "check" | "trust";

Whether the directories above a new object are checked to be directories (check: a stat for each), or trusted (trust: none).

governance.Policytypeno test imports it
type Policy = { readonly markers: Markers; readonly ownership: Ownership; readonly ancestors: AncestorChecks; /*… (432 characters)
type Policy = {
  readonly markers: Markers;
  readonly ownership: Ownership;
  readonly ancestors: AncestorChecks;
  /** The most bytes the read cache holds; 0 holds none. */
  readonly readCacheBytes: number;
  /** How many entries a list is asked for at a time. */
  readonly listPage: number;
  /** How many times an append reads and writes again after another writer changed the object. */
  readonly appendAttempts: number;
};

What the view is told.

governance.defaultPolicyfunctionno test imports it
function defaultPolicy(): Policy

The default policy: no markers, the default ownership, the ancestors checked, 8 MiB of cache, pages of 1000 and 5 attempts.

governance.withPolicyfunctionno test imports it
function withPolicy(base: Policy, changes: Partial<Policy>): Result<Policy, string>

A policy with changes, or why they make none: the sizes are whole numbers, the page at least 1 and the attempts at least 1.

MarkerNametypeno test imports it
type MarkerName = Brand<string, "anyfs posix marker name">;

The name of the marker object that keeps a directory: one segment of a path. Made only by parseMarkerName.

parseMarkerNamefunction
function parseMarkerName(text: string): Result<MarkerName, string>

The name of a marker, or why the text is not one: one segment, which a path can hold.

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

Markerstypeno test imports it
type Markers = { readonly kind: "none" } | { readonly kind: "keep"; readonly name: MarkerName };

Whether an empty directory is kept: not at all, or as an empty object of this name below it.

keepMarkersfunction
function keepMarkers(name: string): Result<Markers, string>

Keeping empty directories as marker objects of a name.

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

Ownershiptypeno test imports it
type Ownership = { readonly uid: number; readonly gid: number; readonly fileMode: number; readonly dirMode: number };

Whom an object belongs to and with which mode, for a view that has no such thing in its store: a number each.

DEFAULT_OWNERSHIPconst
const DEFAULT_OWNERSHIP: Ownership

The owner of everything, root, and the modes of a file system's usual defaults.

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

parseOwnershipfunction
function parseOwnership(uid: number, gid: number, fileMode: number, dirMode: number): Result<Ownership, string>

An ownership from numbers, or why they are not one: whole numbers from 0, and modes of at most four octal digits.

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

AncestorCheckstypeno test imports it
type AncestorChecks = "check" | "trust";

Whether the directories above a new object are checked to be directories (check: a stat for each), or trusted (trust: none).

Policytype
type Policy = { readonly markers: Markers; readonly ownership: Ownership; readonly ancestors: AncestorChecks; /*… (432 characters)
type Policy = {
  readonly markers: Markers;
  readonly ownership: Ownership;
  readonly ancestors: AncestorChecks;
  /** The most bytes the read cache holds; 0 holds none. */
  readonly readCacheBytes: number;
  /** How many entries a list is asked for at a time. */
  readonly listPage: number;
  /** How many times an append reads and writes again after another writer changed the object. */
  readonly appendAttempts: number;
};

What the view is told.

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

defaultPolicyfunction
function defaultPolicy(): Policy

The default policy: no markers, the default ownership, the ancestors checked, 8 MiB of cache, pages of 1000 and 5 attempts.

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

withPolicyfunction
function withPolicy(base: Policy, changes: Partial<Policy>): Result<Policy, string>

A policy with changes, or why they make none: the sizes are whole numbers, the page at least 1 and the attempts at least 1.

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

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