@@ -502,8 +502,13 @@ const captures = fs.existsSync(process.env.LOCAL_REVIEW_CAPTURE)
502502captures.push({
503503 hasPreviousReview: prompt.includes('"previousClawSweeperReview"'),
504504 hasPriorFinding: prompt.includes(${ JSON . stringify ( priorFindingTitle ) } ),
505+ previousReviewedSha: prompt.match(/"reviewedSha":\\s*"([0-9a-f]{40})"/)?.[1] ?? null,
505506});
506507fs.writeFileSync(process.env.LOCAL_REVIEW_CAPTURE, JSON.stringify(captures));
508+ if (process.env.LOCAL_REVIEW_FAIL === "1") {
509+ process.stderr.write("deterministic local review failure\\n");
510+ process.exit(1);
511+ }
507512fs.writeFileSync(outputPath, fs.readFileSync(process.env.LOCAL_REVIEW_DECISION));
508513process.stdout.write(JSON.stringify({ type: "turn.completed", usage: { input_tokens: 1 } }) + "\\n");
509514` ,
@@ -516,7 +521,7 @@ process.stdout.write(JSON.stringify({ type: "turn.completed", usage: { input_tok
516521 } ) ;
517522 }
518523
519- function runReview ( artifactDir : string , base = "base-ref" ) : void {
524+ function runReview ( artifactDir : string , base = "base-ref" , shouldFail = false ) : void {
520525 const result = spawnSync (
521526 process . execPath ,
522527 [
@@ -542,11 +547,16 @@ process.stdout.write(JSON.stringify({ type: "turn.completed", usage: { input_tok
542547 CODEX_BIN : fakeCodex ,
543548 LOCAL_REVIEW_CAPTURE : capturePath ,
544549 LOCAL_REVIEW_DECISION : decisionPath ,
550+ LOCAL_REVIEW_FAIL : shouldFail ? "1" : "0" ,
545551 } ,
546552 timeout : 60000 ,
547553 } ,
548554 ) ;
549- assert . equal ( result . status , 0 , `${ result . stderr ?? "" } ${ result . stdout ?? "" } ` ) ;
555+ if ( shouldFail ) {
556+ assert . notEqual ( result . status , 0 , "deterministic Codex failure must fail the review run" ) ;
557+ } else {
558+ assert . equal ( result . status , 0 , `${ result . stderr ?? "" } ${ result . stdout ?? "" } ` ) ;
559+ }
550560 }
551561
552562 try {
@@ -564,7 +574,9 @@ process.stdout.write(JSON.stringify({ type: "turn.completed", usage: { input_tok
564574 writeFileSync ( join ( dir , "feature.txt" ) , "first\nsecond\n" ) ;
565575 git ( dir , "add" , "feature.txt" ) ;
566576 git ( dir , "commit" , "-q" , "-m" , "fix: follow up on local review" ) ;
567- runReview ( join ( harness , "run-2" ) ) ;
577+ const failedHead = git ( dir , "rev-parse" , "HEAD" ) ;
578+ runReview ( join ( harness , "run-2-failed" ) , "base-ref" , true ) ;
579+ runReview ( join ( harness , "run-3" ) ) ;
568580
569581 const historyPath = resolve (
570582 dir ,
@@ -576,24 +588,27 @@ process.stdout.write(JSON.stringify({ type: "turn.completed", usage: { input_tok
576588 assert . match ( relatedHistory , new RegExp ( firstHead ) ) ;
577589
578590 git ( dir , "branch" , "alternate-base" , firstHead ) ;
579- runReview ( join ( harness , "run-3 " ) , "alternate-base" ) ;
591+ runReview ( join ( harness , "run-4 " ) , "alternate-base" ) ;
580592
581593 git ( dir , "checkout" , "-q" , "-b" , "unrelated" , "base-ref" ) ;
582594 writeFileSync ( join ( dir , "unrelated.txt" ) , "different branch\n" ) ;
583595 git ( dir , "add" , "unrelated.txt" ) ;
584596 git ( dir , "commit" , "-q" , "-m" , "feat: unrelated local range" ) ;
585- runReview ( join ( harness , "run-4 " ) ) ;
597+ runReview ( join ( harness , "run-5 " ) ) ;
586598
587599 const captures = JSON . parse ( readFileSync ( capturePath , "utf8" ) ) as Array < {
588600 hasPreviousReview : boolean ;
589601 hasPriorFinding : boolean ;
602+ previousReviewedSha : string | null ;
590603 } > ;
591604 assert . deepEqual ( captures , [
592- { hasPreviousReview : false , hasPriorFinding : false } ,
593- { hasPreviousReview : true , hasPriorFinding : true } ,
594- { hasPreviousReview : false , hasPriorFinding : false } ,
595- { hasPreviousReview : false , hasPriorFinding : false } ,
605+ { hasPreviousReview : false , hasPriorFinding : false , previousReviewedSha : null } ,
606+ { hasPreviousReview : true , hasPriorFinding : true , previousReviewedSha : firstHead } ,
607+ { hasPreviousReview : true , hasPriorFinding : true , previousReviewedSha : firstHead } ,
608+ { hasPreviousReview : false , hasPriorFinding : false , previousReviewedSha : null } ,
609+ { hasPreviousReview : false , hasPriorFinding : false , previousReviewedSha : null } ,
596610 ] ) ;
611+ assert . doesNotMatch ( JSON . stringify ( captures [ 2 ] ) , new RegExp ( failedHead ) ) ;
597612 assert . doesNotMatch ( readFileSync ( historyPath , "utf8" ) , / R e v i e w h i s t o r y \( / ) ;
598613 assert . equal ( git ( dir , "status" , "--porcelain" ) , "" ) ;
599614 } finally {
0 commit comments