{
  "assessment_id": "opus-gtme-clay-webhook-v1",
  "title": "GTM Engineer Work Sample: Clay Waterfall, Webhook Dedupe, and HubSpot Routing",
  "version": "1.0.0",
  "license": "CC-BY-4.0",
  "time_budget_minutes": 60,
  "permitted_tools": [
    "Any local script language (Python, Node.js, jq)",
    "Clay sandbox or local webhook simulator",
    "AI coding assistants if declared and explained during review"
  ],
  "scenario": {
    "company": "Northstar Ledger (Fictional B2B SaaS)",
    "problem": "Inbound product signups and enrichment webhook retries are creating duplicate HubSpot contacts, overwriting manual AE notes, and burning paid enrichment credits on freemail and already-enriched domains.",
    "requirements": [
      "Normalize email and root domain before calling any enrichment provider.",
      "Enforce idempotency using event_id and a 24-hour domain cache so duplicate webhook retries do not spend enrichment credits.",
      "Skip company enrichment for personal freemail domains (gmail.com, yahoo.com, outlook.com) and route them to self_serve_nurture.",
      "Implement a 2-step waterfall: check internal_cache first, then provider_a, then provider_b only if employee_count or industry is still null.",
      "Never overwrite non-null manual_ae_notes or existing customer lifecycle stages in HubSpot.",
      "Route qualified enterprise accounts (employee_count >= 250 and country in US/CA) to enterprise_pod, mid-market (50-249) to growth_pod, and send malformed payloads to dead_letter_queue."
    ]
  },
  "incoming_webhook_events": [
    {
      "event_id": "evt_9001",
      "received_at": "2026-10-14T14:02:11Z",
      "source": "product_signup",
      "payload": {
        "email": " Elena.Vargas@AcmeLogistics.com ",
        "full_name": "Elena Vargas",
        "company_input": "Acme Logistics Inc",
        "utm_campaign": "q4_erp_sync"
      }
    },
    {
      "event_id": "evt_9001",
      "received_at": "2026-10-14T14:02:14Z",
      "source": "product_signup_retry",
      "payload": {
        "email": "elena.vargas@acmelogistics.com",
        "full_name": "Elena Vargas",
        "company_input": "Acme Logistics Inc",
        "utm_campaign": "q4_erp_sync"
      }
    },
    {
      "event_id": "evt_9002",
      "received_at": "2026-10-14T14:05:00Z",
      "source": "product_signup",
      "payload": {
        "email": "marcus.chen88@gmail.com",
        "full_name": "Marcus Chen",
        "company_input": "",
        "utm_campaign": "organic_docs"
      }
    },
    {
      "event_id": "evt_9003",
      "received_at": "2026-10-14T14:09:42Z",
      "source": "demo_request",
      "payload": {
        "email": "d.okafor@harborhealth.io",
        "full_name": "David Okafor",
        "company_input": "Harbor Health",
        "utm_campaign": "enterprise_search"
      }
    },
    {
      "event_id": "evt_9004",
      "received_at": "2026-10-14T14:12:19Z",
      "source": "demo_request",
      "payload": {
        "email": "sara.lindqvist@nordicpay.se",
        "full_name": "Sara Lindqvist",
        "company_input": "NordicPay AB",
        "utm_campaign": "paid_linkedin"
      }
    },
    {
      "event_id": "evt_9005",
      "received_at": "2026-10-14T14:15:33Z",
      "source": "partner_referral",
      "payload": {
        "email": "not-an-email",
        "full_name": "Missing Email Record",
        "company_input": "Unknown",
        "utm_campaign": "partner_portal"
      }
    },
    {
      "event_id": "evt_9006",
      "received_at": "2026-10-14T14:18:05Z",
      "source": "product_signup",
      "payload": {
        "email": "priya.nair@acmelogistics.com",
        "full_name": "Priya Nair",
        "company_input": "Acme Logistics",
        "utm_campaign": "q4_erp_sync"
      }
    }
  ],
  "existing_hubspot_records": [
    {
      "hubspot_id": "hs_44102",
      "email": "d.okafor@harborhealth.io",
      "lifecycle_stage": "customer",
      "manual_ae_notes": "Active annual contract through Dec 2027. Do not re-route.",
      "owner_pod": "account_management"
    }
  ],
  "mock_enrichment_responses": {
    "provider_a": {
      "acmelogistics.com": {
        "employee_count": 410,
        "industry": "Supply Chain",
        "country": "US",
        "credit_cost": 1
      },
      "harborhealth.io": {
        "employee_count": 820,
        "industry": null,
        "country": "US",
        "credit_cost": 1
      },
      "nordicpay.se": {
        "employee_count": 190,
        "industry": "Fintech",
        "country": "SE",
        "credit_cost": 1
      }
    },
    "provider_b": {
      "harborhealth.io": {
        "employee_count": 820,
        "industry": "Healthcare Technology",
        "country": "US",
        "credit_cost": 3
      }
    }
  },
  "expected_outputs_summary": {
    "evt_9001_first": "Normalize email/domain, enrich via provider_a (1 credit), cache acmelogistics.com, route to enterprise_pod.",
    "evt_9001_retry": "Drop as idempotent duplicate (0 credits, 0 CRM writes).",
    "evt_9002": "Freemail detected, skip paid enrichment (0 credits), route to self_serve_nurture.",
    "evt_9003": "Existing customer detected. Preserve lifecycle_stage=customer and manual_ae_notes; do not re-route to enterprise_pod; optionally log expansion signal.",
    "evt_9004": "Enrich via provider_a (1 credit). Country is SE (outside US/CA routing rule): flag for emea_review or unassigned queue rather than silently assigning to US pod.",
    "evt_9005": "Invalid email format: route to dead_letter_queue with structured validation error (0 credits).",
    "evt_9006": "Hit 24-hour domain cache for acmelogistics.com (0 additional credits), create contact under enterprise_pod."
  },
  "rubric": [
    {
      "dimension": "Idempotency & Credit Hygiene",
      "strong": "Deduplicates evt_9001 retry by event_id, caches acmelogistics.com for evt_9006, skips freemail, and spends at most 2-3 total credits across all 7 events.",
      "weak": "Calls enrichment on every incoming event or fails to handle retry bursts."
    },
    {
      "dimension": "CRM Write Safety",
      "strong": "Checks existing HubSpot state before write, preserves customer lifecycle_stage and manual_ae_notes on hs_44102, and isolates bad payloads to a DLQ.",
      "weak": "Uses blind upsert that overwrites manual notes or downgrades customer to MQL."
    },
    {
      "dimension": "Ambiguity Handling (Non-US Routing)",
      "strong": "Flags nordicpay.se (SE) explicitly as outside stated US/CA rules instead of silently dropping or misrouting to growth_pod.",
      "weak": "Silently routes SE lead to a US rep or crashes on unexpected country code."
    }
  ]
}
