governance.PATCH_OPSconstno test imports itconst PATCH_OPS: readonly ["add-item", "add-event", "change-state", "link", "confirm"]The operations a patch is.
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"governance.PATCH_OPSconstno test imports itconst PATCH_OPS: readonly ["add-item", "add-event", "change-state", "link", "confirm"]The operations a patch is.
governance.PatchOptypeno test imports ittype PatchOp = (typeof PATCH_OPS)[number];One operation of a patch.
governance.opOffunctionno test imports itfunction opOf(data: EventData): "add-event" | "add-item" | "change-state" | "confirm" | "link"The operation an event is, by its type.
governance.Patchtypeno test imports ittype 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 ittype PatchProblem = { readonly kind: "no-target"; readonly message: string };Why a patch is refused.
governance.makePatchfunctionno test imports itfunction 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 itfunction 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 itfunction mayApply(patch: Patch, capabilities: ReadonlySet<"append-event" | "assign" | "close" | "create" | "delete" | "edit" | "read">): booleanWhether a source with these capabilities may be given the patch.
governance.OutboxReasontypeno test imports ittype 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 ittype 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 itconst PATCH_OPS: readonly ["add-item", "add-event", "change-state", "link", "confirm"]The operations a patch is.
PatchOptypeno test imports ittype PatchOp = (typeof PATCH_OPS)[number];One operation of a patch.
opOffunctionno test imports itfunction opOf(data: EventData): "add-event" | "add-item" | "change-state" | "confirm" | "link"The operation an event is, by its type.
Patchtypeno test imports ittype 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 ittype PatchProblem = { readonly kind: "no-target"; readonly message: string };Why a patch is refused.
makePatchfunctionno test imports itfunction 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 itfunction 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 itfunction mayApply(patch: Patch, capabilities: ReadonlySet<"append-event" | "assign" | "close" | "create" | "delete" | "edit" | "read">): booleanWhether a source with these capabilities may be given the patch.
OutboxReasontypeno test imports ittype 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 ittype 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.