business-as-code
Version:
Primitives for expressing business logic and processes as code
92 lines • 3.35 kB
TypeScript
/**
* ProofPredicate — composable predicates that gate outcome-based settlement.
*
* Stripe's MPP Sessions ship escrow but no outcome-predicate-driven release —
* this module is the gap-filler. SaS's Service.outcomeContract.predicate
* uses these to express "definition of done."
*
* Seven leaf predicates + AND/OR composition:
* - schema-match : output matches schema
* - evaluator-pass : EvaluatorPanel approves at threshold
* - human-sign : human with signerRoles signs
* - external : external verifier (e.g. github CI + merged) approves
* - load-bearing-pass : a named subset of rubric items all pass (sb killThreshold)
* - overall-floor : N of total rubric items pass (sb killThreshold)
* - unmet-requirements-pass : no `severity: 'blocking'` UnmetRequirements remain
* (sb-n7d open-blocking gate); when `categories` is
* supplied, only those categories are checked.
*/
export type ProofPredicate = {
kind: 'schema-match';
schema: unknown;
} | {
kind: 'evaluator-pass';
panelRef: string | 'self';
minScore: number | 'all-approved' | 'majority';
} | {
kind: 'human-sign';
signerRoles: string[];
when?: string;
} | {
kind: 'external';
verifier: string;
spec: unknown;
} | {
kind: 'load-bearing-pass';
itemSet: string[];
} | {
kind: 'overall-floor';
minPasses: number;
outOfTotal: number;
} | {
kind: 'unmet-requirements-pass';
categories?: string[];
} | {
kind: 'and';
predicates: ProofPredicate[];
} | {
kind: 'or';
predicates: ProofPredicate[];
};
export declare const SchemaMatch: (schema: unknown) => ProofPredicate;
export declare const EvaluatorPass: (opts: {
panelRef: string | "self";
minScore: number | "all-approved" | "majority";
}) => ProofPredicate;
export declare const HumanSign: (opts: {
signerRoles: string[];
when?: string;
}) => ProofPredicate;
export declare const External: (opts: {
verifier: string;
spec: unknown;
}) => ProofPredicate;
export declare const LoadBearingPass: (itemSet: string[]) => ProofPredicate;
export declare const OverallFloor: (opts: {
minPasses: number;
outOfTotal: number;
}) => ProofPredicate;
/**
* `UnmetRequirementsPass` — sb-n7d's open-blocking gate as a first-class
* predicate.
*
* Passes iff no `severity: 'blocking'` UnmetRequirement is present in the
* verify-time evaluation context. `severity: 'warning'` items are ignored.
*
* When `categories` is supplied, only requirements whose `category` matches
* one of the listed values are considered (others are ignored regardless of
* severity). When omitted, ALL categories are inspected.
*
* @example
* // Any blocking unmet requirement fails the predicate.
* UnmetRequirementsPass()
*
* // Only blocking items in the 'compliance' or 'security' buckets fail.
* UnmetRequirementsPass({ categories: ['compliance', 'security'] })
*/
export declare const UnmetRequirementsPass: (opts?: {
categories?: string[];
}) => ProofPredicate;
export declare const AND: (...predicates: ProofPredicate[]) => ProofPredicate;
export declare const OR: (...predicates: ProofPredicate[]) => ProofPredicate;
//# sourceMappingURL=proof-predicate.d.ts.map