# ---------------------------------------------------------------------------
# Open Data Contract Standard (ODCS) - v3.0.0
# Bitol / Linux Foundation AI & Data
# ---------------------------------------------------------------------------
# Sanitized work sample. Illustrates how an interface between a data producer
# and its consumers is governed as an explicit, version-controlled contract:
# schema, semantics, data quality, SLAs and ownership in one place.
# ---------------------------------------------------------------------------

apiVersion: v3.0.0
kind: DataContract
id: customer-master-apac
status: active
name: Customer Master (APAC)
version: 1.2.0

# --- Description & semantics -------------------------------------------------
description:
  purpose: >
    Single trusted view of the APAC Wealth Management client, consumed by
    client reporting, risk aggregation and regulatory submissions.
  usage: Master reference for any process that needs the agreed client record.
  limitations: Not for marketing use; contains Confidential data.

domain: customer
tenant: apac-wealth-management
dataProduct: customer-master

# --- Ownership ---------------------------------------------------------------
team:
  - role: owner
    description: Head of Client Data, APAC
  - role: steward
    description: Customer Data Steward
  - role: custodian
    description: Client Master Platform (IT)

# --- Physical binding --------------------------------------------------------
servers:
  - server: prod
    type: snowflake
    database: CLIENT_MASTER
    schema: CURATED
    dataset: DIM_CUSTOMER

# --- Schema ------------------------------------------------------------------
schema:
  - name: customer
    logicalType: object
    physicalName: DIM_CUSTOMER
    description: One row per mastered client (golden record).
    properties:
      - name: customer_id
        logicalType: string
        physicalType: VARCHAR(18)
        description: Surrogate golden-record key.
        required: true
        unique: true
        classification: Confidential
      - name: legal_name
        logicalType: string
        physicalType: VARCHAR(200)
        required: true
        classification: Confidential
      - name: email
        logicalType: string
        physicalType: VARCHAR(254)
        description: Must match RFC 5322 format.
        required: false
      - name: domicile_country
        logicalType: string
        physicalType: CHAR(2)
        description: ISO 3166-1 alpha-2 country code.
        required: true
      - name: record_source
        logicalType: string
        description: Lineage - originating system of the surviving value.
        required: true
      - name: load_ts
        logicalType: date
        description: UTC load timestamp.
        required: true

# --- Data quality (the rules, not the code) ----------------------------------
quality:
  - property: customer_id
    rule: completeness
    mustBe: 100
    unit: percent
    severity: critical
    dimension: completeness
  - property: customer_id
    rule: uniqueness
    mustBe: 100
    unit: percent
    severity: critical
    dimension: uniqueness
  - property: email
    rule: validFormat
    pattern: "^[^@\\s]+@[^@\\s]+\\.[^@\\s]+$"
    mustBeGreaterThan: 98
    unit: percent
    severity: high
    dimension: validity
  - property: domicile_country
    rule: validValues
    reference: iso-3166-1-alpha-2
    severity: high
    dimension: validity

# --- Service levels ----------------------------------------------------------
slaProperties:
  - property: freshness
    value: 24
    unit: hours
    description: Maximum age of the data after the daily load.
  - property: availability
    value: 99.5
    unit: percent
  - property: retention
    value: 7
    unit: years

# --- Interoperability --------------------------------------------------------
support:
  standards:
    - ISO 3166-1   # country codes
    - RFC 5322     # email format
  exchangeFormats:
    - FpML         # product & counterparty interchange
  catalog: OpenMetadata
