:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(bi): persist catalog query snapshots in worksheet schema (#117991)
Marius Andra52fbbb002808
diff --git a/frontend/src/queries/schema.json b/frontend/src/queries/schema.jsonindex 093e0c267938..792ef874b1ba 100644--- a/frontend/src/queries/schema.json+++ b/frontend/src/queries/schema.json@@ -2204,6 +2204,25 @@"enum": ["exact", "is_not"],"type": "string"},+ "AssistantBIVisualizationNode": {+ "additionalProperties": {},+ "properties": {+ "config": {+ "additionalProperties": {},+ "description": "Complete worksheet configuration, including shelves and filters. Validated by the insight API.",+ "type": "object"+ },+ "kind": {+ "const": "BIVisualizationNode",+ "type": "string"+ },+ "source": {+ "$ref": "#/definitions/AssistantBareHogQLQuery"+ }+ },+ "required": ["kind", "source", "config"],+ "type": "object"+ },"AssistantBareHogQLQuery": {"additionalProperties": {},"properties": {@@ -2408,7 +2427,7 @@"type": "string"},"label": {- "description": "Custom label for this series, shown in the legend and tooltips instead of the column name.",+ "description": "Series label in legends and tooltips; replaces the column name.","type": "string"},"trendLine": {@@ -2435,12 +2454,12 @@"type": "string"},"style": {- "description": "Number formatting style.\n- `none` — no formatting.\n- `number` — thousands separators (e.g. `1,234`).\n- `short` — abbreviated large numbers (e.g. `1.2k`, `3.4M`).\n- `percent` — multiply the value by 100 and append a `%` sign, so pass a 0-1 ratio (`a / b`, not `100.0 * a / b`). Never pair it with a `%` suffix, which renders `47.3%%`.",+ "description": "`none`: unformatted; `number`: thousands separators; `short`: abbreviations (1.2k, 3.4M). `percent`: multiplies by 100 and adds `%`. Pass a 0–1 ratio (`a / b`) and omit the `%` suffix to avoid doubling it.","enum": ["none", "number", "short", "percent"],"type": "string"},"suffix": {- "description": "Text appended to each value (e.g. ` ms`). Leave unset when `style` is `percent`, which already appends the `%` sign.",+ "description": "Value suffix (e.g. ` ms`). Omit for `percent`, which adds `%`.","type": "string"}},@@ -6195,6 +6214,10 @@"BIConfig": {"additionalProperties": false,"properties": {+ "catalogMetric": {+ "description": "Catalog provenance only: the snapshot does not track subsequent definition edits.",+ "type": "string"+ },"chartType": {"$ref": "#/definitions/ChartDisplayType"},@@ -6315,6 +6338,10 @@"$ref": "#/definitions/BIPaneSettings","description": "Split the returned groups into charts using these ordered dimension IDs."},+ "querySnapshot": {+ "$ref": "#/definitions/HogQLQuery",+ "description": "Executable catalog query snapshot. Dates and grouping belong to the definition, not the shelves."+ },"resultFilterGroup": {"$ref": "#/definitions/BIConditionGroup"},@@ -30332,6 +30359,9 @@{"$ref": "#/definitions/AssistantDataTableNode"},+ {+ "$ref": "#/definitions/AssistantBIVisualizationNode"+ },{"$ref": "#/definitions/AssistantInsightVizNode"},diff --git a/frontend/src/queries/schema/schema-assistant-queries.ts b/frontend/src/queries/schema/schema-assistant-queries.tsindex afb7af72e749..12b8ade737da 100644--- a/frontend/src/queries/schema/schema-assistant-queries.ts+++ b/frontend/src/queries/schema/schema-assistant-queries.ts@@ -1881,7 +1881,7 @@ export interface AssistantDataVisualizationAxisDisplaySettings {displayType?: 'auto' | 'line' | 'bar' | 'area'/** Draw a linear trend line for this series. Only meaningful for line, bar, and area charts. */trendLine?: boolean- /** Custom label for this series, shown in the legend and tooltips instead of the column name. */+ /** Series label in legends and tooltips; replaces the column name. */label?: string/** Custom color for this series as a hex string (e.g. `#1d4aff`). */color?: string@@ -1890,14 +1890,11 @@ export interface AssistantDataVisualizationAxisDisplaySettings {export interface AssistantDataVisualizationAxisFormatting {/** Text prepended to each value (e.g. `$`). */prefix?: string- /** Text appended to each value (e.g. ` ms`). Leave unset when `style` is `percent`, which already appends the `%` sign. */+ /** Value suffix (e.g. ` ms`). Omit for `percent`, which adds `%`. */suffix?: string/**- * Number formatting style.- * - `none` — no formatting.- * - `number` — thousands separators (e.g. `1,234`).- * - `short` — abbreviated large numbers (e.g. `1.2k`, `3.4M`).- * - `percent` — multiply the value by 100 and append a `%` sign, so pass a 0-1 ratio (`a / b`, not `100.0 * a / b`). Never pair it with a `%` suffix, which renders `47.3%%`.+ * `none`: unformatted; `number`: thousands separators; `short`: abbreviations (1.2k, 3.4M).+ * `percent`: multiplies by 100 and adds `%`. Pass a 0–1 ratio (`a / b`) and omit the `%` suffix to avoid doubling it.*/style?: 'none' | 'number' | 'short' | 'percent'/** Number of decimal places to display. */@@ -2072,10 +2069,20 @@ export interface AssistantDataTableNode {[key: string]: unknown}+export interface AssistantBIVisualizationNode {+ kind: NodeKind.BIVisualizationNode+ source: AssistantBareHogQLQuery+ /** Complete worksheet configuration, including shelves and filters. Validated by the insight API. */+ config: Record<string, unknown>+ // Preserve display settings without expanding recursive worksheet filters in the tool schema.+ [key: string]: unknown+}+// Zod fills in omitted kinds and takes the first matching union branch. Match events sources// before the generic insight wrapper so inferred tables keep their kind and table settings.export type InsightQuery =| AssistantDataTableNode+ | AssistantBIVisualizationNode| AssistantInsightVizNode| AssistantDataVisualizationNode| AssistantBareInsightQuerydiff --git a/frontend/src/queries/schema/schema-business-intelligence.ts b/frontend/src/queries/schema/schema-business-intelligence.tsindex adcb5bbba1f6..13258f4278b7 100644--- a/frontend/src/queries/schema/schema-business-intelligence.ts+++ b/frontend/src/queries/schema/schema-business-intelligence.ts@@ -150,6 +150,10 @@ export interface BIPaneSettings {export interface BIConfig {source: BIDataSource | null+ /** Executable catalog query snapshot. Dates and grouping belong to the definition, not the shelves. */+ querySnapshot?: HogQLQuery+ /** Catalog provenance only: the snapshot does not track subsequent definition edits. */+ catalogMetric?: string/** Reusable expressions owned by this worksheet only. */localFields?: BIField[]/** Named dimension sequences saved with the worksheet; imports are independent copies. */diff --git a/posthog/schema.py b/posthog/schema.pyindex 29aea646b5a1..eb19ff701b69 100644--- a/posthog/schema.py+++ b/posthog/schema.py@@ -521,7 +521,7 @@ class AssistantDataVisualizationAxisDisplaySettings(BaseModel):displayType: DisplayType | None = Field(default=None, description="Chart type. `auto` uses `display`.")label: str | None = Field(default=None,- description=("Custom label for this series, shown in the legend and tooltips instead of the column name."),+ description="Series label in legends and tooltips; replaces the column name.",)trendLine: bool | None = Field(default=None,@@ -542,19 +542,14 @@ class AssistantDataVisualizationAxisFormatting(BaseModel):style: Style | None = Field(default=None,description=(- "Number formatting style.\n- `none` — no formatting.\n- `number` —"- " thousands separators (e.g. `1,234`).\n- `short` — abbreviated large"- " numbers (e.g. `1.2k`, `3.4M`).\n- `percent` — multiply the value by 100"- " and append a `%` sign, so pass a 0-1 ratio (`a / b`, not `100.0 * a /"- " b`). Never pair it with a `%` suffix, which renders `47.3%%`."+ "`none`: unformatted; `number`: thousands separators; `short`:"+ " abbreviations (1.2k, 3.4M). `percent`: multiplies by 100 and adds `%`."+ " Pass a 0–1 ratio (`a / b`) and omit the `%` suffix to avoid doubling it."),)suffix: str | None = Field(default=None,- description=(- "Text appended to each value (e.g. ` ms`). Leave unset when `style` is"- " `percent`, which already appends the `%` sign."- ),+ description="Value suffix (e.g. ` ms`). Omit for `percent`, which adds `%`.",)@@ -3847,6 +3842,15 @@ class AssistantArrayPropertyFilter(BaseModel):)+class AssistantBIVisualizationNode(BaseModel):+ config: dict[str, Any] = Field(+ ...,+ description=("Complete worksheet configuration, including shelves and filters. Validated by the insight API."),+ )+ kind: Literal["BIVisualizationNode"] = "BIVisualizationNode"+ source: AssistantBareHogQLQuery++class AssistantBareInsightQuery(BaseModel):kind: InsightNodeKind@@ -11425,56 +11429,6 @@ class MemberAliase(BaseModel):field: BIField-class BIConfig(BaseModel):- model_config = ConfigDict(- extra="forbid",- )- chartType: ChartDisplayType- colorBy: str | None = None- columns: list[BIField]- compareFilter: CompareFilter | None = None- comparisonPeriod: ComparisonPeriod | None = Field(- default=None,- description=("Explore only the comparison window, using dateRange as its reference window."),- )- dateField: BIField | None = Field(- default=None,- description="Column that receives the worksheet and dashboard date range.",- )- dateRange: DateRange | None = None- filters: list[BIFilter]- hierarchies: list[BIHierarchy] | None = Field(- default=None,- description=("Named dimension sequences saved with the worksheet; imports are independent copies."),- )- hierarchyDrillPath: list[HierarchyDrillPathItem] | None = None- limit: BIQueryLimit- localFields: list[BIField] | None = Field(- default=None, description="Reusable expressions owned by this worksheet only."- )- memberAliases: list[MemberAliase] | None = None- missingDates: MissingDates | None = Field(- default=None,- description=("Fill missing date buckets before table calculations. Unset preserves observed points only."),- )- panes: BIPaneSettings | None = Field(- default=None,- description=("Split the returned groups into charts using these ordered dimension IDs."),- )- resultFilterGroup: BIConditionGroup | None = None- resultFilters: list[BIResultFilter] | None = None- rowFilterGroup: BIConditionGroup | None = None- rows: list[BIField]- sort: BISort | None = Field(- default=None,- description=("null sorts automatically: newest date or highest value first, so top rows survive the LIMIT."),- )- source: BIDataSource | None = None- topN: BITopN | None = None- totals: BITotals | None = None- values: list[BIValue]--class BehavioralPropertyFilter(BaseModel):model_config = ConfigDict(extra="forbid",@@ -19011,6 +18965,7 @@ class InsightActorsQueryBase(BaseModel):class InsightQuery(RootModel[AssistantDataTableNode+ | AssistantBIVisualizationNode| AssistantInsightVizNode| AssistantDataVisualizationNode| AssistantBareInsightQuery@@ -19020,6 +18975,7 @@ class InsightQuery():root: (AssistantDataTableNode+ | AssistantBIVisualizationNode| AssistantInsightVizNode| AssistantDataVisualizationNode| AssistantBareInsightQuery@@ -31033,6 +30989,66 @@ class TraceSpansTreeQuery(BaseModel):version: float | None = Field(default=None, description="version of the node, used for schema migrations")+class BIConfig(BaseModel):+ model_config = ConfigDict(+ extra="forbid",+ )+ catalogMetric: str | None = Field(+ default=None,+ description=("Catalog provenance only: the snapshot does not track subsequent definition edits."),+ )+ chartType: ChartDisplayType+ colorBy: str | None = None+ columns: list[BIField]+ compareFilter: CompareFilter | None = None+ comparisonPeriod: ComparisonPeriod | None = Field(+ default=None,+ description=("Explore only the comparison window, using dateRange as its reference window."),+ )+ dateField: BIField | None = Field(+ default=None,+ description="Column that receives the worksheet and dashboard date range.",+ )+ dateRange: DateRange | None = None+ filters: list[BIFilter]+ hierarchies: list[BIHierarchy] | None = Field(+ default=None,+ description=("Named dimension sequences saved with the worksheet; imports are independent copies."),+ )+ hierarchyDrillPath: list[HierarchyDrillPathItem] | None = None+ limit: BIQueryLimit+ localFields: list[BIField] | None = Field(+ default=None, description="Reusable expressions owned by this worksheet only."+ )+ memberAliases: list[MemberAliase] | None = None+ missingDates: MissingDates | None = Field(+ default=None,+ description=("Fill missing date buckets before table calculations. Unset preserves observed points only."),+ )+ panes: BIPaneSettings | None = Field(+ default=None,+ description=("Split the returned groups into charts using these ordered dimension IDs."),+ )+ querySnapshot: HogQLQuery | None = Field(+ default=None,+ description=(+ "Executable catalog query snapshot. Dates and grouping belong to the definition, not the shelves."+ ),+ )+ resultFilterGroup: BIConditionGroup | None = None+ resultFilters: list[BIResultFilter] | None = None+ rowFilterGroup: BIConditionGroup | None = None+ rows: list[BIField]+ sort: BISort | None = Field(+ default=None,+ description=("null sorts automatically: newest date or highest value first, so top rows survive the LIMIT."),+ )+ source: BIDataSource | None = None+ topN: BITopN | None = None+ totals: BITotals | None = None+ values: list[BIValue]++class BIVisualizationNode(BaseModel):model_config = ConfigDict(extra="forbid",diff --git a/products/dashboards/frontend/generated/api.schemas.ts b/products/dashboards/frontend/generated/api.schemas.tsindex 67ea8aaa2d7d..67b7b3ebe9d9 100644--- a/products/dashboards/frontend/generated/api.schemas.ts+++ b/products/dashboards/frontend/generated/api.schemas.ts@@ -9619,6 +9619,8 @@ export interface BIValueApi {}export interface BIConfigApi {+ /** Catalog provenance only: the snapshot does not track subsequent definition edits. */+ catalogMetric?: string | nullchartType: ChartDisplayTypeApicolorBy?: string | nullcolumns: BIFieldApi[]@@ -9640,6 +9642,8 @@ export interface BIConfigApi {missingDates?: MissingDatesApi | null/** Split the returned groups into charts using these ordered dimension IDs. */panes?: BIPaneSettingsApi | null+ /** Executable catalog query snapshot. Dates and grouping belong to the definition, not the shelves. */+ querySnapshot?: HogQLQueryApi | nullresultFilterGroup?: BIConditionGroupApi | nullresultFilters?: BIResultFilterApi[] | nullrowFilterGroup?: BIConditionGroupApi | nulldiff --git a/products/desktop/packages/api-client/src/generated.ts b/products/desktop/packages/api-client/src/generated.tsindex e76d4a96749e..271258e1e668 100644--- a/products/desktop/packages/api-client/src/generated.ts+++ b/products/desktop/packages/api-client/src/generated.ts@@ -4794,6 +4794,7 @@ export namespace Schemas {tableCalculation?: (BITableCalculation | null) | undefined;};export type BIConfig = {+ catalogMetric?: (string | null) | undefined;chartType: ChartDisplayType;colorBy?: (string | null) | undefined;columns: Array<BIField>;@@ -4809,6 +4810,7 @@ export namespace Schemas {memberAliases?: (Array<MemberAliase> | null) | undefined;missingDates?: (MissingDates | null) | undefined;panes?: (BIPaneSettings | null) | undefined;+ querySnapshot?: (HogQLQuery | null) | undefined;resultFilterGroup?: (BIConditionGroup | null) | undefined;resultFilters?: (Array<BIResultFilter> | null) | undefined;rowFilterGroup?: (BIConditionGroup | null) | undefined;diff --git a/products/product_analytics/backend/tests/api/test_insight_query.py b/products/product_analytics/backend/tests/api/test_insight_query.pyindex 3e806deffc1e..3dff00da5361 100644--- a/products/product_analytics/backend/tests/api/test_insight_query.py+++ b/products/product_analytics/backend/tests/api/test_insight_query.py@@ -568,7 +568,8 @@ class TestInsight(ClickhouseTestMixin, LicensedTestMixin, APIBaseTest, QueryMatcassert update_response.json()["query"] == response.json()["query"]assert Insight.objects.get(pk=insight_id).query == stored_query- def test_mcp_bi_member_alias_null_round_trip(self) -> None:+ def test_mcp_bi_config_round_trip(self) -> None:+ query_snapshot = {"kind": "HogQLQuery", "query": "SELECT 1"}aliases = [{"field": {@@ -594,6 +595,8 @@ class TestInsight(ClickhouseTestMixin, LicensedTestMixin, APIBaseTest, QueryMatc"limit": 1000,"memberAliases": aliases,"colorBy": None,+ "querySnapshot": query_snapshot,+ "catalogMetric": "example_total",},}response = self.client.post(@@ -612,6 +615,8 @@ class TestInsight(ClickhouseTestMixin, LicensedTestMixin, APIBaseTest, QueryMatcsaved = self.client.get(f"/api/projects/{self.team.id}/insights/{insight_id}/?basic=true").json()["query"]assert saved["config"]["memberAliases"] == aliasesassert saved["config"]["colorBy"] is None+ assert saved["config"]["querySnapshot"] == query_snapshot+ assert saved["config"]["catalogMetric"] == "example_total"def test_mcp_create_rejects_disallowed_query_kind(self) -> None:response = self.client.post(diff --git a/products/product_analytics/frontend/generated/api.schemas.ts b/products/product_analytics/frontend/generated/api.schemas.tsindex 6afe013c3822..7e750350c477 100644--- a/products/product_analytics/frontend/generated/api.schemas.ts+++ b/products/product_analytics/frontend/generated/api.schemas.ts@@ -8497,6 +8497,8 @@ export interface BIValueApi {}export interface BIConfigApi {+ /** Catalog provenance only: the snapshot does not track subsequent definition edits. */+ catalogMetric?: string | nullchartType: ChartDisplayTypeApicolorBy?: string | nullcolumns: BIFieldApi[]@@ -8518,6 +8520,8 @@ export interface BIConfigApi {missingDates?: MissingDatesApi | null/** Split the returned groups into charts using these ordered dimension IDs. */panes?: BIPaneSettingsApi | null+ /** Executable catalog query snapshot. Dates and grouping belong to the definition, not the shelves. */+ querySnapshot?: HogQLQueryApi | nullresultFilterGroup?: BIConditionGroupApi | nullresultFilters?: BIResultFilterApi[] | nullrowFilterGroup?: BIConditionGroupApi | nulldiff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex 590239f14c74..a39f73b661a0 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -11067,6 +11067,8 @@ export namespace Schemas {}export interface BIConfig {+ /** Catalog provenance only: the snapshot does not track subsequent definition edits. */+ catalogMetric?: string | null;chartType: ChartDisplayType;colorBy?: string | null;columns: BIField[];@@ -11088,6 +11090,8 @@ export namespace Schemas {missingDates?: MissingDates | null;/** Split the returned groups into charts using these ordered dimension IDs. */panes?: BIPaneSettings | null;+ /** Executable catalog query snapshot. Dates and grouping belong to the definition, not the shelves. */+ querySnapshot?: HogQLQuery | null;resultFilterGroup?: BIConditionGroup | null;resultFilters?: BIResultFilter[] | null;rowFilterGroup?: BIConditionGroup | null;diff --git a/services/mcp/src/tools/generated/product_analytics.ts b/services/mcp/src/tools/generated/product_analytics.tsindex 1455617d8f01..99c7723b4693 100644--- a/services/mcp/src/tools/generated/product_analytics.ts+++ b/services/mcp/src/tools/generated/product_analytics.ts@@ -30,6 +30,23 @@ const AssistantDataTableNode = z}).catchall(z.unknown())+const AssistantBareHogQLQuery = z+ .object({+ kind: z.literal('HogQLQuery').default('HogQLQuery'),+ query: z.string().describe('The HogQL query to run.'),+ })+ .catchall(z.unknown())++const AssistantBIVisualizationNode = z+ .object({+ config: z+ .record(z.string(), z.unknown())+ .describe('Complete worksheet configuration, including shelves and filters. Validated by the insight API.'),+ kind: z.literal('BIVisualizationNode').default('BIVisualizationNode'),+ source: AssistantBareHogQLQuery,+ })+ .catchall(z.unknown())+const AssistantPieChartOptions = z.object({hideAggregation: z.coerce.boolean().describe('Hide the total on a pie chart.').optional(),})@@ -111,10 +128,7 @@ const PieChartSettings = z.object({const AssistantDataVisualizationAxisDisplaySettings = z.object({color: z.string().describe('Custom color for this series as a hex string (e.g. `#1d4aff`).').optional(),displayType: z.enum(['auto', 'line', 'bar', 'area']).describe('Chart type. `auto` uses `display`.').optional(),- label: z- .string()- .describe('Custom label for this series, shown in the legend and tooltips instead of the column name.')- .optional(),+ label: z.string().describe('Series label in legends and tooltips; replaces the column name.').optional(),trendLine: z.coerce.boolean().describe('Draw a linear trend line for this series. Only meaningful for line, bar, and area charts.')@@ -131,15 +145,10 @@ const AssistantDataVisualizationAxisFormatting = z.object({style: z.enum(['none', 'number', 'short', 'percent']).describe(- 'Number formatting style.\n- `none` — no formatting.\n- `number` — thousands separators (e.g. `1,234`).\n- `short` — abbreviated large numbers (e.g. `1.2k`, `3.4M`).\n- `percent` — multiply the value by 100 and append a `%` sign, so pass a 0-1 ratio (`a / b`, not `100.0 * a / b`). Never pair it with a `%` suffix, which renders `47.3%%`.'- )- .optional(),- suffix: z- .string()- .describe(- 'Text appended to each value (e.g. ` ms`). Leave unset when `style` is `percent`, which already appends the `%` sign.'+ '`none`: unformatted; `number`: thousands separators; `short`: abbreviations (1.2k, 3.4M). `percent`: multiplies by 100 and adds `%`. Pass a 0–1 ratio (`a / b`) and omit the `%` suffix to avoid doubling it.').optional(),+ suffix: z.string().describe('Value suffix (e.g. ` ms`). Omit for `percent`, which adds `%`.').optional(),})const AssistantDataVisualizationAxisSettings = z.object({@@ -267,15 +276,9 @@ const AssistantBareInsightQuery = z}).catchall(z.unknown())-const AssistantBareHogQLQuery = z- .object({- kind: z.literal('HogQLQuery').default('HogQLQuery'),- query: z.string().describe('The HogQL query to run.'),- })- .catchall(z.unknown())-const InsightQuery = z.union([AssistantDataTableNode,+ AssistantBIVisualizationNode,AssistantInsightVizNode,AssistantDataVisualizationNode,AssistantBareInsightQuery,diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/insight-create.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/insight-create.jsonindex 5b70ae225044..08570ac9cc4b 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/insight-create.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/insight-create.json@@ -67,6 +67,42 @@"required": ["source"],"type": "object"},+ {+ "additionalProperties": {},+ "properties": {+ "config": {+ "additionalProperties": {},+ "description": "Complete worksheet configuration, including shelves and filters. Validated by the insight API.",+ "propertyNames": {+ "type": "string"+ },+ "type": "object"+ },+ "kind": {+ "const": "BIVisualizationNode",+ "default": "BIVisualizationNode",+ "type": "string"+ },+ "source": {+ "additionalProperties": {},+ "properties": {+ "kind": {+ "const": "HogQLQuery",+ "default": "HogQLQuery",+ "type": "string"+ },+ "query": {+ "description": "The HogQL query to run.",+ "type": "string"+ }+ },+ "required": ["query"],+ "type": "object"+ }+ },+ "required": ["config", "source"],+ "type": "object"+ },{"properties": {"kind": {@@ -334,7 +370,7 @@"type": "string"},"label": {- "description": "Custom label for this series, shown in the legend and tooltips instead of the column name.",+ "description": "Series label in legends and tooltips; replaces the column name.","type": "string"},"trendLine": {@@ -361,12 +397,12 @@"type": "string"},"style": {- "description": "Number formatting style.\n- `none` — no formatting.\n- `number` — thousands separators (e.g. `1,234`).\n- `short` — abbreviated large numbers (e.g. `1.2k`, `3.4M`).\n- `percent` — multiply the value by 100 and append a `%` sign, so pass a 0-1 ratio (`a / b`, not `100.0 * a / b`). Never pair it with a `%` suffix, which renders `47.3%%`.",+ "description": "`none`: unformatted; `number`: thousands separators; `short`: abbreviations (1.2k, 3.4M). `percent`: multiplies by 100 and adds `%`. Pass a 0–1 ratio (`a / b`) and omit the `%` suffix to avoid doubling it.","enum": ["none", "number", "short", "percent"],"type": "string"},"suffix": {- "description": "Text appended to each value (e.g. ` ms`). Leave unset when `style` is `percent`, which already appends the `%` sign.",+ "description": "Value suffix (e.g. ` ms`). Omit for `percent`, which adds `%`.","type": "string"}},@@ -407,7 +443,7 @@"type": "string"},"label": {- "description": "Custom label for this series, shown in the legend and tooltips instead of the column name.",+ "description": "Series label in legends and tooltips; replaces the column name.","type": "string"},"trendLine": {@@ -434,12 +470,12 @@"type": "string"},"style": {- "description": "Number formatting style.\n- `none` — no formatting.\n- `number` — thousands separators (e.g. `1,234`).\n- `short` — abbreviated large numbers (e.g. `1.2k`, `3.4M`).\n- `percent` — multiply the value by 100 and append a `%` sign, so pass a 0-1 ratio (`a / b`, not `100.0 * a / b`). Never pair it with a `%` suffix, which renders `47.3%%`.",+ "description": "`none`: unformatted; `number`: thousands separators; `short`: abbreviations (1.2k, 3.4M). `percent`: multiplies by 100 and adds `%`. Pass a 0–1 ratio (`a / b`) and omit the `%` suffix to avoid doubling it.","enum": ["none", "number", "short", "percent"],"type": "string"},"suffix": {- "description": "Text appended to each value (e.g. ` ms`). Leave unset when `style` is `percent`, which already appends the `%` sign.",+ "description": "Value suffix (e.g. ` ms`). Omit for `percent`, which adds `%`.","type": "string"}},@@ -517,7 +553,7 @@"type": "string"},"label": {- "description": "Custom label for this series, shown in the legend and tooltips instead of the column name.",+ "description": "Series label in legends and tooltips; replaces the column name.","type": "string"},"trendLine": {@@ -544,12 +580,12 @@"type": "string"},"style": {- "description": "Number formatting style.\n- `none` — no formatting.\n- `number` — thousands separators (e.g. `1,234`).\n- `short` — abbreviated large numbers (e.g. `1.2k`, `3.4M`).\n- `percent` — multiply the value by 100 and append a `%` sign, so pass a 0-1 ratio (`a / b`, not `100.0 * a / b`). Never pair it with a `%` suffix, which renders `47.3%%`.",+ "description": "`none`: unformatted; `number`: thousands separators; `short`: abbreviations (1.2k, 3.4M). `percent`: multiplies by 100 and adds `%`. Pass a 0–1 ratio (`a / b`) and omit the `%` suffix to avoid doubling it.","enum": ["none", "number", "short", "percent"],"type": "string"},"suffix": {- "description": "Text appended to each value (e.g. ` ms`). Leave unset when `style` is `percent`, which already appends the `%` sign.",+ "description": "Value suffix (e.g. ` ms`). Omit for `percent`, which adds `%`.","type": "string"}},diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/insight-update.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/insight-update.jsonindex 053ada5d0d74..be5edcb6b1c1 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/insight-update.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/insight-update.json@@ -78,6 +78,42 @@"required": ["source"],"type": "object"},+ {+ "additionalProperties": {},+ "properties": {+ "config": {+ "additionalProperties": {},+ "description": "Complete worksheet configuration, including shelves and filters. Validated by the insight API.",+ "propertyNames": {+ "type": "string"+ },+ "type": "object"+ },+ "kind": {+ "const": "BIVisualizationNode",+ "default": "BIVisualizationNode",+ "type": "string"+ },+ "source": {+ "additionalProperties": {},+ "properties": {+ "kind": {+ "const": "HogQLQuery",+ "default": "HogQLQuery",+ "type": "string"+ },+ "query": {+ "description": "The HogQL query to run.",+ "type": "string"+ }+ },+ "required": ["query"],+ "type": "object"+ }+ },+ "required": ["config", "source"],+ "type": "object"+ },{"properties": {"kind": {@@ -345,7 +381,7 @@"type": "string"},"label": {- "description": "Custom label for this series, shown in the legend and tooltips instead of the column name.",+ "description": "Series label in legends and tooltips; replaces the column name.","type": "string"},"trendLine": {@@ -372,12 +408,12 @@"type": "string"},"style": {- "description": "Number formatting style.\n- `none` — no formatting.\n- `number` — thousands separators (e.g. `1,234`).\n- `short` — abbreviated large numbers (e.g. `1.2k`, `3.4M`).\n- `percent` — multiply the value by 100 and append a `%` sign, so pass a 0-1 ratio (`a / b`, not `100.0 * a / b`). Never pair it with a `%` suffix, which renders `47.3%%`.",+ "description": "`none`: unformatted; `number`: thousands separators; `short`: abbreviations (1.2k, 3.4M). `percent`: multiplies by 100 and adds `%`. Pass a 0–1 ratio (`a / b`) and omit the `%` suffix to avoid doubling it.","enum": ["none", "number", "short", "percent"],"type": "string"},"suffix": {- "description": "Text appended to each value (e.g. ` ms`). Leave unset when `style` is `percent`, which already appends the `%` sign.",+ "description": "Value suffix (e.g. ` ms`). Omit for `percent`, which adds `%`.","type": "string"}},@@ -418,7 +454,7 @@"type": "string"},"label": {- "description": "Custom label for this series, shown in the legend and tooltips instead of the column name.",+ "description": "Series label in legends and tooltips; replaces the column name.","type": "string"},"trendLine": {@@ -445,12 +481,12 @@"type": "string"},"style": {- "description": "Number formatting style.\n- `none` — no formatting.\n- `number` — thousands separators (e.g. `1,234`).\n- `short` — abbreviated large numbers (e.g. `1.2k`, `3.4M`).\n- `percent` — multiply the value by 100 and append a `%` sign, so pass a 0-1 ratio (`a / b`, not `100.0 * a / b`). Never pair it with a `%` suffix, which renders `47.3%%`.",+ "description": "`none`: unformatted; `number`: thousands separators; `short`: abbreviations (1.2k, 3.4M). `percent`: multiplies by 100 and adds `%`. Pass a 0–1 ratio (`a / b`) and omit the `%` suffix to avoid doubling it.","enum": ["none", "number", "short", "percent"],"type": "string"},"suffix": {- "description": "Text appended to each value (e.g. ` ms`). Leave unset when `style` is `percent`, which already appends the `%` sign.",+ "description": "Value suffix (e.g. ` ms`). Omit for `percent`, which adds `%`.","type": "string"}},@@ -528,7 +564,7 @@"type": "string"},"label": {- "description": "Custom label for this series, shown in the legend and tooltips instead of the column name.",+ "description": "Series label in legends and tooltips; replaces the column name.","type": "string"},"trendLine": {@@ -555,12 +591,12 @@"type": "string"},"style": {- "description": "Number formatting style.\n- `none` — no formatting.\n- `number` — thousands separators (e.g. `1,234`).\n- `short` — abbreviated large numbers (e.g. `1.2k`, `3.4M`).\n- `percent` — multiply the value by 100 and append a `%` sign, so pass a 0-1 ratio (`a / b`, not `100.0 * a / b`). Never pair it with a `%` suffix, which renders `47.3%%`.",+ "description": "`none`: unformatted; `number`: thousands separators; `short`: abbreviations (1.2k, 3.4M). `percent`: multiplies by 100 and adds `%`. Pass a 0–1 ratio (`a / b`) and omit the `%` suffix to avoid doubling it.","enum": ["none", "number", "short", "percent"],"type": "string"},"suffix": {- "description": "Text appended to each value (e.g. ` ms`). Leave unset when `style` is `percent`, which already appends the `%` sign.",+ "description": "Value suffix (e.g. ` ms`). Omit for `percent`, which adds `%`.","type": "string"}},diff --git a/services/mcp/tests/unit/insight-query-shapes.test.ts b/services/mcp/tests/unit/insight-query-shapes.test.tsindex 57aee2ba37b3..ece416b7935d 100644--- a/services/mcp/tests/unit/insight-query-shapes.test.ts+++ b/services/mcp/tests/unit/insight-query-shapes.test.ts@@ -21,6 +21,28 @@ const acceptedQueries = [shape: 'wrapped DataVisualizationNode',query: { kind: 'DataVisualizationNode', source: { kind: 'HogQLQuery', query: 'select 1' } },},+ {+ shape: 'BI worksheet',+ query: {+ kind: 'BIVisualizationNode',+ source: { kind: 'HogQLQuery', query: 'SELECT 1 AS total' },+ display: 'ActionsTable',+ tableSettings: { columns: [{ column: 'total', settings: { display: { label: 'Total' } } }] },+ config: {+ chartType: 'ActionsTable',+ source: null,+ rows: [],+ columns: [],+ values: [],+ filters: [],+ limit: 1000,+ sort: null,+ querySnapshot: { kind: 'HogQLQuery', query: 'SELECT 1 AS total' },+ catalogMetric: 'example_total',+ rowFilterGroup: { operator: 'AND', filters: [], groups: [{ operator: 'OR', filters: [], groups: [] }] },+ },+ },+ },{ shape: 'bare TrendsQuery', query: BARE_TRENDS_QUERY },{ shape: 'bare HogQLQuery', query: { kind: 'HogQLQuery', query: 'select 1' } },{@@ -40,7 +62,9 @@ describe('insight query shapes', () => {it.each(cases)('$tool accepts a $shape', ({ tool, base, query }) => {const { schema } = GENERATED_TOOLS[tool]!()- expect(schema.safeParse({ ...base, query }).success).toBe(true)+ const result = schema.safeParse({ ...base, query })+ expect(result.success).toBe(true)+ expect(result.data?.query).toMatchObject(query)})it.each(tools)('$tool sends a bare query on to the endpoint whole', ({ tool, base }) => {