The Context Hierarchy
TextQL applies context in layers, from broadest to most specific. When Ana answers a question, she reads all context that applies to the current user and connector, with more specific context taking precedence over broader context.| Scope | Who sees it | When it applies |
|---|---|---|
| Organization | Everyone | Always |
| Role | Users with that role | Always, for that role |
| Connector | Anyone querying that connector | When that connector is active |
| Role + Connector | Users with that role, querying that connector | When both conditions are met |
What to Put in Context vs. Ontology
Context and ontology serve different purposes. Choosing the right one for a given piece of information makes a meaningful difference in how reliably Ana uses it. Use context for:- Business rules and policies (“Revenue is recognized at time of shipment, not order placement”)
- Fiscal calendar definitions (“Our fiscal year runs July 1 through June 30”)
- Currency and unit conventions (“All financial figures are in USD unless otherwise noted”)
- Terminology that differs from common usage (“In our data, ‘user’ means a paying account, not an individual login”)
- Data quality caveats (“The
legacy_orderstable only contains data through December 2023”) - Exclusion rules (“Internal test accounts have
is_internal = trueand should be excluded from all user metrics”)
- Metric definitions that require specific SQL logic (“Monthly Active Users = distinct user_ids with at least one session in the calendar month, excluding internal accounts”)
- Dimensions and joins that are used frequently (“Customer segment is derived by joining accounts to the segment_mapping table on account_id”)
- Calculations that must be consistent across all users and all questions
High-Impact Context Examples
The following types of context have the highest return on investment. If your organization has not documented these, start here. Fiscal calendar If your fiscal year does not align with the calendar year, Ana will use the wrong periods for “this quarter,” “last year,” and similar relative date references. Document your fiscal year start date and quarter definitions explicitly.“Our fiscal year runs from February 1 to January 31. Q1 is February through April, Q2 is May through July, Q3 is August through October, Q4 is November through January.”Metric definitions Any metric your team discusses regularly — revenue, DAU, churn, conversion rate — should be defined in context or ontology. Even a one-sentence definition prevents Ana from making a different assumption each time.
“Churn rate is calculated as the number of accounts that cancelled in a given month divided by the number of active accounts at the start of that month. Trial accounts are excluded.”Exclusion rules Internal accounts, test users, and bot traffic should be excluded from most analyses. Document the filter once so you do not have to repeat it in every prompt.
“Exclude all accounts whereTable ownership and caveats If certain tables are deprecated, have known data quality issues, or should only be used for specific purposes, document that. Ana will use the most relevant table she can find — if you want her to use a specific one, say so.account_type = 'internal'oremail LIKE '%@yourcompany.com'from user-facing metrics.”
“Useorders_v2for all order analysis. Theorderstable is deprecated and contains data only through Q3 2023.”
Common Mistakes
Too much context (noise) A context document that is hundreds of lines long and covers every edge case will slow Ana down and may cause her to miss the most important rules. Prioritize the 10–15 rules that matter most and keep the document focused. If you find yourself adding caveats to caveats, that is a sign the document needs editing, not expansion. Too little context (Ana guesses) The opposite problem: no context at all, or context that only covers obvious things. Ana will make reasonable assumptions, but “reasonable” may not match your conventions. The most common gaps are fiscal calendar, metric definitions, and exclusion rules. Wrong scope level Putting connector-specific rules in organization context means every user sees them, even when they are not relevant. Putting universal rules in connector context means they only apply when that connector is active. Match the scope to the actual applicability of the rule. Stale context Context that was accurate six months ago may no longer be. If your fiscal year changed, a table was deprecated, or a metric definition was updated, the context document needs to reflect that. Stale context is often worse than no context, because Ana will confidently apply the wrong rule.How to Test Context Changes
Before rolling out a context change to your whole organization, test it with a targeted question.- Note the question you want to test: something that should be directly affected by the context change.
- Ask Ana that question before making the change. Note the answer.
- Make the context change.
- Ask the same question again. Compare the answers.
When to Use GitHub Integration for Version-Controlled Context
For organizations that want to treat context like code — with change history, review processes, and rollback capability — TextQL supports a GitHub integration that syncs context documents from a repository. This is most useful when:- Multiple people are responsible for maintaining context
- You want a review process before context changes go live
- You need an audit trail of what changed and when
- Your context documents are complex enough that accidental edits could cause problems
Cross-References
- Using the Context Editor — how to create and manage context documents
- Context Scoping — detailed guide to organization, role, and connector scoping
- What is Ontology? — when to use ontology instead of context
- Writing Better Prompts — how end users can work effectively with the context you configure