From d8783f2241b89b57c8eb1fc4b76fbd443533bf93 Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Sun, 15 Nov 2026 18:02:51 +0100 Subject: [PATCH 1/2] fix: preserve the compliance adapter retry delay defaults --- .changeset/goofy-rats-travel.md | 5 +++++ .github/workflows/sdk-compliance.yml | 4 ++-- sdk_compliance_adapter/README.md | 13 ++++++++----- sdk_compliance_adapter/adapter.php | 6 ++++-- sdk_compliance_adapter/check_report.py | 2 +- sdk_compliance_adapter/docker-compose.yml | 2 +- sdk_compliance_adapter/test_server.py | 19 +++++++++++++++++++ 7 files changed, 40 insertions(+), 11 deletions(-) create mode 100644 .changeset/goofy-rats-travel.md diff --git a/.changeset/goofy-rats-travel.md b/.changeset/goofy-rats-travel.md new file mode 100644 index 00000000..66a332d3 --- /dev/null +++ b/.changeset/goofy-rats-travel.md @@ -0,0 +1,5 @@ +--- +"posthog-php": none +--- + +Upgrade the compliance harness to 1.31.1 and preserve the SDK's default Retry-After ceiling when no retry count is configured. diff --git a/.github/workflows/sdk-compliance.yml b/.github/workflows/sdk-compliance.yml index 7ff30a50..bf8d147f 100644 --- a/.github/workflows/sdk-compliance.yml +++ b/.github/workflows/sdk-compliance.yml @@ -24,11 +24,11 @@ jobs: dockerfile: sdk_compliance_adapter/Dockerfile.socket - consumer: fork_curl dockerfile: sdk_compliance_adapter/Dockerfile.fork_curl - uses: PostHog/posthog-sdk-test-harness/.github/workflows/test-sdk-action.yml@75fb00092c6045daef60c30acc10ac83afefbfe9 + uses: PostHog/posthog-sdk-test-harness/.github/workflows/test-sdk-action.yml@003d4162421193b458bbaa93fbb7bb0d0104bc3b with: adapter-dockerfile: ${{ matrix.dockerfile }} adapter-context: "." - test-harness-version: "1.0.0" + test-harness-version: "1.31.1" report-name: sdk-compliance-${{ matrix.consumer }} sdk-type: server concurrency: 1 diff --git a/sdk_compliance_adapter/README.md b/sdk_compliance_adapter/README.md index c0b3ebcb..457427e1 100644 --- a/sdk_compliance_adapter/README.md +++ b/sdk_compliance_adapter/README.md @@ -1,7 +1,7 @@ # PostHog PHP SDK compliance adapter The adapter runs the repository's `PostHog\Client` with production capture consumers -and production `HttpClient` feature-flag requests. Harness 1.0.0 selects **30 server +and production `HttpClient` feature-flag requests. Harness 1.31.1 selects **30 server capture V0 tests and 17 flag tests per profile**, including UTC timestamp overrides and gzip. No tests are filtered; compliance assertions remain advisory in CI. @@ -15,7 +15,7 @@ and gzip. No tests are filtered; compliance assertions remain advisory in CI. CI runs all three profiles with distinct report artifacts. An independent `report-completeness` job checks each artifact against `expected_inventory.json` -(the harness 1.0.0 server V0 and flags IDs). Missing, empty, incomplete, duplicate, +(the harness 1.31.1 server V0 and flags IDs). Missing, empty, incomplete, duplicate, or unexpected results and inconsistent summary counts fail this gate. Complete reports with failing assertions still pass the inventory gate; SDK compliance assertions remain advisory. The checker reads the pinned harness's Markdown result @@ -28,9 +28,12 @@ uncompressed HTTP client even when capture compression is enabled. The adapter maps `flush_at` to `batch_size` and `flush_interval_ms` to `flush_interval_seconds` (SDK default: 5 seconds, enforced on enqueue, not an idle -timer). `max_retries` maps to the existing backoff-duration option: for three -retries, 801 ms for HttpClient and 800 ms for Socket and foreground ForkCurl, -reflecting their different limit checks. Socket's connection +timer). When `max_retries` is omitted, the SDK's native 10000 ms maximum +backoff duration is preserved, including for Retry-After. An explicit `max_retries` +maps to the existing backoff-duration option: for three retries, 801 ms for +HttpClient and 800 ms for Socket and foreground ForkCurl, reflecting their different +limit checks. This mapping also caps Retry-After at that duration; the SDK has no +independent ingestion retry-count option. Socket's connection timeout is expressed in seconds; the PHP worker's `default_socket_timeout=1` bounds reads, including idle retry connections. This is a configured runtime profile, not certification of default PHP socket timing. diff --git a/sdk_compliance_adapter/adapter.php b/sdk_compliance_adapter/adapter.php index 7ff04859..fcba536a 100644 --- a/sdk_compliance_adapter/adapter.php +++ b/sdk_compliance_adapter/adapter.php @@ -89,7 +89,6 @@ function handleRequest(array $request, AdapterState $state): array [$normalizedHost, $useSsl] = normalizeHost($host); $flushAt = max(1, (int) ($data['flush_at'] ?? 100)); $flushIntervalMs = max(0, (int) ($data['flush_interval_ms'] ?? 5000)); - $maxRetries = max(0, (int) ($data['max_retries'] ?? 3)); $enableCompression = (bool) ($data['enable_compression'] ?? false); $timeoutMs = max(1000, (int) ($data['timeout_ms'] ?? 10000)); @@ -98,7 +97,10 @@ function handleRequest(array $request, AdapterState $state): array throw new InvalidArgumentException('Unsupported consumer: ' . $consumer); } - $maximumBackoffDuration = maxBackoffDurationForRetries($maxRetries, $consumer); + // Do not lower the SDK's native Retry-After ceiling when no retry count was requested. + $maximumBackoffDuration = isset($data['max_retries']) + ? maxBackoffDurationForRetries(max(0, (int) $data['max_retries']), $consumer) + : 10000; $state->client = new Client($apiKey, [ 'host' => $normalizedHost, 'ssl' => $useSsl, diff --git a/sdk_compliance_adapter/check_report.py b/sdk_compliance_adapter/check_report.py index a6946687..0f2bfbb3 100644 --- a/sdk_compliance_adapter/check_report.py +++ b/sdk_compliance_adapter/check_report.py @@ -1,4 +1,4 @@ -"""Check inventory completeness in harness 1.0.0 Markdown; assertions stay advisory.""" +"""Check inventory completeness in harness 1.31.1 Markdown; assertions stay advisory.""" import argparse import json diff --git a/sdk_compliance_adapter/docker-compose.yml b/sdk_compliance_adapter/docker-compose.yml index f8b396db..8c5c6847 100644 --- a/sdk_compliance_adapter/docker-compose.yml +++ b/sdk_compliance_adapter/docker-compose.yml @@ -11,7 +11,7 @@ services: - test-network test-harness: - image: ghcr.io/posthog/sdk-test-harness:1.0.0 + image: ghcr.io/posthog/sdk-test-harness:1.31.1 command: ["run", "--adapter-url", "http://sdk-adapter:8080", "--mock-url", "http://test-harness:8081"] networks: - test-network diff --git a/sdk_compliance_adapter/test_server.py b/sdk_compliance_adapter/test_server.py index 8324af87..497d489b 100644 --- a/sdk_compliance_adapter/test_server.py +++ b/sdk_compliance_adapter/test_server.py @@ -5,6 +5,7 @@ import os import socket import threading +import time import unittest from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer from unittest.mock import patch @@ -20,10 +21,13 @@ class MockHandler(BaseHTTPRequestHandler): def do_POST(self): body = self.rfile.read(int(self.headers["Content-Length"])) self.server.requests.append((self.path, dict(self.headers), body)) + self.server.request_times.append(time.monotonic()) status = self.server.statuses.pop(0) if self.server.statuses else 200 response = b'{"featureFlags":{"test-flag":"variant-a"}}' if "/flags/" in self.path else b'{}' self.send_response(status) self.send_header("Content-Length", str(len(response))) + for name, value in self.server.response_headers.items(): + self.send_header(name, value) self.end_headers() self.wfile.write(response) @@ -39,7 +43,9 @@ def setUp(self): self.mock = ThreadingHTTPServer(("127.0.0.1", MOCK_PORT), MockHandler) self.addCleanup(self.mock.server_close) self.mock.requests = [] + self.mock.request_times = [] self.mock.statuses = [] + self.mock.response_headers = {} self.thread = threading.Thread(target=self.mock.serve_forever, daemon=True) self.thread.start() self.addCleanup(self.thread.join) @@ -55,7 +61,9 @@ def call(self, path, data=None): def init(self, consumer="lib_curl", **options): os.environ["POSTHOG_CONSUMER"] = consumer self.mock.requests.clear() + self.mock.request_times.clear() self.mock.statuses.clear() + self.mock.response_headers.clear() self.call("/init", {"host": f"http://127.0.0.1:{self.mock.server_address[1]}", "api_key": "phc_local_test", **options}) @@ -129,6 +137,17 @@ def test_production_retry_attempts_are_observed(self): self.assertTrue(all(r["uuid_list"] == [captured["uuid"]] for r in requests)) self.assertTrue(all(r[2] == self.mock.requests[0][2] for r in self.mock.requests)) + def test_default_backoff_honors_retry_after(self): + for consumer in ("lib_curl", "socket", "fork_curl"): + with self.subTest(consumer=consumer): + self.init(consumer) + self.mock.statuses = [429, 200] + self.mock.response_headers = {"Retry-After": "3"} + self.capture() + self.assertTrue(self.call("/flush", {})["success"]) + self.assertEqual(len(self.mock.requests), 2) + self.assertGreaterEqual(self.mock.request_times[1] - self.mock.request_times[0], 2.5) + def test_terminal_response_exposes_sdk_boolean_not_observer_success(self): for consumer in ("lib_curl", "socket", "fork_curl"): with self.subTest(consumer=consumer): From 5b86c69b8adff6803fbf363114bec9105098ac2c Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Tue, 17 Nov 2026 10:47:06 +0100 Subject: [PATCH 2/2] ci: use SDK harness 1.32.0 without a release intent --- .changeset/goofy-rats-travel.md | 5 ----- .github/workflows/sdk-compliance.yml | 4 ++-- sdk_compliance_adapter/README.md | 4 ++-- sdk_compliance_adapter/check_report.py | 2 +- sdk_compliance_adapter/docker-compose.yml | 2 +- 5 files changed, 6 insertions(+), 11 deletions(-) delete mode 100644 .changeset/goofy-rats-travel.md diff --git a/.changeset/goofy-rats-travel.md b/.changeset/goofy-rats-travel.md deleted file mode 100644 index 66a332d3..00000000 --- a/.changeset/goofy-rats-travel.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"posthog-php": none ---- - -Upgrade the compliance harness to 1.31.1 and preserve the SDK's default Retry-After ceiling when no retry count is configured. diff --git a/.github/workflows/sdk-compliance.yml b/.github/workflows/sdk-compliance.yml index bf8d147f..388c5eac 100644 --- a/.github/workflows/sdk-compliance.yml +++ b/.github/workflows/sdk-compliance.yml @@ -24,11 +24,11 @@ jobs: dockerfile: sdk_compliance_adapter/Dockerfile.socket - consumer: fork_curl dockerfile: sdk_compliance_adapter/Dockerfile.fork_curl - uses: PostHog/posthog-sdk-test-harness/.github/workflows/test-sdk-action.yml@003d4162421193b458bbaa93fbb7bb0d0104bc3b + uses: PostHog/posthog-sdk-test-harness/.github/workflows/test-sdk-action.yml@dde638562d33572b5c8ac3a2eafc98b92ffa2261 with: adapter-dockerfile: ${{ matrix.dockerfile }} adapter-context: "." - test-harness-version: "1.31.1" + test-harness-version: "1.32.0" report-name: sdk-compliance-${{ matrix.consumer }} sdk-type: server concurrency: 1 diff --git a/sdk_compliance_adapter/README.md b/sdk_compliance_adapter/README.md index 457427e1..72dab5d4 100644 --- a/sdk_compliance_adapter/README.md +++ b/sdk_compliance_adapter/README.md @@ -1,7 +1,7 @@ # PostHog PHP SDK compliance adapter The adapter runs the repository's `PostHog\Client` with production capture consumers -and production `HttpClient` feature-flag requests. Harness 1.31.1 selects **30 server +and production `HttpClient` feature-flag requests. Harness 1.32.0 selects **30 server capture V0 tests and 17 flag tests per profile**, including UTC timestamp overrides and gzip. No tests are filtered; compliance assertions remain advisory in CI. @@ -15,7 +15,7 @@ and gzip. No tests are filtered; compliance assertions remain advisory in CI. CI runs all three profiles with distinct report artifacts. An independent `report-completeness` job checks each artifact against `expected_inventory.json` -(the harness 1.31.1 server V0 and flags IDs). Missing, empty, incomplete, duplicate, +(the harness 1.32.0 server V0 and flags IDs). Missing, empty, incomplete, duplicate, or unexpected results and inconsistent summary counts fail this gate. Complete reports with failing assertions still pass the inventory gate; SDK compliance assertions remain advisory. The checker reads the pinned harness's Markdown result diff --git a/sdk_compliance_adapter/check_report.py b/sdk_compliance_adapter/check_report.py index 0f2bfbb3..2e181c24 100644 --- a/sdk_compliance_adapter/check_report.py +++ b/sdk_compliance_adapter/check_report.py @@ -1,4 +1,4 @@ -"""Check inventory completeness in harness 1.31.1 Markdown; assertions stay advisory.""" +"""Check inventory completeness in harness 1.32.0 Markdown; assertions stay advisory.""" import argparse import json diff --git a/sdk_compliance_adapter/docker-compose.yml b/sdk_compliance_adapter/docker-compose.yml index 8c5c6847..1c31d9c4 100644 --- a/sdk_compliance_adapter/docker-compose.yml +++ b/sdk_compliance_adapter/docker-compose.yml @@ -11,7 +11,7 @@ services: - test-network test-harness: - image: ghcr.io/posthog/sdk-test-harness:1.31.1 + image: ghcr.io/posthog/sdk-test-harness:1.32.0 command: ["run", "--adapter-url", "http://sdk-adapter:8080", "--mock-url", "http://test-harness:8081"] networks: - test-network