Skip to content

RollingCapRule

A cap on time in statuses inside a window: “60 hours in 7 operator days”, “100 hours in 672 hours”.

import type { RollingCapRule } from "@northguild/gmt";
MemberTypeDescription
labelstringThe caller’s name for the rule. The report is keyed by it; labels must be unique.
severity?"violation" | "advisory" (DutySeverity)Whether a failure is a violation or an advisory.
kind"rollingCap"Selects this rule kind.
statusesS[]The statuses whose time is capped.
capstringThe most time allowed in the window, a positive ISO 8601 duration of exact time.
windowPeriodThe span the cap is counted over.
reset?Reset<S> (Reset)A rest that starts the count again, as a long rest that restarts a cycle does.
precondition?objectA rest the window must hold before its time passes beforeHours.
precondition.restStatusesS[]The statuses the rest is made of.
precondition.minimumstringHow long the rest must be, a positive ISO 8601 duration of exact time.
precondition.beforeHoursstringThe most time allowed before that rest, a positive ISO 8601 duration of exact time.
type RollingCapRule<S extends string = string> = {
/** The caller's name for the rule. The report is keyed by it; labels must be unique. */
label: string;
/**
* Whether a failure is a violation or an advisory.
*
* @defaultValue `"violation"`.
*/
severity?: DutySeverity;
/** Selects this rule kind. */
kind: "rollingCap";
/** The statuses whose time is capped. */
statuses: S[];
/** The most time allowed in the window, a positive ISO 8601 duration of exact time. */
cap: string;
/** The span the cap is counted over. */
window: Period;
/**
* A rest that starts the count again, as a long rest that restarts a cycle does.
*
* @defaultValue None. Only the window limits the count.
*/
reset?: Reset<S>;
/**
* A rest the window must hold before its time passes `beforeHours`.
*
* @defaultValue None. The cap applies from the start of the window.
*/
precondition?: {
/** The statuses the rest is made of. */
restStatuses: S[];
/** How long the rest must be, a positive ISO 8601 duration of exact time. */
minimum: string;
/** The most time allowed before that rest, a positive ISO 8601 duration of exact time. */
beforeHours: string;
};
};

types/duty.ts