IF Commons GitHub

matrix

Written to: 1 requirement: 1 proved, 0 partly, 0 failing, 0 with no test recorded. 0001-kanon-checker FR-014

The matrix of requirement by instance (commons 0033-kanon FR-023): for each annotation of each element of Governance, and for each instance (dialect) of the model, how it ends: expressed, carried or unexpressed with its reason, or dropped where it ends in none (a finding). A typed value, and its two renderings for the documentation lens: Markdown and JSON.

Pure and total. The rows are made from the same reading of the dispositions as the check of dropped annotations (accountOf), so a dropped cell is exactly a kanon/dropped finding. A row is keyed by the element's ElementId and the annotation's name, which are those of the LayeredModel the documentation generator reads, so that a page can link a row to its element. The columns are the model's instances in their order; a model with no instances has no columns and each row has no cells.

import { buildMatrix, matrixMarkdown, type LayeredModel } from "@intellectual-frontiers/kanon";
declare const model: LayeredModel;
matrixMarkdown(buildMatrix(model));

Source: commons/kanon/src/matrix.ts

4 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.

buildMatrixfunction
function buildMatrix(model: LayeredModel): Matrix

The matrix of a model: a row for each annotation of each element of its first layer and a cell for each instance.

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

cellTextfunctionno test imports it
function cellText(cell: Cell): string

The words of a cell, for a table: expressed (by X), carried (by X), unexpressed: the reason, dropped.

Matrixtypeno test imports it
type Matrix = {
  readonly model: string;
  readonly instances: readonly InstanceName[];
  readonly rows: readonly MatrixRow[];
};

The matrix of a model: its instances and the rows.

MatrixCelltypeno test imports it
type MatrixCell = { readonly instance: InstanceName; readonly cell: Cell };

One cell of a row: the instance and how the annotation ends for it.

MatrixRowtypeno test imports it
type MatrixRow = {
  readonly element: ElementId;
  readonly name: string;
  readonly annotation: string;
  readonly cells: readonly MatrixCell[];
};

One row: an annotation of an element of Governance, with a cell for each instance of the matrix, in its order.

matrixJsonfunction
function matrixJson(matrix: Matrix): string

The matrix as JSON text, two spaces to a level and a final newline: the matrix is plain data, so this is the value itself.

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

matrixMarkdownfunction
function matrixMarkdown(matrix: Matrix): string

The matrix as a Markdown table, for the documentation lens: one row for each annotation, one column for each instance, then a line of totals.

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

matrixTotalsfunction
function matrixTotals(matrix: Matrix): Readonly<Record<"carried" | "dropped" | "expressed" | "unexpressed", number>>

How many cells end each way: a registry with an entry for every outcome.

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

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