governance.ProblemLeveltypeno test imports ittype ProblemLevel = "fail" | "warn" | "pending" | "action";How serious a problem is: fail and warn are problems; pending waits on time or someone else; action is the person's to take.
What a run found, as the one contract every headless program shares (commons headless 0002-headless-governance FR-008): a problem has one of four levels, a stable code that can be searched for and written down, a message, and the one step that fixes it. A failure and a warning are problems; pending is something not set up yet that is expected until someone does it; action is a step that is the person's to take. Neither of the last two is wrong, so neither is a failure.
import { countsOf, isProblemCode, problem } from "./problems.ts";
const p = problem("fail", "the disk is full", { code: "E105-DISK", fix: "df -h" });
isProblemCode(p.code); // true
countsOf([p]); // { fail: 1, warn: 0, pending: 0, action: 0 }governance.ProblemLeveltypeno test imports ittype ProblemLevel = "fail" | "warn" | "pending" | "action";How serious a problem is: fail and warn are problems; pending waits on time or someone else; action is the person's to take.
governance.PROBLEM_LEVELSconstno test imports itconst PROBLEM_LEVELS: readonly ProblemLevel[]Every level, in the order a closing block shows them.
governance.Problemtypeno test imports ittype Problem = {
readonly level: ProblemLevel;
/** What happened, in a plain sentence. */
readonly message: string… (693 characters)type Problem = {
readonly level: ProblemLevel;
/** What happened, in a plain sentence. */
readonly message: string;
/** The phase it happened in, where the run has phases. */
readonly phase?: string;
/** How to fix it (for `pending` and `action`: the next step): one command, or a sentence that holds one. */
readonly fix?: string;
/** A stable code: `E` for a problem, `P` for something pending, then letters and digits and dashes. */
readonly code?: string;
/** The raw text of a system error, when `message` is its plain sentence: shown with `--verbose`. */
readonly raw?: string;
/** Its line in the run's log, where there is one. */
readonly logLine?: number;
};A problem a run found.
governance.ProblemFieldstypeno test imports ittype ProblemFields = {
readonly phase?: string;
readonly fix?: string;
readonly code?: string;
readonly raw?: string;
readonly logLine?: number;
};A problem's optional fields, given by name.
governance.problemfunctionno test imports itfunction problem(level: ProblemLevel, message: string, fields?: ProblemFields): ProblemA problem, made with only the fields that are given (a field never holds undefined).
governance.isProblemCodefunctionno test imports itfunction isProblemCode(text: unknown): text is stringWhether a value is a stable problem code.
governance.isPendingCodefunctionno test imports itfunction isPendingCode(code: string): booleanWhether a code is the code of a pending thing (P...), which is never a failure.
governance.GenericCodestypeno test imports ittype GenericCodes = Readonly<Record<ProblemLevel, string>>;The codes a problem carries when its raiser gave none: one per level, a program's own to configure.
governance.DEFAULT_GENERIC_CODESconstno test imports itconst DEFAULT_GENERIC_CODES: Readonly<Record<ProblemLevel, string>>The generic codes of a program that has no numbers of its own.
governance.withCodefunctionno test imports itfunction withCode(p: Problem, generic?: Readonly<Record<ProblemLevel, string>>): ProblemThe problem with the code of its level where it has none.
governance.countsOffunctionno test imports itfunction countsOf(problems: readonly Problem[]): CountsHow many problems of each level.
governance.ofLevelfunctionno test imports itfunction ofLevel(problems: readonly Problem[], level: ProblemLevel): readonly Problem[]The problems of a level, in the order found.
ProblemLeveltypetype ProblemLevel = "fail" | "warn" | "pending" | "action";How serious a problem is: fail and warn are problems; pending waits on time or someone else; action is the person's to take.
PROBLEM_LEVELSconstconst PROBLEM_LEVELS: readonly ProblemLevel[]Every level, in the order a closing block shows them.
Problemtypetype Problem = {
readonly level: ProblemLevel;
/** What happened, in a plain sentence. */
readonly message: string… (693 characters)type Problem = {
readonly level: ProblemLevel;
/** What happened, in a plain sentence. */
readonly message: string;
/** The phase it happened in, where the run has phases. */
readonly phase?: string;
/** How to fix it (for `pending` and `action`: the next step): one command, or a sentence that holds one. */
readonly fix?: string;
/** A stable code: `E` for a problem, `P` for something pending, then letters and digits and dashes. */
readonly code?: string;
/** The raw text of a system error, when `message` is its plain sentence: shown with `--verbose`. */
readonly raw?: string;
/** Its line in the run's log, where there is one. */
readonly logLine?: number;
};A problem a run found.
ProblemFieldstypeno test imports ittype ProblemFields = {
readonly phase?: string;
readonly fix?: string;
readonly code?: string;
readonly raw?: string;
readonly logLine?: number;
};A problem's optional fields, given by name.
problemfunctionfunction problem(level: ProblemLevel, message: string, fields?: ProblemFields): ProblemA problem, made with only the fields that are given (a field never holds undefined).
isProblemCodefunctionfunction isProblemCode(text: unknown): text is stringWhether a value is a stable problem code.
isPendingCodefunctionfunction isPendingCode(code: string): booleanWhether a code is the code of a pending thing (P...), which is never a failure.
GenericCodestypeno test imports ittype GenericCodes = Readonly<Record<ProblemLevel, string>>;The codes a problem carries when its raiser gave none: one per level, a program's own to configure.
const DEFAULT_GENERIC_CODES: Readonly<Record<ProblemLevel, string>>The generic codes of a program that has no numbers of its own.
withCodefunctionfunction withCode(p: Problem, generic?: Readonly<Record<ProblemLevel, string>>): ProblemThe problem with the code of its level where it has none.
countsOffunctionfunction countsOf(problems: readonly Problem[]): CountsHow many problems of each level.
ofLevelfunctionfunction ofLevel(problems: readonly Problem[], level: ProblemLevel): readonly Problem[]The problems of a level, in the order found.