{
  "id": "set-campaign-canary-20-contacts",
  "title": "Workflow Set Campaign performance — 20 contacts",
  "kind": "hubspot_sync",
  "linkedIssues": [
    4739,
    5667
  ],
  "allowedTargetEnvironments": [
    "staging",
    "test1",
    "test2",
    "test3"
  ],
  "optional": true,
  "optionalReason": "Excluded from functionality acceptance; required in the Set Campaign performance suite.",
  "performanceContract": {
    "schemaVersion": "hubspot-set-campaign-performance/v1",
    "profile": "set_campaign_20_contacts",
    "acceptanceScope": "set_campaign_performance_claim",
    "expectation": "must_pass",
    "releaseBlocking": true,
    "correctnessRequired": true,
    "fullSuitePolicy": "dedicated_only",
    "nonPassPolicy": "fails_required_performance_acceptance"
  },
  "executionMode": "serial",
  "executionModeReason": "The case owns one isolated 20-contact cohort and one fresh Campaign; no other case may share its queue boundary.",
  "requiresHubSpotSandboxPreflight": true,
  "caseTimeoutMs": 900000,
  "caseGroups": [
    "hubspot-performance",
    "set-campaign-performance",
    "set-campaign-canary-20-contacts"
  ],
  "provenance": {
    "businessScenario": "SET-CAMPAIGN-CANARY-20-CONTACTS exercises the corrected Set Campaign sequence with exactly 20 contacts. It creates one unique HubSpot cohort, waits for one cohort Lead to materialize, submits one signed workflow action per contact at concurrency 4, and reconciles all 53 source properties and all 17 skip-if-set property histories through the authoritative inbound mapping to all 51 persisted Lead fields for every returned provider identity. The two projection-only Salesforce routing hints must also select that Lead rather than a Contact. It requires exactly one active Lead, finalized authorship, one Sent CampaignMember, and one completed Runtime command per identity. The complete source, destination, mapping, and durability snapshot must remain unchanged for 60 seconds; an omitted source property or history, ambiguous history, mapping drift, active Contact projection, missing or duplicate row, field mismatch, failed/nonterminal work, or late arrival fails the case.",
    "reportedBy": "#5667 queue recovery and fixed canary",
    "capturedAt": "2026-09-01",
    "calibrated": "The workload is fixed. In Staging run 33997497645, all 20 actions were admitted and attributed, but the 60-second deep-consistency poll stopped at 17/20 at 23:12:40.980 UTC; the remaining four mapped fields on three records were present after writes at 23:18:09-15, about seven minutes after the case began at 23:11:00.657. The 100-contact case in that run needed 269.770 seconds for deep consistency, followed by a 63.372-second stability step. The 20-contact consistency poll now has a 10-minute maximum and its case ceiling is 15 minutes, including all earlier phases and the unchanged 60-second stability delay and final snapshot. The existing case deadline caps the whole execution, and the performance suite still shares 43 minutes. Slow earlier phases consume the same case budget. Exhaustion still fails; no exact cohort, source-history, deep-equivalence, durability, or stable-fingerprint assertion is weakened. Historical late field presence is not proof that this changed case passes."
  },
  "steps": [
    {
      "id": "s0-create-campaign",
      "system": "nexuscrm",
      "authRole": "admin",
      "method": "POST",
      "path": "/services/data/v63.0/sobjects/Campaign",
      "body": {
        "Name": "IT Set Campaign 20 {{__runId}}",
        "IsActive": true
      },
      "expectStatusRange": [
        200,
        299
      ],
      "assertions": [
        {
          "path": "response.body.id",
          "exists": true
        }
      ]
    },
    {
      "id": "s1-create-contacts",
      "system": "hubspot",
      "method": "POST",
      "path": "/crm/v3/objects/contacts/batch/create",
      "generate": {
        "count": 20,
        "batchSize": 100,
        "aggregateResponse": true,
        "into": "inputs",
        "itemTemplate": {
          "properties": {
            "email": "setcampaign20-{{__runId}}-{{i}}@example.com",
            "firstname": "KCamp10",
            "lastname": "Bulk-{{i}}",
            "lifecyclestage": "lead"
          }
        }
      },
      "expectStatusRange": [
        200,
        299
      ],
      "assertions": [
        {
          "path": "response.body.batchCount",
          "numericEquals": 1
        },
        {
          "path": "response.body.failedBatchCount",
          "numericEquals": 0
        },
        {
          "path": "response.body.resultCount",
          "numericEquals": 20
        }
      ]
    },
    {
      "id": "s1a-first-lead-materialized",
      "system": "nexuscrm",
      "authRole": "admin",
      "method": "GET",
      "path": "/services/data/v63.0/query?q=SELECT Id,HubSpot_Id__c,Email FROM Lead WHERE HubSpot_Id__c IN ('{{steps.s1-create-contacts.response.body.results[0].id}}','{{steps.s1-create-contacts.response.body.results[1].id}}','{{steps.s1-create-contacts.response.body.results[2].id}}','{{steps.s1-create-contacts.response.body.results[3].id}}','{{steps.s1-create-contacts.response.body.results[4].id}}','{{steps.s1-create-contacts.response.body.results[5].id}}','{{steps.s1-create-contacts.response.body.results[6].id}}','{{steps.s1-create-contacts.response.body.results[7].id}}','{{steps.s1-create-contacts.response.body.results[8].id}}','{{steps.s1-create-contacts.response.body.results[9].id}}','{{steps.s1-create-contacts.response.body.results[10].id}}','{{steps.s1-create-contacts.response.body.results[11].id}}','{{steps.s1-create-contacts.response.body.results[12].id}}','{{steps.s1-create-contacts.response.body.results[13].id}}','{{steps.s1-create-contacts.response.body.results[14].id}}','{{steps.s1-create-contacts.response.body.results[15].id}}','{{steps.s1-create-contacts.response.body.results[16].id}}','{{steps.s1-create-contacts.response.body.results[17].id}}','{{steps.s1-create-contacts.response.body.results[18].id}}','{{steps.s1-create-contacts.response.body.results[19].id}}') AND IsConverted=false LIMIT 1",
      "expectStatus": 200,
      "poll": {
        "budgetMs": 120000,
        "intervalMs": 10000
      },
      "onTimeout": "fail",
      "assertions": [
        {
          "path": "response.body.records",
          "lengthAtLeast": 1
        },
        {
          "path": "response.body.records[0].HubSpot_Id__c",
          "exists": true
        },
        {
          "path": "response.body.records[0].Email",
          "exists": true
        }
      ]
    },
    {
      "id": "s2-set-campaign",
      "system": "connector_action",
      "path": "/webhooks/hubspot-crm-connector/workflow-action",
      "forEach": "steps.s1-create-contacts.response.body.results",
      "contactIdField": "id",
      "emailField": "properties.email",
      "campaignId": "{{steps.s0-create-campaign.response.body.id}}",
      "status": "Sent",
      "callbackIdPrefix": "set-campaign-canary-20",
      "concurrency": 4,
      "maxCaseElapsedMs": 240000,
      "assertions": [
        {
          "path": "response.body.failedCount",
          "numericEquals": 0
        },
        {
          "path": "response.body.acceptedCount",
          "numericEquals": 20
        }
      ]
    },
    {
      "id": "s3-lead-attribution-count",
      "system": "nexuscrm",
      "authRole": "admin",
      "method": "GET",
      "path": "/services/data/v63.0/query?q=SELECT COUNT() FROM Lead WHERE Id IN (SELECT LeadId FROM CampaignMember WHERE CampaignId='{{steps.s0-create-campaign.response.body.id}}' AND Status='Sent') AND First_Campaign__c='{{steps.s0-create-campaign.response.body.id}}' AND Last_Campaign__c='{{steps.s0-create-campaign.response.body.id}}'",
      "expectStatus": 200,
      "poll": {
        "budgetMs": 300000,
        "intervalMs": 30000
      },
      "onTimeout": "fail",
      "assertions": [
        {
          "path": "response.body.totalSize",
          "atLeast": 20
        }
      ]
    },
    {
      "id": "s4-exact-cohort",
      "system": "set_campaign_consistency",
      "actionStepId": "s2-set-campaign",
      "expectedCount": 20,
      "timeoutMs": 60000,
      "expectStatus": 200,
      "poll": {
        "budgetMs": 600000,
        "intervalMs": 10000
      },
      "onTimeout": "fail",
      "assertions": [
        { "path": "response.body.consistent", "equals": true },
        { "path": "response.body.expectedCount", "numericEquals": 20 },
        { "path": "response.body.providerCount", "numericEquals": 20 },
        { "path": "response.body.providerBatchCount", "numericEquals": 1 },
        { "path": "response.body.mappingSourcePropertyCount", "numericEquals": 53 },
        { "path": "response.body.expectedSourcePropertyCount", "numericEquals": 1060 },
        { "path": "response.body.verifiedSourcePropertyCount", "numericEquals": 1060 },
        { "path": "response.body.sourcePropertyMissingCount", "numericEquals": 0 },
        { "path": "response.body.skipIfSetSourcePropertyCount", "numericEquals": 17 },
        { "path": "response.body.expectedSourceHistoryFieldCount", "numericEquals": 340 },
        { "path": "response.body.verifiedSourceHistoryFieldCount", "numericEquals": 340 },
        { "path": "response.body.sourceHistoryMismatchCount", "numericEquals": 0 },
        { "path": "response.body.mappingFieldCount", "numericEquals": 51 },
        { "path": "response.body.mappingProjectionOnlyCount", "numericEquals": 2 },
        { "path": "response.body.expectedProjectionOnlyCellCount", "numericEquals": 40 },
        { "path": "response.body.verifiedProjectionOnlyCellCount", "numericEquals": 40 },
        { "path": "response.body.projectionOnlyMismatchCount", "numericEquals": 0 },
        { "path": "response.body.deployedMappingCount", "numericEquals": 53 },
        { "path": "response.body.mappingContractMismatchCount", "numericEquals": 0 },
        { "path": "response.body.expectedMappedCellCount", "numericEquals": 1020 },
        { "path": "response.body.mappedCellCount", "numericEquals": 1020 },
        { "path": "response.body.matchedMappedCellCount", "numericEquals": 1020 },
        { "path": "response.body.deepMismatchCount", "numericEquals": 0 },
        { "path": "response.body.fullyEquivalentRecordCount", "numericEquals": 20 },
        { "path": "response.body.leadCount", "numericEquals": 20 },
        { "path": "response.body.contactCount", "numericEquals": 0 },
        { "path": "response.body.campaignMemberCount", "numericEquals": 20 },
        { "path": "response.body.authorshipCount", "numericEquals": 20 },
        { "path": "response.body.terminalEventCount", "numericEquals": 20 },
        { "path": "response.body.mismatchCount", "numericEquals": 0 }
      ]
    },
    {
      "id": "s5-stable-exact-cohort",
      "system": "set_campaign_consistency",
      "actionStepId": "s2-set-campaign",
      "expectedCount": 20,
      "delayMs": 60000,
      "timeoutMs": 60000,
      "expectStatus": 200,
      "assertions": [
        { "path": "response.body.consistent", "equals": true },
        { "path": "response.body.expectedCount", "numericEquals": 20 },
        { "path": "response.body.providerCount", "numericEquals": 20 },
        { "path": "response.body.providerBatchCount", "numericEquals": 1 },
        { "path": "response.body.mappingSourcePropertyCount", "numericEquals": 53 },
        { "path": "response.body.expectedSourcePropertyCount", "numericEquals": 1060 },
        { "path": "response.body.verifiedSourcePropertyCount", "numericEquals": 1060 },
        { "path": "response.body.sourcePropertyMissingCount", "numericEquals": 0 },
        { "path": "response.body.skipIfSetSourcePropertyCount", "numericEquals": 17 },
        { "path": "response.body.expectedSourceHistoryFieldCount", "numericEquals": 340 },
        { "path": "response.body.verifiedSourceHistoryFieldCount", "numericEquals": 340 },
        { "path": "response.body.sourceHistoryMismatchCount", "numericEquals": 0 },
        { "path": "response.body.mappingFieldCount", "numericEquals": 51 },
        { "path": "response.body.mappingProjectionOnlyCount", "numericEquals": 2 },
        { "path": "response.body.expectedProjectionOnlyCellCount", "numericEquals": 40 },
        { "path": "response.body.verifiedProjectionOnlyCellCount", "numericEquals": 40 },
        { "path": "response.body.projectionOnlyMismatchCount", "numericEquals": 0 },
        { "path": "response.body.deployedMappingCount", "numericEquals": 53 },
        { "path": "response.body.mappingContractMismatchCount", "numericEquals": 0 },
        { "path": "response.body.expectedMappedCellCount", "numericEquals": 1020 },
        { "path": "response.body.mappedCellCount", "numericEquals": 1020 },
        { "path": "response.body.matchedMappedCellCount", "numericEquals": 1020 },
        { "path": "response.body.deepMismatchCount", "numericEquals": 0 },
        { "path": "response.body.fullyEquivalentRecordCount", "numericEquals": 20 },
        { "path": "response.body.leadCount", "numericEquals": 20 },
        { "path": "response.body.contactCount", "numericEquals": 0 },
        { "path": "response.body.campaignMemberCount", "numericEquals": 20 },
        { "path": "response.body.authorshipCount", "numericEquals": 20 },
        { "path": "response.body.terminalEventCount", "numericEquals": 20 },
        { "path": "response.body.mismatchCount", "numericEquals": 0 },
        { "path": "response.body.snapshotFingerprint", "equals": "{{steps.s4-exact-cohort.response.body.snapshotFingerprint}}" }
      ]
    }
  ]
}
