: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
chore(dev): drop localstack from the dev stack (#81257)
Raúl Negrón-Otero8c2d6e375309
diff --git a/.github/workflows/ci-nodejs.yml b/.github/workflows/ci-nodejs.ymlindex fc7c5ac6f4cf..ebc0e939227b 100644--- a/.github/workflows/ci-nodejs.yml+++ b/.github/workflows/ci-nodejs.yml@@ -303,7 +303,7 @@ jobs:- name: Stop/Start stack with Docker Composeenv:COMPOSE_FILE: docker-compose.dev.yml:docker-compose.profiles.yml- COMPOSE_PROFILES: dev_tools,localstack+ COMPOSE_PROFILES: dev_tools,dynamodbWAIT_FOR_DOCKER_LAUNCH_RETRIES: 3WAIT_FOR_DOCKER_LAUNCH_RETRY_DELAY: 5run: |@@ -312,7 +312,7 @@ jobs:- name: Wait for Docker servicesenv:COMPOSE_FILE: docker-compose.dev.yml:docker-compose.profiles.yml- COMPOSE_PROFILES: dev_tools,localstack+ COMPOSE_PROFILES: dev_tools,dynamodbrun: bin/ci-wait-for-docker wait- name: Add service hostnames to /etc/hosts@@ -385,11 +385,13 @@ jobs:install-command: pnpm --filter=@posthog/nodejs... install --frozen-lockfiletoken: ${{ steps.setup-gh-token.outputs.token || github.token }}- - name: Wait for Clickhouse, Redis, Kafka, Localstack, SeaweedFS+ - name: Wait for Clickhouse, Redis, Kafka, DynamoDB, SeaweedFS# seaweedfs backs the blob-store integration tests; the profile-scoped# stack launch above never starts it (it sits in the replay/agents# profiles), so start it explicitly here — no profiles overlay in play.- run: docker compose -f docker-compose.dev.yml up kafka redis7 valkey-cluster clickhouse maildev localstack seaweedfs -d --wait+ # objectstorage starts by default but is listed so --wait blocks on its+ # bootstrap sentinel: it returns InvalidAccessKeyId until that finishes.+ run: docker compose -f docker-compose.dev.yml up kafka redis7 valkey-cluster clickhouse maildev dynamodb objectstorage seaweedfs -d --wait- name: Create Kafka topicsrun: docker compose -f docker-compose.dev.yml up kafka-init@@ -478,8 +480,6 @@ jobs:SHARD_INDEX: ${{ matrix.shard }}SHARD_COUNT: 3LOG_LEVEL: info- # Enable localstack integration tests for DynamoDB/KMS- LOCALSTACK_ENABLED: '1'# Emit JUnit XML for the Trunk upload below (turbo passes JEST_JUNIT_* through).JEST_JUNIT_OUTPUT_DIR: ${{ github.workspace }}/junit-resultsJEST_JUNIT_OUTPUT_NAME: junit-nodejs-${{ matrix.shard }}.xml@@ -576,7 +576,7 @@ jobs:- name: Stop/Start stack with Docker Composeenv:COMPOSE_FILE: docker-compose.dev.yml:docker-compose.profiles.yml- COMPOSE_PROFILES: dev_tools,localstack+ COMPOSE_PROFILES: dev_toolsWAIT_FOR_DOCKER_LAUNCH_RETRIES: 3WAIT_FOR_DOCKER_LAUNCH_RETRY_DELAY: 5run: |@@ -585,7 +585,7 @@ jobs:- name: Wait for Docker servicesenv:COMPOSE_FILE: docker-compose.dev.yml:docker-compose.profiles.yml- COMPOSE_PROFILES: dev_tools,localstack+ COMPOSE_PROFILES: dev_toolsrun: bin/ci-wait-for-docker wait- name: Add service hostnames to /etc/hosts@@ -658,8 +658,8 @@ jobs:install-command: pnpm --filter=@posthog/nodejs... install --frozen-lockfiletoken: ${{ steps.setup-gh-token.outputs.token || github.token }}- - name: Wait for Clickhouse, Redis, Kafka, Localstack- run: docker compose -f docker-compose.dev.yml up kafka redis7 clickhouse maildev localstack -d --wait+ - name: Wait for Clickhouse, Redis, Kafka+ run: docker compose -f docker-compose.dev.yml up kafka redis7 clickhouse maildev -d --wait- name: Create Kafka topicsrun: docker compose -f docker-compose.dev.yml up kafka-initdiff --git a/bin/mprocs.yaml b/bin/mprocs.yamlindex fd12d036df00..8577b3fd72fe 100755--- a/bin/mprocs.yaml+++ b/bin/mprocs.yaml@@ -243,7 +243,7 @@ procs:# tools/hogli-commands/hogli_commands/devenv/generator.py. Edit it there and run# `hogli dev:regenerate-mprocs`; CI pre-flight fails if the two drift apart.docker-compose:- shell: 'if [ "${POSTHOG_SANDBOX:-}" = "1" ]; then echo "Sandbox: infra managed by docker compose externally" && echo "docker-compose ready" && sleep infinity; else docker compose -p posthog -f docker-compose.dev.yml -f docker-compose.profiles.yml --profile dev_tools --profile etcd --profile localstack --profile observability --profile replay --profile temporal up --pull always -d || { echo "docker compose up failed (see the error above). A common cause: another stack or process holding a required port (see the pre-flight output from bin/start). Inspect with: docker ps --all"; exit 1; } && echo "docker-compose ready" && docker compose -p posthog -f docker-compose.dev.yml -f docker-compose.profiles.yml --profile dev_tools --profile etcd --profile localstack --profile observability --profile replay --profile temporal logs --tail=100 -f; fi'+ shell: 'if [ "${POSTHOG_SANDBOX:-}" = "1" ]; then echo "Sandbox: infra managed by docker compose externally" && echo "docker-compose ready" && sleep infinity; else docker compose -p posthog -f docker-compose.dev.yml -f docker-compose.profiles.yml --profile dev_tools --profile dynamodb --profile etcd --profile observability --profile replay --profile temporal up --pull always -d || { echo "docker compose up failed (see the error above). A common cause: another stack or process holding a required port (see the pre-flight output from bin/start). Inspect with: docker ps --all"; exit 1; } && echo "docker-compose ready" && docker compose -p posthog -f docker-compose.dev.yml -f docker-compose.profiles.yml --profile dev_tools --profile dynamodb --profile etcd --profile observability --profile replay --profile temporal logs --tail=100 -f; fi'capability: core_infraready_pattern: 'docker-compose ready'groups:diff --git a/devenv/intent-map.yaml b/devenv/intent-map.yamlindex 9c164dcde0db..f276e3a0ffc2 100644--- a/devenv/intent-map.yaml+++ b/devenv/intent-map.yaml@@ -154,7 +154,7 @@ capabilities:nodejs_session_replay:description: 'Node.js Session Replay - recording ingestion'requires: [event_ingestion]- docker_profiles: [replay]+ docker_profiles: [replay, dynamodb]nodejs_logs:description: 'Node.js Logs - log ingestion'diff --git a/devenv/news.txt b/devenv/news.txtindex 90a52bd50fd8..666f1ad3273d 100644--- a/devenv/news.txt+++ b/devenv/news.txt@@ -1,3 +1,6 @@+2026-08-12+localstack is gone (its license stopped being free); if you still have a localstack-main container, run docker rm -f localstack-main to clear it+2026-07-02send feedback to the devex team (humans and agents): hogli devex:feedback "..."diff --git a/docker-compose.base.yml b/docker-compose.base.ymlindex a2562084b183..e501f3893097 100644--- a/docker-compose.base.yml+++ b/docker-compose.base.yml@@ -814,12 +814,26 @@ services:networks:- otel_network- localstack:- image: localstack/localstack:4.12.0- environment:- - DEBUG=${DEBUG:-0}- volumes:- - '/var/run/docker.sock:/var/run/docker.sock'+ dynamodb:+ # Session recording encryption keys live in DynamoDB on Cloud (see getKeyStore in+ # nodejs/src/ingestion/pipelines/sessionreplay/shared/keystore), so the keystore+ # integration test needs a real DynamoDB API to exercise its composite key and+ # conditional writes. -inMemory holds the tables in the JVM rather than in a file inside+ # the container, so a restart cannot resurrect a table from an interrupted run. -sharedDb+ # puts every credential and region pair in one table namespace; without it a client using+ # different credentials than the one that created a table sees an empty table list, which+ # -inMemory alone does not prevent. -disableTelemetry stops it reporting usage to AWS in+ # the background, which it does by default.+ image: amazon/dynamodb-local:3.3.1+ command: ['-jar', 'DynamoDBLocal.jar', '-inMemory', '-sharedDb', '-disableTelemetry']+ healthcheck:+ # Opening the port from bash rather than curling it, because DynamoDB answers GET /+ # with a 400 and `curl -f` treats that as failure. Without a healthcheck,+ # `docker compose up --wait` returns as soon as the JVM starts, before it listens.+ test: ['CMD-SHELL', 'exec 3<>/dev/tcp/localhost/8000']+ interval: 5s+ timeout: 3s+ retries: 12seaweedfs:# Default open-access mode; see the `objectstorage` service above for rationalediff --git a/docker-compose.dev-full.yml b/docker-compose.dev-full.ymlindex 939502fadf88..c0c6b6b10a06 100644--- a/docker-compose.dev-full.yml+++ b/docker-compose.dev-full.yml@@ -279,10 +279,10 @@ services:file: docker-compose.base.ymlservice: jaeger- localstack:+ dynamodb:extends:file: docker-compose.base.yml- service: localstack+ service: dynamodbnetworks:otel_network:diff --git a/docker-compose.dev.yml b/docker-compose.dev.ymlindex fb31c1849a65..66a0ded4ade5 100644--- a/docker-compose.dev.yml+++ b/docker-compose.dev.yml@@ -786,14 +786,16 @@ services:- '14268:14268' # jaeger.thrift- '14250:14250' # model.proto- localstack:+ dynamodb:extends:file: docker-compose.base.yml- service: localstack- container_name: '${LOCALSTACK_DOCKER_NAME:-localstack-main}'+ service: dynamodb+ profiles: [dynamodb]+ container_name: '${DYNAMODB_DOCKER_NAME:-dynamodb-main}'ports:- - '127.0.0.1:4566:4566' # LocalStack Gateway- - '127.0.0.1:4510-4559:4510-4559' # external services port range+ # Not 8000 (the Django dev server) and not 18000, which the eval harness binds for its+ # live server, where sharing the port fails `hogli evals` on Linux with the stack up.+ - '127.0.0.1:18010:8000'seaweedfs:extends:diff --git a/docker-compose.profiles.yml b/docker-compose.profiles.ymlindex 6422bf4318c0..095383d24494 100644--- a/docker-compose.profiles.yml+++ b/docker-compose.profiles.yml@@ -49,8 +49,6 @@ services:profiles: [replay]# Cloud provider emulators- localstack:- profiles: [localstack]objectstorage-azure:profiles: [azure]diff --git a/docker-compose.sandbox.yml b/docker-compose.sandbox.ymlindex b79f3a1a5b6c..678b1d0b26e5 100644--- a/docker-compose.sandbox.yml+++ b/docker-compose.sandbox.yml@@ -457,10 +457,11 @@ services:timeout: 5sretries: 10- localstack:+ dynamodb:extends:file: docker-compose.base.yml- service: localstack+ service: dynamodb+ profiles: [dynamodb]restart: on-failure# No host ports — avoid conflicts between sandboxesdiff --git a/nodejs/package.json b/nodejs/package.jsonindex cd8b57718d83..93336cad5828 100644--- a/nodejs/package.json+++ b/nodejs/package.json@@ -30,14 +30,14 @@"prepublishOnly": "pnpm build","setup:dev:clickhouse": "cd .. && DEBUG=1 python manage.py migrate_clickhouse","setup:test": "cd .. && TEST=1 python manage.py setup_test_environment && cd nodejs && pnpm run setup:test:rust",- "test:full": "docker compose -f ../docker-compose.dev.yml up -d && pnpm setup:test && pnpm test && pnpm test:postgres-parity && pnpm test:rust-ingestion-e2e",+ "test:full": "docker compose -f ../docker-compose.dev.yml --profile dynamodb up -d && pnpm setup:test && pnpm test && pnpm test:postgres-parity && pnpm test:rust-ingestion-e2e","setup:test:rust": "CYCLOTRON_NODE_DATABASE_NAME=test_cyclotron_node PERSONS_DATABASE_NAME=test_persons BEHAVIORAL_COHORTS_DATABASE_NAME=test_behavioral_cohorts ../rust/bin/migrate-entry all --fresh","setup:test:persons-parity": "PERSONS_DATABASE_NAME=test_persons_parity ../rust/bin/migrate-entry persons --fresh","migrate:persons": "../rust/bin/migrate-persons","migrate:cyclotron-node": "../rust/bin/migrate-cyclotron-node","migrate:behavioral-cohorts": "../rust/bin/migrate-behavioral-cohorts","migrate:rust": "../rust/bin/migrate-entry all",- "services:start": "cd .. && docker compose -f docker-compose.dev.yml up",+ "services:start": "cd .. && docker compose -f docker-compose.dev.yml --profile dynamodb up","services:stop": "cd .. && docker compose -f docker-compose.dev.yml down","services:clean": "cd .. && docker compose -f docker-compose.dev.yml rm -v","services": "pnpm services:stop && pnpm services:clean && pnpm services:start",diff --git a/nodejs/src/ingestion/pipelines/sessionreplay/README.md b/nodejs/src/ingestion/pipelines/sessionreplay/README.mdindex 3a1029fbe429..0b6e3f6398a9 100644--- a/nodejs/src/ingestion/pipelines/sessionreplay/README.md+++ b/nodejs/src/ingestion/pipelines/sessionreplay/README.md@@ -28,10 +28,10 @@ The `SessionRecordingIngester` consumes session recording events from Kafka and:hogli dev:setup```- Or manually:+ Or manually, with the profile that carries the DynamoDB the keystore tests need:```bash- docker compose -f docker-compose.dev.yml up+ docker compose -f docker-compose.dev.yml --profile dynamodb up```2. Set up the test database (creates test_posthog DB and runs migrations):diff --git a/nodejs/src/ingestion/pipelines/sessionreplay/shared/keystore/index.test.ts b/nodejs/src/ingestion/pipelines/sessionreplay/shared/keystore/index.test.tsindex 996f4c90e26d..ff4789126a2e 100644--- a/nodejs/src/ingestion/pipelines/sessionreplay/shared/keystore/index.test.ts+++ b/nodejs/src/ingestion/pipelines/sessionreplay/shared/keystore/index.test.ts@@ -30,8 +30,8 @@ describe('getKeyStore', () => {;(envUtils.isCloud as jest.Mock).mockReturnValue(true)const keyStore = getKeyStore('us-east-1', {- kmsEndpoint: 'http://localhost:4566',- dynamoDBEndpoint: 'http://localhost:4566',+ kmsEndpoint: 'http://kms.test',+ dynamoDBEndpoint: 'http://dynamodb.test',})expect(keyStore).toBeInstanceOf(DynamoDBKeyStore)diff --git a/nodejs/src/session-replay/recording-api/recording-api.test.ts b/nodejs/src/session-replay/recording-api/recording-api.test.tsindex 747eab56e968..84ee7b07cbab 100644--- a/nodejs/src/session-replay/recording-api/recording-api.test.ts+++ b/nodejs/src/session-replay/recording-api/recording-api.test.ts@@ -151,14 +151,14 @@ describe('RecordingApi', () => {})it('should configure forcePathStyle when endpoint is specified', async () => {- mockConfig.SESSION_RECORDING_V2_S3_ENDPOINT = 'http://localhost:4566'+ mockConfig.SESSION_RECORDING_V2_S3_ENDPOINT = 'http://s3.test'const recordingApi = new RecordingApi(mockConfig as RecordingApiConfig, mockPostgres, mockOutputs)await recordingApi.start()expect(S3Client).toHaveBeenCalledWith({region: 'us-west-2',- endpoint: 'http://localhost:4566',+ endpoint: 'http://s3.test',forcePathStyle: true,})})diff --git a/nodejs/tests/session-replay/recording-api/recording-api.integration.test.ts b/nodejs/tests/session-replay/recording-api/recording-api.integration.test.tsindex e7958627188f..160b0274ef35 100644--- a/nodejs/tests/session-replay/recording-api/recording-api.integration.test.ts+++ b/nodejs/tests/session-replay/recording-api/recording-api.integration.test.ts@@ -6,15 +6,14 @@* 2. Decrypting block data* 3. Handling deleted sessions (crypto shredding)* 4. HTTP endpoints via supertest- * 5. S3 + decryption pipeline via localstack+ * 5. S3 + decryption pipeline* 6. Cache invalidation on delete*- * Includes tests with:- * - MemoryKeyStore (always run)- * - DynamoDB/KMS/S3 via Localstack (run by default, skip with LOCALSTACK_DISABLED=1)- *- * To skip localstack tests (e.g. when localstack isn't running):- * LOCALSTACK_DISABLED=1 pnpm jest src/session-replay/recording-api/recording-api.integration.test.ts+ * The encryption contract runs against MemoryKeyStore and always runs. The DynamoDBKeyStore+ * block covers what only a real DynamoDB can show: the composite key, the conditional writes,+ * and the tombstones behind crypto shredding. It needs the dynamodb and objectstorage services+ * from the dev stack, so it skips with:+ * DYNAMODB_TESTS_DISABLED=1 pnpm jest tests/session-replay/recording-api/recording-api.integration.test.ts*/import {CreateTableCommand,@@ -23,21 +22,8 @@ import {DynamoDBClient,ResourceNotFoundException,} from '@aws-sdk/client-dynamodb'-import {- CreateAliasCommand,- CreateKeyCommand,- DeleteAliasCommand,- DescribeKeyCommand,- KMSClient,-} from '@aws-sdk/client-kms'-import {- CreateBucketCommand,- DeleteBucketCommand,- DeleteObjectCommand,- ListObjectsV2Command,- PutObjectCommand,- S3Client,-} from '@aws-sdk/client-s3'+import { KMSClient } from '@aws-sdk/client-kms'+import { DeleteObjectCommand, ListObjectsV2Command, PutObjectCommand, S3Client } from '@aws-sdk/client-s3'import { Server } from 'http'import sodium from 'libsodium-wrappers'import snappy from 'snappy'@@ -57,16 +43,21 @@ import { RecordingApi } from '~/session-replay/recording-api/recording-api'import { RecordingService } from '~/session-replay/recording-api/recording-service'import { KeyStore, RecordingApiConfig, SessionKey, SessionKeyDeletedError } from '~/session-replay/recording-api/types'+import { createStubKmsClient } from './stub-kms-client'+const mockOutputs = {queueMessages: jest.fn().mockResolvedValue(undefined),produce: jest.fn().mockResolvedValue(undefined),} as unknown as IngestionOutputs<ReplayEventsOutput | SessionFeaturesOutput>-// Localstack configuration-const LOCALSTACK_ENDPOINT = 'http://localhost:4566'+// Dev-stack services backing the DynamoDBKeyStore block+const DYNAMODB_ENDPOINT = 'http://127.0.0.1:18010'+const S3_ENDPOINT = 'http://127.0.0.1:19000'+const S3_BUCKET = 'posthog'+const S3_PREFIX = 'session_recordings_recording_api_test'+const S3_CREDENTIALS = { accessKeyId: 'object_storage_root_user', secretAccessKey: 'object_storage_root_password' }const KEYS_TABLE_NAME = 'session-recording-keys'-const KMS_KEY_ALIAS = 'alias/session-replay-master-key'-const shouldRunLocalstackTests = process.env.LOCALSTACK_DISABLED !== '1'+const shouldRunDynamoDBTests = process.env.DYNAMODB_TESTS_DISABLED !== '1'const isResourceNotFoundException = (error: unknown): boolean => {return (@@ -449,51 +440,21 @@ describe('Recording API encryption integration', () => {})})- // Tests with DynamoDB/KMS via Localstack (run when LOCALSTACK_ENABLED=1)- const describeLocalstack = shouldRunLocalstackTests ? describe : describe.skip+ const describeDynamoDB = shouldRunDynamoDBTests ? describe : describe.skip- describeLocalstack('with Localstack (DynamoDB + KMS)', () => {+ describeDynamoDB('with DynamoDBKeyStore', () => {let dynamoDBClient: DynamoDBClientlet kmsClient: KMSClient- let kmsKeyId: stringlet keyStore: DynamoDBKeyStorelet encryptor: SodiumRecordingEncryptorlet decryptor: SodiumRecordingDecryptor- async function setupKmsKey(): Promise<void> {- try {- const describeResult = await kmsClient.send(new DescribeKeyCommand({ KeyId: KMS_KEY_ALIAS }))- if (describeResult.KeyMetadata?.KeyId) {- kmsKeyId = describeResult.KeyMetadata.KeyId- return- }- } catch {- // Alias doesn't exist, create key and alias- }-- const createKeyResult = await kmsClient.send(- new CreateKeyCommand({- Description: 'Session replay master key for testing',- KeyUsage: 'ENCRYPT_DECRYPT',- })- )-- kmsKeyId = createKeyResult.KeyMetadata!.KeyId!-- await kmsClient.send(- new CreateAliasCommand({- AliasName: KMS_KEY_ALIAS,- TargetKeyId: kmsKeyId,- })- )- }-async function setupDynamoDBTable(): Promise<void> {try {await dynamoDBClient.send(new DeleteTableCommand({ TableName: KEYS_TABLE_NAME }))await waitForTableDeletion()} catch {- // Best-effort cleanup: table absence and Localstack's modeled errors vary in CI.+ // Best-effort cleanup: the table is usually absent, and how that surfaces varies.}await dynamoDBClient.send(@@ -545,18 +506,13 @@ describe('Recording API encryption integration', () => {beforeAll(async () => {dynamoDBClient = new DynamoDBClient({- endpoint: LOCALSTACK_ENDPOINT,+ endpoint: DYNAMODB_ENDPOINT,region: 'us-east-1',credentials: { accessKeyId: 'test', secretAccessKey: 'test' },})- kmsClient = new KMSClient({- endpoint: LOCALSTACK_ENDPOINT,- region: 'us-east-1',- credentials: { accessKeyId: 'test', secretAccessKey: 'test' },- })+ kmsClient = await createStubKmsClient()- await setupKmsKey()await setupDynamoDBTable()}, 30000)@@ -567,12 +523,6 @@ describe('Recording API encryption integration', () => {// Ignore}- try {- await kmsClient.send(new DeleteAliasCommand({ AliasName: KMS_KEY_ALIAS }))- } catch {- // Ignore- }-dynamoDBClient.destroy()kmsClient.destroy()})@@ -588,15 +538,11 @@ describe('Recording API encryption integration', () => {await decryptor.start()})- runEncryptionTests(- () => keyStore,- () => encryptor,- () => decryptor- )-+ // The encryption contract itself is a property of the encryptor, not of the keystore, so it+ // runs once against MemoryKeyStore above. What follows is only what DynamoDB decides.describe('DynamoDBKeyStore specific', () => {- it('should generate and retrieve an encrypted key via KMS', async () => {- const sessionId = `kms-test-${Date.now()}`+ it('should round-trip a wrapped key through DynamoDB', async () => {+ const sessionId = `wrapped-key-${Date.now()}`const teamId = 1const generatedKey = await keyStore.generateKey(sessionId, teamId, 30)@@ -612,16 +558,58 @@ describe('Recording API encryption integration', () => {expect(retrievedKey.encryptedKey.equals(generatedKey.encryptedKey)).toBe(true)})+ it('should return the existing key instead of overwriting on a second generate', async () => {+ const sessionId = `regenerate-${Date.now()}`+ const teamId = 50++ const firstKey = await keyStore.generateKey(sessionId, teamId, 30)+ const secondKey = await keyStore.generateKey(sessionId, teamId, 30)++ expect(secondKey.sessionState).toBe('ciphertext')+ expect(secondKey.plaintextKey.equals(firstKey.plaintextKey)).toBe(true)+ expect(secondKey.encryptedKey.equals(firstKey.encryptedKey)).toBe(true)+ })++ it('should not resurrect a shredded session on regenerate', async () => {+ const sessionId = `shredded-regenerate-${Date.now()}`+ const teamId = 60++ await keyStore.generateKey(sessionId, teamId, 30)+ await keyStore.deleteKey(sessionId, teamId, '[email protected]')++ const regenerated = await keyStore.generateKey(sessionId, teamId, 30)+ expect(regenerated.sessionState).toBe('deleted')++ const tombstone = await keyStore.getKey(sessionId, teamId)+ expect(tombstone.sessionState).toBe('deleted')+ })+it('should return already_deleted when deleting already deleted key', async () => {const sessionId = `double-delete-${Date.now()}`const teamId = 4await keyStore.generateKey(sessionId, teamId, 30)+ const beforeDelete = Math.floor(Date.now() / 1000)await keyStore.deleteKey(sessionId, teamId, '[email protected]')+ const afterDelete = Math.floor(Date.now() / 1000) + 1const result = await keyStore.deleteKey(sessionId, teamId, '[email protected]')expect(result.status).toBe('already_deleted')- expect(result.deletedAt).toBeDefined()+ expect(result.deletedAt).toBeGreaterThanOrEqual(beforeDelete)+ expect(result.deletedAt).toBeLessThanOrEqual(afterDelete)+ })++ it('should write a tombstone when deleting a session that has no key', async () => {+ const sessionId = `never-generated-${Date.now()}`++ const result = await keyStore.deleteKey(sessionId, 999, '[email protected]')+ expect(result.status).toBe('deleted')++ // Reading it back is the half that catches a tombstone DynamoDB accepted but+ // getKey cannot parse, which serves a 500 instead of a 410 for a deleted session.+ const tombstone = await keyStore.getKey(sessionId, 999)+ expect(tombstone.sessionState).toBe('deleted')+ expect(tombstone.deletedAt).toBe(result.deletedAt)})it('should isolate keys between teams', async () => {@@ -662,31 +650,25 @@ describe('Recording API encryption integration', () => {describe('S3 + decryption pipeline', () => {let s3Client: S3Clientlet recordingService: RecordingService- const S3_BUCKET = 'test-recording-bucket'- const S3_PREFIX = 'session_recordings'- beforeAll(async () => {+ beforeAll(() => {s3Client = new S3Client({- endpoint: LOCALSTACK_ENDPOINT,+ endpoint: S3_ENDPOINT,region: 'us-east-1',- credentials: { accessKeyId: 'test', secretAccessKey: 'test' },+ credentials: S3_CREDENTIALS,forcePathStyle: true,})-- try {- await s3Client.send(new CreateBucketCommand({ Bucket: S3_BUCKET }))- } catch {- // Bucket may already exist- }- }, 30000)+ })afterAll(async () => {try {- const objects = await s3Client.send(new ListObjectsV2Command({ Bucket: S3_BUCKET }))+ // The bucket is shared with the rest of the dev stack, so clean by prefix.+ const objects = await s3Client.send(+ new ListObjectsV2Command({ Bucket: S3_BUCKET, Prefix: S3_PREFIX })+ )for (const obj of objects.Contents ?? []) {await s3Client.send(new DeleteObjectCommand({ Bucket: S3_BUCKET, Key: obj.Key }))}- await s3Client.send(new DeleteBucketCommand({ Bucket: S3_BUCKET }))} catch {// Ignore cleanup errors}diff --git a/nodejs/tests/session-replay/recording-api/stub-kms-client.ts b/nodejs/tests/session-replay/recording-api/stub-kms-client.tsnew file mode 100644index 000000000000..b06fca528474--- /dev/null+++ b/nodejs/tests/session-replay/recording-api/stub-kms-client.ts@@ -0,0 +1,105 @@+import {+ DecryptCommand,+ DecryptCommandOutput,+ GenerateDataKeyCommand,+ GenerateDataKeyCommandOutput,+ KMSClient,+ NotFoundException,+} from '@aws-sdk/client-kms'+import sodium from 'libsodium-wrappers'++/** The alias DynamoDBKeyStore asks for. Anything else is a bug the stub has to fail on, as KMS would. */+const MASTER_KEY_ALIAS = 'alias/session-replay-master-key'++/**+ * KMS compares the encryption context as a map, so the serialization has to be injective.+ * Joining `k=v` pairs is not: `{a: 'b&c=d'}` and `{a: 'b', c: 'd'}` produce the same string.+ * Real KMS also rejects non-string values, so the stub checks at runtime rather than trusting+ * the compile-time type, which a cast can bypass.+ */+const toAdditionalData = (context: Record<string, string> | undefined): Uint8Array => {+ const entries = Object.entries(context ?? {})+ for (const [key, value] of entries) {+ if (typeof value !== 'string') {+ throw new Error(`EncryptionContext values must be strings, got ${typeof value} for '${key}'`)+ }+ }+ return new TextEncoder().encode(JSON.stringify(entries.sort(([left], [right]) => left.localeCompare(right))))+}++/**+ * In-process stand-in for KMS, covering the two commands DynamoDBKeyStore issues.+ *+ * Data keys are wrapped under a per-instance master key with the EncryptionContext as additional+ * authenticated data, so a Decrypt whose context does not match the GenerateDataKey that produced+ * the blob throws, the same way real KMS rejects it. Both commands also reject an unrecognized+ * KeyId, which is what catches a keystore that asks for an alias nobody provisioned, and+ * GenerateDataKey requires NumberOfBytes in KMS's 1 to 1024 range.+ *+ * The keystore only ever asks KMS to wrap and unwrap bytes, so running that against a local+ * emulator instead proves nothing extra about AWS while costing a container.+ */+export async function createStubKmsClient(): Promise<KMSClient> {+ await sodium.ready+ const masterKey = sodium.crypto_aead_xchacha20poly1305_ietf_keygen()+ const nonceBytes = sodium.crypto_aead_xchacha20poly1305_ietf_NPUBBYTES++ const respond = (+ command: GenerateDataKeyCommand | DecryptCommand+ ): GenerateDataKeyCommandOutput | DecryptCommandOutput => {+ const { KeyId } = command.input+ if (KeyId !== MASTER_KEY_ALIAS) {+ throw new NotFoundException({ $metadata: {}, message: `Alias ${KeyId} is not defined` })+ }++ if (command instanceof GenerateDataKeyCommand) {+ const { NumberOfBytes, EncryptionContext } = command.input+ if (NumberOfBytes === undefined || NumberOfBytes < 1 || NumberOfBytes > 1024) {+ throw new Error(`GenerateDataKey requires NumberOfBytes between 1 and 1024, got ${NumberOfBytes}`)+ }+ const plaintext = sodium.randombytes_buf(NumberOfBytes)+ const nonce = sodium.randombytes_buf(nonceBytes)+ const wrapped = sodium.crypto_aead_xchacha20poly1305_ietf_encrypt(+ plaintext,+ toAdditionalData(EncryptionContext),+ null,+ nonce,+ masterKey+ )+ return { $metadata: {}, Plaintext: plaintext, CiphertextBlob: Buffer.concat([nonce, wrapped]) }+ }++ if (command instanceof DecryptCommand) {+ const { CiphertextBlob, EncryptionContext } = command.input+ if (!CiphertextBlob) {+ throw new Error('DecryptCommand requires a CiphertextBlob')+ }+ const blob = Buffer.from(CiphertextBlob)+ return {+ $metadata: {},+ Plaintext: sodium.crypto_aead_xchacha20poly1305_ietf_decrypt(+ null,+ blob.subarray(nonceBytes),+ toAdditionalData(EncryptionContext),+ blob.subarray(0, nonceBytes),+ masterKey+ ),+ }+ }++ throw new Error('Stub KMS client received an unsupported command')+ }++ // The real send() is generically overloaded per command; the stub implements only the two the+ // keystore uses, so it is cast at this boundary rather than satisfying the full client type.+ return {+ send: (command: GenerateDataKeyCommand | DecryptCommand) => {+ try {+ return Promise.resolve(respond(command))+ } catch (error) {+ return Promise.reject(error)+ }+ },+ destroy: () => {},+ } as unknown as KMSClient+}diff --git a/rust/capture/src/s3_client.rs b/rust/capture/src/s3_client.rsindex 7e38a793b6c0..f2748c3c3733 100644--- a/rust/capture/src/s3_client.rs+++ b/rust/capture/src/s3_client.rs@@ -64,7 +64,7 @@ impl S3Client {let mut s3_config_builder = aws_sdk_s3::config::Builder::from(&aws_config).region(region)- .force_path_style(true); // Required for MinIO/localstack compatibility+ .force_path_style(true); // Required for SeaweedFS compatibilityif let Some(endpoint) = &config.endpoint {s3_config_builder = s3_config_builder.endpoint_url(endpoint);diff --git a/tools/hogli-commands/hogli_commands/devenv/generator.py b/tools/hogli-commands/hogli_commands/devenv/generator.pyindex 10870c5851ad..4543ea0b30f8 100644--- a/tools/hogli-commands/hogli_commands/devenv/generator.py+++ b/tools/hogli-commands/hogli_commands/devenv/generator.py@@ -102,7 +102,7 @@ def _build_docker_compose_shell(profiles: list[str]) -> str:# recording-rasterizer wait on `temporal`; personhog-etcd-init docker-execs# into `etcd`; session replay needs `replay`) — this reproduces master's# unprofiled `docker-compose.dev.yml` service set exactly.-_STATIC_MPROCS_PROFILES = ["dev_tools", "etcd", "localstack", "observability", "replay", "temporal"]+_STATIC_MPROCS_PROFILES = ["dev_tools", "dynamodb", "etcd", "observability", "replay", "temporal"]def build_static_docker_compose_shell() -> str: