IF Commons GitHub

governance/asset

Written to: 2 requirements: 2 proved, 0 partly, 0 failing, 0 with no test recorded. 0002-estate-governance FR-004, 0002-estate-governance FR-005

An asset: its identity, kind and state, and for every capability either the system that owns it or the reason it is not offered, so that nothing is silently dropped. An asset is refused where it names an owner for a capability its state does not offer, or leaves a capability it does offer with no owner.

import { defineAsset } from "./asset.ts";
const a = defineAsset({ id: "athens", kind: "server", state: "adopted", origin: "paired", owners: { observe: "archon", verify: "archon" } });
a.kind; // "ok"

Source: commons/estate/src/governance/asset.ts

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

AssetInputtypeno test imports it
type AssetInput = { readonly id: string; readonly kind: string; readonly state: AssetState; /** Where it came fr… (618 characters)
type AssetInput = {
  readonly id: string;
  readonly kind: string;
  readonly state: AssetState;
  /** Where it came from; a managed asset is `provisioned` by default, and only a managed asset can be. An asset that is not provisioned was installed by someone else. */
  readonly origin?: Origin;
  /** For each capability the state offers, the system that owns it. */
  readonly owners: Readonly<Partial<Record<Capability, string>>>;
  /** The attributes of the asset, checked against the catalog of its kind where the kind has one (`kinds.ts`). */
  readonly attributes?: Readonly<Record<string, AttributeValue>>;
};

What defineAsset takes.

CapabilityLinetypeno test imports it
type CapabilityLine =
  | { readonly capability: Capability; readonly offered: true; readonly owner: SystemId }
  | { readonly capability: Capability; readonly offered: false; readonly reason: string };

One capability of an asset: offered and owned, or not offered with the reason.

Assettype
type Asset = { readonly id: AssetId; readonly kind: AssetKind; readonly state: AssetState; /** Where it came fro… (431 characters)
type Asset = {
  readonly id: AssetId;
  readonly kind: AssetKind;
  readonly state: AssetState;
  /** Where it came from, where that is known. */
  readonly origin?: Origin;
  /** The attributes it states, checked against the catalog of its kind. */
  readonly attributes?: Readonly<Record<string, AttributeValue>>;
  /** Every capability, in the order of the closed list. */
  readonly capabilities: readonly CapabilityLine[];
};

An asset.

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

installOffunction
function installOf(asset: Asset): Install

Who installed the asset: the system, where its origin is provisioned, or someone else (inherited) for every other asset.

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

ownerOffunction
function ownerOf(asset: Asset, capability: "access" | "backup" | "converge" | "identity" | "observe" | "plan" | "provision" | "retire" | "update" | "verify"): SystemId | undefined

The owner of a capability of an asset, or nothing where it is not offered.

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

defineAssetfunction
function defineAsset(input: AssetInput): Result<Asset, readonly string[]>

An asset from its input, or every reason it is refused.

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

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