@@ -66,17 +66,31 @@ describe("getOrCreateAnonSecret()", () => {
6666 } ) ;
6767} ) ;
6868
69- describe ( "exportOrbBatch() — always-on ; reads review_audit, ships anonymized reversal-aware signal" , ( ) => {
69+ describe ( "exportOrbBatch() — opt-in ; reads review_audit, ships anonymized reversal-aware signal" , ( ) => {
7070 beforeEach ( ( ) => {
7171 resetMetrics ( ) ;
7272 ( process . env as NodeJS . Dict < string > ) . GITHUB_APP_PRIVATE_KEY = "test-private-key" ; // gates export (App configured); not the anon key
73+ process . env . ORB_ENABLED = "true" ;
7374 process . env . ORB_APP_ID = "555" ;
7475 process . env . ORB_ANONYMIZE = "true" ;
7576 delete process . env . ORB_AIR_GAP ;
7677 delete process . env . ORB_COLLECTOR_URL ;
7778 } ) ;
7879 afterEach ( ( ) => {
79- for ( const k of [ "GITHUB_APP_PRIVATE_KEY" , "ORB_APP_ID" , "ORB_ANONYMIZE" , "ORB_AIR_GAP" , "ORB_COLLECTOR_URL" , "GITHUB_APP_ID" ] ) delete ( process . env as NodeJS . Dict < string > ) [ k ] ;
80+ for ( const k of [ "GITHUB_APP_PRIVATE_KEY" , "ORB_ENABLED" , "ORB_APP_ID" , "ORB_ANONYMIZE" , "ORB_AIR_GAP" , "ORB_COLLECTOR_URL" , "GITHUB_APP_ID" ] ) delete ( process . env as NodeJS . Dict < string > ) [ k ] ;
81+ } ) ;
82+
83+ it ( "returns 0 unless Orb export is explicitly enabled" , async ( ) => {
84+ delete process . env . ORB_ENABLED ;
85+ const db = makeDb ( ) ;
86+ await audit ( db , "o/r" , 1 , "gate_decision" , "merge" , "2026-01-01T00:00:00Z" ) ;
87+ await audit ( db , "o/r" , 1 , "pr_outcome" , "merged" , "2026-01-01T01:00:00Z" ) ;
88+ expect ( await exportOrbBatch ( db , 200 , async ( ) => new Response ( null , { status : 200 } ) ) ) . toBe ( 0 ) ;
89+
90+ for ( const off of [ "" , "false" , "no" , "0" , "off" ] ) {
91+ process . env . ORB_ENABLED = off ;
92+ expect ( await exportOrbBatch ( db , 200 , async ( ) => new Response ( null , { status : 200 } ) ) ) . toBe ( 0 ) ;
93+ }
8094 } ) ;
8195
8296 it ( "returns 0 when the App private key is not configured (App not set up → nothing to export)" , async ( ) => {
@@ -179,7 +193,7 @@ describe("exportOrbBatch() — always-on; reads review_audit, ships anonymized r
179193 expect ( sig ) . toMatch ( / ^ s h a 2 5 6 = [ a - f 0 - 9 ] { 64 } $ / ) ;
180194 } ) ;
181195
182- it ( "falls back to GITHUB_APP_ID for the instance id and applies the anonymize default when ORB_* are unset" , async ( ) => {
196+ it ( "falls back to GITHUB_APP_ID for the instance id and applies the anonymize default when optional ORB_* are unset" , async ( ) => {
183197 delete process . env . ORB_APP_ID ; // → falls through to GITHUB_APP_ID
184198 delete process . env . ORB_ANONYMIZE ; // → defaults to "true"
185199 ( process . env as NodeJS . Dict < string > ) . GITHUB_APP_ID = "999" ;
0 commit comments