: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(data-warehouse): add inngest runs, functions and session tables (#111528)
Tom Owersfb744e60311c
diff --git a/posthog/test/repo_invariants/dataclass_frozen_baseline.txt b/posthog/test/repo_invariants/dataclass_frozen_baseline.txtindex 909b1d6aa310..84f0922048c7 100644--- a/posthog/test/repo_invariants/dataclass_frozen_baseline.txt+++ b/posthog/test/repo_invariants/dataclass_frozen_baseline.txt@@ -687,7 +687,6 @@1 products/warehouse_sources/backend/temporal/data_imports/sources/inflowinventory/inflowinventory.py1 products/warehouse_sources/backend/temporal/data_imports/sources/inflowinventory/settings.py1 products/warehouse_sources/backend/temporal/data_imports/sources/inngest/inngest.py-1 products/warehouse_sources/backend/temporal/data_imports/sources/inngest/settings.py1 products/warehouse_sources/backend/temporal/data_imports/sources/insightly/insightly.py1 products/warehouse_sources/backend/temporal/data_imports/sources/instagram/instagram.py1 products/warehouse_sources/backend/temporal/data_imports/sources/instagram/settings.pydiff --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.mdindex a5a72f9df27d..ed47fcd5e3fe 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@@ -4293,17 +4293,17 @@ Note: inFlow publishes a clean ReDoc/Swagger spec and even advertises it in a st## Inngest — gaps-Today (7): `cancellations`, `environments`, `event_keys`, `events`, `function_runs`, `signing_keys`, `webhooks`+Today (12): `cancellations`, `environments`, `event_keys`, `events`, `function_runs`, `functions`, `runs`, `session_keys`, `session_runs`, `sessions`, `signing_keys`, `webhooks`Diffed against: <https://api-docs.inngest.com/api-specs/v2.json>-- [ ] `GET /v2/apps/{appId}/functions` — lookup resolving the function IDs on every run row - today there is no way to get a function's name or app from the warehouse (high)-- [ ] `GET /v1/runs/{runID}/jobs` — per-step execution history within a run (attempts, step outputs, failures) - the grain needed to find which step fails (high)-- [ ] `GET /v2/runs and GET /v2/apps/{appId}/functions/{functionId}/runs` — direct run listings; today function_runs is walked as /v1/events/{internal_id}/runs per event, so cron- and invoke-triggered runs are never captured and the walk costs one request per event (high)+- [x] `GET /v2/apps/{appId}/functions` — lookup resolving the function IDs on every run row - today there is no way to get a function's name or app from the warehouse (high). Added as `functions` (fan-out over the `GET /v2/apps` list).+- [ ] `GET /v1/runs/{runID}/jobs` — skipped: the endpoint returns only the run's jobs still in the function queue (`at`, `position`, `attempt`), cached for 5 seconds, not step outputs or failure history. `GET /v2/runs/{runId}/trace` is the step-level source.+- [x] `GET /v2/runs and GET /v2/apps/{appId}/functions/{functionId}/runs` — direct run listings; today function_runs is walked as /v1/events/{internal_id}/runs per event, so cron- and invoke-triggered runs are never captured and the walk costs one request per event (high). Added as `runs` (incremental on `queuedAt`). The per-function list is skipped: it returns the same rows filtered to one function.- [ ] `GET /v2/runs/{runId}/trace` — step-level span/timing tree for a run, for latency and retry analysis (medium)- [ ] `GET /v2/experiments and GET /v2/apps/{appId}/functions/{functionId}/experiments/{experimentId}` — experiment definitions plus per-experiment aggregates, Inngest's own rollout metric (medium)-- [ ] `GET /v2/apps/{appId}` — app metadata to resolve appId on functions and runs (note: fetch-by-id only, there is no list-apps endpoint, so it needs an ID walk) (medium)-- [ ] `GET /v2/sessions, /v2/sessions/{sessionKey}, /v2/sessions/{sessionKey}/{sessionId}/runs` — AgentKit session grouping and the runs belonging to each session, for agent-workflow analysis (medium)+- [ ] `GET /v2/apps/{appId}` — app metadata to resolve appId on functions and runs (medium). The current spec also has a `GET /v2/apps` list, which `functions` already pages, so no ID walk is needed.+- [x] `GET /v2/sessions, /v2/sessions/{sessionKey}, /v2/sessions/{sessionKey}/{sessionId}/runs` — AgentKit session grouping and the runs belonging to each session, for agent-workflow analysis (medium). Added as `session_keys`, `sessions` and `session_runs`.Note: Inngest ships two real OpenAPI specs (v1 at /api-specs/v1.json, v2 at /api-specs/v2.json) plus llms.txt / llms-full.txt; I diffed both. The existing source already mixes versions (environments and both key tables use v2, everything else v1), so pulling runs and functions from v2 fits. Excluded as config: /v2/account, /v2/partner/accounts, and the POST-only invoke/sync/rerun/scores actions. The most valuable single change here is probably switching function_runs off the per-event v1 walk onto GET /v2/runs.diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/inngest/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/inngest/canonical_descriptions.pyindex 4198a528fc6e..ed1abe90a04a 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/inngest/canonical_descriptions.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/inngest/canonical_descriptions.py@@ -41,6 +41,38 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {"event_received_at": "When the triggering event was received by Inngest (added by PostHog to drive incremental sync).",},},+ "runs": {+ "description": "A function run, listed directly so cron-, event- and invoke-triggered runs are all included.",+ "docs_url": "https://api-docs.inngest.com/v2/runs/V2_ListRuns",+ "columns": {+ "id": "The ID of the function run.",+ "app": "The app the run belongs to (`id`).",+ "function": "The function that ran (`id`, `name` and its `app`).",+ "status": "The run status: QUEUED, RUNNING, COMPLETED, FAILED, or CANCELLED.",+ "queuedAt": "When the run was enqueued.",+ "startedAt": "When the run started executing.",+ "endedAt": "When the run ended; null while it is still running.",+ "durationMs": "How long the run took, in milliseconds.",+ "trigger": "What triggered the run: event name and IDs, batch ID, or cron schedule.",+ "output": "Data returned from the function handler, JSON-encoded when not already a string.",+ },+ },+ "functions": {+ "description": "A function defined in one of the environment's apps, with its triggers and flow-control configuration.",+ "docs_url": "https://api-docs.inngest.com/v2/functions/V2_GetFunctions",+ "columns": {+ "id": "The ID of the function.",+ "app_id": "The ID of the app the function belongs to (added by PostHog from the parent app).",+ "app": "The app the function belongs to (`id`).",+ "name": "The function name.",+ "slug": "The function slug.",+ "triggers": "The events, cron schedules, or other triggers that start the function.",+ "configuration": "Flow-control settings: concurrency, throttle, rate limit, debounce, batching, retries, priority, and cancellations.",+ "failureHandler": "The function that handles failures of this function, if any.",+ "isPaused": "Whether the function is paused.",+ "isArchived": "Whether the function is archived.",+ },+ },"cancellations": {"description": "A bulk cancellation, stopping function runs in a time range matching an optional expression.","docs_url": "https://api-docs.inngest.com/v1/cancellations/ListCancellations",@@ -96,4 +128,40 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {"createdAt": "When the signing key was created.",},},+ "session_keys": {+ "description": "An AgentKit session key: the dimension runs are grouped into sessions by.",+ "docs_url": "https://api-docs.inngest.com/v2/sessions/V2_ListSessionKeys",+ "columns": {+ "id": "The session key.",+ "createdAt": "When the session key was first observed.",+ },+ },+ "sessions": {+ "description": "An AgentKit session: one value of a session key and the runs grouped under it.",+ "docs_url": "https://api-docs.inngest.com/v2/sessions/V2_ListSessions",+ "columns": {+ "id": "The session ID, unique within its session key.",+ "session_key": "The session key the session belongs to (added by PostHog from the parent key).",+ "runCount": "Number of runs in the session.",+ "failedRunCount": "Number of failed runs in the session.",+ "failureRate": "Share of the session's runs that failed.",+ "functions": "The functions that ran in the session.",+ "lastActiveAt": "When the session last had activity.",+ },+ },+ "session_runs": {+ "description": "A function run that belongs to an AgentKit session.",+ "docs_url": "https://api-docs.inngest.com/v2/sessions/V2_ListSessionRuns",+ "columns": {+ "id": "The ID of the function run.",+ "session_key": "The session key (added by PostHog from the parent session).",+ "session_id": "The session ID (added by PostHog from the parent session).",+ "function": "The function that ran (`id`, `name` and its `app`).",+ "eventName": "The name of the event that triggered the run.",+ "status": "The run status: QUEUED, RUNNING, COMPLETED, FAILED, or CANCELLED.",+ "queuedAt": "When the run was enqueued.",+ "startedAt": "When the run started executing.",+ "endedAt": "When the run ended; null while it is still running.",+ },+ },}diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/inngest/inngest.posthog-doc.mdx b/products/warehouse_sources/backend/temporal/data_imports/sources/inngest/inngest.posthog-doc.mdxindex fe06f4a4fcd1..b0eff5a43c7d 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/inngest/inngest.posthog-doc.mdx+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/inngest/inngest.posthog-doc.mdx@@ -25,13 +25,13 @@ import AlphaRelease from '../_snippets/alpha-release.mdx'<AlphaRelease />[Inngest](https://www.inngest.com/) is a durable workflow engine: functions are triggered by events and run with steps, retries, and flow control.-This connector pulls your Inngest data — events, function runs, bulk cancellations, environments, inbound webhook intake endpoints, and event/signing key inventories — into the PostHog Data warehouse so you can join it with your product data.+This connector pulls your Inngest data — events, function runs, functions, AgentKit sessions, bulk cancellations, environments, inbound webhook intake endpoints, and event/signing key inventories — into the PostHog Data warehouse so you can join it with your product data.Inngest retains event and run history for a plan-dependent window (from 24 hours up to 90 days), so a synced copy in PostHog doubles as durable history. Schedule frequent syncs to avoid gaps.## Prerequisites-You need an Inngest account and the signing key for the environment you want to sync. Signing keys authenticate both the v1 and v2 REST APIs, so no additional scopes are required. (Dashboard API keys only work with the v2 API, which does not cover events and runs, so they can't be used here.)+You need an Inngest account and the signing key for the environment you want to sync. Signing keys authenticate both the v1 and v2 REST APIs, so no additional scopes are required. (Dashboard API keys only work with the v2 API, which does not cover events, so they can't be used here.)## Adding a data source@@ -43,7 +43,7 @@ Inngest authenticates with a per-environment signing key (it starts with `signke<SyncModes />-**Events** sync append-only using the server-side `received_after` filter, backfilling up to 90 days of history on the first sync (bounded by your plan's retention). **Function runs** sync incrementally: they are discovered by walking the incoming event stream and looking up each event's runs, and each sync re-reads a trailing hour so recently-started runs pick up their final status. The other tables are small inventories with no server-side timestamp filter, so they sync as full refresh.+**Events** sync append-only using the server-side `received_after` filter, backfilling up to 90 days of history on the first sync (bounded by your plan's retention). **Function runs** sync incrementally: they are discovered by walking the incoming event stream and looking up each event's runs, and each sync re-reads a trailing hour so recently-started runs pick up their final status. **Runs** sync incrementally on the server-side `queuedAt` filter and include every run, including cron- and invoke-triggered runs that **Function runs** misses; they also re-read a trailing hour each sync. **Session runs** look up each AgentKit session's runs one session at a time, so the table is off by default. The other tables are small inventories with no server-side timestamp filter, so they sync as full refresh.Secret values are never synced: event keys and signing keys keep only their metadata (name, environment, creation time), and webhook intake URLs — which let anyone holding them submit events — are stripped too.diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/inngest/inngest.py b/products/warehouse_sources/backend/temporal/data_imports/sources/inngest/inngest.pyindex 9abc3e91cfdf..af143aed7de0 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/inngest/inngest.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/inngest/inngest.py@@ -3,6 +3,7 @@ import dataclassesfrom collections.abc import Iteratorfrom datetime import UTC, date, datetime, timedeltafrom typing import Any, Optional+from urllib.parse import quoteimport requestsfrom structlog.types import FilteringBoundLogger@@ -15,6 +16,7 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.common.typfrom products.warehouse_sources.backend.temporal.data_imports.sources.inngest.settings import (INNGEST_DEFAULT_VERSION,INNGEST_ENDPOINTS,+ V2_MAX_PAGE_SIZE,InngestEndpointConfig,)@@ -309,34 +311,170 @@ def _drop_redacted_fields(item: dict[str, Any], redacted_fields: tuple[str, ...]return item-def _get_v2_list_rows(+def _iter_v2_pages(session: requests.Session,headers: dict[str, str],logger: FilteringBoundLogger,- config: InngestEndpointConfig,path: str,-) -> Iterator[list[dict[str, Any]]]:+ params: Optional[dict[str, Any]] = None,+ cursor: str | None = None,+) -> Iterator[tuple[list[dict[str, Any]], str | None]]:"""Page a v2 list endpoint via its `page.cursor` / `page.hasMore` envelope.- No `limit` is passed: the documented defaults vary per endpoint and the maxima are- undocumented, so we accept the server default — these are small inventory lists.+ Yields (page items, next cursor); the next cursor is None on the final page."""- cursor: str | None = Nonewhile True:- params = {"cursor": cursor} if cursor else None- payload = _fetch(session, f"{INNGEST_API_BASE_URL}{path}", headers, logger, params=params)- items = payload.get("data") or []- rows = [_drop_redacted_fields(item, config.redacted_fields) for item in items if isinstance(item, dict)]- if rows:- yield rows-+ request_params = {**(params or {}), **({"cursor": cursor} if cursor else {})}+ payload = _fetch(session, f"{INNGEST_API_BASE_URL}{path}", headers, logger, params=request_params or None)+ items = [item for item in payload.get("data") or [] if isinstance(item, dict)]page = payload.get("page") or {}next_cursor = page.get("cursor")- if not page.get("hasMore") or not next_cursor or next_cursor == cursor:+ has_more = bool(page.get("hasMore")) and bool(next_cursor) and next_cursor != cursor+ yield items, next_cursor if has_more else None+ if not has_more:breakcursor = next_cursor+def _page_params(config: InngestEndpointConfig) -> dict[str, Any]:+ # Endpoints without a page size keep the server default: their maxima are undocumented.+ return {"limit": config.page_size} if config.page_size else {}+++def _get_v2_list_rows(+ session: requests.Session,+ headers: dict[str, str],+ logger: FilteringBoundLogger,+ config: InngestEndpointConfig,+ path: str,+) -> Iterator[list[dict[str, Any]]]:+ for items, _ in _iter_v2_pages(session, headers, logger, path, _page_params(config)):+ rows = [_drop_redacted_fields(item, config.redacted_fields) for item in items]+ if rows:+ yield rows+++def _normalize_v2_run(run: dict[str, Any]) -> dict[str, Any]:+ output = run.get("output")+ if output is not None and not isinstance(output, str):+ run["output"] = json.dumps(output)+ return run+++def _get_v2_run_rows(+ session: requests.Session,+ headers: dict[str, str],+ logger: FilteringBoundLogger,+ config: InngestEndpointConfig,+ path: str,+ resumable_source_manager: ResumableSourceManager[InngestResumeConfig],+ should_use_incremental_field: bool,+ db_incremental_field_last_value: Any,+) -> Iterator[list[dict[str, Any]]]:+ """List every run (event, cron and invoke triggered) over a pinned queuedAt window, oldest first.++ The resume state reuses the events walk's fields: `cursor` is the v2 page cursor and+ `received_after`/`received_before` hold the pinned `from`/`until` bounds.+ """+ resume = resumable_source_manager.load_state() if resumable_source_manager.can_resume() else None+ if resume is not None and resume.received_after and resume.received_before:+ window: SyncWindow[str] = SyncWindow(start=resume.received_after, end=resume.received_before)+ cursor = resume.cursor+ else:+ window = _event_window(should_use_incremental_field, db_incremental_field_last_value)+ cursor = None++ params = {+ **_page_params(config),+ "from": window.start,+ "until": window.end,+ "timeField": "queuedAt",+ "order": "ASC",+ "includeOutput": "true",+ }+ for items, next_cursor in _iter_v2_pages(session, headers, logger, path, params, cursor):+ if next_cursor:+ resumable_source_manager.save_state(+ InngestResumeConfig(cursor=next_cursor, received_after=window.start, received_before=window.end)+ )+ rows = [_normalize_v2_run(item) for item in items]+ if rows:+ yield rows+++def _get_app_function_rows(+ session: requests.Session,+ headers: dict[str, str],+ logger: FilteringBoundLogger,+ config: InngestEndpointConfig,+) -> Iterator[list[dict[str, Any]]]:+ for apps, _ in _iter_v2_pages(session, headers, logger, "/v2/apps", {"limit": V2_MAX_PAGE_SIZE}):+ for app in apps:+ app_id = app.get("id")+ if not app_id:+ continue+ path = config.path.format(app_id=quote(app_id, safe=""))+ for functions, _ in _iter_v2_pages(session, headers, logger, path, _page_params(config)):+ rows = [{**function, "app_id": app_id} for function in functions]+ if rows:+ yield rows+++def _session_window_params(config: InngestEndpointConfig, window: SyncWindow[str]) -> dict[str, Any]:+ # The default `from` of the session lists is undocumented, so always send the backfill window.+ return {**_page_params(config), "from": window.start, "until": window.end}+++def _iter_session_keys(+ session: requests.Session, headers: dict[str, str], logger: FilteringBoundLogger+) -> Iterator[str]:+ keys_config = INNGEST_ENDPOINTS["session_keys"]+ for keys, _ in _iter_v2_pages(session, headers, logger, keys_config.path, _page_params(keys_config)):+ for key in keys:+ if key.get("id"):+ yield key["id"]+++def _get_session_rows(+ session: requests.Session,+ headers: dict[str, str],+ logger: FilteringBoundLogger,+ config: InngestEndpointConfig,+) -> Iterator[list[dict[str, Any]]]:+ window = _event_window(should_use_incremental_field=False, db_incremental_field_last_value=None)+ for session_key in _iter_session_keys(session, headers, logger):+ path = config.path.format(session_key=quote(session_key, safe=""))+ for items, _ in _iter_v2_pages(session, headers, logger, path, _session_window_params(config, window)):+ rows = [{**item, "session_key": session_key} for item in items]+ if rows:+ yield rows+++def _get_session_run_rows(+ session: requests.Session,+ headers: dict[str, str],+ logger: FilteringBoundLogger,+ config: InngestEndpointConfig,+) -> Iterator[list[dict[str, Any]]]:+ sessions_config = INNGEST_ENDPOINTS["sessions"]+ window = _event_window(should_use_incremental_field=False, db_incremental_field_last_value=None)+ for session_key in _iter_session_keys(session, headers, logger):+ encoded_key = quote(session_key, safe="")+ sessions_path = sessions_config.path.format(session_key=encoded_key)+ for sessions, _ in _iter_v2_pages(+ session, headers, logger, sessions_path, _session_window_params(sessions_config, window)+ ):+ for session_group in sessions:+ session_id = session_group.get("id")+ if not session_id:+ continue+ path = config.path.format(session_key=encoded_key, session_id=quote(session_id, safe=""))+ for runs, _ in _iter_v2_pages(session, headers, logger, path, _session_window_params(config, window)):+ rows = [{**run, "session_key": session_key, "session_id": session_id} for run in runs]+ if rows:+ yield rows++def _get_v1_list_rows(session: requests.Session,headers: dict[str, str],@@ -387,6 +525,12 @@ def get_rows(should_use_incremental_field,db_incremental_field_last_value,)+ elif config.fan_out == "app_functions":+ yield from _get_app_function_rows(session, headers, logger, config)+ elif config.fan_out == "session_key_sessions":+ yield from _get_session_rows(session, headers, logger, config)+ elif config.fan_out == "session_runs":+ yield from _get_session_run_rows(session, headers, logger, config)elif pagination == "events_cursor":yield from _get_event_rows(session,@@ -396,6 +540,17 @@ def get_rows(should_use_incremental_field,db_incremental_field_last_value,)+ elif pagination == "v2_runs_window":+ yield from _get_v2_run_rows(+ session,+ headers,+ logger,+ config,+ path,+ resumable_source_manager,+ should_use_incremental_field,+ db_incremental_field_last_value,+ )elif pagination == "v2_cursor":yield from _get_v2_list_rows(session, headers, logger, config, path)else:@@ -430,7 +585,8 @@ def inngest_source(# The events walk's ordering within the window is undocumented (and could not be# curl-verified without credentials), so declare "desc": the watermark is then persisted# only at successful job end from the max value seen, which is correct for any arrival- # order. Full-refresh endpoints keep the default.+ # order. The v2 runs list is requested in ascending queuedAt order, and full-refresh+ # endpoints keep the default.sort_mode="desc" if config.pagination == "events_cursor" else "asc",partition_count=1,partition_size=1,diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/inngest/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/inngest/settings.pyindex 1e2f98b8566c..54314732e1a9 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/inngest/settings.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/inngest/settings.py@@ -13,14 +13,17 @@ INNGEST_API_VERSION_V2 = "v2"INNGEST_SUPPORTED_VERSIONS = (INNGEST_API_VERSION_V1, INNGEST_API_VERSION_V2)INNGEST_DEFAULT_VERSION = INNGEST_API_VERSION_V2+# Documented max `limit` for the v2 apps, functions, runs and sessions lists.+V2_MAX_PAGE_SIZE = 100+@dataclass(frozen=True)class InngestVersionPath:path: str- pagination: Literal["events_cursor", "v2_cursor", "none"]+ pagination: Literal["events_cursor", "v2_cursor", "v2_runs_window", "none"]-@dataclass+@dataclass(frozen=True)class InngestEndpointConfig:name: strpath: str@@ -33,11 +36,18 @@ class InngestEndpointConfig:# - "events_cursor": the /v1/events walk — `cursor` (last event internal_id) + `limit`,# bounded by an explicit [received_after, received_before] window.# - "v2_cursor": v2 envelope pagination — follow `page.cursor` while `page.hasMore`.+ # - "v2_runs_window": v2 envelope pagination over a pinned [from, until] queuedAt window,+ # ordered ascending.# - "none": a single request returning the full (small) list.- pagination: Literal["events_cursor", "v2_cursor", "none"] = "none"+ pagination: Literal["events_cursor", "v2_cursor", "v2_runs_window", "none"] = "none"# When True, the endpoint fans out over the incremental events walk, fetching# GET /v1/events/{internal_id}/runs once per event.fan_out_runs_per_event: bool = False+ # v2 parent/child walks: "app_functions" lists each app's functions, "session_key_sessions"+ # lists each session key's sessions, "session_runs" lists each session's runs.+ fan_out: Optional[Literal["app_functions", "session_key_sessions", "session_runs"]] = None+ # `limit` sent on v2 list requests. None keeps the server default.+ page_size: Optional[int] = None# Secret-bearing response fields dropped from every row before yielding — key material# must never be synced into the warehouse.redacted_fields: tuple[str, ...] = ()@@ -57,9 +67,10 @@ class InngestEndpointConfig:## Only the event-driven endpoints sync incrementally: GET /v1/events takes `received_after` /# `received_before` RFC3339 bounds, a genuine server-side filter (and `received_after` defaults to-# only 1 hour ago, so we always pass it explicitly). Function runs have no list endpoint of their-# own — they are discovered by walking the events window and fetching each event's runs. The-# remaining endpoints are small full-refresh inventories with no server-side timestamp filter.+# only 1 hour ago, so we always pass it explicitly). `function_runs` is discovered by walking the+# events window and fetching each event's runs, so it misses cron- and invoke-triggered runs;+# `runs` lists every run directly from GET /v2/runs with a server-side queuedAt window. The+# remaining endpoints are full-refresh inventories with no server-side timestamp filter.INNGEST_ENDPOINTS: dict[str, InngestEndpointConfig] = {"events": InngestEndpointConfig(name="events",@@ -101,6 +112,36 @@ INNGEST_ENDPOINTS: dict[str, InngestEndpointConfig] = {},],),+ "runs": InngestEndpointConfig(+ name="runs",+ path="/v2/runs",+ # Run IDs are ULIDs, unique across the environment.+ primary_keys=["id"],+ # `queuedAt` is set when the run is enqueued and never changes.+ partition_key="queuedAt",+ pagination="v2_runs_window",+ page_size=V2_MAX_PAGE_SIZE,+ # The window filters on queuedAt, so a run that was still Running when pulled keeps that+ # status until re-read; re-read a trailing hour each run so recent runs settle.+ default_incremental_lookback_seconds=3600,+ incremental_fields=[+ {+ "label": "queuedAt",+ "type": IncrementalFieldType.DateTime,+ "field": "queuedAt",+ "field_type": IncrementalFieldType.DateTime,+ },+ ],+ ),+ "functions": InngestEndpointConfig(+ name="functions",+ path="/v2/apps/{app_id}/functions",+ # Function IDs are only documented per app, so the parent app ID is part of the key.+ primary_keys=["app_id", "id"],+ pagination="v2_cursor",+ fan_out="app_functions",+ page_size=V2_MAX_PAGE_SIZE,+ ),"cancellations": InngestEndpointConfig(name="cancellations",path="/v1/cancellations",@@ -138,6 +179,34 @@ INNGEST_ENDPOINTS: dict[str, InngestEndpointConfig] = {pagination="v2_cursor",redacted_fields=("key",),),+ # AgentKit sessions: a session key names a grouping dimension, a session is one value of it.+ "session_keys": InngestEndpointConfig(+ name="session_keys",+ path="/v2/sessions",+ primary_keys=["id"],+ pagination="v2_cursor",+ page_size=V2_MAX_PAGE_SIZE,+ ),+ "sessions": InngestEndpointConfig(+ name="sessions",+ path="/v2/sessions/{session_key}",+ primary_keys=["session_key", "id"],+ pagination="v2_cursor",+ fan_out="session_key_sessions",+ page_size=V2_MAX_PAGE_SIZE,+ ),+ "session_runs": InngestEndpointConfig(+ name="session_runs",+ path="/v2/sessions/{session_key}/{session_id}/runs",+ # A run can belong to more than one session, so both parents are part of the key.+ primary_keys=["session_key", "session_id", "id"],+ partition_key="queuedAt",+ pagination="v2_cursor",+ fan_out="session_runs",+ page_size=V2_MAX_PAGE_SIZE,+ # One request per session, so it is opt-in.+ should_sync_default=False,+ ),}ENDPOINTS = tuple(INNGEST_ENDPOINTS.keys())diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/inngest/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/inngest/source.pyindex a116eb3c7c48..963871c0f5cd 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/inngest/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/inngest/source.py@@ -108,7 +108,7 @@ Inngest retains event and run history for a plan-dependent window (from 24 hoursappend_only_endpoints = {"events"}# Run rows mutate (status/output settle after the run ends) and the incremental lookback# re-pulls a window each run; only merge dedupes those, append would duplicate them.- merge_only_endpoints = {"function_runs"}+ merge_only_endpoints = {"function_runs", "runs"}def _description(endpoint: str) -> str | None:if endpoint == "events":@@ -122,6 +122,13 @@ Inngest retains event and run history for a plan-dependent window (from 24 hours"output are point-in-time; a trailing window is re-read each sync so recent runs ""settle, but long-lived runs only update on a full refresh")+ if endpoint == "runs":+ return (+ "Every function run, including cron- and invoke-triggered runs. A trailing window is "+ "re-read each sync so recent runs settle, but long-lived runs only update on a full refresh"+ )+ if endpoint == "session_runs":+ return "Runs grouped by AgentKit session (one lookup per session)"return Nonedef _build_schema(endpoint: str) -> SourceSchema:diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/inngest/tests/test_inngest.py b/products/warehouse_sources/backend/temporal/data_imports/sources/inngest/tests/test_inngest.pyindex 53d57af3e3a4..13ade2d15a45 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/inngest/tests/test_inngest.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/inngest/tests/test_inngest.py@@ -273,6 +273,98 @@ class TestV2ListPagination:assert rows == [{"id": "k1", "name": "prod key"}]+class TestV2Runs:+ @time_machine.travel("2026-07-14T12:00:00Z", tick=False)+ def test_pages_a_pinned_ascending_queued_at_window_and_stages_the_next_cursor(self) -> None:+ pages = [+ {"data": [{"id": "r1", "output": {"ok": True}}], "page": {"cursor": "c2", "hasMore": True}},+ {"data": [{"id": "r2", "output": "done"}], "page": {"cursor": "c3", "hasMore": False}},+ ]+ seen: list[tuple[str, dict]] = []++ def fake_fetch(session: Any, url: str, headers: dict, logger: Any, params: dict | None = None) -> Any:+ seen.append((url, dict(params or {})))+ return pages[len(seen) - 1]++ rows, manager = _run_rows(+ "runs",+ fake_fetch,+ should_use_incremental_field=True,+ db_incremental_field_last_value="2026-07-10T08:30:00Z",+ )++ assert [r["id"] for r in rows] == ["r1", "r2"]+ assert rows[0]["output"] == json.dumps({"ok": True})+ assert rows[1]["output"] == "done"+ assert all(url == "https://api.inngest.com/v2/runs" for url, _ in seen)+ for _, params in seen:+ # The incremental watermark is a queuedAt value, so the server window and the order+ # must use queuedAt too; any other field skips or re-reads runs.+ assert params["from"] == "2026-07-10T08:30:00.000Z"+ assert params["until"] == "2026-07-14T12:00:00.000Z"+ assert params["timeField"] == "queuedAt"+ assert params["order"] == "ASC"+ assert "cursor" not in seen[0][1]+ assert seen[1][1]["cursor"] == "c2"+ assert [(s.cursor, s.received_after, s.received_before) for s in manager.saved] == [+ ("c2", "2026-07-10T08:30:00.000Z", "2026-07-14T12:00:00.000Z")+ ]++ def test_resume_continues_the_saved_cursor_and_window(self) -> None:+ state = InngestResumeConfig(+ cursor="c2", received_after="2026-07-01T00:00:00.000Z", received_before="2026-07-14T00:00:00.000Z"+ )+ seen_params: list[dict] = []++ def fake_fetch(session: Any, url: str, headers: dict, logger: Any, params: dict | None = None) -> Any:+ seen_params.append(dict(params or {}))+ return {"data": [{"id": "r2"}], "page": {"hasMore": False}}++ _run_rows("runs", fake_fetch, manager=_FakeResumableManager(state))+ assert seen_params[0]["cursor"] == "c2"+ assert seen_params[0]["from"] == "2026-07-01T00:00:00.000Z"+ assert seen_params[0]["until"] == "2026-07-14T00:00:00.000Z"+++class TestV2FanOut:+ def test_functions_are_listed_per_app_with_the_parent_app_id(self) -> None:+ # `app_id` is part of the primary key; dropping it would collide functions across apps.+ def fake_fetch(session: Any, url: str, headers: dict, logger: Any, params: dict | None = None) -> Any:+ if url.endswith("/v2/apps"):+ return {"data": [{"id": "billing"}, {"id": "my app/v2"}], "page": {"hasMore": False}}+ return {"data": [{"id": f"fn-{url}"}], "page": {"hasMore": False}}++ rows, _ = _run_rows("functions", fake_fetch)+ assert [(r["app_id"], r["id"]) for r in rows] == [+ ("billing", "fn-https://api.inngest.com/v2/apps/billing/functions"),+ # User-defined app IDs are encoded so they can't change the request path.+ ("my app/v2", "fn-https://api.inngest.com/v2/apps/my%20app%2Fv2/functions"),+ ]++ @time_machine.travel("2026-07-14T12:00:00Z", tick=False)+ def test_session_runs_walk_keys_then_sessions_and_carry_both_parents(self) -> None:+ seen: list[tuple[str, dict]] = []++ def fake_fetch(session: Any, url: str, headers: dict, logger: Any, params: dict | None = None) -> Any:+ seen.append((url, dict(params or {})))+ path = url.removeprefix("https://api.inngest.com")+ if path == "/v2/sessions":+ return {"data": [{"id": "userId"}], "page": {"hasMore": False}}+ if path == "/v2/sessions/userId":+ return {"data": [{"id": "u-1"}, {"id": "u-2"}], "page": {"hasMore": False}}+ return {"data": [{"id": f"run-{path.split('/')[4]}"}], "page": {"hasMore": False}}++ rows, _ = _run_rows("session_runs", fake_fetch)+ assert rows == [+ {"id": "run-u-1", "session_key": "userId", "session_id": "u-1"},+ {"id": "run-u-2", "session_key": "userId", "session_id": "u-2"},+ ]+ # The session lists' default time range is undocumented, so the backfill window is always sent.+ for url, params in seen[1:]:+ assert params["from"] == "2026-04-15T12:00:00.000Z", url+ assert params["until"] == "2026-07-14T12:00:00.000Z", url++class TestV1Lists:@parameterized.expand([@@ -387,6 +479,8 @@ class TestSourceResponse:# successful job end — the walk's arrival order within the window is unverified.("events", "desc", "received_at"),("function_runs", "desc", "run_started_at"),+ ("runs", "asc", "queuedAt"),+ ("session_runs", "asc", "queuedAt"),("cancellations", "asc", None),("environments", "asc", None),("webhooks", "asc", None),diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/inngest/tests/test_inngest_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/inngest/tests/test_inngest_source.pyindex 3be07e09dbf1..44472b138011 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/inngest/tests/test_inngest_source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/inngest/tests/test_inngest_source.py@@ -63,6 +63,11 @@ class TestInngestSource:# small inventory with no server-side timestamp filter and syncs as full refresh.("events", False, True, ["received_at"]),("function_runs", True, False, ["event_received_at"]),+ ("runs", True, False, ["queuedAt"]),+ ("functions", False, False, []),+ ("session_keys", False, False, []),+ ("sessions", False, False, []),+ ("session_runs", False, False, []),("cancellations", False, False, []),("environments", False, False, []),("webhooks", False, False, []),@@ -78,10 +83,11 @@ class TestInngestSource:assert schema.supports_append is supports_appendassert [f["field"] for f in schema.incremental_fields] == incremental_fields- def test_function_runs_re_read_a_trailing_window(self) -> None:+ @parameterized.expand([("function_runs",), ("runs",)])+ def test_run_tables_re_read_a_trailing_window(self, endpoint: str) -> None:# Runs fetched while still Running keep a stale status unless each incremental sync# re-reads a trailing window; dropping the default lookback would freeze them forever.- schema = next(s for s in self.source.get_schemas(MagicMock(), team_id=1) if s.name == "function_runs")+ schema = next(s for s in self.source.get_schemas(MagicMock(), team_id=1) if s.name == endpoint)assert schema.default_incremental_lookback_seconds == 3600@parameterized.expand([("valid", True, True), ("invalid", False, False)])