IF Commons GitHub

logical/truth

Written to: 2 requirements: 2 proved, 0 partly, 0 failing, 0 with no test recorded. 0003-estate-logical FR-003, 0003-estate-logical FR-004

Operational truth: for an asset, what is declared of it, what is observed of it, what differs between them and how old the observation is; and the assets seen that nobody declared, and the ones declared that were never seen. A discovered asset has nothing declared and is never aligned, so only its age is told; an asset never observed is never-observed, never a match.

import { unexpectedAssets } from "./truth.ts";
unexpectedAssets(["olympia"], ["olympia", "printer"]); // { unexpected: ["printer"], unseen: [] }

Source: commons/estate/src/logical/truth.ts

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

Observationtypeno test imports it
type Observation = { readonly at: string; readonly source: string; readonly state: Readonly<Record<string, Json>> };

What was observed of an asset: when, by what (the source the observation is attributed to: a probe, an agent, a connector), and the keyed records seen. No evidence without attribution (OTO).

Currencytypeno test imports it
type Currency = "fresh" | "due" | "stale" | "never-observed";

How current an observation is: as fresh, due or stale by grc, or never-observed.

Alignmenttypeno test imports it
type Alignment = "aligned" | "drifted" | "not-observed";

The alignment of an asset (OTO oto:AlignmentState): aligned where what is declared and what is observed agree, drifted where they differ and not-observed where nothing was observed, which waits and is never a failure.

Truthtypeno test imports it
type Truth = { readonly asset: string; readonly state: Asset["state"]; readonly observedAt: string | null; reado… (804 characters)
type Truth = {
  readonly asset: string;
  readonly state: Asset["state"];
  readonly observedAt: string | null;
  readonly currency: Currency;
  /** What differs between what is declared and what is observed; nothing where nothing was observed or nothing is declared. */
  readonly difference: Drift | null;
  /** Whether what is declared and what is observed agree: false where they differ, and false where nothing was observed. */
  readonly agrees: boolean;
  /** The alignment: `not-observed` where nothing was observed, `aligned` where it agrees, `drifted` where it does not; a discovered asset has nothing declared and is `not-observed`. */
  readonly alignment: Alignment;
  /** What was observed was attributed to this source, where anything was observed. */
  readonly source: string | null;
};

The operational truth of one asset.

TruthInputtypeno test imports it
type TruthInput = {
  readonly asset: Asset;
  readonly declared: Readonly<Record<string, Json>>;
  readonly observed: Observation | undefined;
  readonly now: string;
  readonly within: string;
};

What is declared of an asset, what was observed, the instant now and how long an observation is good for (an ISO 8601 duration).

operationalTruthfunction
function operationalTruth(i: TruthInput): Result<Truth, string>

The operational truth of an asset, or why it cannot be told (a duration or an instant that is not one).

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

unexpectedAssetsfunction
function unexpectedAssets(declared: readonly string[], seen: readonly string[]): { readonly unexpected: readonly string[]; readonly unseen: readonly string[]; }

The assets seen that no declaration expects (they are candidates to be discovered), and those declared and not seen, each in order.

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

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