IF Commons GitHub

logical/machine

Written to: 3 requirements: 3 proved, 0 partly, 0 failing, 0 with no test recorded. 0006-machine-verbs FR-001, 0006-machine-verbs FR-002, 0006-machine-verbs FR-003

The two verbs of a machine (commons headless 0006-machine-verbs): machine query takes a query string and machine check a check id, each with a target selector (--on, as any command that may be reached through ssh), and returns the typed outcome of a report. Headless does not learn what a query is: the string is opaque to it, handed to the backend byte for byte, and what answers it (SQL over a database, an osquery schema, a check of governance, risk and compliance) is the backend's, which the program that uses these verbs gives. This module imports neither the data library nor the grc library, and no layer of Headless MAY.

import { machineVerbs } from "./machine.ts";
const verbs = machineVerbs({ query: async () => outcomeOf([]), check: async () => outcomeOf(null) });
verbs.name; // "machine"

Source: commons/headless/src/logical/machine.ts

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

logical.MachineBackendtypeno test imports it
type MachineBackend = {
  /** Answers a query string, which it alone reads. */
  query(query: string, ctx: Context): Promise<Outcome>;
  /** Runs the check with this id. */
  check(id: string, ctx: Context): Promise<Outcome>;
  /** The ids of the checks there are, where the backend knows them, so that a wrong id is told the nearest. */
  checks?(): readonly string[];
};

What answers a machine verb: the program's own (data's queries, grc's checks), given to the verbs.

logical.validCheckIdfunctionno test imports it
function validCheckId(id: string): boolean

Whether a text can stand as a check id: not empty, one line, no NUL.

logical.machineVerbsfunctionno test imports it
function machineVerbs(backend: MachineBackend): Branch

The branch machine with the verbs query and check, answered by the backend.

MachineBackendtypeno test imports it
type MachineBackend = {
  /** Answers a query string, which it alone reads. */
  query(query: string, ctx: Context): Promise<Outcome>;
  /** Runs the check with this id. */
  check(id: string, ctx: Context): Promise<Outcome>;
  /** The ids of the checks there are, where the backend knows them, so that a wrong id is told the nearest. */
  checks?(): readonly string[];
};

What answers a machine verb: the program's own (data's queries, grc's checks), given to the verbs.

validCheckIdfunction
function validCheckId(id: string): boolean

Whether a text can stand as a check id: not empty, one line, no NUL.

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

machineVerbsfunction
function machineVerbs(backend: MachineBackend): Branch

The branch machine with the verbs query and check, answered by the backend.

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

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