IF Commons GitHub

logical/reconcile

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

reconcile (0037-planning FR-016 to FR-018): what a source read, brought together with the store. Each observation is matched to an item (the anchor it carries, an external id, its fingerprint, its locator), classed against the trace last taken (new, unchanged, updated, absent: the baselineState of SARIF 2.1.0 section 3.27.24), and each difference of the place from its base becomes an event whose actor is the source, a tool, so that the authority of a field decides in fold; where the place, its base and the store all differ and the policy names no authority, the result is a conflict value and nothing is chosen. A thing no longer found is closed by a derived close and reopened if it is found again, unless a person closed it. The result is data (events, traces, conflicts, classes) and nothing is written. Async only because an id made of an external id takes a SHA-256.

import { reconcile } from "./reconcile.ts";
// const r = await reconcile({ source: "markdown", observations, items, traces, policy, now, wallMs, clock, actor });

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

0 of 16 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.MergedFieldtypeno test imports it
type MergedField = "title" | "body" | "severity" | "state";

The fields of a place that are merged three ways.

logical.Conflicttypeno test imports it
type Conflict =
  | { readonly kind: "field"; readonly item: ItemId; readonly field: MergedField; readonly base: string; readonly now: string; readonly store: string; readonly source: string }
  | { readonly kind: "event-id"; readonly item: ItemId; readonly id: EventId; readonly source: string };

A difference that nothing decides: it names the item, the field, the three values and the source (0037-planning FR-017).

logical.ReconcileInputtypeno test imports it
type ReconcileInput = { readonly source: string; readonly observations: readonly Observation[]; readonly items: re… (470 characters)
type ReconcileInput = {
  readonly source: string;
  readonly observations: readonly Observation[];
  readonly items: readonly Item[];
  readonly traces: readonly Trace[];
  readonly policy: Policy;
  /** The instant the read was made, which the events made of it carry. */
  readonly now: Instant;
  /** The wall time in milliseconds, for the clock. */
  readonly wallMs: number;
  readonly clock: Clock;
  /** The source as an actor. */
  readonly actor: ToolActor;
};

What reconcile is given.

logical.Classedtypeno test imports it
type Classed = { readonly fingerprint: string; readonly class: BaselineClass; readonly item: ItemId | undefined };

How an observation ended, for the report.

logical.Reconciledtypeno test imports it
type Reconciled = {
  readonly events: readonly ItemEvent[];
  /** The traces to write: new, changed or made absent. */
  readonly traces: readonly Trace[];
  readonly links: readonly Link[];
  readonly conflicts: readonly Conflict[];
  readonly classes: readonly Classed[];
  readonly clock: Clock;
};

What reconcile gives: data, and the clock after the ids it made.

logical.ReconcileProblemtypeno test imports it
type ReconcileProblem =
  | { readonly kind: "id"; readonly problem: IdProblem }
  | { readonly kind: "clock"; readonly problem: ClockProblem }
  | { readonly kind: "event"; readonly problem: EventProblem }
  | { readonly kind: "time"; readonly problem: TimeProblem };

Why reconcile cannot go on.

logical.stateKeyfunctionno test imports it
function stateKey(s: ObservedState | State): string

The state a place says, as the item's state says it, for comparing.

logical.reconcilefunctionno test imports it
function reconcile(input: ReconcileInput): Promise<Result<Reconciled, ReconcileProblem>>

Reconciles what a source read with the store: events, traces, links, conflicts and classes, as data.

MergedFieldtypeno test imports it
type MergedField = "title" | "body" | "severity" | "state";

The fields of a place that are merged three ways.

Conflicttypeno test imports it
type Conflict =
  | { readonly kind: "field"; readonly item: ItemId; readonly field: MergedField; readonly base: string; readonly now: string; readonly store: string; readonly source: string }
  | { readonly kind: "event-id"; readonly item: ItemId; readonly id: EventId; readonly source: string };

A difference that nothing decides: it names the item, the field, the three values and the source (0037-planning FR-017).

ReconcileInputtypeno test imports it
type ReconcileInput = { readonly source: string; readonly observations: readonly Observation[]; readonly items: re… (470 characters)
type ReconcileInput = {
  readonly source: string;
  readonly observations: readonly Observation[];
  readonly items: readonly Item[];
  readonly traces: readonly Trace[];
  readonly policy: Policy;
  /** The instant the read was made, which the events made of it carry. */
  readonly now: Instant;
  /** The wall time in milliseconds, for the clock. */
  readonly wallMs: number;
  readonly clock: Clock;
  /** The source as an actor. */
  readonly actor: ToolActor;
};

What reconcile is given.

Classedtypeno test imports it
type Classed = { readonly fingerprint: string; readonly class: BaselineClass; readonly item: ItemId | undefined };

How an observation ended, for the report.

Reconciledtypeno test imports it
type Reconciled = {
  readonly events: readonly ItemEvent[];
  /** The traces to write: new, changed or made absent. */
  readonly traces: readonly Trace[];
  readonly links: readonly Link[];
  readonly conflicts: readonly Conflict[];
  readonly classes: readonly Classed[];
  readonly clock: Clock;
};

What reconcile gives: data, and the clock after the ids it made.

ReconcileProblemtypeno test imports it
type ReconcileProblem =
  | { readonly kind: "id"; readonly problem: IdProblem }
  | { readonly kind: "clock"; readonly problem: ClockProblem }
  | { readonly kind: "event"; readonly problem: EventProblem }
  | { readonly kind: "time"; readonly problem: TimeProblem };

Why reconcile cannot go on.

stateKeyfunctionno test imports it
function stateKey(s: ObservedState | State): string

The state a place says, as the item's state says it, for comparing.

reconcilefunctionno test imports it
function reconcile(input: ReconcileInput): Promise<Result<Reconciled, ReconcileProblem>>

Reconciles what a source read with the store: events, traces, links, conflicts and classes, as data.

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