@@ -2,30 +2,40 @@ import assert from "node:assert/strict";
22import test from "node:test" ;
33
44import {
5- appendFloorBackfillCandidateNumbersForTest ,
5+ appendFloorBackfillCandidates ,
66 hotIntakeRecencyMs ,
77 reviewPriority ,
8- selectDueCandidateNumbersForTest ,
8+ selectDueCandidates ,
99 shouldReviewItem ,
1010 shouldStopSaturatedPlanScan ,
1111} from "../dist/scheduler-policy.js" ;
12+ import { item } from "./helpers.ts" ;
1213
13- function item ( overrides = { } ) {
14+ function schedulerCandidate ( candidate ) {
1415 return {
15- repo : "openclaw/openclaw" ,
16- number : 123 ,
17- kind : "issue" ,
18- title : "Sample item" ,
19- url : "https://github.com/openclaw/openclaw/issues/123" ,
20- createdAt : "2026-01-01T00:00:00Z" ,
21- updatedAt : "2026-01-01T00:00:00Z" ,
22- author : "contributor" ,
23- authorAssociation : "NONE" ,
24- labels : [ ] ,
25- ...overrides ,
16+ item : candidate . item ,
17+ review : null ,
18+ priority : candidate . priority ?? reviewPriority ( candidate . item , null ) ,
19+ reviewedAt : candidate . reviewedAt ?? 0 ,
20+ nextDueAt : candidate . nextDueAt ?? 0 ,
21+ bucket : candidate . bucket ,
2622 } ;
2723}
2824
25+ function selectedNumbers ( due , limit , now ) {
26+ return selectDueCandidates ( due . map ( schedulerCandidate ) , limit , undefined , now ) . map (
27+ ( candidate ) => candidate . item . number ,
28+ ) ;
29+ }
30+
31+ function backfilledNumbers ( selected , backfill , activeFloor , capacity ) {
32+ return appendFloorBackfillCandidates (
33+ selected . map ( schedulerCandidate ) ,
34+ backfill . map ( schedulerCandidate ) ,
35+ { activeFloor, capacity } ,
36+ ) . map ( ( candidate ) => candidate . item . number ) ;
37+ }
38+
2939test ( "review policy changes force fresh complete reports back into planning" , ( ) => {
3040 const reviewedAt = new Date ( ) . toISOString ( ) ;
3141 const review = {
@@ -345,7 +355,7 @@ test("normal scheduler reserves throughput for PR and older buckets", () => {
345355 } ,
346356 ) ;
347357
348- assert . deepEqual ( selectDueCandidateNumbersForTest ( due , 8 , now ) , [ 1 , 2 , 3 , 4 , 101 , 201 , 301 , 5 ] ) ;
358+ assert . deepEqual ( selectedNumbers ( due , 8 , now ) , [ 1 , 2 , 3 , 4 , 101 , 201 , 301 , 5 ] ) ;
349359} ) ;
350360
351361test ( "normal scheduler prioritizes items already breaching weekly freshness" , ( ) => {
@@ -383,7 +393,7 @@ test("normal scheduler prioritizes items already breaching weekly freshness", ()
383393 } ,
384394 ] ;
385395
386- assert . deepEqual ( selectDueCandidateNumbersForTest ( due , 3 , now ) , [ 3 , 2 , 1 ] ) ;
396+ assert . deepEqual ( selectedNumbers ( due , 3 , now ) , [ 3 , 2 , 1 ] ) ;
387397} ) ;
388398
389399test ( "weekly freshness preselection still fills remaining scheduler capacity" , ( ) => {
@@ -421,7 +431,7 @@ test("weekly freshness preselection still fills remaining scheduler capacity", (
421431 } ,
422432 ) ;
423433
424- assert . deepEqual ( selectDueCandidateNumbersForTest ( due , 7 , now ) , [ 1 , 2 , 3 , 4 , 5 , 7 , 6 ] ) ;
434+ assert . deepEqual ( selectedNumbers ( due , 7 , now ) , [ 1 , 2 , 3 , 4 , 5 , 7 , 6 ] ) ;
425435} ) ;
426436
427437test ( "normal scheduler can fill active floor from stale current reviews" , ( ) => {
@@ -457,11 +467,8 @@ test("normal scheduler can fill active floor from stale current reviews", () =>
457467 } ,
458468 ] ;
459469
460- assert . deepEqual (
461- appendFloorBackfillCandidateNumbersForTest ( selected , backfill , 3 , 10 ) ,
462- [ 1 , 10 , 11 ] ,
463- ) ;
464- assert . deepEqual ( appendFloorBackfillCandidateNumbersForTest ( selected , backfill , 3 , 2 ) , [ 1 , 10 ] ) ;
470+ assert . deepEqual ( backfilledNumbers ( selected , backfill , 3 , 10 ) , [ 1 , 10 , 11 ] ) ;
471+ assert . deepEqual ( backfilledNumbers ( selected , backfill , 3 , 2 ) , [ 1 , 10 ] ) ;
465472} ) ;
466473
467474test ( "normal scheduler can stop scanning once planned capacity is saturated" , ( ) => {
0 commit comments