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(data-warehouse): add braintrust event and user tables (#118998)

Tom Owers689c7e80d70b
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 0a0c9bd61ca0..9a5cad902cbf 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
@@ -1806,18 +1806,18 @@ Note: Source uses the Braintree GraphQL API (payments.braintree-api.com/graphql)
## Braintrust — **thin**
-Today (5): `datasets`, `experiments`, `functions`, `projects`, `prompts`
+Today (9): `dataset_events`, `datasets`, `experiment_events`, `experiments`, `functions`, `project_logs`, `projects`, `prompts`, `users`
Diffed against: <https://www.braintrust.dev/docs/openapi.json>
-- [ ] `Project log events (GET /v1/project_logs/{project_id}/fetch)` — analyze production traces, scores, token usage, latency, and model costs (high)
-- [ ] `Experiment events (GET /v1/experiment/{experiment_id}/fetch)` — compare evaluation results, scores, and model behavior for individual test cases (high)
-- [ ] `Dataset events (GET /v1/dataset/{dataset_id}/fetch)` — analyze evaluation inputs, expected outputs, and dataset contents beyond metadata (high)
-- [ ] `Users (GET /v1/user)` — resolve user_id in projects, experiments, and datasets to identify their creators (high)
+- [x] `Project log events (GET /v1/project_logs/{project_id}/fetch)` — analyze production traces, scores, token usage, latency, and model costs (high)
+- [x] `Experiment events (GET /v1/experiment/{experiment_id}/fetch)` — compare evaluation results, scores, and model behavior for individual test cases (high)
+- [x] `Dataset events (GET /v1/dataset/{dataset_id}/fetch)` — analyze evaluation inputs, expected outputs, and dataset contents beyond metadata (high)
+- [x] `Users (GET /v1/user)` — resolve user_id in projects, experiments, and datasets to identify their creators (high)
- [ ] `Experiment summaries (GET /v1/experiment/{experiment_id}/summarize)` — report aggregate scores and metrics with comparisons against baseline experiments (medium)
- [ ] `Dataset snapshots (GET /v1/dataset_snapshot)` — track named dataset versions and connect evaluations to reproducible test data (medium)
-Note: The OpenAPI specification lists metadata resources and separate event collections. The source imports only metadata. Event tables need calls for each parent and cursor pagination. API keys, secrets, permissions, and saved views are excluded.
+Note: The OpenAPI specification lists metadata resources and separate event collections. The event tables fan out over each parent and page through the POST form of fetch with its body cursor. API keys, secrets, permissions, and saved views are excluded.
## Braze — gaps
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/braintrust/braintrust.py b/products/warehouse_sources/backend/temporal/data_imports/sources/braintrust/braintrust.py
index b88a073d81fb..64f177cff8e8 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/braintrust/braintrust.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/braintrust/braintrust.py
@@ -1,6 +1,8 @@
-from typing import Any
+import sqlite3
+from typing import Any, cast
from urllib.parse import urlsplit
+from requests import Request
from requests.exceptions import HTTPError
from posthog.dataclasses import frozen
@@ -9,16 +11,24 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.braintrust
AUTH_ERRORS,
ENDPOINTS,
PAGE_SIZE,
+ BraintrustEndpoint,
)
from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source import (
RESTAPIConfig,
rest_api_resource,
)
from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.auth import BearerTokenAuth
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.fanout import (
+ build_dependent_resource,
+)
from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.paginators import (
+ JSONResponseCursorPaginator,
SinglePagePaginator,
+ set_json_param,
)
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.resource import Resource
from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.rest_client import RESTClient
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.typing import ClientConfig
from products.warehouse_sources.backend.temporal.data_imports.sources.common.resumable import ResumableSourceManager
from products.warehouse_sources.backend.temporal.data_imports.sources.common.schema import schema_for_resource
from products.warehouse_sources.backend.temporal.data_imports.sources.common.typings import SourceResponse
@@ -29,7 +39,55 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.generated_
@frozen
class BraintrustResumeConfig:
- cursor: str
+ cursor: str | None = None
+ fanout: dict[str, Any] | None = None
+
+
+class FetchCursorPaginator(JSONResponseCursorPaginator):
+ # Fan-out child requests carry no endpoint body, so the page size rides in with the cursor.
+ def __init__(self, limit: int) -> None:
+ super().__init__(
+ cursor_path="cursor", cursor_param="cursor", param_location="json", raise_on_repeated_cursor=True
+ )
+ self.limit = limit
+
+ def init_request(self, request: Request) -> None:
+ if request.json is None:
+ request.json = {}
+ set_json_param(request.json, "limit", self.limit)
+ super().init_request(request)
+
+
+class LatestEventVersionFilter:
+ """Keep the first row seen per event id within each parent object.
+
+ Fetch pages walk the version history newest-first, so a repeated id is an outdated version.
+ The seen ids live in a private temporary SQLite database, which spills to disk, so a parent with
+ a long history does not hold every id in worker memory.
+ """
+
+ def __init__(self, parent_key: str) -> None:
+ self._parent_key = parent_key
+ self._parent: Any = None
+ self._seen: sqlite3.Connection | None = None
+
+ def _reset(self) -> None:
+ if self._seen is not None:
+ self._seen.close()
+ # An empty filename opens a private on-disk database that SQLite deletes on close.
+ self._seen = sqlite3.connect("", isolation_level=None, check_same_thread=False)
+ self._seen.execute("PRAGMA journal_mode = OFF")
+ self._seen.execute("PRAGMA synchronous = OFF")
+ self._seen.execute("CREATE TABLE seen (id TEXT PRIMARY KEY) WITHOUT ROWID")
+
+ def __call__(self, row: dict[str, Any]) -> bool:
+ parent = row.get(self._parent_key)
+ if self._seen is None or parent != self._parent:
+ self._parent = parent
+ self._reset()
+ assert self._seen is not None
+ inserted = self._seen.execute("INSERT OR IGNORE INTO seen (id) VALUES (?)", (str(row.get("id")),))
+ return inserted.rowcount == 1
def validated_api_url(api_url: str, team_id: int) -> str:
@@ -91,34 +149,36 @@ def validate_credentials(config: BraintrustSourceConfig, team_id: int) -> tuple[
return True, None
-def braintrust_source(
- config: BraintrustSourceConfig,
- endpoint: str,
+def _client_config(config: BraintrustSourceConfig, team_id: int) -> ClientConfig:
+ return {
+ "base_url": validated_api_url(config.api_url, team_id),
+ "auth": {"type": "bearer", "token": config.api_key},
+ "allowed_hosts": [],
+ "allow_redirects": False,
+ "request_timeout": (10, 60),
+ "paginator": {
+ "type": "cursor",
+ "cursor_path": "objects[-1].id",
+ "cursor_param": "starting_after",
+ "raise_on_repeated_cursor": True,
+ },
+ }
+
+
+def _list_resource(
+ settings: BraintrustEndpoint,
+ client_config: ClientConfig,
team_id: int,
job_id: str,
resumable_source_manager: ResumableSourceManager[BraintrustResumeConfig],
-) -> SourceResponse:
- path = schema_for_resource(ENDPOINTS, endpoint)
- base_url = validated_api_url(config.api_url, team_id)
+) -> Resource:
rest_config: RESTAPIConfig = {
- "client": {
- "base_url": base_url,
- "auth": {"type": "bearer", "token": config.api_key},
- "allowed_hosts": [],
- "allow_redirects": False,
- "request_timeout": (10, 60),
- "paginator": {
- "type": "cursor",
- "cursor_path": "objects[-1].id",
- "cursor_param": "starting_after",
- "raise_on_repeated_cursor": True,
- },
- },
+ "client": client_config,
"resources": [
{
- "name": endpoint,
+ "name": settings.name,
"endpoint": {
- "path": f"v1/{path}",
+ "path": settings.path,
"params": {"limit": PAGE_SIZE},
"data_selector": "objects",
"data_selector_required": True,
@@ -133,18 +193,79 @@ def braintrust_source(
if state and state.get("cursor"):
resumable_source_manager.save_state(BraintrustResumeConfig(cursor=str(state["cursor"])))
- resource = rest_api_resource(
+ return rest_api_resource(
rest_config,
team_id,
job_id,
db_incremental_field_last_value=None,
resume_hook=save_checkpoint,
- initial_paginator_state={"cursor": resume.cursor} if resume else None,
+ initial_paginator_state={"cursor": resume.cursor} if resume and resume.cursor else None,
)
+
+
+def _events_resource(
+ settings: BraintrustEndpoint,
+ client_config: ClientConfig,
+ team_id: int,
+ job_id: str,
+ resumable_source_manager: ResumableSourceManager[BraintrustResumeConfig],
+) -> Resource:
+ assert settings.fanout is not None
+ resume = resumable_source_manager.load_state() if resumable_source_manager.can_resume() else None
+
+ def save_checkpoint(state: dict[str, Any] | None) -> None:
+ if state:
+ resumable_source_manager.save_state(BraintrustResumeConfig(fanout=state))
+
+ resource = build_dependent_resource(
+ endpoint_configs=ENDPOINTS,
+ child_endpoint=settings.name,
+ fanout=settings.fanout,
+ client_config=client_config,
+ path_format_values={},
+ team_id=team_id,
+ job_id=job_id,
+ db_incremental_field_last_value=None,
+ parent_endpoint_extra={
+ "data_selector": "objects",
+ "data_selector_required": True,
+ "data_selector_malformed_retryable": True,
+ },
+ # The GET form of fetch takes no cursor, so pages are read through the POST form.
+ child_endpoint_extra={
+ "method": "POST",
+ "data_selector": "events",
+ "data_selector_required": True,
+ "data_selector_malformed_retryable": True,
+ "paginator": FetchCursorPaginator(settings.page_size),
+ },
+ page_size_param=None,
+ resume_hook=save_checkpoint,
+ initial_paginator_state=resume.fanout if resume else None,
+ )
+ return cast(Resource, resource).add_filter(LatestEventVersionFilter(settings.fanout.resolve_param))
+
+
+def braintrust_source(
+ config: BraintrustSourceConfig,
+ endpoint: str,
+ team_id: int,
+ job_id: str,
+ resumable_source_manager: ResumableSourceManager[BraintrustResumeConfig],
+) -> SourceResponse:
+ settings = schema_for_resource(ENDPOINTS, endpoint)
+ client_config = _client_config(config, team_id)
+ if settings.fanout is not None:
+ resource = _events_resource(settings, client_config, team_id, job_id, resumable_source_manager)
+ else:
+ resource = _list_resource(settings, client_config, team_id, job_id, resumable_source_manager)
return SourceResponse(
name=endpoint,
items=lambda: resource,
- primary_keys=["id"],
+ primary_keys=list(settings.primary_keys),
+ partition_keys=[settings.partition_key] if settings.partition_key else None,
+ partition_mode="datetime" if settings.partition_key else None,
+ partition_format="month" if settings.partition_key else None,
sort_mode="desc",
on_complete=resumable_source_manager.clear_state,
)
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/braintrust/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/braintrust/canonical_descriptions.py
index a2dbc33728fb..1f084c495857 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/braintrust/canonical_descriptions.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/braintrust/canonical_descriptions.py
@@ -29,7 +29,7 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
},
},
"datasets": {
- "description": "Dataset definitions used for evaluations. These rows do not contain dataset records.",
+ "description": "Dataset definitions used for evaluations. The dataset records are in dataset_events.",
"docs_url": "https://www.braintrust.dev/docs/openapi.json",
"columns": {
"id": "The dataset's unique identifier.",
@@ -61,4 +61,77 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
"function_schema": "The JSON schema for the function parameters and return value.",
},
},
+ "users": {
+ "description": "Users in the organization, which resolve the user_id on projects, experiments, and datasets.",
+ "docs_url": "https://www.braintrust.dev/docs/openapi.json",
+ "columns": {
+ "id": "The user's unique identifier.",
+ "given_name": "The user's given name.",
+ "family_name": "The user's family name.",
+ "email": "The user's email address.",
+ "avatar_url": "The URL of the user's avatar image.",
+ "created": "The time when the user was created.",
+ },
+ },
+ "project_logs": {
+ "description": "Production log events (spans) of each project, with inputs, outputs, scores, and metrics. One row per event, latest version only.",
+ "docs_url": "https://www.braintrust.dev/docs/openapi.json",
+ "columns": {
+ "id": "The project log event's unique identifier within its project.",
+ "_xact_id": "The transaction identifier of the latest write to the event. It increases over time.",
+ "created": "The time when the event was created.",
+ "project_id": "The identifier of the project that owns the event.",
+ "org_id": "The identifier of the organization that owns the project.",
+ "input": "The arguments that define the input to the application.",
+ "output": "The output of the application.",
+ "expected": "The ground truth value to compare with the output.",
+ "error": "The error that occurred, if any.",
+ "scores": "Numeric scores between 0 and 1, keyed by score name.",
+ "metadata": "User-defined metadata about the event.",
+ "tags": "The tags on the event.",
+ "metrics": "Numeric measurements of the execution, such as start and end times and token counts.",
+ "span_id": "The identifier of the span that this event records.",
+ "root_span_id": "The identifier of the trace that the event belongs to.",
+ "span_parents": "The span identifiers of the event's parent spans. Empty for a root span.",
+ "is_root": "Whether the event is the root span of its trace.",
+ },
+ },
+ "experiment_events": {
+ "description": "Evaluation events (spans) of each experiment, with inputs, outputs, expected values, and scores. One row per event, latest version only.",
+ "docs_url": "https://www.braintrust.dev/docs/openapi.json",
+ "columns": {
+ "id": "The experiment event's unique identifier within its experiment.",
+ "_xact_id": "The transaction identifier of the latest write to the event. It increases over time.",
+ "created": "The time when the event was created.",
+ "project_id": "The identifier of the project that owns the event.",
+ "experiment_id": "The identifier of the experiment that contains the event.",
+ "input": "The arguments that define the input to the application.",
+ "output": "The output of the application.",
+ "expected": "The ground truth value to compare with the output.",
+ "error": "The error that occurred, if any.",
+ "scores": "Numeric scores between 0 and 1, keyed by score name.",
+ "metadata": "User-defined metadata about the event.",
+ "tags": "The tags on the event.",
+ "metrics": "Numeric measurements of the execution, such as start and end times and token counts.",
+ "span_id": "The identifier of the span that this event records.",
+ "root_span_id": "The identifier of the trace that the event belongs to.",
+ "span_parents": "The span identifiers of the event's parent spans. Empty for a root span.",
+ "is_root": "Whether the event is the root span of its trace.",
+ },
+ },
+ "dataset_events": {
+ "description": "Records of each dataset, with inputs and expected outputs. One row per record, latest version only.",
+ "docs_url": "https://www.braintrust.dev/docs/openapi.json",
+ "columns": {
+ "id": "The dataset event's unique identifier within its dataset.",
+ "_xact_id": "The transaction identifier of the latest write to the event. It increases over time.",
+ "created": "The time when the event was created.",
+ "project_id": "The identifier of the project that owns the event.",
+ "dataset_id": "The identifier of the dataset that contains the event.",
+ "input": "The input of the dataset record.",
+ "expected": "The expected output of the dataset record.",
+ "metadata": "User-defined metadata about the record.",
+ "tags": "The tags on the record.",
+ },
+ },
}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/braintrust/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/braintrust/settings.py
index 8d3b422b14f7..66667cf40210 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/braintrust/settings.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/braintrust/settings.py
@@ -1,12 +1,66 @@
-ENDPOINTS = {
- "projects": "project",
- "experiments": "experiment",
- "datasets": "dataset",
- "prompts": "prompt",
- "functions": "function",
-}
+from dataclasses import field
+
+from posthog.dataclasses import frozen
+
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.fanout import (
+ DependentEndpointConfig,
+)
+from products.warehouse_sources.backend.types import IncrementalField
PAGE_SIZE = 100
+# Fetch endpoints count `limit` in traces, so one page can hold many more rows than this.
+EVENTS_PAGE_SIZE = 100
+
+
+@frozen
+class BraintrustEndpoint:
+ name: str
+ path: str
+ primary_keys: tuple[str, ...] = ("id",)
+ partition_key: str | None = None
+ fanout: DependentEndpointConfig | None = None
+ page_size: int = PAGE_SIZE
+ incremental_fields: list[IncrementalField] = field(default_factory=list)
+ default_incremental_field: str | None = None
+
+
+def _events_endpoint(name: str, path: str, parent_name: str, parent_key: str) -> BraintrustEndpoint:
+ return BraintrustEndpoint(
+ name=name,
+ path=path,
+ primary_keys=(parent_key, "id"),
+ partition_key="created",
+ page_size=EVENTS_PAGE_SIZE,
+ fanout=DependentEndpointConfig(
+ parent_name=parent_name,
+ resolve_param=parent_key,
+ resolve_field="id",
+ include_from_parent=[],
+ parent_params={"limit": PAGE_SIZE},
+ ),
+ )
+
+
+ENDPOINTS: dict[str, BraintrustEndpoint] = {
+ "projects": BraintrustEndpoint(name="projects", path="v1/project"),
+ "experiments": BraintrustEndpoint(name="experiments", path="v1/experiment"),
+ "datasets": BraintrustEndpoint(name="datasets", path="v1/dataset"),
+ "prompts": BraintrustEndpoint(name="prompts", path="v1/prompt"),
+ "functions": BraintrustEndpoint(name="functions", path="v1/function"),
+ "users": BraintrustEndpoint(name="users", path="v1/user"),
+ "project_logs": _events_endpoint(
+ "project_logs", "v1/project_logs/{project_id}/fetch", parent_name="projects", parent_key="project_id"
+ ),
+ "experiment_events": _events_endpoint(
+ "experiment_events",
+ "v1/experiment/{experiment_id}/fetch",
+ parent_name="experiments",
+ parent_key="experiment_id",
+ ),
+ "dataset_events": _events_endpoint(
+ "dataset_events", "v1/dataset/{dataset_id}/fetch", parent_name="datasets", parent_key="dataset_id"
+ ),
+}
AUTH_ERRORS = {
401: "Braintrust rejected the API key. Check the key in your organization settings.",
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/braintrust/tests/test_braintrust.py b/products/warehouse_sources/backend/temporal/data_imports/sources/braintrust/tests/test_braintrust.py
index 74109b1d3723..1af1ec5329f3 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/braintrust/tests/test_braintrust.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/braintrust/tests/test_braintrust.py
@@ -23,6 +23,7 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.common.tes
ScriptedResponse,
SourceDriver,
always,
+ route,
scripted_network,
)
from products.warehouse_sources.backend.temporal.data_imports.sources.generated_configs.braintrust import (
@@ -62,6 +63,7 @@ def make_driver(config: BraintrustSourceConfig | None = None) -> SourceDriver:
("datasets", "dataset"),
("prompts", "prompt"),
("functions", "function"),
+ ("users", "user"),
],
)
def test_pagination_auth_and_checkpoints(http: responses.RequestsMock, table: str, path: str) -> None:
@@ -86,6 +88,91 @@ def test_pagination_auth_and_checkpoints(http: responses.RequestsMock, table: st
manager.clear_state.assert_called_once_with()
+EVENT_TABLES = [
+ ("project_logs", "project", "project_logs/{}/fetch", "project_id"),
+ ("experiment_events", "experiment", "experiment/{}/fetch", "experiment_id"),
+ ("dataset_events", "dataset", "dataset/{}/fetch", "dataset_id"),
+]
+
+
+def event_script(parent_path: str, child_path: str, parent_key: str) -> Any:
+ return route(
+ {
+ f"/v1/{parent_path}": [
+ ScriptedResponse(json={"objects": [{"id": "p1"}, {"id": "p2"}]}),
+ ScriptedResponse(json={"objects": []}),
+ ],
+ f"/v1/{child_path.format('p1')}": [
+ ScriptedResponse(
+ json={
+ "events": [{"id": "a", parent_key: "p1", "_xact_id": "3"}, {"id": "b", parent_key: "p1"}],
+ "cursor": "c1",
+ }
+ ),
+ ScriptedResponse(
+ json={
+ "events": [{"id": "a", parent_key: "p1", "_xact_id": "1"}, {"id": "c", parent_key: "p1"}],
+ "cursor": "c2",
+ }
+ ),
+ ScriptedResponse(json={"events": []}),
+ ],
+ f"/v1/{child_path.format('p2')}": [ScriptedResponse(json={"events": [{"id": "a", parent_key: "p2"}]})],
+ }
+ )
+
+
[email protected](("table", "parent_path", "child_path", "parent_key"), EVENT_TABLES)
+def test_event_fanout_pages_by_body_cursor_and_drops_outdated_versions(
+ table: str, parent_path: str, child_path: str, parent_key: str
+) -> None:
+ result = make_driver().run(table, event_script(parent_path, child_path, parent_key))
+ assert result.raised is None
+ assert [(row[parent_key], row["id"], row.get("_xact_id")) for row in result.rows] == [
+ ("p1", "a", "3"),
+ ("p1", "b", None),
+ ("p1", "c", None),
+ ("p2", "a", None),
+ ]
+ p1_requests = [request for request in result.requests if request.path == f"/v1/{child_path.format('p1')}"]
+ assert [request.method for request in p1_requests] == ["POST"] * 3
+ assert [request.json() for request in p1_requests] == [
+ {"limit": 100},
+ {"limit": 100, "cursor": "c1"},
+ {"limit": 100, "cursor": "c2"},
+ ]
+ assert result.response is not None
+ assert result.response.primary_keys == [parent_key, "id"]
+
+
+def test_event_fanout_resumes_from_saved_parent_cursor() -> None:
+ first = make_driver().run("project_logs", event_script("project", "project_logs/{}/fetch", "project_id"))
+ assert first.raised is None
+ mid_parent = next(
+ state for state in first.saved_states if state.fanout and (state.fanout.get("child_state") or {}).get("cursor")
+ )
+ resumed = make_driver().run(
+ "project_logs",
+ route(
+ {
+ "/v1/project": [
+ ScriptedResponse(json={"objects": [{"id": "p1"}, {"id": "p2"}]}),
+ ScriptedResponse(json={"objects": []}),
+ ],
+ "/v1/project_logs/p1/fetch": [
+ ScriptedResponse(json={"events": [{"id": "c", "project_id": "p1"}]}),
+ ],
+ "/v1/project_logs/p2/fetch": [ScriptedResponse(json={"events": []})],
+ }
+ ),
+ resume_state=mid_parent,
+ )
+ assert resumed.raised is None
+ p1_bodies = [request.json() for request in resumed.requests if request.path == "/v1/project_logs/p1/fetch"]
+ assert p1_bodies == [{"limit": 100, "cursor": "c1"}]
+ assert [row["id"] for row in resumed.rows] == ["c"]
+
+
@pytest.mark.parametrize("cursor", [None, "saved"])
def test_empty_page_and_resume(cursor: str | None) -> None:
result = make_driver().run(