: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(llm-gateway): add enabled_at to the per-team policy cache blob (#60759)
Brandon2165899000fe
diff --git a/posthog/api/test/__snapshots__/test_annotation.ambr b/posthog/api/test/__snapshots__/test_annotation.ambrindex 4e2c9f2ccf5d..32205e3164b8 100644--- a/posthog/api/test/__snapshots__/test_annotation.ambr+++ b/posthog/api/test/__snapshots__/test_annotation.ambr@@ -134,6 +134,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -626,6 +627,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -759,6 +761,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",diff --git a/posthog/api/test/__snapshots__/test_element.ambr b/posthog/api/test/__snapshots__/test_element.ambrindex 1fd569d5719e..2e3f384f3f63 100644--- a/posthog/api/test/__snapshots__/test_element.ambr+++ b/posthog/api/test/__snapshots__/test_element.ambr@@ -134,6 +134,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",diff --git a/posthog/api/test/__snapshots__/test_preflight.ambr b/posthog/api/test/__snapshots__/test_preflight.ambrindex 8bbeeca02859..6c9b7042b187 100644--- a/posthog/api/test/__snapshots__/test_preflight.ambr+++ b/posthog/api/test/__snapshots__/test_preflight.ambr@@ -134,6 +134,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",diff --git a/posthog/api/test/dashboards/__snapshots__/test_dashboard.ambr b/posthog/api/test/dashboards/__snapshots__/test_dashboard.ambrindex 16abf2b807e5..1d2fd89e7c91 100644--- a/posthog/api/test/dashboards/__snapshots__/test_dashboard.ambr+++ b/posthog/api/test/dashboards/__snapshots__/test_dashboard.ambr@@ -147,6 +147,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -274,6 +275,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -408,6 +410,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -513,6 +516,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -679,6 +683,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -784,6 +789,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -882,6 +888,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -1103,6 +1110,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -1208,6 +1216,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -1412,6 +1421,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -1733,6 +1743,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -2248,6 +2259,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -2703,6 +2715,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -2938,6 +2951,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -3514,6 +3528,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -3824,6 +3839,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -3958,6 +3974,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -4063,6 +4080,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -4229,6 +4247,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -4334,6 +4353,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -4520,6 +4540,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -4653,6 +4674,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -4758,6 +4780,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -4933,6 +4956,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -5101,6 +5125,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -5422,6 +5447,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -6076,6 +6102,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -6289,6 +6316,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -6426,6 +6454,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -6531,6 +6560,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -6717,6 +6747,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -6822,6 +6853,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -6997,6 +7029,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -7187,6 +7220,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -7458,6 +7492,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -7843,6 +7878,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -7982,6 +8018,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -8116,6 +8153,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -8221,6 +8259,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -8387,6 +8426,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -8492,6 +8532,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -8697,6 +8738,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -8802,6 +8844,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -8977,6 +9020,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -9145,6 +9189,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -9423,6 +9468,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -9816,6 +9862,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -9943,6 +9990,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -10077,6 +10125,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -10182,6 +10231,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -10348,6 +10398,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -10469,6 +10520,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -10655,6 +10707,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -10760,6 +10813,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -10935,6 +10989,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -11133,6 +11188,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -11452,6 +11508,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -11723,6 +11780,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -12200,6 +12258,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -12601,6 +12660,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -12833,6 +12893,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -13042,6 +13103,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -13611,6 +13673,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -13777,6 +13840,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -14167,6 +14231,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -14424,6 +14489,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -14867,6 +14933,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -15317,6 +15384,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -15444,6 +15512,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -15578,6 +15647,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -15683,6 +15753,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -15897,6 +15968,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -16002,6 +16074,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -16188,6 +16261,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -16293,6 +16367,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -16427,6 +16502,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -16532,6 +16608,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -16731,6 +16808,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -16836,6 +16914,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -17011,6 +17090,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -17179,6 +17259,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -17458,6 +17539,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -17848,6 +17930,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -17975,6 +18058,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -18109,6 +18193,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -18214,6 +18299,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -18534,6 +18620,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -18868,6 +18955,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -19077,6 +19165,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -19472,6 +19561,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -19874,6 +19964,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -20131,6 +20222,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -20442,6 +20534,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -20661,6 +20754,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -21051,6 +21145,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -21308,6 +21403,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -21751,6 +21847,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",diff --git a/posthog/api/test/notebooks/__snapshots__/test_notebook.ambr b/posthog/api/test/notebooks/__snapshots__/test_notebook.ambrindex fe4702bb45c1..53a3d09b9b64 100644--- a/posthog/api/test/notebooks/__snapshots__/test_notebook.ambr+++ b/posthog/api/test/notebooks/__snapshots__/test_notebook.ambr@@ -175,6 +175,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -481,6 +482,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -716,6 +718,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -821,6 +824,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -1210,6 +1214,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",diff --git a/posthog/management/commands/llm_gateway_team.py b/posthog/management/commands/llm_gateway_team.pynew file mode 100644index 000000000000..89ebe7533fb2--- /dev/null+++ b/posthog/management/commands/llm_gateway_team.py@@ -0,0 +1,121 @@+"""+Inspect or flip a team's llm-gateway admission state.++Usage:+ python manage.py llm_gateway_team enable 42+ python manage.py llm_gateway_team enable phc_demo+ python manage.py llm_gateway_team unenable 42+ python manage.py llm_gateway_team revoke 42+ python manage.py llm_gateway_team unrevoke 42+ python manage.py llm_gateway_team refresh 42+ python manage.py llm_gateway_team status 42++Both fields live on Team and project into the dedicated llm_gateway_policy+hypercache blob via Team.save() signal handlers. The gateway admits a team+only when enabled_at is set and revoked_at is null.+"""++from typing import Any++from django.core.management.base import BaseCommand, CommandError+from django.utils import timezone++from posthog.models.team.team import Team+from posthog.storage.team_llm_gateway_policy_cache import update_team_llm_gateway_policy_cache++_VERBS = (+ ("enable", "set llm_gateway_enabled_at to now (idempotent: no-op if already set)"),+ ("unenable", "clear llm_gateway_enabled_at (no-op if already null)"),+ ("revoke", "set llm_gateway_revoked_at to now (idempotent: no-op if already set)"),+ ("unrevoke", "clear llm_gateway_revoked_at (no-op if already null)"),+ ("refresh", "rewrite the team's policy cache entry from current DB state (no field change)"),+ ("status", "print the team's current admission state"),+)+++class Command(BaseCommand):+ help = "Inspect or flip a team's llm-gateway admission state (enabled_at, revoked_at)."++ def add_arguments(self, parser: Any) -> None:+ sub = parser.add_subparsers(dest="action", required=True, metavar="action")+ for verb, desc in _VERBS:+ p = sub.add_parser(verb, help=desc)+ p.add_argument("team", help="team id (integer) or api_token")++ def handle(self, *args: Any, **opts: Any) -> None:+ team = _resolve_team(opts["team"])+ action = opts["action"]+ if action == "status":+ _print_status(self.stdout, team)+ return+ if action == "refresh":+ update_team_llm_gateway_policy_cache(team)+ self.stdout.write(self.style.SUCCESS(f"team {team.id} ({team.api_token}): refresh ok"))+ self.stdout.write(f" {_snapshot(team)}")+ return++ before = _snapshot(team)+ changed = _apply(team, action)+ if not changed:+ self.stdout.write(f"team {team.id} ({team.api_token}): {action} no-op ({before})")+ return++ team.save()+ after = _snapshot(team)+ self.stdout.write(self.style.SUCCESS(f"team {team.id} ({team.api_token}): {action} ok"))+ self.stdout.write(f" before: {before}")+ self.stdout.write(f" after: {after}")+++def _resolve_team(arg: str) -> Team:+ # Bare integers resolve as id; anything else as api_token (no phc_ prefix+ # gate, since BaseTest fixtures use non-prefixed tokens).+ try:+ team_id = int(arg)+ except ValueError:+ try:+ return Team.objects.get(api_token=arg)+ except Team.DoesNotExist:+ raise CommandError(f"no team with api_token={arg!r}")+ try:+ return Team.objects.get(id=team_id)+ except Team.DoesNotExist:+ raise CommandError(f"no team with id={team_id}")+++def _apply(team: Team, action: str) -> bool:+ """Mutate team in-place; return True if a save is required."""+ now = timezone.now()+ if action == "enable":+ if team.llm_gateway_enabled_at is not None:+ return False+ team.llm_gateway_enabled_at = now+ return True+ if action == "unenable":+ if team.llm_gateway_enabled_at is None:+ return False+ team.llm_gateway_enabled_at = None+ return True+ if action == "revoke":+ if team.llm_gateway_revoked_at is not None:+ return False+ team.llm_gateway_revoked_at = now+ return True+ if action == "unrevoke":+ if team.llm_gateway_revoked_at is None:+ return False+ team.llm_gateway_revoked_at = None+ return True+ raise CommandError(f"unknown action {action!r}")+++def _snapshot(team: Team) -> str:+ return f"enabled_at={team.llm_gateway_enabled_at} revoked_at={team.llm_gateway_revoked_at}"+++def _print_status(stdout: Any, team: Team) -> None:+ admit = team.llm_gateway_enabled_at is not None and team.llm_gateway_revoked_at is None+ state = "admit" if admit else "deny"+ stdout.write(f"team {team.id} ({team.api_token}) state={state}")+ stdout.write(f" enabled_at: {team.llm_gateway_enabled_at}")+ stdout.write(f" revoked_at: {team.llm_gateway_revoked_at}")diff --git a/posthog/management/commands/test/test_llm_gateway_team.py b/posthog/management/commands/test/test_llm_gateway_team.pynew file mode 100644index 000000000000..8afa48ddc80d--- /dev/null+++ b/posthog/management/commands/test/test_llm_gateway_team.py@@ -0,0 +1,118 @@+from datetime import UTC, datetime+from io import StringIO++from posthog.test.base import BaseTest+from unittest.mock import patch++from django.core.management import call_command+from django.core.management.base import CommandError++from parameterized import parameterized+++class TestLLMGatewayTeamCommand(BaseTest):+ def _run(self, *args: str) -> str:+ out = StringIO()+ call_command("llm_gateway_team", *args, stdout=out)+ return out.getvalue()++ def test_enable_by_team_id(self) -> None:+ self.assertIsNone(self.team.llm_gateway_enabled_at)+ out = self._run("enable", str(self.team.id))+ self.team.refresh_from_db()+ self.assertIsNotNone(self.team.llm_gateway_enabled_at)+ self.assertIn("enable ok", out)++ def test_enable_by_api_token(self) -> None:+ out = self._run("enable", self.team.api_token)+ self.team.refresh_from_db()+ self.assertIsNotNone(self.team.llm_gateway_enabled_at)+ self.assertIn(self.team.api_token, out)++ @parameterized.expand([("enable", "llm_gateway_enabled_at"), ("revoke", "llm_gateway_revoked_at")])+ def test_set_action_is_idempotent(self, action: str, field: str) -> None:+ # Pre-set the field; second call must be a no-op and not overwrite the timestamp.+ original = datetime(2026, 5, 1, 12, 0, 0, tzinfo=UTC)+ setattr(self.team, field, original)+ self.team.save()+ out = self._run(action, str(self.team.id))+ self.team.refresh_from_db()+ self.assertEqual(getattr(self.team, field), original)+ self.assertIn("no-op", out)++ def test_revoke_sets_revoked_at(self) -> None:+ out = self._run("revoke", str(self.team.id))+ self.team.refresh_from_db()+ self.assertIsNotNone(self.team.llm_gateway_revoked_at)+ self.assertIn("revoke ok", out)++ @parameterized.expand(+ [+ ("unenable", "llm_gateway_enabled_at"),+ ("unrevoke", "llm_gateway_revoked_at"),+ ]+ )+ def test_clear_action_clears_field(self, action: str, field: str) -> None:+ setattr(self.team, field, datetime(2026, 5, 1, 12, 0, 0, tzinfo=UTC))+ self.team.save()+ out = self._run(action, str(self.team.id))+ self.team.refresh_from_db()+ self.assertIsNone(getattr(self.team, field))+ self.assertIn(f"{action} ok", out)++ @parameterized.expand(+ [+ ("unenable", "llm_gateway_enabled_at"),+ ("unrevoke", "llm_gateway_revoked_at"),+ ]+ )+ def test_clear_action_on_already_null_is_noop(self, action: str, field: str) -> None:+ self.assertIsNone(getattr(self.team, field))+ out = self._run(action, str(self.team.id))+ self.assertIn("no-op", out)++ @parameterized.expand(+ [+ ("admit_when_enabled_and_not_revoked", datetime(2026, 5, 1, 12, 0, 0, tzinfo=UTC), None, "state=admit"),+ ("deny_when_unenrolled", None, None, "state=deny"),+ (+ "deny_when_revoked",+ datetime(2026, 5, 1, 12, 0, 0, tzinfo=UTC),+ datetime(2026, 5, 2, 12, 0, 0, tzinfo=UTC),+ "state=deny",+ ),+ ("deny_when_only_revoked_without_enabled", None, datetime(2026, 5, 2, 12, 0, 0, tzinfo=UTC), "state=deny"),+ ]+ )+ def test_status(self, _name: str, enabled_at, revoked_at, expected_marker: str) -> None:+ self.team.llm_gateway_enabled_at = enabled_at+ self.team.llm_gateway_revoked_at = revoked_at+ self.team.save()+ out = self._run("status", str(self.team.id))+ self.assertIn(expected_marker, out)++ @parameterized.expand(+ [+ ("unknown_team_id", "999999999"),+ ("unknown_api_token", "phc_does_not_exist"),+ ("garbage_arg", "not-an-id-or-token"),+ ]+ )+ def test_resolve_failure_raises(self, _name: str, arg: str) -> None:+ with self.assertRaises(CommandError):+ self._run("enable", arg)++ def test_refresh_rewrites_cache_without_field_change(self) -> None:+ # refresh exists so an operator can re-warm a drifted cache without+ # toggling enabled_at/revoked_at (which enable/revoke would no-op on).+ self.team.llm_gateway_enabled_at = datetime(2026, 5, 1, 12, 0, 0, tzinfo=UTC)+ self.team.save()+ before_enabled = self.team.llm_gateway_enabled_at+ before_revoked = self.team.llm_gateway_revoked_at+ with patch("posthog.management.commands.llm_gateway_team.update_team_llm_gateway_policy_cache") as mock_update:+ out = self._run("refresh", str(self.team.id))+ self.team.refresh_from_db()+ mock_update.assert_called_once_with(self.team)+ self.assertEqual(self.team.llm_gateway_enabled_at, before_enabled)+ self.assertEqual(self.team.llm_gateway_revoked_at, before_revoked)+ self.assertIn("refresh ok", out)diff --git a/posthog/migrations/1196_team_llm_gateway_enabled_at.py b/posthog/migrations/1196_team_llm_gateway_enabled_at.pynew file mode 100644index 000000000000..be8dff481061--- /dev/null+++ b/posthog/migrations/1196_team_llm_gateway_enabled_at.py@@ -0,0 +1,19 @@+from django.db import migrations, models+++class Migration(migrations.Migration):+ dependencies = [+ ("posthog", "1195_alter_batchexportdestination_type"),+ ]++ operations = [+ # Nullable with no DB-level default so this is metadata-only on PG 11++ # (no table rewrite, no row backfill, instant on posthog_team). Null+ # means "not enrolled" — pairs with llm_gateway_revoked_at; the+ # gateway admits only when enabled_at is set and revoked_at is null.+ migrations.AddField(+ model_name="team",+ name="llm_gateway_enabled_at",+ field=models.DateTimeField(null=True, blank=True),+ ),+ ]diff --git a/posthog/migrations/max_migration.txt b/posthog/migrations/max_migration.txtindex 6a59d3d7b27e..4254f3a511b4 100644--- a/posthog/migrations/max_migration.txt+++ b/posthog/migrations/max_migration.txt@@ -1 +1 @@-1195_alter_batchexportdestination_type+1196_team_llm_gateway_enabled_atdiff --git a/posthog/models/team/team.py b/posthog/models/team/team.pyindex 9f6990feb88f..f382861bbfc8 100644--- a/posthog/models/team/team.py+++ b/posthog/models/team/team.py@@ -439,11 +439,13 @@ class Team(UUIDTClassicModel):# Logslogs_settings = field_access_control(models.JSONField(null=True, blank=True), "project", "admin")- # LLM gateway — per-team kill switch read by the llm-gateway Go service via a- # purpose-built HyperCache blob (cache/team_tokens/<token>/team_metadata/- # llm_gateway_policy.json). Non-null revokes the team's gateway access; null- # means active. A non-revoked team with balance gets the full supported model- # surface (the catalog is gateway-owned). Set by internal tooling/admin only.+ # LLM gateway — per-team admission projection read by the llm-gateway Go+ # service via a purpose-built HyperCache blob (cache/team_tokens/<token>/+ # team_metadata/llm_gateway_policy.json). The gateway admits a team only+ # when llm_gateway_enabled_at is set and llm_gateway_revoked_at is null;+ # revoke wins over enable. Null enabled_at = not enrolled (default-deny);+ # null revoked_at = not revoked. Set by internal tooling/admin only.+ llm_gateway_enabled_at = models.DateTimeField(null=True, blank=True)llm_gateway_revoked_at = models.DateTimeField(null=True, blank=True)# Heatmapsdiff --git a/posthog/session_recordings/test/__snapshots__/test_session_recording_playlist.ambr b/posthog/session_recordings/test/__snapshots__/test_session_recording_playlist.ambrindex e30566dec125..6b93ecdd361e 100644--- a/posthog/session_recordings/test/__snapshots__/test_session_recording_playlist.ambr+++ b/posthog/session_recordings/test/__snapshots__/test_session_recording_playlist.ambr@@ -121,6 +121,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -431,6 +432,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -772,6 +774,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -1328,6 +1331,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -1557,6 +1561,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -1913,6 +1918,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -2152,6 +2158,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -2555,6 +2562,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",diff --git a/posthog/session_recordings/test/__snapshots__/test_session_recordings.ambr b/posthog/session_recordings/test/__snapshots__/test_session_recordings.ambrindex f5012c3afb05..6d0afe6524bb 100644--- a/posthog/session_recordings/test/__snapshots__/test_session_recordings.ambr+++ b/posthog/session_recordings/test/__snapshots__/test_session_recordings.ambr@@ -218,6 +218,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -422,6 +423,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -1030,6 +1032,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -1230,6 +1233,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -1838,6 +1842,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -2034,6 +2039,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -2642,6 +2648,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -2838,6 +2845,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -3446,6 +3454,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -3646,6 +3655,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -4254,6 +4264,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -4454,6 +4465,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -5062,6 +5074,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -5262,6 +5275,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -5924,6 +5938,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -6226,6 +6241,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -6360,6 +6376,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -6869,6 +6886,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -7220,6 +7238,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -7770,6 +7789,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -7994,6 +8014,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -8213,6 +8234,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -8772,6 +8794,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -9086,6 +9109,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -9641,6 +9665,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -10043,6 +10068,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -10286,6 +10312,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -10618,6 +10645,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -11127,6 +11155,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -11459,6 +11488,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -12016,6 +12046,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -12371,6 +12402,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -12937,6 +12969,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -13231,6 +13264,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -13774,6 +13808,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -14128,6 +14163,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",diff --git a/posthog/storage/team_llm_gateway_policy_cache.py b/posthog/storage/team_llm_gateway_policy_cache.pyindex 8225a3e8271a..15322ce676a1 100644--- a/posthog/storage/team_llm_gateway_policy_cache.py+++ b/posthog/storage/team_llm_gateway_policy_cache.py@@ -8,14 +8,15 @@ Shape:{"id": 123,"api_token": "phc_...",+ "llm_gateway_enabled_at": "2026-05-29T20:46:30+00:00" | null,"llm_gateway_revoked_at": "2026-05-20T12:34:56+00:00" | null}The blob is written to its own cache key (sibling to full_metadata.json) so theflags-pipeline consumers of team_metadata are not affected by additions here.-The gateway resolves token -> team and denies on a non-null revoked_at; a-non-revoked team gets the full gateway-owned model surface. Null revoked_at-means active, so no backfill is required when the column is first added.+The gateway admits a team only when enabled_at is set and revoked_at is null;+revoke wins over enable. Null enabled_at = not enrolled (default-deny); null+revoked_at = not revoked. Nullable defaults mean no backfill on schema add."""import os@@ -46,6 +47,7 @@ LLM_GATEWAY_POLICY_CACHE_EXPIRY_SORTED_SET = "llm_gateway_policy_cache_expiry"LLM_GATEWAY_POLICY_FIELDS = ["id","api_token",+ "llm_gateway_enabled_at","llm_gateway_revoked_at",]@@ -55,6 +57,7 @@ def _serialize_team_to_llm_gateway_policy(team: Team) -> dict[str, Any]:return {"id": team.id,"api_token": team.api_token,+ "llm_gateway_enabled_at": (team.llm_gateway_enabled_at.isoformat() if team.llm_gateway_enabled_at else None),"llm_gateway_revoked_at": (team.llm_gateway_revoked_at.isoformat() if team.llm_gateway_revoked_at else None),}diff --git a/posthog/storage/team_llm_gateway_policy_signal_handlers.py b/posthog/storage/team_llm_gateway_policy_signal_handlers.pyindex 6d9aaf234458..05ddda33eb6e 100644--- a/posthog/storage/team_llm_gateway_policy_signal_handlers.py+++ b/posthog/storage/team_llm_gateway_policy_signal_handlers.py@@ -27,48 +27,55 @@ from posthog.tasks.team_llm_gateway_policy import update_team_llm_gateway_policylogger = structlog.get_logger(__name__)# Snapshots of the values a Team was loaded with, so post_save can detect a-# rotation (api_token) or a revocation flip (llm_gateway_revoked_at) without an-# extra DB read.+# rotation (api_token) or an admission flip (llm_gateway_enabled_at,+# llm_gateway_revoked_at) without an extra DB read._LOADED_API_TOKEN_ATTR = "_llm_gateway_loaded_api_token"+_LOADED_ENABLED_AT_ATTR = "_llm_gateway_loaded_enabled_at"_LOADED_REVOKED_AT_ATTR = "_llm_gateway_loaded_revoked_at"+_TRACKED_FIELDS = ("api_token", "llm_gateway_enabled_at", "llm_gateway_revoked_at")_NO_SNAPSHOT = object()def _snapshot_loaded_state(sender: type[Team], instance: Team, **kwargs: Any) -> None:"""- Record the instance's current api_token and llm_gateway_revoked_at on- post_init so the post_save handler can spot a rotation or revocation flip- without a DB read. Skip a field when it is deferred (e.g. a .only() fetch)- so we never trigger a lazy load.+ Record the instance's current api_token, llm_gateway_enabled_at, and+ llm_gateway_revoked_at on post_init so the post_save handler can spot a+ rotation or admission flip without a DB read. Skip a field when it is+ deferred (e.g. a .only() fetch) so we never trigger a lazy load."""deferred = instance.get_deferred_fields()if "api_token" not in deferred:instance.__dict__[_LOADED_API_TOKEN_ATTR] = instance.api_token+ if "llm_gateway_enabled_at" not in deferred:+ instance.__dict__[_LOADED_ENABLED_AT_ATTR] = instance.llm_gateway_enabled_atif "llm_gateway_revoked_at" not in deferred:instance.__dict__[_LOADED_REVOKED_AT_ATTR] = instance.llm_gateway_revoked_atdef _capture_old_state_if_deferred(sender: type[Team], instance: Team, **kwargs: Any) -> None:"""- Fallback for instances loaded with api_token or llm_gateway_revoked_at- deferred: capture the old values from the DB before the UPDATE runs.- No-op (zero query) for the common full-load path, where post_init already- snapshotted. Without this, a deferred-load rotation or revocation would- leave the previous cache entry live for the full 7-day TTL.+ Fallback for instances loaded with any tracked field deferred: capture+ the old values from the DB before the UPDATE runs. No-op (zero query) for+ the common full-load path, where post_init already snapshotted. Without+ this, a deferred-load rotation or admission flip would leave the previous+ cache entry live for the full 7-day TTL."""if not instance.pk or instance._state.adding:returnneed_api = _LOADED_API_TOKEN_ATTR not in instance.__dict__- need_rev = _LOADED_REVOKED_AT_ATTR not in instance.__dict__- if not need_api and not need_rev:+ need_enabled = _LOADED_ENABLED_AT_ATTR not in instance.__dict__+ need_revoked = _LOADED_REVOKED_AT_ATTR not in instance.__dict__+ if not (need_api or need_enabled or need_revoked):returnupdate_fields = kwargs.get("update_fields")- if update_fields is not None and not ({"api_token", "llm_gateway_revoked_at"} & set(update_fields)):+ if update_fields is not None and not (set(_TRACKED_FIELDS) & set(update_fields)):returnfields: list[str] = []if need_api:fields.append("api_token")- if need_rev:+ if need_enabled:+ fields.append("llm_gateway_enabled_at")+ if need_revoked:fields.append("llm_gateway_revoked_at")try:row = Team.objects.filter(pk=instance.pk).values(*fields).first()@@ -84,10 +91,20 @@ def _capture_old_state_if_deferred(sender: type[Team], instance: Team, **kwargs:returnif need_api and row.get("api_token") is not None:instance.__dict__[_LOADED_API_TOKEN_ATTR] = row["api_token"]- if need_rev:+ if need_enabled:+ instance.__dict__[_LOADED_ENABLED_AT_ATTR] = row.get("llm_gateway_enabled_at")+ if need_revoked:instance.__dict__[_LOADED_REVOKED_AT_ATTR] = row.get("llm_gateway_revoked_at")+def _value_changed(instance: Team, snapshot_attr: str, field_name: str) -> bool:+ """Sentinel-based change check: True only when both old and new are present and differ.+ Reads via __dict__ to skip lazy-load on deferred fields."""+ old = instance.__dict__.get(snapshot_attr, _NO_SNAPSHOT)+ new = instance.__dict__.get(field_name, _NO_SNAPSHOT)+ return old is not _NO_SNAPSHOT and new is not _NO_SNAPSHOT and old != new++def _update_cache_on_save(sender: type[Team], instance: Team, created: bool, **kwargs: Any) -> None:if not settings.FLAGS_REDIS_URL:return@@ -95,19 +112,16 @@ def _update_cache_on_save(sender: type[Team], instance: Team, created: bool, **kold_api_token: str | None = instance.__dict__.get(_LOADED_API_TOKEN_ATTR)rotated = bool(old_api_token and old_api_token != instance.api_token)- # Use a sentinel so "no snapshot" (deferred + no fallback) is distinguishable- # from "snapshot of None" (loaded as null). Read via __dict__ rather than the- # descriptor so a deferred-load save that does not touch this field does not- # trigger a lazy load just to feed the comparison. We only act on an observed- # change where both sides have a real value.- old_revoked_at = instance.__dict__.get(_LOADED_REVOKED_AT_ATTR, _NO_SNAPSHOT)- new_revoked_at = instance.__dict__.get("llm_gateway_revoked_at", _NO_SNAPSHOT)- revoked_changed = (- old_revoked_at is not _NO_SNAPSHOT and new_revoked_at is not _NO_SNAPSHOT and old_revoked_at != new_revoked_at- )+ enabled_changed = _value_changed(instance, _LOADED_ENABLED_AT_ATTR, "llm_gateway_enabled_at")+ revoked_changed = _value_changed(instance, _LOADED_REVOKED_AT_ATTR, "llm_gateway_revoked_at")+ admission_changed = enabled_changed or revoked_changed# Re-snapshot so chained changes compare against the just-saved values.instance.__dict__[_LOADED_API_TOKEN_ATTR] = instance.api_token+ new_enabled_at = instance.__dict__.get("llm_gateway_enabled_at", _NO_SNAPSHOT)+ if new_enabled_at is not _NO_SNAPSHOT:+ instance.__dict__[_LOADED_ENABLED_AT_ATTR] = new_enabled_at+ new_revoked_at = instance.__dict__.get("llm_gateway_revoked_at", _NO_SNAPSHOT)if new_revoked_at is not _NO_SNAPSHOT:instance.__dict__[_LOADED_REVOKED_AT_ATTR] = new_revoked_at@@ -119,11 +133,11 @@ def _update_cache_on_save(sender: type[Team], instance: Team, created: bool, **k# Same on-commit flow as the refresh so the old cache entry# disappears the moment the rotated token becomes live.clear_team_llm_gateway_policy_cache(old_api_token, kinds=kinds)- if revoked_changed:+ if admission_changed:# Invalidate the current token's entry synchronously so the next- # gateway request reads the fresh revocation state from the DB.- # The async refresh task can lag, leaving the stale active- # policy usable for the full cache TTL.+ # gateway request reads the fresh admission state from the DB.+ # The async refresh task can lag, leaving the stale policy+ # usable for the full cache TTL.clear_team_llm_gateway_policy_cache(instance, kinds=kinds)except Exception as e:HYPERCACHE_SIGNAL_UPDATE_COUNTER.labels(diff --git a/posthog/storage/test/test_team_llm_gateway_policy_cache.py b/posthog/storage/test/test_team_llm_gateway_policy_cache.pyindex 3ab18b5c7269..f837b997f8f3 100644--- a/posthog/storage/test/test_team_llm_gateway_policy_cache.py+++ b/posthog/storage/test/test_team_llm_gateway_policy_cache.py@@ -35,12 +35,14 @@ class TestLLMGatewayPolicyProjection(BaseTest):)self.assertEqual(set(LLM_GATEWAY_POLICY_FIELDS),- {"id", "api_token", "llm_gateway_revoked_at"},+ {"id", "api_token", "llm_gateway_enabled_at", "llm_gateway_revoked_at"},)def test_populated_team_round_trips_through_json(self):+ enabled_at = datetime(2026, 5, 29, 20, 46, 30, tzinfo=UTC)revoked_at = datetime(2026, 5, 20, 12, 34, 56, tzinfo=UTC)+ self.team.llm_gateway_enabled_at = enabled_atself.team.llm_gateway_revoked_at = revoked_atself.team.save()@@ -48,22 +50,25 @@ class TestLLMGatewayPolicyProjection(BaseTest):self.assertEqual(policy["id"], self.team.id)self.assertEqual(policy["api_token"], self.team.api_token)- # Datetime must be ISO8601 so the Go service can parse it from JSON.+ # Datetimes must be ISO8601 so the Go service can parse them from JSON.+ self.assertEqual(policy["llm_gateway_enabled_at"], enabled_at.isoformat())self.assertEqual(policy["llm_gateway_revoked_at"], revoked_at.isoformat())rehydrated = json.loads(json.dumps(policy))self.assertEqual(rehydrated, policy)- def test_unset_team_serializes_to_null_revoked_at(self):+ def test_unset_team_serializes_to_null_enabled_and_revoked(self):"""- A team that has never been revoked projects a null revoked_at, not a- default, so the schema migration needs no backfill. The gateway treats- null as active.+ A team that has never been enrolled or revoked projects null for both,+ so the schema migration needs no backfill. The gateway reads null+ enabled_at as not enrolled (default-deny) and null revoked_at as not+ revoked."""policy = _serialize_team_to_llm_gateway_policy(self.team)self.assertEqual(policy["id"], self.team.id)self.assertEqual(policy["api_token"], self.team.api_token)+ self.assertIsNone(policy["llm_gateway_enabled_at"])self.assertIsNone(policy["llm_gateway_revoked_at"])@@ -75,6 +80,7 @@ class TestLLMGatewayPolicyCacheOps(BaseTest):mock_payload: dict[str, Any] = {"id": self.team.id,"api_token": self.team.api_token,+ "llm_gateway_enabled_at": None,"llm_gateway_revoked_at": None,}mock_hypercache.get_from_cache.return_value = mock_payload@@ -165,8 +171,9 @@ class TestLLMGatewayPolicySignals(BaseTest):@patch("posthog.storage.team_llm_gateway_policy_signal_handlers.clear_team_llm_gateway_policy_cache")@patch("posthog.storage.team_llm_gateway_policy_signal_handlers.update_team_llm_gateway_policy_cache_task.delay")def test_unrelated_save_does_not_clear_cache(self, mock_delay, mock_clear, mock_settings, mock_transaction):- """A save that touches neither api_token nor llm_gateway_revoked_at must- not invalidate the cache; the async task still refreshes the blob."""+ """A save that touches no tracked field (api_token, llm_gateway_enabled_at,+ llm_gateway_revoked_at) must not invalidate the cache; the async task still+ refreshes the blob."""mock_settings.FLAGS_REDIS_URL = "redis://localhost"mock_settings.TEST = Truemock_transaction.on_commit.side_effect = lambda fn: fn()@@ -201,6 +208,29 @@ class TestLLMGatewayPolicySignals(BaseTest):mock_delay.assert_called_with(self.team.id)mock_clear.assert_called_once_with(self.team, kinds=["redis"])+ @patch("posthog.storage.team_llm_gateway_policy_signal_handlers.transaction")+ @patch("posthog.storage.team_llm_gateway_policy_signal_handlers.settings")+ @patch("posthog.storage.team_llm_gateway_policy_signal_handlers.clear_team_llm_gateway_policy_cache")+ @patch("posthog.storage.team_llm_gateway_policy_signal_handlers.update_team_llm_gateway_policy_cache_task.delay")+ def test_setting_enabled_at_clears_current_token_cache_on_commit(+ self, mock_delay, mock_clear, mock_settings, mock_transaction+ ):+ """+ Setting llm_gateway_enabled_at must invalidate synchronously for the+ same reason as the revoke path: until the async task runs, the+ gateway would keep treating the team as not-enrolled and 401 every+ request even after admin flips them on.+ """+ mock_settings.FLAGS_REDIS_URL = "redis://localhost"+ mock_settings.TEST = True+ mock_transaction.on_commit.side_effect = lambda fn: fn()++ self.team.llm_gateway_enabled_at = datetime(2026, 5, 29, 20, 46, 30, tzinfo=UTC)+ self.team.save()++ mock_delay.assert_called_with(self.team.id)+ mock_clear.assert_called_once_with(self.team, kinds=["redis"])+@patch("posthog.storage.team_llm_gateway_policy_signal_handlers.transaction")@patch("posthog.storage.team_llm_gateway_policy_signal_handlers.settings")@patch("posthog.storage.team_llm_gateway_policy_signal_handlers.clear_team_llm_gateway_policy_cache")@@ -252,3 +282,75 @@ class TestLLMGatewayPolicySignals(BaseTest):mock_delay.assert_called_with(self.team.id)mock_clear.assert_called_once_with(old_token, kinds=["redis"])++ @patch("posthog.storage.team_llm_gateway_policy_signal_handlers.transaction")+ @patch("posthog.storage.team_llm_gateway_policy_signal_handlers.settings")+ @patch("posthog.storage.team_llm_gateway_policy_signal_handlers.clear_team_llm_gateway_policy_cache")+ @patch("posthog.storage.team_llm_gateway_policy_signal_handlers.update_team_llm_gateway_policy_cache_task.delay")+ def test_simultaneous_enable_and_revoke_clears_cache_once(+ self, mock_delay, mock_clear, mock_settings, mock_transaction+ ):+ """+ Flipping both llm_gateway_enabled_at and llm_gateway_revoked_at in one+ save must invalidate exactly once. The handler ORs the two change+ signals; a future refactor that fires clear per field would double the+ Redis traffic on every admin enable-after-revoke.+ """+ mock_settings.FLAGS_REDIS_URL = "redis://localhost"+ mock_settings.TEST = True+ mock_transaction.on_commit.side_effect = lambda fn: fn()++ self.team.llm_gateway_enabled_at = datetime(2026, 5, 29, 20, 46, 30, tzinfo=UTC)+ self.team.llm_gateway_revoked_at = datetime(2026, 5, 30, 12, 0, 0, tzinfo=UTC)+ self.team.save()++ mock_delay.assert_called_with(self.team.id)+ mock_clear.assert_called_once_with(self.team, kinds=["redis"])++ @patch("posthog.storage.team_llm_gateway_policy_signal_handlers.transaction")+ @patch("posthog.storage.team_llm_gateway_policy_signal_handlers.settings")+ @patch("posthog.storage.team_llm_gateway_policy_signal_handlers.clear_team_llm_gateway_policy_cache")+ @patch("posthog.storage.team_llm_gateway_policy_signal_handlers.update_team_llm_gateway_policy_cache_task.delay")+ def test_deferred_enabled_at_load_still_clears_cache_on_flip(+ self, mock_delay, mock_clear, mock_settings, mock_transaction+ ):+ """+ A Team fetched with llm_gateway_enabled_at deferred and then flipped+ on must still invalidate the cache. post_init skips the snapshot to+ avoid a lazy load; the pre_save fallback captures the old value from+ the DB before the UPDATE runs.+ """+ mock_settings.FLAGS_REDIS_URL = "redis://localhost"+ mock_settings.TEST = True+ mock_transaction.on_commit.side_effect = lambda fn: fn()++ partial = Team.objects.only("id", "name").get(pk=self.team.pk)+ partial.llm_gateway_enabled_at = datetime(2026, 5, 29, 20, 46, 30, tzinfo=UTC)+ partial.save()++ mock_delay.assert_called_with(self.team.id)+ mock_clear.assert_called_once_with(partial, kinds=["redis"])++ @patch("posthog.storage.team_llm_gateway_policy_signal_handlers.transaction")+ @patch("posthog.storage.team_llm_gateway_policy_signal_handlers.settings")+ @patch("posthog.storage.team_llm_gateway_policy_signal_handlers.clear_team_llm_gateway_policy_cache")+ @patch("posthog.storage.team_llm_gateway_policy_signal_handlers.update_team_llm_gateway_policy_cache_task.delay")+ def test_chained_enabled_at_flips_invalidate_each_save(+ self, mock_delay, mock_clear, mock_settings, mock_transaction+ ):+ """+ Two consecutive enabled_at writes on the same kept-alive instance must+ invalidate twice. post_save re-snapshots the saved value so the second+ save compares against t1 instead of seeing "unchanged" and skipping.+ """+ mock_settings.FLAGS_REDIS_URL = "redis://localhost"+ mock_settings.TEST = True+ mock_transaction.on_commit.side_effect = lambda fn: fn()++ self.team.llm_gateway_enabled_at = datetime(2026, 5, 29, 12, 0, 0, tzinfo=UTC)+ self.team.save()++ self.team.llm_gateway_enabled_at = datetime(2026, 5, 30, 12, 0, 0, tzinfo=UTC)+ self.team.save()++ self.assertEqual(mock_clear.call_count, 2)diff --git a/posthog/storage/test/test_team_metadata_cache.py b/posthog/storage/test/test_team_metadata_cache.pyindex 9cb1668e52e8..050f2e03ca4c 100644--- a/posthog/storage/test/test_team_metadata_cache.py+++ b/posthog/storage/test/test_team_metadata_cache.py@@ -591,4 +591,5 @@ class TestSampleRateSerializationForRustCompatibility(BaseTest):# unaffected by llm-gateway changes.class TestLLMGatewayFieldsNotInSharedProjection(BaseTest):def test_llm_gateway_fields_excluded_from_shared_metadata(self):+ self.assertNotIn("llm_gateway_enabled_at", TEAM_METADATA_FIELDS)self.assertNotIn("llm_gateway_revoked_at", TEAM_METADATA_FIELDS)diff --git a/posthog/tasks/test/__snapshots__/test_process_scheduled_changes.ambr b/posthog/tasks/test/__snapshots__/test_process_scheduled_changes.ambrindex 9af3cf89b08b..b908b9b3e83e 100644--- a/posthog/tasks/test/__snapshots__/test_process_scheduled_changes.ambr+++ b/posthog/tasks/test/__snapshots__/test_process_scheduled_changes.ambr@@ -406,6 +406,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -595,6 +596,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -1113,6 +1115,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -1432,6 +1435,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",diff --git a/products/actions/backend/api/test/__snapshots__/test_action.ambr b/products/actions/backend/api/test/__snapshots__/test_action.ambrindex 700fca4ccb14..3cd2b8efdcaf 100644--- a/products/actions/backend/api/test/__snapshots__/test_action.ambr+++ b/products/actions/backend/api/test/__snapshots__/test_action.ambr@@ -134,6 +134,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -618,6 +619,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -751,6 +753,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",diff --git a/products/early_access_features/backend/test/__snapshots__/test_early_access_feature.ambr b/products/early_access_features/backend/test/__snapshots__/test_early_access_feature.ambrindex d1dc78dbebf4..cb4369036dd4 100644--- a/products/early_access_features/backend/test/__snapshots__/test_early_access_feature.ambr+++ b/products/early_access_features/backend/test/__snapshots__/test_early_access_feature.ambr@@ -89,6 +89,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -532,6 +533,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -670,6 +672,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",diff --git a/products/feature_flags/backend/api/test/__snapshots__/test_feature_flag.ambr b/products/feature_flags/backend/api/test/__snapshots__/test_feature_flag.ambrindex a5e3e304056c..8092f5ed8ae1 100644--- a/products/feature_flags/backend/api/test/__snapshots__/test_feature_flag.ambr+++ b/products/feature_flags/backend/api/test/__snapshots__/test_feature_flag.ambr@@ -555,6 +555,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -880,6 +881,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -1084,6 +1086,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -1279,6 +1282,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -1588,6 +1592,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -1847,6 +1852,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -2105,6 +2111,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -2210,6 +2217,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -2415,6 +2423,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",diff --git a/products/feature_flags/backend/api/test/__snapshots__/test_organization_feature_flag.ambr b/products/feature_flags/backend/api/test/__snapshots__/test_organization_feature_flag.ambrindex daec52bf4f57..8237cfaa3836 100644--- a/products/feature_flags/backend/api/test/__snapshots__/test_organization_feature_flag.ambr+++ b/products/feature_flags/backend/api/test/__snapshots__/test_organization_feature_flag.ambr@@ -134,6 +134,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -323,6 +324,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -617,6 +619,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -783,6 +786,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -949,6 +953,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -1046,6 +1051,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -1454,6 +1460,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -1588,6 +1595,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -1693,6 +1701,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -1811,6 +1820,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -1931,6 +1941,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -2050,6 +2061,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -2184,6 +2196,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -2420,6 +2433,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -2525,6 +2539,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -2681,6 +2696,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -2815,6 +2831,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -2920,6 +2937,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -3054,6 +3072,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -3286,6 +3305,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -3391,6 +3411,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",diff --git a/products/product_analytics/backend/api/test/__snapshots__/test_insight.ambr b/products/product_analytics/backend/api/test/__snapshots__/test_insight.ambrindex c1789b0eb193..b32c1f100367 100644--- a/products/product_analytics/backend/api/test/__snapshots__/test_insight.ambr+++ b/products/product_analytics/backend/api/test/__snapshots__/test_insight.ambr@@ -536,6 +536,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -670,6 +671,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -775,6 +777,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -941,6 +944,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -1046,6 +1050,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -1232,6 +1237,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -1365,6 +1371,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -1470,6 +1477,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -1674,6 +1682,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -2002,6 +2011,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -2323,6 +2333,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",@@ -2747,6 +2758,7 @@"posthog_team"."autocapture_exceptions_opt_in","posthog_team"."autocapture_exceptions_errors_to_ignore","posthog_team"."logs_settings",+ "posthog_team"."llm_gateway_enabled_at","posthog_team"."llm_gateway_revoked_at","posthog_team"."heatmaps_opt_in","posthog_team"."receive_org_level_activity_logs",