Skip to content

: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.

feat(warehouse-sources): add AirOps brand-kit, prompt, and citation tables (#98113)

Tom Owers116c894f1c96
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md b/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md
index 071e3578cf5f..fc7baad906a7 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md
@@ -158,11 +158,11 @@ Today (2): `apps`, `executions`
Diffed against: <https://docs.airops.com/llms.txt>
-- [ ] `brand_kits (POST /public_api/brand_kits/list)` — the top-level object all AI-search-visibility data hangs off; a lookup for everything below (high)
+- [x] `brand_kits (POST /public_api/brand_kits/list)` — the top-level object all AI-search-visibility data hangs off; a lookup for everything below (high)
- [ ] `brand kit analytics (POST /public_api/brand_kits/{brand_kit_id}/analytics)` — AirOps' headline AI visibility/share-of-voice metrics (high)
-- [ ] `citations (POST /public_api/brand_kits/{brand_kit_id}/citations/list)` — per-URL citation counts, citation share and influence score across AI answers (high)
+- [x] `citations (POST /public_api/brand_kits/{brand_kit_id}/citations/list)` — per-URL citation counts, citation share and influence score across AI answers (high)
- [ ] `answers (POST /public_api/brand_kits/{brand_kit_id}/answers/list)` — the raw LLM answers being measured - the fact table under every visibility metric (high)
-- [ ] `prompts (POST /public_api/brand_kits/{brand_kit_id}/prompts/list)` — the tracked prompt set; the dimension every answer and citation is grouped by (high)
+- [x] `prompts (POST /public_api/brand_kits/{brand_kit_id}/prompts/list)` — the tracked prompt set; the dimension every answer and citation is grouped by (high)
- [ ] `topics (POST /public_api/brand_kits/{brand_kit_id}/topics/list)` — lookup decoding the topic dimension on prompts and answers (medium)
- [ ] `competitors (POST /public_api/brand_kits/{brand_kit_id}/competitors/list)` — competitive share-of-voice comparison, a core reporting cut (medium)
- [ ] `web_pages (POST /public_api/brand_kits/{brand_kit_id}/web_pages/list)` — page-level performance for owned content (medium)
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/airops/airops.py b/products/warehouse_sources/backend/temporal/data_imports/sources/airops/airops.py
index a96923f087c9..073c454ae5ca 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/airops/airops.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/airops/airops.py
@@ -1,17 +1,27 @@
+from collections.abc import Callable, Iterable, Iterator
from typing import Any, Optional
import requests
from requests import Response
-from products.warehouse_sources.backend.temporal.data_imports.sources.airops.settings import AIROPS_ENDPOINTS
+from products.warehouse_sources.backend.temporal.data_imports.sources.airops.settings import (
+ AIROPS_ENDPOINTS,
+ AirOpsEndpointConfig,
+)
from products.warehouse_sources.backend.temporal.data_imports.sources.common.http import make_tracked_session
from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source import (
RESTAPIConfig,
+ RESTClient,
+ create_auth,
rest_api_resource,
rest_api_resources,
)
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.config_setup import (
+ create_response_hooks,
+)
from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.paginators import (
JSONResponseCursorPaginator,
+ PageNumberPaginator,
SinglePagePaginator,
)
from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.typing import EndpointResource
@@ -23,6 +33,17 @@ APPS_PATH = "public_api/airops_apps"
# The executions endpoint caps `items` at 100.
EXECUTIONS_PAGE_SIZE = 100
+# AI search-visibility surface. Every brand-kit list endpoint is POST, wraps rows in
+# `{"data": [...], "meta": {...}}`, and paginates by page number carried in the request body.
+BRAND_KITS_PATH = "public_api/brand_kits"
+BRAND_KIT_LIST_PATH = f"{BRAND_KITS_PATH}/list"
+# `per_page` caps at 100 on every brand-kit list endpoint.
+BRAND_KIT_PAGE_SIZE = 100
+# Child endpoints hang off a brand kit and share the `/{brand_kit_id}/{name}/list` POST shape, so the
+# schema name doubles as the path segment. `brand_kits` is the top-level parent (no fan-out).
+BRAND_KIT_CHILD_ENDPOINTS = ("prompts", "citations")
+BRAND_KIT_ENDPOINTS = ("brand_kits", *BRAND_KIT_CHILD_ENDPOINTS)
+
class AirOpsCursorPaginator(JSONResponseCursorPaginator):
"""Cursor pagination over `meta.cursor`, honoring an explicit `has_more: false`.
@@ -67,11 +88,99 @@ def _stamp_app_id(row: dict[str, Any]) -> dict[str, Any]:
return row
+def _brand_kit_client(api_key: str) -> RESTClient:
+ # Auth goes through the framework (bearer header built per request, token redacted from
+ # telemetry). The tracked session pins redirects off and disables sample capture the same way
+ # `_make_session` does for the rest of AirOps.
+ return RESTClient(
+ base_url=AIROPS_BASE_URL,
+ auth=create_auth({"type": "bearer", "token": api_key}),
+ session=_make_session(api_key),
+ )
+
+
+def _brand_kit_paginator() -> PageNumberPaginator:
+ # AirOps carries the page number in the POST body (`param_location="json"`) and reports the page
+ # count in `meta.total_pages`, so pagination stops after the last page without paying for an
+ # extra empty page.
+ return PageNumberPaginator(base_page=1, total_path="meta.total_pages", param_location="json")
+
+
+def _paginate_brand_kits(client: RESTClient) -> Iterator[list[dict[str, Any]]]:
+ # A 200 without a `data` array means the response shape changed — fail loud
+ # (`data_selector_required`) rather than silently syncing 0 rows.
+ yield from client.paginate(
+ path=BRAND_KIT_LIST_PATH,
+ method="post",
+ json={"per_page": BRAND_KIT_PAGE_SIZE},
+ paginator=_brand_kit_paginator(),
+ data_selector="data",
+ data_selector_required=True,
+ )
+
+
+def _paginate_brand_kit_children(client: RESTClient, endpoint: str) -> Iterator[list[dict[str, Any]]]:
+ # prompts/citations only exist per brand kit, so enumerate brand kits first and follow each one's
+ # paginated child endpoint, stamping every row with its parent brand kit id (part of the composite
+ # primary key, so rows from two brand kits never collide).
+ #
+ # A brand kit that has not configured AEO answers the child endpoints with 412; ignore that brand
+ # kit (a valid empty page) rather than failing the whole table.
+ child_hooks = create_response_hooks([{"status_code": 412, "action": "ignore"}], resource_name=endpoint)
+ for kit_page in _paginate_brand_kits(client):
+ for kit in kit_page:
+ brand_kit_id = kit.get("id")
+ if brand_kit_id is None:
+ raise ValueError(f"AirOps brand kit is missing its 'id' field; cannot list {endpoint}")
+ for child_page in client.paginate(
+ path=f"{BRAND_KITS_PATH}/{brand_kit_id}/{endpoint}/list",
+ method="post",
+ json={"per_page": BRAND_KIT_PAGE_SIZE},
+ paginator=_brand_kit_paginator(),
+ data_selector="data",
+ data_selector_required=True,
+ hooks=child_hooks,
+ ):
+ for row in child_page:
+ row["brand_kit_id"] = brand_kit_id
+ yield child_page
+
+
+def _source_response(
+ endpoint: str,
+ endpoint_config: AirOpsEndpointConfig,
+ items: Callable[[], Iterable[Any]],
+ column_hints: Optional[dict[str, Any]],
+) -> SourceResponse:
+ return SourceResponse(
+ name=endpoint,
+ items=items,
+ primary_keys=endpoint_config.primary_keys,
+ partition_count=1,
+ partition_size=1,
+ partition_mode="datetime" if endpoint_config.partition_key else None,
+ partition_format="month" if endpoint_config.partition_key else None,
+ partition_keys=[endpoint_config.partition_key] if endpoint_config.partition_key else None,
+ column_hints=column_hints,
+ )
+
+
def airops_source(api_key: str, endpoint: str, team_id: int, job_id: str) -> SourceResponse:
if endpoint not in AIROPS_ENDPOINTS:
raise ValueError(f"Unknown AirOps endpoint: {endpoint}")
endpoint_config = AIROPS_ENDPOINTS[endpoint]
+ if endpoint in BRAND_KIT_ENDPOINTS:
+ client = _brand_kit_client(api_key)
+
+ def brand_kit_items() -> Iterator[list[dict[str, Any]]]:
+ if endpoint == "brand_kits":
+ yield from _paginate_brand_kits(client)
+ else:
+ yield from _paginate_brand_kit_children(client, endpoint)
+
+ return _source_response(endpoint, endpoint_config, brand_kit_items, column_hints=None)
+
# The apps endpoint returns a plain (unwrapped) JSON array with no pagination. A non-list 200
# body means the response shape changed — fail loud instead of silently syncing 0 rows.
apps_resource: EndpointResource = {
@@ -124,17 +233,7 @@ def airops_source(api_key: str, endpoint: str, team_id: int, job_id: str) -> Sou
rest_config["resources"] = [apps_resource]
resource = rest_api_resource(rest_config, team_id, job_id, None)
- return SourceResponse(
- name=endpoint,
- items=lambda: resource,
- primary_keys=endpoint_config.primary_keys,
- partition_count=1,
- partition_size=1,
- partition_mode="datetime" if endpoint_config.partition_key else None,
- partition_format="month" if endpoint_config.partition_key else None,
- partition_keys=[endpoint_config.partition_key] if endpoint_config.partition_key else None,
- column_hints=resource.column_hints,
- )
+ return _source_response(endpoint, endpoint_config, lambda: resource, resource.column_hints)
def validate_credentials(api_key: str) -> bool:
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/airops/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/airops/canonical_descriptions.py
index f5c7d730fbd3..b1e608fa52e4 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/airops/canonical_descriptions.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/airops/canonical_descriptions.py
@@ -44,4 +44,90 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
"updatedAt": "Timestamp when the execution was last updated.",
},
},
+ "brand_kits": {
+ "description": "A brand kit: the top-level object AI search-visibility data hangs off, holding a brand's identity, voice, and writing guidelines.",
+ "docs_url": "https://docs.airops.com/api-reference/api-reference/brand-kits",
+ "columns": {
+ "id": "Unique identifier for the brand kit.",
+ "workspace_name": "Name of the workspace this brand kit belongs to.",
+ "brand_name": "Name of the brand.",
+ "brand_url": "URL of the brand website.",
+ "brand_about": "Description/overview of the brand.",
+ "brand_customer": "Description of the target customer.",
+ "brand_competitors": "Information about brand competitors.",
+ "brand_point_of_view": "The brand's unique perspective or stance.",
+ "writing_persona": "The persona/voice used in brand writing.",
+ "writing_tone": "The tone of voice for brand content.",
+ "writing_cta": "Default call-to-action text.",
+ "writing_cta_url": "URL for call-to-action links.",
+ "writing_rules": "Writing rules and guidelines.",
+ "writing_sample_title": "Title of the writing sample.",
+ "writing_sample_outline": "Outline of the writing sample.",
+ "writing_sample_body": "Body content of the writing sample.",
+ "writing_sample_url": "URL reference for the writing sample.",
+ "primary_color": "Primary brand color (hex format).",
+ "secondary_color": "Secondary brand color (hex format).",
+ "accent_color": "Accent brand color (hex format).",
+ "header_case": "Header case style (title_case, sentence_case, or custom).",
+ "header_case_custom_value": "Custom header case rules when header_case is custom.",
+ "countries": "Country codes the brand kit targets.",
+ "aeo_enabled": "Whether AEO (answer engine optimization) is enabled for the brand kit.",
+ "prompts_count": "Number of prompts/questions associated with this brand kit.",
+ "created_at": "Timestamp when the brand kit was created.",
+ "updated_at": "Timestamp when the brand kit was last updated.",
+ },
+ },
+ "prompts": {
+ "description": "A tracked prompt for a brand kit: the question AI answers are measured against, with per-prompt visibility metrics.",
+ "docs_url": "https://docs.airops.com/api-reference/api-reference/brand-kits/prompts",
+ "columns": {
+ "id": "Unique identifier for the prompt.",
+ "brand_kit_id": "Identifier of the parent brand kit this prompt belongs to.",
+ "text": "The prompt text.",
+ "keyword": "Associated keyword for the prompt.",
+ "brand_mentioned": "Whether the brand is mentioned in the prompt.",
+ "prompt_volume": "Prompt volume level (very_low, low, medium, high).",
+ "search_volume": "Actual search volume behind the prompt_volume level.",
+ "topic_id": "Identifier of the associated topic.",
+ "created_at": "Timestamp when the prompt was created.",
+ "updated_at": "Timestamp when the prompt was last updated.",
+ "mention_rate": "Percentage of AI answers mentioning the brand (0-100).",
+ "positive_answer_rate": "Percentage of answers where the brand is positively mentioned (0-100).",
+ "citation_rate": "Percentage of AI answers citing the brand (0-100).",
+ "mention_rate_trend": "Change in mention_rate vs the previous period.",
+ "positive_answer_rate_trend": "Change in positive_answer_rate vs the previous period.",
+ "citation_rate_trend": "Change in citation_rate vs the previous period.",
+ "query_fanouts": "Search queries the AI ran internally when answering this question.",
+ "countries": "ISO alpha-2 country codes currently assigned to the prompt.",
+ "persona_ids": "Identifiers of personas currently assigned to the prompt.",
+ "platforms": "AI platforms currently assigned to the prompt.",
+ "est_answers_mo": "Estimated monthly answer credits this prompt will consume.",
+ },
+ },
+ "citations": {
+ "description": "A per-URL citation summary for a brand kit: how often a URL is cited across AI answers, its citation share, and its influence.",
+ "docs_url": "https://docs.airops.com/api-reference/api-reference/brand-kits/citations",
+ "columns": {
+ "brand_kit_id": "Identifier of the parent brand kit these citation metrics belong to.",
+ "url": "The cited URL.",
+ "domain": "Identifier of the domain the URL belongs to.",
+ "domain_name": "Name of the domain.",
+ "domain_category": "Category of the domain (Owned, Competitors, Social, etc.).",
+ "logo_url": "URL to the domain logo.",
+ "citation_count": "Total number of citations for this URL.",
+ "citation_count_trend": "Change in citation count vs the previous period.",
+ "citation_share": "Percentage of total citations this URL accounts for (0-100).",
+ "citation_share_trend": "Change in citation share vs the previous period.",
+ "citation_rate": "Percentage of answers citing this URL (0-100).",
+ "citation_rate_trend": "Change in citation rate vs the previous period.",
+ "influence_score": "Overall influence score for the URL (0-100).",
+ "influence_score_breakdown": "Breakdown of the influence score (coverage, impact, and domain-authority components).",
+ "page_type": "Type of page the URL points to.",
+ "brand_mentioned": "Whether the brand is mentioned on the page.",
+ "brand_sentiment": "Sentiment toward the brand on the page.",
+ "mentioned_competitor_domains": "Competitor domains mentioned on the page.",
+ "domain_authority": "Domain authority score.",
+ "social": "Platform-neutral social content and account enrichment for the URL.",
+ },
+ },
}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/airops/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/airops/settings.py
index b9e9f7192cfe..2ba635a7ed78 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/airops/settings.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/airops/settings.py
@@ -29,6 +29,23 @@ AIROPS_ENDPOINTS: dict[str, AirOpsEndpointConfig] = {
# apps' executions that share an id from colliding into one warehouse row.
primary_keys=["airops_app_id", "id"],
),
+ # AI search-visibility surface. `brand_kits` is the top-level object; `prompts` and `citations`
+ # are listed per brand kit (fan-out), so their composite keys carry the parent brand kit id.
+ "brand_kits": AirOpsEndpointConfig(
+ name="brand_kits",
+ partition_key="created_at",
+ ),
+ "prompts": AirOpsEndpointConfig(
+ name="prompts",
+ partition_key="created_at",
+ primary_keys=["brand_kit_id", "id"],
+ ),
+ "citations": AirOpsEndpointConfig(
+ name="citations",
+ # Citations carry no id or creation timestamp — a citation is identified by its URL within a
+ # brand kit, and there is no stable creation time to partition on.
+ primary_keys=["brand_kit_id", "url"],
+ ),
}
ENDPOINTS = tuple(AIROPS_ENDPOINTS.keys())
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/airops/tests/test_airops.py b/products/warehouse_sources/backend/temporal/data_imports/sources/airops/tests/test_airops.py
index 0648078cb45a..153009599159 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/airops/tests/test_airops.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/airops/tests/test_airops.py
@@ -10,6 +10,8 @@ from requests import Response
from products.warehouse_sources.backend.temporal.data_imports.sources.airops.airops import (
AIROPS_BASE_URL,
+ BRAND_KIT_LIST_PATH,
+ BRAND_KITS_PATH,
_make_session,
airops_source,
validate_credentials,
@@ -25,6 +27,7 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.common.typ
SESSION_PATCH = "products.warehouse_sources.backend.temporal.data_imports.sources.airops.airops.make_tracked_session"
APPS_URL = f"{AIROPS_BASE_URL}/public_api/airops_apps"
+BRAND_KITS_URL = f"{AIROPS_BASE_URL}/{BRAND_KIT_LIST_PATH}"
def _response(body: Any, status: int = 200, reason: str | None = None, url: str = APPS_URL) -> Response:
@@ -53,6 +56,9 @@ def _wire(session: mock.MagicMock, responses: list[Response]) -> list[dict[str,
{
"url": request.url,
"params": dict(request.params or {}),
+ # Brand-kit endpoints carry pagination in the POST body; snapshot it here for the
+ # same in-place-mutation reason as params.
+ "json": dict(request.json or {}),
"auth_headers": dict(prepared.headers),
}
)
@@ -222,6 +228,97 @@ class TestExecutions:
assert session.send.call_count == 1
+class TestBrandKits:
+ @mock.patch(SESSION_PATCH)
+ def test_paginates_by_page_number_in_body(self, MockSession: mock.MagicMock) -> None:
+ session = MockSession.return_value
+ seen = _wire(
+ session,
+ [
+ _response({"data": [{"id": 1}], "meta": {"total_pages": 2}}, url=BRAND_KITS_URL),
+ _response({"data": [{"id": 2}], "meta": {"total_pages": 2}}, url=BRAND_KITS_URL),
+ ],
+ )
+
+ rows = [row for batch in _batches(_source("brand_kits")) for row in batch]
+
+ assert rows == [{"id": 1}, {"id": 2}]
+ # `meta.total_pages` stops pagination after the last page — exactly two requests, no extra
+ # empty page.
+ assert session.send.call_count == 2
+ assert [s["url"] for s in seen] == [BRAND_KITS_URL, BRAND_KITS_URL]
+ # Page size and the incrementing page number both ride in the POST body, not the query string.
+ assert seen[0]["json"] == {"per_page": 100, "page": 1}
+ assert seen[1]["json"] == {"per_page": 100, "page": 2}
+ assert seen[0]["params"] == {}
+ assert seen[0]["auth_headers"]["Authorization"] == "Bearer k"
+
+ @mock.patch(SESSION_PATCH)
+ def test_missing_data_key_fails_loud(self, MockSession: mock.MagicMock) -> None:
+ # A 200 whose body drops the `data` array means the response shape changed — fail loud
+ # instead of silently syncing 0 rows.
+ _wire(MockSession.return_value, [_response({"meta": {"total_pages": 1}}, url=BRAND_KITS_URL)])
+ with pytest.raises(Exception, match="data"):
+ _batches(_source("brand_kits"))
+
+
+class TestBrandKitFanout:
+ @pytest.mark.parametrize("endpoint", ["prompts", "citations"])
+ @mock.patch(SESSION_PATCH)
+ def test_fans_out_over_brand_kits_and_stamps_parent_id(self, MockSession: mock.MagicMock, endpoint: str) -> None:
+ session = MockSession.return_value
+ seen = _wire(
+ session,
+ [
+ _response({"data": [{"id": 10}, {"id": 20}], "meta": {"total_pages": 1}}, url=BRAND_KITS_URL),
+ _response({"data": [{"url": "a"}], "meta": {"total_pages": 1}}), # kit 10
+ _response({"data": [{"url": "b"}], "meta": {"total_pages": 1}}), # kit 20
+ ],
+ )
+
+ rows = [row for batch in _batches(_source(endpoint)) for row in batch]
+
+ # Every child row is stamped with its parent brand kit id so the flattened table's composite
+ # key stays unique across brand kits.
+ assert rows == [{"url": "a", "brand_kit_id": 10}, {"url": "b", "brand_kit_id": 20}]
+ assert [s["url"] for s in seen] == [
+ BRAND_KITS_URL,
+ f"{AIROPS_BASE_URL}/{BRAND_KITS_PATH}/10/{endpoint}/list",
+ f"{AIROPS_BASE_URL}/{BRAND_KITS_PATH}/20/{endpoint}/list",
+ ]
+
+ @pytest.mark.parametrize("endpoint", ["prompts", "citations"])
+ @mock.patch(SESSION_PATCH)
+ def test_skips_brand_kit_without_aeo_configured(self, MockSession: mock.MagicMock, endpoint: str) -> None:
+ # A brand kit that hasn't configured AEO answers the child endpoint with 412; that brand kit
+ # is skipped rather than failing the whole table, and its siblings still sync.
+ session = MockSession.return_value
+ _wire(
+ session,
+ [
+ _response({"data": [{"id": 10}, {"id": 20}], "meta": {"total_pages": 1}}, url=BRAND_KITS_URL),
+ _response({"error": "AEO not configured"}, status=412, reason="Precondition Failed"), # kit 10
+ _response({"data": [{"url": "b"}], "meta": {"total_pages": 1}}), # kit 20
+ ],
+ )
+
+ rows = [row for batch in _batches(_source(endpoint)) for row in batch]
+
+ assert rows == [{"url": "b", "brand_kit_id": 20}]
+ assert session.send.call_count == 3
+
+ @pytest.mark.parametrize("endpoint", ["prompts", "citations"])
+ @mock.patch(SESSION_PATCH)
+ def test_fails_when_brand_kit_missing_id(self, MockSession: mock.MagicMock, endpoint: str) -> None:
+ # A brand kit without an `id` can't be fanned out — fail loud rather than dropping its rows.
+ _wire(
+ MockSession.return_value,
+ [_response({"data": [{"name": "no id"}], "meta": {"total_pages": 1}}, url=BRAND_KITS_URL)],
+ )
+ with pytest.raises(ValueError, match="missing its 'id'"):
+ _batches(_source(endpoint))
+
+
class TestUnknownEndpoint:
def test_raises_for_unknown_endpoint(self) -> None:
with pytest.raises(ValueError, match="Unknown AirOps endpoint"):
@@ -287,6 +384,10 @@ class TestAirOpsSourceResponse:
("apps", "created_at", ["id"]),
# Executions are keyed by (app id, id) because execution ids are scoped per app.
("executions", "createdAt", ["airops_app_id", "id"]),
+ ("brand_kits", "created_at", ["id"]),
+ # Fan-out children carry the parent brand kit id in the composite key so rows from two
+ # brand kits never collide (which would seed duplicate rows and slow every merge).
+ ("prompts", "created_at", ["brand_kit_id", "id"]),
],
)
def test_partition_and_primary_keys(self, endpoint: str, partition_key: str, primary_keys: list[str]) -> None:
@@ -296,3 +397,11 @@ class TestAirOpsSourceResponse:
assert response.primary_keys == primary_keys
assert response.partition_keys == [partition_key]
assert response.partition_mode == "datetime"
+
+ def test_citations_keyed_by_url_without_partition(self) -> None:
+ # Citations carry no id or creation timestamp: identity is (brand kit id, URL) and there is
+ # no stable timestamp to partition on.
+ response = _source("citations")
+ assert response.primary_keys == ["brand_kit_id", "url"]
+ assert response.partition_keys is None
+ assert response.partition_mode is None
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/airops/tests/test_airops_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/airops/tests/test_airops_source.py
index 8ad676d24e21..efb18454e0be 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/airops/tests/test_airops_source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/airops/tests/test_airops_source.py
@@ -31,7 +31,7 @@ class TestAirOpsSource:
# AirOps exposes no server-side timestamp filter and executions mutate after creation, so
# neither table may advertise incremental/append — that would silently drop mutated rows.
schemas = AirOpsSource().get_schemas(_config(), team_id=1)
- assert {s.name for s in schemas} == {"apps", "executions"}
+ assert {s.name for s in schemas} == {"apps", "executions", "brand_kits", "prompts", "citations"}
for schema in schemas:
assert schema.supports_incremental is False
assert schema.supports_append is False
@@ -62,6 +62,9 @@ class TestAirOpsSource:
# from the static endpoint catalog with no network call and merge canonical descriptions.
tables = AirOpsSource().get_documented_tables()
by_name: dict[str, dict[str, Any]] = {t["name"]: t for t in tables}
- assert set(by_name) == {"apps", "executions"}
+ assert set(by_name) == {"apps", "executions", "brand_kits", "prompts", "citations"}
assert by_name["apps"]["sync_methods"] == ["Full refresh"]
assert by_name["executions"]["description"]
+ # Canonical descriptions cover the brand-kit surface too, so the docs catalog is not a stub.
+ assert by_name["brand_kits"]["description"]
+ assert by_name["citations"]["description"]