---
id: ADR-CRM-DQ-019
title: Provide CRM-owned functions for portal registration
product_area: crm
module: data-quality
revision: 1
status: proposed
design_intent: proposed
source_sha:
  services-crm: a8d1364f1dd44b723bb5f9acba12f983e9ec8d69
decision: >-
  Platform registration reaches candidate selection and declined-suggestion
  creation through CRM-owned security-definer functions granted to the Platform
  application role.
constrains:
  - WF-CRM-DQ-008
  - SVC-CRM-DQ-duplicates
  - DOM-CRM-DQ-001
origin: >-
  services-crm:db/migrations/0077_portal_sign_up_contacts.sql (shared contract
  portal member sign-in, Andrew 2026-10-16); docs/merging/decisions.md#D1
  pattern
alternatives:
  - option: Call a separate CRM HTTP operation
    why_not: This adds another request boundary to registration.
  - option: Let Platform create CRM contacts directly
    why_not: Record writes would cross the owning application boundary.
consequences:
  - >-
    The SQL matching port has comparisons with the TypeScript scorer in CRM
    tests.
  - >-
    Portal matching does not consult workspace rules or their stored portal
    flag.
supersedes: []
evidence:
  - >-
    services-crm at a8d1364f: db/migrations/0077_portal_sign_up_contacts.sql;
    modules/duplicates/tests/integration/db/portal-sign-up-contacts.integration.spec.js.
---

# Provide CRM-owned functions for portal registration

## Context

Registration needs constrained access to contact matching and creation across the ownership boundary.

## Decision

Platform registration reaches candidate selection and declined-suggestion creation through CRM-owned security-definer functions granted to the Platform application role.

## Alternatives Considered

Call a separate CRM HTTP operation. This adds another request boundary to registration.

Let Platform create CRM contacts directly. Record writes would cross the owning application boundary.

## Consequences

The SQL matching port has comparisons with the TypeScript scorer in CRM tests. Portal matching does not consult workspace rules or their stored portal flag.
