Observationtypeno test imports ittype Observation = { readonly state: "absent" } | { readonly state: "present"; readonly value: JsonValue };What is observed of one resource: not there, or there with this state.
The plan: what differs between what is observed of a subject and its order. One entry for each requirement of the order says whether its resource is already as it must be, must be made, must be changed or must be removed. A plan has a canonical text and a digest (the SHA-256 of it), so that a person can approve exactly one plan and any change of any entry changes the digest.
import { planOrder } from "./plan.ts";
// planOrder(order, new Map()) gives an entry `create` for each requirement that must be presentObservationtypeno test imports ittype Observation = { readonly state: "absent" } | { readonly state: "present"; readonly value: JsonValue };What is observed of one resource: not there, or there with this state.
Observedtypetype Observed = ReadonlyMap<RequirementId, JsonValue>;The observed state of the resources of a subject, by requirement; a requirement with no entry is observed absent.
PlanActiontypeno test imports ittype PlanAction = "none" | "create" | "update" | "remove";What a plan does to a resource.
PlanEntrytypeno test imports ittype PlanEntry = {
readonly id: RequirementId;
readonly kind: ResourceKindId;
readonly action: PlanAction;
readonly change: ChangeClass;
readonly tier: string;
readonly observed: Observation;
readonly desired: Observation;
};One entry of a plan.
Plantypetype Plan = {
readonly format: "archon-plan/1";
readonly subject: Subject;
readonly entries: readonly PlanEntry[];
};A plan.
planOrderfunctionfunction planOrder(order: Order, observed: Observed): PlanThe plan that brings what is observed to the order: one entry for each requirement, in the order of the sequence.
changesOffunctionfunction changesOf(plan: Plan): readonly PlanEntry[]The entries of a plan that change something.
canonicalPlanfunctionfunction canonicalPlan(plan: Plan): stringThe canonical text of a plan: the same plan is the same text on every machine whatever the order its keys were made in.
planDigestfunctionfunction planDigest(plan: Plan): Promise<Sha256>The digest of a plan: the SHA-256 of its canonical text.