44// REPLICA ONLY; each member run is hydrated independently via the per-run read-through primitive,
55// so a batch whose members span migrated (NEW) + abandoned (LEGACY) runs returns the
66// complete reachable set. Single-DB collapses to one passthrough read. We NEVER mock the DB — the
7- // only injected fakes are the pure boundaries (splitEnabled / isKnownMigrated / isPastRetention).
7+ // only injected fakes are the pure boundaries (splitEnabled / isPastRetention).
88//
99// The BatchTaskRunItem -> TaskRun FK is per-DB; a batch straddling the seam references member ids
1010// that live on the other DB, so we drop that one FK on the batch's DB at seed time (the cross-seam
@@ -196,8 +196,6 @@ const env = (ctx: SeedCtx) =>
196196 project : { name : ctx . project . name } ,
197197 } ) as unknown as AuthenticatedEnvironment ;
198198
199- const neverMigrated = async ( ) => false ;
200-
201199describe ( "ApiBatchResultsPresenter read-through (legacy + new DB)" , ( ) => {
202200 // A batch with members on BOTH DBs returns the complete set, byte-identical.
203201 heteroPostgresTest (
@@ -235,7 +233,6 @@ describe("ApiBatchResultsPresenter read-through (legacy + new DB)", () => {
235233 splitEnabled : true ,
236234 newClient : prisma17 as unknown as PrismaReplicaClient ,
237235 legacyReplica : prisma14 as unknown as PrismaReplicaClient ,
238- isKnownMigrated : neverMigrated ,
239236 } ) ;
240237
241238 const result = await presenter . call ( "batch_span" , env ( ctx ) ) ;
@@ -286,7 +283,6 @@ describe("ApiBatchResultsPresenter read-through (legacy + new DB)", () => {
286283 splitEnabled : true ,
287284 newClient : prisma17 as unknown as PrismaReplicaClient ,
288285 legacyReplica : prisma14 as unknown as PrismaReplicaClient ,
289- isKnownMigrated : neverMigrated ,
290286 } ) ;
291287
292288 const result = await presenter . call ( "batch_legacy" , env ( ctx ) ) ;
@@ -298,69 +294,6 @@ describe("ApiBatchResultsPresenter read-through (legacy + new DB)", () => {
298294 }
299295 ) ;
300296
301- // A known-migrated member is not re-probed against the legacy replica.
302- heteroPostgresTest (
303- "a known-migrated member missing from the new probe is NOT re-probed on legacy" ,
304- async ( { prisma14, prisma17 } ) => {
305- const newDb = prisma17 as unknown as PrismaClient ;
306- const legacyDb = prisma14 as unknown as PrismaClient ;
307-
308- const ctx = await seedEnv ( newDb , "mig-new" ) ;
309- await mirrorEnv ( legacyDb , ctx , "mig-legacy" ) ;
310- await relaxFks ( newDb ) ;
311- await relaxFks ( legacyDb ) ;
312-
313- // A legacy-classified id (so the LEGACY fan-out branch is reachable) that is "known migrated".
314- const migratedId = legacyRunId ( "d" ) ;
315- // Seed the member ONLY on legacy, but mark it known-migrated → legacy must NOT be probed,
316- // so it resolves to not-found and is omitted.
317- await seedMember ( legacyDb , ctx , {
318- id : migratedId ,
319- friendlyId : "run_migrated_d" ,
320- status : "COMPLETED_SUCCESSFULLY" ,
321- output : JSON . stringify ( { } ) ,
322- } ) ;
323- await seedBatch ( newDb , ctx , "batch_mig" , [ migratedId ] ) ;
324-
325- // Spy legacy replica: throw if the member-hydrate findFirst runs for the migrated id.
326- const legacySpy = new Proxy ( prisma14 , {
327- get ( target , prop ) {
328- if ( prop === "taskRun" ) {
329- return new Proxy ( ( target as any ) . taskRun , {
330- get ( trTarget , trProp ) {
331- if ( trProp === "findFirst" ) {
332- return async ( args : any ) => {
333- if ( args ?. where ?. id === migratedId ) {
334- throw new Error (
335- "legacy replica must not be probed for a known-migrated member"
336- ) ;
337- }
338- return ( trTarget as any ) . findFirst ( args ) ;
339- } ;
340- }
341- return ( trTarget as any ) [ trProp ] ;
342- } ,
343- } ) ;
344- }
345- return ( target as any ) [ prop ] ;
346- } ,
347- } ) as unknown as PrismaReplicaClient ;
348-
349- const presenter = new ApiBatchResultsPresenter ( throwingPrisma , throwingPrisma , {
350- splitEnabled : true ,
351- newClient : prisma17 as unknown as PrismaReplicaClient ,
352- legacyReplica : legacySpy ,
353- isKnownMigrated : async ( id ) => id === migratedId ,
354- } ) ;
355-
356- const result = await presenter . call ( "batch_mig" , env ( ctx ) ) ;
357-
358- expect ( result ) . toBeDefined ( ) ;
359- // Known-migrated + missing from NEW → not-found → omitted, without probing legacy.
360- expect ( result ! . items ) . toHaveLength ( 0 ) ;
361- }
362- ) ;
363-
364297 // Past-retention / missing member is omitted (dangling-ref gate adjacent), not errored.
365298 heteroPostgresTest (
366299 "a member present on neither DB is omitted; the reachable members still return" ,
@@ -388,7 +321,6 @@ describe("ApiBatchResultsPresenter read-through (legacy + new DB)", () => {
388321 splitEnabled : true ,
389322 newClient : prisma17 as unknown as PrismaReplicaClient ,
390323 legacyReplica : prisma14 as unknown as PrismaReplicaClient ,
391- isKnownMigrated : neverMigrated ,
392324 } ) ;
393325
394326 const result = await presenter . call ( "batch_dangle" , env ( ctx ) ) ;
@@ -411,7 +343,6 @@ describe("ApiBatchResultsPresenter read-through (legacy + new DB)", () => {
411343 splitEnabled : true ,
412344 newClient : prisma17 as unknown as PrismaReplicaClient ,
413345 legacyReplica : prisma14 as unknown as PrismaReplicaClient ,
414- isKnownMigrated : neverMigrated ,
415346 } ) ;
416347
417348 const result = await presenter . call ( "batch_does_not_exist" , env ( ctx ) ) ;
@@ -439,16 +370,13 @@ describe("ApiBatchResultsPresenter passthrough (single-DB collapse)", () => {
439370
440371 const runStore = new PostgresRunStore ( { prisma, readOnlyPrisma : prisma } ) ;
441372
442- // Throwing boundaries : if the split path is entered, these blow up.
373+ // Throwing legacy replica : if the split path is entered, it blows up.
443374 const presenter = new ApiBatchResultsPresenter (
444375 prisma ,
445376 prisma ,
446377 {
447378 splitEnabled : false ,
448379 legacyReplica : throwingPrisma ,
449- isKnownMigrated : async ( ) => {
450- throw new Error ( "isKnownMigrated must not be invoked on the passthrough path" ) ;
451- } ,
452380 } ,
453381 runStore
454382 ) ;
0 commit comments