Enforcing Minimum Cohort Size in a Databricks App with AI/BI Genie

Fortinbras
New Contributor

Hello, I'm currently building a Databricks App using AppKit and AI/BI Genie to let business users ask natural-language questions over registration and customer-demographic data. For privacy protection, demographic records are currently filtered so that only predefined demographic cohorts containing at least five distinct customers are available. However, Genie can join these records with registration data and apply additional filters or groupings, such as product, date, channel, or location. A cohort that was safe at the source level can therefore become a final result containing fewer than five distinct customers.

We need to enforce a rule equivalent to:

HAVING COUNT(DISTINCT customer_id) >= 5

at the final result level, after all joins, filters, and output grouping have been applied.

We are aiming for a robust privacy control rather than relying on prompt instructions alone, therefore we have considered a few different approaches, like client-side filtering or adding a server-side policy-aware proxy between the Genie plugin and the browser, but would appreciate guidance on the best Databricks-native pattern for this scenario:

  • Is there a recommended way to centrally intercept/govern Genie query-result streams in an AppKit application?
  • Are there established patterns for enforcing minimum cohort thresholds after arbitrary Genie-generated joins and filters?
  • Would you recommend a server-side proxy, a custom agent/tool architecture, trusted SQL functions, or another approach?