@@ -5,15 +5,14 @@ import {
55 OVERALL_CORRECTNESS_VALUES ,
66 PR_STATUS_LABEL_NAMES ,
77 PR_STATUS_LABELS ,
8- REAL_BEHAVIOR_PROOF_STATUSES ,
98 SECURITY_REVIEW_STATUSES ,
109} from "./clawsweeper-policy.js" ;
1110import {
1211 AUTOMERGE_LABEL ,
1312 HUMAN_REVIEW_LABEL ,
1413 MANUAL_ONLY_LABEL ,
1514} from "./repair/exact-review-guard-labels.js" ;
16- import type { AttachedLiveVerification } from "./live -proof/verification .js" ;
15+ import type { RealBehaviorProofPolicy } from "./clawsweeper -proof-policy .js" ;
1716import type {
1817 FeatureShowcase ,
1918 FeatureShowcaseStatus ,
@@ -22,8 +21,6 @@ import type {
2221 MergeRiskOptionCategory ,
2322 OverallCorrectness ,
2423 PrStatusLabelKind ,
25- RealBehaviorProof ,
26- RealBehaviorProofStatus ,
2724 ReviewFinding ,
2825 SecurityReview ,
2926 SecurityReviewStatus ,
@@ -34,9 +31,8 @@ interface LabelPolicyDependencies {
3431 frontMatterValue : ( markdown : string , key : string ) => string | undefined ;
3532 isAutomationReportAuthor : ( author : string | undefined ) => boolean ;
3633 mergeRiskOptionsFromReport : ( markdown : string ) => MergeRiskOption [ ] ;
37- reportAttachedLiveVerification : ( markdown : string ) => AttachedLiveVerification ;
3834 reportOverallCorrectness : ( markdown : string ) => OverallCorrectness ;
39- reportRealBehaviorProof : ( markdown : string ) => RealBehaviorProof ;
35+ reportRealBehaviorProofPolicy : ( markdown : string ) => RealBehaviorProofPolicy ;
4036 reportReviewFindings : ( markdown : string ) => ReviewFinding [ ] ;
4137 reportSecurityReview : ( markdown : string ) => SecurityReview ;
4238 stringOrUndefined : ( value : unknown ) => string | undefined ;
@@ -48,9 +44,8 @@ export function createLabelPolicy({
4844 frontMatterValue,
4945 isAutomationReportAuthor,
5046 mergeRiskOptionsFromReport,
51- reportAttachedLiveVerification,
5247 reportOverallCorrectness,
53- reportRealBehaviorProof ,
48+ reportRealBehaviorProofPolicy ,
5449 reportReviewFindings,
5550 reportSecurityReview,
5651 stringOrUndefined,
@@ -127,18 +122,6 @@ export function createLabelPolicy({
127122 } ) ;
128123 }
129124
130- function proofIsUnresolved ( proof : Pick < RealBehaviorProof , "status" > ) : boolean {
131- return (
132- proof . status === "missing" || proof . status === "mock_only" || proof . status === "insufficient"
133- ) ;
134- }
135-
136- function proofNeedsContributorAction (
137- proof : Pick < RealBehaviorProof , "status" | "needsContributorAction" > ,
138- ) : boolean {
139- return proofIsUnresolved ( proof ) && proof . needsContributorAction ;
140- }
141-
142125 function hasBlockingReviewFindings (
143126 findings : readonly Pick < ReviewFinding , "priority" > [ ] ,
144127 ) : boolean {
@@ -160,22 +143,22 @@ export function createLabelPolicy({
160143 }
161144
162145 function hasUnresolvedContributorWork ( options : {
163- realBehaviorProof : Pick < RealBehaviorProof , "status " | "needsContributorAction" > ;
146+ proofPolicy : Pick < RealBehaviorProofPolicy , "blocksMerge " | "needsContributorAction" > ;
164147 reviewFindings : readonly Pick < ReviewFinding , "priority" > [ ] ;
165148 securityReview : Pick < SecurityReview , "status" > ;
166149 mergeRiskOptions : readonly Pick < MergeRiskOption , "category" | "recommended" > [ ] ;
167150 overallCorrectness : OverallCorrectness ;
168151 } ) : boolean {
169152 return (
170- proofNeedsContributorAction ( options . realBehaviorProof ) ||
153+ options . proofPolicy . needsContributorAction ||
171154 hasBlockingReviewFindings ( options . reviewFindings ) ||
172155 securityReviewNeedsContributorWork ( options ) ||
173156 options . overallCorrectness === "patch is incorrect"
174157 ) ;
175158 }
176159
177160 function isReadyForMaintainerLook ( options : {
178- realBehaviorProof : Pick < RealBehaviorProof , "status " | "needsContributorAction" > ;
161+ proofPolicy : Pick < RealBehaviorProofPolicy , "blocksMerge " | "needsContributorAction" > ;
179162 reviewFindings : readonly Pick < ReviewFinding , "priority" > [ ] ;
180163 securityReview : Pick < SecurityReview , "status" > ;
181164 mergeRiskOptions : readonly Pick < MergeRiskOption , "category" | "recommended" > [ ] ;
@@ -184,15 +167,14 @@ export function createLabelPolicy({
184167 return (
185168 ! hasBlockingReviewFindings ( options . reviewFindings ) &&
186169 ! securityReviewNeedsContributorWork ( options ) &&
187- ( options . realBehaviorProof . status === "sufficient" ||
188- options . realBehaviorProof . status === "override" ||
189- options . realBehaviorProof . status === "not_applicable" ) &&
170+ ! options . proofPolicy . blocksMerge &&
190171 options . overallCorrectness === "patch is correct"
191172 ) ;
192173 }
193174
194175 function prStatusLabelKind ( options : {
195- realBehaviorProof : Pick < RealBehaviorProof , "status" | "needsContributorAction" > ;
176+ reviewFailed : boolean ;
177+ proofPolicy : Pick < RealBehaviorProofPolicy , "blocksMerge" | "needsContributorAction" > ;
196178 reviewFindings : readonly Pick < ReviewFinding , "priority" > [ ] ;
197179 securityReview : Pick < SecurityReview , "status" > ;
198180 mergeRiskOptions : readonly Pick < MergeRiskOption , "category" | "recommended" > [ ] ;
@@ -206,8 +188,9 @@ export function createLabelPolicy({
206188 if ( options . hasRepairLoopPauseLabel ) return null ;
207189 if ( options . hasRecentReReviewRequest ) return "re_review_loop" ;
208190 if ( options . hasRecentAuthorActivity && unresolvedWork ) return "actively_grinding" ;
209- if ( proofNeedsContributorAction ( options . realBehaviorProof ) ) return "needs_proof" ;
210- if ( proofIsUnresolved ( options . realBehaviorProof ) ) return "needs_maintainer_proof_decision" ;
191+ if ( options . proofPolicy . needsContributorAction ) return "needs_proof" ;
192+ if ( options . proofPolicy . blocksMerge ) return "needs_maintainer_proof_decision" ;
193+ if ( options . reviewFailed ) return null ;
211194 if ( unresolvedWork ) return "waiting_on_author" ;
212195 if ( options . hasAutomergeLabel ) return "automerge_armed" ;
213196 if ( isReadyForMaintainerLook ( options ) ) return "ready_for_maintainer_look" ;
@@ -308,15 +291,9 @@ export function createLabelPolicy({
308291 currentLabels : readonly string [ ] ,
309292 ) : PrStatusLabelKind | null {
310293 if ( frontMatterValue ( markdown , "type" ) !== "pull_request" ) return null ;
311- const proof = reportRealBehaviorProof ( markdown ) ;
312- const attached = reportAttachedLiveVerification ( markdown ) ;
313- const statusProof =
314- ( attached . status === "failed" || attached . status === "malformed" ) &&
315- ! proofNeedsContributorAction ( proof )
316- ? { status : "insufficient" as const , needsContributorAction : false }
317- : proof ;
318294 return prStatusLabelKind ( {
319- realBehaviorProof : statusProof ,
295+ reviewFailed : frontMatterValue ( markdown , "review_status" ) === "failed" ,
296+ proofPolicy : reportRealBehaviorProofPolicy ( markdown ) ,
320297 reviewFindings : reportReviewFindings ( markdown ) ,
321298 securityReview : reportSecurityReview ( markdown ) ,
322299 mergeRiskOptions : mergeRiskOptionsFromReport ( markdown ) ,
@@ -364,14 +341,14 @@ export function createLabelPolicy({
364341 { comments : [ ...( options . comments ?? [ ] ) ] } ,
365342 options . reviewedAt ?? "2026-01-01T00:00:00Z" ,
366343 ) ;
344+ const unresolvedProof = [ "missing" , "mock_only" , "insufficient" ] . includes (
345+ options . proofStatus ?? "" ,
346+ ) ;
367347 const statusKind = prStatusLabelKind ( {
368- realBehaviorProof : {
369- status : REAL_BEHAVIOR_PROOF_STATUSES . has ( options . proofStatus as RealBehaviorProofStatus )
370- ? ( options . proofStatus as RealBehaviorProofStatus )
371- : "not_applicable" ,
372- needsContributorAction :
373- options . needsContributorAction ??
374- [ "missing" , "mock_only" , "insufficient" ] . includes ( options . proofStatus ?? "" ) ,
348+ reviewFailed : false ,
349+ proofPolicy : {
350+ blocksMerge : unresolvedProof ,
351+ needsContributorAction : unresolvedProof && ( options . needsContributorAction ?? true ) ,
375352 } ,
376353 reviewFindings : ( options . findingPriorities ?? [ ] )
377354 . filter ( ( priority ) : priority is 0 | 1 | 2 | 3 => [ 0 , 1 , 2 , 3 ] . includes ( priority ) )
0 commit comments