{
  "id": "fix-2784",
  "title": "Native Lead round-trip stays one Lead (no proliferation)",
  "kind": "hubspot_sync",
  "linkedIssues": [2784],
  "provenance": {
    "businessScenario": "FIX-2784 — re-prove #2784: a native Lead outbounds and, after the round-trip echo, the NX side still holds exactly one Lead (no proliferation). Create native Lead, poll HubSpot_Id__c writeback, settle 15s, then COUNT Leads by that HubSpot_Id. PASS (verbatim NEW runbook H FIX-2784): round-trip stays single. totalSize>=2 = FAIL (#2784 reproduced, round-trip proliferation); HubSpot_Id__c not written back = BLOCKED (outbound did not happen).",
    "reportedBy": "HubSpot sync spec FIX-2784 (hubspot-nexuscrm-sync-CASE-EXEC-SELFCONTAINED)",
    "capturedAt": "2026-06-18",
    "calibrated": "[calibrated] native Lead create carries required LastName/Company/Email; round-trip count assertion unchanged (depends on outbound writeback)."
  },
  "steps": [
    {
      "id": "create-lead",
      "system": "nexuscrm",
      "authRole": "admin",
      "method": "POST",
      "path": "/services/data/v63.0/sobjects/Lead",
      "body": { "LastName": "Fx2784-{{__runId}}", "Company": "C", "Email": "fx2784-{{__runId}}@example.com", "HubSpot_Sync_Enabled__c": true },
      "expectStatusRange": [200, 299],
      "assertions": [ { "path": "response.body.id", "exists": true } ]
    },
    {
      "id": "wait-hubspot-id",
      "system": "nexuscrm",
      "authRole": "admin",
      "method": "GET",
      "path": "/services/data/v63.0/query?q=SELECT HubSpot_Id__c FROM Lead WHERE Id='{{steps.create-lead.response.body.id}}' LIMIT 1",
      "expectStatus": 200,
      "poll": { "budgetMs": 90000, "intervalMs": 6000 },
      "onTimeout": "fail",
      "assertions": [ { "path": "response.body.records[0].HubSpot_Id__c", "exists": true } ]
    },
    {
      "id": "assert-count-one",
      "system": "nexuscrm",
      "authRole": "admin",
      "method": "GET",
      "path": "/services/data/v63.0/query?q=SELECT COUNT() FROM Lead WHERE HubSpot_Id__c='{{steps.wait-hubspot-id.response.body.records[0].HubSpot_Id__c}}'",
      "expectStatus": 200,
      "delayMs": 15000,
      "poll": { "budgetMs": 60000, "intervalMs": 6000 },
      "onTimeout": "fail",
      "assertions": [ { "path": "response.body.totalSize", "numericEquals": 1 } ]
    }
  ]
}
