IF Commons GitHub

governance/patch

Written to: 1 requirement: 0 proved, 0 partly, 0 failing, 1 with no test recorded. 0003-planning-reconcile FR-008

A patch (0037-planning FR-010): one event for one explicit source and place, in a closed union of the operations add an item, add an event, change a state, link and confirm. A patch does nothing until a source applies it, and makePatch is pure. The capability a patch needs of its source and the outbox of the patches no source could apply are here too (FR-014, FR-033).

import { opOf } from "./patch.ts";
opOf({ type: "closed", reason: "completed" }); // "change-state"

Source: commons/planning/src/governance/patch.ts

0 of 20 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.PATCH_OPSconstno test imports it
const PATCH_OPS: readonly ["add-item", "add-event", "change-state", "link", "confirm"]

The operations a patch is.

governance.PatchOptypeno test imports it
type PatchOp = (typeof PATCH_OPS)[number];

One operation of a patch.

governance.opOffunctionno test imports it
function opOf(data: EventData): "add-event" | "add-item" | "change-state" | "confirm" | "link"

The operation an event is, by its type.

governance.Patchtypeno test imports it
type Patch = {
  readonly op: PatchOp;
  readonly source: string;
  readonly place: string;
  readonly event: ItemEvent;
  /** The fingerprint of the observation the event is about in the source, where the item has one there. */
  readonly fingerprint?: string;
};

One event for one source and place: what a source is asked to write.

governance.PatchProblemtypeno test imports it
type PatchProblem = { readonly kind: "no-target"; readonly message: string };

Why a patch is refused.

governance.makePatchfunctionno test imports it
function makePatch(source: string, place: string, event: ItemEvent, fingerprint?: string | undefined): Result<Patch, PatchProblem>

The patch of an event for a source and a place, or why it is refused: the target is explicit, so a source and a place are not empty.

governance.capabilityForfunctionno test imports it
function capabilityFor(patch: Patch): "append-event" | "assign" | "close" | "create" | "delete" | "edit" | "read"

The capability a patch asks of its source: the one of its kind. A source that appends events holds every type of event it can express.

governance.mayApplyfunctionno test imports it
function mayApply(patch: Patch, capabilities: ReadonlySet<"append-event" | "assign" | "close" | "create" | "delete" | "edit" | "read">): boolean

Whether a source with these capabilities may be given the patch.

governance.OutboxReasontypeno test imports it
type OutboxReason = { readonly kind: "capability"; readonly capability: Capability } | { readonly kind: "unexpressed"; readonly reason: string };

Why a patch waits in the outbox: the capability its source lacks, or the reason the place cannot say it.

governance.OutboxEntrytypeno test imports it
type OutboxEntry = { readonly patch: Patch; readonly waiting: OutboxReason; readonly at: Instant };

A patch that no source could apply, with why, and when it was put there.

PATCH_OPSconstno test imports it
const PATCH_OPS: readonly ["add-item", "add-event", "change-state", "link", "confirm"]

The operations a patch is.

PatchOptypeno test imports it
type PatchOp = (typeof PATCH_OPS)[number];

One operation of a patch.

opOffunctionno test imports it
function opOf(data: EventData): "add-event" | "add-item" | "change-state" | "confirm" | "link"

The operation an event is, by its type.

Patchtypeno test imports it
type Patch = {
  readonly op: PatchOp;
  readonly source: string;
  readonly place: string;
  readonly event: ItemEvent;
  /** The fingerprint of the observation the event is about in the source, where the item has one there. */
  readonly fingerprint?: string;
};

One event for one source and place: what a source is asked to write.

PatchProblemtypeno test imports it
type PatchProblem = { readonly kind: "no-target"; readonly message: string };

Why a patch is refused.

makePatchfunctionno test imports it
function makePatch(source: string, place: string, event: ItemEvent, fingerprint?: string | undefined): Result<Patch, PatchProblem>

The patch of an event for a source and a place, or why it is refused: the target is explicit, so a source and a place are not empty.

capabilityForfunctionno test imports it
function capabilityFor(patch: Patch): "append-event" | "assign" | "close" | "create" | "delete" | "edit" | "read"

The capability a patch asks of its source: the one of its kind. A source that appends events holds every type of event it can express.

mayApplyfunctionno test imports it
function mayApply(patch: Patch, capabilities: ReadonlySet<"append-event" | "assign" | "close" | "create" | "delete" | "edit" | "read">): boolean

Whether a source with these capabilities may be given the patch.

OutboxReasontypeno test imports it
type OutboxReason = { readonly kind: "capability"; readonly capability: Capability } | { readonly kind: "unexpressed"; readonly reason: string };

Why a patch waits in the outbox: the capability its source lacks, or the reason the place cannot say it.

OutboxEntrytypeno test imports it
type OutboxEntry = { readonly patch: Patch; readonly waiting: OutboxReason; readonly at: Instant };

A patch that no source could apply, with why, and when it was put there.

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