: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 fulcrum history, groups and audit log tables (#108303)
Tom Owers33e2765a54c0
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.mdindex 7167f0228c39..bab09c166d8c 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@@ -3449,14 +3449,14 @@ Note: Diffed against Front's published OpenAPI 3.0 spec (128 GET operations). Th## Fulcrum — gaps-Today (13): `audio`, `changesets`, `choice_lists`, `classification_sets`, `forms`, `memberships`, `photos`, `projects`, `records`, `roles`, `signatures`, `videos`, `webhooks`+Today (17): `audio`, `audit_logs`, `changesets`, `choice_lists`, `classification_sets`, `form_history`, `forms`, `groups`, `memberships`, `photos`, `projects`, `records`, `records_history`, `roles`, `signatures`, `videos`, `webhooks`Diffed against: <https://docs.fulcrumapp.com/reference/records-intro>-- [ ] `records/history (records-get-all-history)` — full version history of every record — the only way to analyze edits, corrections and field-level change over time (high)-- [ ] `groups (+ group resources)` — lookup that resolves the group ID carried on the memberships and projects already synced (high)-- [ ] `audit_logs` — account-wide activity trail: who did what to which form, record or membership (medium)-- [ ] `forms/{id}/history` — form schema versions, needed to interpret older records collected under a prior form definition (medium)+- [x] `records/history (records-get-all-history)` — full version history of every record — the only way to analyze edits, corrections and field-level change over time (high)+- [x] `groups (+ group resources)` — lookup that resolves the group ID carried on the memberships and projects already synced (high). Synced with `associations=true`, which returns each group's member, layer, project and form ids on the group row; the per-resource `groups/{id}/{resource}` endpoint only re-lists rows the `memberships`, `projects` and `forms` tables already hold.+- [x] `audit_logs` — account-wide activity trail: who did what to which form, record or membership (medium)+- [x] `forms/{id}/history` — form schema versions, needed to interpret older records collected under a prior form definition (medium)- [ ] `sketches` — the one media type not synced alongside photos, audio, video and signatures — leaves media coverage inconsistent (low)- [ ] `attachments` — arbitrary file attachments linked to records, with metadata for completeness checks (low)- [ ] `layers` — reference data layers that records join against for spatial context (low)diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/fulcrum/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/fulcrum/canonical_descriptions.pyindex 2f5680670a18..7ad8ffac67ae 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/fulcrum/canonical_descriptions.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/fulcrum/canonical_descriptions.py@@ -36,6 +36,68 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {"record_count": "The number of records in this form.",},},+ "records_history": {+ "description": "Every version of every record, including edits, corrections and deletions, so field-level change can be analysed over time.",+ "docs_url": "https://docs.fulcrumapp.com/reference/records-get-all-history",+ "columns": {+ "history_id": "Unique identifier for this history entry.",+ "history_change_type": "Type of change this entry records: c for create, u for update, d for delete.",+ "history_created_at": "Timestamp when this history entry was created.",+ "history_changed_by_id": "Identifier of the member who made this change.",+ "history_changed_by": "Display name of the member who made this change.",+ "id": "Identifier of the record this history entry belongs to.",+ "version": "Version number of the record at this history entry.",+ "form_id": "Identifier of the form this record belongs to.",+ "form_version": "Version of the form the record was collected under.",+ "changeset_id": "Identifier of the changeset this version was part of.",+ "form_values": "Object of the record's field values at this version, keyed by the form schema's element keys.",+ "created_at": "Timestamp when the record was created.",+ "updated_at": "Timestamp when the record was last updated.",+ },+ },+ "form_history": {+ "description": "Past versions of each form's schema, needed to interpret records collected under an earlier form definition.",+ "docs_url": "https://docs.fulcrumapp.com/reference/forms-get-history",+ "columns": {+ "form_id": "Identifier of the form this version belongs to.",+ "version": "Version number of the form schema.",+ "name": "The form's name at this version.",+ "description": "The form's description at this version.",+ "elements": "The form's custom elements (its field schema) at this version.",+ "status_field": "The form's status field configuration at this version.",+ },+ },+ "audit_logs": {+ "description": "Read-only trail of user activity across the organization: who changed which form, record, membership or other resource, and when.",+ "docs_url": "https://docs.fulcrumapp.com/reference/audit-logs-intro",+ "columns": {+ "id": "Unique identifier for the audit log entry.",+ "source_type": "Type of resource the activity was performed on, such as form, membership, layer or project.",+ "source_id": "Identifier of the resource the activity was performed on.",+ "action": "The action that was logged, such as create, update, delete or download.",+ "description": "Brief description of the logged activity.",+ "data": "Additional data captured for certain activities.",+ "actor": "Name of the member that triggered the activity.",+ "actor_id": "Identifier of the member that triggered the activity.",+ "time": "Timestamp when the activity was recorded.",+ "ip": "IP address of the device that triggered the activity.",+ "user_agent": "User agent of the browser that triggered the activity.",+ "location": "Approximate location of the device that triggered the activity, derived from its IP address.",+ },+ },+ "groups": {+ "description": "Groups used to manage member permissions to forms, layers and projects in bulk. Resolves the group ids carried on memberships and projects.",+ "docs_url": "https://docs.fulcrumapp.com/reference/groups-api",+ "columns": {+ "id": "Unique identifier for the group.",+ "name": "The name of the group.",+ "description": "The description given to the group.",+ "member_ids": "Identifiers of the members in the group.",+ "layer_ids": "Identifiers of the layers in the group.",+ "project_ids": "Identifiers of the projects in the group.",+ "form_ids": "Identifiers of the forms in the group.",+ },+ },"choice_lists": {"description": "Reusable lists of choices that can be referenced by choice fields across forms.","docs_url": "https://docs.fulcrumapp.com/reference/choice-lists-intro",diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/fulcrum/fulcrum.py b/products/warehouse_sources/backend/temporal/data_imports/sources/fulcrum/fulcrum.pyindex 05369e866806..b880dd8db103 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/fulcrum/fulcrum.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/fulcrum/fulcrum.py@@ -1,16 +1,24 @@-import dataclasses+from collections.abc import Iterablefrom datetime import UTC, date, datetime-from typing import Any, Optional+from typing import Any, Optional, castfrom requests import Request, Response+from posthog.dataclasses import frozen+from products.warehouse_sources.backend.temporal.data_imports.sources.common.http import make_tracked_sessionfrom 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.fanout import (+ build_dependent_resource,+)from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.paginators import BasePaginator-from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.typing import Endpoint+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.typing import (+ ClientConfig,+ Endpoint,+)from products.warehouse_sources.backend.temporal.data_imports.sources.common.resumable import ResumableSourceManagerfrom products.warehouse_sources.backend.temporal.data_imports.sources.common.source_helpers import validate_via_probefrom products.warehouse_sources.backend.temporal.data_imports.sources.common.typings import SourceResponse@@ -22,11 +30,18 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.fulcrum.seFULCRUM_BASE_URL = "https://api.fulcrumapp.com/api/v2"+@frozenclass FulcrumResumeConfig:- # Next page number to fetch. Page-number pagination is deterministic and the incremental- # `updated_since` filter is fixed for the job, so the page number alone is enough to resume.- page: int+ # Next page number to fetch for a top-level endpoint. Page-number pagination is deterministic+ # and the incremental `updated_since` filter is fixed for the job, so the page number alone is+ # enough to resume. None means "start from page 1".+ page: int | None = None+ # Fan-out endpoints (form_history) resume by parent instead: the parent paths already fully+ # synced, the parent in progress, and that parent's paginator state — see+ # `common.rest_source.__init__._make_paginate_dependent_resource`.+ completed: list[str] | None = None+ current: str | None = None+ child_state: dict[str, Any] | None = Nonedef _accept_header() -> dict[str, str]:@@ -113,25 +128,108 @@ class FulcrumPageNumberPaginator(BasePaginator):return f"FulcrumPageNumberPaginator(page={self.page})"+def _client_config(api_token: str) -> ClientConfig:+ return {+ "base_url": FULCRUM_BASE_URL,+ "headers": _accept_header(),+ # X-ApiToken travels as an api_key header so its value is redacted from logs and errors.+ "auth": {"type": "api_key", "api_key": api_token, "name": "X-ApiToken", "location": "header"},+ }++def _build_endpoint(config: FulcrumEndpointConfig) -> Endpoint:endpoint: Endpoint = {"path": config.path,- "params": {"per_page": config.page_size},+ "params": {"per_page": config.page_size, **config.params},"data_selector": config.data_key,"paginator": FulcrumPageNumberPaginator(per_page=config.page_size),}- if config.supports_incremental:- # Server-side filter on updated_at. Records default to updated_at ascending order, which- # matches SourceResponse.sort_mode="asc" so the watermark advances correctly. Only injected- # when a watermark is present (a None value is dropped from the query string).+ cursor_path = config.default_incremental_field+ if config.supports_incremental and cursor_path is not None:+ # Server-side filter on the endpoint's cursor field. Only injected when a watermark is+ # present (a None value is dropped from the query string).endpoint["incremental"] = {"start_param": "updated_since",- "cursor_path": "updated_at",+ "cursor_path": cursor_path,"convert": _to_epoch_seconds,}return endpoint+def _source_response(config: FulcrumEndpointConfig, items: Any, column_hints: Any = None) -> SourceResponse:+ return SourceResponse(+ name=config.name,+ items=items,+ primary_keys=config.primary_keys,+ sort_mode=config.sort_mode,+ partition_count=1,+ partition_size=1,+ partition_mode="datetime" if config.partition_key else None,+ partition_format="week" if config.partition_key else None,+ partition_keys=[config.partition_key] if config.partition_key else None,+ column_hints=column_hints,+ )+++def _fanout_source(+ config: FulcrumEndpointConfig,+ api_token: str,+ team_id: int,+ job_id: str,+ resumable_source_manager: ResumableSourceManager[FulcrumResumeConfig],+) -> SourceResponse:+ assert config.fanout is not None+ parent_config = FULCRUM_ENDPOINTS[config.fanout.parent_name]++ initial_state: Optional[dict[str, Any]] = None+ if resumable_source_manager.can_resume():+ resume = resumable_source_manager.load_state()+ if resume is not None and (resume.completed or resume.current):+ initial_state = {+ "completed": resume.completed or [],+ "current": resume.current,+ "child_state": resume.child_state,+ }++ def save_checkpoint(state: Optional[dict[str, Any]]) -> None:+ if state is not None:+ resumable_source_manager.save_state(+ FulcrumResumeConfig(+ completed=state.get("completed"),+ current=state.get("current"),+ child_state=state.get("child_state"),+ )+ )++ dependent_resource = cast(+ Iterable[Any],+ build_dependent_resource(+ endpoint_configs=FULCRUM_ENDPOINTS,+ child_endpoint=config.name,+ fanout=config.fanout,+ client_config=_client_config(api_token),+ path_format_values={},+ team_id=team_id,+ job_id=job_id,+ db_incremental_field_last_value=None,+ # Fulcrum wraps every list response in a root key, and both sides page the same way.+ parent_endpoint_extra={+ "data_selector": parent_config.data_key,+ "paginator": FulcrumPageNumberPaginator(per_page=parent_config.page_size),+ },+ child_endpoint_extra={+ "data_selector": config.data_key,+ "paginator": FulcrumPageNumberPaginator(per_page=config.page_size),+ },+ page_size_param="per_page",+ resume_hook=save_checkpoint,+ initial_paginator_state=initial_state,+ ),+ )++ return _source_response(config, lambda: dependent_resource)++def fulcrum_source(api_token: str,endpoint: str,@@ -143,13 +241,11 @@ def fulcrum_source() -> SourceResponse:config = FULCRUM_ENDPOINTS[endpoint]+ if config.fanout is not None:+ return _fanout_source(config, api_token, team_id, job_id, resumable_source_manager)+rest_config: RESTAPIConfig = {- "client": {- "base_url": FULCRUM_BASE_URL,- "headers": _accept_header(),- # X-ApiToken travels as an api_key header so its value is redacted from logs and errors.- "auth": {"type": "api_key", "api_key": api_token, "name": "X-ApiToken", "location": "header"},- },+ "client": _client_config(api_token),"resource_defaults": {},"resources": [{@@ -162,7 +258,7 @@ def fulcrum_source(initial_paginator_state: Optional[dict[str, Any]] = Noneif resumable_source_manager.can_resume():resume = resumable_source_manager.load_state()- if resume is not None:+ if resume is not None and resume.page is not None:initial_paginator_state = {"page": resume.page}def save_checkpoint(state: Optional[dict[str, Any]]) -> None:@@ -183,20 +279,7 @@ def fulcrum_source(initial_paginator_state=initial_paginator_state,)- return SourceResponse(- name=endpoint,- items=lambda: resource,- primary_keys=config.primary_keys,- # Records list defaults to updated_at ascending; full-refresh endpoints don't checkpoint a- # watermark, so ascending is a safe default for them too.- sort_mode="asc",- partition_count=1,- partition_size=1,- partition_mode="datetime" if config.partition_key else None,- partition_format="week" if config.partition_key else None,- partition_keys=[config.partition_key] if config.partition_key else None,- column_hints=resource.column_hints,- )+ return _source_response(config, lambda: resource, column_hints=resource.column_hints)def validate_credentials(api_token: str) -> bool:diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/fulcrum/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/fulcrum/settings.pyindex 31a595278ee5..8f7850fa7c57 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/fulcrum/settings.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/fulcrum/settings.py@@ -1,10 +1,13 @@from dataclasses import dataclass, field-from typing import Optional+from typing import Any, Literal, Optional+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.fanout import (+ DependentEndpointConfig,+)from products.warehouse_sources.backend.types import IncrementalField, IncrementalFieldType-@dataclass+@dataclass(frozen=True)class FulcrumEndpointConfig:name: strpath: str # e.g. "/records.json"@@ -12,19 +15,32 @@ class FulcrumEndpointConfig:primary_keys: list[str] = field(default_factory=lambda: ["id"])partition_key: Optional[str] = None # stable creation-time field for datetime partitioningincremental_fields: list[IncrementalField] = field(default_factory=list)- # Server-side `updated_since`-style time filter. Only records exposes one; everything- # else is full-refresh only.+ # Server-side `updated_since` time filter. Only records and audit_logs expose one;+ # everything else is full-refresh only.supports_incremental: bool = False+ # Order rows arrive in. Full-refresh endpoints checkpoint no watermark, so "asc" is a safe+ # default for them. "desc" makes the pipeline commit the watermark once at the end of the sync+ # instead of after every batch, which is what an endpoint with undocumented ordering needs.+ sort_mode: Literal["asc", "desc"] = "asc"+ # Extra static query params sent with every request to this endpoint.+ params: dict[str, Any] = field(default_factory=dict)+ # Set when the endpoint only exists under a parent resource and has to be fanned out.+ fanout: Optional[DependentEndpointConfig] = Nonepage_size: int = 1000 # Fulcrum caps per_page at 20000; keep pages small to bound memoryshould_sync_default: bool = True+ @property+ def default_incremental_field(self) -> Optional[str]:+ # Also satisfies the fan-out helper's FanoutEndpointLike protocol.+ return self.incremental_fields[0]["field"] if self.incremental_fields else None-def _updated_at_field() -> list[IncrementalField]:++def _datetime_field(name: str) -> list[IncrementalField]:return [{- "label": "updated_at",+ "label": name,"type": IncrementalFieldType.DateTime,- "field": "updated_at",+ "field": name,"field_type": IncrementalFieldType.DateTime,}]@@ -39,7 +55,7 @@ FULCRUM_ENDPOINTS: dict[str, FulcrumEndpointConfig] = {path="/records.json",data_key="records",partition_key="created_at",- incremental_fields=_updated_at_field(),+ incremental_fields=_datetime_field("updated_at"),supports_incremental=True,),# The resources below have no documented server-side time filter, so they're full refresh.@@ -90,6 +106,53 @@ FULCRUM_ENDPOINTS: dict[str, FulcrumEndpointConfig] = {data_key="webhooks",partition_key="created_at",),+ # Every version of every record. The history endpoint documents only `changeset_id` and+ # `deleted_form_id` filters — no time filter — so it is full refresh. Each row is one history+ # entry, identified by `history_id` and stamped with `history_created_at`.+ "records_history": FulcrumEndpointConfig(+ name="records_history",+ path="/records/history.json",+ data_key="records",+ primary_keys=["history_id"],+ partition_key="history_created_at",+ ),+ # Account-wide activity trail. `updated_since` is a genuine server-side filter (epoch seconds)+ # keyed off the entry's `time`, but the endpoint documents no ordering, so sort descending:+ # the watermark is then committed once the sync finishes rather than after each batch, which+ # is correct whichever order rows actually arrive in.+ "audit_logs": FulcrumEndpointConfig(+ name="audit_logs",+ path="/audit_logs.json",+ data_key="audit_logs",+ partition_key="time",+ incremental_fields=_datetime_field("time"),+ supports_incremental=True,+ sort_mode="desc",+ ),+ # Lookup resolving the group ids carried on memberships and projects. `associations=true` adds+ # the member/layer/project/form id arrays, so the group's contents come back on the same row.+ # Group objects carry no timestamps, so there is nothing stable to partition on.+ "groups": FulcrumEndpointConfig(+ name="groups",+ path="/groups.json",+ data_key="groups",+ params={"associations": "true"},+ ),+ # Form schema versions, needed to read records collected under an earlier definition. There is+ # no account-wide history list, so fan out over the forms endpoint.+ "form_history": FulcrumEndpointConfig(+ name="form_history",+ path="/forms/{form_id}/history.json",+ data_key="forms",+ primary_keys=["form_id", "version"],+ fanout=DependentEndpointConfig(+ parent_name="forms",+ resolve_param="form_id",+ resolve_field="id",+ include_from_parent=["id"],+ parent_field_renames={"id": "form_id"},+ ),+ ),# Media metadata list endpoints. The identifier is `access_key` (a UUID), not `id`."photos": FulcrumEndpointConfig(name="photos",diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/fulcrum/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/fulcrum/source.pyindex a3208156d716..db8d06fb61f0 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/fulcrum/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/fulcrum/source.py@@ -96,8 +96,9 @@ You can create an API token in your [Fulcrum account settings](https://web.fulcrforce_refresh: bool = False,api_version: str | None = None,) -> list[SourceSchema]:- # Only `records` carries incremental fields, so build_endpoint_schemas marks it (and only it)- # incremental + append and leaves the rest full-refresh — matching the per-endpoint config.+ # Only `records` and `audit_logs` carry incremental fields, so build_endpoint_schemas marks+ # those two incremental + append and leaves the rest full-refresh — matching the per-endpoint+ # config.return build_endpoint_schemas(ENDPOINTS, INCREMENTAL_FIELDS, names)def validate_credentials(diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/fulcrum/tests/test_fulcrum.py b/products/warehouse_sources/backend/temporal/data_imports/sources/fulcrum/tests/test_fulcrum.pyindex 77b08dacd670..00ddd1678dfd 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/fulcrum/tests/test_fulcrum.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/fulcrum/tests/test_fulcrum.py@@ -56,17 +56,20 @@ def _make_manager(resume_state: FulcrumResumeConfig | None = None) -> mock.Magicreturn manager-def _wire(session: mock.MagicMock, responses: list[Response]) -> list[dict[str, Any]]:+def _wire(session: mock.MagicMock, responses: list[Response], urls: list[str] | None = None) -> list[dict[str, Any]]:"""Wire a mock session and return a list capturing each request's params AT SEND TIME.``request.params`` is one dict mutated in place across pages, so inspecting it after the run- shows only the final state — snapshot a copy when each request is prepared instead.+ shows only the final state — snapshot a copy when each request is prepared instead. Pass+ ``urls`` to collect the requested URLs in the same order."""session.headers = {}param_snapshots: list[dict[str, Any]] = []def _prepare(request: Any) -> mock.MagicMock:param_snapshots.append(dict(request.params or {}))+ if urls is not None:+ urls.append(request.url)prepared = mock.MagicMock()prepared.url = request.urlreturn prepared@@ -101,14 +104,18 @@ class TestToEpochSeconds:class TestIncrementalParams:+ # Both endpoints filter through `updated_since`, but they key off different cursor fields+ # (records on updated_at, audit_logs on time), so the cursor comes from the endpoint config.+ @parameterized.expand(["records", "audit_logs"])@mock.patch(CLIENT_SESSION_PATCH)- def test_records_incremental_adds_updated_since(self, MockSession) -> None:+ def test_incremental_adds_updated_since(self, endpoint: str, MockSession) -> None:session = MockSession.return_value- params = _wire(session, [_response("records", [{"id": "1"}], total_pages=1, current_page=1)])+ config = FULCRUM_ENDPOINTS[endpoint]+ params = _wire(session, [_response(config.data_key, [{"id": "1"}], total_pages=1, current_page=1)])_rows(_source(- "records",+ endpoint,_make_manager(),should_use_incremental_field=True,db_incremental_field_last_value=datetime(2021, 1, 1, tzinfo=UTC),@@ -118,7 +125,7 @@ class TestIncrementalParams:# updated_since is the epoch-seconds cutoff; per_page and page ride alongside it.assert params[0]["updated_since"] == 1609459200assert params[0]["page"] == 1- assert params[0]["per_page"] == FULCRUM_ENDPOINTS["records"].page_size+ assert params[0]["per_page"] == config.page_size@mock.patch(CLIENT_SESSION_PATCH)def test_records_full_refresh_omits_filter(self, MockSession) -> None:@@ -136,7 +143,7 @@ class TestIncrementalParams:assert "updated_since" not in params[0]- @parameterized.expand(["forms", "projects", "photos"])+ @parameterized.expand(["forms", "projects", "photos", "records_history", "groups"])@mock.patch(CLIENT_SESSION_PATCH)def test_non_incremental_endpoints_never_filter(self, endpoint: str, MockSession) -> None:# A full-refresh endpoint must never send updated_since even when a watermark is present —@@ -320,3 +327,70 @@ class TestRetryAndErrors:with pytest.raises(HTTPError):_rows(_source("forms", _make_manager()))+++class TestStaticEndpointParams:+ @mock.patch(CLIENT_SESSION_PATCH)+ def test_groups_requests_associations(self, MockSession) -> None:+ # Without associations=true the group rows carry no member/layer/project/form ids, which is+ # the whole reason the table exists — so it must ride on every page, not just the first.+ session = MockSession.return_value+ params = _wire(+ session,+ [+ _response("groups", [{"id": "g1"}], total_pages=2, current_page=1),+ _response("groups", [{"id": "g2"}], total_pages=2, current_page=2),+ ],+ )++ _rows(_source("groups", _make_manager()))++ assert [p["associations"] for p in params] == ["true", "true"]+++class TestFormHistoryFanout:+ def _parent_page(self) -> Response:+ return _response("forms", [{"id": "f1"}, {"id": "f2"}], total_pages=1, current_page=1)++ def _child_page(self, form_id: str, version: int) -> Response:+ return _response("forms", [{"id": form_id, "version": version}], total_pages=1, current_page=1)++ @mock.patch(CLIENT_SESSION_PATCH)+ def test_fans_out_over_forms_and_tags_rows_with_form_id(self, MockSession) -> None:+ session = MockSession.return_value+ urls: list[str] = []+ _wire(session, [self._parent_page(), self._child_page("f1", 1), self._child_page("f2", 3)], urls=urls)++ rows = _rows(_source("form_history", _make_manager()))++ assert urls[1:] == [+ "https://api.fulcrumapp.com/api/v2/forms/f1/history.json",+ "https://api.fulcrumapp.com/api/v2/forms/f2/history.json",+ ]+ # The parent id is injected under form_id, which is half the table's primary key — a row+ # missing it would collide with every other form's version of the same number.+ assert [(r["form_id"], r["version"]) for r in rows] == [("f1", 1), ("f2", 3)]++ @mock.patch(CLIENT_SESSION_PATCH)+ def test_checkpoints_each_finished_parent(self, MockSession) -> None:+ session = MockSession.return_value+ _wire(session, [self._parent_page(), self._child_page("f1", 1), self._child_page("f2", 3)])++ manager = _make_manager()+ _rows(_source("form_history", manager))++ completed = [call.args[0].completed for call in manager.save_state.call_args_list]+ assert completed[-1] == ["/forms/f1/history.json", "/forms/f2/history.json"]++ @mock.patch(CLIENT_SESSION_PATCH)+ def test_resume_skips_completed_parents(self, MockSession) -> None:+ # The parent listing is always re-fetched; only the child fetches are skipped.+ session = MockSession.return_value+ urls: list[str] = []+ _wire(session, [self._parent_page(), self._child_page("f2", 3)], urls=urls)++ manager = _make_manager(FulcrumResumeConfig(completed=["/forms/f1/history.json"]))+ rows = _rows(_source("form_history", manager))++ assert urls[1:] == ["https://api.fulcrumapp.com/api/v2/forms/f2/history.json"]+ assert [r["form_id"] for r in rows] == ["f2"]