PolicyFindingtypeno test imports ittype PolicyFinding = "pass" | "fail" | "warn" | "unknown";What a policy found on a machine: pass, fail, warn (not required, but worth doing) or unknown (cannot tell).
Accepted risk and the status of a policy (Stolos 067-adopt FR-013, 117-adopted-in-status): a person accepts a failing policy of a machine with a reason and a date at most a year away, the policy then shows as accepted and never as passing, and after the date it fails again, saying so. A machine never observed, and a policy that could not tell, are waiting: never a failure and never a warning.
import { acceptRisk, judgePolicy } from "./risk.ts";
const risk = acceptRisk({ policy: "disk-encryption", reason: "holds only open-source code", by: "an owner", until: "2027-03-01" }, "2026-12-01");
risk.kind; // "ok"
judgePolicy({ result: { id: "disk-encryption", status: "fail", controls: ["SC-28"] }, observed: true, accepted: risk.kind === "ok" ? [risk.value] : [], now: "2026-12-02" }).status; // "accepted"PolicyFindingtypeno test imports ittype PolicyFinding = "pass" | "fail" | "warn" | "unknown";What a policy found on a machine: pass, fail, warn (not required, but worth doing) or unknown (cannot tell).
PolicyOutcometypetype PolicyOutcome = { readonly id: string; readonly status: PolicyFinding; readonly controls: readonly string[] };What a policy found, by its id, with the controls it gives evidence for (identifiers of a framework's controls, such as NIST SP 800-53 Rev 5's).
PolicyStatustypeno test imports ittype PolicyStatus = "pass" | "fail" | "warn" | "accepted" | "waiting";The status shown for a policy: accepted is a failing policy a person accepted until a date; waiting is a policy nothing was observed for or that could not tell.
AcceptedRisktypetype AcceptedRisk = { readonly policy: string; readonly reason: string; readonly by: string; readonly until: string };A risk a person accepted: the policy, why, who and until when (a day, YYYY-MM-DD).
acceptRiskfunctionfunction acceptRisk(input: AcceptedRisk, now: string): Result<AcceptedRisk, readonly string[]>An accepted risk, or every reason it is refused: the date is a day after today and within a year (366 days), and the reason is at least ten characters, in words an auditor reads.
JudgedPolicytypeno test imports ittype JudgedPolicy = { readonly id: string; readonly status: PolicyStatus; readonly controls: readonly string[]; readonly detail: string };The status of a policy and why.
JudgeInputtypeno test imports ittype JudgeInput = { readonly result: PolicyOutcome; readonly observed: boolean; readonly accepted: readonly AcceptedRisk[]; readonly now: string };What judgePolicy takes: what the policy found, whether the machine was observed at all, the risks accepted and the instant now.
judgePolicyfunctionfunction judgePolicy(i: JudgeInput): JudgedPolicyThe status of one policy. A machine never observed, and a policy that is unknown, are waiting; a pass stays a pass; a failing or warning policy a person accepted is accepted until the day after its date, and after that it is what it was, with the end of the acceptance said.