     1	export default async function validateIncludeConfigurations ({ context, scopes, log }) {
     2	  const { scopeName } = context
     3	  const scope = scopes[scopeName]
     4	  const relationships = scope.vars.schemaInfo?.schemaRelationships
     5	
     6	  if (!relationships) return
     7	
     8	  // Check each relationship for include configuration
     9	  for (const [relName, relDef] of Object.entries(relationships)) {
    10	    if (relDef.include?.strategy === 'window') {
    11	      // This relationship requires window functions
    12	      // We'll validate this at query time since the database might not be connected yet
    13	      log.debug(`Relationship ${scopeName}.${relName} configured for window function includes`)
    14	    }
    15	
    16	    // Validate include configuration
    17	    if (relDef.include?.limit) {
    18	      if (typeof relDef.include.limit !== 'number') {
    19	        throw new Error(
    20	          `Invalid include limit for ${scopeName}.${relName}: limit must be a number`
    21	        )
    22	      }
    23	      // Check against queryMaxLimit if available
    24	      const maxLimit = scope.vars?.queryMaxLimit
    25	      if (maxLimit && relDef.include.limit > maxLimit) {
    26	        throw new Error(
    27	          `Invalid include limit for ${scopeName}.${relName}: ` +
    28	          `limit (${relDef.include.limit}) exceeds queryMaxLimit (${maxLimit})`
    29	        )
    30	      }
    31	    }
    32	
    33	    if (relDef.include?.orderBy && !Array.isArray(relDef.include.orderBy)) {
    34	      throw new Error(
    35	        `Invalid include orderBy for ${scopeName}.${relName}: orderBy must be an array`
    36	      )
    37	    }
    38	  }
    39	}
