@@ -309,6 +309,111 @@ test("composite honors custom weights and falls back to objective-only when all
309309 assert . equal ( allZero . compositeScore , 0.4 ) ;
310310} ) ;
311311
312+ test ( "composite sanitizes pre-ingested reviewer-consensus rows before auditing" , ( ) => {
313+ const poisoned = {
314+ accepted : [
315+ {
316+ repoFullName : "ACME/Widgets" ,
317+ replayRunId : " replay-1 " ,
318+ reviewRunId : "review-1" ,
319+ observedAt : "2026-07-04T00:00:00Z" ,
320+ score : 0 ,
321+ privateMetadata : "do-not-leak" ,
322+ dimensions : [
323+ {
324+ dimension : "coverage" ,
325+ voteCount : 2 ,
326+ majorityOutcome : "success" ,
327+ agreement : 1 ,
328+ score : 0 ,
329+ rawReviewText : "do-not-leak" ,
330+ } ,
331+ {
332+ dimension : "security" ,
333+ voteCount : 2 ,
334+ majorityOutcome : "fail" ,
335+ agreement : "not-a-number" ,
336+ rawReviewText : "do-not-leak" ,
337+ } ,
338+ ] ,
339+ } ,
340+ ] ,
341+ rejected : [
342+ {
343+ repoFullName : "ACME/Widgets" ,
344+ replayRunId : "replay-2" ,
345+ reviewRunId : "review-2" ,
346+ reason : "not_opted_in" ,
347+ privateMetadata : "do-not-leak" ,
348+ } ,
349+ {
350+ repoFullName : "bad" ,
351+ replayRunId : "replay-3" ,
352+ reviewRunId : "review-3" ,
353+ reason : "invalid_repo" ,
354+ privateMetadata : "do-not-leak" ,
355+ } ,
356+ {
357+ repoFullName : "ACME/Widgets" ,
358+ replayRunId : "replay-4" ,
359+ reviewRunId : "review-4" ,
360+ reason : "private_reason" ,
361+ privateMetadata : "do-not-leak" ,
362+ } ,
363+ ] ,
364+ } ;
365+
366+ const result = computeReviewerConsensusCompositeCalibrationScore ( {
367+ objectiveAnchor : 0.5 ,
368+ pairwise : null ,
369+ reviewerConsensus : poisoned as never ,
370+ } ) ;
371+
372+ assert . equal ( result . structuredReviewerConsensusScore , 1 ) ;
373+ assert . deepEqual ( result . audit . contributingRepos , [
374+ {
375+ repoFullName : "acme/widgets" ,
376+ replayRunId : "replay-1" ,
377+ reviewRunId : "review-1" ,
378+ observedAt : "2026-07-04T00:00:00.000Z" ,
379+ score : 1 ,
380+ dimensions : [ { dimension : "tests" , voteCount : 2 , majorityOutcome : "pass" , agreement : 1 , score : 1 } ] ,
381+ } ,
382+ ] ) ;
383+ assert . deepEqual ( result . audit . rejected , [
384+ { repoFullName : "acme/widgets" , replayRunId : "replay-2" , reviewRunId : "review-2" , reason : "not_opted_in" } ,
385+ { repoFullName : "bad" , replayRunId : "replay-3" , reviewRunId : "review-3" , reason : "invalid_repo" } ,
386+ ] ) ;
387+ assert . ok ( ! JSON . stringify ( result ) . includes ( "do-not-leak" ) ) ;
388+ } ) ;
389+
390+ test ( "composite drops malformed pre-ingested rows instead of rendering invalid dimensions" , ( ) => {
391+ const result = computeReviewerConsensusCompositeCalibrationScore ( {
392+ objectiveAnchor : 0.5 ,
393+ pairwise : 0.7 ,
394+ reviewerConsensus : {
395+ accepted : [
396+ {
397+ repoFullName : "acme/widgets" ,
398+ replayRunId : "replay-1" ,
399+ reviewRunId : "review-1" ,
400+ observedAt : null ,
401+ score : 1 ,
402+ dimensions : [
403+ { dimension : "correctness" , voteCount : 1 , majorityOutcome : "pass" , agreement : "1" , score : 1 } ,
404+ ] ,
405+ } ,
406+ ] ,
407+ rejected : [ { repoFullName : "acme/widgets" , replayRunId : "replay-2" , reviewRunId : "review-2" } ] ,
408+ } as never ,
409+ } ) ;
410+
411+ assert . equal ( result . structuredReviewerConsensusScore , null ) ;
412+ assert . deepEqual ( result . audit . contributingRepos , [ ] ) ;
413+ assert . deepEqual ( result . audit . rejected , [ ] ) ;
414+ assert . doesNotThrow ( ( ) => renderReviewerConsensusCalibrationAuditMarkdown ( result ) ) ;
415+ } ) ;
416+
312417test ( "renderAuditMarkdown is deterministic, public-safe, and reports contributors and rejections" , ( ) => {
313418 const ingestion = ingestReviewerConsensusCalibrationSignals ( [
314419 signal ( { repoFullName : "acme/widgets" , observedAt : "2026-07-04T00:00:00Z" } ) ,
0 commit comments