IF Commons GitHub

logical/lifecycle

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

The life of an asset: a move between states (a discovered asset is adopted, an adopted asset is released back or taken over with an approval; a managed asset is never moved, it is retired), and the move of one capability from one system to another, which is made only when the acceptance test of that capability on that asset has passed. A move down a state gives up the capabilities the lower state does not offer; a move up needs an owner for each new one.

import { moveState } from "./lifecycle.ts";
// moveState(asset, "managed", { converge: "archon", ... }) is a Result of the asset in its new state

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

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

Approvaltypeno test imports it
type Approval = { readonly by: string; readonly planHash: string };

The approval to take an adopted asset over: the person, and the hash of the plan they approved.

moveStatefunction
function moveState(asset: Asset, to: "adopted" | "discovered" | "managed", owners?: Readonly<Partial<Record<"access" | "backup" | "converge" | "identity" | "observe" | "plan" | "provision" | "retire" | "update" | "verify", string>>>, approval?: Approval | undefined): Result<Asset, readonly string[]>

The asset in another state: the owners it had are kept for what the new state still offers (what it does not offer is given up), and owners names the owners of what is new; refused where the move is not allowed or an owner is missing.

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

AcceptanceRecordtype
type AcceptanceRecord = { readonly asset: string; readonly capability: Capability; readonly system: string; readonly test: string; readonly passedAt: string };

A test of a capability of an asset that passed, by the system that is to own it.

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

moveCapabilityfunction
function moveCapability(asset: Asset, capability: "access" | "backup" | "converge" | "identity" | "observe" | "plan" | "provision" | "retire" | "update" | "verify", to: string, acceptance: AcceptanceRecord | undefined): Result<Asset, readonly string[]>

The asset with one capability owned by another system, or why not: it is made only with a passed acceptance test for this asset, this capability and the system that takes it.

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

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