@@ -40,13 +40,20 @@ function makeDedicatedStore(prisma17: RunOpsPrismaClient) {
4040}
4141
4242function makeLegacyStore ( prisma14 : PrismaClient ) {
43- return new PostgresRunStore ( { prisma : prisma14 , readOnlyPrisma : prisma14 , schemaVariant : "legacy" } ) ;
43+ return new PostgresRunStore ( {
44+ prisma : prisma14 ,
45+ readOnlyPrisma : prisma14 ,
46+ schemaVariant : "legacy" ,
47+ } ) ;
4448}
4549
4650// Wrap a real store so findRun/findRunOnPrimary calls are COUNTED while every method still delegates
4751// to the REAL PostgresRunStore (this is instrumentation, not a behavior mock — the underlying reads,
4852// writes, getters all run for real). Lets us assert the FAST PATH does not touch the other store.
49- function countingReads ( inner : RunStore , counts : { findRun : number ; findRunOnPrimary : number } ) : RunStore {
53+ function countingReads (
54+ inner : RunStore ,
55+ counts : { findRun : number ; findRunOnPrimary : number }
56+ ) : RunStore {
5057 return new Proxy ( inner , {
5158 get ( target , prop ) {
5259 // Read via target[prop] so getters (e.g. primaryReadClient) run with `this` = the real store.
@@ -139,7 +146,13 @@ function buildCreateRunInput(params: {
139146// residency/classification MISMATCH: the row is physically on #new while `classify` calls its id LEGACY.
140147async function insertRunOnNewStore (
141148 prisma17 : RunOpsPrismaClient ,
142- params : { runId : string ; friendlyId : string ; environmentId : string ; organizationId : string ; projectId : string }
149+ params : {
150+ runId : string ;
151+ friendlyId : string ;
152+ environmentId : string ;
153+ organizationId : string ;
154+ projectId : string ;
155+ }
143156) {
144157 await prisma17 . taskRun . create ( {
145158 data : {
@@ -258,21 +271,26 @@ describe("RoutingRunStore.findRun — on-miss fan-out for a classifiable id (res
258271 newCounts . findRun = 0 ;
259272 legacyCounts . findRun = 0 ;
260273
261- const hitLegacy = ( await router . findRun ( { id : legacyId } , { select : { id : true } } ) ) as Record <
262- string ,
263- unknown
264- > | null ;
274+ const hitLegacy = ( await router . findRun (
275+ { id : legacyId } ,
276+ { select : { id : true } }
277+ ) ) as Record < string , unknown > | null ;
265278 expect ( hitLegacy ?. id ) . toBe ( legacyId ) ;
266279 expect ( legacyCounts . findRun ) . toBe ( 1 ) ;
267280 expect ( newCounts . findRun ) . toBe ( 0 ) ;
268281 }
269282 ) ;
270283
271284 // ── A genuine miss on BOTH stores still returns null (fan-out exhausted) ──
272- heteroRunOpsPostgresTest ( "returns null when the run is on neither store" , async ( { prisma14, prisma17 } ) => {
273- const newStore = makeDedicatedStore ( prisma17 ) ;
274- const legacyStore = makeLegacyStore ( prisma14 ) ;
275- const router = new RoutingRunStore ( { new : newStore , legacy : legacyStore } ) ;
276- expect ( await router . findRun ( { id : cuidLegacy ( "ghost" ) } , { select : { id : true } } ) ) . toBeNull ( ) ;
277- } ) ;
285+ heteroRunOpsPostgresTest (
286+ "returns null when the run is on neither store" ,
287+ async ( { prisma14, prisma17 } ) => {
288+ const newStore = makeDedicatedStore ( prisma17 ) ;
289+ const legacyStore = makeLegacyStore ( prisma14 ) ;
290+ const router = new RoutingRunStore ( { new : newStore , legacy : legacyStore } ) ;
291+ expect (
292+ await router . findRun ( { id : cuidLegacy ( "ghost" ) } , { select : { id : true } } )
293+ ) . toBeNull ( ) ;
294+ }
295+ ) ;
278296} ) ;
0 commit comments