IF Commons GitHub

logical/config

Written to: 1 requirement: 0 proved, 0 partly, 0 failing, 1 with no test recorded. 0005-planning-surfaces FR-001

The configuration of Planning (0037-planning FR-037, FR-045): a typed value a repository writes in planning.config.ts with definePlanning (the identity, as defineConfig of repoctl is), and parsePlanning, the one reader, which returns a Result that names the field of a bad value and refuses a field that is not in the type. This is the pure part: the file is imported by the physical layer, and JSON or YAML is never read. With it, who runs the work: contextOf takes the person a session, an argument or the configuration names, in that order, and says which, so that an agent's principal is established and never guessed.

import { definePlanning, parsePlanning } from "./config.ts";
const c = definePlanning({ store: { place: "planning/" }, sources: [{ name: "markdown", place: "docs/" }] });
parsePlanning(c).kind; // "ok"

Source: commons/planning/src/logical/config.ts

0 of 18 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.SourceConfigtypeno test imports it
type SourceConfig = | { readonly name: "markdown"; readonly place: string } | { readonly name: "comments"; readonly … (471 characters)
type SourceConfig =
  | { readonly name: "markdown"; readonly place: string }
  | { readonly name: "comments"; readonly place: string; readonly markers?: readonly string[]; readonly anchors?: readonly string[] }
  | { readonly name: "issues"; readonly place: string; readonly scope: string }
  | { readonly name: "event-files"; readonly place: string }
  | { readonly name: "githost"; readonly place: string; readonly issues?: readonly number[]; readonly repo?: string };

A source of the configuration: its name and where it reads.

logical.RenderFormattypeno test imports it
type RenderFormat = "markdown" | "json5";

The formats a rendering may be in.

logical.PlanningConfigtypeno test imports it
type PlanningConfig = { /** Who runs the work: an argument of the run overrides it. */ readonly principal?: { readon… (1045 characters)
type PlanningConfig = {
  /** Who runs the work: an argument of the run overrides it. */
  readonly principal?: { readonly id: string; readonly name?: string };
  /** `any-person` (the default) or `principal`: who confirms a proposal. */
  readonly confirmers?: "any-person" | "principal";
  /** Where the store of events is: a folder of the repository. */
  readonly store: { readonly place: string };
  readonly sources: readonly SourceConfig[];
  /** The authority over each field. */
  readonly authority?: { readonly [F in AuthorityField]?: FieldAuthority };
  readonly duplicates?: { readonly threshold: number };
  readonly clock?: { readonly maxDriftMs: number };
  /** The ids that are agents acting for a person (0037-planning FR-044). */
  readonly agents?: { readonly [id: string]: { readonly actsFor: string } };
  /** Whether the author of a commit with a `Co-Authored-By` trailer is the principal of an agent's event (0037-planning FR-045). */
  readonly commitAuthorRule?: boolean;
  readonly render?: readonly RenderFormat[];
};

The configuration of a repository.

logical.definePlanningconstno test imports it
const definePlanning: (config: PlanningConfig) => PlanningConfig

The identity: it only gives the type to the value written.

logical.ConfigProblemtypeno test imports it
type ConfigProblem = { readonly path: string; readonly expected: string };

Why a value is not a configuration: the path of the field and what was expected.

logical.parsePlanningfunctionno test imports it
function parsePlanning(value: unknown): Result<PlanningConfig, ConfigProblem>

A configuration from a value, or the field that is wrong and what it should be.

logical.principalOffunctionno test imports it
function principalOf(config: Pick<PlanningConfig, "principal">): PersonActor | undefined

The person a configuration names as the principal, or none.

logical.WhoRunstypeno test imports it
type WhoRuns = { readonly session?: PersonActor; readonly argument?: PersonActor; readonly configuration?: PersonActor };

What names who runs the work.

logical.contextOffunctionno test imports it
function contextOf(who: WhoRuns): RunContext

The context of a run: the person of the session where there is one (a tool server's), else the person an argument names, else the configuration's; none where nothing names one. An argument overrides the configuration, and a tool server takes only its session.

SourceConfigtypeno test imports it
type SourceConfig = | { readonly name: "markdown"; readonly place: string } | { readonly name: "comments"; readonly … (471 characters)
type SourceConfig =
  | { readonly name: "markdown"; readonly place: string }
  | { readonly name: "comments"; readonly place: string; readonly markers?: readonly string[]; readonly anchors?: readonly string[] }
  | { readonly name: "issues"; readonly place: string; readonly scope: string }
  | { readonly name: "event-files"; readonly place: string }
  | { readonly name: "githost"; readonly place: string; readonly issues?: readonly number[]; readonly repo?: string };

A source of the configuration: its name and where it reads.

RenderFormattypeno test imports it
type RenderFormat = "markdown" | "json5";

The formats a rendering may be in.

PlanningConfigtypeno test imports it
type PlanningConfig = { /** Who runs the work: an argument of the run overrides it. */ readonly principal?: { readon… (1045 characters)
type PlanningConfig = {
  /** Who runs the work: an argument of the run overrides it. */
  readonly principal?: { readonly id: string; readonly name?: string };
  /** `any-person` (the default) or `principal`: who confirms a proposal. */
  readonly confirmers?: "any-person" | "principal";
  /** Where the store of events is: a folder of the repository. */
  readonly store: { readonly place: string };
  readonly sources: readonly SourceConfig[];
  /** The authority over each field. */
  readonly authority?: { readonly [F in AuthorityField]?: FieldAuthority };
  readonly duplicates?: { readonly threshold: number };
  readonly clock?: { readonly maxDriftMs: number };
  /** The ids that are agents acting for a person (0037-planning FR-044). */
  readonly agents?: { readonly [id: string]: { readonly actsFor: string } };
  /** Whether the author of a commit with a `Co-Authored-By` trailer is the principal of an agent's event (0037-planning FR-045). */
  readonly commitAuthorRule?: boolean;
  readonly render?: readonly RenderFormat[];
};

The configuration of a repository.

definePlanningconstno test imports it
const definePlanning: (config: PlanningConfig) => PlanningConfig

The identity: it only gives the type to the value written.

ConfigProblemtypeno test imports it
type ConfigProblem = { readonly path: string; readonly expected: string };

Why a value is not a configuration: the path of the field and what was expected.

parsePlanningfunctionno test imports it
function parsePlanning(value: unknown): Result<PlanningConfig, ConfigProblem>

A configuration from a value, or the field that is wrong and what it should be.

principalOffunctionno test imports it
function principalOf(config: Pick<PlanningConfig, "principal">): PersonActor | undefined

The person a configuration names as the principal, or none.

WhoRunstypeno test imports it
type WhoRuns = { readonly session?: PersonActor; readonly argument?: PersonActor; readonly configuration?: PersonActor };

What names who runs the work.

contextOffunctionno test imports it
function contextOf(who: WhoRuns): RunContext

The context of a run: the person of the session where there is one (a tool server's), else the person an argument names, else the configuration's; none where nothing names one. An argument overrides the configuration, and a tool server takes only its session.

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