IF Commons GitHub

logical/commit

Written to: 1 requirement: 1 proved, 0 partly, 0 failing, 0 with no test recorded. 0005-repoctl-library-commit-doctor FR-004

repoctl commit (commons repoctl 0005-repoctl-library-commit-doctor FR-004 to FR-007): the commit of this repository, made one way. The author and the committer are the identity of the repository's configuration, the message is the subject and then the trailers the configuration lists (the reference to an issue, the line that credits the agent, the session) on their own lines, files that must not be committed (the local folder of an agent, installed packages, files that look like secrets) are refused by their paths and by what they say, and the generated files are checked first (before anything is staged), so that no commit leaves one stale. Pure where it can be: the message and the refusals are functions of their inputs.

import { DEFAULT_ALLOWED_PATHS, DEFAULT_FORBIDDEN_PATHS } from "@intellectual-frontiers/repoctl/governance";
import { forbidden, messageOf } from "./commit.ts";
forbidden({ paths: DEFAULT_FORBIDDEN_PATHS, allow: DEFAULT_ALLOWED_PATHS, secrets: [] }, ".claude/settings.json"); // "the local folder of an agent (.claude/)"
messageOf({ issue: { prefix: "Refs #", required: false }, trailers: ["issue"] }, { subject: "Add", refs: "10", coAuthor: undefined, session: undefined }).trailers; // ["Refs #10"]

Source: commons/repoctl/src/logical/commit.ts

4 of 16 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.CommitInputtypeno test imports it
type CommitInput = { readonly subject: CommitSubject; readonly refs: IssueNumber | undefined; /** The impact the c… (646 characters)
type CommitInput = {
  readonly subject: CommitSubject;
  readonly refs: IssueNumber | undefined;
  /** The impact the commit states on its `Impact:` line, where the policy has the trailer and the commit gives one. */
  readonly impact: CommitImpact | undefined;
  /** The address of the session, where the policy has the trailer. */
  readonly session: SessionUrl | undefined;
  /** The line that credits the agent, where the policy has the trailer. */
  readonly coAuthor: string | undefined;
  /** Paths to stage first (the files already staged are committed in any case). */
  readonly paths: readonly string[];
  readonly dryRun: boolean;
};

What a commit is made of.

logical.Messagetypeno test imports it
type Message = { readonly subject: string; readonly trailers: readonly string[] };

The message of a commit: the subject, and the trailers, each a line.

logical.messageOffunctionno test imports it
function messageOf(policy: Pick<CommitPolicy, "issue" | "trailers">, input: { readonly subject: string; readonly refs: string | undefined; readonly impact?: string | undefined; readonly coAuthor: string | undefined; readonly session: string | undefined; }): Message

The message: the subject, then the trailers the policy lists, in its order, each a line: the reference to an issue (the policy's prefix and the number), Impact: and the impact, the line that credits the agent, and Claude-Session. A trailer whose value is not given is left out.

logical.messageTextfunctionno test imports it
function messageText(m: Message): string

The message as Git is given it: the subject, a blank line, and the trailers on lines of their own.

logical.forbiddenfunctionno test imports it
function forbidden(policy: { readonly paths: readonly ForbiddenPath[]; readonly allow: readonly string[]; readonly secrets: readonly SecretPattern[]; }, path: string): string | undefined

Why a path must not be committed under the policy, or undefined where it may be: a forbidden glob matches it and no allowed glob does.

logical.secretLikefunctionno test imports it
function secretLike(policy: { readonly paths: readonly ForbiddenPath[]; readonly allow: readonly string[]; readonly secrets: readonly SecretPattern[]; }, text: string): string | undefined

What a text holds that looks like a secret under the policy, or undefined where it holds none.

logical.CommitReporttypeno test imports it
type CommitReport =
  | { readonly kind: "refused"; readonly findings: readonly Finding[] }
  | { readonly kind: "preview"; readonly message: string; readonly files: readonly string[] }
  | { readonly kind: "committed"; readonly message: string; readonly files: readonly string[]; readonly sha: string };

What a commit came to.

logical.runCommitfunctionno test imports it
function runCommit(w: Pick<World, "files" | "process" | "repo">, input: CommitInput, order: readonly Generator[], policy: CommitPolicy): Promise<CommitReport>

Makes the commit: stages the paths, refuses what must not be committed, checks the generated files, and commits as the repository's identity.

CommitInputtypeno test imports it
type CommitInput = { readonly subject: CommitSubject; readonly refs: IssueNumber | undefined; /** The impact the c… (646 characters)
type CommitInput = {
  readonly subject: CommitSubject;
  readonly refs: IssueNumber | undefined;
  /** The impact the commit states on its `Impact:` line, where the policy has the trailer and the commit gives one. */
  readonly impact: CommitImpact | undefined;
  /** The address of the session, where the policy has the trailer. */
  readonly session: SessionUrl | undefined;
  /** The line that credits the agent, where the policy has the trailer. */
  readonly coAuthor: string | undefined;
  /** Paths to stage first (the files already staged are committed in any case). */
  readonly paths: readonly string[];
  readonly dryRun: boolean;
};

What a commit is made of.

Messagetypeno test imports it
type Message = { readonly subject: string; readonly trailers: readonly string[] };

The message of a commit: the subject, and the trailers, each a line.

messageOffunction
function messageOf(policy: Pick<CommitPolicy, "issue" | "trailers">, input: { readonly subject: string; readonly refs: string | undefined; readonly impact?: string | undefined; readonly coAuthor: string | undefined; readonly session: string | undefined; }): Message

The message: the subject, then the trailers the policy lists, in its order, each a line: the reference to an issue (the policy's prefix and the number), Impact: and the impact, the line that credits the agent, and Claude-Session. A trailer whose value is not given is left out.

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

messageTextfunction
function messageText(m: Message): string

The message as Git is given it: the subject, a blank line, and the trailers on lines of their own.

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

forbiddenfunction
function forbidden(policy: { readonly paths: readonly ForbiddenPath[]; readonly allow: readonly string[]; readonly secrets: readonly SecretPattern[]; }, path: string): string | undefined

Why a path must not be committed under the policy, or undefined where it may be: a forbidden glob matches it and no allowed glob does.

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

secretLikefunction
function secretLike(policy: { readonly paths: readonly ForbiddenPath[]; readonly allow: readonly string[]; readonly secrets: readonly SecretPattern[]; }, text: string): string | undefined

What a text holds that looks like a secret under the policy, or undefined where it holds none.

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

CommitReporttypeno test imports it
type CommitReport =
  | { readonly kind: "refused"; readonly findings: readonly Finding[] }
  | { readonly kind: "preview"; readonly message: string; readonly files: readonly string[] }
  | { readonly kind: "committed"; readonly message: string; readonly files: readonly string[]; readonly sha: string };

What a commit came to.

runCommitfunctionno test imports it
function runCommit(w: Pick<World, "files" | "process" | "repo">, input: CommitInput, order: readonly Generator[], policy: CommitPolicy): Promise<CommitReport>

Makes the commit: stages the paths, refuses what must not be committed, checks the generated files, and commits as the repository's identity.

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