IF Commons GitHub

logical/preview

Written to: 1 requirement: 0 proved, 0 partly, 0 failing, 1 with no test recorded. 0003-planning-reconcile FR-010

The plan of a patch and its preview (0037-planning FR-011, FR-032): a plan is what a source would write to carry a patch out, effect by effect (a target, the revision it expects, the text it makes and a sentence); a preview is that, with the SHA-256 of the plan as its hash. A write is held to a hash: with none it is a dry run, with another it is refused, and with the hash of the plan it is that plan.

import { decide, previewOf } from "./preview.ts";
// const p = await previewOf(plan); (await decide(plan, undefined)).kind === "dry-run"

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

0 of 13 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.Effecttypeno test imports it
type Effect = { readonly target: string; readonly expect: string | null; readonly after: string; readonly summary: string };

One thing a plan writes: where, the revision it expects of what is there (none where it must be absent), the text, and a sentence.

logical.Plantypeno test imports it
type Plan = { readonly source: string; readonly place: string; readonly patch: Patch; readonly effects: readonly Effect[] };

What a source would write to carry a patch out.

logical.Previewtypeno test imports it
type Preview = {
  readonly source: string;
  readonly place: string;
  readonly effects: readonly { readonly target: string; readonly expect: string | null; readonly afterHash: string; readonly summary: string }[];
  readonly hash: string;
};

What a plan says it writes, with the hash a write is held to.

logical.previewOffunctionno test imports it
function previewOf(plan: Plan): Promise<Preview>

The preview of a plan.

logical.Decisiontypeno test imports it
type Decision =
  | { readonly kind: "dry-run"; readonly preview: Preview }
  | { readonly kind: "apply"; readonly preview: Preview }
  | { readonly kind: "stale"; readonly given: string; readonly preview: Preview };

What a write asked for with a hash comes to.

logical.decidefunctionno test imports it
function decide(plan: Plan, given: string | undefined): Promise<Decision>

A write is a dry run unless it names the hash of the preview of the plan, and a hash that is not that of the plan is refused.

logical.changesfunctionno test imports it
function changes(plan: Plan): boolean

Whether a plan changes anything.

Effecttypeno test imports it
type Effect = { readonly target: string; readonly expect: string | null; readonly after: string; readonly summary: string };

One thing a plan writes: where, the revision it expects of what is there (none where it must be absent), the text, and a sentence.

Plantypeno test imports it
type Plan = { readonly source: string; readonly place: string; readonly patch: Patch; readonly effects: readonly Effect[] };

What a source would write to carry a patch out.

Previewtypeno test imports it
type Preview = {
  readonly source: string;
  readonly place: string;
  readonly effects: readonly { readonly target: string; readonly expect: string | null; readonly afterHash: string; readonly summary: string }[];
  readonly hash: string;
};

What a plan says it writes, with the hash a write is held to.

previewOffunctionno test imports it
function previewOf(plan: Plan): Promise<Preview>

The preview of a plan.

decidefunctionno test imports it
function decide(plan: Plan, given: string | undefined): Promise<Decision>

A write is a dry run unless it names the hash of the preview of the plan, and a hash that is not that of the plan is refused.

changesfunctionno test imports it
function changes(plan: Plan): boolean

Whether a plan changes anything.

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