IF Commons GitHub

logical/judge

Written to: 4 requirements: 4 proved, 0 partly, 0 failing, 0 with no test recorded. 0002-change-control-policy FR-001, 0002-change-control-policy FR-002, 0002-change-control-policy FR-003, 0002-change-control-policy FR-004

The judgement of a range of changes: the policy parsed with every reason it is refused, the allowed_signers text Git verifies with, and each commit accepted, refused (not signed by a signer of the fleet) or blocked (it changes a controlled path and no different signer of an approving role has approved it, by a commit that says Approves: <commit> in a line of its own). A merge is judged by its parents. Nothing here runs Git.

import { judgeRange } from "./judge.ts";
judgeRange([], { signers: [], controlled: [] }); // { accepted: [], refused: [], blocked: [], ok: true, verdicts: [] }

Source: commons/change-control/src/logical/judge.ts

5 of 14 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.allowedSignersfunctionno test imports it
function allowedSigners(signers: readonly Signer[]): string

The text of an allowed_signers file that Git verifies with (gpg.ssh.allowedSignersFile): a line for each signer, the name as the principal, for signatures made for Git.

logical.judgeRangefunctionno test imports it
function judgeRange(commits: readonly Commit[], policy: Policy): Judgement

Each commit of a range, oldest first, accepted, refused or blocked by the policy; a range is ok where every commit is accepted. An approval is a later commit of the range, signed by a signer who is not the signer of the commit approved and whose role the controlled path names.

logical.matchesfunctionno test imports it
function matches(pattern: string, path: string): boolean

Whether a path is one a pattern names (* any characters but /, ** any characters).

logical.parsePolicyfunctionno test imports it
function parsePolicy(input: unknown): Result<Policy, readonly string[]>

A policy from what a fleet wrote, or every reason it is refused (a signer with no name, a role or a key Git can use, one named twice, a controlled path that names an approver no signer has).

logical.Committypeno test imports it
type Commit = { readonly sha: string; readonly author: string; readonly subject: string; readonly body: string; readonly files: readonly string[]; readonly signature: SignatureState; readonly signer: string; readonly at?: string };

A commit as read: its identity, who it says made it, what it says, the paths it changed, the state of its signature and the signer Git found (the principal of the allowed_signers line).

logical.Judgementtypeno test imports it
type Judgement = { readonly verdicts: readonly Verdict[]; readonly accepted: readonly string[]; readonly refused: readonly string[]; readonly blocked: readonly string[]; readonly ok: boolean };

What was found of a range.

logical.Verdicttypeno test imports it
type Verdict = { readonly sha: string; readonly subject: string; readonly state: "accepted" | "refused" | "blocked"; readonly signer: string; readonly reasons: readonly string[]; readonly controlled: readonly string[]; readonly approvedBy: string | undefined };

What was found of one commit.

allowedSignersfunction
function allowedSigners(signers: readonly Signer[]): string

The text of an allowed_signers file that Git verifies with (gpg.ssh.allowedSignersFile): a line for each signer, the name as the principal, for signatures made for Git.

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

judgeRangefunction
function judgeRange(commits: readonly Commit[], policy: Policy): Judgement

Each commit of a range, oldest first, accepted, refused or blocked by the policy; a range is ok where every commit is accepted. An approval is a later commit of the range, signed by a signer who is not the signer of the commit approved and whose role the controlled path names.

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

matchesfunction
function matches(pattern: string, path: string): boolean

Whether a path is one a pattern names (* any characters but /, ** any characters).

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

parsePolicyfunction
function parsePolicy(input: unknown): Result<Policy, readonly string[]>

A policy from what a fleet wrote, or every reason it is refused (a signer with no name, a role or a key Git can use, one named twice, a controlled path that names an approver no signer has).

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

Committype
type Commit = { readonly sha: string; readonly author: string; readonly subject: string; readonly body: string; readonly files: readonly string[]; readonly signature: SignatureState; readonly signer: string; readonly at?: string };

A commit as read: its identity, who it says made it, what it says, the paths it changed, the state of its signature and the signer Git found (the principal of the allowed_signers line).

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

Judgementtypeno test imports it
type Judgement = { readonly verdicts: readonly Verdict[]; readonly accepted: readonly string[]; readonly refused: readonly string[]; readonly blocked: readonly string[]; readonly ok: boolean };

What was found of a range.

Verdicttypeno test imports it
type Verdict = { readonly sha: string; readonly subject: string; readonly state: "accepted" | "refused" | "blocked"; readonly signer: string; readonly reasons: readonly string[]; readonly controlled: readonly string[]; readonly approvedBy: string | undefined };

What was found of one commit.

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