@@ -32,11 +32,8 @@ func TestResolveArgsUsesEmbeddedClawHubProfile(t *testing.T) {
3232 if got := strings .Join (opts .Scanners , "," ); got != "skillspector,clawscan-static" {
3333 t .Fatalf ("scanners = %q" , got )
3434 }
35- if got := len (opts .GateRules ["skillspector" ].JSONRules ); got != 3 {
36- t .Fatalf ("skillspector JSON gate rules = %#v" , opts .GateRules ["skillspector" ].JSONRules )
37- }
38- if got := len (opts .GateRules ["clawscan-static" ].JSONRules ); got != 1 {
39- t .Fatalf ("static JSON gate rules = %#v" , opts .GateRules ["clawscan-static" ].JSONRules )
35+ if len (opts .GateRules ) != 0 {
36+ t .Fatalf ("embedded clawhub profile changed its existing gate contract: %#v" , opts .GateRules )
4037 }
4138 if opts .Judge == nil {
4239 t .Fatal ("expected embedded clawhub judge" )
@@ -85,8 +82,8 @@ func TestResolveArgsUsesEmbeddedClawHubAIGCandidateProfile(t *testing.T) {
8582 if got := strings .Join (candidate .Scanners , "," ); got != "skillspector,aig" {
8683 t .Fatalf ("scanners = %q" , got )
8784 }
88- if got := len (candidate .GateRules [ "skillspector" ]. JSONRules ); got != 3 {
89- t .Fatalf ("skillspector JSON gate rules = %#v" , candidate .GateRules [ "skillspector" ]. JSONRules )
85+ if len (candidate .GateRules ) != 0 {
86+ t .Fatalf ("embedded clawhub-aig profile changed its existing gate contract: %#v" , candidate .GateRules )
9087 }
9188 if candidate .Judge == nil || clawhub .Judge == nil {
9289 t .Fatal ("missing embedded ClawHub judge" )
@@ -983,108 +980,6 @@ profiles:
983980 }
984981}
985982
986- func TestEmbeddedClawHubGateCoversSupportedSkillSpectorShapes (t * testing.T ) {
987- tests := []struct {
988- name string
989- raw json.RawMessage
990- want string
991- path string
992- }{
993- {
994- name : "top-level recommendation" ,
995- raw : json .RawMessage (`{"recommendation":"do-not-install","issues":[]}` ),
996- want : "block" ,
997- path : "risk_recommendation|riskRecommendation|recommendation" ,
998- },
999- {
1000- name : "null recommendation alias falls through" ,
1001- raw : json .RawMessage (`{"risk_recommendation":null,"recommendation":"DO_NOT_INSTALL","issues":[]}` ),
1002- want : "block" ,
1003- path : "risk_recommendation|riskRecommendation|recommendation" ,
1004- },
1005- {
1006- name : "nested recommendation behind empty top-level alias" ,
1007- raw : json .RawMessage (`{"recommendation":"","risk_assessment":{"recommendation":"DO_NOT_INSTALL"},"issues":[]}` ),
1008- want : "block" ,
1009- path : "risk_assessment.recommendation|risk_recommendation|riskRecommendation" ,
1010- },
1011- {
1012- name : "risk recommendation has precedence" ,
1013- raw : json .RawMessage (`{"recommendation":"SAFE","risk_recommendation":"DO_NOT_INSTALL","issues":[]}` ),
1014- want : "block" ,
1015- path : "risk_recommendation|riskRecommendation|recommendation" ,
1016- },
1017- {
1018- name : "empty preferred recommendation group falls back to nested" ,
1019- raw : json .RawMessage (`{"risk_recommendation":"","recommendation":"SAFE","risk_assessment":{"recommendation":"DO_NOT_INSTALL"},"issues":[]}` ),
1020- want : "block" ,
1021- path : "risk_assessment.recommendation|risk_recommendation|riskRecommendation" ,
1022- },
1023- {
1024- name : "camel-case report" ,
1025- raw : json .RawMessage (`{"riskAssessment":{"recommendation":"CAUTION"},"filteredFindings":[{"severity":"CRITICAL"}]}` ),
1026- want : "block" ,
1027- path : "filteredFindings[].severity|risk_severity|level" ,
1028- },
1029- {
1030- name : "alternate issue fields" ,
1031- raw : json .RawMessage (`{"findings":[{"level":"high"}]}` ),
1032- want : "warn" ,
1033- path : "findings[].severity|risk_severity|level" ,
1034- },
1035- {
1036- name : "empty filtered findings override raw findings" ,
1037- raw : json .RawMessage (`{"filtered_findings":[],"findings":[{"severity":"CRITICAL"}]}` ),
1038- want : "pass" ,
1039- },
1040- {
1041- name : "null filtered findings fall through to raw findings" ,
1042- raw : json .RawMessage (`{"filtered_findings":null,"findings":[{"severity":"CRITICAL"}]}` ),
1043- want : "block" ,
1044- path : "findings[].severity|risk_severity|level" ,
1045- },
1046- {
1047- name : "nonmatching filtered findings override raw findings" ,
1048- raw : json .RawMessage (`{"filtered_findings":[{"severity":"LOW"}],"findings":[{"severity":"CRITICAL"}]}` ),
1049- want : "pass" ,
1050- },
1051- {
1052- name : "finding field aliases resolve per item" ,
1053- raw : json .RawMessage (`{"filtered_findings":[{"severity":"LOW"},{"risk_severity":"CRITICAL"}]}` ),
1054- want : "block" ,
1055- path : "filtered_findings[].severity|risk_severity|level" ,
1056- },
1057- }
1058- for _ , test := range tests {
1059- t .Run (test .name , func (t * testing.T ) {
1060- opts , err := ResolveArgs ([]string {"./skill" , "--profile" , "clawhub" , "--sandbox" , "off" }, t .TempDir ())
1061- if err != nil {
1062- t .Fatal (err )
1063- }
1064- opts .Judge = nil
1065- artifact , err := runner .Run (opts , runner.RunContext {
1066- Env : map [string ]string {},
1067- ScannerRunner : profileScannerResultRunner {results : map [string ]runner.ScannerResult {
1068- "skillspector" : {Status : "completed" , Raw : test .raw },
1069- "clawscan-static" : {Status : "completed" , Raw : json .RawMessage (`{"findings":[]}` )},
1070- }},
1071- })
1072- if err != nil {
1073- t .Fatal (err )
1074- }
1075- if artifact .Gate != test .want {
1076- t .Fatalf ("gate = %q, rules = %#v" , artifact .Gate , artifact .GateRules )
1077- }
1078- if test .path == "" && len (artifact .GateRules ) != 0 {
1079- t .Fatalf ("gate rules = %#v" , artifact .GateRules )
1080- }
1081- if test .path != "" && (len (artifact .GateRules ) != 1 || artifact .GateRules [0 ].Path != test .path ) {
1082- t .Fatalf ("gate rules = %#v" , artifact .GateRules )
1083- }
1084- })
1085- }
1086- }
1087-
1088983func TestCommandScannerDeclarativeJSONRuleGatesUnchangedOutput (t * testing.T ) {
1089984 dir := t .TempDir ()
1090985 target := filepath .Join (dir , "skill" )
0 commit comments