@@ -100,7 +100,7 @@ test("local exact reviews default to item-specific artifacts", () => {
100100 assert . equal ( defaultReviewArtifactDirForTest ( false , 357 , undefined ) , "artifacts/reviews" ) ;
101101} ) ;
102102
103- test ( "CSW-088 scheduled hot planning suppresses #117063 while explicit re-review remains eligible" , ( ) => {
103+ test ( "CSW-088 scheduled hot planning suppresses #117063, observes an in-flight update, and leaves explicit re-review eligible" , ( ) => {
104104 const root = mkdtempSync ( join ( tmpdir ( ) , "cmd-csw-088-" ) ) ;
105105 const binDir = join ( root , "bin" ) ;
106106 const itemsDir = join ( root , "items" ) ;
@@ -123,6 +123,12 @@ test("CSW-088 scheduled hot planning suppresses #117063 while explicit re-review
123123 deletions : 2 ,
124124 changed_files : 2 ,
125125 commits : 1 ,
126+ updated_at : reviewedAt ,
127+ } ;
128+ const updatedPull = { ...pull , body : "The PR body changed during the snapshot read." } ;
129+ const commentUpdatedPull = {
130+ ...pull ,
131+ updated_at : new Date ( Date . parse ( reviewedAt ) + 1 ) . toISOString ( ) ,
126132 } ;
127133 const issue = {
128134 number,
@@ -177,6 +183,7 @@ test("CSW-088 scheduled hot planning suppresses #117063 while explicit re-review
177183 title : pull . title ,
178184 reviewed_at : reviewedAt ,
179185 review_policy : reviewPolicyHashForTest ( ) ,
186+ item_updated_at : reviewedAt ,
180187 item_source_revision : sourceRevision ,
181188 pull_head_sha : headSha ,
182189 reviewed_pull_state_digest : pullStateDigest ,
@@ -198,6 +205,15 @@ const path = args[1] || "";
198205const listItem = ${ JSON . stringify ( listItem ) } ;
199206const issue = ${ JSON . stringify ( issue ) } ;
200207const pull = ${ JSON . stringify ( pull ) } ;
208+ const updatedPull = ${ JSON . stringify ( updatedPull ) } ;
209+ const commentUpdatedPull = ${ JSON . stringify ( commentUpdatedPull ) } ;
210+ const raceMarker = process.env.CSW_RACE_MARKER;
211+ const race = process.env.CSW_RACE === "1";
212+ const activityRaceMarker = process.env.CSW_ACTIVITY_RACE_MARKER;
213+ const activityRace = process.env.CSW_ACTIVITY_RACE === "1";
214+ const commentRaceMarker = process.env.CSW_COMMENT_RACE_MARKER;
215+ const commentRace = process.env.CSW_COMMENT_RACE === "1";
216+ const updatedReview = { id: 1, user: { login: "reviewer" }, state: "COMMENTED", body: "new review activity", submitted_at: "2026-07-31T00:00:00Z", commit_id: pull.head.sha };
201217if (args[0] === "api" && /issues\\?state=open/.test(path)) {
202218 console.log(JSON.stringify(listItem));
203219 process.exit(0);
@@ -207,17 +223,24 @@ if (args[0] === "api" && path === "repos/openclaw/openclaw/issues/${number}") {
207223 process.exit(0);
208224}
209225if (args[0] === "api" && path === "repos/openclaw/openclaw/pulls/${ number } ") {
210- console.log(JSON.stringify(pull));
226+ if (activityRace && activityRaceMarker) require("node:fs").writeFileSync(activityRaceMarker, "seen");
227+ console.log(JSON.stringify(race && raceMarker && require("node:fs").existsSync(raceMarker) ? updatedPull : commentRace && commentRaceMarker && require("node:fs").existsSync(commentRaceMarker) ? commentUpdatedPull : pull));
211228 process.exit(0);
212229}
213- if (args[0] === "api" && /(issues|pulls)\\/${ number } \\/comments/.test(path)) {
230+ if (args[0] === "api" && path.startsWith("repos/openclaw/openclaw/issues/${ number } /comments")) {
231+ if (commentRace && commentRaceMarker) require("node:fs").writeFileSync(commentRaceMarker, "seen");
214232 console.log(JSON.stringify([[]]));
215233 process.exit(0);
216234}
217- if (args[0] === "api" && /pulls\\/${ number } \\/reviews/.test(path)) {
235+ if (args[0] === "api" && path.startsWith("repos/openclaw/openclaw/pulls/${ number } /comments")) {
236+ if (race && raceMarker) require("node:fs").writeFileSync(raceMarker, "seen");
218237 console.log(JSON.stringify([[]]));
219238 process.exit(0);
220239}
240+ if (args[0] === "api" && /pulls\\/${ number } \\/reviews/.test(path)) {
241+ console.log(JSON.stringify(activityRace && activityRaceMarker && require("node:fs").existsSync(activityRaceMarker) ? [[updatedReview]] : [[]]));
242+ process.exit(0);
243+ }
221244console.error("unexpected gh args " + JSON.stringify(args));
222245process.exit(1);
223246` ,
@@ -248,6 +271,105 @@ process.exit(1);
248271 assert . equal ( scheduled . status , 0 , scheduled . stderr ) ;
249272 assert . deepEqual ( JSON . parse ( scheduled . stdout ) . candidates , [ ] ) ;
250273
274+ const raced = spawnSync (
275+ process . execPath ,
276+ [
277+ CLI ,
278+ "plan" ,
279+ "--target-repo" ,
280+ "openclaw/openclaw" ,
281+ "--items-dir" ,
282+ itemsDir ,
283+ "--coverage-tracked-items-manifest" ,
284+ coverageManifest ,
285+ "--hot-intake" ,
286+ "--max-pages" ,
287+ "1" ,
288+ "--batch-size" ,
289+ "1" ,
290+ "--shard-count" ,
291+ "1" ,
292+ ] ,
293+ { encoding : "utf8" , env : { ...env , CSW_RACE : "1" , CSW_RACE_MARKER : join ( root , "race" ) } } ,
294+ ) ;
295+ assert . equal ( raced . status , 0 , raced . stderr ) ;
296+ assert . deepEqual (
297+ JSON . parse ( raced . stdout ) . candidates . map ( ( candidate : { number : number } ) => candidate . number ) ,
298+ [ number ] ,
299+ ) ;
300+
301+ const commentRaced = spawnSync (
302+ process . execPath ,
303+ [
304+ CLI ,
305+ "plan" ,
306+ "--target-repo" ,
307+ "openclaw/openclaw" ,
308+ "--items-dir" ,
309+ itemsDir ,
310+ "--coverage-tracked-items-manifest" ,
311+ coverageManifest ,
312+ "--hot-intake" ,
313+ "--max-pages" ,
314+ "1" ,
315+ "--batch-size" ,
316+ "1" ,
317+ "--shard-count" ,
318+ "1" ,
319+ ] ,
320+ {
321+ encoding : "utf8" ,
322+ env : {
323+ ...env ,
324+ CSW_COMMENT_RACE : "1" ,
325+ CSW_COMMENT_RACE_MARKER : join ( root , "comment-race" ) ,
326+ } ,
327+ } ,
328+ ) ;
329+ assert . equal ( commentRaced . status , 0 , commentRaced . stderr ) ;
330+ assert . deepEqual (
331+ JSON . parse ( commentRaced . stdout ) . candidates . map (
332+ ( candidate : { number : number } ) => candidate . number ,
333+ ) ,
334+ [ number ] ,
335+ ) ;
336+
337+ const activityRaced = spawnSync (
338+ process . execPath ,
339+ [
340+ CLI ,
341+ "plan" ,
342+ "--target-repo" ,
343+ "openclaw/openclaw" ,
344+ "--items-dir" ,
345+ itemsDir ,
346+ "--coverage-tracked-items-manifest" ,
347+ coverageManifest ,
348+ "--hot-intake" ,
349+ "--max-pages" ,
350+ "1" ,
351+ "--batch-size" ,
352+ "1" ,
353+ "--shard-count" ,
354+ "1" ,
355+ ] ,
356+ {
357+ encoding : "utf8" ,
358+ env : {
359+ ...env ,
360+ CSW_ACTIVITY_RACE : "1" ,
361+ CSW_ACTIVITY_RACE_MARKER : join ( root , "activity-race" ) ,
362+ } ,
363+ } ,
364+ ) ;
365+ assert . equal ( activityRaced . status , 0 , activityRaced . stderr ) ;
366+ assert . deepEqual (
367+ JSON . parse ( activityRaced . stdout ) . candidates . map (
368+ ( candidate : { number : number } ) => candidate . number ,
369+ ) ,
370+ [ number ] ,
371+ ) ;
372+
251373 const explicit = spawnSync (
252374 process . execPath ,
253375 [
0 commit comments