IF Commons GitHub

logical/fold

Written to: 1 requirement: 0 proved, 0 partly, 0 failing, 1 with no test recorded. 0002-planning-core FR-006

The state of an item is the result of fold, a pure and total function from the events of the item (0037-planning FR-004): events are taken in the order of their id (a UUID version 7 sorts as text in the order its time and its counter give), the first being the opening, and the same events in any order or with any repeats give the same item. Two events with one id are one event where their content is the same and a conflict value where it is not; nothing is settled by taking either. The authority over each field (FR-012) is applied here, over the events, and not by overwriting a field: where the authority of a field is person-only, a change by an agent or a tool waits as a proposal and changes nothing, and an agent that acts for a person is not that person. An item inferred by a heuristic or an agent starts proposed and leaves that state only by a confirmation by a person (FR-006).

import { fold } from "./fold.ts";
// const item = fold(events); item.kind === "ok" && item.value.state.kind

Source: commons/planning/src/logical/fold.ts

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

logical.FoldProblemtypeno test imports it
type FoldProblem =
  | { readonly kind: "no-events" }
  | { readonly kind: "mixed-items"; readonly expected: ItemId; readonly found: ItemId }
  | { readonly kind: "conflict"; readonly ids: readonly EventId[] }
  | { readonly kind: "not-opened"; readonly first: EventId };

Why the events of an item are not an item: there are none, they are of two items, two with one id differ, or the first is not an opening.

logical.describeFoldProblemfunctionno test imports it
function describeFoldProblem(p: FoldProblem): string

One sentence for a problem.

logical.orderEventsfunctionno test imports it
function orderEvents(events: readonly ItemEvent[]): Result<readonly ItemEvent[], FoldProblem>

The events with each id once, in the order of their id, or the ids that exist with two contents.

logical.foldfunctionno test imports it
function fold(events: readonly ItemEvent[], policy?: Policy): Result<Item, FoldProblem>

The item the events of one item make, or why they are not an item.

FoldProblemtypeno test imports it
type FoldProblem =
  | { readonly kind: "no-events" }
  | { readonly kind: "mixed-items"; readonly expected: ItemId; readonly found: ItemId }
  | { readonly kind: "conflict"; readonly ids: readonly EventId[] }
  | { readonly kind: "not-opened"; readonly first: EventId };

Why the events of an item are not an item: there are none, they are of two items, two with one id differ, or the first is not an opening.

describeFoldProblemfunctionno test imports it
function describeFoldProblem(p: FoldProblem): string

One sentence for a problem.

orderEventsfunctionno test imports it
function orderEvents(events: readonly ItemEvent[]): Result<readonly ItemEvent[], FoldProblem>

The events with each id once, in the order of their id, or the ids that exist with two contents.

foldfunctionno test imports it
function fold(events: readonly ItemEvent[], policy?: Policy): Result<Item, FoldProblem>

The item the events of one item make, or why they are not an item.

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