version: 1

# Example BigQuery extract source (ADR 0017): the source-system axis of ingestion, keyed on
# BigQuery. This stage introspects BigQuery INFORMATION_SCHEMA, `bq extract`s each selected
# table to Parquet in a GCS bucket we own, and owns the GCS-snapshot `source` contract for
# the objects it writes (ADR 0015 — the producer owns the contract), even though the upstream
# BigQuery table is externally managed.
#
# This is the extract-then-load shape, distinct from gcs_bulk_load's external-incremental mode
# (ADR 0018), which loads a pre-existing bucket we do NOT extract. Fill in the project, dataset,
# and bucket, run `setup/grunt/<source>` to provision the bucket + reader SA (see setup/README.md),
# then: generate-contracts -> extract-run, and load the resulting manifest with gcs_bulk_load.
#
# `bq`/`gcloud` authenticate via ambient gcloud auth (GOOGLE_OAUTH_ACCESS_TOKEN or ADC); there is
# no DSN to store. The generated `source` contracts land under contracts/generated/ and are
# reviewed/committed — they are not committed here because they require live introspection.

source:
  name: metadb
  # The Google Cloud project + dataset that own the source tables.
  project: REPLACE-WITH-GCP-PROJECT
  dataset: metadb_new
  domain: billing
  owner: data-platform
  secrets_file: secrets.env
  # Columns the engine treats as change watermarks when present on a table.
  # Source-specific convention — declared here, not in engine code.
  watermark_candidates:
    - updated_at
    - created_at
  # BigQuery enforces no primary keys, so the snapshot source declares them per table;
  # the loader needs a key for raw-snapshot dedup detection (ADR 0017).
  primary_keys:
    billing2_invoices: [id]

tables:
  include:
    - billing2_invoices
  exclude: []
  # Skip tables without a declared primary key (not snapshot-diffable / not contract-worthy).
  require_primary_key: true

gcs:
  # `bq extract` requires the export bucket to match the source dataset's location. These
  # names/prefixes/retention are the single source of truth: setup/grunt reads this block to
  # provision the bucket + its lifecycle.
  bucket: REPLACE-WITH-EXPORT-BUCKET
  location: US
  snapshot_prefix: snapshots/source=metadb
  manifest_prefix: manifests/source=metadb
  runtime_log_prefix: logs/source=metadb

export:
  compression: ZSTD

freshness:
  degraded_after_hours: 30
  blocked_after_hours: 48

retention:
  # GCS Parquet is transient — landed, COPY INTO raw, then expired; raw Cloud Lake is durable.
  gcs_snapshots_days: 7
  manifests_days: 365

governance:
  # Baseline classifications applied to every table in this source.
  classifications:
    - restricted
    - financial
    - customer_data
  # Column/table-name regex → classification. Source-specific governance rules; the engine
  # applies them generically, it does not hardcode them. Every label must be in the fixed
  # ADR-0011 governance set.
  classification_patterns:
    financial: "price|cost|invoice|payment|loss|amount|revenue|currency|billing|fee|charge"
    operational_sensitive: "token|secret|password|credential|payment_meta|payment_method|payment_code"

contracts:
  output_dir: contracts/generated
