33 * Documents and validates contract policy for boundary MTTR inputs.
44 */
55
6+ import { describe , it , expect } from '@jest/globals' ;
7+
8+
69interface SlaConfig {
710 threshold : number ; // minutes
811 penaltyBps : number ;
@@ -18,13 +21,16 @@ function evaluateSla(
1821 return mttr <= config . threshold ? "met" : "violated" ;
1922}
2023
21- const CONFIGS : Record < string , SlaConfig > = {
24+ type Severity = "critical" | "high" | "medium" ;
25+
26+ const CANONICAL_SEVERITIES = [ "critical" , "high" , "medium" ] as const ;
27+
28+ const CONFIGS : Record < Severity , SlaConfig > = {
2229 critical : { threshold : 60 , penaltyBps : 500 } ,
2330 high : { threshold : 240 , penaltyBps : 300 } ,
2431 medium : { threshold : 480 , penaltyBps : 100 } ,
2532} ;
26-
27- const CANONICAL_SEVERITIES = [ "critical" , "high" , "medium" ] as const ;
33+
2834
2935describe ( "SC-046 Threshold Edge Cases" , ( ) => {
3036 it ( "zero MTTR always meets any positive threshold" , ( ) => {
@@ -57,10 +63,11 @@ describe("SC-046 Threshold Edge Cases", () => {
5763 } ) ;
5864
5965 it ( "MTTR one above threshold is violated" , ( ) => {
60- for ( const severity of CANONICAL_SEVERITIES ) {
61- const cfg = CONFIGS [ severity ] ;
62- expect ( evaluateSla ( cfg . threshold + 1 , cfg ) ) . toBe ( "violated" ) ;
63- }
66+ for ( const severity of CANONICAL_SEVERITIES ) {
67+ const cfg = CONFIGS [ severity ] ;
68+ expect ( evaluateSla ( cfg . threshold + 1 , cfg ) ) . toBe ( "violated" ) ;
69+ }
70+
6471 } ) ;
6572
6673 it ( "exact threshold does not drift into violation due to boundary math" , ( ) => {
@@ -76,7 +83,7 @@ describe("SC-046 Threshold Edge Cases", () => {
7683 } ) ;
7784
7885 it ( "negative MTTR is rejected as invalid" , ( ) => {
79- expect ( evaluateSla ( - 1 , CONFIGS . critical ) ) . toBe ( "invalid" ) ;
86+ expect ( evaluateSla ( - 1 , CONFIGS [ ' critical' ] ) ) . toBe ( "invalid" ) ;
8087 } ) ;
8188
8289 it ( "uses a documented canonical severity order for backend fixtures" , ( ) => {
@@ -86,6 +93,6 @@ describe("SC-046 Threshold Edge Cases", () => {
8693
8794 it ( "near-zero MTTR (0.001) treated as zero — rounds to met" , ( ) => {
8895 const nearZero = Math . floor ( 0.001 ) ; // contract uses integer minutes
89- expect ( evaluateSla ( nearZero , CONFIGS . critical ) ) . toBe ( "met" ) ;
96+ expect ( evaluateSla ( nearZero , CONFIGS [ ' critical' ] ) ) . toBe ( "met" ) ;
9097 } ) ;
9198} ) ;
0 commit comments