Module type Sarek_policy.BUDGET

type t

A set of grants, each with the reason it was given.

val exact : t

No grant: the bottom of leq.

val add : grant -> reason:string -> t -> (t, refusal) Stdlib.result

add g ~reason b grants g. A blank reason is Error Blank_reason, the only refusal add can return (Default_kernel_name concerns the kernel scope of grant). The error type is shared with grant on purpose. The first reason for a grant is kept; adding it again is a no-op.

val permits : t -> grant -> bool
val reason : t -> grant -> string option
val meet : t -> t -> t

Intersection: a grant survives only if both operands hold it. The reason is the left operand's. The budget of a fused kernel is the meet of its members' budgets.

val leq : t -> t -> bool

leq a b: every grant of a is in b. exact is below everything and meet is the greatest lower bound.

val grants : t -> (grant * string) list

The grants and their reasons, in all_grants order.

val digest : t -> string

A stable string of the grant set: equal iff the sets are equal, whatever the reasons and the order in which grants were added. Meant for cache keys, where a policy change must change the key.