Skip to content

Commit 422cb22

Browse files
committed
feat: Genie Space AI config, three-file split, and README cleanup
- Add AI-generated Genie Space config (sample questions, instructions, benchmarks, title, description) via serialized_space API - Split auth.auto.tfvars into auth (secrets, gitignored) and env (tables/warehouse/genie, checked in) for safe git tracking - Rebuild genie_space.sh with Python-based JSON builder for proper serialized_space construction (version 2, sorted IDs, 32-char hex) - Simplify README: remove reference tables, trim troubleshooting, clean up Advanced Usage, update flowchart with two-box layout - Improve generate_abac.py output with clickable file paths and clearer next-step guidance - Update all docs and examples for three-file config pattern Made-with: Cursor
1 parent 284bfd8 commit 422cb22

23 files changed

Lines changed: 700 additions & 541 deletions

uc-quickstart/utils/genie/aws/ABAC_PROMPT.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,42 @@ Violating any of these causes validation failures. Double-check consistency acro
228228
6. Select masking functions from the library above (or create new ones)
229229
7. Generate both output files. For entity names in tag_assignments, always use **fully qualified** names (`catalog.schema.table` or `catalog.schema.table.column`). For function_name in fgac_policies, use relative names only (e.g. `mask_pii`). Every fgac_policy MUST include `catalog`, `function_catalog`, and `function_schema`. **CRITICAL**: set `function_schema` to the schema where the tagged columns actually live — do NOT default all policies to the first schema. In `masking_functions.sql`, group the `CREATE FUNCTION` statements by schema with separate `USE SCHEMA` blocks. Only create each function in the schema where it is needed
230230
8. Every `match_condition` and `when_condition` MUST only use `hasTagValue()` and/or `hasTag()` — no other functions or operators
231+
9. Generate Genie Space config — all five fields below. Tailor everything to the user's actual tables, domain, and business context:
232+
- `genie_space_title` — a concise, descriptive title (e.g., "Financial Compliance Analytics", "Clinical Data Explorer")
233+
- `genie_space_description` — 1–2 sentence summary of what the space covers and who it's for
234+
- `genie_sample_questions` — 5–10 natural-language questions a business user would ask (shown as conversation starters in the UI)
235+
- `genie_instructions` — domain-specific guidance for the Genie LLM (e.g., how to calculate metrics, date conventions, terminology, masking behaviour awareness)
236+
- `genie_benchmarks` — 3–5 benchmark questions with ground-truth SQL for evaluating accuracy
237+
238+
### Output Format — Genie Space Config (in `abac.auto.tfvars`)
239+
240+
Include these variables alongside groups, tag_policies, etc.:
241+
242+
```hcl
243+
genie_space_title = "Financial & Clinical Analytics"
244+
genie_space_description = "Explore transaction data, patient encounters, and compliance metrics. Designed for analysts, compliance officers, and clinical staff."
245+
246+
genie_sample_questions = [
247+
"What is the total revenue by region for last quarter?",
248+
"Show the top 10 customers by transaction volume",
249+
"Which accounts have been flagged for AML review?",
250+
"How many patient encounters occurred last month?",
251+
"What is the average transaction amount by account type?",
252+
]
253+
254+
genie_instructions = "When calculating revenue, sum the Amount column. 'Last month' means the previous calendar month (not last 30 days). Round monetary values to 2 decimal places. Patient names are masked for non-clinical roles — queries about patient counts or encounter dates are always allowed."
255+
256+
genie_benchmarks = [
257+
{
258+
question = "What is the total transaction amount?"
259+
sql = "SELECT SUM(Amount) as total_amount FROM catalog.schema.transactions"
260+
},
261+
{
262+
question = "How many patients were seen last month?"
263+
sql = "SELECT COUNT(*) FROM catalog.schema.encounters WHERE EncounterDate >= DATE_TRUNC('month', CURRENT_DATE - INTERVAL 1 MONTH) AND EncounterDate < DATE_TRUNC('month', CURRENT_DATE)"
264+
},
265+
]
266+
```
231267

232268
---
233269

