@@ -47,6 +47,23 @@ export async function enqueueScheduledReviewPlan(
4747 options : EnqueueOptions ,
4848) : Promise < ScheduledReviewEnqueueSummary > {
4949 const fetchImpl = options . fetchImpl ?? fetch ;
50+ for ( const candidate of options . plan . candidates ) validateCandidate ( candidate , options . targetRepo ) ;
51+ const queueUrl = options . queueUrl . replace ( / \/ $ / , "" ) ;
52+ const capabilityResponse = await fetchImpl ( `${ queueUrl } /api/exact-review-queue` , {
53+ signal : AbortSignal . timeout ( 20_000 ) ,
54+ } ) ;
55+ const capability = ( await capabilityResponse . json ( ) . catch ( ( ) => null ) ) as Record <
56+ string ,
57+ unknown
58+ > | null ;
59+ const scheduledFeed = capability ?. scheduled_feed as Record < string , unknown > | undefined ;
60+ if (
61+ ! capabilityResponse . ok ||
62+ ! scheduledFeed ||
63+ ! Number . isFinite ( Number ( scheduledFeed . target_rate_per_hour ) )
64+ ) {
65+ throw new Error ( "exact-review queue does not advertise scheduled feed admission" ) ;
66+ }
5067 const ages = ( options . plan . selection ?? [ ] )
5168 . map ( ( selection ) => Number ( selection . ageMs ) )
5269 . filter ( ( age ) => Number . isFinite ( age ) && age >= 0 )
@@ -75,7 +92,6 @@ export async function enqueueScheduledReviewPlan(
7592 } ;
7693
7794 for ( const [ index , candidate ] of options . plan . candidates . entries ( ) ) {
78- validateCandidate ( candidate , options . targetRepo ) ;
7995 const payload = JSON . stringify ( {
8096 delivery_id : `${ options . deliveryPrefix } :${ index } :${ candidate . number } ` ,
8197 decision : {
@@ -92,18 +108,15 @@ export async function enqueueScheduledReviewPlan(
92108 } ) ;
93109 const signature = `sha256=${ createHmac ( "sha256" , options . secret ) . update ( payload ) . digest ( "hex" ) } ` ;
94110 summary . attempted += 1 ;
95- const response = await fetchImpl (
96- `${ options . queueUrl . replace ( / \/ $ / , "" ) } /internal/exact-review/enqueue` ,
97- {
98- method : "POST" ,
99- headers : {
100- "content-type" : "application/json" ,
101- "x-clawsweeper-exact-review-signature" : signature ,
102- } ,
103- body : payload ,
104- signal : AbortSignal . timeout ( 20_000 ) ,
111+ const response = await fetchImpl ( `${ queueUrl } /internal/exact-review/enqueue` , {
112+ method : "POST" ,
113+ headers : {
114+ "content-type" : "application/json" ,
115+ "x-clawsweeper-exact-review-signature" : signature ,
105116 } ,
106- ) ;
117+ body : payload ,
118+ signal : AbortSignal . timeout ( 20_000 ) ,
119+ } ) ;
107120 const body = ( await response . json ( ) . catch ( ( ) => null ) ) as Record < string , unknown > | null ;
108121 if ( ! response . ok || ! body || body . ok !== true ) {
109122 throw new Error (
0 commit comments