IF Commons GitHub

logical/arming

Written to: 1 requirement: 1 proved, 0 partly, 0 failing, 0 with no test recorded. 0003-netboot-logical FR-002

The arming of a host for one install: a host is armed with a token that the install's URLs carry, and stays armed until the installer says it is done, so that a machine is not reinstalled by its next network boot. The state is a plain value: what is armed, what has installed (and from which MAC), and the progress of installs. Every change is a function that gives a new value.

import { arm, emptyState, isArmed } from "./arming.ts";
isArmed(arm(emptyState(), "athens", { token: "t", at: "2026-11-21T00:00:00Z" }), "athens"); // true

Source: commons/netboot/src/logical/arming.ts

9 of 24 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.Armingtypeno test imports it
type Arming = {
  readonly token: string;
  readonly at: string;
  /** A person said that a machine with data on its disks may be erased. */
  readonly confirmDestroy?: boolean;
  /** The MAC that the install is for, where it is known beforehand. */
  readonly mac?: string;
};

What an arming carries.

logical.Progresstypeno test imports it
type Progress = { readonly at: string; readonly host: string; readonly level: string; readonly phase: string; readonly summary: string };

One line of an install's progress, as the installer reported it.

logical.BootStatetypeno test imports it
type BootState = {
  readonly armed: Readonly<Record<string, Arming>>;
  /** Hosts that installed, with the MAC they installed from. */
  readonly installed: Readonly<Record<string, { readonly mac?: string; readonly at: string }>>;
  readonly progress: readonly Progress[];
};

What the boot server remembers.

logical.emptyStatefunctionno test imports it
function emptyState(): BootState

The state of a server that has done nothing yet.

logical.armfunctionno test imports it
function arm(s: BootState, host: string, a: Arming): BootState

The state with a host armed (a host armed again gets the new arming).

logical.disarmfunctionno test imports it
function disarm(s: BootState, host: string): BootState

The state with a host disarmed.

logical.isArmedfunctionno test imports it
function isArmed(s: BootState, host: string): boolean

Whether a host is armed.

logical.tokenFitsfunctionno test imports it
function tokenFits(s: BootState, host: string, token: string): boolean

Whether a token is the one a host is armed with.

logical.donefunctionno test imports it
function done(s: BootState, host: string, mac: string | undefined, at: string): BootState

The state when the installer says it is done: the host is disarmed and recorded as installed from the MAC it booted from.

logical.notefunctionno test imports it
function note(s: BootState, p: Progress): BootState

The state with one more line of progress (the last 200 are kept).

logical.armedHostsfunctionno test imports it
function armedHosts(s: BootState): readonly { readonly host: { readonly name: string; }; readonly token: string; }[]

The armed hosts as the chooser menu lists them, in the order of their names.

logical.newTokenfunctionno test imports it
function newToken(random?: (n: number) => Uint8Array<ArrayBufferLike>): string

A new token: 32 hexadecimal digits from the system's random numbers.

Armingtypeno test imports it
type Arming = {
  readonly token: string;
  readonly at: string;
  /** A person said that a machine with data on its disks may be erased. */
  readonly confirmDestroy?: boolean;
  /** The MAC that the install is for, where it is known beforehand. */
  readonly mac?: string;
};

What an arming carries.

Progresstypeno test imports it
type Progress = { readonly at: string; readonly host: string; readonly level: string; readonly phase: string; readonly summary: string };

One line of an install's progress, as the installer reported it.

BootStatetypeno test imports it
type BootState = {
  readonly armed: Readonly<Record<string, Arming>>;
  /** Hosts that installed, with the MAC they installed from. */
  readonly installed: Readonly<Record<string, { readonly mac?: string; readonly at: string }>>;
  readonly progress: readonly Progress[];
};

What the boot server remembers.

emptyStatefunction
function emptyState(): BootState

The state of a server that has done nothing yet.

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

armfunction
function arm(s: BootState, host: string, a: Arming): BootState

The state with a host armed (a host armed again gets the new arming).

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

disarmfunction
function disarm(s: BootState, host: string): BootState

The state with a host disarmed.

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

isArmedfunction
function isArmed(s: BootState, host: string): boolean

Whether a host is armed.

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

tokenFitsfunction
function tokenFits(s: BootState, host: string, token: string): boolean

Whether a token is the one a host is armed with.

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

donefunction
function done(s: BootState, host: string, mac: string | undefined, at: string): BootState

The state when the installer says it is done: the host is disarmed and recorded as installed from the MAC it booted from.

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

notefunction
function note(s: BootState, p: Progress): BootState

The state with one more line of progress (the last 200 are kept).

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

armedHostsfunction
function armedHosts(s: BootState): readonly { readonly host: { readonly name: string; }; readonly token: string; }[]

The armed hosts as the chooser menu lists them, in the order of their names.

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

newTokenfunction
function newToken(random?: (n: number) => Uint8Array<ArrayBufferLike>): string

A new token: 32 hexadecimal digits from the system's random numbers.

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

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