uc-quickstart/utils/genie/aws/GENIE_SPACE_PERMISSIONS.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ This document lists everything that must be in place for business users (the gro
1717

1818
- **SQL warehouse:** A single SQL warehouse is used for both masking function deployment and the Genie Space. Genie embeds on this warehouse; end users do **not** need explicit **CAN USE** on the warehouse.
1919
- **Terraform:** `warehouse.tf` handles warehouse resolution:
20-
- `sql_warehouse_id` set in `auth.auto.tfvars` -> reuses the existing warehouse (dev)
20+
- `sql_warehouse_id` set in `env.auto.tfvars` -> reuses the existing warehouse (dev)
2121
- `sql_warehouse_id` empty or omitted -> auto-creates a serverless warehouse (prod)
2222

2323
## 4. Data access
@@ -27,18 +27,18 @@ This document lists everything that must be in place for business users (the gro
2727

2828
## 5. Genie Space (create + ACLs)
2929

30-
- **Genie Space:** Create a Genie Space with the tables from `uc_tables` (in `auth.auto.tfvars`) and grant at least **CAN VIEW** and **CAN RUN** to all groups.
30+
- **Genie Space:** Create a Genie Space with the tables from `uc_tables` (in `env.auto.tfvars`) and grant at least **CAN VIEW** and **CAN RUN** to all groups.
3131
- **Automation:** Terraform manages Genie Space lifecycle via `genie_space.tf`:
3232
- **`genie_space_id` empty** (greenfield): `terraform apply` auto-creates a Genie Space from `uc_tables`, sets ACLs, and trashes the space on `terraform destroy`.
3333
- **`genie_space_id` set** (existing): `terraform apply` only applies CAN_RUN ACLs to the existing space.
3434

3535
### Auto-create mode
3636

37-
Set `genie_space_id = ""` in `auth.auto.tfvars` and ensure `uc_tables` is non-empty. Terraform runs `genie_space.sh create` automatically during apply. Wildcards (`catalog.schema.*`) are expanded via the UC Tables API.
37+
Set `genie_space_id = ""` in `env.auto.tfvars` and ensure `uc_tables` is non-empty. Terraform runs `genie_space.sh create` automatically during apply. Wildcards (`catalog.schema.*`) are expanded via the UC Tables API.
3838

3939
### Existing space mode
4040

41-
Set `genie_space_id` to your Genie Space ID in `auth.auto.tfvars`. Terraform runs `genie_space.sh set-acls` to grant CAN_RUN to all configured groups.
41+
Set `genie_space_id` to your Genie Space ID in `env.auto.tfvars`. Terraform runs `genie_space.sh set-acls` to grant CAN_RUN to all configured groups.
4242

4343
### Manual script usage
4444

uc-quickstart/utils/genie/aws/IMPORT_EXISTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ If the warehouse, groups, or tag policies **already exist**, Terraform will fail
66

77
Before running the import script, ensure:
88

9-
1. `auth.auto.tfvars` is configured with valid credentials.
9+
1. `auth.auto.tfvars` is configured with valid credentials and `env.auto.tfvars` with your environment.
1010
2. `abac.auto.tfvars` is configured with the groups and tag policies you want to import.
1111
3. `terraform init` has been run.
1212

@@ -32,7 +32,7 @@ The script reads group names from `abac.auto.tfvars` and tag policy keys from th
3232

3333
## Optional: reuse an existing warehouse
3434

35-
To use an existing warehouse instead of auto-creating one, set in **auth.auto.tfvars**:
35+
To use an existing warehouse instead of auto-creating one, set in **env.auto.tfvars**:
3636

3737
```hcl
3838
sql_warehouse_id = "<WAREHOUSE_ID>"

uc-quickstart/utils/genie/aws/Makefile

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ setup: ## Copy example files and prompt for credentials
1313
else \
1414
echo "auth.auto.tfvars already exists — skipping."; \
1515
fi
16+
@if [ ! -f env.auto.tfvars ]; then \
17+
cp env.auto.tfvars.example env.auto.tfvars; \
18+
echo "Created env.auto.tfvars — edit it with your tables and environment config."; \
19+
else \
20+
echo "env.auto.tfvars already exists — skipping."; \
21+
fi
1622
@if [ ! -f abac.auto.tfvars ]; then \
1723
cp abac.auto.tfvars.example abac.auto.tfvars; \
1824
echo "Created abac.auto.tfvars — edit it with your ABAC config."; \
@@ -22,7 +28,10 @@ setup: ## Copy example files and prompt for credentials
2228
@mkdir -p ddl generated
2329
@echo "Created ddl/ and generated/ directories."
2430
@echo ""
25-
@echo "Next: edit auth.auto.tfvars, then run 'make generate' or 'make plan'."
31+
@echo "Next steps:"
32+
@echo " 1. Edit credentials (gitignored): $$(pwd)/auth.auto.tfvars"
33+
@echo " 2. Edit tables & environment: $$(pwd)/env.auto.tfvars"
34+
@echo " 3. Run: make generate"
2635

2736
generate: ## Run generate_abac.py to produce masking SQL + tfvars
2837
@echo "=== Generate ABAC Config ==="
@@ -86,4 +95,4 @@ clean: ## Remove generated files, Terraform state, and .terraform/
8695
rm -rf generated/abac.auto.tfvars generated/masking_functions.sql generated/generated_response.md
8796
rm -rf .terraform *.tfstate *.tfstate.backup .terraform.lock.hcl
8897
@echo "Cleaned generated files and Terraform state."
89-
@echo "NOTE: auth.auto.tfvars and abac.auto.tfvars were NOT removed."
98+
@echo "NOTE: auth.auto.tfvars, env.auto.tfvars, and abac.auto.tfvars were NOT removed."

0 commit comments

Comments
 (0)