Skip to content

feat: stamp recording consent provenance on conversation initiate - #1440

Open
JorimTheuns wants to merge 9 commits into
mainfrom
feat/conversation-consent-columns
Open

JorimTheuns wants to merge 9 commits into
mainfrom
feat/conversation-consent-columns

Conversation

@JorimTheuns

@JorimTheuns JorimTheuns commented Nov 30, 2026 •

Copy link
Copy Markdown
Member

Summary

Adds server-stamped recording consent columns to conversation so recording consent provenance is stored in Postgres alongside each conversation instead of only in PostHog events.

Stacked on feat/landscape-gate (#1438).

Changes

  1. Database migration (0061_expand_conversation_consent.sql):
    • Adds nullable consent_accepted_at timestamptz, consent_version varchar(32), and consent_basis varchar(32) columns to conversation in dembrane/platform/packages/db/src/schema/index.ts.
    • Uses a single idempotent ALTER TABLE "conversation" ADD COLUMN IF NOT EXISTS ... statement so no rows are rewritten and the hot table is locked once.
  2. Backend (dembrane/platform/packages/conversations/src/portal/):
    • Accepts an optional consent: { accepted: boolean; version: string } object (version 1 to 32 chars) in POST /api/participant/projects/:project_id/conversations/initiate, keeping older dembrane-go iOS clients backward-compatible.
    • Always stamps consent_basis from the server-derived effectiveLegalBasis (never client-supplied).
    • Stamps consent_accepted_at = now() and consent_version = consent.version when consent.accepted === true.
  3. Frontend (dembrane/frontend/src/portal/ and src/lib/api.ts):
    • Exports CONSENT_VERSION alongside the privacy card copy in onboardingCards.ts.
    • Tracks privacy card acceptance in ParticipantOnboardingCards and passes consent: { accepted: true, version: CONSENT_VERSION } to ParticipantInitiateForm for both manual submission and auto-start.
  4. Tests:
    • Backend unit and integration tests covering initiate with accepted consent, without consent, overlong version rejection, and server-derived consent_basis.
    • Frontend tests covering privacy card acceptance (with and without checkbox), skipped onboarding, ParticipantInitiateForm manual and auto-start forwarding, and initiateConversation API payloads.

Verification

  • bunx drizzle-kit generate drift check: No schema changes
  • dembrane/platform: bunx biome ci ., bun run typecheck, bun run config check, bun run packages check, bun test packages/conversations packages/db packages/verify (105 pass, 0 fail; DB integration tests run in CI with Postgres)
  • dembrane/frontend: node scripts/check-path-case.mjs, pnpm lint, pnpm exec tsc, pnpm messages:extract, pnpm messages:compile, node scripts/check-translations.mjs --strict, API contract sync checks, vitest run src/portal/ src/lib/api.interceptor.test.ts src/lib/participantToken.test.ts (29 files, 227 tests passed)

@JorimTheuns
JorimTheuns force-pushed the feat/conversation-consent-columns branch from e1a3871 to 68ac5c2 Compare November 30, 2026 12:31
@JorimTheuns
JorimTheuns changed the base branch from main to feat/landscape-gate November 30, 2026 12:31
@JorimTheuns
JorimTheuns force-pushed the feat/conversation-consent-columns branch from 68ac5c2 to 0333a8a Compare December 1, 2026 21:13
@JorimTheuns
JorimTheuns force-pushed the feat/conversation-consent-columns branch from 0333a8a to 43d0c63 Compare December 1, 2026 22:39
Base automatically changed from feat/landscape-gate to main December 2, 2026 13:56

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant